简体   繁体   English

数据声明中的fortran循环语法错误

[英]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. 我是Fortran的新手,对此进行了一些修改,但不确定我的编码有什么问题。

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

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: 并且此代码看起来像是直接从http://www.esm.psu.edu/~ajm138/fortranexamples.html获取的,因此您在键入时必须始终按下错误的键。您可能需要更改:

 A(I) = 0.0E0

to

print *, I

so you can see the output of your example code. 这样您就可以看到示例代码的输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM