logo LMD

Page de Lionel GUEZ

Enseignement à l'école normale supérieure, en L3 de géosciences, 2014/2015

Travaux dirigés de compilation (mise à jour du 27 janvier 2015).

Cours sur la compilation et l'utilitaire make (mise à jour du 22 janvier 2015).

Cours : algorithmique et programmation (mise à jour du 2 février 2015).

Mots-clefs du langage Fortran 95 (mise à jour du 31 octobre 2014).

Premier semestre :

Second semestre :




NR_util is a Fortran 95 library. It originates from the "utility routines" of Numerical Recipes in Fortran 90 (Press et al., 1996, Cambridge University Press, appendix C1), contained in files nrtype.f90 and nrutil.f90. These files of Numerical Recipes were put in the public domain. The content of NR_util is almost the same than the content of the "utility routines" of Numerical Recipes; the form is quite different.

Some procedures have an added pure attribute in NR_Util.

The treatment of kind attribute is different in NR_util than in the original "utility routines" of Numerical Recipes. The procedures in NR_util do not essentially require a large precision. For integer data objects, we have removed the i4b kind parameterization. This parameterization did not make any sense for the routines of NR_util. All the integer data objects of NR_util are of default integer kind. For a given procedure and a given argument, of real type, we want to allow a user to call this procedure with an actual argument of all possible real kinds.

Download the archive.

Templates of makefiles for Fortran programs and libraries

From the simplest case to more complex cases, makefiles for a Fortran program made up with:

Makefiles for a Fortran library made up with:

The above makefiles contain the description of your program or library: the names of inputs files, the directories where they are, the dependencies between them. But, by design, the part of the makefile which depends on the compiler is well isolated. The part that depends on the compiler is the definition of variables FC, FFLAGS, CPPFLAGS, LDFLAGS and LDLIBS. If you are going to compile your program with a single compiler then you can just add the definition of those variables inside the makefile. But if you use several compilers then write the definition of FC, FFLAGS, CPPFLAGS, LDFLAGS and LDLIBS in a separate file, one file for each compiler.

If you just want the products of compilation (executable file, library, object files, compiled module interfaces) to be created in the directory containing the makefile, you just go to that directory and invoke make from there. However, often, one wants the products of the compilation to go somewhere else, in a directory not related to the source files (maybe another file system, or a directory the position of which relative to your source files will change when you port your code to another machine). In that case, instead of invoking make, use the script make.sh. Choose the value of MAKE and dest_dir in make.sh and just invoke make.sh instead of make. You can add any argument to make.sh that you would want to use with make. For example, you could type:

make.sh clean all
make.sh FC=pgf95

Fortran : insertion des procédures dans des modules

Autour de LMDZ


Climatologie de l'ozone (18 KiB), de Fortuin et Kelder (1998), convertie au format NetCDF. Cf. page correspondante du Tropospheric Emission Monitoring Internet Service.