|
Compiling and running Fortran programs
Before your program can be executed, it must be compiled.
Compiling the program works by converting the English-like text
of a Fortran program into a binary form that the processor
understands.
You compile a program by typing a line similar to the
following:
f77 -o myprogram myprogram.f
It is important that you understand what is happening here:
- f77 is the name of the
Fortran compiler. Computers that
run the Unix operating system often use the name
for the
Fortran compiler, though your compiler may have a different name
such as
g77
or
pgf77.
- The -o option tells the
compiler that the next word (here, myprogram) will be the name of
the binary version of the program. If
you omit this option, most systems will automatically
name the binary version
a.out
regardless of the name of your program. It's perfectly
legal to use this default, though it's usually helpful
to use a more meaningful name.
The binary file is often called the executable
file because the computer can run (execute) it.
- myprogram.f is the
name of the file that contains the source code
of your program. The source code is the file of
instructions that you actually edit and type. Your source
file could be named something other than
myprogram.f,
such as
homework1.f.
or some other descriptive name. On many systems the name
of the source file must end with the
suffix .f
or the compiler is apt to become unhappy.
To run the program, simply type the name of the executable
file:
myprogram
|
|