IODA not finding netcdf-cxx

Hi all - so I’m having a problem building ioda on my linux laptop. Cmake can’t find netcdf-cxx.

I have my own spack installation, based partly on the spack-stack version of spack.

When I link to netcdf for oops and saber everything is fine. But, when I get to ioda, it has problems finding the CXX component. In my stack the three component are installed as separate modules, in their own directories:

netcdf-c/4.9.2-iees7jj

netcdf-cxx/4.2-i4jkx37

netcdf-fortran/4.6.1-ordmma2

The error looks like this:

CMake Error at /home/miesch/jedi/spack-stack/spack/opt/spack/linux-ubuntu24.04-skylake/gcc-13.3.0/jedi-cmake-1.4.0-fw5jpjj66sdikkw2ne2dcjvaruqixf5y/share/jedicmake/Modules/FindNetCDF.cmake:246 (message):Unable to properly find NetCDF.  Found static libraries at:/home/miesch/jedi/jedi-bundle/ioda/NetCDF_CXX_LIBRARY-NOTFOUND but couldnot run nc-config:

That suggests that it’s trying to get the netcdf-cxx informtion from nc-config? But nc-config runs fine with no indication of a cxx component. Is there some way to build netcdf-cxx so that it can be found by nc-config?

I tried setting NETCDF_ROOT and NETCDF_PATH as implied by the FindNetCDF file in jedi-cmake but it does not help. Also, I confirmed that the netcdf-cxx path is indeed included in CMAKE_PREFIX_PATH.

Any ideas? Thanks

Hi Mark, good to hear from you. Hope things are going well. I think the issue might be that you need to set the following variables instead of NETCDF_ROOT.

  • netcdf_ROOT
  • netcdf_cxx4_ROOT (or perhaps in your case, netcdf_cxx_ROOT (no “4”))
  • netcdf_fortran_ROOT

I’m guessing that NETCDF_ROOT is for the case where you install all three packages (netcdf-c, netcdf-cxx, netcdf-fortran) in the same directory, and when these are in separate directories, then you need the three separate variables.

Note: the FindNetCDF macro should be running ncxx-config (or ncxx4-config) for netcdf-cxx, and nf-config for netcdf-fortran. Hopefully that will get straightened out when using the three separate environment variables.

Sorry missed the comment about the CMAKE_PREFIX_PATH. It might be that you will need to use the “_DIR” or “_PATH” versions of the three variables to get CMake to look specifically if and where files like netcdf-c-config.cmake are installed.

Thanks Steve - Good to hear from you!

Yes - after I entered that I took a closer look at the FindNetCDF.cmake file and it looks like it wants to use ncxx4_config. But my netcdf-cxx-4.2 module has no bin directory so that program does not exist. I’ll probably need to re-install it with different spack options. I’ll do more digging. But can you confirm what version of netcdf-cxx you use these days?

We are using:

  • netcdf-c 4.9.2
  • netcdf-cxx4 4.3.1
  • netcdf-fortran 4.6.1

It might be helpful to look at the JCSDA spack package spec to get an idea of the netcdf-cxx build options. spack/var/spack/repos/builtin/packages/netcdf-cxx4/package.py at spack-stack-dev · JCSDA/spack · GitHub

Good luck with this! And let me know if you have more questions/issues.

Problem solved.

The problem was that I installed the netcdf-cxx spack module instead of the netcdf-cxx4 module. When I install the latter, the config file is there and it compiles. Thanks again!

You are welcome, and great to hear it is working!