GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
fortran

Fortran: Allows access to coarray elements within modules.

The Fortran compiler now correctly handles access to coarray elements within modules.

The Fortran compiler had issues accessing coarray elements within modules due to namespace handling. This commit ensures correct namespace resolution when accessing coarray elements defined in modules. It also prevents symbol initialization outside of functions and ensures that the current namespace reflects the current procedure. A new test case, gfortran.dg/coarray/pr125051.f90, validates the fix.

In Details

This commit addresses PR fortran/125051 by modifying trans-decl.cc, trans-intrinsic.cc, and trans-openmp.cc. The key changes involve ensuring that gfc_conv_intrinsic_caf_get works correctly in the module namespace and that gfc_current_ns is correctly set to the referencing procedure's namespace. Incorrect namespace handling prevented proper code generation. These changes are specific to the Fortran front end's lowering to GIMPLE.

For Context

Coarrays are a Fortran feature for parallel programming, allowing different parts of a program to access data on other "images" (parallel execution instances). This commit resolves an issue where accessing coarray variables declared within modules would fail. Modules are used to group related data and procedures. The fix ensures that the compiler can correctly locate and access coarray variables within modules, enabling correct parallel execution.

Filed Under: fortrancoarraymoduleparallel programming