Modern Fortran

West Virginia University

Aug 9-12, 2021

14:00 - 17:00

Instructors: Guillermo Avendano-Franco

Helpers: Daniel Turpen, Nathaniel Garver-Daniels

General Information

Modern Fortran workshop aims to present the Fortran Programming Language from a modern perspective. Fortran is one of the oldest programming languages in active use today. Fortran is the language of choice of some of the largest HPC software packages in many areas of High-Performance Computing, such as weather modeling, materials science, molecular dynamics, and the software On its long history of more than 60 years, new features have been introduced and some others became discouraged and later deprecated. This lessons were created presenting the current best ways of programming using features introduced with Fortran 90, 95 2003 and 2008. Today High-Performance Computing is equivalent to Parallel Computing. We devote several hours to present parallel computing paradigms such as OpenMP, OpenACC and MPI. Fortran is one of the main programming languages for High-Performance Computing and working knowledge is fundamental to understand and contribute some of the most important scientific codes that run on the fastest supercomputers today.

For more information on Fortran and its history, wikipedia is a good start: "Wikipedia page about Fortran".

Who: The course is aimed at graduate students and other researchers.

You don't need to have any previous knowledge about Fortran. At least some familiarity with at least one programming language is very welcome. Understanding basic concepts in programming such as variables, loops, conditionals, functions will set a good foundation to learn how those concepts work in Fortran.

Some familiarity with UNIX as a user is handy. That means that you should know how to connect to the cluster using SSH, use the basic commands in UNIX/Linux and edit files with your favorite text editor. In those moments where submitting jobs to a cluster is needed, the proper commands are presented and explained.

You don't need to know about parallel programming for this course. The lesson will introduce the basic concepts of parallel programming for the various paradigms and standards present in the workshop.

Where: One Waterfront Place. Get directions with OpenStreetMap or Google Maps.

When: Aug 9-12, 2021. Add to your Google Calendar.

Requirements: Participants must bring a laptop with a Mac, Linux, or Windows operating system. Any electronic device where you can install and SSH client will work. See below instructions about how to install an SSH client on your computer. All the examples and exercises will take place on our HPC clusters.

Accessibility: We are committed to making this workshop accessible to everybody. The workshop organizers have checked that:

Materials will be provided in advance of the workshop and large-print handouts are available if needed by notifying the organizers in advance. If we can help making learning easier for you (e.g. sign-language interpreters, lactation facilities) please get in touch (using contact details below) and we will attempt to provide them.

Contact: Please email , or for more information.

Roles: To learn more about the roles at the workshop (who will be doing what), refer to our Workshop FAQ.


Day 3

14:00 OpenACC: Parallel Accelerators
15:00 OpenACC and Fortran CUDA
16:00 Exercises
17:00 Adjurn

Day 4

14:00 MPI: Message Passing Interface
15:00 Advanced Topics in MPI
16:00 Exercises
17:00 End



  • Variables
  • Expressions
  • Conditionals and Loops
  • Arrays (Static and Dynamic)
  • Formatted Input/Output
  • Modules
  • Precision of variables
  • Modern style guidelines
  • Fortran 2003 and 2008 standards

Parallel Programming

  • Shared Memory Parallelism
  • Distributed Computng
  • Directive-based Programming
  • OpenMP


  • Parallel Loops
  • Data Management
  • Tasks

Message Passing Interface

  • Point to Point Communications: Send and Recv
  • Collective messages: Broadcast and Reduce
  • Barriers and Synchronization


To participate in a Research Computing workshop, you will need access to the software described below. In addition, you will need an up-to-date web browser.

We maintain a list of common issues that occur during installation as a reference for instructors that may be useful on the Configuration Problems and Solutions wiki page.

Accessing the clusters using Secure shell (SSH)

The most common way of accessing a High-Performance Computing (HPC) cluster is via a remote shell. A remote shell allows you to execute commands on another machine as you do by sitting in front of it. A remote shell is convenient because it also allows other people to do the same, so you get access to a resource that serves several users at the same time.

All that you need on your computer is a terminal emulator and an SSH client. A terminal emulator is a program that mimics the behavior of old dumb terminals from a few decades ago. An SSH client is a program on your computer that allows you to connect to the SSH server from another computer. In the old times (the 80s), people used to create a remote shell using Telnet. SSH provides a secure channel over an unsecured network such as the internet. SSH offers similar capabilities to Telnet but adding encryption, so all data sent and received between your computer and the remote host is encrypted in such a way that only your computer and the remote computer can see the data. If you want to know more about Secure Shell see it at Wikipedia. Currently (2021) WVU has two clusters for HPC, Spruce Knob and Thorny Flat. You can access them using SSH.

Regardless of which Operating System you use, there is always a way of having the terminal emulator and SSH client that you need to connect to an HPC cluster. Both Linux and macOS include an SSH client by default. In this case, all that you have to do is open a terminal. On macOS the terminal is located in the Utilities folder inside your Applications folder. On Linux, the terminal is so central that most Linux distributions create an icon directly from the desktop.

    On Windows machines, you need to install an external application. One option in Windows is a free application called PuTTY. PuTTY offers a simple SSH client that is enough for this lesson. Another option is MobaXTerm that offers a full-featured SSH client plus the ability to open X11 windows from the remote machine.



    More recently there are also options to get access to a terminal and SSH clients using Microsoft products. One option is to install Visual Studio Code. Instructions to add an SSH client to VSC can be found here and here. Visual Studio Code will give you not only access to remote access to a file manager.

    Another alternative is using the Windows Subsystem for Linux (WSL). WSL will allow you to run a full Linux OS inside Windows with all the commands are present on a typical Linux machine. With the latest version of WSL 2 and the development version of Windows 10, you can even run GUI applications from inside Windows alongside other Windows applications. You can see the files from your windows machine. Running and complete Linux OS inside Windows will give you access not only to SSH client and terminal but also the commands that you will learn during this lesson as you will do from a Native Linux machine. Instructions about installing and configuring WSL can be found here

On macOS, the terminal icon is under "Applications / Utilities".

An SSH client comes integrated by default with the OS.

Terminal MacOS

On any Linux distribution a Terminal is a central part of the Operating System even for desktop usage. An SSH is also part of a default installation. There is usually no need to install anything.

Terminal Linux

Connecting to Spruce Knob

Most likely, you will connect to Thorny Flat, our newest cluster. However, it is also good to know how to connect to Spruce, our older cluster. Accounts on those clusters are independent of each other, so you can have access to one without necessarily having an account on the other.

To access Spruce from your computer, execute this command from your terminal (Linux, macOS):

ssh <username>

If you are using a GUI client such as PuTTY enter as the name of the server and your username in the corresponding field before connecting to the remote machine.

After entering your credentials with DUO, you get a prompt on Spruce

Connecting to Thorny Flat

On Thorny Flat, you cannot connect to the front end directly. First, use your SSH client to connect to like this::

ssh <username>

Enter your DUO authentication and execute this command on the Gateway node.

ssh <username>

Once you enter the system, you can start typing commands. You can open several connections simultaneously. Each connection is independent of the other. Opening new terminals will have to authenticate separately.