150
150
PROGRAM bsnap
151
151
USE iso_fortran_env, only: real64, output_unit, error_unit, IOSTAT_END
152
152
USE DateCalc, only: epochToDate, timeGM
153
- USE snapdebug, only: iulog, idebug
153
+ USE snapdebug, only: iulog, idebug, acc_timer = > prefixed_accumulating_timer
154
154
USE snapargosML, only: argosdepofile, argosdosefile, argoshoursrelease, &
155
155
argoshourstep, argoshoursrun, iargos, margos, argosconcfile, nargos, &
156
156
argostime
@@ -260,6 +260,12 @@ PROGRAM bsnap
260
260
! > name of selected release position
261
261
character (len= 40 ), save :: srelnam = " *"
262
262
263
+ ! > Time spent in various components of SNAP
264
+ type (acc_timer) :: timeloop_timer
265
+ type (acc_timer) :: output_timer
266
+ type (acc_timer) :: input_timer
267
+ type (acc_timer) :: particleloop_timer
268
+
263
269
#if defined(TRAJ)
264
270
integer :: timeStart(6 ), timeCurrent(6 )
265
271
integer :: ilvl, k1, k2
@@ -664,9 +670,15 @@ PROGRAM bsnap
664
670
" in this build"
665
671
#endif
666
672
end if
673
+
674
+ timeloop_timer = acc_timer(" time_loop:" )
675
+ output_timer = acc_timer(" output/accumulation:" )
676
+ input_timer = acc_timer(" Reading MET input:" )
677
+ particleloop_timer = acc_timer(" Particle loop:" )
678
+
667
679
! start time loop
668
680
time_loop: do istep = 0 , nstep
669
-
681
+ call timeloop_timer % start()
670
682
write (iulog, * ) ' istep,nplume,npart: ' , istep, nplume, npart
671
683
flush (iulog)
672
684
if (mod (istep, nsteph) == 0 ) then
@@ -702,6 +714,7 @@ PROGRAM bsnap
702
714
nhleft = (nstep - istep + 1 )/ nsteph
703
715
if (nhrun < 0 ) nhleft = - nhleft
704
716
end if
717
+ call input_timer% start()
705
718
if (ftype == " netcdf" ) then
706
719
call readfield_nc(istep, nhleft, itimei, ihr1, ihr2, &
707
720
time_file, ierror)
@@ -715,6 +728,7 @@ PROGRAM bsnap
715
728
write (iulog, * ) " igtype, gparam(8): " , igtype, gparam
716
729
end if
717
730
if (ierror /= 0 ) call snap_error_exit(iulog)
731
+ call input_timer% stop_and_log()
718
732
719
733
n = time_file(5 )
720
734
call vtime(time_file, ierr)
@@ -771,6 +785,7 @@ PROGRAM bsnap
771
785
nxtinf = 1
772
786
ifldout = 0
773
787
! continue istep loop after initialization
788
+ call timeloop_timer% stop ()
774
789
cycle time_loop
775
790
end if
776
791
@@ -869,6 +884,9 @@ PROGRAM bsnap
869
884
do npl = 1 , nplume
870
885
iplume(npl)% ageInSteps = iplume(npl)% ageInSteps + 1
871
886
end do
887
+ ! $OMP END PARALLEL DO
888
+
889
+ call particleloop_timer% start()
872
890
! particle loop
873
891
! $OMP PARALLEL DO PRIVATE(pextra) SCHEDULE(guided) !np is private by default
874
892
part_do: do np = 1 , npart
@@ -898,6 +916,7 @@ PROGRAM bsnap
898
916
call checkDomain(pdata(np))
899
917
end do part_do
900
918
! $OMP END PARALLEL DO
919
+ call particleloop_timer% stop_and_log()
901
920
902
921
! ..remove inactive particles or without any mass left
903
922
call rmpart(rmlimit)
@@ -1029,6 +1048,7 @@ PROGRAM bsnap
1029
1048
end if
1030
1049
1031
1050
! ..field output if ifldout=1, always accumulation for average fields
1051
+ call output_timer% start()
1032
1052
if (idailyout == 1 ) then
1033
1053
! daily output, append +x for each day
1034
1054
! istep/nsteph = hour -> /24 =day
@@ -1053,6 +1073,7 @@ PROGRAM bsnap
1053
1073
endif
1054
1074
if (ierror /= 0 ) call snap_error_exit(iulog)
1055
1075
end if
1076
+ call output_timer% stop_and_log()
1056
1077
1057
1078
if (isteph == 0 .AND. iprecip < nprecip) iprecip = iprecip + 1
1058
1079
@@ -1110,6 +1131,7 @@ PROGRAM bsnap
1110
1131
enddo
1111
1132
endif
1112
1133
#endif
1134
+ call timeloop_timer% stop_and_log()
1113
1135
end do time_loop
1114
1136
#if defined(TRAJ)
1115
1137
close (13 )
@@ -1135,6 +1157,11 @@ PROGRAM bsnap
1135
1157
write (error_unit, ' ('' mhmax='' ,f10.2)' ) mhmax
1136
1158
write (error_unit, ' ('' mhmin='' ,f10.2)' ) mhmin
1137
1159
write (error_unit, * )
1160
+
1161
+ call timeloop_timer% print_accumulated()
1162
+ call output_timer% print_accumulated()
1163
+ call input_timer% print_accumulated()
1164
+ call particleloop_timer% print_accumulated()
1138
1165
! b_end
1139
1166
write (iulog, * ) ' SNAP run finished'
1140
1167
write (error_unit, * ) ' SNAP run finished'
@@ -1192,7 +1219,7 @@ subroutine read_inputfile(snapinput_unit)
1192
1219
#if defined(FIMEX)
1193
1220
use find_parameters_fi, only: detect_gridparams_fi
1194
1221
#endif
1195
-
1222
+
1196
1223
! > Open file unit
1197
1224
integer , intent (in ) :: snapinput_unit
1198
1225
0 commit comments