Summary and Schedule
Description
Fortran (a contraction of Formula Translation) was the first programming language to have a standard (in 1954), but has changed significantly over the years. More recent standards (the latest being Fortran 2023) come under the umbrella term “Modern Fortran”. Fortran retains very great significance in many areas of scientific and numerical computing, particularly for applications such as quantum chemistry, plasmas, engineering and fluid dynamics, and in numerical weather prediction and climate models.
This intermediate course concentrates on some of the more recent features which are central to Modern Fortran. Attendees should be familiar with the basics of Fortran programming which might be covered in an introductory course, e.g., the one at,
https://epcced.github.io/2026-03-02-Fortran-intro/
So, attendees should be comfortable writing structured Fortran programs based on modules and procedures, and have a sound grounding in variables, logic, flow-of-control, and so on. Some knowledge of Fortran I/O is assumed.
There are two main topics in this intermediate course: the facilities in Fortran for abstraction and polymorphism provided by classes and interfaces, and the facilities for formal interoperability with ANSI C. The course will cover type extension (“classes” and “inheritance”), type-bound procedures (“methods”), generic procedures (“polymorphism”), and so on. The standard iso_c_binding module provides facilities for interoperability with C; this allow the communication of Fortran entities with direct analogues C, and also Fortran objects (particularly arrays) which have no direct analogue in C.
Further language features concerning arrays, pointers, and facilities for structured programming using submodules will also be covered along the way.
Knowledge of the object-oriented paradigm would be useful, but is not essential. Knowledge of C is required for the material on C/Fortran interoperation. The course will allow programmers interested in working on larger, structured, software projects to make use of (almost) a full complement of Modern Fortran features.
The course requires a Fortran compiler, for which a local machine or laptop may be appropriate [1]. If you do not have access to a Fortran compiler, course training accounts on ARCHER2 will be available which provide access to various compilers. Use of a text editor will be required (some may prefer an IDE, but we do not intend to consider or support IDEs).
[1] This may typically be gfortran, freely available as part of the GNU Compiler Collection (GCC). See e.g., https://gcc.gnu.org/wiki/GFortranBinaries
General Information
Requirements: Participants must have a working laptop or desktop computer with a Mac, Linux, or Windows operating system (not a tablet, Chromebook, etc.) that they have administrative privileges on. They should have access to a terminal (Mac and Linux users should have a terminal installed by default; Windows users should get either MobaXterm or PuTTY. They are also required to abide by the ARCHER2 Training Code of Conduct.
Prerequisites
You should have used remote HPC facilities before. In particular, you
should be happy with connecting using SSH, know what a batch scheduling
system is and be familiar with using the Linux command line. You should
also be happy editing plain text files in a remote terminal (or,
alternatively, editing them on your local system and copying them to the
remote HPC system using scp).
| Setup Instructions | Download files required for the lesson | |
| Duration: 00h 00m | 1. Connecting to ARCHER2 and transferring data |
What can I expect from this course? How will the course work and how will I get help? How can I give feedback to improve the course? How can I access ARCHER2 interactively? |
| Duration: 00h 40m | 2. Arrays |
How are arrays declared? How can array sizes be determined at runtime? |
| Duration: 01h 00m | 3. Break | |
| Duration: 01h 40m | 4. Arrays as arguments |
How are arrays passed as arguments? How are array slices passed as arguments? How do allocatable array arguments interact with argument intent attributes? |
| Duration: 02h 05m | 5. More on pointers |
How are pointers associated with data? How can pointers be used to access arrays? How can pointers be associated with procedures? |
| Duration: 02h 35m | 6. Lunch | |
| Duration: 03h 45m | 7. Derived types |
How are data structures (derived types) defined in Fortran? How can we control access to components of data structures in Fortran? How does assignment between derived types work? |
| Duration: 04h 15m | 8. Interfaces and overloading | How are interfaces used for generic programming? |
| Duration: 05h 00m | 9. Break | |
| Duration: 05h 25m | 10. Type extension and polymorphism |
How can we reuse type definitions in related types? How can we write generic procedures for related types? How can we apply type-specific behaviour for related types? |
| Duration: 06h 00m | 11. Type-bound procedures |
How can we associate behaviour with types? How can we specialise behaviour for extended types? |
| Duration: 06h 30m | 12. Generic input/output for derived types | How can we customise the writing/reading of defined types? |
| Duration: 07h 00m | 13. Abstract types | How can we write programs that abstract over implementations? |
| Duration: 08h 00m | 14. Break | |
| Duration: 08h 40m | 15. Modules again |
How to organise large Fortran programs? How to minimise recompilation in large Fortran programs? |
| Duration: 09h 10m | 16. Unlimited polymorphic entities | How does Fortran support unknown data (at compile time) types? |
| Duration: 09h 40m | 17. Lunch | |
| Duration: 10h 50m | 18. Type parameters |
How to implement user-defined types with kinds, like
intrinsic types?
|
| Duration: 11h 20m | 19. Intrinsic modules |
What intrinsic modules does Fortran provide? How can intrinsic modules aid writing portable code? |
| Duration: 11h 40m | 20. Break | |
| Duration: 12h 20m | 21. Interoperability with C |
How can we write Fortran programs that interact with C in a portable
way? How can we make use of Fortran procedures from C code? |
| Duration: 13h 05m | Finish |
The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.
Please try to complete the following setup tasks ahead of the lesson.
Create appropriate SAFE accounts
Course attendees should have received instructions on how to set up an Archer SAFE account. Details are available in the [ARCHER2 documentation][archer2-quickstart].
This will allow you to obtain a machine account which will be used for the course. (If you already have a machine account, it is possible to use that, although you may not have access to the course queue reservation.)
Any problems encountered will be addressed as the first part of the course.