Stewart Kerr
Stewart Kerr

Reputation: 1

Error when compiling parallel netCDF

I am trying to compile and install netCDF with a parallel build of HDF5.

First I installed an up to date zlib then I installed a serial HDF5 and a parallel HDF5 so that

/scratch/mycomputername/packages/ ... contains the HDF5 and zlib lib, include, bin folders.

/scratch/mycomputername/packages_parallel ... contains the parallel HDF5 and zlib lib, include and bin folders.

***ZLIB INSTALL:

./configure --prefix=/scratch/mycomputername/packages
make
make test
make install prefix=/scratch/mycomputername/packages

&

./configure --prefix=/scratch/mycomputername/packages_parallel
make
make test
make install prefix=/scratch/mycomputername/packages_parallel

***HDF5 INSTALL:

./configure --prefix=/scratch/mycomputername/packages --enable-fortran --with-zlib=/scratch/mycomputername/packages/include,/scratch/mycomputername/packages/lib
make
make check
make install prefix=/scratch/dione/packages

&

./configure --prefix=/scratch/mycomputername/packages_parallel --enable-parallel --enable-fortran --with-zlib=/scratch/mycomputername/packages_parallel/include,/scratch/mycomputername/packages_parallel/lib
make
make check
make install prefix=/scratch/mycomputername/packages_parallel

***Then, to install the serial netCDF I used

./configure --prefix=/scratch/mycomputername/packages CPPFLAGS=-I/scratch/mycomputername/packages/include LDFLAGS=-L/scratch/computername/packages/lib
make
make check
make install prefix=/scratch/mycomputername/packages

This worked successfully.

***However, when I tried to do the same for parallel netCDF I ran into errors. I used

./configure --prefix=/scratch/mycomputername/packages_parallel CPPFLAGS=-I/scratch/mycomputername/packages_parallel/include LDFLAGS=-L/scratch/mycomputername/packages_parallel/lib

and I get the error: checking hdf5.h usability ... no checking hdf5.h presence ... no checking for hdf5.h ... no configure: error: Compiling a test with HDF5 failed. Either hdf5.h cannot be found, or config.log should be checked for other reason

I also tried ./configure --prefix=/scratch/computername/packages_parallel --with-hdf5=/scratch/mycomputername/packages_parallel/ --with-zlib=/scratch/mycomputername/packages_parallel/lib but I get the error message quoted above.

Does anyone know why the parallel version might be having trouble finding the HDF5 library?

Upvotes: 0

Views: 2717

Answers (2)

taranaki
taranaki

Reputation: 843

From the netcdf README file, it is suggested to specify both include paths (CPPFLAGS) and linker flags (LDFLAGS, library paths and additional libraries).

I had the same trouble as you when I included pnetcdf, and adding the paths to the hdf5 include directory to CPPFLAGS, and the path to the hdf5 lib directory as well as the path to the mpi libraries and the addition of -lmpi to LDFLAGS.

Here's all of that together in one command:

CPPFLAGS="-I/usr/local/pnetcdf/include -I/usr/local/hdf5/include -I/usr/local/mpi/include" LDFLAGS="-L/usr/local/hdf5/lib -L/usr/local/pnetcdf/lib -L/usr/local/mpi/lib -lmpi" ./configure --prefix=/usr/local/netcdf --enable-netcdf4 --enable-pnetcdf

Upvotes: 1

Trond Kristiansen
Trond Kristiansen

Reputation: 2446

Make sure that for each package you compile and install add the necessary paths to your .profile or .bashrc file. For example, you need to add this after ZLIB installation (given that install directory is /usr/local):

if [ -z "${ZLIBDIR}" ]
then
ZLIBDIR="/usr/local"; export ZLIBDIR
else
ZLIBDIR="/usr/local:${ZLIBDIR}"; export ZLIBDIR
fi

For HDF5 I always use the following:

export HDF5_LIB_DIR="/usr/local/lib"
if [ -z "${LD_LIBRARY_PATH}" ]
then
LD_LIBRARY_PATH="/usr/local/lib"; export LD_LIBRARY_PATH
else
LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"; export LD_LIBRARY_PATH
fi
if [ -z "${LIBDIR}" ]
then
LIBDIR="/usr/local/lib"; export LIBDIR
else
LIBDIR="/usr/local/lib:${LIBDIR}"; export LIBDIR
fi
export INCLUDE=/usr/local/lib:$Include
export PATH=/usr/local/bin:$PATH
export HDF5_LIB_DIR=/usr/local/lib
export HDF5DIR=/usr/local
export HDF5_DIR=/usr/local
export CPPFLAGS="-I$HDF5_DIR/include -I/usr/local/include"
export LDFLAGS="-L$HDF5_DIR/lib -L/usr/local/lib"

Finally, after installing NetCDF I use:

export NETCDFHOME=/usr/local
export NETCDF_PREFIX=/usr/local
export NETCDF_LIB=/usr/local/lib
export NETCDF4_ROOT=/usr/local
export NETCDF4_DIR=/usr/local
export NETCDF_INC=/usr/local/include
export PATH=/usr/local/bin:$PATH

Hope this helps. Cheers, Trond

Upvotes: 2

Related Questions