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.

External procedures<br />

Program units and procedures<br />

External procedures<br />

External procedures are implemented as either functions or subroutines. The major difference<br />

between the two is that a function subprogram returns a value and can therefore appear as an<br />

operand in an expression.<br />

The following sections describe both types of external procedures, including the following<br />

topics:<br />

Procedure definition<br />

Procedure reference<br />

Returning from a procedure call<br />

Alternate entry points<br />

For detailed information about any of the statements associated with procedures (for example,<br />

SUBROUTINE and FUNCTION), refer to Chapter 10, “<strong>HP</strong> <strong>Fortran</strong> Statements.”<br />

Procedure definition<br />

The definition of an external procedure takes the form:<br />

external-procedure-statement<br />

[specification-part]<br />

[execution-part]<br />

[internal-procedure-part]<br />

end-external-procedure-statement<br />

external-procedure-statement<br />

takes one of the following forms, depending on whether the procedure is a<br />

subroutine or function<br />

[RECURSIVE] SUBROUTINE name &<br />

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

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

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

where name is the name of the procedure; type-spec isthetypeofthe<br />

function’s result value; and dummy-arg-list is a comma-separated list of<br />

dummy arguments, as described in “Arguments” on page 139. The<br />

SUBROUTINE and FUNCTION statements are fully described in Chapter 10,<br />

“<strong>HP</strong> <strong>Fortran</strong> Statements.”<br />

Chapter 7 129

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

Saved successfully!

Ooh no, something went wrong!