Difference between revisions of "Co-array Fortran on Niagara"

From SciNet Users Documentation
Jump to: navigation, search
Line 42: Line 42:
 
The way you compile and run for these two cases is different.
 
The way you compile and run for these two cases is different.
  
<!-- However, we're working on making coarray fortran compilation and running more uniform among these two cases, as well as with the, as-yet-experimental, gfortran coarray support.  See [[#Uniformized_Usage | Uniformized Usage]] below. --!>
+
<!-- However, we're working on making coarray fortran compilation and running more uniform among these two cases, as well as with the, as-yet-experimental, gfortran coarray support.  See [[#Uniformized_Usage | Uniformized Usage]] below.
 +
--!>
  
 
Note: For multiple node usage, it makes sense to have to load the IntelMPI module, since Intel's implementation of Co-array Fortran uses MPI. However, the Intel MPI module is needed even for single-node usage, just in order to link successfully.
 
Note: For multiple node usage, it makes sense to have to load the IntelMPI module, since Intel's implementation of Co-array Fortran uses MPI. However, the Intel MPI module is needed even for single-node usage, just in order to link successfully.

Revision as of 01:13, 3 February 2021

Versions 12 and higher of the Intel Fortran compiler, and version 5.1 and up of the GNU Fortran compiler, support almost all of Co-array Fortran, and are installed on Niagara.

This page will briefly sketch how to compile and run Co-array Fortran programs using these compilers.

Example

Here is an example of a co-array fortran program:

program Hello_World
  integer :: i ! Local variable
  integer :: num[*] ! scalar coarray
  if (this_image() == 1) then
    write(*,'(a)') 'Enter a number: '
    read(*,'(i80)') num
    ! Distribute information to other images
    do i = 2, num_images()
      num[i] = num
    end do
  end if
  sync all ! Barrier to make sure the data has arrived
  ! I/O from all nodes
  write(*,'(a,i0,a,i0)') 'Hello ',num,' from image ', this_image()
end program Hello_world

(Adapted from [1]).

Compiling, linking and running co-array fortran programs is different depending on whether you will run the program only on a single node (with 8 cores), or on several nodes, and depends on which compiler you are using, Intel, or GNU.

Intel compiler instructions for Coarray Fortran

Loading necessary modules

First, you need to load the module for version 12 or greater of the Intel compilers, as well as Intel MPI.

module load NiaEnv/2019b  intel/2019u4 intelmpi/2019u4

There are two modes in which the intel compiler supports coarray fortran:

1. Single node usage

2. Multiple node usage

The way you compile and run for these two cases is different.