From Fedora Project Wiki

No edit summary
(Deprecate this page.)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{admon/warning|This is a draft document}}
{{OldGuidelinePage|Fortran}}
 
''This document is loosely based on the [[PackagingDrafts/FortranLibraries|Fortran library draft]] and the [[PackagingDrafts/FortranModulesDir|Fortran modules directory guideline]]. It is supposed to replace both of them, due to [https://bugzilla.redhat.com/show_bug.cgi?id=483765 the bug in the Fortran modules directory guidelines].''
 
== Modules and include files ==
== Modules and include files ==


Line 21: Line 18:
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>).
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>).


== Required changes ==
[[Category:Packaging guidelines]]
 
Packages that contain modules in the wrong place must be found and fixed (e.g. find all packages that BR: gcc-gfortran and contain '.mod' files).
 
The module files depend on the used compiler version and the architecture. The versioning should not matter, as mass rebuilds are done anyway whenever GCC is updated to a newer version. It is important, however, if there are multiple Fortran compilers present on the system.
 
 
* If it is decided to keep using an unversioned, multilib compatible <code>%{_fmoddir}</code>, the ''gcc-gfortran'' package must be changed to own <code>%{_fmoddir}</code> and all package containing modules must <code>Requires: gcc-gfortran</code>.
* If it is decided to use a GCC-versioned <code>%{_fmoddir}</code>, the preexisting <code>%{_fmoddir}</code> macro in <code>redhat-rpm-macros</code> must be changed from <code>%{_libdir}/gfortran/modules</code> to <code>/usr/lib/gcc/<target>/<version>/finclude</code> which is already used and owned by gfortran. After that a mass rebuild of all packages containing Fortran modules must be performed.

Latest revision as of 20:01, 21 December 2018

This is an old copy of a packaging guideline, preserved here in the wiki while we complete the transition to the Fedora documentation system. The current version is located at https://docs.fedoraproject.org/en-US/packaging-guidelines/Fortran/. Please update your bookmarks.

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.

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).