(j3.2006) Question about constant expressions with len typeparameters

Malcolm Cohen malcolm
Mon Feb 16 22:50:40 EST 2015

Ages ago, Bill Long asked (and I didn't see a reply...):
For a type definition

  type foo (n)
     integer,len :: n
     real :: a(1:n)
  end type
it is allowed to declare a named constant like this:

   type(foo(3)),parameter ::  c = foo(3)(a = [1.0,2.0,3.0])


The rules for constant expressions say you can rely on the value of a previously 
defined KIND type parameter, but the case for a LEN parameter seems less 

I see no "rely"ing on anything here, the expression contains no reference to the 
value of any length type parameter.

This would not seem to be different from
    CHARACTER(LEN=17),PARAMETER :: CH = 'abcdeghijklmnopqr'
or indeed
   REAL,PARAMETER :: X(3) = [ 1.0,2.0,.30]
(it being that array bounds are more like LEN type parameters than they are like 
KIND type parameters).

................................Malcolm Cohen, Nihon NAG, Tokyo. 

More information about the J3 mailing list