CMake: Fix parallel-build race on shared ungrib Fortran modules#288
Open
MHBalsmeier wants to merge 1 commit into
Open
CMake: Fix parallel-build race on shared ungrib Fortran modules#288MHBalsmeier wants to merge 1 commit into
MHBalsmeier wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TYPE: bug fix
KEYWORDS: cmake, ungrib, parallel build, fortran module, race condition
SOURCE: internal
DESCRIPTION OF CHANGES:
Problem:
In the CMake build, the ungrib, g1print, and g2print targets each
recompiled shared sources (gridinfo.F, filelist.F, table.F,
module_stringutil.F, gribcode.F, module_debug.F, debug_cio.c,
module_datarray.F) into a single shared Fortran_MODULE_DIRECTORY. Under
a parallel build (-j), two targets could compile the same source at the
same time and both write the same .mod, causing an intermittent fatal
error, e.g.:
f951: Fatal Error: Cannot rename module file '.../gridinfo.mod0' to
'.../gridinfo.mod': No such file or directory
Because it is a timing-dependent race, the build failed only on some
runs.
Solution:
Compile each shared source exactly once into the pgu library and have
ungrib, g1print, and g2print link pgu instead of recompiling those
sources. This mirrors the traditional Makefile build, where shared
objects are built once and linked into each executable. The existing
link dependencies on pgu also guarantee the shared modules are built
before the executables, removing the race without disabling parallelism.
TESTS CONDUCTED:
Clean parallel build (-j) of WPS repeated multiple times; ungrib,
g1print, and g2print build and link successfully with no module-rename
errors.
RELEASE NOTE: Fix intermittent parallel-build failure caused by
concurrent writes to shared ungrib Fortran module files.