netcdf-c icon indicating copy to clipboard operation
netcdf-c copied to clipboard

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

Open mauimuc opened this issue 4 years ago • 5 comments

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?

mauimuc avatar Dec 01 '20 20:12 mauimuc

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

WardF avatar Dec 01 '20 20:12 WardF

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 avatar Dec 01 '20 20:12 WardF

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.

WardF avatar Dec 01 '20 21:12 WardF

Works like charm. Thanks a million!

mauimuc avatar Dec 02 '20 08:12 mauimuc

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

WardF avatar Dec 09 '20 22:12 WardF