The netCDF library : Différence entre versions

De LMDZPedia
Aller à : navigation, rechercher
Ligne 19 : Ligne 19 :
 
== Various ways to install the NetCDF library ==
 
== Various ways to install the NetCDF library ==
 
=== Install from the package repository of your Linux distribution ===
 
=== Install from the package repository of your Linux distribution ===
This is the easiest (and recommended) way. If your distribution is Ubuntu or Linux Mint (and you have admin, i.e. ''sudo'' rights), open a terminal and type:
+
This is the easiest (and recommended) way. For exemple, if your distribution is Ubuntu or Linux Mint (and you have admin, i.e. ''sudo'' rights), open a terminal and type:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sudo apt install netcdf-bin libnetcdff-dev
 
sudo apt install netcdf-bin libnetcdff-dev

Version du 3 janvier 2023 à 15:34

the NetCDF library

The model reads and writes input and output files in NetCDF (Network Common Data Form) format (developed and maintained by Unidata: https://www.unidata.ucar.edu/software/netcdf/ ) and therefore a NetCDF library must be at hand when compiling and running LMDZ6.

As this library is not quite standard, chances are that you might need to install it yourself on your system (note that the install_lmdz.sh default behavior is to download and install that library), hence this page with some indications on how to do so.

Checking if a NetCDF library is already available

It is possible that the library, including its Fortran component, is already available. An easy way to check this is to see if the related utilities like ncdump are available, i.e. that

which ncdump

returns a positive answer.

Note that this does not suffice as the full library, including its Fortran component, and not just the related utilities are required. A neat way to check this is to use the nf-config

nf-config --all

returns something meaningful. If not, you probably need to take some action along the lines of what is indicated in the following sections.

Various ways to install the NetCDF library

Install from the package repository of your Linux distribution

This is the easiest (and recommended) way. For exemple, if your distribution is Ubuntu or Linux Mint (and you have admin, i.e. sudo rights), open a terminal and type:

sudo apt install netcdf-bin libnetcdff-dev

Personal installation

One can always download the source code and compile the NetCDF library (see https://docs.unidata.ucar.edu/netcdf-c/current/faq.html#HowdoIgetthenetCDFsoftwarepackage ). You can use the following home-made "install_netcdf4_hdf5_seq.bash" script to do so. For this, ensure that you are in your home directory and:

mkdir netcdf
cd netcdf
wget -nv --no-check-certificate http://www.lmd.jussieu.fr/~lmdz/pub/import/install_netcdf4_hdf5_seq.bash
chmod u=rwx install_netcdf4_hdf5_seq.bash
./install_netcdf4_hdf5_seq.bash > netcdf.log 2>&1

Compiling the library and dependencies can take a while (>>15 minutes; be patient). Once this is done, check file netcdf.log to verify that all went well. You may want to also add its "bin" directory to your PATH environment variable by adding in your .bashrc a line of:

export PATH=$PATH:$HOME/netcdf/bin

The assumption here is that you have run the "install_netcdf4_hdf5_seq.bash" script in a "netcdf" subdirectory of your home directory. Adapt accordingly if not.

Check that the installation was successfully installed :-) Again, a neat way to do that is to run and check the output of

nf-config --all

Personal installation of an advanced NetCDF4-HDF5 library with MPI enabled

This specific version is useful especially if running with the XIOS library. A prerequisite is to have an MPI library installed and available. You can use the following home-made "install_netcdf4_hdf5_seq.bash" script to do so. For this, ensure that you are in your home directory and:

mkdir netcdf4hdf5
cd netcdf4hdf5
wget -nv --no-check-certificate http://www.lmd.jussieu.fr/~lmdz/pub/import/install_netcdf4_hdf5.bash
chmod u=rwx install_netcdf4_hdf5.bash
./install_netcdf4_hdf5.bash -CC mpicc -FC mpif90 -CXX mpiCC -MPI /path/to/your/MPI/install > netcdf.log 2>&1

You should of course adapt the command line, especially the -MPI /path/to/your/MPI/install part to your settings.

Compiling the library and dependencies can take a while (>>15 minutes; be patient). Once this is done, check file netcdf.log to verify that all went well. You may want to also add its "bin" directory to your PATH environment variable by adding in your .bashrc a line of:

export PATH=$PATH:$HOME/netcdf4hdf5/bin

The assumption here is that you have run the "install_netcdf4_hdf5.bash" script in a "netcdf4hdf5" subdirectory of your home directory. Adapt accordingly if not.

Check that the installation was successfully installed :-) Again, a neat way to do that is to run and check the output of

nf-config --all

03/01/2022