lanl / lanl/SNAP

Flux moments are not printed correctly when `fluxp == 2`

Open Beginner friendly
#23 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Fortran
Stars
53
Forks
35
PR merge metrics
No merged PRs in 30d

Description

Setting fluxp == 2 is supposed to cause all flux moments to be output to the flux file. However, the Fortran reference implementation of SUBROUTINE output_flux_file erroneously prints multiple copies of moment 1 (the isotropic component) where moments 2 through cmom (the anisotropic components) are supposed to be.

I think the offending statement is here on line 332 of output.f90, which only reads from flux0 instead of conditionally reading from flux0 or fluxm depending on the value of l. Note that the output_send calls on line 322 do correctly implement this conditional logic:

            IF ( l == 1 ) THEN
              CALL output_send ( mtag, flux0(:,:,kloc,g) )
            ELSE
              CALL output_send ( mtag, fluxm(l-1,:,:,kloc,g) )
            END IF

However, in non-MPI runs, output_send is a no-op, causing the program to revert to faulty single-rank behavior. In addition, the FORMAT statement on line 370 uses the I1 specifier:

    323 FORMAT( /, 2X, 'Moment = ', I1 )

This causes the erroneous output Moment = * to be printed whenever the moment index is 10 or greater (which commonly occurs in 2D and 3D problems whenever nmom >= 4). The I0 specifier should be used instead to allow arbitrarily large integers to be printed without unnecessary padding.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/output.f90 at output_send and the output loop around lines 322 and 332, then inspect FORMAT 323 around line 370. Compare MPI and non-MPI behavior for fluxp == 2, and verify that every moment is read from the appropriate source and that moment indices of 10 or greater are printed numerically.

Written by the indexing model from the issue text.

Assessment

Tech stack
fortran
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.