Skip to content

Commit

Permalink
move getting time to a util function
Browse files Browse the repository at this point in the history
  • Loading branch information
jcurtis2 committed Oct 20, 2024
1 parent 55245e6 commit d35d10d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/partmc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ subroutine partmc_part(file)
character(len=PMC_MAX_FILENAME_LEN) :: restart_filename
integer :: dummy_index, dummy_i_repeat
real(kind=dp) :: n_part
integer(kind=8) :: clock_count, clock_count_rate

!> \page input_format_particle Input File Format: Particle-Resolved Simulation
!!
Expand Down Expand Up @@ -487,8 +486,7 @@ subroutine partmc_part(file)
call pmc_rand_finalize()
call pmc_srand(rand_init, pmc_mpi_rank())

call system_clock(clock_count, clock_count_rate)
run_part_opt%t_wall_start = real(clock_count, kind=dp) / clock_count_rate
run_part_opt%t_wall_start = system_clock_time()

do i_repeat = 1,run_part_opt%n_repeat
run_part_opt%i_repeat = i_repeat
Expand Down
8 changes: 2 additions & 6 deletions src/run_part.F90
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ subroutine run_part(scenario, env_state, aero_data, aero_state, gas_data, &
integer :: global_n_nuc
logical :: do_output, do_state, do_state_netcdf, do_progress, did_coag
real(kind=dp) :: t_start, t_wall_now, t_wall_elapsed, t_wall_remain
integer(kind=8) :: clock_count, clock_count_rate
type(env_state_t) :: old_env_state
integer :: n_time, i_time, pre_i_time
integer :: i_state, i_state_netcdf, i_output
Expand Down Expand Up @@ -223,8 +222,7 @@ subroutine run_part(scenario, env_state, aero_data, aero_state, gas_data, &
t_wall_elapsed = 0d0
t_wall_remain = 0d0
else
call system_clock(clock_count, clock_count_rate)
t_wall_now = real(clock_count, kind=dp) / clock_count_rate
t_wall_now = system_clock_time()
prop_done = real(run_part_opt%i_repeat - 1, kind=dp) &
/ real(run_part_opt%n_repeat, kind=dp)
t_wall_elapsed = t_wall_now - run_part_opt%t_wall_start
Expand Down Expand Up @@ -808,7 +806,6 @@ subroutine run_part_timestep(scenario, env_state, aero_data, aero_state, &
integer :: global_n_nuc
logical :: do_output, do_state, do_state_netcdf, do_progress
real(kind=dp) :: t_wall_now, t_wall_elapsed, t_wall_remain, time
integer(kind=8) :: clock_count, clock_count_rate
type(env_state_t) :: old_env_state
#ifdef PMC_USE_CAMP
type(camp_state_t), pointer :: camp_state
Expand Down Expand Up @@ -950,8 +947,7 @@ subroutine run_part_timestep(scenario, env_state, aero_data, aero_state, &
call pmc_mpi_reduce_sum_integer(progress_n_nuc, global_n_nuc)
if (pmc_mpi_rank() == 0) then
! progress only printed from root process
call system_clock(clock_count, clock_count_rate)
t_wall_now = real(clock_count, kind=dp) / clock_count_rate
t_wall_now = system_clock_time()
prop_done = (real(run_part_opt%i_repeat - 1, kind=dp) &
+ time / run_part_opt%t_max) &
/ real(run_part_opt%n_repeat, kind=dp)
Expand Down
13 changes: 13 additions & 0 deletions src/util.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,19 @@ integer function pow2_above(n)

end function pow2_above

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!> Returns the current system clock time in seconds.
real(kind=dp) function system_clock_time()

! 64 bit integer enables hi-resolution time.
integer(kind=8) :: clock_count, clock_count_rate

call system_clock(clock_count, clock_count_rate)
system_clock_time= real(clock_count, kind=dp) / clock_count_rate

end function system_clock_time

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

end module pmc_util

0 comments on commit d35d10d

Please sign in to comment.