ROMS
Loading...
Searching...
No Matches
nf_fread4d_mod::nf_fread4d Interface Reference

Public Member Functions

integer function nf90_fread4d (ng, model, ncname, ncid, ncvname, ncvarid, tindex, gtype, vsize, lbi, ubi, lbj, ubj, lbk, ubk, lbt, ubt, ascl, amin, amax, amask, adat, checksum)
 
integer function pio_fread4d (ng, model, ncname, piofile, ncvname, piovar, tindex, piodesc, vsize, lbi, ubi, lbj, ubj, lbk, ubk, lbt, ubt, ascl, amin, amax, amask, adat, checksum)
 

Detailed Description

Definition at line 71 of file nf_fread4d.F.

Member Function/Subroutine Documentation

◆ nf90_fread4d()

integer function nf_fread4d_mod::nf_fread4d::nf90_fread4d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
integer, intent(in) ncid,
character (len=*), intent(in) ncvname,
integer, intent(in) ncvarid,
integer, intent(in) tindex,
integer, intent(in) gtype,
integer, dimension(4), intent(in) vsize,
integer, intent(in) lbi,
integer, intent(in) ubi,
integer, intent(in) lbj,
integer, intent(in) ubj,
integer, intent(in) lbk,
integer, intent(in) ubk,
integer, intent(in) lbt,
integer, intent(in) ubt,
real(dp), intent(in) ascl,
real(r8), intent(out) amin,
real(r8), intent(out) amax,
real(r8), dimension(lbi:,lbj:), intent(in) amask,
real(r8), dimension(lbi:,lbj:,lbk:,lbt:), intent(out) adat,
integer(i8b), intent(out), optional checksum )

Definition at line 83 of file nf_fread4d.F.

