02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's 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>HP</strong> <strong>Fortran</strong> statements<br />

CALL<br />

4. Control returns from the subroutine, normally to the statement following the CALL<br />

statement, or to a statement label indicated by an alternate return argument—*label or<br />

&label. (The& label form is provided as a compatibility extension and can be used in<br />

fixed source form only.)<br />

A subroutine can call itself, directly or indirectly; in this case the keyword RECURSIVE must be<br />

specified in the SUBROUTINE statement of the subroutine definition.<br />

The %VAL and %REF built-in functions are provided as <strong>HP</strong> extensions. They can be used to<br />

change argument-passing conventions calling a routine written in another language.<br />

The only subroutine invocation other than by the CALL statement in <strong>Fortran</strong> 90 is through<br />

“defined assignment”, where a defined type assignment operator that has been defined by<br />

means of a subroutine is used.<br />

Examples<br />

! Interface for subroutine draw<br />

INTERFACE<br />

SUBROUTINE draw (x_start, y_start, x_end, y_end, form, scale)<br />

REAL x_start, y_start, x_end, y_end<br />

CHARACTER (LEN = 6), OPTIONAL :: form<br />

REAL, OPTIONAL :: scale<br />

END SUBROUTINE draw<br />

END INTERFACE<br />

! <strong>Reference</strong>s to draw<br />

! arguments given by position; optional argument scale omitted<br />

CALL draw (5., -4., 2., .6, ”DASHED”)<br />

! arguments given by keyword; optional argument form omitted<br />

CALL draw (scale=.4, x_end=0., y_end=0., x_start=.5, y_start=.3)<br />

Related statements<br />

INTERFACE and SUBROUTINE<br />

Related concepts<br />

For related information, see the following:<br />

258<br />

“Recursive reference” on page 132<br />

“Referencing a subroutine” on page 130<br />

“Arguments” on page 139<br />

“%VAL and %REF built-in functions” on page 146<br />

“Defined assignment” on page 155<br />

Chapter 10

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

Saved successfully!

Ooh no, something went wrong!