Unidata / netcdf-c

Official GitHub repository for netCDF-C libraries and utilities.
BSD 3-Clause "New" or "Revised" License
515 stars 262 forks source link

Issues compiling netCDF with HDF5 support through Amber #2984

Closed JarofDirt closed 2 months ago

JarofDirt commented 2 months ago

Hello,

I'm trying to compile netcdf-4.6.1 through the amber package via their instructions at https://ambermd.org/InstUbuntu.php on Ubuntu 22.04.4 LTS .

A user has asked to have HDF5 enabled.

I have installed and compiled HDF5 1.14..4.2 on the system successfully with the Configure command below:

./configure --prefix=/usr/local/hdf5 --enable-hl --with-zlib --enable-parallel --enable-shared

Which compiles and installs fine.

When using the above instructions for amber, after ./run_cmake and running the make install I get the following error:

.....
[  8%] Building C object AmberTools/src/netcdf-4.6.1/libsrc4/CMakeFiles/netcdf4.dir/nc4attr.c.o
[  8%] Building C object AmberTools/src/netcdf-4.6.1/libsrc4/CMakeFiles/netcdf4.dir/nc4dim.c.o
[  8%] Building C object AmberTools/src/netcdf-4.6.1/libsrc4/CMakeFiles/netcdf4.dir/nc4file.c.o
In file included from /usr/local/include/hdf5/H5public.h:31,
                 from /usr/local/include/hdf5/hdf5.h:21,
                 from /usr/local/amber24_src/AmberTools/src/netcdf-4.6.1/include/nc4internal.h:18,
                 from /usr/local/amber24_src/AmberTools/src/netcdf-4.6.1/libsrc4/nc4file.c:17:
/usr/local/amber24_src/AmberTools/src/netcdf-4.6.1/libsrc4/nc4file.c: In function ‘read_type’:
/usr/local/include/hdf5/H5version.h:1096:29: error: too many arguments to function ‘H5Tget_array_dims2’
 1096 |   #define H5Tget_array_dims H5Tget_array_dims2
      |                             ^~~~~~~~~~~~~~~~~~
/usr/local/amber24_src/AmberTools/src/netcdf-4.6.1/libsrc4/nc4file.c:1564:17: note: in expansion of macro ‘H5Tget_array_dims’
 1564 |             if (H5Tget_array_dims(member_hdf_typeid, dims, NULL) != ndims) {
      |                 ^~~~~~~~~~~~~~~~~
In file included from /usr/local/include/hdf5/H5Apublic.h:22,
                 from /usr/local/include/hdf5/hdf5.h:22,
                 from /usr/local/amber24_src/AmberTools/src/netcdf-4.6.1/include/nc4internal.h:18,
                 from /usr/local/amber24_src/AmberTools/src/netcdf-4.6.1/libsrc4/nc4file.c:17:
/usr/local/include/hdf5/H5Tpublic.h:1731:12: note: declared here
 1731 | H5_DLL int H5Tget_array_dims2(hid_t type_id, hsize_t dims[]);
      |            ^~~~~~~~~~~~~~~~~~
make[2]: *** [AmberTools/src/netcdf-4.6.1/libsrc4/CMakeFiles/netcdf4.dir/build.make:118: AmberTools/src/netcdf-4.6.1/libsrc4/CMakeFiles/netcdf4.dir/nc4file.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:4695: AmberTools/src/netcdf-4.6.1/libsrc4/CMakeFiles/netcdf4.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

When following the instructions provided by: https://docs.unidata.ucar.edu/nug/current/getting_and_building_netcdf.html

It seems to compile fine without a hitch...

Configure command below:

export NCDIR="/usr/local/netcdf-4.6.1/standalone/";  export H5DIR="/usr/local/hdf5";  export CPPFLAGS="-I${H5DIR}/include" export LDFLAGS="-L${H5DIR}/lib"; ./configure --prefix=${NCDIR};

Is there something that I'm missing between CMAKE vs configure or is there something to do with Amber? Any assistance would be greatly appreciated.

WardF commented 2 months ago

I suspect you will need to either upgrade to a more recent version of netcdf, either v4.9.2 or v4.9.3-rc1, or downgrade to an earlier version of libdhdf5, something in the 1.10.x or maybe 1.12.x family. I believe the issue here is forward-incompatibility with an old version of netCDF and a new version of libhdf5.

JarofDirt commented 2 months ago

I'm just following up on this in case anyone else runs into it...

The best path forward is to download/install a newer instance of NetCDF instead of trying to force the NetCDF packaged with Amber...

Using NetCDF v4.9.2 and HDF5 1.14.4-3 compiled with no issues for me.

Thanks again @WardF