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.

Arrays<br />

Array-valued functions<br />

PROGRAM main<br />

! The following interface block describes the characteristics of<br />

! the function genrand; the function inputs a single integer<br />

! scalar and returns a real array of rank-one with an extent<br />

! equal to the value of its argument<br />

INTERFACE<br />

FUNCTION genrand(n)<br />

INTEGER:: n<br />

REAL, DIMENSION (n)::genrand<br />

END FUNCTION genrand<br />

END INTERFACE<br />

REAL :: a(100)<br />

REAL :: b(10,10)<br />

! set array a to the result returned by the function genrand;<br />

! note that the left and right hand side are conformable<br />

a = genrand(SIZE(a))<br />

! add each element of a to the corresponding element of the<br />

! result returned by genrand, forming an intermediate rank-one<br />

! result that is passed into the intrinsic function RESHAPE.<br />

! This intrinsic transforms its argument into a 10 by 10 array.<br />

! Again, the left and right hand side are conformable.<br />

b = RESHAPE(a + genrand(100),(/ 10, 10 /))<br />

.<br />

.<br />

.<br />

END PROGRAM main<br />

78<br />

Chapter 4

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

Saved successfully!

Ooh no, something went wrong!