24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>FORTRAN</strong> Statements<br />

2.9 CALL Statement<br />

<br />

CALL sub [( [a [, a] ... ] )]<br />

where:<br />

sub<br />

a<br />

is a symbolic name of a subroutine and must not be the name of a main program, function,<br />

common block, or block data subprogram. As an extension to <strong>FORTRAN</strong> <strong>77</strong>, <strong>Open</strong> <strong>Watcom</strong><br />

<strong>FORTRAN</strong> <strong>77</strong> permits the calling of functions.<br />

is an actual argument.<br />

The CALL statement is used to invoke the execution of a subroutine subprogram or function.<br />

Example:<br />

X = 1.0<br />

Y = 1.1<br />

Z = 1.2<br />

CALL QUAD( X, Y, Z )<br />

.<br />

.<br />

.<br />

END<br />

SUBROUTINE QUAD( ARGA, ARGB, ARGC )<br />

REAL ARGA, ARGB, ARGC<br />

PRINT *, 2.0*ARGA**2 + 4.0*ARGB + ARGC<br />

END<br />

In the above example, the variables X, Y and Z are passed to the subroutine QUAD. This subroutine<br />

computes an expression and prints the result.<br />

Notes:<br />

1. The parameters in the CALL statement are called actual arguments.<br />

2. The parameters in the SUBROUTINE statement are called dummy arguments.<br />

3. The actual arguments in a subroutine or function reference must agree in order, number and<br />

type with the corresponding dummy arguments.<br />

4. An actual argument may be an expression, array name, intrinsic function name, external<br />

procedure name (i.e., a subroutine or function name), a dummy procedure name (i.e., one that<br />

was an argument to the calling subroutine or function), or an alternate return specifier<br />

(subroutines only). An alternate return specifier takes the form *s, where s is the statement<br />

label of an executable statement that appears in the same program unit as the CALL statement.<br />

An expression may not be a character expression involving the concatenation of an operand<br />

whose length specification is (*) unless the operand is the symbolic name of a constant.<br />

5. Actual arguments are associated with dummy arguments by passing the address of the actual<br />

arguments.<br />

CALL Statement 23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!