How to Compile Fortran 77 on Ubuntu


Fortran is the "living fossil" of computer programming languages. It was originally developed in the 1950's 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.

Things You'll Need

  • Current release of Ubuntu Linux
  • Internet Connection
  • Plain Text editor
  • Press the "Alt" and "F2" keys at the same time. Type "gnome-terminal" in the input box and press "Enter."

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

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

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

  • 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


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

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

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

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

Tips & 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.

Related Searches


  • Photo Credit Jupiterimages/ Images
Promoted By Zergnet



You May Also Like

  • How to Convert Fortran to Visual Basic

    Fortran was the world's first procedural programming language, and it brought with it a whole host of improvements to the art and...

  • How to Run Fortran F Code on Ubuntu

    While most programmers used languages such as C, C++, Java or Python by the dawning of the 21st century, some developers still...

  • How to Learn Fortran on a Mac

    Fortran is a programming language designed primarily for use in writing programs capable of solving scientific problems. Although this was the primary...

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!