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 />

2.45.2 Extended FUNCTION Statement<br />

[type[*len]] FUNCTION fun[*len] ( [d [, d] ...] )<br />

where:<br />

type<br />

fun<br />

d<br />

len<br />

is one of LOGICAL, INTEGER, REAL, DOUBLE PRECISION, COMPLEX, CHARACTER<br />

or RECORD /typename/<br />

is a symbolic name of a function subprogram.<br />

is a variable name, array name, or a dummy procedure name. d is called a dummy argument.<br />

is called the length specification and has one of the following forms:<br />

(1) An unsigned positive integer constant.<br />

(2) A positive integer constant expression enclosed in parentheses.<br />

(3) An asterisk in parentheses, (*).<br />

For valid values of len, refer to the appropriate type declaration statement.<br />

This form of the FUNCTION statement is an extension to the <strong>FORTRAN</strong> <strong>77</strong> language.<br />

Example:<br />

INTEGER*2 MOD2, I, J<br />

I = 12<br />

J = 5<br />

PRINT *, MOD2( I, J )<br />

END<br />

INTEGER*2 FUNCTION MOD2( I, J )<br />

INTEGER*2 I, J<br />

INTEGER II, JJ<br />

II = I<br />

JJ = J<br />

MOD2 = MOD(II, JJ)<br />

END<br />

Notes:<br />

1. No dummy arguments need be specified in the FUNCTION statement. However, the parentheses<br />

() are mandatory.<br />

2. The length specification can appear only once in the FUNCTION statement.<br />

For more information, see the chapter entitled "Functions and Subroutines" on page 243.<br />

78 FUNCTION Statement

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

Saved successfully!

Ooh no, something went wrong!