da_get_var_2d_int_cdf.inc
References to this file elsewhere.
1 subroutine da_get_var_2d_int_cdf(file, var, data, i1, i2, time, debug)
2
3 !-----------------------------------------------------------------------
4 ! Purpose: TBD
5 !-----------------------------------------------------------------------
6
7 implicit none
8
9 #include "netcdf.inc"
10
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 integer, intent(out) :: data(i1,i2)
16
17 integer :: cdfid, rcode, id_data
18 character (len=80) :: varnam
19 integer :: ndims, natts, idims(10), istart(10),iend(10), dimids(10)
20 integer :: i, ivtype
21
22 ! if (trace_use) call da_trace_entry("da_get_var_2d_int_cdf")
23
24 cdfid = ncopn(file, NCNOWRIT, rcode)
25
26 if (rcode /= 0) then
27 write(unit=stdout, fmt='(2a)') ' error opening netcdf file ', trim(file)
28 stop
29 end if
30
31 id_data = ncvid(cdfid, var, rcode)
32
33 rcode = nf_inq_var(cdfid, id_data, varnam, ivtype, ndims, dimids, natts)
34
35 if (debug) then
36 write(unit=stdout, fmt='(3a,i6)') ' get_var_2d_real_cdf: dims for ',var,' ',ndims
37 end if
38
39 do i=1,ndims
40 rcode = nf_inq_dimlen(cdfid, dimids(i), idims(i))
41 if (debug) then
42 write(unit=stdout, fmt='(a,2i6)') ' dimension ',i,idims(i)
43 write(unit=stdout, fmt='(a,i6)') ' ivtype=', ivtype
44 write(unit=stdout, fmt='(a, a)') ' varnam=', trim(varnam)
45 end if
46 end do
47
48 ! check the dimensions
49
50 if ((i1 /= idims(1)) .or. &
51 (i2 /= idims(2)) .or. &
52 (time > idims(3)) ) then
53
54 write(unit=stdout,fmt=*) ' error in 2d_var_real read, dimension problem '
55 write(unit=stdout,fmt=*) i1, idims(1)
56 write(unit=stdout,fmt=*) i2, idims(2)
57 write(unit=stdout,fmt=*) time, idims(4)
58 write(unit=stdout,fmt=*) ' error stop '
59 stop
60
61 end if
62
63 ! get the data
64
65 istart(1) = 1
66 iend(1) = i1
67 istart(2) = 1
68 iend(2) = i2
69 istart(3) = time
70 iend(3) = 1
71
72 call ncvgt(cdfid,id_data,istart,iend,data,rcode)
73
74 if (debug) then
75 write(unit=stdout, fmt='(a, i8)') ' Sample data=', data(1,1)
76 end if
77
78 call ncclos(cdfid,rcode)
79
80 ! if (trace_use) call da_trace_exit("da_get_var_2d_int_cdf")
81
82 end subroutine da_get_var_2d_int_cdf
83
84