Could NOT find NETCDF (missing: NETCDF_LIBRARY HAVE_NETCDF4)

Thank you so much for your reply. Appreciated. Sorry to take your valuable time. I am not sure how, but it has always been the case that the library is found. This is what my CMakeCache.txt shows, i.e.,

NETCDF_LIBRARY:FILEPATH=/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/lib64/libnetcdf.so

The command below shows no output:

nm -gu /opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/lib64/libnetcdf.so | grep nc_def_var_deflate

I did insert these commands below in /cmake/modules/ FindNETCDF.cmake

set (NETCDF_DIR /opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a)
set (NETCDF_LIBRARY /opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a/lib64/libnetcdf.so)
set (export NETCDF_ROOT=/opt/apps/resif/data/production/v1.2-20191021/default/software/data/netCDF/4.6.2-gompi-2019a)

I also insert the same environment specifications at ConfigUser.cmake

So the same error happens all the times.

The lack of nc_def_var_deflate is a problem. If it is not in your library then that certainly will explain why it fails. You will need a netcdf library with that function supported.

I asked one of our experts (who no longer is involved) and he wrote back with a few suggestions:

As for the cmake issue: I would suggest to run cmake with --debug-trycompile and --trace and examine the try_compile build tree for netcdf issues.

On the other hand since Yacob builds GMT himself: why not build his own netcdf in the first place? That might take less time than hunting down the errors with the pre-installed libs.