FORTRAN 77 - Example Program Code

This section provides a simple example program code of FORTRAN 77 language.

In FORTRAN 77, several interesting features were added to FORTRAN 66:

Here is a simple example code of FORTRAN 77 that calculates the area of triangles using Heron's formula:

C AREA OF A TRIANGLE - HERON'S FORMULA
C INPUT - CARD READER UNIT 5, INTEGER INPUT
C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT
C INPUT ERROR DISPAYS ERROR MESSAGE ON OUTPUT
      PROGRAM AREA
      INTEGER A, B, C
      CHARACTER MSGEND*40, MSGERR*40
      MSGEND = "NORMAL END"
      STRERR = "INPUT ERROR"

  100 READ(5,10,END=200,ERR=300) A,B,C
   10 FORMAT(3I5)
      IF(A=0 .OR. B=0 .OR. C=0) THEN
         WRITE(6,*) "Zero value not allowed"
      ELSE
         S = (A + B + C) / 2.0
         AREA = SQRT( S * (S - A) * (S - B) * (S - C))
         WRITE(6,20) A,B,C,AREA
   20    FORMAT(" A=",I5,", B=",I5,", C=",I5,", AREA=",
     *      F10.2," SQUARE UNITS")
      END IF
      GO TO 100

  200 WRITE(6,*) MSGEND
      STOP
  300 WRITE(6,*) MSGERR
      STOP
      END

Table of Contents

 About This Book

 2002 - .NET Framework Developed by Microsoft

 1995 - PHP: Hypertext Preprocessor Created by Rasmus Lerdorf

 1995 - Java Language Developed by Sun Microsystems

 1991 - WWW (World Wide Web) Developed by Tim Berners-Lee

 1991 - Gopher Protocol Created by a University of Minnesota Team

 1984 - X Window System Developed a MIT Team

 1984 - Macintosh Developed by Apple Inc.

 1983 - "Sendmail" Mail Transfer Agent Developed by Eric Allman

 1979 - The Tcsh (TENEX C Shell) Developed by Ken Greer

 1978 - Bash (Bourne-Again Shell) Developed by Brian Fox

 1978 - The C Shell Developed by Bill Joy

 1977 - The Bourne Shell Developed by Stephen Bourne

 1977 - Apple II Designed by Steve Jobs and Steve Wozniak

 1976 - vi Text Editor Developed by Bill Joy

 1974 - Internet by Vinton Cerf

 1972 - C Language Developed by Dennis Ritchie

 1971 - FTP Protocol Created by Abhay Bhushan

 1970 - UNIX Operating System Developed by AT&T Bell Labs

1957 - FORTRAN Language Developed by IBM

 What Is FORTRAN

 Storing FORTRAN Program Code on Punch Cards

 FORTRAN 66 - Example Program Code

FORTRAN 77 - Example Program Code

 g77 - GNU Project FORTRAN Compiler

 Fortran 90 - Example Program Code

 References

 Full Version in PDF/EPUB