Warning message

Submissions for this form are closed.

The future of HPC programming - a Modern Fortran workshop

The future of HPC programming - a Modern Fortran workshop

Future of HPC programming: recent developments in Fortran

Fortran is the primordial HPC language. Its handling of multidimensional arrays have ensured that compilers can produce highly efficient code, and inclusion of coarrays in the 2008 standard made it the first major programming language with builtin support for parallelism. The 2008 inclusion of object-oriented modernised the language, bringing it on par with many of its contenders. In 2019 the Fortran standards committee started work on generics (templates). Templates are planned for the 202y release of Fortran, the one after the upcoming 2023 release.

Unlike C++ templates, Fortran templates are type-safe (strong concepts) and does not support meta-programming. This enables some very powerful programming techniques not matched by other high performance languages.

In this workshop we will give a hands-on preview of such techniques. This includes defining your own Fortran integrated domain specific programming languages (IDSLs) while benefitting from Fortran's efficient code generation. We also look at the dichotomy between well-structured code and efficient code, and show some systematic transformations between these. Lastly, we suggest just-in-time compilation and interpreters for user defined Fortran IDSLs, achieving much of the same flexibility as the current integration of Fortran and Python.

The workshop is in three parts.


The workshop is open to all SNIC users, prospective SNIC users and academics throughout the Nordic region.


The workshop will be hybrid. The on-site location is Umeå University (see below for rooms). It will also be streamed over Zoom. The url for the Zoom meeting will be distributed to participants shortly before the event.

For those participating on-site you should make sure you have a working eduroam setup. There is a possibility of setting up guest accounts if eduroam is not working for you.


Participants should have a basic understanding of programming. A basic knowledge of UNIX/LINUX is beneficial as well. 

For the hand-on part participants should have access to a laptop or desktop computer, which is connected to the internet.

Preliminary schedule


8:30 - 12:00 CET

Object-oriented programming in Fortran
In Fortran 2003, object-oriented features were added to the language, making Fortran almost as feature-rich as other more recent languages. Most modern Fortran compilers today support the object-oriented features added in the 2003 standard, enabling developers to implement truly object-oriented numerical applications in Fortran.
This lecture will introduce how to use object-oriented programming in Fortran with practical examples and use cases.

Mixed-language programming in Fortran

Today it is often important to be able to combine multiple languages adding functionality and features to existing applications. Fortran 2003 added a new module, iso_c_bining, specifically for C/C++ interoperability. This lecture will introduce how to compile and link C/C++ and Fortran applications using different calling conventions. Calling C/C++ from Fortran and calling Fortran from C++

The lecture will also cover how to integrate Fortran in the Python language using the f2py tool.

13:00 - 17:00 CET

Part 1: Type-safe generics as it is being embodied in Fortran.
The template idea is to parameterise code by types and procedures. This enables reusable collections classes (STL in C++ terminology). As an example, consider the industry sponsored GraphBlas library, which is a collection of graph algorithms parameterised by semirings. Type safety ensures that instantiation errors will immediately be detected and appropriate error messages provided.
Type-safe generics takes this several steps further. User defined template code is type checked on par with normal code, thus guaranteeing that instantiations never can induce unknown errors. Thus the dreaded megabytes of template instantiation error messages that C++ sometimes generate will never happen for type-safe generics.
We can also utilise this to define our own problem specific micro-languages within Fortran – we term these integrated domain specific languages (IDSLs). We can use these to ensure dimensional safety in our code. For instance, we can ensure that temperature never inadvertently is confused with time or distance, and that vectors are not confused with covectors in code. This eliminates a large class of potential errors, at no additional runtime cost.
At the workshop participants will develop their own IDSLs and experience the benefits this can give everyday code. There are techniques for experimenting with IDSLs in current Fortran, but we hope to have available a prototype compiler supporting type-safe generics.


8:30 - 12:00 CET

Part 2: Mathematics of arrays (MoA).
Any computation with large data sets is a computation on array data. Fortran is designed with multiarrays (multi-dimensional arrays) of intrinsic types as the basic data structure. This prevents nesting of arrays, and gives the compiler an upper hand in generating efficient code. We can treat this as Fortran's inherent IDSL.
Yet this IDSL faces two major challenges:
1) From a software engineering perspective such code is suboptimal. It obscures the abstract concepts forming the background for the code. The result is less readable code and more expensive program maintenance.
2) Optimally mapping source code to target machine hardware requires adapting the source code to the target machine: data decomposition, choice of loop traversals, maybe adding OpenMP and OpenACC annotations. As hardware is moving towards greater variety, continuously adapting source code is going to hit an «update barrier» where there is not enough time or resources to maintain the code for the variety of hardware it should target.
Here we will study various sets of rules to systematically change a well written code to a form which matches Fortran's inherent IDSL, in a form which will match a chosen target hardware architecture. Applying these rules to code can be fully automated, though such tools are a few years into the future.

13:00 - 14:30 CET

Part 3: JIT Interpreters for Fortran IDSLs.
This part taps into more futuristic possibilities. Observe that in principle it is possible to autogenerate interpreters for IDSLs. Any instantiation for an IDSL provides the semantics needed. Turning this into an interpreter is a «mere» tooling problem. Such an interpreter is tailored for the IDSL, i.e., all code developed for the IDSL. If we have rules for the IDSL, such as those for MoA, the interpreter can use them «just-in-time» (JIT) style to optimise the code while interpreting it.
There is a clear similarity between the above insight and the widespread use of, e.g., Python to glue together Fortran library code.
In the workshop we will open a discussion on tradeoffs between an «all» Fortran toolchain versus the current multi-language tool chains.


- Slides and source for the OOP Fortran lecture (on GitHub)
- Qt Creator extensions for Fortran (on GitHub)
- Q/A document (PDF)


Date and time: 24-25 November 2022, 8:30 - 17:00 CET (Thursday), 8:30 - 14:30 CET (Friday)
Location: Hybrid. Zoom and at Umeå University. MIT.C.313 (Thursday) and NAT.D.380 (Friday)

Instructors: Magne Haveraaen, Jonas Lindemann

Deadline for registration: 14 November 2022


Please register by filling in the below form. Fields marked with a * are mandatory. REGISTRATION CLOSED!

Updated: 2023-05-12, 14:29