Skip to content

Fix intermittent parallel build failure in lib/libnfu#406

Open
underwoo wants to merge 2 commits into
NOAA-GFDL:mainfrom
underwoo:nfu.parallel.build
Open

Fix intermittent parallel build failure in lib/libnfu#406
underwoo wants to merge 2 commits into
NOAA-GFDL:mainfrom
underwoo:nfu.parallel.build

Conversation

@underwoo

@underwoo underwoo commented Jun 10, 2026

Copy link
Copy Markdown
Member

Under make -j, make scheduled two independent jobs that both compiled
libnfu/nfu.F90: the .F90.o rule (producing nfu.o for libnfu.a) and the
.F90.$(FC_MODEXT) suffix rule (producing nfu_mod.mod for
nfu_compress.o's prerequisite). Because AM_FCFLAGS uses $(FC_MODOUT)$(@d),
both gfortran processes wrote to the same libnfu/nfu_mod.mod0 temp file
and raced to rename it, causing the intermittent error:

f951: Fatal Error: Cannot rename module file 'libnfu/nfu_mod.mod0'
to 'libnfu/nfu_mod.mod': No such file or directory

Fix by adding an explicit no-op rule in lib/libnfu/local.mk:

libnfu/nfu_mod.$(FC_MODEXT): libnfu/nfu.$(OBJEXT)
    @:

This overrides the .F90.$(FC_MODEXT) suffix rule so nfu.F90 is compiled
only once. nfu_mod.mod is treated as a side effect of building nfu.o,
and nfu_compress.o waits for it via the existing prerequisite.

Also replace the duplicate clean-local rule in local.mk (which produced
a make warning) with CLEANFILES += entries, and add CLEANFILES = in
lib/Makefile.am to initialise the variable before local.mk uses +=.

Fix a typo in tools/simple_hydrog/lakes/Makefile.am: the prerequisite
horiz_intrep.$(OBJEXT) did not match any source file; corrected to
horiz_interp.$(OBJEXT).

Closes: #405

Description
Include a summary of the change and which issue is fixed. Please also include
relevant motivation and context. List any dependencies that are required for
this change.

Fixes # (issue)

How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also note
any relevant details for your test configuration (e.g. compiler, OS). Include
enough information so someone can reproduce your tests.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

underwoo and others added 2 commits June 10, 2026 15:17
  Under make -j, make scheduled two independent jobs that both compiled
  libnfu/nfu.F90: the .F90.o rule (producing nfu.o for libnfu.a) and the
  .F90.$(FC_MODEXT) suffix rule (producing nfu_mod.mod for
  nfu_compress.o's prerequisite). Because AM_FCFLAGS uses $(FC_MODOUT)$(@d),
  both gfortran processes wrote to the same libnfu/nfu_mod.mod0 temp file
  and raced to rename it, causing the intermittent error:

    f951: Fatal Error: Cannot rename module file 'libnfu/nfu_mod.mod0'
    to 'libnfu/nfu_mod.mod': No such file or directory

  Fix by adding an explicit no-op rule in lib/libnfu/local.mk:

    libnfu/nfu_mod.$(FC_MODEXT): libnfu/nfu.$(OBJEXT)
        @:

  This overrides the .F90.$(FC_MODEXT) suffix rule so nfu.F90 is compiled
  only once. nfu_mod.mod is treated as a side effect of building nfu.o,
  and nfu_compress.o waits for it via the existing prerequisite.

  Also replace the duplicate clean-local rule in local.mk (which produced
  a make warning) with CLEANFILES += entries, and add CLEANFILES = in
  lib/Makefile.am to initialise the variable before local.mk uses +=.

  Fix a typo in tools/simple_hydrog/lakes/Makefile.am: the prerequisite
  horiz_intrep.$(OBJEXT) did not match any source file; corrected to
  horiz_interp.$(OBJEXT).

  Closes: NOAA-GFDL#405
The Fortran compiler writes .mod files into .mods/ subdirectories
(src/.mods/, src/plevel/.mods/) but clean-local never removed those
directories, causing distcleancheck to report leftover files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread tools/simple_hydrog/lakes/Makefile.am
@ilaflott

Copy link
Copy Markdown
Member

i always find the CI here slippery because the branch/fork label doesn't get associated to the next jobs triggered, so making sure i'm viewing the right distcheck since you have two PRs right now:

the latest commit triggered FRE-NCTools CI --> ✅

that triggers FRE-NCTools Check Expensive --> ✅

that triggered... this good run of distcheck... or this bad run of distcheck?

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.

Intermittent parallel build failure: f951 cannot rename nfu_mod.mod0 under make -j

2 participants