Compiling and Running your First Fortran Program
Using a text editor such as nano, vi or emacs, create a file called hello.F90.
If you don't already know how to use a text editor, we suggest you learn to use nano. To create the file named hello.F90, enter the following command on the login node on Peregrine:
$ nano hello.F90
This will start the nano program, which will allow you to type text into the file. Commands to tell nano what to do are located at the bottom of your screen. The ^ symbol means to hold the Control key while you type the letter, so ^O (pronounced "control-o") is entered by holding the control key and the o key at the same time.
Enter the following text, being careful to include the spaces and symbols as shown:
end program hello
Save this file by entering ^O. Exit nano by entering ^X.
To convert your program from a human-readable language like Fortran (which is used in the example above) to the language used inside the computer, a program called a "compiler" is used. Peregrine has several different compilers for each commonly used language. For this example, we will use the compilers that are developed by Intel. The command used to run the Intel Fortran compiler is "ifort". To run it on the file you just created, type
$ ifort -o hello hello.F90
The -o hello part of the command tells the compiler to store its output in a file called hello. This file contains the program that will execute on the computer.