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.

...<br />

d(2,3,2) a(3,2)<br />

Program units and procedures<br />

Arguments<br />

When an actual argument and the associated dummy argument are default character arrays,<br />

they may be of unequal character length. If this is the case, then the first character of the<br />

dummy and actual arguments are matched, and the successive characters—rather than array<br />

elements—are matched.<br />

The next example illustrates character sequence association. Assuming this declaration of the<br />

actual argument:<br />

CHARACTER*2 a(3,4)<br />

and this declaration of the corresponding dummy argument:<br />

CHARACTER*4 d(2,3)<br />

then the correspondence between elements of the actual and dummy arguments is as follows:<br />

Dummy Actual<br />

------------------d(1,1)<br />

a(1,1)//a(2,1)<br />

d(2,1) a(3,1)//a(1,2)<br />

...<br />

d(2,3) a(2,4)//a(3,4)<br />

An actual argument may be an array section, but associating an array section with any other<br />

but an assumed-shape dummy argument may cause a copy of the array section to be<br />

generated and is likely to result in a degradation in performance.<br />

For information about the different types of arrays, see “Array declarations” on page 57.<br />

Derived-type dummy argument<br />

When passing a derived-type object, the corresponding dummy and actual arguments of<br />

derived types are assumed to be of the same derived type. Unless the interface of the<br />

referenced procedure is explicit within the program unit that makes the reference, the<br />

compiler does not perform any type-checking. It is the programmer’s responsibility to ensure<br />

that the types of the dummy argument and the actual argument are the same, such as by<br />

doing either of the following:<br />

Replicating the definition of the derived type in both subprograms<br />

Placing the definition in a module and making the definition available to both<br />

subprograms by use association<br />

For information about explicit interface, see “Procedure interface” on page 149. For<br />

information modules and use association, see “Modules” on page 158.<br />

Chapter 7 141

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

Saved successfully!

Ooh no, something went wrong!