行截断,参数列表中的语法错误

时间:2020-12-29 22:42:42

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

当我编译下面的程序时,在调用Coor_Trans命令行as中有一个错误和一个警告

Warning: Line truncated

警告:线截断

Error: Syntax error in argument list

错误:参数列表中的语法错误。

I compile the program several times, but it does not work. Maybe there is something wrong with my call command.

这个程序我编译了好几次,但都不起作用。也许我的呼叫命令有问题。

program 3D

      implicit none
      integer :: i,j,k
      integer, parameter :: FN=2,FML=5,FMH=5
      integer, parameter :: NBE=FN*FML*FMH
      real, parameter :: pi = 4*atan(1.0)
      real(kind=4), dimension(1:FN,1:FML+1,1:FMH+1) :: BEXL,BEYL,BEZL
      real(kind=4), dimension(1:FN,1:FML,1:FMH) :: BEXC,BEYC,BEZC,BE2A,BE2B,ANGLE
      real(kind=4), dimension(1:NBE,1:1,1:1) :: BEXC1,BEYC1,BEZC1,BE2A1,BE2B1,ANGLE1
      real(kind=4), dimension(1:NBE,1:NBE) :: LOC_PTS1,LOC_PTS2,LOC_PTS3
      real :: LOC_1,LOC_2,LOC_3

      do i=1,FN
        do j=1,FML
           do k=1,FMH

            BEXC(i,j,k) = 0.5*(BEXL(i,j,k) + BEXL(i,j+1,k))
            BEYC(i,j,k) = 0.5*(BEYL(i,j,k) + BEYL(i,j+1,k))
            BEZC(i,j,k) = 0.5*(BEZL(i,j,k) + BEZL(i,j,k+1))
            BE2A(i,j,k) = FL(i)/FML + j*0 + k*0
            BE2B(i,j,k) = FH(i)/FMH + j*0 + k*0
            ANGLE(i,j,k) = BETA(i) + j*0 + k*0

           end do
        end do
      end do

      BEXC1 = reshape(BEXC,(/NBE,1,1/))
      BEYC1 = reshape(BEYC,(/NBE,1,1/))
      BEZC1 = reshape(BEZC,(/NBE,1,1/))
      BE2A1 = reshape(BE2A,(/NBE,1,1/))
      BE2B1 = reshape(BE2B,(/NBE,1,1/))
      ANGLE1 = reshape(ANGLE,(/NBE,1,1/))

      do i=1,NBE
        do j=1,NBE

            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)
            LOC_PTS1(i,j) = LOC_1
            LOC_PTS2(i,j) = LOC_2
            LOC_PTS3(i,j) = LOC_3

        end do
      end do

    end program 3D

      subroutine Coor_Trans(GLOB_PTSX1,GLOB_PTSY1,GLOB_PTSZ1,GLOB_PTSX2,GLOB_PTSY2,GLOB_PTSZ2,BETA,LOC_PTS1,LOC_PTS2,LOC_PTS3)

      implicit none
      real(kind=4), intent(in) :: GLOB_PTSX1,GLOB_PTSY1,GLOB_PTSZ1,GLOB_PTSX2,GLOB_PTSY2,GLOB_PTSZ2,BETA
      real(kind=4), intent(out) :: LOC_PTS1,LOC_PTS2,LOC_PTS3
      real, parameter :: pi = 4*atan(1.0)
      real :: E1,E2
      E1 = cos(BETA/180*pi)
      E2 = sin(BETA/180*pi)
      LOC_PTS1 = (GLOB_PTSX1-GLOB_PTSX2)*E1 + (GLOB_PTSY1-GLOB_PTSY2)*E2
      LOC_PTS2 = (GLOB_PTSZ1-GLOB_PTSZ2)
      LOC_PTS3 = -(GLOB_PTSX1-GLOB_PTSX2)*E2 + (GLOB_PTSY1-GLOB_PTSY2)*E1
      !return

      end subroutine Coor_Trans

2 个解决方案

#1


5  

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

你的通话时长太长了。一条线的默认最大宽度是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.

编译器将在这个宽度上截断输入行(就像它所做的那样——并在警告下这样说)。之后,您有一个不完整的行(例如调用foo(a,b,没有关闭),它生成第二个警告消息。

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.

大多数c样式的指南建议将行保持在<= 80字符。在我看来,这是一个很好的练习,即使是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

注意,使用GNU fortran,您可以使用-ffree-line-length- 命令行选项来增加限制。所以,你可以尝试-ffree-line-length-512,但是,我将继续上面的内容。

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

历史脚注:132列是一个高速,链驱动,链轮进给,扇折纸,行打印机可以打印的最大宽度。

#2


3  

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:

Fortran标准对编译器需要处理的行长度进行了限制,目前它有132个字符。您可以在适当的位置中断行并使用延续行。是这样的:

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.

注意到在继续行末尾的& at。

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.

您的编译器可能有一个选项来强制它读更长的行。

#1


5  

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

你的通话时长太长了。一条线的默认最大宽度是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.

编译器将在这个宽度上截断输入行(就像它所做的那样——并在警告下这样说)。之后,您有一个不完整的行(例如调用foo(a,b,没有关闭),它生成第二个警告消息。

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.

大多数c样式的指南建议将行保持在<= 80字符。在我看来,这是一个很好的练习,即使是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

注意,使用GNU fortran,您可以使用-ffree-line-length- 命令行选项来增加限制。所以,你可以尝试-ffree-line-length-512,但是,我将继续上面的内容。

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

历史脚注:132列是一个高速,链驱动,链轮进给,扇折纸,行打印机可以打印的最大宽度。

#2


3  

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:

Fortran标准对编译器需要处理的行长度进行了限制,目前它有132个字符。您可以在适当的位置中断行并使用延续行。是这样的:

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.

注意到在继续行末尾的& at。

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.

您的编译器可能有一个选项来强制它读更长的行。