1 subroutine da_get_var_2d_real_cdf(file, var, data, i1, i2, time, debug)
3 !-----------------------------------------------------------------------
5 !-----------------------------------------------------------------------
11 integer, intent(in) :: i1, i2, time
12 character (len=*), intent(in) :: file
13 logical, intent(in) :: debug
14 character (len=*), intent(in) :: var
15 real, intent(out) :: data(i1,i2)
17 real(kind=8) :: tmp(i1,i2)
18 real(kind=4) :: tmp4(i1,i2)
19 integer :: cdfid, rcode, id_data
20 character (len=80) :: varnam
21 integer :: ndims, natts, idims(10), istart(10),iend(10), dimids(10)
24 ! if (trace_use) call da_trace_entry("da_get_var_2d_real_cdf")
26 cdfid = ncopn(file, NCNOWRIT, rcode)
29 write(unit=stdout, fmt='(2a)') ' error openiing netcdf file ', trim(file)
33 id_data = ncvid(cdfid, var, rcode)
35 rcode = nf_inq_var(cdfid, id_data, varnam, ivtype, ndims, dimids, natts)
38 write(unit=stdout, fmt='(3a,i6)') ' get_var_2d_real_cdf: dims for ',var,' ',ndims
42 rcode = nf_inq_dimlen(cdfid, dimids(i), idims(i))
44 write(unit=stdout, fmt='(a,2i6)') ' dimension ',i,idims(i)
45 write(unit=stdout, fmt='(a,i6)') ' ivtype=', ivtype
46 write(unit=stdout, fmt='(a, a)') ' varnam=', trim(varnam)
50 ! check the dimensions
52 if ((i1 /= idims(1)) .or. &
53 (i2 /= idims(2)) .or. &
54 (time > idims(3)) ) then
56 write(unit=stdout,fmt=*) ' error in 2d_var_real read, dimension problem '
57 write(unit=stdout,fmt=*) i1, idims(1)
58 write(unit=stdout,fmt=*) i2, idims(2)
59 write(unit=stdout,fmt=*) time, idims(3)
60 write(unit=stdout,fmt=*) ' error stop '
73 if ((ivtype == NF_real) .and. (kind(data) == 4)) then
74 call ncvgt(cdfid,id_data,istart,iend,data,rcode)
75 else if ((ivtype == NF_DOUBLE) .and. (kind(data) == 8)) then
76 call ncvgt(cdfid,id_data,istart,iend,data,rcode)
77 else if ((ivtype == NF_DOUBLE) .and. (kind(data) == 4)) then
78 call ncvgt(cdfid,id_data,istart,iend,tmp,rcode)
80 else if ((ivtype == NF_REAL) .and. (kind(data) == 8)) then
81 call ncvgt(cdfid,id_data,istart,iend,tmp4,rcode)
84 write(unit=stdout, fmt='(a, i6)') &
85 'Unrecognizable ivtype:', ivtype
90 write(unit=stdout, fmt='(a,e24.12)') ' Sample data=', data(1,1)
93 call ncclos(cdfid,rcode)
95 ! if (trace_use) call da_trace_exit("da_get_var_2d_real_cdf")
97 end subroutine da_get_var_2d_real_cdf