02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INTEGER, PARAMETER :: buffsize = 0<br />

REAL :: buffer (1: buffsize)<br />

! buffer has explicit shape, but no elements and is zero-sized<br />

.<br />

.<br />

.<br />

END SUBROUTINE sort<br />

Assumed-shape arrays<br />

Arrays<br />

Array declarations<br />

An assumed-shape array is a dummy argument that assumes the shape of the<br />

corresponding actual argument. It must not have the POINTER attribute. Each dimension of<br />

an assumed-shape array has the form:<br />

[lower-bound] :<br />

where lower-bound is a specification expression. The default for lower-bound is 1.<br />

The actual argument and the corresponding dummy argument may have different bounds for<br />

each dimension. An assumed-shape array subscript may extend from the specified<br />

lower-bound to an upper bound that is equal to lower-bound plus the extent in that<br />

dimension of the actual argument minus one.<br />

The following code segment illustrates different declarations of assumed-shape arrays.<br />

SUBROUTINE initialize (a,b,c,n)<br />

! examples of assumed-shape arrays<br />

INTEGER :: n<br />

INTEGER :: a(:)<br />

! the array a is a rank-one assumed-shape array, it takes its<br />

! shape and size from the corresponding actual argument; its<br />

! lower bound is 1 regardless of the lower bound defined for<br />

! the actual argument<br />

COMPLEX :: b(ABS(n):)<br />

! a rank-one assumed-shape array, the lower bound is ABS(n) and<br />

! the upper bound will be the lower bound plus the extent of<br />

! the corresponding actual argument minus one<br />

REAL, DIMENSION(:,:,:,:,:) :: c<br />

! an assumed-shape array with 5 dimensions; the lower bound for<br />

! each dimension is 1<br />

.<br />

.<br />

.<br />

END SUBROUTINE initialize<br />

Chapter 4 59

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

Saved successfully!

Ooh no, something went wrong!