PDA

View Full Version : Re: [Fwd: [LF] SIZE intrinsic]


Lahey Support
08-15-2003, 01:24 AM
>No, this is not the complete definition of a parameter. A parameter is a
>named constant initialized using an initialization-expr (see 5.1.2.1). SIZE
>is not allowed in an initialization-expr (see 7.1.6.1).


Perhaps I am being unfair when taking this sentence out
of context but it still seems false to me, no offense
intended. To clear things out I have pasted in the relevant
parts of The Standard at the bottom of the mail. According
to point (6) I can have a SIZE reference in my PARAMETER
statement, eg:

PROGRAM Test
INTEGER :: x( 10 )
INTEGER, PARAMETER :: n = SIZE (x)
WRITE(*,*) n
END PROGRAM Test

would be a legal program. But of course the SIZE in the
PARAMETER can't have the argument of a SUBROUTINE as
argument. Was that what the writer meant or am I
missing something here?

Kindly,

Per Hakan Lundow

----------------------------------------------------------------------------
From 7.1.6.1:

An initialization expression is a constant expression in which the
exponentiation operation is permitted
only with an integer power, and each primary is one of the following:

(1) A constant or subobject of a constant where each subscript,
section subscript, substring
starting point, and substring ending point is an initialization expression,

(2) An array constructor where each element and the bounds and strides
of each implied-DO are
expressions whose primaries are either initialization expressions or
implied-DO variables,

(3) A structure constructor where each component is an initialization
expression,

(4) An elemental intrinsic function reference of type integer or
character where each argument is
an initialization expression of type integer or character,

(5) A reference to one of the transformational functions,
REPEAT, RESHAPE,
SELECTED_INT_KIND, SELECTED_REAL_KIND, TRANSFER, or TRIM, where each
argument is an initialization expression,

(6) A reference to an array inquiry function (13.10.15) other than
ALLOCATED, the bit inquiry
function BIT_SIZE, the character inquiry function LEN, the kind inquiry
function KIND, or a
numeric inquiry function (13.10.8), where each argument is either an
initialization expression
or a variable whose type parameters or bounds inquired about are not
assumed or defined by
an ALLOCATE statement or a pointer assignment, or

(7) An initialization expression enclosed in parentheses.


13.10.15 Array inquiry functions

ALLOCATED (ARRAY) Array allocation status
LBOUND (ARRAY, DIM) Lower dimension bounds of an array
Optional DIM
SHAPE (SOURCE) Shape of an array or scalar
SIZE (ARRAY, DIM) Total number of elements in an array
Optional DIM
UBOUND (ARRAY, DIM) Upper dimension bounds of an array
Optional DIM



----------------------------------------------------------
To unsubscribe, send to [address removed] the following
as the first and only line of the message body:
unsubscribe fortran
----------------------------------------------------------