geos-chem
geos-chem copied to clipboard
[BUG/ISSUE] Necessity of LD_LIBRARY_PATH when building/running GEOS-Chem
What institution are you from?
Duke University
Description of the problem
I successfully downloaded and compiled GCClassic v13.4.1 on my cluster. But when I tried to perform a dry run with the command ./geos --dryrun > log.dryrun I get the message gcclassic: error while loading shared libraries: libnetcdff.so.7: cannot open shared object file: No such file or directory
Description of troubleshooting performed
I did not do any specific troubleshooting because the User's Guide says "If you are using GEOS-Chem 13.0.0 , you do not need to define any Unix environment variables other than the compiler variables (FC, CC, and CXX)."
GEOS-Chem version
v13.4.1
Description of modifications
None
Log files
- Build log (if applicable): I am attaching the CMakeCache.txt file CMakeCache.txt
- Run logs (if applicable):
- Run script (if applicable):
Software versions
- CMake version: 3.19.3
- Compilers (Intel or GNU, and version): GNU 9.4.0
- NetCDF version: 4.8.1
Hi @pkasibhatla. It seems that CMake couldn't find your netCDF Fortran library.
From the cache file I see that these are the paths that the build process found.
//Location of nc-config utility
NC_CONFIG:FILEPATH=/opt/apps/rhel8/miniconda3/envs/gchp-env/bin/nc-config
//Directory containing "netcdf.h"
NETCDF_C_INCLUDE_DIR:PATH=/opt/apps/rhel8/miniconda3/envs/gchp-env/include
//Path to "libnetcdf"
NETCDF_C_LIBRARY:FILEPATH=/opt/apps/rhel8/miniconda3/envs/gchp-env/lib/libnetcdf.so
//Directory containing "netcdf.inc"
NETCDF_F77_INCLUDE_DIR:PATH=/opt/apps/rhel8/miniconda3/envs/gchp-env/include
//Directory containing "netcdf.mod"
NETCDF_F90_INCLUDE_DIR:PATH=/opt/apps/rhel8/miniconda3/envs/gchp-env/include
//Path to "libnetcdff"
NETCDF_F_LIBRARY:FILEPATH=/opt/apps/rhel8/miniconda3/envs/gchp-env/lib/libnetcdff.so
//Location of nf-config utility
NF_CONFIG:FILEPATH=/opt/apps/rhel8/miniconda3/envs/gchp-env/bin/nf-config
It did find the libnetcdff.so
file (the shared library for netCDF-Fortran). Sometimes this is a symbolic link to another file in the same directory. Take a look in this folder: /opt/apps/rhel8/miniconda3/envs/gchp-env/lib/
and see if libnetcdff.so
is symbolically linked to another library file there or if the link is broken.
Also note: we are updating our documentation and migrating it to geos-chem.readthedocs.io. We realize that some of the wiki docs are out of date. We'll have this finished by the 14.0.0 release.
Hi @yantosca, it is indeed symbolically linked to another file, but that file exists:
psk9@dcc-login-03 ~ $ cd /opt/apps/rhel8/miniconda3/envs/gchp-env/lib psk9@dcc-login-03 /opt/apps/rhel8/miniconda3/envs/gchp-env/lib $ ls -l libnetcdff.so lrwxrwxrwx. 1 tm103 rescomp 19 Jul 18 10:22 libnetcdff.so -> libnetcdff.so.7.1.0* psk9@dcc-login-03 /opt/apps/rhel8/miniconda3/envs/gchp-env/lib $ ls -l libnetcdff.so.7.1.0 -rwxrwxr-x. 3 tm103 rescomp 1760416 Jan 20 11:39 libnetcdff.so.7.1.0*
Hi again @yantosca,
I was able to run after executing the command:
export LD_LIBRARY_PATH=/opt/apps/rhel8/miniconda3/envs/gchp-env/lib:$LD_LIBRARY_PATH
But I thought with v13, we did not need to specify this environment variable.
Normally you wouldn't need to specify LD_LIBRARY_PATH, as the CMake build process should find the library file. Am tagging @LiamBindle who knows more about the particulars of CMake than I do.
Adding -DCMAKE_PREFIX_PATH=/opt/apps/rhel8/miniconda3/envs/gchp-env/lib to the build initialization did not fix this problem - I still need to specify
export LD_LIBRARY_PATH=/opt/apps/rhel8/miniconda3/envs/gchp-env/lib:$LD_LIBRARY_PATH
to run the model, even though it compiles without LD_LIBRARY_PATH being set.
If I understand correctly, you successfully compiled GC-Classic but when you try to run you get
gcclassic: error while loading shared libraries: libnetcdff.so.7: cannot open shared object file: No such file or directory
If that's the case, the problem is the shared library libnetcdff.so.7
cant be found when you execute ./geos
. This isn't related to building GEOS-Chem. In linux, when a program starts, the dynamic linker loads all of the shared libraries that the program links. It does this by searching through a list of directories for a file with the right name. LD_LIBRARY_PATH
is an environment variable that adds extra directories to this search list.
You can always run ldd ./geos
to list the resolved paths to shared libraries loaded by the ./geos
program. Before you set LD_LIBRARY_PATH
, ldd
it should say libnetcdff.so.7.1.0
isn't found. After you set LD_LIBRARY_PATH
, it should show the path to the library. This is because your libnetcdff.so.7.1.0
is installed in a non-standard location (since you've installed it via conda rather than installing it system wide).
tldr: This is expected. Set LD_LIBRARY_PATH
before you run ./geos
. LD_LIBRARY_PATH
is a list of directories that linux searches for shared libraries when you launch a program. If your netcdf libraries are in a non-standard directory (e.g., installed via conda as opposed to installed system-wide) then you usually need to set LD_LIBRARY_PATH
.
Thanks for the explanation. Not sure why the Duke sys admin installed using conda, but I guess I am stuck with it. So yes, everything works fine once I set LD_LIBRARY_PATH.
This issue has been automatically marked as stale because it has not had recent activity. If there are no updates within 7 days it will be closed. You can add the "never stale" tag to prevent the Stale bot from closing this issue.