user3452351
user3452351

Reputation: 103

Syntax error in function arguments in fortran

I have a sub routine file as follows

subroutine grids(Ngrids,gridsize,boundx,boundy,boundz,occmatrix,myid)

  implicit NONE

  integer           i,j,k,Ngrids, occmatrix(14,14,10)
  integer           locx,locy,locz,myid
  double precision  gridsize,boundx,boundy,boundz


  do i = 1, 14
     do j = 1, 14
        do k = 1, 10
           occmatrix(i,j,k) = 0
        enddo
     enddo
  enddo

  open (13, file = 'grid_data.9deg')    
  write(*,'(A,i2)'),' READING GRID FILE ON PROC.....',myid
  read(13,*) Ngrids,gridsize
  read(13,*) boundx,boundy,boundz       
  do i = 1, Ngrids
    read(13,*) locx, locy, locz
    occmatrix(locx,locy,locz) = 1 
  enddo 
  close(13)

  return
end

It gives the following syntax error in compiling

subroutine grids(Ngrids,gridsize,boundx,boundy,boundz,occmatrix,my
                                                                  1
Error: Unexpected junk in formal argument list at (1)

It used to run well before

Upvotes: 1

Views: 2717

Answers (1)

haraldkl
haraldkl

Reputation: 3819

I would believe, your line is to long. Did you add a new argument? Your code looks like free form, but it might be the compiler tried to apply fixed form due to a .f suffix in the filename or something like that. Convince the compiler to assume free formatted source code (by compiler options or usually a .f90 suffix).

Even in free formatted files your line width is limited and you should break longer lines, which would for example look like:

subroutine grids( Ngrids,gridsize,boundx,boundy,boundz, &
  &               occmatrix,myid )

If you are stuck with fixed format you need to indicate a continuation line by a non blank character in column 6.

Here is how it looks like in fixed form:

      subroutine grids(Ngrids,gridsize,boundx,boundy,boundz,
     &                 occmatrix,myid)

Please do not use fixed form anymore! Instead, change your files to end with .f90, most compilers recognize this for free formatted code.

Upvotes: 3

Related Questions