How to compile and install netcdf-4 (C and Fortran) with nvidia c and fortran compiler

Hi.
Is there a guide or a reference for a complete installation (and compilation) of netcdf4 with nvidia compilers instead of gnu compilers?
Many thanks in advance.

Try this. I use the 22.7 release here, but feel free to substitute your own preferred version. Note we have not tested HDF5 1.13.x nor NetCDF-C 4.9.0 here yet, so if these versions have issues, I would suggest dropping back to previous versions and filing a report. Also tailor $DESTDIR below according to your needs:

DESTDIR=/path/to/netcdf/will/be/installed
module load nvhpc/22.7
wget https://support.hdfgroup.org/ftp/lib-external/szip/2.1.1/src/szip-2.1.1.tar.gz
tar xvaf szip-2.1.1.tar.gz
cd szip-2.1.1
mkdir build
cd build
../configure CC=nvc \
    --enable-shared \
    --enable-static \
    --prefix=$DESTDIR
make -j
make install
cd ../..

wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.13/hdf5-1.13.2/src/hdf5-1.13.2.tar.gz
tar xvaf hdf5-1.13.2.tar.gz
cd hdf5-1.13.2
mkdir build
cd build
../configure CC=mpicc FC=mpifort \
    CFLAGS="-fPIC -O1" \
    FCFLAGS="-fPIC -O1" \
    --enable-shared \
    --enable-static \
    --enable-fortran \
    --enable-hl \
    --enable-parallel \
    --with-zlib \
    --with-szlib=$DESTDIR \
    --prefix=$DESTDIR
make -j
make install
cd ../..

wget https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.0.tar.gz && \
    mv v4.9.0.tar.gz netcdf-c-4.9.0.tar.gz
tar xvaf netcdf-c-4.9.0.tar.gz
cd netcdf-c-4.9.0
mkdir build
cd build
../configure CC=mpicc \
    CFLAGS="-fPIC -O1"
    CPPFLAGS="-I$DESTDIR/include" \
    LDFLAGS="-L$DESTDIR/lib" \
    --enable-shared \
    --enable-static \
    --prefix=$DESTDIR
make -j
make install
cd ../..

wget https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.0.tar.gz && \
    mv v4.6.0.tar.gz netcdf-fortran-4.6.0.tar.gz
tar xvaf netcdf-fortran-4.6.0.tar.gz
cd netcdf-fortran-4.6.0
../configure CC=mpicc FC=mpifort \
    CFLAGS="-fPIC -O1 -I$DESTDIR/include" \
    FCFLAGS="-fPIC -O1" \
    LDFLAGS="-L$DESTDIR/lib -lnetcdf -lhdf5_hl -lhdf5" \
    --enable-shared \
    --enable-static \
    --prefix=$DESTDIR
make
make install

Hope this helps.

Many thanks for your help.
Unfortunately this is not working because netcdf configuration does not find the “hdf5.h”.

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 checked, and with a previous version of hdf5 (1.12.2) the file hdf5.h exists. I don’t understand.