Closed JiaweiZhuang closed 4 years ago
I saw no hard-coded -lhdf5_hl -lhdf5
in GCHP Makefile. @jimmielin suspect that the -lnetcdf -lnetcdf -lhdf5_hl -lhdf5 -lz -lm
part comes from nf-config --flibs
in some ESMF Makefiles. For example ESMF/build/common.mk uses
ESMF_NFCONFIG = $(shell $(ESMF_NETCDF) --prefix)/bin/nf-config
which gives you this annoying -lhdf5_hl -lhdf5
:
$ $(spack location -i netcdf-fortran)/bin/nf-config --flibs
-L/home/centos/spack/opt/spack/linux-centos7-x86_64/intel-19.0.4/netcdf-fortran-4.4.5-tuuki3kp5ngtji3m54zjw3bkh7ri2num/lib -lnetcdff -L/home/centos/spack/opt/spack/linux-centos7-x86_64/intel-19.0.4/netcdf-4.7.0-sale32bbd3tize6jgjq6npfvgrfeyw65/lib -lnetcdf -lnetcdf -lhdf5_hl -lhdf5 -lz -lm
Same problem with 12.5.0. See https://github.com/geoschem/gchp/issues/17#issuecomment-530017885 for a log containing this HDF5 error.
I can confirm this will also be the case for GEOS-Chem Classic when generating the final geos
executable. This does not impact GEOS-Chem Classic itself as it does not depend on Intel MPI (so this scenario is unlikely to break any users' installs), however there should be no reason GCC depends on -lhdf5 -lhdf5_hl
.
This is specified in Makefile_header.mk
in the main GEOS-Chem directory:
NC_LINK_CMD := $(shell $(GC_F_BIN)/nf-config --flibs)
nf-config --flibs
will return -lhdf5 -lhdf5_hl
. Compiling without those linker flags will not break GCC so there could be a regex to patch them out of the nf-config
output, for a quick fix.
In a container environment (with almost no pre-installed libraries), the -lz
flag (linking zlib) also breaks the build. Can be fixed by yum install zlib-devel
.
@jimmielin @JiaweiZhuang Have either of you verified if this issue is still an open issue when using CMake? I also wonder about using the latest GCHP which has an updated ESMF.
I am closing this issue since there has been no responses. The problematic code is in Makefiles that will be retired in the next version (13.0).
Describe the bug
During compilation, some commands contain
-lhdf5_hl -lhdf5
but don't specify the HDF5 library path via-L
:Full compile log: compile_hdf5_error.log
This can be solved by a dirty fix that copies HDF5 libraries into NetCDF directory:
Successful compile log: compile_success.log
To Reproduce
spack -v install netcdf-fortran %intel ^hdf5+fortran+hl ^intel-mpi
make build_all
The environment config is:
Environment