Reputation: 66
My program starts like
implicit real*8 (a-h,o-z)
parameter (pi=3.141592654)
real*4 yfl
real*4 zz0(20),a0(20),fr0(20)
real*4 par_ion(6)
but I later get error messages such as the below.
data fr0/0.780,0.209,0.009,3*0./ ! fraction by mass for elemen
1
Error: DATA statement at (1) has more variables than values
music-atmosphere-100gev.f:82.10:
data a0/14.0097,15.9994,39.948,3*0./ ! atomic weights for elem
1
Error: DATA statement at (1) has more variables than values
music-atmosphere-100gev.f:81.10:
data zz0/7.,8.,18.,3*0./ ! atomic numbers for elements in atmos
1
Error: DATA statement at (1) has more variables than values
Can anyone help me figure out what is going on here?
Upvotes: 1
Views: 1958
Reputation: 18098
From
real*4 zz0(20),a0(20),fr0(20)
You can see that fr0
, a0
, and zz
have a dimension of 20
. So the correct initialization(s) should read:
data fr0/0.780,0.209,0.009,17*0./
data a0/14.0097,15.9994,39.948,17*0./
data zz0/7.,8.,18.,17*0./
This way, you assign arrays of length 20 (three values and 17 times zero) instead of the previous length-6 arrays.
Upvotes: 4
Reputation: 32366
When using a data
statement for explicit initialization it is required that the number of elements in the two parts (the variables before the first /
and the values between the two /
s) be the same.
In this case a whole array is given for each first part so each list there consists of all of the elements of the corresponding array (of which there are twenty). Therefore, there must be twenty elements of values (as Alexander Vogt gives).
To add to that answer, though, it isn't erroneous not to initialize the whole array. One could instead have
data fr0(1:6)/0.780,0.209,0.009,3*0./
which provides explicit initialization for the first six elements of fr0
. [In this case fr0
as an array isn't defined initially, just its first six elements.] This is useful when one has a long lump of initialization to do:
data fr0(1:6)/0.780,0.209,0.009,3*0./
data fr0(7:12)/0.780,0.209,0.009,3*0./
...
etc., or if one really cares only about the first six elements (say when the lengths varies between compilations, but the first elements are important)
Upvotes: 3