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 ' end
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 helloand to run it you just type
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.
For example, the following f77 command has the same effect as the above make command:
f77 -o hello hello.f