Roland Schilling said:
>On Thu, 9 Mar 2000, I posted the following problem:
>
>> I have the following problem: I want to set-up a large PARAMETER
>> array of derived type, and I need a separate line for each element.
>> The problem now is that Fortran 90/95 only allows 39 continuation
>> lines, but I need something like 120. Any ideas how to solve this?
>
>I got two replies, by Dan Nagle and by Thorsten Ohl, both boiling
>down essentially to the same procedure: splitting up the array to
>be constructed into several smaller (<= 40 elements) subarrays and
>then concatinate them into one large array. I like this idea, but
>doesn't it mean to store the data twice in memory, once as the
>subarrays and once as the final array?
No.
Why do you think that it is stored at all? That is what variables do.
It is a constant - it is not "stored twice" any more than when you say
"X = 3 + 4" it stores "3" and "4" and "7". Or indeed, if you say
"PARAMETER(N=10000)" and then make no use of N, why should you expect
anything to be stored?
If anything needs to be stored, it will be stored at the point of use,
not at the point of declaration. Of course, this is potentially a worse
problem - particularly since loaders generally do not do constant merging
(compilers usually do, but only within one file). Think about it - an
array constant (whether named or not) is just a constant, no different from
say 3.14d0 in anything other than size. Every time you use a constant it
must be manufactured from somewhere - this includes array constants!
So if you have a module (or INCLUDE file) with this huge (named) array
constant, and ten other files use it, there are potentially ten copies
of it.
It sounds like what you might want is a module variable. A variable is only
"stored once". And a variable can be initialised piecemeal with DATA,
bypassing the limit on statement length and the clumsiness of the
sub-parameter declarations.
There is not much of an advantage to using a constant array X if all the
references to it are X(I) with I a variable.
> If this is true, and if
>there is no other solution avoiding this, I would consider this
>as a severe weakness of the present F90/95 standard.
"severe weakness"? Can we say "serious over-exaggeration"?
Anyway, the truth or otherwise is merely a matter of common implementation
technique, not a language issue.
> Is this
>going to change with F2K?
How would you like it to change? We already have variables for those who
want to have "stored values" for which there is only one copy, and constants
for those who want to build up constant expressions. I don't see the need
to add something half-way in between these.
Cheers,
--
...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
([log in to unmask])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|