93!***********************************************************************
94!
95 USE mod_netcdf
96!
98# if defined MASKING && defined READ_WATER
99 USE distribute_mod, ONLY : mp_collect
100# endif
102!
103! Imported variable declarations.
104!
105 integer, intent(in) :: ng, model, ncid, ncvarid, tindex, gtype
106 integer, intent(in) :: LBi, UBi, LBj, UBj, LBk, UBk, LBt, UBt
107 integer, intent(in) :: Vsize(4)
108!
109 integer(i8b), intent(out), optional :: checksum
110!
111 real(dp), intent(in) :: Ascl
112 real(r8), intent(out) :: Amin
113 real(r8), intent(out) :: Amax
114!
115 character (len=*), intent(in) :: ncname
116 character (len=*), intent(in) :: ncvname
117!
118# ifdef ASSUMED_SHAPE
119# ifdef MASKING
120 real(r8), intent(in) :: Amask(LBi:,LBj:)
121# endif
122 real(r8), intent(out) :: Adat(LBi:,LBj:,LBk:,LBt:)
123# else
124# ifdef MASKING
125 real(r8), intent(in) :: Amask(LBi:UBi,LBj:UBj)
126# endif
127 real(r8), intent(out) :: Adat(LBi:UBi,LBj:UBj,LBk:UBk,LBt:UBt)
128# endif
129!
130! Local variable declarations.
131!
132 logical :: Lchecksum
133 logical, dimension(3) :: foundit
134!
135 integer :: i, ic, ij, j, jc, k, kc, l, lc, np, Npts
136 integer :: Imin, Imax, Isize, Jmin, Jmax, Jsize, IJsize
137 integer :: Istr, Iend
138 integer :: Ioff, Joff, Koff, Loff
139 integer :: Ilen, Jlen, Klen, Llen, IJlen
140 integer :: Cgrid, MyType, ghost, status, wtype
141
142 integer, dimension(5) :: start, total
143!
144 real(r8) :: Afactor, Aoffset, Aspval
145
146 real(r8), parameter :: IniVal= 0.0_r8
147
148 real(r8), dimension(2) :: rbuffer
149 real(r8), dimension(3) :: AttValue
150
151# if defined MASKING && defined READ_WATER
152 real(r8), allocatable :: A2d(:)
153# endif
154 real(r8), allocatable :: wrk(:)
155!
156 character (len= 3), dimension(2) :: op_handle
157 character (len=12), dimension(3) :: AttName
158
159 character (len=*), parameter :: MyFile = &
160 & __FILE__//", nf90_fread4d"
161!
162!-----------------------------------------------------------------------
163! Set starting and ending indices to process.
164!-----------------------------------------------------------------------
165!
166 status=nf90_noerr
167!
168! Set first and last grid point according to staggered C-grid
169! classification. Set the offsets for variables with starting
170! zero-index. Recall the NetCDF does not support a zero-index.
171!
172! Notice that (Imin,Jmin) and (Imax,Jmax) are the corner of the
173! computational tile. If ghost=0, ghost points are not processed.
174! They will be processed elsewhere by the appropriate call to any
175! of the routines in "mp_exchange.F". If ghost=1, the ghost points
176! are read.
177!
178# ifdef NO_READ_GHOST
179 ghost=0 ! non-overlapping, no ghost points
180# else
181 IF (model.eq.iadm) THEN
182 ghost=0 ! non-overlapping, no ghost points
183 ELSE
184 ghost=1 ! overlapping, read ghost points
185 END IF
186# endif
187
188 mytype=gtype
189
190 SELECT CASE (abs(mytype))
191 CASE (p2dvar, p3dvar)
192 cgrid=1
193 isize=iobounds(ng)%xi_psi
194 jsize=iobounds(ng)%eta_psi
195 CASE (r2dvar, r3dvar, w3dvar)
196 cgrid=2
197 isize=iobounds(ng)%xi_rho
198 jsize=iobounds(ng)%eta_rho
199 CASE (u2dvar, u3dvar)
200 cgrid=3
201 isize=iobounds(ng)%xi_u
202 jsize=iobounds(ng)%eta_u
203 CASE (v2dvar, v3dvar)
204 cgrid=4
205 isize=iobounds(ng)%xi_v
206 jsize=iobounds(ng)%eta_v
207 CASE DEFAULT
208 cgrid=2
209 isize=iobounds(ng)%xi_rho
210 jsize=iobounds(ng)%eta_rho
211 END SELECT
212
213 imin=bounds(ng)%Imin(cgrid,ghost,myrank)
214 imax=bounds(ng)%Imax(cgrid,ghost,myrank)
215 jmin=bounds(ng)%Jmin(cgrid,ghost,myrank)
216 jmax=bounds(ng)%Jmax(cgrid,ghost,myrank)
217
218 ilen=imax-imin+1
219 jlen=jmax-jmin+1
220 klen=ubk-lbk+1
221 llen=ubt-lbt+1
222!
223! Check if the following attributes: "scale_factor", "add_offset", and
224! "_FillValue" are present in the input NetCDF variable:
225!
226! If the "scale_value" attribute is present, the data is multiplied by
227! this factor after reading.
228! If the "add_offset" attribute is present, this value is added to the
229! data after reading.
230! If both "scale_factor" and "add_offset" attributes are present, the
231! data are first scaled before the offset is added.
232! If the "_FillValue" attribute is present, the data having this value
233! is treated as missing and it is replaced with zero. This feature it
234! is usually related with the land/sea masking.
235!
236 attname(1)='scale_factor'
237 attname(2)='add_offset '
238 attname(3)='_FillValue '
239
240 CALL netcdf_get_fatt (ng, model, ncname, ncvarid, attname, &
241 & attvalue, foundit, &
242 & ncid = ncid)
243 IF (founderror(exit_flag, noerror, __line__, myfile)) THEN
244 status=ioerror
245 RETURN
246 END IF
247
248 IF (.not.foundit(1)) THEN
249 afactor=1.0_r8
250 ELSE
251 afactor=attvalue(1)
252 END IF
253
254 IF (.not.foundit(2)) THEN
255 aoffset=0.0_r8
256 ELSE
257 aoffset=attvalue(2)
258 END IF
259
260 IF (.not.foundit(3)) THEN
261 aspval=spval_check
262 ELSE
263 aspval=attvalue(3)
264 END IF
265!
266! Initialize checsum value.
267!
268 IF (PRESENT(checksum)) THEN
269 lchecksum=.true.
270 checksum=0_i8b
271 ELSE
272 lchecksum=.false.
273 END IF
274!
275!-----------------------------------------------------------------------
276! Parallel I/O: Read in tile data from requested field and scale it.
277! Processing both water and land points.
278!-----------------------------------------------------------------------
279!
280 IF (gtype.gt.0) THEN
281!
282! Set offsets due the NetCDF dimensions. Recall that some output
283! variables not always start at one.
284!
285 SELECT CASE (abs(mytype))
286 CASE (p2dvar, p3dvar)
287 ioff=0
288 joff=0
289 CASE (r2dvar, r3dvar, w3dvar)
290 ioff=1
291 joff=1
292 CASE (u2dvar, u3dvar)
293 ioff=0
294 joff=1
295 CASE (v2dvar, v3dvar)
296 ioff=1
297 joff=0
298 CASE DEFAULT
299 ioff=1
300 joff=1
301 END SELECT
302
303 IF (lbk.eq.0) THEN
304 koff=1
305 ELSE
306 koff=0
307 END IF
308
309 IF (lbt.eq.0) THEN
310 loff=1
311 ELSE
312 loff=0
313 END IF
314
315 npts=ilen*jlen*klen*llen
316!
317! Allocate scratch work array.
318!
319 IF (.not.allocated(wrk)) THEN
320 allocate ( wrk(npts) )
321 wrk=0.0_r8
322 END IF
323!
324! Read in data: all parallel nodes read their own tile data.
325!
326 start(1)=imin+ioff
327 total(1)=ilen
328 start(2)=jmin+joff
329 total(2)=jlen
330 start(3)=lbk+koff
331 total(3)=klen
332 start(4)=lbt+loff
333 total(4)=llen
334 start(5)=tindex
335 total(5)=1
336
337 status=nf90_get_var(ncid, ncvarid, wrk, start, total)
338!
339! Scale read data and process fill values, if any. Compute minimum
340! and maximum values.
341!
342 IF (status.eq.nf90_noerr) THEN
343 amin=spval
344 amax=-spval
345 DO i=1,npts
346 IF (abs(wrk(i)).ge.abs(aspval)) THEN
347 wrk(i)=0.0_r8 ! masked with _FillValue
348 ELSE
349 wrk(i)=ascl*(afactor*wrk(i)+aoffset)
350 amin=min(amin,wrk(i))
351 amax=max(amax,wrk(i))
352 END IF
353 END DO
354 IF ((abs(amin).ge.abs(aspval)).and. &
355 & (abs(amax).ge.abs(aspval))) THEN
356 amin=0.0_r8 ! the entire data is all
357 amax=0.0_r8 ! field value, _FillValue
358 END IF
359!
360! Set minimum and maximum values: global reduction.
361!
362 rbuffer(1)=amin
363 op_handle(1)='MIN'
364 rbuffer(2)=amax
365 op_handle(2)='MAX'
366 CALL mp_reduce (ng, model, 2, rbuffer, op_handle)
367 amin=rbuffer(1)
368 amax=rbuffer(2)
369!
370! Unpack read data.
371!
372 ic=0
373 DO l=lbt,ubt
374 DO k=lbk,ubk
375 DO j=jmin,jmax
376 DO i=imin,imax
377 ic=ic+1
378 adat(i,j,k,l)=wrk(ic)
379 END DO
380 END DO
381 END DO
382 END DO
383 ELSE
384 exit_flag=2
385 ioerror=status
386 END IF
387 END IF
388
389# if defined MASKING && defined READ_WATER
390!
391!-----------------------------------------------------------------------
392! Parallel I/O: Read in tile data from requested field and scale it.
393! Processing water points only.
394!-----------------------------------------------------------------------
395!
396 IF (gtype.lt.0) THEN
397!
398! Set number of points to process, grid type switch, and offsets due
399! array packing into 1D array in column-major order.
400!
401 SELECT CASE (abs(mytype))
402 CASE (p3dvar)
403 ijlen=iobounds(ng)%xy_psi
404 wtype=p2dvar
405 ioff=0
406 joff=1
407 CASE (r3dvar, w3dvar)
408 ijlen=iobounds(ng)%xy_rho
409 wtype=r2dvar
410 ioff=1
411 joff=0
412 CASE (u3dvar)
413 ijlen=iobounds(ng)%xy_u
414 wtype=u2dvar
415 ioff=0
416 joff=0
417 CASE (v3dvar)
418 ijlen=iobounds(ng)%xy_v
419 wtype=v2dvar
420 ioff=1
421 joff=1
422 CASE DEFAULT
423 ijlen=iobounds(ng)%xy_rho
424 wtype=r2dvar
425 ioff=1
426 joff=0
427 END SELECT
428
429 IF (lbk.eq.0) THEN
430 koff=0
431 ELSE
432 koff=1
433 END IF
434
435 IF (lbt.eq.0) THEN
436 loff=1
437 ELSE
438 loff=0
439 END IF
440
441 npts=ijlen*klen*llen
442 ijsize=isize*jsize
443!
444! Allocate scratch work arrays.
445!
446 IF (.not.allocated(a2d)) THEN
447 allocate ( a2d(ijsize) )
448 END IF
449 IF (.not.allocated(wrk)) THEN
450 allocate ( wrk(npts) )
451 wrk=inival
452 END IF
453!
454! Read in data: all parallel nodes read a segment of the 1D data.
455! Recall that water points are pack in the NetCDF file in a single
456! dimension.
457!
458 CALL tile_bounds_1d (ng, myrank, npts, istr, iend)
459
460 start(1)=istr
461 total(1)=iend-istr+1
462 start(2)=1
463 total(2)=tindex
464
465 status=nf90_get_var(ncid, ncvarid, wrk(istr:), start, total)
466!
467! Global reduction of work array. We need this because the packing
468! of the water point only affects the model tile partition.
469!
470 IF (status.eq.nf90_noerr) THEN
471 CALL mp_collect (ng, model, npts, inival, wrk)
472!
473! Scale read data and process fill values, if any. Compute minimum
474! and maximum values.
475!
476 amin=spval
477 amax=-spval
478 DO i=1,npts
479 IF (abs(wrk(i)).ge.abs(aspval)) THEN
480 wrk(i)=0.0_r8 ! set _FillValue to zero
481 ELSE
482 wrk(i)=ascl*(afactor*wrk(i)+aoffset)
483 amin=min(amin,wrk(i))
484 amax=max(amax,wrk(i))
485 END IF
486 END DO
487 IF ((abs(amin).ge.abs(aspval)).and. &
488 & (abs(amax).ge.abs(aspval))) THEN
489 amin=0.0_r8 ! the entire data is all
490 amax=0.0_r8 ! field value, _FillValue
491 END IF
492!
493! Unpack read data. This is tricky in parallel I/O. The cheapeast
494! thing to do is reconstruct a packed 2D global array and then select
495! the appropriate values for the tile.
496!
497 DO l=lbt,ubt
498 lc=(l-loff)*ijlen*klen
499 DO k=lbk,ubk
500 kc=(k-koff)*ijlen+lc
501 a2d=inival
502 DO np=1,ijlen
503 ij=scalars(ng)%IJwater(np,wtype)
504 a2d(ij)=wrk(np+kc)
505 END DO
506 DO j=jmin,jmax
507 jc=(j-joff)*isize
508 DO i=imin,imax
509 ij=i+ioff+jc
510 adat(i,j,k,l)=a2d(ij)
511 END DO
512 END DO
513 END DO
514 END DO
515 ELSE
516 exit_flag=2
517 ioerror=status
518 END IF
519 END IF
520# endif
521!
522!-----------------------------------------------------------------------
523! Deallocate scratch work vector.
524!-----------------------------------------------------------------------
525!
526# if defined MASKING && defined READ_WATER
527 IF (allocated(a2d)) THEN
528 deallocate (a2d)
529 END IF
530# endif
531
532 IF (allocated(wrk)) THEN
533 deallocate (wrk)
534 END IF
535!
536 RETURN
subroutine, public tile_bounds_1d(ng, tile, imax, istr, iend)
Definition get_bounds.F:921

