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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Language</strong> <strong>Reference</strong><br />

Example:<br />

DIMENSION A(10)<br />

CALL SAM( A(3) )<br />

END<br />

SUBROUTINE SAM( B )<br />

DIMENSION B(5)<br />

.<br />

.<br />

.<br />

END<br />

In the previous example, array A is an actual argument and the array B is the dummy argument. Suppose<br />

we wanted to know which element of A is associated with the 4th element of B. Then asv would have<br />

value 3 since the array element A(3) is the actual argument, and dsv is 4. Then the 4th element in B is 3 +<br />

4 - 1 = 6th element of A.<br />

If the actual argument is a character array name, character array element name or character array element<br />

substring which begins at character storage unit ach, then the character storage unit dch of the dummy<br />

argument array is associated with the character storage unit ach + dch - 1 of the actual array. The size of<br />

the dummy character array must not exceed the size of the actual argument array.<br />

12.8.3.4 Procedures as Dummy Arguments<br />

A dummy argument that is a dummy procedure can only be associated with an actual argument that is one<br />

of the following.<br />

1. Intrinsic function.<br />

2. External function.<br />

3. External Subroutine.<br />

4. Another dummy procedure.<br />

If the dummy argument is used as a subroutine (that is it is invoked using a CALL statement) then the<br />

corresponding actual argument must either be a subroutine or a dummy procedure. If the dummy argument<br />

is used as an external function, then the corresponding actual argument must be an intrinsic function,<br />

external function or dummy procedure. Note that it may not be possible to determine in a given program<br />

unit whether a dummy procedure is associated with a function or subroutine. In the following example it is<br />

not possible to tell by looking at this program unit whether PROC is an external subroutine or function.<br />

Example:<br />

SUBROUTINE SAM( PROC )<br />

EXTERNAL PROC<br />

.<br />

.<br />

CALL SAM1( PROC )<br />

.<br />

.<br />

.<br />

END<br />

280 Subprogram Arguments

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

Saved successfully!

Ooh no, something went wrong!