Reputation: 51
I encountered this error message while compiling one of my Fortran codes. I found a few similar posts regarding the same error, but none of the situations in those posts apply to my case. I would appreciate any answer or help offered here. Thanks in advance!
(The code is really long, so I only cut out those sentences that are relevant.)
===================================================
DIMENSION A(20), COORDS(3)
REAL B, C, X, Y, Z
B = 1.0
X = COORDS(1)
Y = COORDS(2)
Z = COORDS(3)
DO I = 1,3
A(I) = COORDS(I)
END DO
C = SQRT ( X**2.0 + Y**2.0 ) + B
===================================================
The error message points to the last line:
error #6366: The shapes of the array expressions do not conform. [C
]
If I comment out + B
, then no error occurs.
I just don't get it. The elements of the array COORDS
are passed on to scalar variables X, Y, Z
. How come they and B
(or C
) are not conformable?
I know there must be something I don't quite understand about Fortran array. Please point out my mistake if you catch any.
Thanks a lot!
Justin
Upvotes: 5
Views: 19109
Reputation: 29401
Is there a dimension
statement elsewhere in the code for any of these variables? The error message seems to point to C
; that commenting out +B
eliminates the error seems to more solidly point to B
.
This is why I like to have all characteristics of a variable declared on a single line. e.g.,
real, dimension (20) :: a
instead of:
dimension A(20)
real A
Upvotes: 3