Open AaronDonahue opened 5 years ago
Pinging @bartgol and @ambrad who helped me track this down.
The error showed up in m_mpif90.F90 module, where two "overloads" of MP_Type were given, for SP and DP. If the default real is 64 bits, and SELECTEDREALKIND is not defined, you end up with SP=DP. This yielded to the two overload to be exactly the same, which meant the interface procedure could not pick one.
Possible solution: Make SP always denote single precision, and DP always denote double precision. This means to eliminate that ifdef, and always pick the first branch.
FYI - CCSM went through an extended exercise to eliminate dependence on compiler flags to autopromote variables, adding explicit typing everywhere, including constants. This has been maintained (as far as I know) in CESM and E3SM. @rljacob , any comments about MCT supporting (or deliberately not supporting) , for example, -r8 ?
Yes auto-promotion is not allowed in E3SM fortran builds.
Although the behavior I'd expect is that MCT just ignores any auto-promotion flags. So this is worth looking at.
You mean you thought MCT would ignore the -real-size 64
flag?
No I thought -r8 would have no effect but you get a build error even with that.
A workaround is go ahead and define SELECTEDREALKIND. You can then build with any of the autopromotion flags. Note that you could still compile an application that links against MCT with autopromotion even if MCT is compiled without it.
IIRC, we were concerned about using the intrinsic selected_real_kind() because we wanted MCT to require only an F90 compiler and that function is in the F95 standard. I suppose we could drop that now. There is similar code in CIME that uses selected_real_kind and I believe E3SM/CIME requires Fortran2008.
If the intel fortran compiler flag
-real-size 64
, which is equivalent to-autodouble
or-r8
, is used the build will break during MCT. We tracked the issue down to the file:cime/src/externals/mct/mpeu/m_realkinds.F90
which has the following block of code that conflicts with the compiler flag option:where SP and DP are defined. The break in the build is in an "interface" defined in
m_mpif90.F90
.