Fortran Error # 6366: The shapes of the array expressions do not conform
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
Admin
Updated on June 07, 2022Comments
-
Admin almost 2 years
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 variablesX, Y, Z
. How come they andB
(orC
) 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
-
Steve Lionel over 10 yearsIn more detail - the compiler believes that B is an array but C, X and Y are not. Adding +B to the expression turns the entire expression into an array, but if C is not also an array of the same shape, that's an error. In cases such as this, it is more helpful to provide a small but complete example that shows the problem, rather than an excerpt or paraphrase, as these often leave out critical details.