Print

Print


Until today, I have used the following hack to declare PARAMETER
arrays with DIMENSION(N), where N can be 0.

module foo
  integer, dimension(0), parameter :: bar0 = reshape ((/ 0 /), (/ 0 /))
  integer, dimension(1), parameter :: bar1 = reshape ((/ 1, 0 /), (/ 1 /))
end module foo

This is done by an automatic code generator, where uniformly adding
the sentinel 0 is more convenient than treating the special case.

Today I have learned that Compaq has recently `fixed' their compiler
(Compaq Fortran X5.3-1155) and that my users can't compile their code
anymore.  E.g.:

  integer, dimension(6,64), parameter, private :: table_spin_states = &
    reshape ( (/ s0001, s0002, s0003, s0004, s0005, s0006, s0007, s0008, s0009, &
    s0010, s0011, s0012, s0013, s0014, s0015, s0016, s0017, s0018, s0019, &
    s0020, s0021, s0022, s0023, s0024, s0025, s0026, s0027, s0028, s0029, &
    s0030, s0031, s0032, s0033, s0034, s0035, s0036, s0037, s0038, s0039, &
    s0040, s0041, s0042, s0043, s0044, s0045, s0046, s0047, s0048, s0049, &
    s0050, s0051, s0052, s0053, s0054, s0055, s0056, s0057, s0058, s0059, &
    s0060, s0061, s0062, s0063, s0064, 0 /), (/ 6, 64 /) )

  f90: Error: eebb.f90, line 180: The shapes of the array expressions do
     not conform. [TABLE_SPIN_STATES]

However, reading from scripture

> 	  13.14.90          RESHAPE (SOURCE, SHAPE [, PAD, ORDER])
> 
> Description. Constructs an array of a specified shape from the
> elements of a given array.
> 
> Class. Transformational function.
> 
> Arguments.
> 
> SOURCE may be of any type.  It shall be array valued.  If PAD is
> absent or of size zero, the size of SOURCE shall be greater than or
> equal to PRODUCT (SHAPE).  The size of the result is the product of
> the values of the elements of SHAPE.
> 
> SHAPE shall be of type integer, rank one, and constant size.  Its size
> shall be positive and less than 8.  It shall not have an element whose
> value is negative.

tells me that by code is correct.  Pragmatically, I have
to fix my code generator anyway, because my users have no other
compiler on their Alphas.  Nevertheless, I'd like to know whether my
interpretation is correct :-).

Cheers,
-Thorsten
-- 
Thorsten Ohl, Physics Department, TU Darmstadt -- [log in to unmask]
http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here]


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%