Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran 90 Programmer's Reference: HP Series 700/800 Computers > Chapter 4 Arrays

Zero-sized arrays

» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

The size of an array is the product of the extents of each dimension; if any extent is zero then the array has no size and is known as a zero-sized array. Any of the arrays described in this chapter may be zero-sized apart from assumed-sized arrays which have no specified size. This concept of a zero-sized arrays is important if a number of algorithms are to be expressed naturally.

Note that while zero-sized arrays have no elements, they do still have a shape and this is important when they are used in array expressions which are described below. Operations involving zero-sized arrays are generally null operations.

Following are some examples of zero-sized arrays:

INTEGER, PARAMETER :: cases = 0
REAL :: data1(cases,2), data2(cases,3)
! both data1 and data2 are explicit-shape
! arrays and have zero size; data1 has
! shape [ 0 , 2] and data2 has the shape
! [ 0 , 3]
DO i = 1,n+1
  a(i) = SIN(x(i))
  b(i:n) = b(i:n) + a(i)
ENDDO
! the array section b(i:n) becomes a
! zero-sized array in the last iteration of
! the DO loop
WRITE(*,"(9a)",ADVANCE="NO") &
(/ (title(i),i=1,cols) /)
! if the variable cols is less than 1, then
! the array constructor contains no values
! and no data will be output
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1996 Hewlett-Packard Development Company, L.P.