20#if defined PIO_LIB && defined DISTRIBUTE
27#if defined PIO_LIB && defined DISTRIBUTE
35#if defined PIO_LIB && defined DISTRIBUTE
71#if defined PIO_LIB && defined DISTRIBUTE
78#if defined PARALLEL_IO && defined DISTRIBUTE
83 & tindex, gtype, Vsize, &
84 & LBi, UBi, LBj, UBj, LBk, UBk, &
90 & checksum)
RESULT (status)
96# if defined MASKING && defined READ_WATER
103 integer,
intent(in) :: ng, model, ncid, ncvarid, tindex, gtype
104 integer,
intent(in) :: lbi, ubi, lbj, ubj, lbk, ubk
105 integer,
intent(in) :: vsize(4)
107 integer(i8b),
intent(out),
optional :: checksum
109 real(dp),
intent(in) :: ascl
110 real(r8),
intent(out) :: amin
111 real(r8),
intent(out) :: amax
113 character (len=*),
intent(in) :: ncname
114 character (len=*),
intent(in) :: ncvname
118 real(r8),
intent(in) :: amask(lbi:,lbj:)
120 real(r8),
intent(out) :: adat(lbi:,lbj:,lbk:)
123 real(r8),
intent(in) :: amask(lbi:ubi,lbj:ubj)
125 real(r8),
intent(out) :: adat(lbi:ubi,lbj:ubj,lbk:ubk)
131 logical,
dimension(3) :: foundit
133 integer :: i, ic, ij, j, jc, k, kc, np, mynpts, npts
134 integer :: imin, imax, isize, jmin, jmax, jsize, ijsize
135 integer :: istr, iend
136 integer :: ioff, joff, koff
137 integer :: ilen, jlen, klen, ijlen
138 integer :: cgrid, mytype, ghost, status, wtype
140 integer,
dimension(4) :: start, total
142 real(r8) :: afactor, aoffset, aspval
144 real(r8),
parameter :: inival= 0.0_r8
146 real(r8),
dimension(2) :: rbuffer
147 real(r8),
dimension(3) :: attvalue
149# if defined MASKING && defined READ_WATER
150 real(r8),
allocatable :: a2d(:)
152 real(r8),
allocatable :: wrk(:)
154 character (len= 3),
dimension(2) :: op_handle
155 character (len=12),
dimension(3) :: attname
157 character (len=*),
parameter :: myfile = &
158 & __FILE__//
", nf90_fread3d"
179 IF (model.eq.
iadm)
THEN
188 SELECT CASE (abs(mytype))
233 attname(1)=
'scale_factor'
234 attname(2)=
'add_offset '
235 attname(3)=
'_FillValue '
238 & attvalue, foundit, &
245 IF (.not.foundit(1))
THEN
251 IF (.not.foundit(2))
THEN
257 IF (.not.foundit(3))
THEN
265 IF (
PRESENT(checksum))
THEN
282 SELECT CASE (abs(mytype))
310 IF (.not.
allocated(wrk))
THEN
311 allocate ( wrk(npts) )
326 status=nf90_get_var(ncid, ncvarid, wrk, start, total)
331 IF (status.eq.nf90_noerr)
THEN
335 IF (abs(wrk(i)).ge.abs(aspval))
THEN
338 wrk(i)=ascl*(afactor*wrk(i)+aoffset)
339 amin=min(amin,wrk(i))
340 amax=max(amax,wrk(i))
343 IF ((abs(amin).ge.abs(aspval)).and. &
344 & (abs(amax).ge.abs(aspval)))
THEN
355 CALL mp_reduce (ng, model, 2, rbuffer, op_handle)
376# if defined MASKING && defined READ_WATER
388 SELECT CASE (abs(mytype))
427 IF (.not.
allocated(a2d))
THEN
428 allocate ( a2d(ijsize) )
430 IF (.not.
allocated(wrk))
THEN
431 allocate ( wrk(npts) )
446 status=nf90_get_var(ncid, ncvarid, wrk(istr:), start, total)
451 IF (status.eq.nf90_noerr)
THEN
452 CALL mp_collect (ng, model, npts, inival, wrk)
460 IF (abs(wrk(i)).ge.abs(aspval))
THEN
463 wrk(i)=ascl*(afactor*wrk(i)+aoffset)
464 amin=min(amin,wrk(i))
465 amax=max(amax,wrk(i))
468 IF ((abs(amin).ge.abs(aspval)).and. &
469 & (abs(amax).ge.abs(aspval)))
THEN
482 ij=
scalars(ng)%IJwater(np,wtype)
504# if defined MASKING && defined READ_WATER
505 IF (
allocated(a2d))
THEN
510 IF (
allocated(wrk))
THEN
522 & ncvname, ncvarid, &
523 & tindex, gtype, Vsize, &
524 & LBi, UBi, LBj, UBj, LBk, UBk, &
525 & Ascl, Amin, Amax, &
530 & checksum)
RESULT (status)
546 integer,
intent(in) :: ng, model, ncid, ncvarid, tindex, gtype
547 integer,
intent(in) :: lbi, ubi, lbj, ubj, lbk, ubk
548 integer,
intent(in) :: vsize(4)
550 integer(i8b),
intent(out),
optional :: checksum
552 real(dp),
intent(in) :: ascl
553 real(r8),
intent(out) :: amin
554 real(r8),
intent(out) :: amax
556 character (len=*),
intent(in) :: ncname
557 character (len=*),
intent(in) :: ncvname
561 real(r8),
intent(in) :: amask(lbi:,lbj:)
563 real(r8),
intent(out) :: adat(lbi:,lbj:,lbk:)
566 real(r8),
intent(in) :: amask(lbi:ubi,lbj:ubj)
568 real(r8),
intent(out) :: adat(lbi:ubi,lbj:ubj,lbk:ubk)
574 logical,
dimension(3) :: foundit
576 integer :: i, j, k, ic, npts, nwpts, status, wtype
577 integer :: is, ie, js, je
578 integer :: imin, imax, jmin, jmax, koff
579 integer :: ilen, jlen, klen, ijlen
580 integer :: cgrid, mytype, ghost
584 integer,
dimension(4) :: start, total
586 real(r8) :: afactor, aoffset, aspval
588 real(r8),
dimension(3) :: attvalue
590 real(r8),
allocatable :: cwrk(:)
592# if defined INLINE_2DIO && defined DISTRIBUTE
593 real(r8),
dimension(2+(Lm(ng)+2)*(Mm(ng)+2)) :: wrk
595 real(r8),
dimension(2+(Lm(ng)+2)*(Mm(ng)+2)*(UBk-LBk+1)) :: wrk
598 character (len=12),
dimension(3) :: attname
600 character (len=*),
parameter :: myfile = &
601 & __FILE__//
", nf90_fread3d"
613 SELECT CASE (abs(mytype))
678 attname(1)=
'scale_factor'
679 attname(2)=
'add_offset '
680 attname(3)=
'_FillValue '
683 & attvalue, foundit, &
690 IF (.not.foundit(1))
THEN
696 IF (.not.foundit(2))
THEN
702 IF (.not.foundit(3))
THEN
718 IF (model.eq.
iadm)
THEN
725# if defined READ_WATER && defined MASKING
730 SELECT CASE (abs(mytype))
747 nwpts=(
lm(ng)+2)*(
mm(ng)+2)
748# if !(defined INLINE_2DIO && defined DISTRIBUTE)
755 IF (mytype.gt.0)
THEN
765# if !(defined INLINE_2DIO && defined DISTRIBUTE)
768# if defined READ_WATER && defined MASKING
784 IF (
PRESENT(checksum))
THEN
798# if defined INLINE_2DIO && defined DISTRIBUTE
809 status=nf90_get_var(ncid, ncvarid, wrk, start, total)
810 IF (status.eq.nf90_noerr)
THEN
812 IF (abs(wrk(i)).ge.abs(aspval))
THEN
815 wrk(i)=ascl*(afactor*wrk(i)+aoffset)
816 amin=min(amin,wrk(i))
817 amax=max(amax,wrk(i))
820 IF ((abs(amin).ge.abs(aspval)).and. &
821 & (abs(amax).ge.abs(aspval)))
THEN
830 IF (
founderror(status, nf90_noerr, __line__, myfile))
THEN
846 & nghost, mytype, amin, amax, &
847# if defined READ_WATER && defined MASKING
848 & nwpts,
scalars(ng)%IJwater(:,wtype), &
850 & npts, wrk, adat(:,:,k))
853 CALL mp_scatter3d (ng, model, lbi, ubi, lbj, ubj, lbk, ubk, &
854 & nghost, mytype, amin, amax, &
855# if defined READ_WATER && defined MASKING
856 & nwpts,
scalars(ng)%IJwater(:,wtype), &
865 IF (mytype.gt.0)
THEN
875# if defined MASKING || defined READ_WATER
881 IF (amask(i,j).gt.0.0_r8)
THEN
900 npts=(imax-imin+1)*(jmax-jmin+1)*(ubk-lbk+1)
901 IF (.not.
allocated(cwrk))
allocate ( cwrk(npts) )
902 cwrk=pack(adat(imin:imax, jmin:jmax, lbk:ubk), .true.)
903 CALL get_hash (cwrk, npts, checksum, .true.)
905 npts=(ie-is+1)*(je-js+1)*(ubk-lbk+1)
906 IF (.not.
allocated(cwrk))
allocate ( cwrk(npts) )
907 cwrk=pack(adat(is:ie, js:je, lbk:ubk), .true.)
908 CALL get_hash (cwrk, npts, checksum)
910 IF (
allocated(cwrk))
deallocate (cwrk)
917#if defined PIO_LIB && defined DISTRIBUTE
922 & tindex, pioDesc, Vsize, &
923 & LBi, UBi, LBj, UBj, LBk, UBk, &
924 & Ascl, Amin, Amax, &
929 & checksum)
RESULT (status)
938 integer,
intent(in) :: ng, model, tindex
939 integer,
intent(in) :: lbi, ubi, lbj, ubj, lbk, ubk
940 integer,
intent(in) :: vsize(4)
942 integer(i8b),
intent(out),
optional :: checksum
944 real(dp),
intent(in) :: ascl
945 real(r8),
intent(out) :: amin
946 real(r8),
intent(out) :: amax
948 character (len=*),
intent(in) :: ncname
949 character (len=*),
intent(in) :: ncvname
953 real(r8),
intent(in) :: amask(lbi:,lbj:)
955 real(r8),
intent(out) :: adat(lbi:,lbj:,lbk:)
958 real(r8),
intent(in) :: amask(lbi:ubi,lbj:ubj)
960 real(r8),
intent(out) :: adat(lbi:ubi,lbj:ubj,lbk:ubk)
963 TYPE (file_desc_t),
intent(inout) :: piofile
964 TYPE (io_desc_t),
intent(inout) :: piodesc
970 logical,
dimension(3) :: foundit
972 integer :: i, j, k, npts, status
973 integer :: is, ie, js, je
974 integer :: imin, imax, jmin, jmax
975 integer :: cgrid, ghost, dkind, gtype
977 integer,
dimension(4) :: start, total
979 real(r8) :: afactor, aoffset, aspval, avalue
980 real(r8) :: my_amin, my_amax
982 real(r8),
dimension(3) :: attvalue
983 real(r8),
dimension(2) :: rbuffer
985 real(r4),
pointer :: awrk4(:,:,:)
986 real(r8),
pointer :: awrk8(:,:,:)
987 real(r8),
allocatable :: cwrk(:)
989 character (len=12),
dimension(3) :: attname
990 character (len= 3),
dimension(2) :: op_handle
992 character (len=*),
parameter :: myfile = &
993 & __FILE__//
", pio_fread3d"
1012 SELECT CASE (abs(gtype))
1066 attname(1)=
'scale_factor'
1067 attname(2)=
'add_offset '
1068 attname(3)=
'_FillValue '
1071 & attvalue, foundit, &
1072 & piofile = piofile)
1078 IF (.not.foundit(1))
THEN
1084 IF (.not.foundit(2))
THEN
1090 IF (.not.foundit(3))
THEN
1098 IF (
PRESENT(checksum))
THEN
1113 IF (dkind.eq.pio_double)
THEN
1114 IF (.not.
associated(awrk8))
THEN
1115 allocate ( awrk8(imin:imax, jmin:jmax, lbk:ubk) )
1119 IF (.not.
associated(awrk4))
THEN
1120 allocate ( awrk4(imin:imax, jmin:jmax, lbk:ubk) )
1127 IF (tindex.gt.0)
THEN
1128 CALL pio_setframe (piofile, &
1130 & int(tindex, kind=pio_offset_kind))
1135 IF (dkind.eq.pio_double)
THEN
1136 CALL pio_read_darray (piofile, &
1139 & awrk8(imin:,jmin:,lbk:), &
1145 IF (abs(awrk8(i,j,k)).ge.abs(aspval))
THEN
1148 avalue=ascl*(afactor*awrk8(i,j,k)+aoffset)
1150 my_amin=min(my_amin,avalue)
1151 my_amax=max(my_amax,avalue)
1156 IF (
associated(awrk8))
deallocate (awrk8)
1161 CALL pio_read_darray (piofile, &
1164 & awrk4(imin:,jmin:,lbk:), &
1170 IF (abs(awrk4(i,j,k)).ge.abs(aspval))
THEN
1173 avalue=real(ascl*(afactor*awrk4(i,j,k)+aoffset),r8)
1175 my_amin=real(min(my_amin,avalue),r8)
1176 my_amax=real(max(my_amax,avalue),r8)
1181 IF (
associated(awrk4))
deallocate (awrk4)
1187 npts=(imax-imin+1)*(jmax-jmin+1)*(ubk-lbk+1)
1188 IF (.not.
allocated(cwrk))
allocate ( cwrk(npts) )
1189 cwrk=pack(adat(imin:imax, jmin:jmax, lbk:ubk), .true.)
1190 CALL get_hash (cwrk, npts, checksum, .true.)
1191 IF (
allocated(cwrk))
deallocate (cwrk)
1200 CALL mp_reduce (ng, model, 2, rbuffer, op_handle)
1204 IF ((abs(amin).ge.abs(
spval)).and. &
1205 & (abs(amax).ge.abs(
spval)))
THEN
subroutine mp_scatter3d(ng, model, lbi, ubi, lbj, ubj, lbk, ubk, nghost, gtype, amin, amax, nwpts, ij_water, npts, a, awrk)
subroutine mp_scatter2d(ng, model, lbi, ubi, lbj, ubj, nghost, gtype, amin, amax, nwpts, ij_water, npts, a, awrk)
subroutine, public tile_bounds_1d(ng, tile, imax, istr, iend)
subroutine, public get_hash(a, asize, hash, lreduce)
type(t_bounds), dimension(:), allocatable bounds
integer, parameter b3dvar
integer, parameter r3dvar
type(t_iobounds), dimension(:), allocatable iobounds
integer, parameter u3dvar
integer, dimension(:), allocatable lm
integer, parameter u2dvar
integer, parameter w3dvar
integer, parameter p2dvar
integer, dimension(:), allocatable mm
integer, parameter r2dvar
integer, parameter l3dvar
integer, parameter v2dvar
integer, parameter p3dvar
integer, parameter v3dvar
real(dp), parameter spval
real(dp), parameter spval_check
type(t_scalars), dimension(:), allocatable scalars
integer function pio_fread3d(ng, model, ncname, piofile, ncvname, piovar, tindex, piodesc, vsize, lbi, ubi, lbj, ubj, lbk, ubk, ascl, amin, amax, amask, adat, checksum)
integer function nf90_fread3d(ng, model, ncname, ncid, ncvname, ncvarid, tindex, gtype, vsize, lbi, ubi, lbj, ubj, lbk, ubk, ascl, amin, amax, amask, adat, checksum)
logical function, public founderror(flag, noerr, line, routine)