| Re: DATA statement to initialise arrays |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.fortran · Group Profile
Author: nospamnospam Date: Sep 19, 2008 10:25
dpb non.net> wrote:
> The second would be
>
> DATA NEWVAL / MXL*MXD *0 /
>
> if initialization expressions allowed "*", but they don't.
Initialization expressions allow "*" just fine. THat's why you can use
the "*" in a PARAMETER statement. But initialization expressions aren't
what are allowed in DATA.
> Note the common thread there is the parentheses aren't allowed.
There are zillions of things that aren't allowed there in DATA
statements. In fact, there are a lot more things that aren't allowed
than that are. It is a special category of syntax all on its own rather
than being a subset of a more general category such as initialization
expressions. I'd think it simpler to keep track of what is allowed
rather than with what isn't, except that...
I'd find it simplest to not keep track at all. For f90 and later (which
is to say for anything today), I far prefer using initializers in type
declaration statements. They are far more regular and mostly more
capable. Note that this is simillar to the f77 suggestion found to work
(using a PARAMETER statement). I happen to prefer the initializer on the
type declaration statement instead of in a parameter statement, but
that's a relatively monor style preference (and it does require f90);
both allow initialization expressions.
On the type declaration statement, in an f90 style, you can just do
integer :: newval (mxl,mxd) = 0
I'm assuming newval is integer; it doesn't seem to have been explicitly
declared (speaking of ways I wouldn't do things).
There are a few cases where the unique syntax of DATA allows things that
just can't be done nearly as easily with initialization in the type
declaration. But the examples here aren't in those cases. (Notable is
the ability of a DATA statement to initialize only part of an array).
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
|