Compile and configure the Ariane program: possible NetCDF library problems
Hello and welcome to this new video
dealing with NetCDF library problems
when configuring and compiling the Ariane program.
This video is part of a set
about the compilation and installation of Ariane.
We are assuming that a compiler,
either gfortran or ifort
is already installed on your computer.
If you don't know how to install these tools,
please watch the previous videos.
Many of you have sent me emails
about Ariane installation problems
concerning the NetCDF library.
This is why this video is important.
Before we start I'll remind you of a few
specific and important points about the NetCDF library.
This must be installed on your computer,
but also accessible from your account.
The other very important point
and one I insist on
is that it must be compiled with the same Fortran compiler
that you use to compile Ariane.
This compiler will be either gfortran or ifort.
You'll also have to make sure that it is
the same version of that compiler.
You need to take into account the version number
for the NetCDF library.
There are also different versions
of the NetCDF library available.
In this module I will focus on
the most recent version:
the NetCDF4 library
based on the HDF5 format,
which has the particularity of being made up
of two libraries.
The core of the library
is written in C,
and performs all the necessary calculations.
And there an interface for Fortran,
which is needed
because Ariane is written in Fortran.
You will need to have the NetCDF library
available on your computer
in the form of these two modules:
- the NetCDF core written in C,
- the Fortran interface.
I'll come back to these points during the demonstration.
Let's see what this means
on your computer.
Going from the simplest to the most complicated:
on the left side of the diagram,
here’s gfortran and NetCDF.
This is the easiest way to install Ariane on your computer:
using gfortran and the NetCDF library.
Another way is to
use the ifort compiler,
as we saw in an earlier video,
with a NetCDF library
compiled with ifort.
In a laboratory or computer centre,
the 'module' command is usually used,
which gives access
to the NetCDF compiler and library.
It is sometimes necessary to install
the NetCDF library.
I won't go into detail here
because it's quite complicated.
There is a third method for advanced users:
here, you install both the compiler
and the NetCDF library yourself.
It's quite complicated
and requires some experience
or to know someone with the necessary skills.
Let's go back to the first case:
on a Linux system,
the installation of the Ariane program
with a gfortran compiler
and a NetCDF library.
I open a terminal
and go into the directory
where the source code
of my Ariane package is located.
As we saw in the previous videos.
I list the contents of the directory,
which contains files and commands
that you should now know about.
We'll run the 'configure' command
to configure the compilation of Ariane.
I run 'configure' and specify
the directory where I want to install Ariane.
Here it will be in the 'home' directory.
I start the configuration.
What's going to happen?
Here we find the 'configure' command.
The program searches for a compiler
and finds the gfortran compiler.
Then, its second step is to look for
the NetCDF library.
In this case it doesn't find the NetCDF library.
It either isn't available on my computer
or else it is not accessible.
If you are using a Linux operating system,
it is relatively easy to install
the NetCDF library
if you use the gfortran compiler.
We'll do it together.
You must be the 'administrator' of your computer.
That is, you are allowed to
install software on your computer.
I am switching to 'administrator' mode
on this computer.
I am now allowed to install software.
The basic command under Linux is 'apt'.
We'll look for the NetCDF library.
'apt search libnetcdf'
The program shows us several packages.
Coming back to the 'apt search libnetcdf' command
and I see that it displays
all the available NetCDF libraries in green.
We have several interfaces,
including one in C++,
but which do not concern Ariane.
We can therefore ignore these files.
Instead, we'll look at the libraries
that appear at the end of the list.
We see 'libnetcdf'.
Here it's the version 13,
although the version will be updated as time goes by.
'libnetcdf' is the core of the NetCDF library,
it's written in C++, and it's what we need.
We will also need the development part
because the compilation process
requires some modules.
So we'll install 'libnetcdf-dev'
and 'libnetcdf13'.
And as I said earlier,
we also need the Fortran part.
You can easily spot it because of the extra 'f' at the end of 'libnetcdff'.
Here we have, for example, 'libnetcdff6'
which is the core of the library in Fortran
that we have to install.
Just like with the NetCDF library in C,
we'll need the 'dev' part.
What are we going to install now?
I'm switching to 'administrator' mode
'apt install'
I'm going to install the core library (libnetcdf13),
the development part (libnetcdf-dev),
the Fortran part (libnetcdff6),
and the Fortran development part (libnetcdff-dev)
So I install four libraries
to then be able to configure Ariane correctly.
I run the command.
The system asks me for an administrator password
in order to install these packages.
If I run the previous command again:
'apt search libnetcdf',
it will once again list me all
the available libraries,
but it will also display
the word 'installed' by the name of each library I installed.
I come out of 'super user' mode
to return to the previous case.
Here, I had run the 'configure' command,
the program looked for the NetCDF library,
but either didn't find it or it wasn't compatible
with the gfortran compiler.
Now, I run the 'configure' command
after installing the NetCDF library.
As you can see, everything went well:
it found the NetCDF library
and I let the configuration finish,
which will allow me to run
the compilation, which you should already know.
Here is a NetCDF command
that allows you to know which compiler
compiled this library.
This is 'nf -config --fc'.
The result is the name of the compiler
that compiled the NetCDF library.
Here, this is gfortran, which is fully compatible
since the configuration went well.
Now, we'll move on to the second part of this module,
framed here in orange:
compilation of the Ariane program
with the Intel Fortran compiler (ifort).
In a previous video we saw
how to install or have access to an ifort compiler
on your computer.
Now, we'll look at the compilation
with the ifort compiler
and the NetCDF library.
There are two ways to direct the NetCDF library
to the Intel ifort compiler.
Either with the 'module' command, as we saw in an earlier video:
in this case,
we install the NetCDF package
to make it available.
Or by installing the NetCDF library directly
on the computer where you want to install Ariane.
This second step is very complicated
because it requires the installation of the part of the NetCDF library
in C, the Fortran interface,
but also, since version 4, NetCDF has been based
on the HDF5 library,
so this too has to be installed.
This is complicated.
So it's better to know the field
or get help from someone
with the necessary skills.
We will work on a computer
in my lab, a remote computer.
I am now in the directory
which contains the Ariane source code.
I suppose that I have an ifort compiler available,
whose version I will display.
This is the ifort 12 compiler,
from the year 2012.
I start the configuration of the program
without specifying the directory where
the executable files will be installed.
The 'configure' command is executed.
It searches and finds the ifort compiler.
As a second step,
the command looks for the NetCDF library,
which will allow it to compile Ariane.
Here the program finds a NetCDF library
installed by default on my computer
but this NetCDF library is not compatible
with the ifort compiler.
So we will check
which compiler
this library was compiled with
using the command 'nf -config --fc'.
We see that a NetCDF library
is available on my lab computer,
but that this library was compiled
with the gfortran compiler.
So, there is an incompatibility
between the NetCDF library
and my ifort compiler.
We have two possible solutions.
The 'module' command can be used,
to list the different packages available.
In my lab,
I have several NetCDF libraries available.
So I will select
a library that is
available and compatible
with my compiler,
which is version 12.1.
The command is 'module load'.
+ compatible NetCDF library.
If I type 'module list'
the program displays
my Intel compiler
and the compatible library.
Now I run the 'configure' command again
and we see that
all the steps run normally.
I can now compile
the Ariane program.
Here, we see the ifort compiler
and the different paths
to the NetCDF library.
That was the first solution.
The second solution
is to directly install
the NetCDF library on your computer,
but that's quite complicated.
You have to know the subject well,
and it takes a lot of time.
You need the ifort compiler.
You need to download the source code
of the NetCDF library:
the C part and the Fortran part.
In addition, since version 4,
the NetCDF library is based on
another library: HDF5.
I won't go into the details here.
I recommend that you contact an expert
or follow another tutorial
to install a NetCDF library
on your computer
that is compatible with the compiler
with which you want to compile Ariane.
Let's go back to our diagram.
We have one last part,
which concerns very few
(10%) cases in general,
shown in red here.
This method is much more complicated
than the others
because here it is assumed
that the 'module' command is not available
on the computer that you are using
(laboratory, computer centre or personal computer).
We are also assuming:
- that a Fortran compiler is available,
- that a NetCDF library is available,
- and that the two are compatible.
However, we can't
use the 'module' command to find this out.
So we need to deal with
environment variables.
The 'configure' command
tells us the environmental variables
that we will need to enter
by adding the '--help' option to 'configure'.
This displays all the options
that can be used with the 'configure' command.
The options that interest us
are environment variables:
'FC' to address the Fortran compiler
and the paths that will allow us to
access the 'include' file
of the NetCDF library
and the NetCDF library.
So it's quite complex.
You need to already have a good level of computer skills.
You can get the information for the
NetCDF_LIB and NetCDF_INC variables
using the command 'nf-config --flibs'.
I won't go into more detail
because it's not really the topic of this video.
In conclusion, I'll come back to this slide:
a simple method when you working under Linux
is to use gfortran and to install the NetCDF library.
Another method, which is a little more complicated,
found in laboratories
and computer centres,
is to use the Intel ifort compiler
and the corresponding NetCDF library
using the 'module' command.
In some cases you will have to
install the NetCDF library,
but in that case you should get help
from someone with a good level of experience.
In the last case, which is extreme
and quite rare,
you will need to enter the environment variables
so that the 'configure' command
can find the correct Fortran compiler
and the NetCDF libraries
compatible with this compiler.
Thank you!