13 #include "inc_openmp.h" 40 end interface stat_total
56 logical,
private :: statistics_use_globalcomm = .false.
67 namelist / param_statistics / &
69 statistics_use_globalcomm
75 if(
io_l )
write(
io_fid_log,*)
'++++++ Module[STATISTICS] / Categ[ATMOS-RM COMM] / Origin[SCALElib]' 81 if(
io_l )
write(
io_fid_log,*)
'*** Not found namelist. Default used.' 82 elseif( ierr > 0 )
then 83 write(*,*)
'xxx Not appropriate names in namelist PARAM_STATISTICS. Check!' 90 if(
io_l )
write(
io_fid_log,*)
'*** Allow global communication for statistics? : ', statistics_use_globalcomm
91 if ( statistics_use_globalcomm )
then 92 if(
io_l )
write(
io_fid_log,*)
'*** Global total is calculated using MPI_ALLreduce.' 94 if(
io_l )
write(
io_fid_log,*)
'*** Local total is calculated in each process.' 112 real(RP),
intent(out) :: allstatval
113 real(RP),
intent(in) :: var(
ia,
ja)
114 character(len=*),
intent(in) :: varname
116 character(len=H_SHORT) :: varname_trim
123 varname_trim = trim(varname)
129 statval = statval + var(i,j) * area(i,j)
133 if ( .NOT. ( statval > -1.0_rp .OR. statval < 1.0_rp ) )
then 134 write(*,*)
'xxx [STAT_total] NaN is detected for ', varname_trim,
' in rank ',
prc_myrank 138 if ( statistics_use_globalcomm )
then 141 call mpi_allreduce( statval, &
146 prc_local_comm_world, &
152 if ( varname_trim /=
"" )
then 154 '[', varname_trim,
'] SUM(global) =', allstatval
160 if ( varname_trim /=
"" )
then 162 '[', varname_trim,
'] SUM(local) =', statval
181 real(RP),
intent(out) :: allstatval
182 real(RP),
intent(in) :: var(
ka,
ia,
ja)
183 character(len=*),
intent(in) :: varname
185 character(len=H_SHORT) :: varname_trim
192 varname_trim = trim(varname)
199 statval = statval + var(k,i,j) * vol(k,i,j)
204 if ( .NOT. ( statval > -1.0_rp .OR. statval < 1.0_rp ) )
then 205 write(*,*)
'xxx [STAT_total] NaN is detected for ', varname_trim,
' in rank ',
prc_myrank 209 if ( statistics_use_globalcomm )
then 212 call mpi_allreduce( statval, &
217 prc_local_comm_world, &
223 if ( varname_trim /=
"" )
then 225 '[', varname_trim,
'] SUM(global) =', allstatval
231 if ( varname_trim /=
"" )
then 233 '[', varname_trim,
'] SUM(local) =', statval
242 subroutine stat_detail(var, varname, supress_globalcomm)
253 real(RP),
intent(inout) :: var(:,:,:,:)
254 character(len=*),
intent(in) :: varname(:)
255 logical,
intent(in),
optional :: supress_globalcomm
257 logical ,
allocatable :: halomask (:,:,:)
258 real(RP),
allocatable :: statval (:,:,:)
259 integer,
allocatable :: statidx (:,:,:,:)
260 real(RP),
allocatable :: allstatval(:,:)
261 integer,
allocatable :: allstatidx(:,:,:)
262 integer :: ksize, vsize
263 logical :: do_globalcomm
269 do_globalcomm = statistics_use_globalcomm
270 if (
present(supress_globalcomm) )
then 271 if ( supress_globalcomm )
then 272 do_globalcomm = .false.
276 ksize =
size(var(:,:,:,:),1)
277 vsize =
size(var(:,:,:,:),4)
279 allocate( halomask(ksize,
ia,
ja) ); halomask(:,:,:) = .false.
281 if ( ksize ==
ka )
then 290 allocate( allstatval( vsize,2) ); allstatval(:,:) =
const_undef8 291 allocate( allstatidx(1,vsize,2) ); allstatidx(:,:,:) =
const_undef2 296 statval( v,1,
prc_myrank) = maxval(var(:,:,:,v),mask=halomask)
297 statval( v,2,
prc_myrank) = minval(var(:,:,:,v),mask=halomask)
298 statidx(:,v,1,
prc_myrank) = maxloc(var(:,:,:,v),mask=halomask)
299 statidx(:,v,2,
prc_myrank) = minloc(var(:,:,:,v),mask=halomask)
302 if ( do_globalcomm )
then 306 call mpi_bcast( statval(1,1,p), &
310 prc_local_comm_world, &
313 call mpi_bcast( statidx(1,1,1,p), &
317 prc_local_comm_world, &
324 allstatval(v,1) = maxval(statval(v,1,:))
325 allstatval(v,2) = minval(statval(v,2,:))
326 allstatidx(:,v,1) = maxloc(statval(v,1,:))-1
327 allstatidx(:,v,2) = minloc(statval(v,2,:))-1
329 if(
io_l )
write(
io_fid_log,
'(1x,A,ES17.10,A,4(I5,A))')
' MAX =', &
330 allstatval( v,1),
'(', &
331 allstatidx(1,v,1),
',', &
332 statidx(1,v,1,allstatidx(1,v,1)),
',', &
333 statidx(2,v,1,allstatidx(1,v,1)),
',', &
334 statidx(3,v,1,allstatidx(1,v,1)),
')' 335 if(
io_l )
write(
io_fid_log,
'(1x,A,ES17.10,A,4(I5,A))')
' MIN =', &
336 allstatval( v,2),
'(', &
337 allstatidx(1,v,2),
',', &
338 statidx(1,v,2,allstatidx(1,v,2)),
',', &
339 statidx(2,v,2,allstatidx(1,v,2)),
',', &
340 statidx(3,v,2,allstatidx(1,v,2)),
')' 346 if(
io_l )
write(
io_fid_log,
'(1x,A,ES17.10,A,3(I5,A))')
'*** MAX = ', &
351 if(
io_l )
write(
io_fid_log,
'(1x,A,ES17.10,A,3(I5,A))')
'*** MIN = ', &
361 deallocate( halomask )
363 deallocate( statval )
364 deallocate( statidx )
366 deallocate( allstatval )
367 deallocate( allstatidx )
integer, public is
start point of inner domain: x, local
logical, public statistics_checktotal
calc&report variable totals to logfile?
integer, public comm_datatype
datatype of variable
integer, public je
end point of inner domain: y, local
integer, public prc_local_comm_world
local communicator
subroutine, public prc_mpistop
Abort MPI.
logical, public io_l
output log or not? (this process)
integer, public ke
end point of inner domain: z, local
integer, public ia
of x whole cells (local, with HALO)
integer, public ka
of z whole cells (local, with HALO)
real(rp), dimension(:,:), allocatable, public real_area
horizontal area [m2]
subroutine, public stat_setup
Setup.
integer, public js
start point of inner domain: y, local
integer, parameter, public const_undef2
undefined value (INT2)
subroutine stat_total_2d(allstatval, var, varname)
Calc volume/area-weighted global sum.
real(rp), dimension(:,:,:), allocatable, public real_vol
control volume [m3]
subroutine, public stat_detail(var, varname, supress_globalcomm)
Search global maximum & minimum value.
integer, public ks
start point of inner domain: z, local
integer, public prc_myrank
process num in local communicator
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
real(dp), parameter, public const_undef8
undefined value (REAL8)
integer, public ie
end point of inner domain: x, local
logical, public io_lnml
output log or not? (for namelist, this process)
subroutine stat_total_3d(allstatval, var, varname)
Calc volume/area-weighted global sum.
integer, public io_fid_conf
Config file ID.
integer, public io_fid_log
Log file ID.
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
integer, public prc_nprocs
myrank in local communicator
integer, public ja
of y whole cells (local, with HALO)