1

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

2
  • How do you compile, what suffix does your file have? Commented Sep 7, 2015 at 12:19
  • What is the extension of your file? Depending on the extension, the compiler might ignore everything else after a certain column number. Please see: stackoverflow.com/questions/24335487/… Commented Sep 7, 2015 at 12:26

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.