Fortran: Install

To download and install GNU Fortran into Windows, download into your c:\ directory the four files .

Get a command prompt and go to the root directory on your c drive by entering

cd c:\

Change the name of to unzip.exe by entering

ren unzip.exe

Next unzip the three zipped files by entering in succession


The three files will unzip into a g77 directory, divided into three subdirectories named g77\bin, g77\lib, and g77\doc.

Fortran is run from the g77\bin directory. It is simplest to save all your Fortran programs to this same directory. To get into this directory from a DOS prompt, enter

									cd c:\g77\bin

Then, to compile for example the file hello.f, enter

g77 hello.f
Fortran creates a compiled file that it names a.exe. To run this file from the g77\bin directory just enter


If you want to give the compiled file a name of your own choosing, say such as hello.exe, then compile it with the command

g77 hello.f -o hello.exe

(Any name you give a compiled file must end with the extension .exe.)

On your home computer probably the easiest editor for creating Fortran source files is the DOS editor. Open a DOS window, go to the g77\bin directory (as above), and enter "edit". The DOS editor will open and you can type your source file. When you save the file, just name it whatever.f and it will automatically be saved to the g77\bin directory (by default, since that is the directory from which you opened the DOS editor). You do not have to enclose the name in quotes, as you do in saving with Notepad.

Perhaps the most efficient way of writing and testing a Fortran program on your home computer is to open two DOS windows, one for editing your source file with the DOS editor, and the second for compiling and running your program. In each window you will be working from the g77\bin directory, and you can jump from one window to the other with the click of your mouse.

Remark: This distribution of Fortran was obtained from the now defunct website but the instructions should work (last checked on January 7, 2012).