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=80), intent(in) :: file
13 logical, intent(in) :: debug
14 character (len=*), intent(in) :: var
15 integer, dimension(i1,i2), intent(out) :: data
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 cdfid = ncopn(file, NCNOWRIT, rcode)
23
24 if (rcode /= 0) then
25 write(unit=*, fmt='(2a)') ' error openiing netcdf file ', trim(file)
26 stop
27 end if
28
29 id_data = ncvid(cdfid, var, rcode)
30
31 rcode = nf_inq_var(cdfid, id_data, varnam, ivtype, ndims, dimids, natts)
32
33 if (debug) then
34 write(unit=*, fmt='(3a,i6)') ' get_var_2d_real_cdf: dims for ',var,' ',ndims
35 end if
36
37 do i=1,ndims
38 rcode = nf_inq_dimlen(cdfid, dimids(i), idims(i))
39 if (debug) then
40 write(unit=*, fmt='(a,2i6)') ' dimension ',i,idims(i)
41 write(unit=*, fmt='(a,i6)') ' ivtype=', ivtype
42 write(unit=*, fmt='(a, a)') ' varnam=', trim(varnam)
43 end if
44 end do
45
46 ! check the dimensions
47
48 if ((i1 /= idims(1)) .or. &
49 (i2 /= idims(2)) .or. &
50 (time > idims(3)) ) then
51
52 write(unit=stdout,fmt=*) ' error in 2d_var_real read, dimension problem '
53 write(unit=stdout,fmt=*) i1, idims(1)
54 write(unit=stdout,fmt=*) i2, idims(2)
55 write(unit=stdout,fmt=*) time, idims(4)
56 write(unit=stdout,fmt=*) ' error stop '
57 stop
58
59 end if
60
61 ! get the data
62
63 istart(1) = 1
64 iend(1) = i1
65 istart(2) = 1
66 iend(2) = i2
67 istart(3) = time
68 iend(3) = 1
69
70 call ncvgt(cdfid,id_data,istart,iend,data,rcode)
71
72 if (debug) then
73 write(unit=*, fmt='(a, i8)') ' Sample data=', data(1,1)
74 end if
75
76 call ncclos(cdfid,rcode)
77
78 end subroutine da_get_var_2d_int_cdf
79
80