我试图让一小段代码在 Fortran90 中运行,但我得到了一个带有 while 语句的未分类语句错误。我在网上查看过,找不到为什么会在 while 语句中发生这种情况。这是我得到的错误:
Test.f90:11.4:
while (R < MinimumEnergy) do
1
Error: Unclassifiable statement at (1)
Test.f90:15.8:
while (f < R) do
1
Error: Unclassifiable statement at (1)
Test.f90:19.11:
enddo
1
Error: Expecting END PROGRAM statement at (1)
Test.f90:23.7:
enddo
1
Error: Expecting END PROGRAM statement at (1)
这是我的代码:
program FD_Number
REAL :: MinimumEnergy = 4.5;
REAL :: a = -9;
REAL :: b = 9;
REAL R, randomN, f
REAL :: FD
FD(R) = (1 + exp(R))**(-1)
R = 0;
while (R < MinimumEnergy) do
R = 999999;
f = FD(a + (b - a)*R);
while (f < R) do
call random_number(randomN)
f = FD(a + (b - a)*randomN);
call random_number(R)
enddo
R = a + (b - a)*R;
f = FD(R);
enddo
print *, f
end