Closed rjleveque closed 11 months ago
I don't think it should throw any kind of error. We all use different gfortran compilers that are mostly ok with the same flags. I think it should warn that it's an 'unknown" compiler so using default flags and continue.
With your suggested fix, how could anyonen run with a different compiler other than editing Makefile.common?
I just pushed a change so that if FC
is set to gfortran-11
or any other string containing gfortran
then the gfortran flags are set.
If the user is using some other compiler, then as it stands they have to fix Makefile.common
, but the error message tells what line number it dies at and the user can probably figure out what to do.
We could add more complicated options allowing the user to specify the proper compiler flags on the command line but I think explaining and using that would be harder for the user than modifying Makefile.common
.
Maybe ifort
and pgfortran
are the only odd ones and we can assume any other Fortran compiler uses the same flags as gfortran
, but that seems potentially problematic.
There are definitely plenty of compilers that we do not currently list. I would be ok with the warning idea. We can also set the equals to ?=
instead so that someone could override it in the environment rather than set defaults.
somehow it's more in keeping with open course to use an open source compiler, which rules out a few of them.
On Nov 17, 2023, at 5:56 PM, Kyle Mandli @.***> wrote:
There are definitely plenty of compilers https://fortran-lang.org/compilers/ that we do not currently list. I would be ok with the warning idea. We can also set the equals to ?= instead so that someone could override it in the environment rather than set defaults.
— Reply to this email directly, view it on GitHub https://github.com/clawpack/clawutil/pull/164#issuecomment-1817224036, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGUGCZHLIL3PB4TQTYNDSLYE7TRDAVCNFSM6AAAAAA7QNM3XSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJXGIZDIMBTGY. You are receiving this because you commented.
Ok, here's a new version that uses the gfortran flags by default but first checks if the flags were set elsewhere, e.g.
$ export FC=xfortran
$ make .exe
/Users/rjl/git/clawpack/clawutil/src/Makefile.common:111: Warning : Proper compiler flags unknown for FC=xfortran
/Users/rjl/git/clawpack/clawutil/src/Makefile.common:114: Warning : Using -J for MODULE_FLAG
/Users/rjl/git/clawpack/clawutil/src/Makefile.common:118: Warning : Using -fopenmp for OMP_FLAG
$ export OMP_FLAG=xomp
$ make .exe
/Users/rjl/git/clawpack/clawutil/src/Makefile.common:111: Warning : Proper compiler flags unknown for FC=xfortran
/Users/rjl/git/clawpack/clawutil/src/Makefile.common:114: Warning : Using -J for MODULE_FLAG
I think it may still be good to provide an override to the flags we are setting so that someone would not need to modify Makefile.common
to get their particular compiler to work. Otherwise this looks good.
This seems to be working fine.
If
FC
is not set to one we recognize then the compiler flags were set forgfortran
but there was an@echo
command that was supposed to print a warning but instead throws an obscure error in this caseIt turns out
@echo
can't be used here. I could have replaced it with$(warning ...)
but it seems safer to just print a better error message and quit to make sure the user avoids other obscure errors due to module flags being improperly set. So now it dies with this sort of message: