Packaging:Fortran

From FedoraProject

(Difference between revisions)
Jump to: navigation, search
(Introduction)
(Fortran Guidelines)
 
(20 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{admon/warning|This is a draft document}}
+
== Modules and include files ==
  
== Introduction ==
+
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 <code>-I</code>).
  
FORTRAN [http://en.wikipedia.org/wiki/Fortran] (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 <code>if</code> clauses.
+
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 natively handles matrices, is rather easy to program and was widely adopted in the scientific community. Due to the large amount of legacy code, Fortran is still widely used in computational science.
+
Fortran can also use include files, similar to C headers. Common used filename suffixes are '.inc' and '.h', although '.fh' has been used for files that are designed to function as public headers.
  
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.
+
== Packaging of Fortran programs ==
  
The Fortran 2003 standard added e.g. access to command line arguments and environment variables. The current standard under development is Fortran 2008.
+
Fortran programs in Fedora <b>MUST</b> be compiled, if possible, using the default Fortran compiler in Fedora, 'gfortran'. As usual, standard Fedora optimization flags <code>%{optflags}</code> <b>MUST</b> be used in the compilation.
  
== Fortran packaging ==
+
Fortran include files <b>MUST</b> be placed in the standard include directory: either directly in <code>%{_includedir}</code>, or if headers have general names or upstream recommends having an own directory, in e.g. <code>%{_includedir}/%{name}</code>.
  
Fortran programs in Fedora <b>MUST</b> be compiled using the default Fortran compiler 'gfortran'. As usual, standard Fedora optimization flags <code>%{optflags}</code> <b>MUST</b> be used in the compilation.
+
As Fortran modules are architecture and GCC version specific, they <b>MUST</b> be placed into <code>%{_fmoddir}</code> (or its package-specific subfolder in case the modules have generic names), which is owned by 'gcc-gfortran'. For directory ownership any packages containing Fortran modules <b>MUST</b> <code>Requires: gcc-gfortran%{_isa}</code>.
  
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 <code>-I</code>). 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.
+
To use the modules in the Fortran module directory, one needs to add <code>-I%{_fmoddir}</code> to the compiler flags (this is already included in <code>FFLAGS</code> used by <code>%configure</code>).
  
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.
+
[[Category:Packaging guidelines]]
 
+
Generally Fortran modules that are generated have very general names, thus placing them in the same directory is troublesome. Fortran include files and modules <b>MUST</b> be placed into <code>%{_libdir}/gfortran/%{name}</code>.
+
 
+
To use the modules and include files of foo, one needs to add <code>-I%{_libdir}/gfortran/foo</code> to the compiler flags.
+

Latest revision as of 20:18, 15 September 2009

[edit] Modules and include files

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. Common used filename suffixes are '.inc' and '.h', although '.fh' has been used for files that are designed to function as public headers.

[edit] Packaging of Fortran programs

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

Fortran include files MUST be placed in the standard include directory: either directly in %{_includedir}, or if headers have general names or upstream recommends having an own directory, in e.g. %{_includedir}/%{name}.

As Fortran modules are architecture and GCC version specific, they MUST be placed into %{_fmoddir} (or its package-specific subfolder in case the modules have generic names), which is owned by 'gcc-gfortran'. For directory ownership any packages containing Fortran modules MUST Requires: gcc-gfortran%{_isa}.

To use the modules in the Fortran module directory, one needs to add -I%{_fmoddir} to the compiler flags (this is already included in FFLAGS used by %configure).