Skip to content

Commit d2f1cbe

Browse files
sbryngelsonclaude
andcommitted
IB markers: index each save by the save count under CFL time stepping
Under cfl_dt the caller passes the save count and t_step_save is left at its default, so t_step/t_step_save collapsed saves 1-99 onto one slot in lustre_ib.dat. Share one f_save_index between writer and post_process reader. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a6add01 commit d2f1cbe

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎src/common/m_helper_basic.fpp‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module m_helper_basic
1515

1616
private
1717
public :: f_approx_equal, f_approx_in_array, f_is_default, f_all_default, f_is_integer, s_configure_coordinate_bounds, &
18-
& s_update_cell_bounds
18+
& s_update_cell_bounds, f_save_index
1919

2020
contains
2121

@@ -109,6 +109,17 @@ contains
109109

110110
end function f_is_integer
111111

112+
!> Index of the save written at t_step: t_step itself under CFL-based stepping (the caller passes the save count), else
113+
!! t_step/t_step_save.
114+
pure integer function f_save_index(t_step, cfl_mode, t_step_save) result(idx)
115+
116+
integer, intent(in) :: t_step, t_step_save
117+
logical, intent(in) :: cfl_mode
118+
119+
idx = merge(t_step, t_step/t_step_save, cfl_mode)
120+
121+
end function f_save_index
122+
112123
!> Compute ghost-cell buffer size and set interior/buffered coordinate index bounds.
113124
subroutine s_configure_coordinate_bounds(recon_type, weno_polyn, muscl_polyn, igr_order, buff_size, idwint, idwbuff, viscous, &
114125
& bubbles_lagrange, m, n, p, num_dims, igr, ib, fd_number)

‎src/post_process/m_data_input.f90‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module m_data_input
1717
use m_boundary_common
1818
use m_boundary_io
1919
use m_helper
20+
use m_helper_basic, only: f_save_index
2021

2122
implicit none
2223

@@ -153,7 +154,7 @@ impure subroutine s_read_ib_data_files(file_loc_base, t_step)
153154
p_MOK = int(p_glb + 1, MPI_OFFSET_KIND)
154155
MOK = int(1._wp, MPI_OFFSET_KIND)
155156
WP_MOK = int(storage_size(0._stp)/8, MPI_OFFSET_KIND)
156-
save_index = t_step/t_step_save ! get the number of saves done to this point
157+
save_index = f_save_index(t_step, cfl_dt, t_step_save)
157158

158159
data_size = (m + 1)*(n + 1)*(p + 1)
159160
var_MOK = int(sys_size + 1, MPI_OFFSET_KIND)

‎src/simulation/m_data_output.fpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ contains
11031103
call s_check_mpi_file_open(ierr, file_loc)
11041104

11051105
var_MOK = int(sys_size + 1, MPI_OFFSET_KIND)
1106-
disp = m_MOK*max(MOK, n_MOK)*max(MOK, p_MOK)*WP_MOK*(var_MOK - 1 + int(time_step/t_step_save))
1106+
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))
11071107
if (time_step == 0) disp = 0
11081108

11091109
call MPI_FILE_SET_VIEW(ifile, disp, MPI_INTEGER, MPI_IO_IB_DATA%view, 'native', mpi_info_int, ierr)

0 commit comments

Comments
 (0)