Check Library Version Netcdf Linux

check library version netcdf linux

netCDF provides the nc-config command line tool for this purpose.

To print the version.

nc-config --version

To print more information on the netCDF build you have:

nc-config --all

How to get the path where the library is installed

If you wish you can fix the path at compile time. Something like

gfortran -cpp mylib.f90 -DPREFIX=\"/usr/local/\"

open(newunit=u,file=PREFIX//'mylib/initialise.dat')

You must than make sure the library is indeed installed in that place PREFIX/mylib/


You can create an environment variable containing the path of your data. This variable can be set by hand, in your .bashrc or .bash_profile or in the system /etc/profile.d/ or /etc/bash.bashrc, there are manyways and they depend if the library is just for one user or for all users of some large computer.

For example
export MYLIB_PATH='/usr/local/mylib'

Then you can read the variable in Fortran as

CALL get_environment_variable("MYLIB_PATH", mylib_path, status=stat)

and the path is now in variable mylib_path. You can check the success by checking if stat==0.


This is not the only possible approach. You can also have a configuration file for your library in your home directory:

mkdir $HOME/.config/mylib/
echo "/usr/local/mylib" > $HOME/.config/mylib/path

and then you can try to read the path from this file if the environment variable was not set

if (stat/=0) then
CALL get_environment_variable("HOME", home_dir)
open(newunit=path_unit, file=home_dir//'/.config/mylib/path',status='old',action='read',iostat=stat)
if (stat/=0) complain

read(path_unit,'(a)',iostat=stat) mylib_path
if (stat/=0) complain
end if

hdf5 dependencies trying to install netcdf4

ValueError: did not find HDF5 headers

The error means there is no development files. You have the library but not headers. Install:

yum install hdf5-devel


Related Topics



Leave a reply



Submit