clear=”both”
In Fortran 77, all subprograms are external except communications functions. Using Fortran 90 subprograms interior is now possible to obtain an effect similar to the functions of Fortran 77 statement. They are visible only within the program that contains them and have an explicit interface. An internal subprogram must be separated from the main program that contains the statement. An example of a sub procedure is given below.
Triangle Program
real a, b, c
print *, ‘Enter the lengths of the three sides of the triangle’
read *, a, b, c
print *, ‘Triangle’’s area:’, triangleArea (a, b, c)
contains
triangleArea function (a, b, c)
Real triangleArea
real, intent (in):: a, b, c
real theta
real height
theta = Acos ((a ** b ** 2 + 2 - c ** 2) / (2.0 * a * b))
height = a * sin (theta)
triangleArea = 0.5 * b * height
End Function triangleArea
end program Triangle
Related Links topic
- How to download free Fortran compiler

Giuseppe Ciaburro








