user1543042
user1543042

Reputation: 3440

Fortran90 Unclassified Statement While Loop

I'm trying to make a little snipett of code run in Fortran90 and I'm getting an Unclassified Statement Error with a while statement. I've looked online and could not find why this would occur with a while statement. Here is the errors I'm getting:

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)

and here is my code:

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

Upvotes: 2

Views: 823

Answers (1)

user1543042
user1543042

Reputation: 3440

I had the code

while (statement) do
  code
enddo

rather than

identifier: do while (statement)
  code
end do identifier

Upvotes: 2

Related Questions