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.45 FUNCTION Statement<br />

A FUNCTION statement is used to define the start of a function subprogram. There are two forms of the<br />

FUNCTION function statement. The second form is a <strong>Open</strong> <strong>Watcom</strong> <strong>FORTRAN</strong> <strong>77</strong> extension.<br />

2.45.1 Standard FUNCTION Statement<br />

<br />

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

where:<br />

type<br />

fun<br />

d<br />

len<br />

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

[*len].<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 is the length (number of characters) of the result of the<br />

character function. It 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 />

Example:<br />

PRINT *, TMAX3( -1.0, 12.0, 5.0 )<br />

END<br />

FUNCTION TMAX3( ARGA, ARGB, ARGC )<br />

TMAX3 = ARGA<br />

IF( ARGB .GT. TMAX3 ) TMAX3 = ARGB<br />

IF( ARGC .GT. TMAX3 ) TMAX3 = ARGC<br />

END<br />

In the above example, the function TMAX3 is defined to find the maximum of three real variables.<br />

Notes:<br />

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

() are mandatory.<br />

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

FUNCTION Statement <strong>77</strong>

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

Saved successfully!

Ooh no, something went wrong!