Programming with Fortran
Content
This three day online course is targeted at scientists that have little or no knowledge of the Fortran programming language, but need it for participation in projects using a Fortran code base, for development of their own codes, and for getting acquainted with additional tools like debugger and syntax checker as well as handling of compilers and libraries. The language is for the most part treated at the level of the Fortran 95 standard; features from later Fortran standards are limited to improvements on the elementary or intermediate level. Advanced Fortran features like object-oriented programming or coarrays will be covered in a follow-on course in autumn.
To consolidate the lecture material, each day's approximately 4.5 hours of lecture are complemented by 3 hours of hands-on sessions.
Lecturers
Gilbert Brietzke, Ivan Pribec (LRZ)
Lecture notes
from the virtual workshop "Programming with Fortran", from March 11 - 13, 2025, that provides an introduction to the language. Please contact one of the tutors (Brietzke_at_lrz_dot_de, Pribec_at_lrz_dot_de) if questions about any of the materials provided below arise.
- The course schedule
- Slides and the Table of Contents for all three course days
Environment to use for the Exercises
For the hands-on sessions we will use the GCS Developer Cloud Service, which provides access to a pre-configured Jupyterhub instance.
To access the service visit the portal at http://portal.gauss-centre.eu/
When logging in for the first time, you will need to register and accept the displayed Terms of Use. There is no need to create a separate username and password. Instead, select "Sign in with Helmholtz AAI", then choose your affiliated institute from the list. You will be redirected to your institute’s Shibboleth login page, where you can enter your credentials. For detailed instructions, refer to the documentation here and follow "Option B: Helmholtz AAI": https://jupyterjsc.pages.jsc.fz-juelich.de/docs/jupyterjsc/authentication/. Further instructions will be provided during the course.
Alternatively, you can use your own computer or institute cluster for the hands-on sessions. In this case, make sure your system satisfies the following requirements:
- We recommend using either a Linux distribution as operating system or the Windows Subsystem for Linux (WSL) on Microsoft Windows.
- A recent version of the gfortran compiler should be installed. Alternatively, the Intel compiler (ifx, most recent version available for free) can be used.
- Linux installation should include the BLAS library or (alternatively) the Intel MKL library (which contains a tuned BLAS implementation; the MKLROOT environment variable should be appropriately set to the base directory of the MKL installation).
- You can use your favourite editor to create new Fortran source files. We recommend either vim, emacs, or geany.
Exercises
The exercises document describes the problems to be solved.
Source-based Track
The following ZIP package contains both some code examples and the skeleton codes that provide starting points for many of the exercises:
The ZIP package for the solutions to the exercises are separated into one per course day:
Please unpack all the above ZIP files within the same folder, using the unzip command. Note that the Makefiles in the examples may need minor modifications to fit the specifics of your environment.
Jupyter Notebook Track
Optionally, you can follow the exercises in the form of Jupyter Notebooks. This track is designed for participants familiar with Jupyter Notebooks and the use of cell magics.
- notebooks_day1.zip (examples + skeleton of day1)
- nb_solutions_day1.zip (solutions of day 1)
- notebooks_day2.zip (examples + skeleton of day2)
- nb_solutions_day2.zip (solutions of day 2)
- notebooks_day3.zip (examples + skeleton of day3)
Please note this track is in an experimental state.
Further information about the language
For quick reference on selected language elements you may also consult the documentation provided by the compiler vendors, e.g. here for GNU and Intel, but be aware also of non-portable vendor extensions:
https://gcc.gnu.org/onlinedocs/gfortran/
https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference
A draft of the Fortran 2023 standard is available in PDF format at
https://j3-fortran.org/doc/year/24/24-007.pdf
It is recommended to use this document for reference, e.g., looking up standard intrinsic procedure (these are in section 16.9) as well as syntax definitions. As far as the general language rules are concerned, the document is rather hard to read and therefore unsuitable as a guide for learning the language semantics.
Copyright and Licensing
The copyright for this work is owned by Leibniz Supercomputing Centre.
This work is licensed under the Creative Commons Attribution Non-Commercial 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/ When attributing this work, please use the following text block:
- Programming with Fortran, Leibniz Supercomputing Centre, 2009-25. Available under a Creative Commons Attribution Non-Commercial 3.0 Unported License.