Zum Inhalt springen

Fortran: Fortran 2003: Submodules

Aus Wikibooks
<<< zur Fortran-Startseite
<< Fortran 2003 Bibliotheken >>
< OOP Coarrays >


  • Submodules sind für sehr große Programme gedacht und bieten Vorteile beim Compilieren solcher Programme.
  • Submodule gibt es ab Fortran 2008.

Beispiel

[Bearbeiten]

Es werde das Submodul-Beispiel in [1], Seite 6 verwendet (The new features of Fortran 2008 von John Reid, 2010, PDF-Datei). Ergänzend sei noch ein Hauptprogramm nachgetragen:

program bsp
  use points
  implicit none

  type(point) :: po1, po2

  po1 = point(10., 20.)
  po2 = point(30., 40.)
  print *, point_dist (po1, po2)
end program bsp

Wird das Ganze z.B. mit gfortran compiliert, so werden einige zusätzliche Dateien geschrieben:

points.mod
points@points_a.smod
points.smod

Mit ifx und flang sieht das etwas anders aus, ist aber ähnlich.



<<< zur Fortran-Startseite
<< Fortran 2003 Bibliotheken >>
< OOP Coarrays >