References mod_param::bounds, mod_scalars::exit_flag, strings_mod::founderror(), get_hash_mod::get_hash(), mod_param::iadm, mod_parallel::inpthread, mod_param::iobounds, mod_iounits::ioerror, mod_param::lm, mod_param::mm, distribute_mod::mp_scatter2d(), distribute_mod::mp_scatter3d(), mod_parallel::myrank, mod_param::nghostpoints, mod_scalars::noerror, mod_param::p2dvar, mod_param::p3dvar, mod_param::r2dvar, mod_param::r3dvar, mod_scalars::scalars, mod_scalars::spval, mod_scalars::spval_check, get_bounds_mod::tile_bounds_1d(), mod_param::u2dvar, mod_param::u3dvar, mod_param::v2dvar, mod_param::v3dvar, and mod_param::w3dvar.

Here is the call graph for this function:

◆ pio_fread4d()

integer function nf_fread4d_mod::nf_fread4d::pio_fread4d ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
type (file_desc_t), intent(inout) piofile,
character (len=*), intent(in) ncvname,
type (my_vardesc), intent(inout) piovar,
integer, intent(in) tindex,
type (io_desc_t), intent(inout) piodesc,
integer, dimension(4), intent(in) vsize,
integer, intent(in) lbi,
integer, intent(in) ubi,
integer, intent(in) lbj,
integer, intent(in) ubj,
integer, intent(in) lbk,
integer, intent(in) ubk,
integer, intent(in) lbt,
integer, intent(in) ubt,
real(dp), intent(in) ascl,
real(r8), intent(out) amin,
real(r8), intent(out) amax,
real(r8), dimension(lbi:,lbj:), intent(in) amask,
real(r8), dimension(lbi:,lbj:,lbk:,lbt:), intent(out) adat,
integer(i8b), intent(out), optional checksum )

