How to Compile Fortran 77 on Ubuntu

Written by allen bethea Google
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Compile Fortran 77 on Ubuntu
Fortran is designed for scientific computations. (Jupiterimages/ Images)

Fortran is the "living fossil" of computer programming languages. It was originally developed in the 1950s to run on IBM's 704 computer. Fortran was not the first compiler, but it offered mathematicians, engineers and scientists a language more suited to numeric and scientific computing than others before it. Fortran 77 represents one stage in Fortran's evolution that keeps it a relevant programming language today. Fortran has been available for installation on all versions of Ubuntu since Warty Warthog.

Skill level:
Moderately Challenging

Other People Are Reading

Things you need

  • Current release of Ubuntu Linux
  • Internet Connection
  • Plain Text editor

Show MoreHide


  1. 1

    Press the "Alt" and "F2" keys at the same time. Type "gnome-terminal" in the input box and press "Enter."

  2. 2

    Type "sudo apt-get install f2c fort 77" at the command prompt. Press enter key. Enter your password and press enter again.

  3. 3

    Type "Y" and press "Enter" at the prompt, "Do you want to continue [Y/n]?" Wait for the software installation process to complete.

  4. 4

    Load the text editor by typing "gedit" at the terminal command prompt. Press "Enter."

  5. 5

    Enter the following sample code in the text editor. Line the columns of text exactly as shown.

      program hello_world
      implicit none


      character*32 text


      text = 'Hello World'
      write (*,*) text


  6. 6

    Click on the "File" menu and select the "Save" option. Save the file under the name "demo.f"

  7. 7

    Click on the "File" menu. Select "Quit" to close the editor.

  8. 8

    Type "f77 -o demo demo.f" at the command prompt to compile the Fortran program.

  9. 9

    Type "./demo" at the command prompt, then press "Enter" to run the "hello world" demo.

Tips and warnings

  • Well-written code comments can help programmers debug, maintain and document their work. Ubuntu and most other Linux distributions include tools to automatically generate documentation from source code comments. Ubuntu's repository contains Robodoc and the Geany IDE plugin, GeanyGenDoc.
  • Fortran was developed during the era when computers were programmed and fed data using 80 column punch cards. Columns have meaning to Fortran compilers. The first column is used for the "c" or "*" symbol indicating comments. Columns one through five are for statement labels. Only columns seven through 72 are used for actual program statements. Misaligned code may not compile at all.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.