Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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: Unclassifiable 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
like image 666
disruptive Avatar asked Aug 04 '11 11:08

disruptive


People also ask

How do I continue a line in Fortran 90?

A line of Fortran 90 code can have a maximum of 132 characters. An ampersand (&) is placed at the end of a line to indicate that it continues on the next line. At most 39 continuation lines are permitted.

How do I print on the same line in FORTRAN?

"write (file_number,format_spec,advance='no') variable_name" - But if you use the defualt format * then it automatically writes multiple variables (in a single write staement) on the same line if possible. As in "write (*,*) a,b,c", variables a,b and c are all written on the same line.

How do I continue a statement in next line in FORTRAN?

In Fortran, a statement must start on a new line. If a statement is too long to fit on a line, it can be continued with the following methods: If a line is ended with an ampersand, &, it will be continued on the next line. Continuation is normally to the first character of the next non-comment line.


1 Answers

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.

like image 107
Deditos Avatar answered Oct 20 '22 00:10

Deditos