Definition at line 958 of file nf_fread4d.F.

968!***********************************************************************
969!
971!
972 USE distribute_mod, ONLY : mp_reduce
973!
974! Imported variable declarations.
975!
976 integer, intent(in) :: ng, model, tindex
977 integer, intent(in) :: LBi, UBi, LBj, UBj, LBk, UBk, LBt, UBt
978 integer, intent(in) :: Vsize(4)
979!
980 integer(i8b), intent(out), optional :: checksum
981!
982 real(dp), intent(in) :: Ascl
983 real(r8), intent(out) :: Amin
984 real(r8), intent(out) :: Amax
985!
986 character (len=*), intent(in) :: ncname
987 character (len=*), intent(in) :: ncvname
988!
989# ifdef ASSUMED_SHAPE
990# ifdef MASKING
991 real(r8), intent(in) :: Amask(LBi:,LBj:)
992# endif
993 real(r8), intent(out) :: Adat(LBi:,LBj:,LBk:,LBt:)
994# else
995# ifdef MASKING
996 real(r8), intent(in) :: Amask(LBi:UBi,LBj:UBj)
997# endif
998 real(r8), intent(out) :: Adat(LBi:UBi,LBj:UBj,LBk:UBk,LBt:UBt)
999# endif
1000!
1001 TYPE (File_desc_t), intent(inout) :: pioFile
1002 TYPE (IO_Desc_t), intent(inout) :: pioDesc
1003 TYPE (My_VarDesc), intent(inout) :: pioVar
1004!
1005! Local variable declarations.
1006!
1007 logical :: Lchecksum
1008 logical, dimension(3) :: foundit
1009!
1010 integer :: i, j, k, l, Npts, status
1011 integer :: Is, Ie, Js, Je
1012 integer :: Imin, Imax, Jmin, Jmax
1013 integer :: Cgrid, ghost, dkind, gtype
1014
1015 integer, dimension(5) :: start, total
1016!
1017 real(r8) :: Afactor, Aoffset, Aspval, Avalue
1018 real(r8) :: my_Amin, my_Amax
1019
1020 real(r8), dimension(3) :: AttValue
1021 real(r8), dimension(2) :: rbuffer
1022!
1023 real(r4), pointer :: Awrk4(:,:,:,:) ! single precision
1024 real(r8), pointer :: Awrk8(:,:,:,:) ! double precision
1025 real(r8), allocatable :: Cwrk(:) ! used for checksum
1026!
1027 character (len=12), dimension(3) :: AttName
1028 character (len= 3), dimension(2) :: op_handle
1029
1030 character (len=*), parameter :: MyFile = &
1031 & __FILE__//", pio_fread4d"
1032!
1033!-----------------------------------------------------------------------
1034! Set starting and ending indices to process.
1035!-----------------------------------------------------------------------
1036!
1037 status=pio_noerr
1038 amin=spval
1039 amax=-spval
1040 my_amin=spval
1041 my_amax=-spval
1042!
1043! Set global (interior plus boundary) starting and ending grid cell
1044! indices in the I- and J-directions according to staggered C-grid
1045! classification.
1046!
1047 dkind=piovar%dkind
1048 gtype=piovar%gtype
1049!
1050 SELECT CASE (abs(gtype))
1051 CASE (p2dvar, p3dvar)
1052 cgrid=1 ! PSI-points
1053 is=iobounds(ng)%ILB_psi
1054 ie=iobounds(ng)%IUB_psi
1055 js=iobounds(ng)%JLB_psi
1056 je=iobounds(ng)%JUB_psi
1057 CASE (l4dvar, r2dvar, r3dvar, w3dvar)
1058 cgrid=2 ! RHO-points
1059 is=iobounds(ng)%ILB_rho
1060 ie=iobounds(ng)%IUB_rho
1061 js=iobounds(ng)%JLB_rho
1062 je=iobounds(ng)%JUB_rho
1063 CASE (u2dvar, u3dvar)
1064 cgrid=3 ! U-points
1065 is=iobounds(ng)%ILB_u
1066 ie=iobounds(ng)%IUB_u
1067 js=iobounds(ng)%JLB_u
1068 je=iobounds(ng)%JUB_u
1069 CASE (v2dvar, v3dvar)
1070 cgrid=4 ! V-points
1071 is=iobounds(ng)%ILB_v
1072 ie=iobounds(ng)%IUB_v
1073 js=iobounds(ng)%JLB_v
1074 je=iobounds(ng)%JUB_v
1075 CASE DEFAULT
1076 cgrid=2 ! RHO-points
1077 is=iobounds(ng)%ILB_rho
1078 ie=iobounds(ng)%IUB_rho
1079 js=iobounds(ng)%JLB_rho
1080 je=iobounds(ng)%JUB_rho
1081 END SELECT
1082!
1083! Set the tile computational I- and J-bounds (no ghost points).
1084!
1085 ghost=0
1086 imin=bounds(ng)%Imin(cgrid,ghost,myrank)
1087 imax=bounds(ng)%Imax(cgrid,ghost,myrank)
1088 jmin=bounds(ng)%Jmin(cgrid,ghost,myrank)
1089 jmax=bounds(ng)%Jmax(cgrid,ghost,myrank)
1090!
1091! Check if the following attributes: "scale_factor", "add_offset", and
1092! "_FillValue" are present in the input NetCDF variable:
1093!
1094! If the "scale_value" attribute is present, the data is multiplied by
1095! this factor after reading.
1096! If the "add_offset" attribute is present, this value is added to the
1097! data after reading.
1098! If both "scale_factor" and "add_offset" attributes are present, the
1099! data are first scaled before the offset is added.
1100! If the "_FillValue" attribute is present, the data having this value
1101! is treated as missing and it is replaced with zero. This feature it
1102! is usually related with the land/sea masking.
1103!
1104 attname(1)='scale_factor'
1105 attname(2)='add_offset '
1106 attname(3)='_FillValue '
1107
1108 CALL pio_netcdf_get_fatt (ng, model, ncname, piovar%vd, attname, &
1109 & attvalue, foundit, &
1110 & piofile = piofile)
1111 IF (founderror(exit_flag, noerror, __line__, myfile)) THEN
1112 status=ioerror
1113 RETURN
1114 END IF
1115
1116 IF (.not.foundit(1)) THEN
1117 afactor=1.0_r8
1118 ELSE
1119 afactor=attvalue(1)
1120 END IF
1121
1122 IF (.not.foundit(2)) THEN
1123 aoffset=0.0_r8
1124 ELSE
1125 aoffset=attvalue(2)
1126 END IF
1127
1128 IF (.not.foundit(3)) THEN
1129 aspval=spval_check
1130 ELSE
1131 aspval=attvalue(3)
1132 END IF
1133!
1134! Initialize checsum value.
1135!
1136 IF (PRESENT(checksum)) THEN
1137 lchecksum=.true.
1138 checksum=0_i8b
1139 ELSE
1140 lchecksum=.false.
1141 END IF
1142!
1143!-----------------------------------------------------------------------
1144! Read in requested field and scale it.
1145!-----------------------------------------------------------------------
1146!
1147! Allocate and initialize local array used for reading. The local array
1148! needs to be of the same precision as "A" and its IO decomposition
1149! descriptor "pioDesc".
1150!
1151 IF (dkind.eq.pio_double) THEN ! double precision
1152 IF (.not.associated(awrk8)) THEN
1153 allocate ( awrk8(imin:imax, jmin:jmax, lbk:ubk, lbt:ubt) )
1154 END IF
1155 awrk8=0.0_r8
1156 ELSE ! single precision
1157 IF (.not.associated(awrk4)) THEN
1158 allocate ( awrk4(imin:imax, jmin:jmax, lbk:ubk, lbt:ubt) )
1159 END IF
1160 awrk4=0.0_r4
1161 END IF
1162!
1163! Set unlimited time dimension record to write, if any.
1164!
1165 IF (tindex.gt.0) THEN
1166 CALL pio_setframe (piofile, &
1167 & piovar%vd, &
1168 & int(tindex, kind=pio_offset_kind))
1169 END IF
1170!
1171! Read in double precision data from NetCDF file.
1172!
1173 IF (dkind.eq.pio_double) THEN
1174 CALL pio_read_darray (piofile, &
1175 & piovar%vd, &
1176 & piodesc, &
1177 & awrk8(imin:,jmin:,lbk:,lbt:), &
1178 & status)
1179!
1180 DO l=lbt,ubt
1181 DO k=lbk,ubk
1182 DO j=jmin,jmax
1183 DO i=imin,imax
1184 IF (abs(awrk8(i,j,k,l)).ge.abs(aspval)) THEN
1185 adat(i,j,k,l)=0.0_r8 ! masked with _FillValue
1186 ELSE
1187 avalue=ascl*(afactor*awrk8(i,j,k,l)+aoffset)
1188 adat(i,j,k,l)=avalue
1189 my_amin=min(my_amin,avalue)
1190 my_amax=max(my_amax,avalue)
1191 END IF
1192 END DO
1193 END DO
1194 END DO
1195 END DO
1196 IF (associated(awrk8)) deallocate (awrk8)
1197!
1198! Read in and load single precision data from NetCDF file.
1199!
1200 ELSE
1201 CALL pio_read_darray (piofile, &
1202 & piovar%vd, &
1203 & piodesc, &
1204 & awrk4(imin:,jmin:,lbk:,lbt:), &
1205 & status)
1206!
1207 DO l=lbt,ubt
1208 DO k=lbk,ubk
1209 DO j=jmin,jmax
1210 DO i=imin,imax
1211 IF (abs(awrk4(i,j,k,l)).ge.abs(aspval)) THEN
1212 adat(i,j,k,l)=0.0_r8 ! masked with _FillValue
1213 ELSE
1214 avalue=real(ascl*(afactor*awrk4(i,j,k,l)+aoffset),r8)
1215 adat(i,j,k,l)=avalue
1216 my_amin=real(min(my_amin,avalue),r8)
1217 my_amax=real(max(my_amax,avalue),r8)
1218 END IF
1219 END DO
1220 END DO
1221 END DO
1222 END DO
1223 IF (associated(awrk4)) deallocate (awrk4)
1224 END IF
1225!
1226! If requested, compute input data checksum value.
1227! (TODO: parallel gathering of checksum)
1228!
1229 IF (lchecksum) THEN
1230 npts=(imax-imin+1)*(jmax-jmin+1)*(ubk-lbk+1)*(ubt-lbt+1)
1231 IF (.not.allocated(cwrk)) allocate ( cwrk(npts) )
1232 cwrk=pack(adat(imin:imax, jmin:jmax, lbk:ubk, lbt:ubt), .true.)
1233 CALL get_hash (cwrk, npts, checksum, .true.)
1234 IF (allocated(cwrk)) deallocate (cwrk)
1235 END IF
1236!
1237! Compute global minimum and maximum values.
1238!
1239 rbuffer(1)=my_amin
1240 rbuffer(2)=my_amax
1241 op_handle(1)='MIN'
1242 op_handle(2)='MAX'
1243 CALL mp_reduce (ng, model, 2, rbuffer, op_handle)
1244 amin=rbuffer(1)
1245 amax=rbuffer(2)
1246!
1247 IF ((abs(amin).ge.abs(spval)).and. &
1248 & (abs(amax).ge.abs(spval))) THEN
1249 amin=0.0_r8 ! the entire data is all
1250 amax=0.0_r8 ! field value, _FillValue
1251 END IF ! and was zeroth out
1252!
1253 RETURN

References mod_param::bounds, mod_scalars::exit_flag, strings_mod::founderror(), get_hash_mod::get_hash(), mod_param::iobounds, mod_iounits::ioerror, mod_param::l4dvar, mod_parallel::myrank, mod_scalars::noerror, mod_param::p2dvar, mod_param::p3dvar, mod_param::r2dvar, mod_param::r3dvar, mod_scalars::spval, mod_scalars::spval_check, mod_param::u2dvar, mod_param::u3dvar, mod_param::v2dvar, mod_param::v3dvar, and mod_param::w3dvar.

Here is the call graph for this function:

The documentation for this interface was generated from the following file: