Skip to content

Bugs in land_iau_mod_set_control and cires_ugwpv0_mod_init related to namelist reads #1182

@climbfuji

Description

@climbfuji

Description

I've come across bugs in land_iau_mod_set_control and cires_ugwpv0_mod_init related to namelist reads that can lead to model crashes, depending on the system and compiler being used.

The symptom: After updating the NEPTUNE code from NCAR ccpp-physics main as of December 15 (same as today), the model aborted on a particular system with [email protected] in cires_ugwpv0_mod_init with the error

cires_ugwp_module.F90 (unit = 9999, file = 'fort.9999') Fortran runtime error: End of file

even though the file name passed in is suite.nml and the code "made it past" the open statement.

It turned out that the issue is that the file open statement fails, but the return code ios is never checked. Therefore, Fortran thinks that the file isn't open and opens it implicitly as fort.9999 where 9999 is the nlunit.

Upon deeper investigation, I found that there is abug in the lnd_iau_mod_set_control code that opens the same namelist file suite.nml, but ever closes it if it can't find the land iau namelist section. (Note that we are not using the INTERNAL_FILE_NML logic at this time.)

The Fortran standard doesn't guarantee that you can open a file multiple times, even if each of the open calls is read-only. Therefore, the correct behavior is to (a) close the file in lnd_iau_mod_set_control if the namelist section can't be found, and (b) to check if the file open call in the UGWP code is successful.

Of course, there may be more of these issues scattered across the CCPP physics code, but finding those and finding a way to test them is not within the scope.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

See above. Whether this fails depends on the particular machine and compiler.

Additional Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Machine DOD HPCMP Nautilus
  • Compiler GCC 13.3.1
  • Suite Definition File or Scheme Any CCPP suite that doesn't uses lnd_iau but uses ugwp and doesn't have a land iau namelist section
  • Reference other issues or PRs in other repositories that this is related to, and how they are related.

Output

See above.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions