Fortran source code is written with any plain-text editor. The standard extension for Fortran source files is .f90, i.e., the source files are named <name>.f90. The extension .f90 implies that the source code is written in free (or unrestricted) format.

In free format, the source code may start in any column. An exclamation mark, unless it is in a literal string (a string in single quotes), comments the rest of the line. Throughout this roadmap, we embed comments in our code samples for pedagogical purposes, either to explain the purpose or meaning of a given element of code, or to indicate the consequences or output from that code.

An ampersand (&) as the last non-blank (not commented) character in a line indicates that the statement continues on the next (non-commented) line.

The source code can be in one file, or the program units (main program, subroutines, functions, modules) can be in separate files. The final executable—the program which can be run—is generated by a compiler. As long as no modules are used (discussed later) the order of compilation is arbitrary. Compilation is often handled by a Makefile.

On Stampede2 and Frontera, code is compiled and linked with ifort, the Intel Fortran compiler. Here are simple examples of how to use it.

Compilation:
ifort -c sub1.f90
ifort -c sub2.f90
ifort -c fct1.f90
ifort -c fct2.f90
ifort -c main.f90
Linking:
ifort sub1.o sub2.o fct1.o fct2.o main.o
Naming the executable:

After linking the executable is named a.out. This may be changed by adding -o <name> to the link command.

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Inclusivity Statement