Line truncated, Syntax error in argument list

后端 未结 2 1641
花落未央
花落未央 2020-11-29 12:08

When I compile the program below, I have an error and a warning in the call Coor_Trans command line as

Warning: Line truncated

Error:

相关标签:
2条回答
  • 2020-11-29 12:15

    The Fortran standard imposes a limit on the length of line that compilers are required to deal with, these days it's 132 characters. You can break the line at a suitable place and use a continuation line. Something like this:

    call Coor_Trans(BEXC1(i,1,1),BEYC1(i,1,1),BEZC1(i,1,1),BEXC1(j,1,1), &
         BEYC1(j,1,1),BEZC1(j,1,1),ANGLE1(j,1,1),LOC_1,LOC_2,LOC_3)
    

    Notice the & at the end of the continued line.

    Once the line is truncated arbitrarily it is syntactically erroneous, which explains the second part of your compiler's complaint.

    Your compiler probably has an option to force it to read longer lines.

    0 讨论(0)
  • 2020-11-29 12:19

    The length of your call statement is too long. The default maximum width of a line is 132.

    The compiler will truncate input lines at that width [as it did--and said so with the warning]. After that, you had an incomplete line (e.g. call foo(a,b that was missing the closing )) which generated the second warning message.

    The best solution is to break up the long line with a continuation character, namely &:

                call Coor_Trans(BEXC1(i,1,1),BEYC1(i,1,1),BEZC1(i,1,1), &
                                BEXC1(j,1,1),BEYC1(j,1,1),BEZC1(j,1,1), &
                                ANGLE1(j,1,1),LOC_1,LOC_2,LOC_3)
    

    Most C-style guides recommend keeping lines at <= 80 chars. IMO, that's a good practice even with fortran.

    Note, with GNU fortran, you can increase the limit with the -ffree-line-length-<n> command line option. So, you could try -ffree-line-length-512, but, I'd do the continuation above

    Historical footnote: 132 columns was the maximum width that a high speed, chain driven, sprocket feed, fanfold paper, line printer could print.

    0 讨论(0)
提交回复
热议问题