How to Compile Fortran 77 on Ubuntu

Save

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

    c

      character*32 text

    c

      text = 'Hello World'

    write (*,*) text

    c

      end
  • 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.

References

  • Photo Credit Jupiterimages/Photos.com/Getty Images
Promoted By Zergnet

Comments

Resources

You May Also Like

Related Searches

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