Closed sarats closed 1 year ago
cc @grnydawn @liho745 @bishtgautam
This seems to be the line with issue:
This line is 261 characters which is longer than the 255 that was set for Cray compilers. This was the only instance in E3SM where this was exceeded.
Note: -N 255
is currently set for Cray. Don't know if we should switch to 1023 for the sake of this one file. Anyway, 1023 seems like a readability nightmare too.
Or we can switch this to a free-format source file with no restrictions.
Relevant man page excerpt:
-N col Specifies the line width for fixed-format source lines. The value used for col specifies the maximum number of columns per line.
? For fixed form sources, col can be set to 72, 80, 132, 255, or 1023.
? Characters in columns beyond the col specification are ignored.
? By default, lines are 72 characters wide for fixed-format sources.
? There is no line size limit for free-format source files.
We should always use free format.
Then is the fix just a case of changing the file extension?
No its finding the cray compiler flag for free format and replace "-N 255" with that.
Are you sure all E3SM sources are free format? The Cray compiler guesses from the file extension IIRC.
Anyway, other compilers like GNU have blocks like
39 string(APPEND FIXEDFLAGS " -ffixed-form")
40 string(APPEND FREEFLAGS " -ffree-form")
That's also a mistake. We should use free-format everywhere.
If its guessing from the extension, .F90 should imply free-format while .F implies fixed form.
Cray is -f free Note that MPAS has free form and unfortunately used .F extensions so we can't rely on suffix alone
Yes. The above Cray option was a legacy option carried over from previous incarnations of Cray machines. We can just switch to free for all ;) and see what happens.
Still on a tangent, do we have a code style preference on line length?
In fact, the Cray compiler block for Crusher/Frontier actually sets it to free format.
string(APPEND FFLAGS " -f free -N 255 -h byteswapio -em")
@grnydawn Do you recall why -N 255
was added?
@twhite-cray When both of the following options are specified for Cray Fortran, -f free -N 255
- is it expected to interpret the MOSART_sediment_mod.F90 as a fixed format file? Does the second option override the first?
The -N
option should not affect whether the compiler expects free or fixed formats. The suffix .F90
tells the compiler to default to free and run it through the C preprocessor. The -f free
is redundant in this case.
I feel like -N
used to apply to free format as well as fixed, but it doesn't now.
@sarats , "the -N 255" option was inherited from "cray.cmake" in cmake_macros. When I created an entry for Spock in machinefile, I copied the options to Spock entry.
@twhite-cray I'm confused, should the Cray compiler complain about the line length in this case then (free format file)?
Sorry, I didn't read the whole thread.
I reproduced the issue with a simple free-format code. Despite what the man
page says, it appears that -N
applies to both fixed and free formats. In other words, it chops off free-format files too.
I'll submit a bug report.
If everything is free format, you should be able to just eliminate -N
.
I created a ticket for the HPE Cray compiler. Is there a fix you would prefer?
-N
continues to apply to all formats, and we fix the man
page.man
pages says now, where -N
should not affect free-format files.Removing "-N 255" flag eliminates the cray compiler error during MOSART_sediment_mod.F90 compilation on Frontier. I am running e3sm_integration test on Frontier to see if the change introduces any new issue.
-N continues to apply to all formats, and we fix the man page.
Don't have a strong preference but I guess fixing the man page makes sense to avoid confusion if someone is explicitly using -N
.
https://github.com/E3SM-Project/E3SM/pull/5444 removed the -N 255 flag.
Orthogonally, we should think if adding a code style recommendation for line length along with pre-commit hook would be beneficial to ensure readability.
Encountered during recent tests.