Compiling and running Fortran programs

Before your program can be executed, it must be compiled. This converts 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:

	gfortran -o myprogram myprogram.f

It is important that you understand what is happening here:

To run the program, simply type the name of the executable file:

	myprogram

On Unix systems (or Linux, or other Unix variants) you may need to explicitly state that the program resides in your current directory. The shorthand for the current directory is . (a period, or "dot"). Then the program would be run as:

	./myprogram

Next: The simplest Fortran program.

Back to the main page for the programming tutorial.