35 #if defined(OLD_PT_TO_T) || defined(OLD_COS_SG) 37 #error Compile time options -DOLD_PT_TO_T and -DOLD_COS_SG are no longer supported. Please remove them from your XML. 41 use mpp_mod
, only: mpp_error, fatal
55 character(len=*),
intent(in):: iflnm
56 integer,
intent(out):: ncid
59 status = nf_open(iflnm, nf_nowrite, ncid)
60 if (status .ne. nf_noerr)
call handle_err(
'nf_open',status)
67 integer,
intent(in):: ncid
70 status = nf_close(ncid)
71 if (status .ne. nf_noerr)
call handle_err(
'nf_close',status)
78 integer,
intent(in):: ncid
79 character(len=*),
intent(in):: var1_name
80 integer,
intent(out):: im
81 integer:: status, var1id
83 status = nf_inq_dimid(ncid, var1_name, var1id)
84 if (status .ne. nf_noerr)
call handle_err(
'dimid '//var1_name,status)
86 status = nf_inq_dimlen(ncid, var1id, im)
87 if (status .ne. nf_noerr)
call handle_err(
'dimid '//var1_name,status)
93 integer,
intent(in):: ncid
94 character(len=*),
intent(in):: var1_name
95 integer,
intent(in):: im
96 logical,
intent(out),
optional:: var_exist
97 real(kind=8),
intent(out):: var1(im)
98 integer:: status, var1id
100 status = nf_inq_varid(ncid, var1_name, var1id)
101 if (status .ne. nf_noerr)
then 103 if(
present(var_exist) ) var_exist = .false.
105 status = nf_get_var_double(ncid, var1id, var1)
106 if (status .ne. nf_noerr)
call handle_err(
'varid '//var1_name,status)
107 if(
present(var_exist) ) var_exist = .true.
115 subroutine get_var1_real( ncid, var1_name, im, var1, var_exist )
116 integer,
intent(in):: ncid
117 character(len=*),
intent(in):: var1_name
118 integer,
intent(in):: im
119 logical,
intent(out),
optional:: var_exist
120 real(kind=4),
intent(out):: var1(im)
121 integer:: status, var1id
123 status = nf_inq_varid(ncid, var1_name, var1id)
124 if (status .ne. nf_noerr)
then 126 if(
present(var_exist) ) var_exist = .false.
128 status = nf_get_var_real(ncid, var1id, var1)
129 if (status .ne. nf_noerr)
call handle_err(
'get_var1_real1 '//var1_name,status)
130 if(
present(var_exist) ) var_exist = .true.
137 integer,
intent(in):: ncid
138 character(len=*),
intent(in):: var_name
139 integer,
intent(in):: im, jm
140 real(kind=4),
intent(out):: var2(im)
142 integer:: status, var1id
144 status = nf_inq_varid(ncid, var_name, var1id)
145 if (status .ne. nf_noerr)
call handle_err(
'get_var2_real varid '//var_name,status)
147 status = nf_get_var_real(ncid, var1id, var2)
148 if (status .ne. nf_noerr)
call handle_err(
'get_var2_real get_var'//var_name,status)
152 subroutine get_var2_r4( ncid, var2_name, is,ie, js,je, var2, time_slice )
153 integer,
intent(in):: ncid
154 character(len=*),
intent(in):: var2_name
155 integer,
intent(in):: is, ie, js, je
156 real(kind=4),
intent(out):: var2(is:ie,js:je)
157 integer,
intent(in),
optional :: time_slice
159 real(kind=4),
dimension(1) :: time
160 integer,
dimension(3):: start, nreco
161 integer:: status, var2id
163 status = nf_inq_varid(ncid, var2_name, var2id)
164 if (status .ne. nf_noerr)
call handle_err(
'get_var2_r4 varid'//var2_name,status)
166 start(1) = is; start(2) = js; start(3) = 1
167 if (
present(time_slice) )
then 168 start(3) = time_slice
171 nreco(1) = ie - is + 1
172 nreco(2) = je - js + 1
175 status = nf_get_vara_real(ncid, var2id, start, nreco, var2)
176 if (status .ne. nf_noerr)
call handle_err(
'get_var2_r4 get_vara_real'//var2_name,status)
181 integer,
intent(in):: ncid
182 character(len=*),
intent(in):: var2_name
183 integer,
intent(in):: im, jm
184 real(kind=8),
intent(out):: var2(im,jm)
186 integer:: status, var2id
188 status = nf_inq_varid(ncid, var2_name, var2id)
189 if (status .ne. nf_noerr)
call handle_err(
'get_var2_double varid'//var2_name,status)
191 status = nf_get_var_double(ncid, var2id, var2)
192 if (status .ne. nf_noerr)
call handle_err(
'get_var2_double get_var_double'//var2_name,status)
199 integer,
intent(in):: ncid
200 character(len=*),
intent(in):: var3_name
201 integer,
intent(in):: im, jm, km
202 real(kind=8),
intent(out):: var3(im,jm,km)
204 integer:: status, var3id
206 status = nf_inq_varid(ncid, var3_name, var3id)
208 if (status .ne. nf_noerr) &
209 call handle_err(
'get_var3_double varid '//var3_name,status)
211 status = nf_get_var_double(ncid, var3id, var3)
212 if (status .ne. nf_noerr) &
213 call handle_err(
'get_var3_double get_vara_double '//var3_name,status)
217 subroutine get_var3_real( ncid, var3_name, im, jm, km, var3 )
218 integer,
intent(in):: ncid
219 character(len=*),
intent(in):: var3_name
220 integer,
intent(in):: im, jm, km
221 real(kind=4),
intent(out):: var3(im,jm,km)
223 integer:: status, var3id
225 status = nf_inq_varid(ncid, var3_name, var3id)
227 if (status .ne. nf_noerr) &
228 call handle_err(
'get_var3_real varid '//var3_name,status)
229 status = nf_get_var_real(ncid, var3id, var3)
231 if (status .ne. nf_noerr) &
232 call handle_err(
'get_var3_real get_var_real '//var3_name,status)
238 integer,
intent(in):: ncid
239 integer,
intent(inout) :: status
240 character(len=*),
intent(in):: var_name
242 status = nf_inq_varid(ncid, var_name, varid)
245 subroutine get_var3_r4( ncid, var3_name, is,ie, js,je, ks,ke, var3, time_slice )
246 integer,
intent(in):: ncid
247 character(len=*),
intent(in):: var3_name
248 integer,
intent(in):: is, ie, js, je, ks,ke
249 real(kind=4),
intent(out):: var3(is:ie,js:je,ks:ke)
250 integer,
intent(in),
optional :: time_slice
252 real(kind=4),
dimension(1) :: time
253 integer,
dimension(4):: start, nreco
254 integer:: status, var3id
256 status = nf_inq_varid(ncid, var3_name, var3id)
257 if (status .ne. nf_noerr)
call handle_err(
'get_var3_r4 varid '//var3_name,status)
259 start(1) = is; start(2) = js; start(3) = ks; start(4) = 1
260 if (
present(time_slice) )
then 261 start(4) = time_slice
264 nreco(1) = ie - is + 1
265 nreco(2) = je - js + 1
266 nreco(3) = ke - ks + 1
269 status = nf_get_vara_real(ncid, var3id, start, nreco, var3)
270 if (status .ne. nf_noerr)
call handle_err(
'get_var3_r4 get_vara_real '//var3_name,status)
275 subroutine get_var4_real( ncid, var4_name, im, jm, km, nt, var4 )
277 #include <netcdf.inc> 278 integer,
intent(in):: ncid
279 character*(*),
intent(in):: var4_name
280 integer,
intent(in):: im, jm, km, nt
281 real*4:: wk4(im,jm,km,4)
282 real*4,
intent(out):: var4(im,jm)
283 integer:: status, var4id
284 integer:: start(4), icount(4)
299 status = nf_inq_varid(ncid, var4_name, var4id)
302 status = nf_get_vara_real(ncid, var4id, start, icount, var4)
312 if (status .ne. nf_noerr)
call handle_err(
'get_var4_r4 get_vara_real '//var4_name,status)
318 integer,
intent(in):: ncid
319 character(len=*),
intent(in):: var4_name
320 integer,
intent(in):: im, jm, km, nt
321 real(kind=8),
intent(out):: var4(im,jm,km,1)
322 integer:: status, var4id
324 integer:: start(4), icount(4)
336 status = nf_inq_varid(ncid, var4_name, var4id)
337 status = nf_get_vara_double(ncid, var4id, start, icount, var4)
339 if (status .ne. nf_noerr)
call handle_err(
'get_var4_double get_vara_double '//var4_name,status)
344 subroutine get_real3( ncid, var4_name, im, jm, nt, var4 )
346 integer,
intent(in):: ncid
347 character(len=*),
intent(in):: var4_name
348 integer,
intent(in):: im, jm, nt
349 real(kind=4),
intent(out):: var4(im,jm)
350 integer:: status, var4id
351 integer:: start(3), icount(3)
362 status = nf_inq_varid(ncid, var4_name, var4id)
363 status = nf_get_vara_real(ncid, var4id, start, icount, var4)
365 if (status .ne. nf_noerr) &
366 call handle_err(
'get_real3 get_vara_real '//var4_name,status)
371 logical function check_var( ncid, var3_name)
372 integer,
intent(in):: ncid
373 character(len=*),
intent(in):: var3_name
375 integer:: status, var3id
377 status = nf_inq_varid(ncid, var3_name, var3id)
384 #include <netcdf.inc> 385 integer,
intent(in):: ncid
386 character*(*),
intent(in):: var_name, att_name
387 character*(*),
intent(out):: att
389 integer:: status, varid
391 status = nf_inq_varid(ncid, var_name, varid)
392 status = nf_get_att_text(ncid, varid, att_name, att)
394 if (status .ne. nf_noerr)
call handle_err(
'get_var_att_str '//var_name,status)
400 #include <netcdf.inc> 401 integer,
intent(in):: ncid
402 character*(*),
intent(in):: var_name, att_name
403 real(kind=8),
intent(out):: value
405 integer:: status, varid
407 status = nf_inq_varid(ncid, var_name, varid)
408 status = nf_get_att(ncid, varid, att_name,
value)
410 if (status .ne. nf_noerr)
call handle_err(
'get_var_att_double '//var_name,status)
417 character(len=500) :: errstr
418 character(len=*) :: idstr
420 if (status .ne. nf_noerr)
then 421 write(errstr,*)
'Error in handle_err: ',trim(idstr)//
' ',nf_strerror(status)
422 call mpp_error(fatal,errstr)
428 subroutine calendar(year, month, day, hour)
429 integer,
intent(inout) :: year
430 integer,
intent(inout) :: month
431 integer,
intent(inout) :: day
432 integer,
intent(inout) :: hour
436 integer irem4,irem100
438 data mdays /31,28,31,30,31,30,31,31,30,31,30,31/
441 irem4 = mod( year, 4 )
442 irem100 = mod( year, 100 )
443 if( irem4 == 0 .and. irem100 /= 0) mdays(2) = 29
445 if( hour >= 24 )
then 450 if( day > mdays(month) )
then 451 day = day - mdays(month)
454 if( month > 12 )
then subroutine, public get_var3_r4(ncid, var3_name, is, ie, js, je, ks, ke, var3, time_slice)
subroutine, public handle_err(idstr, status)
subroutine, public get_var1_real(ncid, var1_name, im, var1, var_exist)
logical function, public check_var(ncid, var3_name)
subroutine, public get_var1_double(ncid, var1_name, im, var1, var_exist)
The 'get_var' subroutines read in variables from netcdf files.
subroutine, public get_var2_double(ncid, var2_name, im, jm, var2)
subroutine get_var_att_str(ncid, var_name, att_name, att)
subroutine, public get_var3_real(ncid, var3_name, im, jm, km, var3)
The module 'sim_nc' is a netcdf file reader.
subroutine, public get_var2_real(ncid, var_name, im, jm, var2)
subroutine get_var4_double(ncid, var4_name, im, jm, km, nt, var4)
subroutine, public get_var2_r4(ncid, var2_name, is, ie, js, je, var2, time_slice)
subroutine, public open_ncfile(iflnm, ncid)
subroutine, public get_var_att_double(ncid, var_name, att_name, value)
subroutine get_real3(ncid, var4_name, im, jm, nt, var4)
subroutine, public get_var3_double(ncid, var3_name, im, jm, km, var3)
subroutine, public get_ncdim1(ncid, var1_name, im)
subroutine, public check_var_exists(ncid, var_name, status)
subroutine calendar(year, month, day, hour)
The subroutine 'calendar' computes the current GMT.
subroutine get_var4_real(ncid, var4_name, im, jm, km, nt, var4)
subroutine, public close_ncfile(ncid)