ESCOMP / CMEPS

NUOPC Community Mediator for Earth Prediction Systems
https://escomp.github.io/CMEPS/
21 stars 77 forks source link

use ESMF_Version_* to get version dependent differences in CMEPS #74

Open mvertens opened 4 years ago

mvertens commented 4 years ago

All of the ESMFVERSION* symbols are available as parameters via "use ESMF" in Fortran code. This is documented under https://esmf-org.github.io/dev_docs/ESMF_refdoc/node9.html#SECTION090161000000000000000.

Using the above Fortran named constants is the most portable way to code version dependent differences in code because it does not require the build system to get involved. I think this approach should be used inside the CMEPS code for (ESMF_VERSION_MAJOR==8 .and. ESMF_VERSION_MINOR>0), and it should replace the CPP #if based code.

There are cases where the CPP based #if approach is necessary - basically for when API changes between ESMF versions will not allow compilation under different versions. This is not the case here, and therefore it will be much simpler to just use Fortran level logic based on the named constants. The problem with the CPP macro based approach is that it requires that the build system gets the variables from the esmf.mk and then pass them in via -D option to the compiler. The NEMS build system does this e.g. for module_EARTH_GRID_COMP.F90 and module_MEDIATOR.F90, but not for CMEPS, which would need a change in the CMEPS Makefile.

Again, my recommendation is to change the CMEPS version logic code to using the ESMFVERSION* named constants defined by "use ESMF".

jedwards4b commented 4 years ago

I think that there must be some confusion here.

jedwards4b commented 4 years ago

The suggestion from Gerhard cannot be used since the ESMF_VERSION macro is being used to determine if elements of the ESMF module itself exist. Therefore I think that this code needs to remain as is.

#if ESMF_VERSION_MINOR > 0                                                                           
    use ESMF , only : ESMF_StateSet, ESMF_StateIntent_Import, ESMF_StateIntent_Export                
    use ESMF , only : ESMF_StateIntent_Flag                                                          
#endif