Skip to content

Commit 4e44eb8

Browse files
committed
AMR instruments: f_amr_wtime() wraps MPI_Wtime under MFC_MPI (the serial no-MPI build failed: 'mpi_wtime has no IMPLICIT type' in the ledger-89 batch instrument and two older sites); no behaviour change with MPI
1 parent 09f7a17 commit 4e44eb8

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

src/simulation/m_amr.fpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,20 @@ module m_amr
549549

550550
contains
551551

552+
!> Wall clock for the AMR instruments (batch and regrid timings); 0 without MPI, where the instruments are not used. Keeps the
553+
!! serial (no-MPI) build compiling.
554+
impure function f_amr_wtime() result(t)
555+
556+
real(wp) :: t
557+
558+
#ifdef MFC_MPI
559+
t = MPI_Wtime()
560+
#else
561+
t = 0._wp
562+
#endif
563+
564+
end function f_amr_wtime
565+
552566
!> Build the static refined level-1 block. No-op unless amr. Called after the level-0 grid (x_cb/dx ready) and time-steppers
553567
!! (sys_size/buff_size set). Per-slot fine arrays allocated lazily (s_amr_reconcile_slots) - only the blocks a rank owns.
554568
impure subroutine s_initialize_amr_module()
@@ -3874,11 +3888,11 @@ contains
38743888
integer :: ierr
38753889
real(wp) :: t0, t1, tmin, tmax
38763890

3877-
t0 = MPI_Wtime()
3891+
t0 = f_amr_wtime()
38783892
#endif
38793893
call s_mpi_allreduce_integer_max(amr_xchg_bad, bad_glb)
38803894
#ifdef MFC_MPI
3881-
t1 = MPI_Wtime()
3895+
t1 = f_amr_wtime()
38823896
if (rank_time_wrt) then
38833897
call MPI_ALLREDUCE(t0, tmin, 1, mpi_p, MPI_MIN, MPI_COMM_WORLD, ierr)
38843898
call MPI_ALLREDUCE(t0, tmax, 1, mpi_p, MPI_MAX, MPI_COMM_WORLD, ierr)
@@ -8612,27 +8626,27 @@ contains
86128626
end do
86138627
end if
86148628
amr_in_fine_advance = .true.
8615-
tb0 = MPI_Wtime()
8629+
tb0 = f_amr_wtime()
86168630
call s_phase_tic(PH_SWAP)
86178631
call s_amr_swap_to_fine() ! the leader's grid, extended into the slab (amr_bat_n > 1)
86188632
idwint = idwbuff ! widen the conversion range to the ghost shells (restored by s_amr_restore_coarse)
86198633
$:GPU_UPDATE(device='[idwint]')
86208634
call s_phase_toc(PH_SWAP)
8621-
tb1 = MPI_Wtime()
8635+
tb1 = f_amr_wtime()
86228636
call s_phase_tic(PH_RHS)
86238637
call s_amr_br_load_batch(amr_bat_n)
86248638
call s_compute_rhs(amr_cons_br, q_T_sf, amr_scr_prim, bc_type, amr_scr_rhs, pb_in, rhs_pb, mv_in, rhs_mv, t_step, s)
86258639
call s_phase_toc(PH_RHS)
8626-
tb2 = MPI_Wtime()
8640+
tb2 = f_amr_wtime()
86278641
call s_phase_tic(PH_SWAP)
86288642
call s_amr_restore_coarse()
86298643
call s_phase_toc(PH_SWAP)
86308644
amr_in_fine_advance = .false.
8631-
tb3 = MPI_Wtime()
8645+
tb3 = f_amr_wtime()
86328646
call s_phase_tic(PH_RK)
86338647
call s_amr_fine_rk_update_batch(amr_bat_n, amr_scr_rhs, coefs(1), coefs(2), coefs(3), coefs(4), dt)
86348648
call s_phase_toc(PH_RK)
8635-
tb4 = MPI_Wtime()
8649+
tb4 = f_amr_wtime()
86368650
if (rank_time_wrt) then
86378651
call s_rank_time_toc()
86388652
if (.not. amr_bat_open) then

0 commit comments

Comments
 (0)