Line truncated, Syntax error in argument list

Jeremy_Tamu picture Jeremy_Tamu · Dec 10, 2015 · Viewed 21.7k times · Source

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

Answer

Craig Estey picture Craig Estey · Dec 10, 2015

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.