Compiling GOTM: NetCDF Library Linking Issue

192 views
Skip to first unread message

Ian Adams

unread,
Nov 30, 2021, 9:05:10 AM11/30/21
to GOTM-users
Hello everyone! I am a hopeful new GOTM user but have been encountering some errors while trying to compile the code. I have seen and read similar errors in this user group as well as in forums, but the solutions there don't seem to function for me. 
The issue is when I attempt to compile, I receive the message: 

cmake /p/home/igbadams/gotm/code -- The Fortran compiler identification is Cray 12.0 -- Check for working Fortran compiler: /opt/cray/pe/craype/2.7.10/bin/ftn -- Check for working Fortran compiler: /opt/cray/pe/craype/2.7.10/bin/ftn - works -- Detecting Fortran compiler ABI info -- Detecting Fortran compiler ABI info - done -- Checking whether /opt/cray/pe/craype/2.7.10/bin/ftn supports Fortran 90 -- Checking whether /opt/cray/pe/craype/2.7.10/bin/ftn supports Fortran 90 - yes CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:164 (message): Could NOT find NetCDF (missing: NetCDF_LIBRARIES) Call Stack (most recent call first): /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE) extern/flexout/cmake/Modules/FindNetCDF.cmake:80 (find_package_handle_standard_args) extern/flexout/CMakeLists.txt:39 (find_package) -- Configuring incomplete, errors occurred!

The output of nf-config is as fllows:


nf-config --all
This netCDF-Fortran 4.5.3 has been built with the following features:
--cc -> cc
--cflags -> -DpgiFortran
--fc -> ftn
--fflags ->
--flibs ->
--has-f90 ->
--has-f03 -> yes
--has-nc2 -> yes
--has-nc4 -> yes
--prefix -> /opt/cray/pe/netcdf/4.7.4.7/CRAYCLANG/10.0
--includedir-> /opt/cray/pe/netcdf/4.7.4.7/CRAYCLANG/10.0/include
--version -> netCDF-Fortran 4.5.3

It is clear to me that the ffflags and flibs are empty, and so I have attemted to set them myself by using -DNetCDF_LIBRARIES when I cmake. This does create an executable, but when I try and run it it gives segmentation faults, making me suspect that it has not compiled correctly. 

Any suggestions as to the best way to link these libraries? Your help is greatly appreciated.

-Ian

Karsten Bolding

unread,
Nov 30, 2021, 9:21:27 AM11/30/21
to gotm-...@googlegroups.com
Hi Ian

The GOTM configuration uses the exact content of --fflags and --flibs to setup NetCDF compilation. When empty (or the include path and library path are not standard search paths) there is no way the right configuration can be done.

If I were you I would try and contact the sysadm of the cluster.

Karsten

--
You received this message because you are subscribed to the Google Groups "GOTM-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gotm-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gotm-users/3f1129cf-f8ab-4f9f-af47-49c8e00829ben%40googlegroups.com.


--

Ian Adams

unread,
Nov 30, 2021, 9:35:01 AM11/30/21
to GOTM-users
Thanks for the quick response. I was afraid that might be the case, but was hopeful that there may have been a workaround. I will try to
 get it resolved through the sysadmin. 

Thanks again!
-Ian

Karsten Bolding

unread,
Nov 30, 2021, 9:41:15 AM11/30/21
to gotm-...@googlegroups.com
There is likely away around it - as on Windows there is no nf-config.

You can have a look in:
extern/flexout/cmake/Modules/FindNetCDF.cmake
but it might be easier to ask the sysadm :-)

Martin Schmidt

unread,
Nov 30, 2021, 9:48:52 AM11/30/21
to gotm-...@googlegroups.com

Dear Ian,

when I was working on a CRAY, they had their own system of linking and managing the path to the libraries. Nobody really understood, how it worked, but it worked perfectly. I have forgotten details, so I cannot deliver syntax examples.

- using environmentel modules. On the CRAY loading the netcdf module and just putting -lnetcdff into the flags did the job. In the background a complex system of joint action of "modules" and pkg-config was in action. Do they exist on your computer. All the paths the compiler and linker needs, were set correctly. Explicit determination of paths is not needed, just load the module. Do not set environmental variables to find libraries. They may overwrite the settings, CRAY is expecting and managing with the modules system.

- CRAY is linking statically by default. I guess (do not know), GOTM is aiming to build a dynamic library.

- I would read the documents of the compute centre or ask the sysadmins, how to link the netcdf library best. May be a simple example away from GOTM helps to understand the principles first.

- From here on dangerous! :-) nf-config is a simple script. May be, flibs and fflags are intensionally empty not to disturb the CRAY linker. If nothing helps, you could put nf-config into your $HOME/bin and add the desired output for fflags and so on. A "nf-config" from a correctly installed netcdf helps to find the syntax details. But do not forget to remove it later, it may rise strange side effects with other netcdf-related software.

- Finally, another option. Just check with "grep", where in the GOTM scripts "nf-config" ist used. You could replace the call of "nf-config" with the desired result.

Cheers,

Martin

Jorn Bruggeman

unread,
Nov 30, 2021, 9:52:45 AM11/30/21
to gotm-...@googlegroups.com

The typical solution would be to provide -DNetCDF_INCLUDE_DIRs=<semicolon-separated-dirs> and -DNetCDF_LIBRARIES=<semicolon-separated-library-paths>. The segmentation fault that you get when you do this might indicate that the NetCDF library was compiled with a different compiler (or a different compiler version) than the one you’re using. But just to rule out other issues, you could try compiling with -DGOTM_USE_NetCDF=OFF, and rerunning GOTM. If it runs, NetCDF is the problem, and you might want to look for a different version (or build it yourself); if it does not run, you might want to try a different compiler such as gfortran, as it is then likely a Cray issue

 

Cheers,

 

Jorn

Reply all
Reply to author
Forward
0 new messages