Skip to content

Remove dead *_MOK MPI-offset assignments in file_per_process I/O branches (and fix n_MOK/p_MOK typo) #1490

Description

@sbryngelson

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working or doesn't seem rightgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions