West Virginia University

Modern Fortran

WVU Research Computing logo

Guillermo Avendano-Franco

Aug 9-12, 2021

14:00 - 17:00

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 gufranco@mail.wvu.edu , djturpen@mail.wvu.edu or Nathaniel.Garver-Daniels@mail.wvu.edu for more information.

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



Schedule

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

Syllabus

Fortran

  • 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

OpenACC

  • Parallel Loops
  • Data Management
  • Tasks

Message Passing Interface

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

Setup

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 WVU's HPC Clusters

There are two ways of today accessing WVU's HPC Clusters: A secure remote shell (SSH) and via a Web Browser using the web application Open On-Demand. The most common way of accessing a High-Performance Computing (HPC) cluster is via a secure remote shell. A remote shell allows you to execute commands on another machine same as you do 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 being utilized by 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 adds 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 (2023) WVU has two clusters for HPC, Thorny Flat for general HPC applications, and Dolly Sods, a specialized HPC cluster for GPU intense processing. 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 which offers a full-featured SSH client plus the ability to open X11 windows from the remote machine.

    Using PuTTY

    PuTTY

    PuTTY

    PuTTY

    PuTTY

    PuTTY

    Using MobaXterm

    MobaXterm

    MobaXterm

    MobaXterm

    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 that you will encounter 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 completing Linux OS inside Windows will give you access not only to SSH client and terminal but also to 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 is located in your "Applications" under "Utilities".

An SSH client is also integrated by default with the OS.

Terminal MacOS

Follow the steps below to connect to the gateway ``ssh.wvu.edu`` and to the HPC cluster.

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

Follow the steps below to connect to the gateway ``ssh.wvu.edu`` and to the HPC cluster.

Connecting to Thorny Flat

Connecting to the HPC Cluster Thorny Flat is a two-step process. First, use your SSH client to connect to ssh.wvu.edu like this::

ssh <username>@ssh.wvu.edu

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

ssh tf.hpc.wvu.edu

Once you enter the system, you can start typing commands. You can open several connections simultaneously. Each connection is independent of the other and you have to authenticate on each new terminal.

**Testing LaTeX support in the (Lesson/Workshop) The Cauchy-Schwarz Inequality** $$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$

$$ (a-b)^2 $$