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

INTENT (statement and attribute)<br />

If a dummy argument has intent OUT, the corresponding actual argument must be definable;<br />

that is, it cannot be a constant. When execution of the procedure begins, the dummy<br />

argument is undefined; thus it must be given a value before it is referenced. The dummy<br />

argument need not be given a value by the procedure.<br />

If a dummy argument has intent INOUT, the corresponding actual argument must be<br />

definable. If the actual argument is defined, this value is passed in as the value of the dummy<br />

argument. The dummy argument need not be given a value by the procedure.<br />

The following points should also be noted:<br />

Intent specifications apply only to dummy arguments and may only appear in the<br />

specification part of a subprogram or interface body.<br />

If there is no intent specified for an argument in a subprogram, the limitations imposed<br />

by the actual argument apply to the dummy argument. For example, if the actual<br />

argument is an expression that is not a variable, the dummy argument must not redefine<br />

its value.<br />

The intent of a pointer dummy argument must not be specified.<br />

Examples<br />

! x, y, and z are dummy arguments<br />

SUBROUTINE electric (x, y, z)<br />

REAL, INTENT (IN) :: x, y ! x and y are used only for input<br />

! z is used for input and output<br />

COMPLEX, INTENT (INOUT), TARGET :: z(1000)<br />

...<br />

SUBROUTINE pressure (true, tape, a, b)<br />

USE a_module<br />

TYPE(ace), INTENT(IN) :: a, b ! a and b are only for input<br />

INTENT (OUT) true, tape ! true and tape are for output<br />

...<br />

SUBROUTINE lab_ten (degrees, x, y, z)<br />

COMPLEX, INTENT(INOUT) :: degrees<br />

REAL, INTENT(IN), OPTIONAL :: x, y<br />

INTENT(IN) z<br />

...<br />

PROGRAM pxx<br />

CALL electric (a+1, h*c, d) ! First subroutine defined above<br />

CALL lab_ten (dg, e, f, g+1.0)<br />

END PROGRAM pxx<br />

Related statements<br />

FUNCTION and SUBROUTINE<br />

Chapter 10 355

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

Saved successfully!

Ooh no, something went wrong!