mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Use type bound procedures for Timer.
This commit is contained in:
parent
d4986ce6f1
commit
38f9226061
11 changed files with 52 additions and 65 deletions
|
|
@ -34,7 +34,6 @@ cmfd_execute.o: mesh_header.o
|
|||
cmfd_execute.o: output.o
|
||||
cmfd_execute.o: search.o
|
||||
cmfd_execute.o: tally.o
|
||||
cmfd_execute.o: timing.o
|
||||
|
||||
cmfd_header.o: constants.o
|
||||
|
||||
|
|
@ -59,7 +58,6 @@ cmfd_loss_operator.o: global.o
|
|||
|
||||
cmfd_message_passing.o: cmfd_header.o
|
||||
cmfd_message_passing.o: global.o
|
||||
cmfd_message_passing.o: timing.o
|
||||
|
||||
cmfd_output.o: cmfd_data.o
|
||||
cmfd_output.o: cmfd_header.o
|
||||
|
|
@ -80,7 +78,6 @@ cmfd_slepc_solver.o: cmfd_loss_operator.o
|
|||
cmfd_slepc_solver.o: cmfd_prod_operator.o
|
||||
cmfd_slepc_solver.o: constants.o
|
||||
cmfd_slepc_solver.o: global.o
|
||||
cmfd_slepc_solver.o: timing.o
|
||||
|
||||
cmfd_snes_solver.o: cmfd_jacobian_operator.o
|
||||
cmfd_snes_solver.o: cmfd_loss_operator.o
|
||||
|
|
@ -106,7 +103,6 @@ eigenvalue.o: source.o
|
|||
eigenvalue.o: state_point.o
|
||||
eigenvalue.o: string.o
|
||||
eigenvalue.o: tally.o
|
||||
eigenvalue.o: timing.o
|
||||
|
||||
cross_section.o: ace_header.o
|
||||
cross_section.o: constants.o
|
||||
|
|
@ -137,7 +133,6 @@ finalize.o: global.o
|
|||
finalize.o: hdf5_interface.o
|
||||
finalize.o: output.o
|
||||
finalize.o: tally.o
|
||||
finalize.o: timing.o
|
||||
|
||||
fission.o: ace_header.o
|
||||
fission.o: constants.o
|
||||
|
|
@ -156,7 +151,6 @@ fixed_source.o: source.o
|
|||
fixed_source.o: state_point.o
|
||||
fixed_source.o: string.o
|
||||
fixed_source.o: tally.o
|
||||
fixed_source.o: timing.o
|
||||
|
||||
geometry.o: constants.o
|
||||
geometry.o: datatypes.o
|
||||
|
|
@ -181,7 +175,7 @@ global.o: particle_header.o
|
|||
global.o: plot_header.o
|
||||
global.o: source_header.o
|
||||
global.o: tally_header.o
|
||||
global.o: timing.o
|
||||
global.o: timer_header.o
|
||||
|
||||
hdf5_interface.o: ace_header.o
|
||||
hdf5_interface.o: bank_header.o
|
||||
|
|
@ -214,7 +208,6 @@ initialize.o: state_point.o
|
|||
initialize.o: string.o
|
||||
initialize.o: tally_header.o
|
||||
initialize.o: tally_initialize.o
|
||||
initialize.o: timing.o
|
||||
|
||||
input_xml.o: cmfd_input.o
|
||||
input_xml.o: constants.o
|
||||
|
|
@ -356,4 +349,4 @@ tally_initialize.o: constants.o
|
|||
tally_initialize.o: global.o
|
||||
tally_initialize.o: tally_header.o
|
||||
|
||||
timing.o: constants.o
|
||||
timer_header.o: constants.o
|
||||
|
|
|
|||
|
|
@ -53,4 +53,4 @@ string.o \
|
|||
tally.o \
|
||||
tally_header.o \
|
||||
tally_initialize.o \
|
||||
timing.o
|
||||
timer_header.o
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ contains
|
|||
cmfd_inact_flush, cmfd_keff_tol, &
|
||||
cmfd_act_flush, current_batch, keff, &
|
||||
n_batches, message, master, mpi_err, rank
|
||||
use timing, only: timer_start, timer_stop
|
||||
|
||||
logical :: leave_cmfd
|
||||
|
||||
|
|
@ -45,7 +44,7 @@ contains
|
|||
|
||||
! stop cmfd timer
|
||||
if (master) then
|
||||
call timer_start(time_cmfd)
|
||||
call time_cmfd % start()
|
||||
end if
|
||||
|
||||
! filter processors (lowest PETSc group)
|
||||
|
|
@ -126,7 +125,7 @@ contains
|
|||
|
||||
! stop cmfd timer
|
||||
if (master) then
|
||||
call timer_stop(time_cmfd)
|
||||
call time_cmfd % stop()
|
||||
end if
|
||||
|
||||
! wait here for all procs
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ contains
|
|||
subroutine petsc_init_mpi()
|
||||
|
||||
use global, only: n_procs_cmfd, time_cmfd, rank, mpi_err
|
||||
use timing, only: timer_reset
|
||||
|
||||
integer :: new_comm ! new communicator
|
||||
integer :: color ! communicator color
|
||||
|
|
@ -41,7 +40,7 @@ contains
|
|||
call PetscInitialize(PETSC_NULL_CHARACTER,mpi_err)
|
||||
|
||||
! initialize timer
|
||||
call timer_reset(time_cmfd)
|
||||
call time_cmfd % reset()
|
||||
|
||||
end subroutine petsc_init_mpi
|
||||
|
||||
|
|
|
|||
|
|
@ -31,10 +31,9 @@ contains
|
|||
|
||||
subroutine cmfd_slepc_execute()
|
||||
|
||||
use global, only:time_cmfd,master
|
||||
use timing
|
||||
use global, only: time_cmfd, master
|
||||
|
||||
call timer_start(time_cmfd)
|
||||
call time_cmfd % start()
|
||||
! initialize data
|
||||
call init_data()
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ module eigenvalue
|
|||
use string, only: to_str
|
||||
use tally, only: synchronize_tallies, setup_active_usertallies, &
|
||||
reset_result
|
||||
use timing, only: timer_start, timer_stop
|
||||
|
||||
#ifdef HDF5
|
||||
use hdf5_interface, only: hdf5_write_state_point
|
||||
|
|
@ -50,7 +49,7 @@ contains
|
|||
call print_columns()
|
||||
|
||||
! Turn on inactive timer
|
||||
call timer_start(time_inactive)
|
||||
call time_inactive % start()
|
||||
|
||||
! ==========================================================================
|
||||
! LOOP OVER BATCHES
|
||||
|
|
@ -71,7 +70,7 @@ contains
|
|||
call initialize_generation()
|
||||
|
||||
! Start timer for transport
|
||||
call timer_start(time_transport)
|
||||
call time_transport % start()
|
||||
|
||||
! ====================================================================
|
||||
! LOOP OVER PARTICLES
|
||||
|
|
@ -86,12 +85,12 @@ contains
|
|||
end do PARTICLE_LOOP
|
||||
|
||||
! Accumulate time for transport
|
||||
call timer_stop(time_transport)
|
||||
call time_transport % stop()
|
||||
|
||||
! Distribute fission bank across processors evenly
|
||||
call timer_start(time_bank)
|
||||
call time_bank % start()
|
||||
call synchronize_bank()
|
||||
call timer_stop(time_bank)
|
||||
call time_bank % stop()
|
||||
|
||||
! Calculate shannon entropy
|
||||
if (entropy_on) call shannon_entropy()
|
||||
|
|
@ -105,7 +104,7 @@ contains
|
|||
|
||||
end do BATCH_LOOP
|
||||
|
||||
call timer_stop(time_active)
|
||||
call time_active % stop()
|
||||
|
||||
! ==========================================================================
|
||||
! END OF RUN WRAPUP
|
||||
|
|
@ -128,8 +127,8 @@ contains
|
|||
|
||||
if (current_batch == n_inactive + 1) then
|
||||
! Switch from inactive batch timer to active batch timer
|
||||
call timer_stop(time_inactive)
|
||||
call timer_start(time_active)
|
||||
call time_inactive % stop()
|
||||
call time_active % start()
|
||||
|
||||
! Enable active batches (and tallies_on if it hasn't been enabled)
|
||||
active_batches = .true.
|
||||
|
|
@ -169,9 +168,9 @@ contains
|
|||
integer :: i ! loop index for state point batches
|
||||
|
||||
! Collect tallies
|
||||
call timer_start(time_tallies)
|
||||
call time_tallies % start()
|
||||
call synchronize_tallies()
|
||||
call timer_stop(time_tallies)
|
||||
call time_tallies % stop()
|
||||
|
||||
! Collect results and statistics
|
||||
call calculate_keff()
|
||||
|
|
@ -278,7 +277,7 @@ contains
|
|||
end if
|
||||
p_sample = real(sites_needed,8)/real(total,8)
|
||||
|
||||
call timer_start(time_bank_sample)
|
||||
call time_bank_sample % start()
|
||||
|
||||
! ==========================================================================
|
||||
! SAMPLE N_PARTICLES FROM FISSION BANK AND PLACE IN TEMP_SITES
|
||||
|
|
@ -353,8 +352,8 @@ contains
|
|||
finish = bank_last
|
||||
end if
|
||||
|
||||
call timer_stop(time_bank_sample)
|
||||
call timer_start(time_bank_sendrecv)
|
||||
call time_bank_sample % stop()
|
||||
call time_bank_sendrecv % start()
|
||||
|
||||
#ifdef MPI
|
||||
! ==========================================================================
|
||||
|
|
@ -450,7 +449,7 @@ contains
|
|||
source_bank = temp_sites(1:n_particles)
|
||||
#endif
|
||||
|
||||
call timer_stop(time_bank_sendrecv)
|
||||
call time_bank_sendrecv % stop()
|
||||
|
||||
! Deallocate space for the temporary source bank on the last generation
|
||||
if (current_batch == n_batches .and. current_gen == gen_per_batch) &
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ module finalize
|
|||
use global
|
||||
use output, only: print_runtime, write_tallies
|
||||
use tally, only: tally_statistics
|
||||
use timing, only: timer_start, timer_stop
|
||||
|
||||
#ifdef MPI
|
||||
use mpi
|
||||
|
|
@ -28,7 +27,7 @@ contains
|
|||
subroutine finalize_run()
|
||||
|
||||
! Start finalization timer
|
||||
call timer_start(time_finalize)
|
||||
call time_finalize % start()
|
||||
|
||||
if (run_mode /= MODE_PLOTTING) then
|
||||
! Calculate statistics for tallies and write to tallies.out
|
||||
|
|
@ -44,8 +43,8 @@ contains
|
|||
#endif
|
||||
|
||||
! stop timers and show timing statistics
|
||||
call timer_stop(time_finalize)
|
||||
call timer_stop(time_total)
|
||||
call time_finalize % stop()
|
||||
call time_total % stop()
|
||||
if (master .and. (run_mode /= MODE_PLOTTING .and. &
|
||||
run_mode /= MODE_TALLIES)) call print_runtime()
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ module fixed_source
|
|||
use state_point, only: write_state_point
|
||||
use string, only: to_str
|
||||
use tally, only: synchronize_tallies, setup_active_usertallies
|
||||
use timing, only: timer_start, timer_stop
|
||||
|
||||
#ifdef HDF5
|
||||
use hdf5_interface, only: hdf5_write_state_point
|
||||
|
|
@ -33,7 +32,7 @@ contains
|
|||
! Turn timer and tallies on
|
||||
tallies_on = .true.
|
||||
call setup_active_usertallies()
|
||||
call timer_start(time_active)
|
||||
call time_active % start()
|
||||
|
||||
! ==========================================================================
|
||||
! LOOP OVER BATCHES
|
||||
|
|
@ -48,7 +47,7 @@ contains
|
|||
call initialize_batch()
|
||||
|
||||
! Start timer for transport
|
||||
call timer_start(time_transport)
|
||||
call time_transport % start()
|
||||
|
||||
! =======================================================================
|
||||
! LOOP OVER PARTICLES
|
||||
|
|
@ -74,13 +73,13 @@ contains
|
|||
end do PARTICLE_LOOP
|
||||
|
||||
! Accumulate time for transport
|
||||
call timer_stop(time_transport)
|
||||
call time_transport % stop()
|
||||
|
||||
call finalize_batch()
|
||||
|
||||
end do BATCH_LOOP
|
||||
|
||||
call timer_stop(time_active)
|
||||
call time_active % stop()
|
||||
|
||||
! ==========================================================================
|
||||
! END OF RUN WRAPUP
|
||||
|
|
@ -112,9 +111,9 @@ contains
|
|||
integer :: i ! loop index for state point batches
|
||||
|
||||
! Collect and accumulate tallies
|
||||
call timer_start(time_tallies)
|
||||
call time_tallies % start()
|
||||
call synchronize_tallies()
|
||||
call timer_stop(time_tallies)
|
||||
call time_tallies % stop()
|
||||
|
||||
! Write out state point if it's been specified for this batch
|
||||
do i = 1, n_state_points
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ module global
|
|||
use plot_header, only: Plot
|
||||
use source_header, only: ExtSource
|
||||
use tally_header, only: TallyObject, TallyMap, TallyResult
|
||||
use timing, only: Timer
|
||||
use timer_header, only: Timer
|
||||
|
||||
#ifdef MPI
|
||||
use mpi
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ module initialize
|
|||
use string, only: to_str, str_to_int, starts_with, ends_with
|
||||
use tally_header, only: TallyObject
|
||||
use tally_initialize, only: configure_tallies
|
||||
use timing, only: timer_start, timer_stop
|
||||
|
||||
#ifdef MPI
|
||||
use mpi
|
||||
|
|
@ -46,8 +45,8 @@ contains
|
|||
subroutine initialize_run()
|
||||
|
||||
! Start total and initialization timer
|
||||
call timer_start(time_total)
|
||||
call timer_start(time_initialize)
|
||||
call time_total % start()
|
||||
call time_initialize % start()
|
||||
|
||||
#ifdef MPI
|
||||
! Setup MPI
|
||||
|
|
@ -100,15 +99,15 @@ contains
|
|||
call normalize_ao()
|
||||
|
||||
! Read ACE-format cross sections
|
||||
call timer_start(time_read_xs)
|
||||
call time_read_xs % start()
|
||||
call read_xs()
|
||||
call timer_stop(time_read_xs)
|
||||
call time_read_xs % stop()
|
||||
|
||||
! Construct unionized energy grid from cross-sections
|
||||
if (grid_method == GRID_UNION) then
|
||||
call timer_start(time_unionize)
|
||||
call time_unionize % start()
|
||||
call unionized_grid()
|
||||
call timer_stop(time_unionize)
|
||||
call time_unionize % stop()
|
||||
end if
|
||||
|
||||
! Allocate and setup tally stride, matching_bins, and tally maps
|
||||
|
|
@ -152,7 +151,7 @@ contains
|
|||
end if
|
||||
|
||||
! Stop initialization timer
|
||||
call timer_stop(time_initialize)
|
||||
call time_initialize % stop()
|
||||
|
||||
end subroutine initialize_run
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
module timing
|
||||
module timer_header
|
||||
|
||||
use constants, only: ZERO
|
||||
|
||||
|
|
@ -11,14 +11,15 @@ module timing
|
|||
!===============================================================================
|
||||
|
||||
type Timer
|
||||
private
|
||||
logical :: running = .false. ! is timer running?
|
||||
integer :: start_counts = 0 ! counts when started
|
||||
real(8) :: elapsed = ZERO ! total time elapsed in seconds
|
||||
!!$ contains
|
||||
!!$ procedure :: start => timer_start
|
||||
!!$ procedure :: get_value => timer_get_value
|
||||
!!$ procedure :: stop => timer_stop
|
||||
!!$ procedure :: reset => timer_reset
|
||||
real(8), public :: elapsed = ZERO ! total time elapsed in seconds
|
||||
contains
|
||||
procedure :: start => timer_start
|
||||
procedure :: get_value => timer_get_value
|
||||
procedure :: stop => timer_stop
|
||||
procedure :: reset => timer_reset
|
||||
end type Timer
|
||||
|
||||
contains
|
||||
|
|
@ -29,7 +30,7 @@ contains
|
|||
|
||||
subroutine timer_start(self)
|
||||
|
||||
type(Timer), intent(inout) :: self
|
||||
class(Timer), intent(inout) :: self
|
||||
|
||||
! Turn timer on and measure starting time
|
||||
self % running = .true.
|
||||
|
|
@ -43,7 +44,7 @@ contains
|
|||
|
||||
function timer_get_value(self) result(elapsed)
|
||||
|
||||
type(Timer), intent(in) :: self ! the timer
|
||||
class(Timer), intent(in) :: self ! the timer
|
||||
real(8) :: elapsed ! total elapsed time
|
||||
|
||||
integer :: end_counts ! current number of counts
|
||||
|
|
@ -66,7 +67,7 @@ contains
|
|||
|
||||
subroutine timer_stop(self)
|
||||
|
||||
type(Timer), intent(inout) :: self
|
||||
class(Timer), intent(inout) :: self
|
||||
|
||||
! Check to make sure timer was running
|
||||
if (.not. self % running) return
|
||||
|
|
@ -83,7 +84,7 @@ contains
|
|||
|
||||
subroutine timer_reset(self)
|
||||
|
||||
type(Timer), intent(inout) :: self
|
||||
class(Timer), intent(inout) :: self
|
||||
|
||||
self % running = .false.
|
||||
self % start_counts = 0
|
||||
|
|
@ -91,4 +92,4 @@ contains
|
|||
|
||||
end subroutine timer_reset
|
||||
|
||||
end module timing
|
||||
end module timer_header
|
||||
Loading…
Add table
Add a link
Reference in a new issue