Installing Fortran

  • by
Installing Fortran

Installing Fortran – Fortran (previously FORTRAN) is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing. Originally developed by IBM in the 1950s for scientific and engineering applications, Fortran came to dominate this area of programming early on and has been in continual use for over half a century in computationally intensive areas such as climate modeling, computational fluid dynamics, computational physics, and computational chemistry. – For more about FORTRAN you can visit the FORTRAN Wikipedia page

Installing Fortran on a windows XP machine

I have installed two different versions of Fortran on my Windows machine, GFortran and G77. Both G-Fortran and G77 are from the same GNU project. I personally like G77, but it will take slightly more time to install. GFortran is a newer version of the old G77, but major operating capabilities are very similar.

Multiple compilers can be useful since one may pick up an error in your program that the other misses.

Installation instructions for G-Fortran; very simple installation

1. Download GFortran by clicking on the link below. This will start the download of the Fortran package.

G95, Windows Download

2. Once it has downloaded, double click on the icon, and it will start the installation automatically. You can just keep hitting enter if you don’t care where it installs. The nice thing about this install is that it automatically creates a path to be used with the command prompt

3. To use GFortran to compile a program (lets call it test.f), go to Start –> click Run –> type in cmd –> in the window that pops up, you will need to change directory to got into the folder that has the program that you want to compile –> e.g. cd Desktop/Programs –> then you type gfortran test.f –> if the script compiles without errors, then type in a and the program will run!

4. To create and edit Fortran files, you will need a text editor. I recommend VIM if you are, or want to become, an advanced programmers, or EMACS if you are just getting started and want something simple.

Installation instructions for G77 Fortran; the classic Fortran package

1. G77 needs to be downloaded in two parts. The execute file, and the library file

execute: http://www.neuralwiki.org/downloads/g77exe.zip

library: http://www.geocities.com/athens/Olympus/5564/g77lib.zip

alternatively http://www.neuralwiki.org/downloads/g77lib.zip

2. You need to have some type of unzipping software like winzip installed. Double click on the g77exe.zip icon and the folder will open up. Then click extract, and set it install on the main drive ( usually c:\ ) (see image)

3. Now do the same to the g77lib.zip Steps 2 and 3 will create a folder called G77 on your main drive. Inside will be two folders, Bin and Lib.

4. Now you need to make a path so that the computer will recognize g77 in the command prompt. Go to Start, click Control Panel, then System. Click the advanced tab, then Environmental Variables. Now a new window will pop up. Highlight PATH, then click edit. Add c:\g77\bin If other files already exist, separate them with a semicolon. for example c:\emacs\bin;c:\g77\bin then click okay (see image)

5. Go to the box labeled system variables (in the Environmental Variables window), and click new. A box will pop up with two lines. In the first line labeled variable name, type in LIBRARY_PATH in the second line labeled variable value, type in c:\g77\lib Now its installed!

Running Fortran

Go to the Windows Start Menu. Click it, then click run. Type in the three letters cmd and the command prompt will pop up. Fortran programs can only act on files that are in the same folder that the program is. Therefore, place the files you want to analyze and the Fortran programs that will do the analysis into a single folder. Then change the command prompt to that folder. For example: If I created a folder titled Fortran on the Desktop, I would type cd Desktop/Fortran into the command prompt to get into that folder.

Once the command prompt is in the proper folder, you can run your Fortran programs. If you installed GFortran, and you wanted to run a Fortran program called test.f you would type gfortran test.f into the command line. If you installed G77, you would type g77 test.f into the command line

Then to run the program, simply type in a at the command prompt.

Editing Files

To edit or create Fortran files, you will need a text editor. I recommend either EMACS for beginners and light programmers, or VIM for those who want to become hardcore efficient programmers.

Share this post ...

Leave a Reply

Your email address will not be published. Required fields are marked *