Skip to content

Fix module_mp_radar USE dependency invisible to CMake scanner#1218

Draft
mathomp4 wants to merge 3 commits intofeature/dbarahon/rc23_MG3from
fix/module_mp_radar-use-dependency
Draft

Fix module_mp_radar USE dependency invisible to CMake scanner#1218
mathomp4 wants to merge 3 commits intofeature/dbarahon/rc23_MG3from
fix/module_mp_radar-use-dependency

Conversation

@mathomp4
Copy link
Member

@mathomp4 mathomp4 commented Mar 6, 2026

I had Claude try and figure this out. This was a thought it had...


Problem

GCC and ifort fail to compile several files due to standard violations that ifort accepted silently as non-standard extensions.

Fix 1 — Process_Library.F90: hoist USE module_mp_radar to module level

GCC: Fatal Error: Cannot open module file 'module_mp_radar.mod' for reading
ifort: error #6404: This name does not have a type [XAM_R]

Root cause: CMake's Fortran module dependency scanner only reads USE statements at the module/program specification part (top level). It does not see USE statements inside contained subprograms.

Process_Library.F90 had USE module_mp_radar inside two contained subroutines (init_refl10cm and calc_refl10cm), making the dependency on module_mp_radar.F90 invisible to CMake. This was a latent bug that never fired before because compilation order happened to put module_mp_radar.F90 first by coincidence.

Commit 37878b71 changed aer_actv_single_moment.F90 to USE GEOSmoist_Process_Library, which introduced a new intra-library dependency that reshuffled the compilation schedule and exposed the hidden gap.

Moving USE module_mp_radar to the module-level USE block of GEOSmoist_Process_Library makes the dependency visible to CMake. The symbols are then available to init_refl10cm and calc_refl10cm via host association, which is semantically identical.

Fix 2 — GEOS_MoistGridComp.F90: replace not() with .not.

GCC: Error: 'i' argument of 'not' intrinsic at (1) must be INTEGER

Root cause: not() is the bitwise integer intrinsic; .not. is the logical negation operator. ifort silently accepts not() on logicals as a non-standard extension, but GCC correctly rejects it.

! Before
if ((USE_AEROSOL_NN) .and. not (USE_NCLOUD_CLIM)) then
! After
if ((USE_AEROSOL_NN) .and. .not. (USE_NCLOUD_CLIM)) then

Fix 3 — GEOS_PhysicsGridComp.F90: pad strings in CHARACTER array constructor

GCC: Error: Different CHARACTER lengths (3/2) in array constructor

Root cause: The Fortran standard requires all elements of an array constructor to have the same character length. 'KM' and 'RI' (length 2) were mixed with 'ALH' (length 3). ifort accepted this silently; GCC correctly rejects it.

! Before
SHORT_NAME  = (/'ALH', 'KM', 'RI'/),
! After
SHORT_NAME  = (/'ALH', 'KM ', 'RI '/),

USE statements inside contained subroutines are not seen by CMake's
Fortran module dependency scanner, only top-level USE statements are.
Moving USE module_mp_radar to the module specification part of
GEOSmoist_Process_Library makes the dependency explicit and ensures
module_mp_radar.mod exists before Process_Library.F90 is compiled.

The latent ordering issue was exposed by commit 37878b7 which added
USE GEOSmoist_Process_Library to aer_actv_single_moment.F90, creating
a new constraint that reshuffled compilation order and triggered the
missing .mod file error in both GCC and ifort.
@mathomp4 mathomp4 requested a review from a team as a code owner March 6, 2026 23:37
@mathomp4 mathomp4 self-assigned this Mar 6, 2026
@mathomp4 mathomp4 requested a review from dbarahon March 6, 2026 23:38
@mathomp4 mathomp4 added 0 diff The changes in this pull request have verified to be zero-diff with the target branch. 0-diff AMIP 0-diff for uncoupled AMIP runs labels Mar 6, 2026
@mathomp4 mathomp4 marked this pull request as draft March 6, 2026 23:38
not() is the bitwise integer intrinsic; .not. is the logical negation
operator. ifort silently accepts not() on logicals as an extension,
but GCC correctly rejects it.
@mathomp4 mathomp4 mentioned this pull request Mar 7, 2026
GCC rejects array constructors with elements of different CHARACTER
lengths (standard violation). 'KM' and 'RI' (length 2) were mixed
with 'ALH' (length 3). Pad short strings with trailing spaces to
make all elements length 3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-diff AMIP 0-diff for uncoupled AMIP runs 0 diff The changes in this pull request have verified to be zero-diff with the target branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant