30 public :: statistics_total
31 public :: statistics_detail
32 public :: statistics_horizontal_mean
33 public :: statistics_horizontal_min
34 public :: statistics_horizontal_max
36 interface statistics_total
39 end interface statistics_total
41 interface statistics_detail
44 end interface statistics_detail
46 interface statistics_horizontal_mean
49 end interface statistics_horizontal_mean
51 interface statistics_horizontal_max
54 end interface statistics_horizontal_max
56 interface statistics_horizontal_min
59 end interface statistics_horizontal_min
74 logical,
private :: statistics_use_globalcomm = .false.
87 namelist / param_statistics / &
89 statistics_use_globalcomm
97 log_info(
"STATISTICS_setup",*)
'Setup' 103 log_info(
"STATISTICS_setup",*)
'Not found namelist. Default used.' 104 elseif( ierr > 0 )
then 105 log_error(
"STATISTICS_setup",*)
'Not appropriate names in namelist PARAM_STATISTICS. Check!' 108 log_nml(param_statistics)
111 log_info(
"STATISTICS_setup",*)
'Caluculate total statistics for monitoring? : ',
statistics_checktotal 112 if ( statistics_use_globalcomm )
then 113 log_info_cont(*)
'=> The total is calculated for the global domain.' 115 log_info_cont(*)
'=> The total is calculated for the local domain.' 124 IA, IS, IE, JA, JS, JE, &
136 integer,
intent(in) :: IA, IS, IE
137 integer,
intent(in) :: JA, JS, JE
139 real(RP),
intent(in) :: var(ia,ja)
140 character(len=*),
intent(in) :: varname
141 real(RP),
intent(in) :: area(ia,ja)
142 real(RP),
intent(in) :: total
144 logical,
intent(in),
optional :: log_suppress
145 real(RP),
intent(out),
optional :: mean
146 real(DP),
intent(out),
optional :: sum
149 real(DP) :: sendbuf(2), recvbuf(2)
150 real(DP) :: sum_, mean_
158 if ( var(is,js) /= undef )
then 162 statval = statval + var(i,j) * area(i,j)
167 if ( .NOT. ( statval > -1.0_dp .OR. statval < 1.0_dp ) )
then 168 log_error(
"STATISTICS_total_2D",*)
'NaN is detected for ', trim(varname),
' in rank ',
prc_myrank 172 if (
present(log_suppress) )
then 173 suppress_ = log_suppress
178 if ( statistics_use_globalcomm )
then 183 call mpi_allreduce( sendbuf(:), recvbuf(:), &
185 mpi_double_precision, &
187 prc_local_comm_world, &
192 mean_ = recvbuf(1) / recvbuf(2)
194 if ( .not. suppress_ )
then 195 log_info(
"STATISTICS_total_2D",
'(1x,A,A24,A,ES24.17)') &
196 '[', trim(varname),
'] MEAN(global) = ', mean_
200 mean_ = statval / total
203 if ( .not. suppress_ )
then 204 log_info(
"STATISTICS_total_2D",
'(1x,A,A24,A,ES24.17)') &
205 '[', trim(varname),
'] MEAN(local) = ', mean_
209 if (
present(mean) ) mean = mean_
210 if (
present(sum ) ) sum = sum_
218 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
230 integer,
intent(in) :: KA, KS, KE
231 integer,
intent(in) :: IA, IS, IE
232 integer,
intent(in) :: JA, JS, JE
234 real(RP),
intent(in) :: var(ka,ia,ja)
235 character(len=*),
intent(in) :: varname
236 real(RP),
intent(in) :: vol(ka,ia,ja)
237 real(RP),
intent(in) :: total
239 logical,
intent(in),
optional :: log_suppress
240 real(RP),
intent(out),
optional :: mean
241 real(DP),
intent(out),
optional :: sum
244 real(DP) :: sendbuf(2), recvbuf(2)
245 real(DP) :: mean_, sum_
253 if ( var(ks,is,js) /= undef )
then 258 statval = statval + var(k,i,j) * vol(k,i,j)
264 if ( .NOT. ( statval > -1.0_dp .OR. statval < 1.0_dp ) )
then 265 log_error(
"STATISTICS_total_3D",*)
'NaN is detected for ', trim(varname),
' in rank ',
prc_myrank 269 if (
present(log_suppress) )
then 270 suppress_ = log_suppress
275 if ( statistics_use_globalcomm )
then 280 call mpi_allreduce( sendbuf(:), recvbuf(:), &
282 mpi_double_precision, &
284 prc_local_comm_world, &
289 mean_ = recvbuf(1) / recvbuf(2)
291 if ( .not. suppress_ )
then 292 log_info(
"STATISTICS_total_3D",
'(1x,A,A24,A,ES24.17)') &
293 '[', trim(varname),
'] MEAN(global) = ', mean_
297 mean_ = statval / total
300 if ( .not. suppress_ )
then 301 log_info(
"STATISTICS_total_3D",
'(1x,A,A24,A,ES24.17)') &
302 '[', trim(varname),
'] MEAN(local) = ', mean_
306 if (
present(mean) ) mean = mean_
307 if (
present(sum ) ) sum = sum_
315 IA, IS, IE, JA, JS, JE, &
320 integer,
intent(in) :: IA, IS, IE
321 integer,
intent(in) :: JA, JS, JE
322 real(RP),
intent(in) :: var (ia,ja)
323 real(RP),
intent(in) :: area(ia,ja)
324 real(RP),
intent(out) :: varmean
326 real(DP) :: statval (2)
327 real(DP) :: allstatval(2)
336 if ( var(i,j) /= undef )
then 337 statval(1) = statval(1) + area(i,j) * var(i,j)
338 statval(2) = statval(2) + area(i,j)
345 call mpi_allreduce( statval(:), &
348 mpi_double_precision, &
354 if ( allstatval(2) > 0.0_dp )
then 355 varmean = allstatval(1) / allstatval(2)
364 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
369 integer,
intent(in) :: KA, KS, KE
370 integer,
intent(in) :: IA, IS, IE
371 integer,
intent(in) :: JA, JS, JE
373 real(RP),
intent(in) :: var (ka,ia,ja)
374 real(RP),
intent(in) :: area( ia,ja)
375 real(RP),
intent(out) :: varmean(ka)
377 real(DP) :: statval (2,ka)
378 real(DP) :: allstatval(2,ka)
384 statval(:,:) = 0.0_dp
388 if ( var(k,i,j) /= undef )
then 389 statval(1,k) = statval(1,k) + area(i,j) * var(k,i,j)
390 statval(2,k) = statval(2,k) + area(i,j)
398 call mpi_allreduce( statval(:,ks:ke), &
399 allstatval(:,ks:ke), &
401 mpi_double_precision, &
408 if ( allstatval(2,k) > 0.0_dp )
then 409 varmean(k) = allstatval(1,k) / allstatval(2,k)
427 IA, IS, IE, JA, JS, JE, &
435 integer,
intent(in) :: IA, IS, IE
436 integer,
intent(in) :: JA, JS, JE
438 real(RP),
intent(in) :: var(ia,ja)
439 real(RP),
intent(out) :: varmin
442 real(RP) :: allstatval
451 if ( var(i,j) /= undef .and. var(i,j) < statval )
then 459 call mpi_allreduce( statval, &
468 if ( allstatval < huge )
then 478 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
486 integer,
intent(in) :: KA, KS, KE
487 integer,
intent(in) :: IA, IS, IE
488 integer,
intent(in) :: JA, JS, JE
490 real(RP),
intent(in) :: var(ka,ia,ja)
491 real(RP),
intent(out) :: varmin(ka)
493 real(RP) :: statval (ka)
494 real(RP) :: allstatval(ka)
504 if ( var(k,i,j) /= undef .and. var(k,i,j) < statval(k) )
then 505 statval(k) = var(k,i,j)
513 call mpi_allreduce( statval(ks:ke), &
523 if ( allstatval(k) < huge )
then 524 varmin(k) = allstatval(k)
542 IA, IS, IE, JA, JS, JE, &
550 integer,
intent(in) :: IA, IS, IE
551 integer,
intent(in) :: JA, JS, JE
553 real(RP),
intent(in) :: var(ia,ja)
554 real(RP),
intent(out) :: varmax
557 real(RP) :: allstatval
566 if ( var(i,j) /= undef .and. var(i,j) > statval )
then 574 call mpi_allreduce( statval, &
583 if ( allstatval > - huge )
then 593 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
601 integer,
intent(in) :: KA, KS, KE
602 integer,
intent(in) :: IA, IS, IE
603 integer,
intent(in) :: JA, JS, JE
605 real(RP),
intent(in) :: var(ka,ia,ja)
606 real(RP),
intent(out) :: varmax(ka)
608 real(RP) :: statval (ka)
609 real(RP) :: allstatval(ka)
619 if ( var(k,i,j) /= undef .and. var(k,i,j) > statval(k) )
then 620 statval(k) = var(k,i,j)
628 call mpi_allreduce( statval(ks:ke), &
638 if ( allstatval(k) > - huge )
then 639 varmax(k) = allstatval(k)
657 KA, KS, KE, IA, IS, IE, JA, JS, JE, VA, &
666 integer,
intent(in) :: KA, KS, KE
667 integer,
intent(in) :: IA, IS, IE
668 integer,
intent(in) :: JA, JS, JE
669 integer,
intent(in) :: VA
671 character(len=*),
intent(in) :: varname(va)
672 real(RP),
intent(in) :: var(ka,ia,ja,va)
674 logical,
intent(in),
optional :: local
676 real(RP) :: statval_l ( va,2)
677 integer :: statidx_l (3,va,2)
680 real(RP) :: allstatval(va,2)
681 integer :: allstatidx(va,2)
682 logical :: do_globalcomm
689 do_globalcomm = statistics_use_globalcomm
690 if (
present(local) ) do_globalcomm = ( .not. local )
693 log_info(
"STATISTICS_detail_3D",*)
'Variable Statistics ' 695 statval_l( v,:) = var(ks,is,js,v)
696 statidx_l(1,v,:) = ks
697 statidx_l(2,v,:) = is
698 statidx_l(3,v,:) = js
702 if ( var(k,i,j,v) > statval_l(v,1) )
then 703 statval_l( v,1) = var(k,i,j,v)
708 if ( var(k,i,j,v) < statval_l(v,2) )
then 709 statval_l( v,2) = var(k,i,j,v)
719 if ( do_globalcomm )
then 722 call mpi_allgather( statval_l(:,:), &
728 prc_local_comm_world, &
731 call mpi_allgather( statidx_l(:,:,:), &
737 prc_local_comm_world, &
743 allstatval(v,1) = statval(v,1,0)
744 allstatval(v,2) = statval(v,2,0)
747 if ( statval(v,1,p) > allstatval(v,1) )
then 748 allstatval(v,1) = statval(v,1,p)
751 if ( statval(v,2,p) < allstatval(v,2) )
then 752 allstatval(v,2) = statval(v,2,p)
756 log_info_cont(*)
'[', trim(varname(v)),
']' 757 log_info_cont(
'(1x,A,ES17.10,A,4(I5,A))')
' MAX =', &
758 allstatval(v,1),
' (rank=', &
759 allstatidx(v,1),
'; ', &
760 statidx(1,v,1,allstatidx(v,1)),
',', &
761 statidx(2,v,1,allstatidx(v,1)),
',', &
762 statidx(3,v,1,allstatidx(v,1)),
')' 763 log_info_cont(
'(1x,A,ES17.10,A,4(I5,A))')
' MIN =', &
764 allstatval(v,2),
' (rank=', &
765 allstatidx(v,2),
'; ', &
766 statidx(1,v,2,allstatidx(v,2)),
',', &
767 statidx(2,v,2,allstatidx(v,2)),
',', &
768 statidx(3,v,2,allstatidx(v,2)),
')' 773 log_info_cont(*)
'[', trim(varname(v)),
']' 774 log_info_cont(
'(1x,A,ES17.10,A,3(I5,A))')
'MAX = ', &
775 statval_l( v,1),
' (', &
776 statidx_l(1,v,1),
',', &
777 statidx_l(2,v,1),
',', &
779 log_info_cont(
'(1x,A,ES17.10,A,3(I5,A))')
'MIN = ', &
780 statval_l( v,2),
' (', &
781 statidx_l(1,v,2),
',', &
782 statidx_l(2,v,2),
',', &
793 IA, IS, IE, JA, JS, JE, VA, &
803 integer,
intent(in) :: IA, IS, IE
804 integer,
intent(in) :: JA, JS, JE
805 integer,
intent(in) :: VA
807 character(len=*),
intent(in) :: varname(va)
808 real(RP),
intent(in) :: var(ia,ja,va)
810 logical,
intent(in),
optional :: local
812 real(RP) :: statval_l ( va,2)
813 integer :: statidx_l (2,va,2)
816 real(RP) :: allstatval(va,2)
817 integer :: allstatidx(va,2)
818 logical :: do_globalcomm
825 do_globalcomm = statistics_use_globalcomm
826 if (
present(local) ) do_globalcomm = ( .not. local )
829 log_info(
"STATISTICS_detail_2D",*)
'Variable Statistics ' 831 statval_l( v,:) = var(is,js,v)
832 statidx_l(1,v,:) = is
833 statidx_l(2,v,:) = js
836 if ( var(i,j,v) > statval_l(v,1) )
then 837 statval_l( v,1) = var(i,j,v)
841 if ( var(i,j,v) < statval_l(v,2) )
then 842 statval_l( v,2) = var(i,j,v)
850 if ( do_globalcomm )
then 853 call mpi_allgather( statval_l(:,:), &
859 prc_local_comm_world, &
862 call mpi_allgather( statidx_l(:,:,:), &
868 prc_local_comm_world, &
874 allstatval(v,1) = statval(v,1,0)
875 allstatval(v,2) = statval(v,2,0)
878 if ( statval(v,1,p) > allstatval(v,1) )
then 879 allstatval(v,1) = statval(v,1,p)
882 if ( statval(v,2,p) < allstatval(v,2) )
then 883 allstatval(v,2) = statval(v,2,p)
887 log_info_cont(*)
'[', trim(varname(v)),
']' 888 log_info_cont(
'(1x,A,ES17.10,A,3(I5,A))')
' MAX =', &
889 allstatval(v,1),
' (rank=', &
890 allstatidx(v,1),
'; ', &
891 statidx(1,v,1,allstatidx(v,1)),
',', &
892 statidx(2,v,1,allstatidx(v,1)),
')' 893 log_info_cont(
'(1x,A,ES17.10,A,3(I5,A))')
' MIN =', &
894 allstatval(v,2),
' (rank=', &
895 allstatidx(v,2),
'; ', &
896 statidx(1,v,2,allstatidx(v,2)),
',', &
897 statidx(2,v,2,allstatidx(v,2)),
')' 902 log_info_cont(*)
'[', trim(varname(v)),
']' 903 log_info_cont(
'(1x,A,ES17.10,A,2(I5,A))')
'MAX = ', &
904 statval_l( v,1),
' (', &
905 statidx_l(1,v,1),
',', &
907 log_info_cont(
'(1x,A,ES17.10,A,2(I5,A))')
'MIN = ', &
908 statval_l( v,2),
' (', &
909 statidx_l(1,v,2),
',', &
real(rp), public const_huge
huge number
subroutine statistics_horizontal_mean_2d(IA, IS, IE, JA, JS, JE, var, area, varmean)
Calc horizontal mean value.
integer, public comm_datatype
datatype of variable
subroutine statistics_detail_2d(IA, IS, IE, JA, JS, JE, VA, varname, var, local)
integer, public io_fid_conf
Config file ID.
logical, public statistics_checktotal
calc&report variable totals to logfile?
integer, public prc_nprocs
myrank in local communicator
subroutine statistics_horizontal_mean_3d(KA, KS, KE, IA, IS, IE, JA, JS, JE, var, area, varmean)
real(rp), public const_undef
subroutine statistics_total_2d(IA, IS, IE, JA, JS, JE, var, varname, area, total, log_suppress, mean, sum)
Calc domain sum and area-weighted mean.
subroutine, public statistics_setup
Setup.
subroutine statistics_horizontal_max_2d(IA, IS, IE, JA, JS, JE, var, varmax)
Calc horizontal maximum value.
integer, public prc_myrank
process num in local communicator
subroutine statistics_horizontal_min_3d(KA, KS, KE, IA, IS, IE, JA, JS, JE, var, varmin)
subroutine, public prc_abort
Abort Process.
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
subroutine statistics_horizontal_min_2d(IA, IS, IE, JA, JS, JE, var, varmin)
Calc horizontal minimum value.
subroutine statistics_total_3d(KA, KS, KE, IA, IS, IE, JA, JS, JE, var, varname, vol, total, log_suppress, mean, sum)
Calc domain sum and volume-weighted mean.
integer, public prc_local_comm_world
local communicator
subroutine, public comm_setup
Setup.
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
subroutine statistics_horizontal_max_3d(KA, KS, KE, IA, IS, IE, JA, JS, JE, var, varmax)
subroutine statistics_detail_3d(KA, KS, KE, IA, IS, IE, JA, JS, JE, VA, varname, var, local)
Search global maximum & minimum value.