Using Fortran

In order to program in FORTRAN (or any other language) you need to be able to write and edit a text file containing the actual code. (See emacs for an example of a text editor.)

The easiest way to run a FORTRAN program is to write it in a file with the extension .f, and use the command "make ". For example, suppose you created a file called "hello.f" containing the text:

      write (*,*) ' hello world '

It is not obvious, but it is vital that each complete line of FORTRAN code begin with exactly six blank characters. This annoying "feature" is a holdover from the days when FORTRAN programs were prepared by punching cards. Interesting, eh?

To compile hello.f you simply type
   % make hello
and to run it you just type
   % hello

You can copy a version of this file to your working directory by giving the command

   cp labdemos/fortran/hello.f .

Note the "." at the end of this command. It is what tells cp that it should copy hello.f to your working directory.

More about the FORTRAN compiler

To find out more about the FORTRAN compiler type
   man f77

For example, the following f77 command has the same effect as the above make command:

   f77 -o hello hello.f