Compile and install the Ariane program on a Linux system: Possible compiler problems
Hello
This video is a supplement to the previous one
on the compilation and installation of Ariane.
In this video we will cover
possible compiler problems.
The compiler makes it possible to transform
the source code, written in Fortran in Ariane,
into a binary executable file readable by the computer.
In 2019, there are two main compilers
for Linux or Unix computers.
The first, 'gfortran', was created
by the GNU free software
developer community.
This is the compiler we use for Ariane.
It is free and open source.
Under Linux there is a second compiler:
the INTEL compiler 'ifort',
which is both proprietary and commercial.
It can generally be found on laboratory computers
or in large computing centres.
Other Fortran compilers exist,
but I won't go into them here.
They are more suitable for particular platforms:
IBM, NEC, Fujitsu, etc.
I suggest you go to the support provided by these companies
for detailed documentation on these compilers.
The terminal I'm presenting here
is connected to a remote computer in my lab
on which I have several Fortran compilers
to illustrate the rest of this video.
Let's see the gfortran compiler first,
which is free.
The first question you might ask yourself is:
is this compiler installed on my computer?
Here are three ways to check if it is installed;
each one gives you additional information.
First, with the 'which' command:
'which gfortran'.
We see that the gfortran compiler
is present on my computer
in the '/usr/bin' directory.
Another way to check whether the gfortran is available
is to display its version number
by typing 'gfortran --version'.
On my computer I see I have version 7.4.0
Another method (but which requires more 'expert' knowledge) is to check
whether gfortran is installed on your Linux system,
in case the 'which' command
or the 'gfortran' command didn't work.
Is gfortran really installed on my computer?
This is a low-level command.
'apt list --installed | grep -i gfortran'
So there are several versions of gfortran installed on my computer,
with the libraries that go with them.
So gfortran is installed and available on my computer.
But, if gfortran is not installed on your computer,
what should you do?
You have to be the 'administrator' of your computer,
i.e. be able to install new software.
If you don't have these rights,
you will need to contact your system and network administrator
of your laboratory or computer centre.
The commands are low-level.
So, if you are not familiar with these methods,
I advise you to ask for help.
We'll type the 'sudo' command
to enter administrator mode.
Then type 'apt-get'.
and 'update' to update the system package.
You’ll be asked for a password.
The packages on your computer are checked.
Now the available packages have been updated,
we can ask to install gfortran.
I call back the previous command
and I replace 'update' with 'install gfortran'.
Now, as gfortran is already installed on my computer,
nothing will happen.
But in your case, gfortran will be installed.
In my case, the installer tells me it is already installed.
If gfortran had not been installed, it would have installed it.
This is the end of the first part, about the gfortran compiler.
We will now go to the compilation.
As we did in the previous video,
I return to the directory with the Ariane source code,
and I list all the available files.
We find our 'configure' command, which we saw in the last video.
I type 'configure' with the '--prefix' option
and the directory where I want to install Ariane.
Here, I'm on a computer in my lab.
The directory is slightly different
from the one I showed in the previous video.
I start the configuration.
Everything went well.
If we review all the configuration information
following the 'configure --prefix' command,
we see that the installer searched for
different types of Fortran compilers,
found the gfortran compiler on the computer,
and will use it for compilation.
So far we have only configured but not yet compiled.
The installer also found a NetCDF library.
Here, the NetCDF library is available
and functional for this compiler.
In another video we will see
that you can also have NetCDF library problems with gfortran
and we'll also see how to solve them.
The installer has created the key 'Makefile' files
that we need in order to compile.
We then have a whole set of information:
the software version, operating system,
compiler, NetCDF library, etc.
It offers us the 'make' command
to finish the compilation.
You can rewatch the previous video,
to see how to use this command.
We will now look at
the other compiler: Intel ifort.
We will check to see if there is
an ifort compiler on our computer.
As for gfortran, I use the 'which ifort' command
to check if it is available.
Here, the 'which' command gives us nothing.
This means that the ifort compiler
is not available on my computer.
I'm looking to see if there are any versions of this compiler
on my computer,
but it is not available.
So it needs to be installed.
The procedure is more complicated than for a free program.
You have to get a license
because it is proprietary and commercial software.
Some licences have to be paid for,
others, for academic uses, are non-commercial.
I suggest that you visit Intel's website
for the ifort compiler.
This tells you how to obtain a licence
and get access to the package
that allows you to install the ifort compiler
under Linux or Unix.
The 'ifort' command is not available
on some computers (laboratories, computer centres).
To manage different compilers on the same computer,
the system and network administrator
of your laboratory or computer centre
will use a handy command:
the 'module' command.
This allows you to manage
and dynamically activate software packages,
here compilers,
in a user's environment
without having to log out/log in.
We will see
the details of this command
and how I activate,
in my laboratory,
an Intel ifort compiler.
Like other commands in Linux,
the details of the 'module' command options
can be obtained by typing 'module help'.
We get a whole set of
options for the 'module' command.
We'll now go through
the main options for 'module' again.
'module avail'
lists all the packages
available on your computer.
I type 'module avail'.
+ 'Enter',
and I get all the packages
available on my computer.
Not all are relevant
to the subject of this video,
but there's some information
on 'intel 11.1' and 'intel 12.1',
which are Intel Fortran compilers.
How do we activate them?
We use the 'load' option
to load the package I want.
I type 'module load intel/12.1',
and the package is loaded.
How can I check if the package has loaded?
I type 'module list',
and I see that the package corresponding
to the Intel 12.1 compiler is available.
I now check with the 'which ifort' command,
if I have an ifort compiler available.
And we see that I do indeed have a directory
on my lab computer
where the ifort compiler is located.
I can also check its version
by typing '-- version'.
I made a typing error... version'.
This is the correct syntax.
We get the information about the version
here, it's the ifort 12.1 compiler.
As for the other 'module' commands
we have other options:
for example 'module list’,
to see the loaded packages;
'module unload'
to remove a package;
A more radical option is
'module purge’, which removes all the packages.
Now if I type 'module list'
I see that no longer any packages.
As I need a compiler for Ariane,
I'll reload
the Intel 12.1 compiler.
I'm in the Ariane directory
where the source code and the 'configure' command are located.
I'll run the 'configure' command again
with the '--prefix' option
to see what this gives us.
Here, it hasn't gone all the way: we have a problem.
Let's go back.
I ran the 'configure' command
and activated the Intel ifort compiler.
The program does some tests and finds the ifort compiler,
which becomes the default compiler
instead of the gfortran compiler.
It checks that the Fortran code
works with this compiler.
Then, as a second step,
the program searches for a NetCDF library
compatible with the ifort compiler.
In this example, the NetCDF library it found
is not compatible with the ifort compiler.
The NetCDF library on this computer
corresponds to the gfortran compiler and not ifort.
We will look at solving this problem
in the next video.
In this module we have seen:
- How to check if a Fortran compiler is available,
gfortran or ifort;
- How to install one if there isn't one available;
- The 'module' command to activate/deactivate
different compilers on the same computer
or different versions of the same compiler,
i.e. two different compilers;
In the next video we will look at
problems with the NetCDF library
such as the one we just saw
i.e. an incompatibility
between the ifort compiler
and the NetCDF library compiled with gfortran.
Thank you!