NOAA-SWPC / WAM

Whole Atmosphere Model extension of the GFS
GNU General Public License v3.0
3 stars 7 forks source link

FIX: Handle big endian compiler check #29

Closed greglucas closed 3 years ago

greglucas commented 3 years ago

Only the first value was being taken before due to a break; Remove that restriction and update the flags for the check.

greglucas commented 3 years ago

Pinging for reviews on this @akubaryk, @rmontuoro

rmontuoro commented 3 years ago

@greglucas - could you please elaborate on the issue? Removing the break may not be the proper solution.

Incidentally, configure is automatically generated. You will have to update the macro definition file (m4/ax_fortran_utils.m4), then run autoreconf -fvi to regenerate configure.

greglucas commented 3 years ago

@rmontuoro: The flags weren't being added to the test and it was only ever using the first value is I think what the main problem was, you're right it didn't have to do with the break. Thanks for pointing me to the m4 files.

I updated the m4 file with the change and it now gets the proper flag for me. My auto-generated configure file has more diffs than just that, so I'm not sure if you would rather remake that or if you want me to.

To test that it doesn't work on Intel, you could swap the order of the big-endian flags and move the Intel one later in the list and it will choose the first flag which wouldn't work.

rmontuoro commented 3 years ago

@greglucas - The logic in the original version of AX_FC_BIGENDIAN is implemented properly. The issue stems from the Intel compiler issuing a warning for unrecognized flags and continuing to compile successfully instead of exiting with an error, which is the behavior of the GNU Fortran compiler:

$ ifort --dummyflag test.F90 && echo SUCCESS || echo FAILURE
ifort: command line warning #10006: ignoring unknown option '-dummyflag'
SUCCESS
$ gfortran --dummyflag aa.F90 && echo SUCCESS || echo FAILURE
gfortran: error: unrecognized command line option ‘--dummyflag’
FAILURE

Flag detection in AX_FC_BIGENDIAN relies on the standard GNU Autoconf macro AC_COMPILE_IFELSE, which ignore warnings and acts based on the compile command's return code.

A different strategy needs to be implemented to address this issue.

greglucas commented 3 years ago

OK, my solution would be to rearrange the flags then. The logic may be "correct", but it is obviously failing on gfortran, which is not good IMO.

I am going to close this as I am out of my area of expertise here. It would be great if WAM supported gfortran compilation as well, so that I could create build tests on multiple compiler architectures.