Skip to content

Fix make -j race on Fortran .mod files - #238

Merged
jcurtis2 merged 2 commits into
masterfrom
parallel-make
Dec 4, 2026
Merged

jcurtis2 merged 2 commits into
masterfrom
parallel-make

Conversation

@jcurtis2

@jcurtis2 jcurtis2 commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Fix make -j race on Fortran .mod files

Several targets compiled the same sources. All .mod files go to the build root, so parallel builds could race in the building and copying steps. This was noted in #196. Several targets compiled the same sources, and all .mod files go to the build root, so under make -j two compilers could write the same module at once. That is the Cannot rename module file 'pmc_util.mod0' error. Previously we've just run everything including CI with serial make to avoid this.

Changes (CMakeLists.txt only)

  • Add a partmc_getopt STATIC library for src/getopt.F90. The 11 programs that use getopt_m now link it instead of each compiling getopt.F90 themselves.
  • test_nucleate_ode, test_poisson_sample and test_binomial_sample now link partmclib instead of recompiling its sources (util, constants, sys, rand, mpi, GSL, C_SORT). This avoids another race condition.
  • CI Dockerfiles (main, MPI, CAMP, cloud_parcel) now build PartMC with make -j$(nproc), so CI exercises the parallel build. However they don't guarantee that parallel builds work (only ninja would address this)

Every source is now compiled by exactly one target, avoiding race conditions and failure.

Testing

  • cmake -G Ninja + ninja: 223/223 (master fails immediately due to race condition)
  • All tests levels of parallelism pass (up to a very unnecesary make -j 32)

Fixes #196.

@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.49%. Comparing base (8669e9c) to head (ecd22ef).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #238   +/-   ##
=======================================
  Coverage   78.49%   78.49%           
=======================================
  Files          56       56           
  Lines        9802     9802           
=======================================
  Hits         7694     7694           
  Misses       2108     2108           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jcurtis2
jcurtis2 merged commit e1e19cf into master Dec 4, 2026
11 checks passed
@jcurtis2
jcurtis2 deleted the parallel-make branch December 4, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot do parallel builds

2 participants