next up previous contents
Next: Language Elements Up: Fortran 90 Programming Previous: Fortran 90 Programming

 

Example of a Fortran 90 Program

Consider the following example Fortran 90 program:

    MODULE Triangle_Operations
     IMPLICIT NONE
    CONTAINS
     FUNCTION Area(x,y,z)
      REAL :: Area            ! function type
      REAL, INTENT( IN ) :: x, y, z
      REAL :: theta, height
      theta = ACOS((x**2+y**2-z**2)/(2.0*x*y))
      height = x*SIN(theta); Area = 0.5*y*height
     END FUNCTION Area
    END MODULE Triangle_Operations

    PROGRAM Triangle
     IMPLICIT NONE
     REAL :: a, b, c, Area
     PRINT *, 'Welcome, please enter the&
              &lengths of the 3 sides.'
     READ *, a, b, c
     PRINT *, 'Triangle''s area:  ', Area(a,b,c)
    END PROGRAM Triangle

The program highlights the following:

Return to corresponding overview page gif


next up previous contents
Next: Language Elements Up: Fortran 90 Programming Previous: Fortran 90 Programming

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.