EVOLUTION: Add support for profiling.

Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
This commit is contained in:
Grzegorz Kowal 2014-09-14 20:38:53 -03:00
parent d1e78eb0b7
commit f89d213386

View File

@ -31,10 +31,22 @@
!
module evolution
#ifdef PROFILE
! import external subroutines
!
use timers, only : set_timer, start_timer, stop_timer
#endif /* PROFILE */
! module variables are not implicit by default
!
implicit none
#ifdef PROFILE
! timer indices
!
integer , save :: imi, ima, imt, imu, imf, imn, imv
#endif /* PROFILE */
! pointer to the temporal integration subroutine
!
procedure(evolve_euler), pointer, save :: evolve => null()
@ -116,6 +128,22 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! set timer descriptions
!
call set_timer('evolution:: initialization' , imi)
call set_timer('evolution:: solution advance', ima)
call set_timer('evolution:: new time step' , imt)
call set_timer('evolution:: solution update' , imu)
call set_timer('evolution:: flux update' , imf)
call set_timer('evolution:: increment update', imn)
call set_timer('evolution:: variable update' , imv)
! start accounting time for module initialization/finalization
!
call start_timer(imi)
#endif /* PROFILE */
! get the integration method and the value of the CFL coefficient
!
call get_parameter_string ("time_advance", integration)
@ -185,6 +213,12 @@ module evolution
end if
#ifdef PROFILE
! stop accounting time for module initialization/finalization
!
call stop_timer(imi)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine initialize_evolution
@ -213,9 +247,23 @@ module evolution
integer, intent(inout) :: iret
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for module initialization/finalization
!
call start_timer(imi)
#endif /* PROFILE */
! nullify pointer to integration subroutine
!
nullify(evolve)
#ifdef PROFILE
! stop accounting time for module initialization/finalization
!
call stop_timer(imi)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine finalize_evolution
@ -256,6 +304,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for solution advance
!
call start_timer(ima)
#endif /* PROFILE */
! find new time step
!
call new_time_step(dtnext)
@ -296,6 +350,12 @@ module evolution
end if ! toplev > 1
#ifdef PROFILE
! stop accounting time for solution advance
!
call stop_timer(ima)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine advance
@ -353,6 +413,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for new time step estimation
!
call start_timer(imt)
#endif /* PROFILE */
! reset the maximum speed, and the highest level
!
cmax = eps
@ -414,6 +480,12 @@ module evolution
!
if (dtnext > 0.0d+00) dt = min(dtn, dtnext)
#ifdef PROFILE
! stop accounting time for new time step estimation
!
call stop_timer(imt)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine new_time_step
@ -467,6 +539,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for one step update
!
call start_timer(imu)
#endif /* PROFILE */
! update fluxes
!
call update_fluxes()
@ -515,6 +593,12 @@ module evolution
!
call boundary_variables()
#ifdef PROFILE
! stop accounting time for one step update
!
call stop_timer(imu)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine evolve_euler
@ -562,6 +646,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for one step update
!
call start_timer(imu)
#endif /* PROFILE */
! update fluxes
!
call update_fluxes()
@ -654,6 +744,12 @@ module evolution
!
call boundary_variables()
#ifdef PROFILE
! stop accounting time for one step update
!
call stop_timer(imu)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine evolve_rk2
@ -714,6 +810,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for one step update
!
call start_timer(imu)
#endif /* PROFILE */
! prepare things which don't change later
!
if (first) then
@ -856,6 +958,12 @@ module evolution
!
call boundary_variables()
#ifdef PROFILE
! stop accounting time for one step update
!
call stop_timer(imu)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine evolve_ssprk2
@ -913,6 +1021,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for one step update
!
call start_timer(imu)
#endif /* PROFILE */
!! 1st substep of integration
!!
! prepare the fractional time step
@ -1063,6 +1177,12 @@ module evolution
!
call boundary_variables()
#ifdef PROFILE
! stop accounting time for one step update
!
call stop_timer(imu)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine evolve_rk3
@ -1121,6 +1241,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for one step update
!
call start_timer(imu)
#endif /* PROFILE */
!= 1st step: U(1) = U(n) + 1/2 dt F[U(n)]
!
! calculate the fractional time step
@ -1311,6 +1437,12 @@ module evolution
!
call boundary_variables()
#ifdef PROFILE
! stop accounting time for one step update
!
call stop_timer(imu)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine evolve_ssprk34
@ -1377,6 +1509,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for one step update
!
call start_timer(imu)
#endif /* PROFILE */
!= 1st step: U(1) = U(n) + b1 dt F[U(n)]
!
! calculate the fractional time step
@ -1614,6 +1752,12 @@ module evolution
!
call boundary_variables()
#ifdef PROFILE
! stop accounting time for one step update
!
call stop_timer(imu)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine evolve_ssprk35
@ -1662,6 +1806,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for fluxe update
!
call start_timer(imf)
#endif /* PROFILE */
! assign pdata with the first block on the data block list
!
pdata => list_data
@ -1694,6 +1844,12 @@ module evolution
!
call boundary_fluxes()
#ifdef PROFILE
! stop accounting time for flux update
!
call stop_timer(imf)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine update_fluxes
@ -1738,6 +1894,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for increment update
!
call start_timer(imn)
#endif /* PROFILE */
! reset the increment array du
!
du(:,:,:,:) = 0.0d+00
@ -1773,6 +1935,12 @@ module evolution
end do
#endif /* NDIMS == 3 */
#ifdef PROFILE
! stop accounting time for increment update
!
call stop_timer(imn)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine update_increment
@ -1811,6 +1979,12 @@ module evolution
!
!-------------------------------------------------------------------------------
!
#ifdef PROFILE
! start accounting time for variable update
!
call start_timer(imv)
#endif /* PROFILE */
! associate the pointer with the first block on the data block list
!
pdata => list_data
@ -1837,6 +2011,12 @@ module evolution
end do
#ifdef PROFILE
! stop accounting time for variable update
!
call stop_timer(imv)
#endif /* PROFILE */
!-------------------------------------------------------------------------------
!
end subroutine update_variables