Intel fortran-80 manual Arguments And Common Blocks Revisited, CALL Statement

Models: fortran-80

1 130
Download 130 pages 742 b
Page 56
Image 56
5.2.7 CALL Statement

Functions And Subroutines

FORTRAN-SO

5.2.7 CALL Statement

The CALL statement is used to reference a subroutine. A subroutine can be refer- enced within any other external procedure or in the main program. A subprogram must not reference itself either directly or indirectly (but see the description of the REENTRANT compiler control in section F.2.3).

The format of the CALL statement is

CALL sub [([arg [,arg]. .. ])]

where

sub is the symbolic name of a subroutine or dummy procedure.

argis an actual argument.

The actual arguments in the CALL statement must agree in order, number, type, and (if applicable) length with the corresponding dummy argument list of the referenced subroutine. If the name of a subroutine is specified as an actual argu- ment, the type conformity rule does not apply since subroutines do not have an associated type.

Each actual argument must be one of the following:

An expression

An array name

An intrinsic function name

An external procedure name

A dummy procedure name

An actual argument in a CALL statement may be a dummy argument name if that name appears in a dummy argument list within the subprogram containing the CALL.

Examples:

CTHE FOLLOWING STATEMENTS COULD BE USED TO CALL C THE SUBROUTINE DEFINED IN THE 'RETURN STATEMENT' C EXAMPLE (SECTION 5.2.5)

CALL POSTOT(3.2,-2.7,0.08)

CALL POSTOT(X,5.2**I,-Y)

5.3 Arguments And Common Blocks Revisited

Arguments and common blocks are the means of communicating between pro- cedures and statements referencing the procedures. Data can be passed to a state- ment function or intrinsic function by an argument list. Data can be passed between external procedures and other program units by argument lists or can be shared in common blocks.

FORTRAN has a number of very specific rules governing the use of common blocks and argument lists. We touched on the most important when function and subroutine references were discussed. This section repeats those rules plus a number of others related to arguments and common blocks.

5-8

Page 56
Image 56
Intel fortran-80 manual Arguments And Common Blocks Revisited, CALL Statement