

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for creating an executable file from a fortran text (.f90) file on standard linux/unix systems, such as those used in aerospace engineering. It covers the basics of compiling a fortran main program using the ifort compiler, legal filenames, and error messages. It also explains how to run the compiled program and compile a program with modules.
Typology: Study Guides, Projects, Research
1 / 3
This page cannot be seen from the preview
Don't miss anything!


D. Haugli, Lecturer Aer E 160 Aerospace Engineering
Compiling & Running Programs
This document describes how to create an executable file from a FORTRAN text (.f90) file on any standard Linux/Unix system (such as the Aerospace Engineering servers). An executable file contains binary commands that the computer interprets to run a program.
This document assumes the reader is logged onto a Linux or Unix server.
Main Programs. To compile a FORTRAN main program, issue the command:
command prompt$
The name of the compiler on the Aerospace Engineering servers is ifort. On Project Vincent (isua.iastate.edu), the compiler is named f90. The program must be saved as standard ASCII text in a file ending with .f90. Filenames must start with a letter, and may contain any combination of letters, numbers and the underscore character; no other characters are allowed.
Example 1. Assume the following files contain FORTRAN programs. The following names would be legal:
hello.f90 main.f90 program1.f90 Prob_1.f
(Note: Unix and Linux are case sensitive, so Prob_1.f90 differs from prob_1.f90.)
The following names would be illegal:
hello.txt.f90 1.f90 prob3-1.f90 _pro.f
Example 2. Assume the prompt looks like this: bash-3.0$. Compile the program hello.f90 at the command prompt using the ifort compiler.
bash-3.0$ ifort hello.f90
The second prompt in Example 2 would appear after the compiler successfully compiled hello.f90. If the file had contained errors, a list of error messages would have appeared instead. Generally, the first error in a list of errors causes some of the later errors; the later errors will be eliminated when the first error is fixed. An “error” (sometimes called a “fatal error”) is so severe that the compiler cannot create an executable file; A “warning” means that an executable file can be created, but the compiler found evidence that something might not be correct in the code.
D. Haugli, Lecturer Aer E 160 Aerospace Engineering
Example 3. Here is an example in which the command PROGRAM in first line of hello.f90 is misspelled. The code is:
PROGRM hello WRITE (,) “Hello World!” STOP END PROGRAM hello
Here is the command to compile the program, followed by the error messages from the compiler:
bash-3.0$ ifort hello.f fortcom: Error: hello.f90, line 1: Syntax error, found IDENTIFIER 'HELLO' when expecting one of: => =. ( : % PROGRM hello -------^ fortcom: Error: hello.f90, line 4: This name does not match the unit name. [HELLO] END PROGRAM hello ------------^ compilation aborted for hello.f90 (code 1)
In this case, the compiler could not exactly determine the error, but recognized that the error occurred in the first line of the program. When that line is corrected, the second error goes away, and the compile command is immediately followed by a second prompt:
bash-3.0$ ifort hello.f bash-3.0$
When the compiler successfully compiles a program, it creates a binary executable file named a.out in the same folder as the program. To run the program, type ./a.out (followed by
Example 4. To run the program hello.f90 (after correctly compiling it, as in Example 3), the command and output appear as:
bash-3.0$ ifort hello.f bash-3.0$ ./a.out Hello World! bash-3.0$