next up previous contents
Next: Procedures Up: Main Program Syntax Previous: Main Program Syntax

 

Main Program Example

The following example demonstrates a main program which calls an intrinsic function, (FLOOR), and an internal procedure, (Negative)

    PROGRAM Main
     IMPLICIT NONE
     REAL x
     INTRINSIC FLOOR
      READ*, x
      PRINT*, FLOOR(x)
      PRINT*, Negative(x)
    CONTAINS
     REAL FUNCTION Negative(a)
      REAL, INTENT(IN) :: a
       Negative = -a
     END FUNCTION Negative
    END PROGRAM Main

Although not totally necessary, the intrinsic procedure is declared in an INTRINSIC statement (the type is not needed -- the compiler knows the types of all intrinsic functions).

The internal procedure is `contained within' the main program so does not require declaring in the main program;

The compiler is able to `see' the procedure and therefore knows its result type, number and type of arguments. Return to corresponding overview page gif


next up previous contents
Next: Procedures Up: Main Program Syntax Previous: Main Program Syntax

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