Unidata / netcdf-c

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

Ubuntu Focal: Can not build with NC-4 parallel support #1894

Open mauimuc opened 3 years ago

mauimuc commented 3 years ago

My actual goal is to build NetCDF fortran but I don't get so far.

I am using a clean docker container to started off from

docker run -it --rm ubuntu:focal

Install dependencies; In particular the hdf5 parallel build

apt update 
apt install wget cmake gcc libopenmpi-dev libcurl4-openssl-dev libhdf5-mpi-dev 

Grab NetCDF-c v4.7.4

wget https://github.com/Unidata/netcdf-c/archive/v4.7.4.tar.gz
tar -xvf v4.7.4.tar.gz
cd netcdf-c-4.7.4

I decided to use cmake because the configure script can't find hdf5.h (although include and library paths are specified correct).

mkdir build 
cd build 
cmake ..

-DBUILD_PARALLEL=ON doesn't seem to have any effect. In any case it says

NC-4 Parallel Support:  no

If I am trying to build it anyways it cant find mpi.h and errors out. Specifying the include dir in CFLAGS, CPPFLAGS or CMAKE_CPP_FLAGS does not help. Any suggestions how to build with NC-4 parallel support it?

WardF commented 3 years ago

I'm investigating now; thanks for providing the docker commands (isn't docker great?). I'll follow up shortly.

WardF commented 3 years ago

Taking a quick look at your steps, what happens if you add the option -DCMAKE_C_COMPILER=mpicc to your cmake command? Using the default compiler, gcc, would explain several things you are observing. I'll try to replicate your issue on my end and also this fix to see if that addresses it, in the meantime.

WardF commented 3 years ago

I was able to resolve this, but not in the way (precisely) that I hypothesized above. I will need to make some changes in how libhdf5 is detected/handled by our cmake subsystem. In the meantime, create a symbolic link thusly:

$ ln -s /usr/lib/x86_64-linux-gnu/libhdf5_openmpi.so /usr/lib/x86_64-linux-gnu/libhdf5.so 

If you do this and then run the cmake command (from the build/ directory):

$ cmake .. -DCMAKE_C_COMPILER=mpicc.openmpi 

you should see that netCDF has been configured to build with parallel support.

mauimuc commented 3 years ago

Works like charm. Thanks a million!

WardF commented 3 years ago

Fantastic, glad to hear it. Leaving this open so that I can reference it with a fix.