diff --git a/src/common/m_helper_basic.fpp b/src/common/m_helper_basic.fpp index dd6fc311f..cb86176f3 100644 --- a/src/common/m_helper_basic.fpp +++ b/src/common/m_helper_basic.fpp @@ -15,7 +15,7 @@ module m_helper_basic private public :: f_approx_equal, f_approx_in_array, f_is_default, f_all_default, f_is_integer, s_configure_coordinate_bounds, & - & s_update_cell_bounds + & s_update_cell_bounds, f_save_index contains @@ -109,6 +109,17 @@ contains end function f_is_integer + !> Index of the save written at t_step: t_step itself under CFL-based stepping (the caller passes the save count), else + !! t_step/t_step_save. + pure integer function f_save_index(t_step, cfl_mode, t_step_save) result(idx) + + integer, intent(in) :: t_step, t_step_save + logical, intent(in) :: cfl_mode + + idx = merge(t_step, t_step/t_step_save, cfl_mode) + + end function f_save_index + !> Compute ghost-cell buffer size and set interior/buffered coordinate index bounds. subroutine s_configure_coordinate_bounds(recon_type, weno_polyn, muscl_polyn, igr_order, buff_size, idwint, idwbuff, viscous, & & bubbles_lagrange, m, n, p, num_dims, igr, ib, fd_number) diff --git a/src/post_process/m_data_input.f90 b/src/post_process/m_data_input.f90 index 6d871b165..8bc8c59f2 100644 --- a/src/post_process/m_data_input.f90 +++ b/src/post_process/m_data_input.f90 @@ -17,6 +17,7 @@ module m_data_input use m_boundary_common use m_boundary_io use m_helper + use m_helper_basic, only: f_save_index implicit none @@ -153,7 +154,7 @@ impure subroutine s_read_ib_data_files(file_loc_base, t_step) p_MOK = int(p_glb + 1, MPI_OFFSET_KIND) MOK = int(1._wp, MPI_OFFSET_KIND) WP_MOK = int(storage_size(0._stp)/8, MPI_OFFSET_KIND) - save_index = t_step/t_step_save ! get the number of saves done to this point + save_index = f_save_index(t_step, cfl_dt, t_step_save) data_size = (m + 1)*(n + 1)*(p + 1) var_MOK = int(sys_size + 1, MPI_OFFSET_KIND) diff --git a/src/simulation/m_data_output.fpp b/src/simulation/m_data_output.fpp index 112ea52a2..d9f0e9efb 100644 --- a/src/simulation/m_data_output.fpp +++ b/src/simulation/m_data_output.fpp @@ -1103,7 +1103,7 @@ contains call s_check_mpi_file_open(ierr, file_loc) var_MOK = int(sys_size + 1, MPI_OFFSET_KIND) - disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1 + int(time_step/t_step_save)) + disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1 + f_save_index(time_step, cfl_dt, t_step_save)) if (time_step == 0) disp = 0 call MPI_FILE_SET_VIEW(ifile, disp, MPI_INTEGER, MPI_IO_IB_DATA%view, 'native', mpi_info_int, ierr)