The Edit - Compile - Run Cycle

The MATLAB Integrated Developement Environment (IDE) allowed you to write program code and run the program with a click of a button in the same Windows application. It does this by implementing a virtual machine that can interpret MATLAB commands directly without an obvious translation to machine code step. Behind the scenes when you clicked "Run", MATLAB's interpreter translates your program's source code and then executes those instructions and shows you the result(s).

Interpreted programs must perform this translation step each time they are run. This is not very efficient if the program is large or it doesn't change between uses. Since most FORTRAN programs in use today are very large and they are used many times before needing any changes to the source code, it is best to compile them first.

The edit compile run cycle diagram is shown to reinforce the addition of this step in the development cycle of FORTRAN programs. Edit -> Compile -> Run Cycle

Edit

Create one or more text-only file(s) that contain the source code.

Editors available on CAE Tux (linux) machines are:

  1. vi (very powerful command-line editor with separate insert and edit modes)
  2. pico (easy to use, but no one does because it's not as powerful)
  3. emacs (harder to learn, but very popular with many programmers because of its multiple buffers)

Text-only editors available on CAE Windows machines are:

  1. MATLAB's editor
  2. Notepad
  3. TextPad

Compile

Translate the source code into machine language or object code and link that code together into an executable file for the target machine. The only FORTRAN compiler available on CAE Tux machines is: g77

Compilers are programs that translate source code into object code, assembly or machine language. The compiler is usually also responsible for linking multiple files of assembly language or object code together into a final program that can be executed. FORTRAN code must be compiled for each type of machine that you wished your FORTRAN program to run on.

This command will compile a simple FORTRAN code file using g77. The -o option will create an output file named myProgram that can be run from the command line.

       >> gfortran -o myProgram myProgram.f

Run

Execute or run the final program on the target machine. In unix, you will exit a.out or whatever name you chose when compiling and linking the source code.

To run the FORTRAN program you wrote and compiled above, just enter it's name on the command-line:

       >> myProgram

NOTE ABOUT COMPILERS: Once a language is released, compiler writers write a compiler program for the "new" language. A compiler is a program that can translate program source code (FORTRAN statements) into program executables that can be run on your computer. Different operating systems require different executable code, so each language must have a compiler written for each of the various types of operating systems that the program will be executed on. This means that a FORTRAN compiler for UNIX/LINUX will not be able to be used to translate FORTRAN code into an executable for a PC running Windows or for a Macintosh computer. The matter is further complicated by the fact that each compiler may or may not implement all of the functionality described by the language and may require their own specific commands or steps to complete the compilation process of you source code.