This guide will be using the GCC Fortran 90 compiler to compile a small Fortran 90 program. We will be using a simple program that computes the area of a triangle.
Step 1 – Download and transfer the program to the Cluster
The program is available here. You can download it and transfer it to the cluster using WinSCP or any other file transfer program. A more direct method is to use a Linux command – wget. This downloads a file from a web site. To use this, enter the command:
wget https://enghpcdocs.swan.ac.uk/wp-content/uploads/2021/07/triangle_area.f90
Step 2 – Load the GCC 10.2.0 compilers module
Enter the following command:
module load gcc/10.2.0
Step 3 – Compile the program
Enter the following command:
gfortran -o triangle_area triangle_area.f90
Step 3 – Run the program
Normally programs that require significant memory or cpu time must not be run on the login node. However, this is allowed for short, small runs.
Enter the following command:
./triangle_area
This asks the user for the lengths of the 3 sides of the triangle. Once these have been entered, the area of the triangle will be displayed.