Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

fortran - Line truncated, Syntax error in argument list

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: 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...