HP Fortran Programmer's Reference (September 2007)

Arrays
Array-valued functions
Chapter 380
PROGRAM main
! The following interface block describes the characteristics of
! the function genrand; the function inputs a single integer
! scalar and returns a real array of rank-one with an extent
! equal to the value of its argument
INTERFACE
FUNCTION genrand(n)
INTEGER:: n
REAL, DIMENSION (n)::genrand
END FUNCTION genrand
END INTERFACE
REAL :: a(100)
REAL :: b(10,10)
! set array a to the result returned by the function genrand;
! note that the left and right hand side are conformable
a = genrand(SIZE(a))
! add each element of a to the corresponding element of the
! result returned by genrand, forming an intermediate rank-one
! result that is passed into the intrinsic function RESHAPE.
! This intrinsic transforms its argument into a 10 by 10 array.
! Again, the left and right hand side are conformable.
b = RESHAPE(a + genrand(100),(/ 10, 10 /))
.
.
.
END PROGRAM main