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

Refactor assumed-rank array resizing in Fortran

The Fortran front end now uses a new helper function for resizing assumed-rank array dimensions, improving code organization.

This commit refactors the Fortran front end’s handling of assumed-rank array dimensions by introducing a new function, gfc_resize_assumed_rank_dim_field. This helper function extracts and centralizes the logic for resizing array dimensions, which was previously embedded within gfc_conv_array_parameter. This improves code readability and maintainability within the Fortran compiler.

In Details

Assumed-rank arrays in Fortran allow procedures to accept array arguments where the rank (number of dimensions) is not known at compile time. The Fortran front end, specifically trans-array.cc, handles the translation of these array parameters. This refactoring extracts the logic for resizing the dimensions of such arrays, typically involving the gfc_array_info structure, into a dedicated function. This improves modularity and clarifies the responsibilities of gfc_conv_array_parameter, which primarily deals with converting array parameters into their internal representation.

For Context

In programming, arrays are collections of data. In Fortran, a language often used for scientific computing, 'assumed-rank arrays' are special because the program doesn't know how many dimensions they have (like a 1D list, a 2D table, or a 3D cube) until it actually runs. This commit is about improving the internal structure of the Fortran compiler. It takes a specific piece of code responsible for adjusting the size of these assumed-rank arrays and moves it into its own dedicated function. This makes the compiler's code cleaner and easier to understand for developers working on the compiler itself, even though it doesn't change how your Fortran programs behave.

Filed Under: fortranrefactoring