next up previous contents
Next: Functions Up: Program Units Previous: Introduction to Procedures

 

Subroutines

Consider the following example,

      PROGRAM Thingy
       IMPLICIT NONE
       .....
        CALL OutputFigures(NumberSet)
       .....
      CONTAINS
       SUBROUTINE OutputFigures(Numbers)
        REAL, DIMENSION(:), INTENT(IN) :: Numbers
         PRINT*, "Here are the figures", Numbers
       END SUBROUTINE OutputFigures
      END PROGRAM Thingy

Internal subroutines lie between CONTAINS and END PROGRAM statements and have the following syntax

 
 SUBROUTINE < procname >[ (< dummy args >) ]

< declaration of dummy args >

< declaration of local objects >

...

< executable stmts >

END [ SUBROUTINE [< procname > ] ]

Note that, in the example, the IMPLICIT NONE statement applies to the whole program including the SUBROUTINE.

For more information, click here gif

Now try this question gif


next up previous contents
Next: Functions Up: Program Units Previous: Introduction to Procedures

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.