Netcdf fortran library


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?

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

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/.


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


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 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 \

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

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

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! 

mpiexec -n 4 simple_xy_par_rd
 *** SUCCESS reading example file!