Skip to content

Building and Running Hello World Fortran

This page describes how to build and run a Hello World Fortran90 program.

Source Code

The Fortran90 MPI Hello World source code is here:

DRP Cluster

The following commands build Fortran90 MPI Hello World, then submit the executable to the job scheduler for execution on the DRP cluster. All the commands listed are run on the DRP front-end nodes (drpfen01 or drpfen02).

The CCI file system is described here.

Load the MPI module

See Modules for instructions on loading MPI compiler wrappers.

For this example the MVAPICH2 version 2.0, using GCC 6.3, module is loaded:

module load gcc
module load mvapich2


mpif90 hello_mpi.f90 -o hello_mpi

Submit the Job

Create the file with the following contents:

#!/bin/bash -xe
srun --mpi=none ./hello_mpi

Give executable permissions:

chmod +x

Submit the job to the Slurm job scheduler requesting 4 processes :

sbatch -n 4 -t 5 ./

For more info on the job scheduler see Slurm.

Monitor the Job

The status of the job can be checked with the following command:

squeue -l

View Output

By default Slurm writes stderr and stdout to a file named slurm-.out in the directory the job was submitted.

slurm-.out should contain something similar to:

  Process        2 says "Hello, world!"

HELLO_MPI - Master process:
  FORTRAN90/MPI version

  An MPI test program.

  The number of processes is        4

  Process        0 says "Hello, world!"

HELLO_MPI - Master process:
  Normal end of execution: "Goodbye, world!".

  Elapsed wall clock time =   0.116825E-03 seconds.

  Process        1 says "Hello, world!"

  Process        3 says "Hello, world!"
+ rm /tmp/hosts.1070892