Nvfortran 26.5: "use associated ... cannot be redeclared" in submodule scopes for symbols not imported by parent or submodule

Hi,

Building a large Fortran application (NWP model) with nvfortran 26.5, I’m hitting repeated name-resolution errors in submodule scopes that no other compiler reports. Intel oneAPI (ifx), GCC (gfortran), and LLVMFlang (flang-new) all accept the same source unchanged.

nvfortran --version: nvfortran 26.5-0 64-bit target on x86-64 Linux -tp haswell
Platform: Linux bounty 6.18.33.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 18 21:54:43 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Compile flags: -g -Mpreprocess -Mdclchk -O2 -module -fPIC -mp

Error:

NVFORTRAN-S-1254-dtg is use associated with module_mp_tempo_params and cannot be redeclared. (…/fields.inc: 101)

This appears to be the still-open half of TPR #31624 (from Nvfortran import all symbols to child submodule from a module used by its parent module - HPC Compilers / nvc, nvc++ and nvfortran - NVIDIA Developer Forums). Example 1 in that thread shows a submodule seeing a symbol its parent never imported; nvfortran wrongly permits the reference there. I’m hitting the same over-visibility from the other direction: it wrongly rejects a local declaration in a submodule as conflicting with a use-associated name that neither the parent nor the submodule imports.

What I established by bisection (before I discovered PTR #31624):

The declaration is a local variable in a submodule of module mod_myparentmod.

  • Declaring the same variable directly in mod_myparentmod (the parent module) compiles fine. Only the submodule scope rejects it.
  • The submodule has no use statements of its own.
  • No module in mod_myparentmod’s use chain imports dtg from module_mp_tempo_params — the symbol is never referenced anywhere in the build. I verified this by reproducing mod_myparentmod’s entire use list in a standalone probe module and declaring a local dtg: that compiles clean.
  • Adding an explicit disambiguating rename in the submodule — use module_mp_tempo_params, only : tempo_dtg_workaround => dtg — does not clear the error. The frontend appears not to consult the submodule’s own import list when resolving the name.
  • Adding private to the declaration in module_mp_tempo_params, and separately converting module_mp_tempo_utils to blanket-private with an explicit public :: list, had no effect.
  • The only thing that resolved it was renaming the variable in its defining module (module_mp_tempo_params) so the name no longer exists in the build.

The .mod files are consistent with the name arriving through submodule host association: mod_myparentmod.mod records use module_mp_tempo_params private, while all four of its submodules record use module_mp_tempo_params public 0 indirect. My reading is that when the frontend reconstructs the parent scope for a submodule compile, it replays the parent’s recorded use without honoring the accessibility that made those names non-inheritable — so names correctly invisible in the parent become visible in the submodule.

This is not isolated to one symbol. The same error class recurs in this build for other common identifiers from unrelated modules (e.g. pi), each time in a submodule scope, each time accepted by ifx/gfortran/flang-new. Renaming symbols one at a time in their defining modules is not a viable workaround at this scale.

The application source is not publicly redistributable. If it would help for me to run specific diagnostic flags (-Minfo, module-file dumps, anything that shows the frontend’s scope construction) and report the output, I’m glad to do that.

I’d also be interested in potential workarounds as this is blocking the benchmarking of our NWP model with NVHPC. Renaming the variables or restructuring the module/submodule code are not feasible.

Thanks,

Dom

Hi Dom,

I tried writing a reproducing example here, but unfortunately wasn’t able to. Without a way to reproduce the issue, I can’t report it to engineering. Also from your description I agree that TPR #31624 is similar, but not close enough to serve as a proxy.

Though given our current PGI based nvfortran has issues with submodules, and the code works with flang-new, we might want to wait for our upcoming new LLVM based nvfortran and try again then. It wont be too much longer till it’s out.

-Mat