title: Fortran compilation error - undefined reference
body: <p>I am trying to compile a fortran program which uses a bunch of modules. I obtain an error when I compile it, and it's driving me crazy. The error is originated by the addition of one subroutine and takes place when I try to recompile the program:</p>
  
  <p>Main program contains these two lines:</p>
  
  <p>--</p>
  
  <pre><code>call read_step(nStepOne,molOne)
  call read_step(nStep,mol)
  </code></pre>
  
  <p>--</p>
  
  <p>This is calling one of the subroutines in a file "fileio.f90":</p>
  
  <p>--</p>
  
  <pre><code>subroutine read_step(n,tape)
  
  implicit none
  
  integer, intent(in) :: tape
  integer, intent(out) :: n
  
  character(len=6) :: dum
  
  rewind(tape)
  read (tape,*)
  read (tape,*) dum, n
  rewind(tape)
  return
  !
  end subroutine read_step
  </code></pre>
  
  <p>--</p>
  
  <p>When I try to compile it, the following error arises:</p>
  
  <pre><code>ifort -o SpIdMD.x *.o -static-intel -openmp 
  SpIdMD.o: In function `MAIN__':
  SpIdMD.f90:(.text+0x3b2): undefined reference to `read_step_'
  SpIdMD.f90:(.text+0x3c5): undefined reference to `read_step_'
  make: *** [SpIdMD.x] Error 1
  </code></pre>
  
  <p>Other calls to subroutines in the same module did not give any error, and I just don't see any difference between the calls to the "old subroutines" and the one I just created.</p>
  
  <p>An example of one of these "old subroutines", which does not give any complaint, is:</p>
  
  <p>In the main program:</p>
  
  <pre><code>call get_dim(n_atom,nSnap,mol)
  </code></pre>
  
  <p>In the fileio.f90:</p>
  
  <pre><code>subroutine get_dim(n,n_snap,tape)
  
  implicit none
  
  integer,intent(in) :: tape
  integer,intent(out) :: n, n_snap
  integer :: m
  
  rewind(tape)
  read (tape,*,err=1,end=2) n
  rewind(tape)
  
  m = 0
  do while (.true.)
     read (tape,*,err=1,end=3)
     m = m +1
  end do
  3   n_snap = m/(n + 2)
  if (m.ne.(n_snap*(n + 2))) stop  'unexpected end of input file'
  
  rewind(tape)
  
  return
  !
  1   stop 'error in input file'
  2   stop 'unexpected end of input file'
  end subroutine get_dim
  </code></pre>
  
  <p>I have absolutely no idea why this behavior. I'd be grateful if anybody could help me solve this nightmare. Thanks!</p>