Free FORTRAN Compilers



The following site lists a number of free compilers:

http://sunsite.icm.edu.pl/fortran/append-f.html

The one that closely resembles the one we're using in this course is the GNU g77. To speed up the download, copies of the four needed files have been mirrored here:

To install it, create a new folder on your hard drive and call it Fortran. Download the four files above (simply right-click each and choose Save Target As...) and place them in this new folder under their default names. Next, run MS-DOS and type the following:
If everything went fine, you should be in the editor screen. The shown file should be corrected by replacing any occurrence of C: by \Fortran. Once done, use the File menu to Exit and confirm that you do want the changes saved.

Use NotePad to create your Fortran programs. Say you wrote a program and saved it under the name MyProg.for in the \Fortran\EMX directory. Do not exit NotePad: Just switch to MS-DOS (e.g. using Alt-Tab) and use the cd command to change to the \Fortran\EMX subdirectory. Once in it, type the command: setupEMX. Once it executes, type the command:

g77 -ffree-form MyProg.for

If errors were reported, use Alt-Tab to switch to NotePad, make the needed corrections, save the file, and press Alt-Tab again to return to DOS. There, use the Up-Arrow to repeat the g77 command (the setupEMX is needed only once - as long as the DOS window remains open). Once the program compiles without errors, you can run it by typing its name; i.e. MyProg.

The language syntax is very similar to the one we're using (Microsoft). The text files in the EMX directory give a detailed reference to its elements. The following list (updated regularly) shows any differences between it and what we use in class:

  1. Don't use $FreeForm.
  2. Instead of the subroutine: Call Random(x), use the function call: x = Rand(0). The function should be declared using: Real*4 Rand.
  3. Our compiler uses " for full-line comments and ! for in-line comments. The gnu compiler uses ! for both; i.e. " is illegal.
  4. gnu does not have a LEN_TRIM function. Need to write your own.
  5. The OPEN statement does not have an 'append' option

(Back to the Home page)