Print

Print


Shareef Siddeek wrote:
> The DATA module is a set of input fixed values to the program.
> Generally it is placed above the main program source codes. It looks
> like this: 
> 
> module moddata
> implicit none
> save
> !
> real, parameter::A =0.18
> real, dimension(2,18)::B = reshape((/0.000,    0.003,    0.171,
> 0.508,    0.271,    0.047,    0.001,    0.000,    0.000,    0.000,
> 0.000,    0.000,    0.000,    0.000,    0.000,    0.000,    0.000,
> 0.000,&
> 0.000,    0.000,    0.003,    0.171,    0.508,    0.271,    0.047,
> 0.001,    0.000,    0.000,    0.000,    0.000,    0.000,    0.000,
> 0.000,    0.000,    0.000,    0.000),(/2,18/))
> ....................................... etc.
> !
> end module moddata

This is one of the few cases where the DATA statement is 
appropriate.  It allows you to initialize a large array using
multiple statements instead of trying to do it all in a single
initialization expression.  So:

   real :: X(100,18)
   data (X(1,J), J=1,18) / 0.000, ... total of 18 values /
   data (X(2,J), J=1,18) / 0.000, ... 18 more values /
   ... total of 100 statements ...

Note that with the implied loops you can initialize in any 
order you like.  This one was just more convenient to initialize 
row-wise.

The DATA statement is the only really convenient way to 
initialize with really large amounts of information.  Other ideas 
are suggested to the committee from time to time, but none 
have been more than curiosities.

-- 
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies."   --  C. A. R. Hoare