esmf-org / esmf

The Earth System Modeling Framework (ESMF) is a suite of software tools for developing high-performance, multi-component Earth science modeling applications.
https://earthsystemmodeling.org/
Other
156 stars 75 forks source link

NetCDF split across directories #146

Open cponder opened 1 year ago

cponder commented 1 year ago

Since NetCDF has been split into separate C/Fortran/C++/etc. distributions with disjointed versions, there are some systems where the libraries are stored in separate directories. The ESMF variables, though, don't seem to allow for this since there is only one variable to set:

ESMF_NETCDF
ESMF_NETCDF_INCLUDE
ESMF_NETCDF_LIBPATH
ESMF_NETCDF_LIBS

Can you please split these up

ESMF_NETCDF_C
ESMF_NETCDF_CXX
ESMF_NETCDF_FORTRAN

but also tell me how I can add the extra paths in the meantime?

cponder commented 1 year ago

An easy way to manage is this is (bash syntax)

if [[ ! -v ESMF_NETCDF_C ]]
then
      ESMF_NETCDF_C=$ESMF_NETCDF
fi
if [[ ! -v ESMF_NETCDF_CXX ]]
then
      ESMF_CXX=$ESMF_NETCDF
fi
# etc.

This way, if the libs are all in the same directory, we just point the individual paths there. Then build-scripts following the old convention will still work.

cponder commented 1 year ago

For the record, this variable seems to be enough of a workaround for now:

export ESMF_F90COMPILEOPTS="-I $NETCDF_F/include -I $MPI/include"
theurich commented 1 year ago

@cponder - ESMF's build system does support the NetCDF split for C (implementation of NetCDF), and separate Fortran bindings. Unfortunately the ESMF user's guide (https://earthsystemmodeling.org/docs/nightly/develop/ESMF_usrdoc/node10.html#SECTION000104200000000000000) does not discuss this feature to the full depth of it. However, see under the nc-config option of ESMF_NETCDF, where it says that nf-config will be looked for, and if found functional will be used for the Fortran bindings of NetCDF.

Internally what happens is that the ESMF_NETCDF* are for the C implementation of NetCDF, but there are also a set of ESMF_NETCDFF* variables that are used for the Fortran bindings. The default of the latter INCLUDE, LIBPATH, and LIBS vars the same as used to find the C implementation of NetCDF. However, if either of the variables is found in the user environment or set via nf-config, it will be used instead.