Johnny 3653925
Johnny 3653925

Reputation: 769

fortran loop syntax error in data declaration

I'm new to fortran and been hacking at this for a bit but not sure what is wrong with my coding.

The error I'm seeing is:

Error: Syntax error in data declaration at (1)


PROGRAM MAIN
    INTEGER I. I_START. I_END. I_INC
    REAL A(100)

    I_START = 1
    I_END = 100
    I_INC = 1

    DO I = I_START, I_END, I_INC

       A(I) = 0.0E0

    END DO

END

Upvotes: 1

Views: 3060

Answers (1)

jbrahy
jbrahy

Reputation: 4425

The syntax error you're seeing is on the integer declaration.

    INTEGER I. I_START. I_END. I_INC

should be

    INTEGER I, I_START, I_END, I_INC

and the updated program should look like this

    PROGRAM MAIN
        INTEGER I. I_START. I_END. I_INC
        REAL A(100)

        I_START = 1
        I_END = 100
        I_INC = 1

        DO I = I_START, I_END, I_INC

           A(I) = 0.0E0

        END DO

    END

and this code looks like it's taken directly from http://www.esm.psu.edu/~ajm138/fortranexamples.html so you must have consistently hit the wrong key while typing it in. You might want to change:

 A(I) = 0.0E0

to

print *, I

so you can see the output of your example code.

Upvotes: 1

Related Questions