Netcdf fortran library

Hi,

I am trying to install the netcdf library for fortran to build a fortran program that uses netcdf files but I can’t find the correct bundle. I have searched and installed “os-clr-on-clr-dev”, and “R-extras-dev” bundles that contain the “netcdf-dev” package but when I do: nc-config --all command, I get “–has-fortran → no”.

Any ideas?
Thanks
Konstantinos

Try installing the Intel oneAPI Base Toolkit + HPC Toolkit (choose offline download).

This toolkit complements the Intel oneAPI Base Toolkit and adds:

Intel Fortran Compiler
Intel Fortran Compiler Classic
Intel Inspector
Intel MPI Library
Intel Trace Analyzer and Collector

https://www.intel.com/content/www/us/en/developer/tools/oneapi/toolkits.html#hpc-kit

https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz

https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz

Thank you @Businux for your reply. I will try your approach.

I was also thinking of installing Dnf package manager, and then install the netcdf-fortran RPM package (from the fedora repository) that matches my compiler version. What do you think about this approach?

oneAPI + HPC is quite a big install, first try your own solution.

This is a net package – I’m currently adding this
(note for new package requests, a quick github issue is the most easy way because github issues – unlike the forum – are easier to track/etc)

The Clear 41080 netcdf.spec file is missing a build requirement, necessary for OpenMPI parallel support.

BuildRequires : hdf5-openmp

I’m curious about the Fortran parallel demonstrations. So, I built hdf5, netcdf, and netcdf-fortran manually; installation in /usr/local/lib64/openmpi/.

Requirements:

sudo swupd bundle-add c-basic graphviz openmpi \
  devpkg-bzip2 devpkg-curl devpkg-libxml2 devpkg-openmpi \
  devpkg-zlib devpkg-zstd 

Environment:

export OMPI_DIR="/usr/local/lib64/openmpi"

export CFLAGS="${CFLAGS} -I${OMPI_DIR}/include -L${OMPI_DIR}/lib"
export CXXFLAGS="${CXXFLAGS} -I${OMPI_DIR}/include -L${OMPI_DIR}/lib"
export FCFLAGS="${FCFLAGS} -I${OMPI_DIR}/include -L${OMPI_DIR}/lib"
export FFLAGS="${FFLAGS} -I${OMPI_DIR}/include -L${OMPI_DIR}/lib"

export LD_LIBRARY_PATH=${OMPI_DIR}/lib
export PKG_CONFIG_PATH=${OMPI_DIR}/lib/pkgconfig

# create folders if they do not exist
sudo mkdir -p ${OMPI_DIR}/include
sudo mkdir -p ${OMPI_DIR}/lib

Configure options:

# hdf5
CC=mpicc FC=mpif90 ./configure \
  --prefix=${OMPI_DIR} \
  --disable-static \
  --enable-fortran \
  --enable-parallel \
  --with-szlib

# netcdf-c
CC=mpicc FC=mpif90 ./configure \
  --prefix=${OMPI_DIR} \
  --disable-static \
  --disable-dap-remote-tests \
  --disable-doxygen \
  --enable-dap \
  --enable-hdf5=${OMPI_DIR} \
  --with-pic

# netcdf-fortran
CC=mpicc FC=mpif90 ./configure \
  --prefix=${OMPI_DIR} \
  --disable-static

Testing mpif90:

cd netcdf-fortran-4.6.1/examples/F90

mpif90 -o simple_xy_par_wr -O3 simple_xy_par_wr.F90 \
  -I${OMPI_DIR}/include -L${OMPI_DIR}/lib -lnetcdff

mpif90 -o simple_xy_par_rd -O3 simple_xy_par_rd.F90 \
  -I${OMPI_DIR}/include -L${OMPI_DIR}/lib -lnetcdff

mpiexec -n 4 simple_xy_par_wr
*** SUCCESS writing example file simple_xy_par.nc! 

mpiexec -n 4 simple_xy_par_rd
 *** SUCCESS reading example file simple_xy_par.nc!