> I wrote:
> ...
> > > Having just said that (based on vaguely remembered discussions
> > > in the newsgroup) I can't actually find the feature in the proposed
> > > document. Did I misremember, or is there somewhere in the
> > > document I need to look?
> >
> > Type parameters are discussed in 4.2, starting on page 32. Character type
> > is defined to have a nonkind type parameter LEN at [32:13-14]. At [32:16ff]
> > we see the syntax for declaring a "deferred type parameter" and restrictions
> > on it. In the discussion of the ALLOCATE statement in 6.3.1, starting on
> > page 108, we see that one can put a type-spec, in which one has to specify
> > type parameter values if the type has any parameters. The constraint at
> > [32:20-21] prevents these from being colons, so the only possibilities are
> > integers and asterisk. An integer expression has an obvious interpretation.
> > Asterisk means "get the value from the corresponding parameter of the actual
> > argument corresponding to the dummy argument."
> >
> > Does that explain it?
and James Giles <[log in to unmask]> wrote:
> Well, no. Unless all this means that character strings cannot have
> dynamic length. The description of the ALLOCATE statement you
> refer to contains the constraint [109:14-15] that the type specs in the
> ALLOCATE statement must agree with the type specs declared for
> each object it's applied to. So, if the LEN specified in the declaration
> of the object name is N, the LEN specified in the ALLOCATE statement
> must also be the same N. Or am I still misreading it? Another instance
> where an example would seem appropriate.
I think you're looking at Constraint 626, which refers to kind parameters.
LEN is a nonkind parameter. Look at [32:24-26] and [109:36-41]. These mean
that you can allocate a character with a length determined dynamically and
specified in the allocate statement, so long as it is declared to have a
deferred length, i.e., specified by a colon, and it has either the pointer
or allocatable attribute:
character(len=:), allocatable :: C
...
allocate ( character(len=42) :: C )
--
Van Snyder | What fraction of Americans believe
[log in to unmask] | Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or disapproved
by JPL, CalTech, NASA, Sean O'Keefe, George Bush, the Pope, or anybody else.
|