In the sequential file_per_process restart I/O paths, the *_MOK MPI byte-offset variables are computed but never consumed: these branches open with MPI_COMM_SELF and read/write sequentially via MPI_FILE_READ / MPI_FILE_WRITE_ALL with no MPI_FILE_SET_VIEW and no disp displacement. The offsets are only meaningful in the other (collective, set-view) path, which recomputes them itself.
1. src/simulation/m_start_up.fpp:403-407 (read path, inside if (file_per_process) opened with MPI_COMM_SELF):
m_MOK = int(m_glb_read + 1, MPI_OFFSET_KIND)
n_MOK = int(m_glb_read + 1, MPI_OFFSET_KIND) ! BUG: uses m_glb_read
p_MOK = int(m_glb_read + 1, MPI_OFFSET_KIND) ! BUG: uses m_glb_read
WP_MOK = int(storage_size(0._stp)/8, MPI_OFFSET_KIND)
MOK = int(1._wp, MPI_OFFSET_KIND)
Two issues:
- Dead: none of
m_MOK/n_MOK/p_MOK/WP_MOK/MOK/var_MOK are read in this branch — the reads are plain sequential MPI_FILE_READ with no SET_VIEW/disp.
- Copy-paste typo:
n_MOK and p_MOK are both derived from m_glb_read instead of n_glb_read / p_glb_read (computed just above). Latent (harmless only because unused), but a real bug that would surface if SET_VIEW were ever wired into this path.
2. src/simulation/m_data_output.fpp:718-724 (write path, inside MPI_COMM_SELF):
m_MOK = int(m_glb_save + 1, MPI_OFFSET_KIND)
n_MOK = int(n_glb_save + 1, MPI_OFFSET_KIND)
p_MOK = int(p_glb_save + 1, MPI_OFFSET_KIND)
WP_MOK = int(storage_size(0._stp)/8, MPI_OFFSET_KIND)
MOK = int(1._wp, MPI_OFFSET_KIND)
str_MOK = int(name_len, MPI_OFFSET_KIND)
NVARS_MOK = int(sys_size, MPI_OFFSET_KIND)
Dead in this branch (writes are MPI_FILE_WRITE_ALL with no SET_VIEW). By contrast the other branch (m_data_output.fpp:775-798) does build disp = m_MOK*max(MOK,n_MOK)*max(MOK,p_MOK)*WP_MOK*(var_MOK-1) and calls MPI_FILE_SET_VIEW — so the variables are genuinely needed only there. No typo in this block.
Fix.
- m_start_up.fpp: delete lines 403-407 (the dead
*_MOK assignments). If kept defensively, at minimum fix the typo (n_MOK ← n_glb_read, p_MOK ← p_glb_read). Recommended: delete.
- m_data_output.fpp: delete lines 718-724.
- Optionally drop the per-iteration
var_MOK = int(i, ...) lines in these branches too (unused there).
Output-neutrality: removing dead assignments to never-read variables does not change file contents or behavior; the collective path that actually uses *_MOK is untouched.
Filed from a repo-wide code-cleanliness review; verified against master @ 40dde5e.
Code references
In the sequential
file_per_processrestart I/O paths, the*_MOKMPI byte-offset variables are computed but never consumed: these branches open withMPI_COMM_SELFand read/write sequentially viaMPI_FILE_READ/MPI_FILE_WRITE_ALLwith noMPI_FILE_SET_VIEWand nodispdisplacement. The offsets are only meaningful in the other (collective, set-view) path, which recomputes them itself.1.
src/simulation/m_start_up.fpp:403-407(read path, insideif (file_per_process)opened withMPI_COMM_SELF):Two issues:
m_MOK/n_MOK/p_MOK/WP_MOK/MOK/var_MOKare read in this branch — the reads are plain sequentialMPI_FILE_READwith noSET_VIEW/disp.n_MOKandp_MOKare both derived fromm_glb_readinstead ofn_glb_read/p_glb_read(computed just above). Latent (harmless only because unused), but a real bug that would surface ifSET_VIEWwere ever wired into this path.2.
src/simulation/m_data_output.fpp:718-724(write path, insideMPI_COMM_SELF):Dead in this branch (writes are
MPI_FILE_WRITE_ALLwith noSET_VIEW). By contrast the other branch (m_data_output.fpp:775-798) does builddisp = m_MOK*max(MOK,n_MOK)*max(MOK,p_MOK)*WP_MOK*(var_MOK-1)and callsMPI_FILE_SET_VIEW— so the variables are genuinely needed only there. No typo in this block.Fix.
*_MOKassignments). If kept defensively, at minimum fix the typo (n_MOK ← n_glb_read,p_MOK ← p_glb_read). Recommended: delete.var_MOK = int(i, ...)lines in these branches too (unused there).Output-neutrality: removing dead assignments to never-read variables does not change file contents or behavior; the collective path that actually uses
*_MOKis untouched.Filed from a repo-wide code-cleanliness review; verified against
master@40dde5e.Code references
src/simulation/m_start_up.fpp:403-407— dead *_MOK + n/p typosrc/simulation/m_data_output.fpp:718-724— dead *_MOK (write)src/simulation/m_data_output.fpp:775-798— SET_VIEW path that uses *_MOK