1 subroutine da_put_var_3d_real_cdf(file, var, data, i1, i2, i3, time, debug)
3 !-----------------------------------------------------------------------
5 !-----------------------------------------------------------------------
11 integer, intent(in) :: i1, i2, i3, time
12 character (len=*), intent(in) :: file
13 logical, intent(in) :: debug
14 character (len=*), intent(in) :: var
15 real, intent(in) :: data(i1,i2,i3)
17 real(kind=8) :: tmp(i1,i2,i3)
18 real(kind=4) :: tmp4(i1,i2,i3)
20 integer :: cdfid, rcode, id_data
21 character (len=80) :: varnam
22 integer :: ndims, natts, idims(10), istart(10),iend(10), dimids(10)
26 ! if (trace_use) call da_trace_entry("da_put_var_3d_real_cdf")
28 cdfid = ncopn(file, NCWRITE, rcode)
31 write(unit=stdout, fmt='(2a)') ' error openiing netcdf file ', trim(file)
35 id_data = ncvid(cdfid, var, rcode)
37 rcode = nf_inq_var(cdfid, id_data, varnam, ivtype, ndims, dimids, natts)
40 write(unit=stdout, fmt='(3a,i6)') ' put_var_3d_real_cdf: dims for ',var,' ',ndims
44 rcode = nf_inq_dimlen(cdfid, dimids(i), idims(i))
45 if (debug) write(unit=stdout,fmt=*) ' dimension ',i,idims(i)
48 ! check the dimensions
50 if ((i1 /= idims(1)) .or. &
51 (i2 /= idims(2)) .or. &
52 (i3 /= idims(3)) .or. &
53 (time > idims(4)) ) then
55 write(unit=stdout,fmt=*) ' error in 3d_var_real read, dimension problem '
56 write(unit=stdout,fmt=*) i1, idims(1)
57 write(unit=stdout,fmt=*) i2, idims(2)
58 write(unit=stdout,fmt=*) i3, idims(3)
59 write(unit=stdout,fmt=*) time, idims(4)
60 write(unit=stdout,fmt=*) ' error stop '
75 if ((ivtype == NF_real) .and. (kind(data) == 4)) then
76 call ncvpt(cdfid,id_data,istart,iend,data,rcode)
77 else if ((ivtype == NF_DOUBLE) .and. (kind(data) == 8)) then
79 call ncvpt(cdfid,id_data,istart,iend,tmp,rcode)
80 else if ((ivtype == NF_DOUBLE) .and. (kind(data) == 4)) then
82 call ncvpt(cdfid,id_data,istart,iend,tmp,rcode)
83 else if ((ivtype == NF_REAL) .and. (kind(data) == 8)) then
85 call ncvpt(cdfid,id_data,istart,iend,tmp4,rcode)
87 write(unit=stdout, fmt='(a, 4i6)') &
88 'Unrecognizable ivtype:', ivtype,nf_double,nf_real,kind(data)
92 call ncclos(cdfid,rcode)
94 ! if (trace_use) call da_trace_exit("da_put_var_3d_real_cdf")
96 end subroutine da_put_var_3d_real_cdf