开发者

Multiple statements on same line in FORTRAN 90

I have a whole series of assignments which I have put on the same ike using a ";" to seperate the statemnts but I get this error:

1.0; lb(1,9) 1 Error: Unclassifiab开发者_运维技巧le statement at (1) In file LJ.F90:223

I do not understand where there is coming from, when I have the code working if each statement is on its own line. The code is really simple...

What am I stupidly doing wrong.. below code is all on one line.

lb(1,1) = 1.0; lb(1,2) = 1.0; lb(1,3) = 1.0; lb(1,4) = 1.0; lb(1,5) = 1.0; lb(1,6) = 1.0; lb(1,7) = 1.0; lb(1,8) = 1.0; lb(1,9) = 1.0


Your line of code is 134 characters long and, even with Fortran 90-style free format code, most compilers impose a maximum line length. For example, with Sun Studio the default limit is 132 characters.

You can usually increase this character limit using compiler flags, but I suggest splitting that code so that you have one statement per line. It is more legible to human readers and compile- and run-time error messages may be more easily diagnosed.


Adding to the comments of @Deditos, in this case you could use Fortran array notation to reduce the number of lines since all of the elements are being set to the same value:

lb (1, 1:9) = 1.0

Are all elements of the array being initialized to 1.0? Then simply:

lb = 1.0
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