02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's 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.

FUNCTION<br />

Introduces a function subprogram.<br />

Syntax<br />

[RECURSIVE] [type-spec] FUNCTION<br />

RECURSIVE<br />

type-spec<br />

function-name ([dummy-arg-name-list])<br />

[RESULT (result-name)]<br />

function-name<br />

dummy-arg-name-list<br />

result-name<br />

<strong>HP</strong> <strong>Fortran</strong> statements<br />

FUNCTION<br />

is a keyword that must be specified in the FUNCTION statement if the<br />

function is either directly or indirectly recursive. The RECURSIVE clause can<br />

appear at most once, either before or after type-spec. It is not an error to<br />

specify RECURSIVE for a nonrecursive function.<br />

A recursive function that calls itself directly must also have the RESULT<br />

clause specified (see below).<br />

is a valid type specification (INTEGER, REAL, LOGICAL, CHARACTER, TYPE<br />

(name), etc.). The type and type parameters of the function result can be<br />

specified by type-spec or by declaring the result variable within the<br />

function subprogram, but not by both. The implicit typing rules apply if the<br />

function is not typed explicitly.<br />

If the function result is array-valued or a pointer, the appropriate attributes<br />

for the result variable (which is function-name, orresult-name if<br />

specified) must be specified within the function subprogram.<br />

is the name of the function subprogram being defined.<br />

is a comma-separated list of dummy argument names for the function.<br />

is the result variable. If the RESULT clause is not specified, function-name<br />

becomes the result variable. If result-name is given, it must differ from<br />

function-name, andfunction-name must not then be declared within the<br />

function subprogram.<br />

Chapter 10 329

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

Saved successfully!

Ooh no, something went wrong!