Modern Fortran

Fortran is one of the three most commonly used compiled programming languages for scientific computing. The other two are C and C++. Fortran has a long tradition of being the first programming language widely adopted by scientists for numerical programming. With this long tradition also comes a legacy in the structure of programming and style that have evolved over the years. Today is possible to see codes written in the now-old Fortran 77 style. Plenty of important codes were developed during the 70s and 80s. Even during the 90s when Fortran 90 became the new standard for the Fortran language, the lack of affordable implementation of the new specification made many scientists still rely on the old Fortran 77. By the early 2000’s all that has changed; most Fortran 77 codes were translated to Fortran 90 or Fortran 95 standard, compilers are still capable of compiling codes using the old style but its usage has been discouraged since. After Fortran 90 came Fortran 95 which fixed some problematic issues with Fortran 90 standard and established itself as the base for what we call today Modern Fortran. Today Fortran 2003 and 2008 are implemented by several vendors some of them offering compilers including open-source versions such as GCC. This is a tutorial on Modern Fortran, understanding it as code produced for Fortran 95, 2003, 2008, or even 2018, the latest major revision of the language.

Modern Scientific Programming is also a synonym for Parallel Programming. We have dedicated 3 days of this workshop to discuss several Parallel Programming paradigms and their usage on Fortran. The four models of scientific parallel programming are OpenMP, OpenACC, CUDA Fortran and MPI.

Prerequisites

Programming a computer is the process of translating ideas into code that can be objectively interpreted by a computer and perform the operations that lead to a result.

To follow this tutorial, it is always helpful to understand how most programming languages operated. Most programming languages use the concept of variables and operations executed on those variables. Operations on variables are called functions or methods. The flow of operations is organized in sections that in some languages are also called functions, structures, and classes.

The code follows a path, starting from an initial line of execution it continues line after line. Sometimes they follow a different path according to the result of an operation. On other occasions, the path repeats itself over and over a certain number of times or until another condition is met. All this we will learn here in the context of a particular programming language called Fortran.

For parallel programming multiple instructions happen concurrently, potentially using the also multiple CPU cores on a machine a numerical accelerator such as a GPU, or even multiple machines. Some of our examples, in particular, those for OpenACC and CUDA Fortran can only be executed if you have a machine with an NVIDIA GPU. For distributed parallel programming with MPI, you can still execute the codes using a single machine even if the scope of MPI programming is to use the computational power of multiple independent machines.

Schedule

Setup Download files required for the lesson
Day 1 14:00 1. Introduction to Modern Fortran What is Fortran?
Why learn Fortran?
Which version of Fortran should I learn?
15:00 2. Best Practices in Modern Fortran How to move out of Fortran 77 into Modern Fortran styles?
16:00 3. Exercises
17:00 4. Adjurn
17:00 Finish
Day 2 14:00 5. Parallel Programming in Fortran How to get faster executions using more cores, GPUs or machines.
15:00 6. OpenMP: Parallel Multiprocessing How to use the multiple cores on modern computers
16:00 7. Exercises
17:00 8. Adjurn
17:00 Finish
Day 3 14:00 9. OpenACC: Parallel Accelerators
15:00 10. CUDA Fortran How to program in CUDA Fortran?
16:00 11. Exercises
17:00 12. Adjurn
17:00 Finish
Day 4 14:00 13. MPI: Message Passing Interface How to parallelize a code for multiple machines.
15:00 14. Advanced Topics in MPI How to use collective operations on MPI
16:00 15. Exercises
17:00 16. Final
17:00 Finish

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.