Skip to content

Bug: When out_alllog is enabled, output log filenames show inconsistent calculation types across MPI ranks​ #6352

Description

@AsTonyshment

Describe the bug

When running calculations with calculation = md and enabling out_alllog = 1, the generated log filenames are incorrectly formatted as running_md_1.log (rank 0) and running_scf_2.log (rank 1), while the expected behavior should be running_md_[rank].log for all ranks.

Image

Debugging reveals that PARAM.inp.calculation is not properly broadcasted across MPI ranks: rank 0 correctly reads md, but other ranks default to scf. This inconsistency occurs in read_set_globalv.cpp during log filename generation. I added a line to output PARAM.inp.calculation used to generate log files:

    // set the global log file
    bool out_alllog = inp.out_alllog;
#ifdef __MPI
    // because log_file is different for each rank, so we need to bcast the out_alllog
    Parallel_Common::bcast_bool(out_alllog);
#endif
    if (out_alllog)
    {
        std::cerr << "PARAM.inp.calculation = " << PARAM.inp.calculation << std::endl;
        PARAM.sys.log_file = "running_" + PARAM.inp.calculation + "_" + std::to_string(PARAM.sys.myrank + 1) + ".log";
    }
    else
    {
        PARAM.sys.log_file = "running_" + PARAM.inp.calculation + ".log";
    }

And the output reads

PARAM.inp.calculation = md
PARAM.inp.calculation = scf

Expected behavior

No response

To Reproduce

No response

Environment

No response

Additional Context

No response

Task list for Issue attackers (only for developers)

  • Verify the issue is not a duplicate.
  • Describe the bug.
  • Steps to reproduce.
  • Expected behavior.
  • Error message.
  • Environment details.
  • Additional context.
  • Assign a priority level (low, medium, high, urgent).
  • Assign the issue to a team member.
  • Label the issue with relevant tags.
  • Identify possible related issues.
  • Create a unit test or automated test to reproduce the bug (if applicable).
  • Fix the bug.
  • Test the fix.
  • Update documentation (if necessary).
  • Close the issue and inform the reporter (if applicable).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions