Fortran “Error: The shapes of the array expressions do not conform.”

試著忘記壹切 提交于 2021-02-17 06:35:11

问题


I know someone has asked a similar question. It said that the error maybe come from trying to assign an array to a scalar. I checked my program again and again as it said but I really don't find any wrong with my program.

The specific error message is:

D:\src\fortran\Kramers\kramers.f90(54) : Error: The shapes of the array expressions do not conform. [Y2] y2(1)=sqrt(2.0d0*T)*[h*omega(2)-h1*omega(3)+h1*h*omega(4)-h1*h1*omega(6)+& ----------------^
D:\src\fortran\Kramers\kramers.f90(65) : Error: The shapes of the array expressions do not conform. [Y2] y2(2)=sqrt(2.0d0*T)*[omega(1)-h*omega(2)+h*h*omega(3)-h1*h*omega(4)+h1*h1*omega(6)+& ----------------^
Error executing df.exe.

kramers.obj - 2 error(s), 0 warning(s)

This is the part of my program which causes the error:

real*8 :: y(2),y2(2),omega(10),V4

real*8 :: h,h1,T,ngt

real*8,external :: V,V1,V2,V3

y2(1) = sqrt(2.0d0*T)*[h*omega(2) - h1*omega(3) + h1*h*omega(4) - h1*h1*omega(6) + &
    (-h1*h*omega(4) + 2.0d0*h1*h1*omega(6))*V2(y(1)) - h1*h1*y(2)*omega(10)*V3(y(1))]

y2(2) = sqrt(2.0d0*T)*[omega(1) - h*omega(2) + h*h*omega(3) - h1*h*omega(4) + h1*h1*omega(6) + &
    (-h*h*omega(3) + 2*h1*h*omega(4) - 3*h1*h1*omega(6))*V2(y(1)) + &
    (-h1*h*y(2)*omega(5) + h1*h1*y(2)*omega(7) + h1*h1*y(2)*omega(8) + h1*h1*y(2)*omega(10))*V3(y(1)) + &
    h1*h1*V2(y(1))*V2(y(1))*omega(6) + h1*h1*V1(y(1))*V3(y(1))*omega(8) - 0.5d0*h1*h1*V4*y(2)*y(2)] - h1*h*T*V3(y(1))*ngt

回答1:


You use square brackets [] which denote an array constructor. You have to use normal ones ().



来源:https://stackoverflow.com/questions/12956888/fortran-error-the-shapes-of-the-array-expressions-do-not-conform

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!