Packaging:Fortran

From FedoraProject

Revision as of 12:22, 26 July 2009 by Jussilehtola (Talk | contribs)

Jump to: navigation, search
Warning (medium size).png
This is a draft document

This document is loosely based on the old drafts Fortran libraries and Fortran modules directory.

Introduction

FORTRAN [1] (short for FORmula TRANslator) was the first programming language ever, invented in 1957 and standardized in 1966. The Fortran 77 standard introduced improved support for structured programming such as if clauses.

Fortran natively handles matrices and is rather easy to program and for these reasons it was widely adopted in the scientific community. Due to the large amount of legacy code, Fortran is still widely used in computational science. Some modernization has taken place, though.

Fortran 90 presented a modernization of the language to support among others dynamic memory allocation, free-form source input and an argument passing mechanism to support compile time interface checking. Fortran 95 introduced many useful features such as vectorization constructs for high performance computing.

The Fortran 2003 standard added e.g. access to command line arguments and environment variables. The current standard under development is Fortran 2008.

Fortran packaging

Fortran programs in Fedora MUST be compiled using the default Fortran compiler 'gfortran'. As usual, standard Fedora optimization flags %{optflags} MUST be used in the compilation.

The fortran modules files, ending in .mod are files describing a fortran 90 (and above) module API and ABI. These are not like C header files describing an API, they are compiler dependent and arch dependent, and not easily readable by a human being. They are nevertheless searched for in the includes directories by gfortran (in directories specified with -I).

Due to the ABI specificity, the module directory used must be architecture specific. In addition each gfortran release (e.g. from 4.4 to 4.5) may lead to an incompatible change in the .mod files, therefore mass rebuilds of Fortran packages must take place when gfortran is updated.

Fortran can also use include files, similar to C headers. The most common filename suffix is '.inc' or '.h', although '.fh' has been used for files that are designed to function as public headers.

Generally Fortran modules that are generated have very general names, thus placing them in the same directory is troublesome. For this reason Fortran include files and modules MUST be placed into %{_libdir}/gfortran/%{name}. The directory %{_libdir}/gfortran MUST be owned by gfortran.

The preexisting %{_fmoddir} macro should be either removed or replaced with a %{_flibdir} macro which evaluates to %{_libdir}/gfortran.

To use the modules and include files of foo, one needs to add -I%{_libdir}/gfortran/foo to the compiler flags.