anchor.diff:    end if
   
     fErr = .false.
  -  call f_open(unit=fUnit,file=fName,formatted=.true.,mode="r",err=fErr,status="old")
  +  call f_open(unit=fUnit,file=fName,formatted=.true.,mode="r-",err=fErr,status="old")
     if(fErr) return
   
     bufIdx = 0
  
positive.code: #endif
  
  end subroutine abend
  #endif
  
  ! =================================================================================================
  !  K. Sjobak, V.K. Berglyd Olsen, BE-ABP-HSS
  !  Created:   2017-06
  !  Rewritten: 2019-04-15 (VKBO)
  !  Updated:   2019-04-15
  !  Subroutine to copy the last lines from a file to stderr
  !  It is mainly used just before exiting SixTrack in case there was an error.
  !  This is useful since STDERR is often returned from batch systems and BOINC.
  ! =================================================================================================
  subroutine copyToStdErr(fUnit,fName,maxLines)
  
    use parpro
    use mod_units
    use, intrinsic :: iso_fortran_env, only : error_unit
  
negative.code:   if(bufIdx > bufMax)   bufMax = bufIdx
    inBuf(bufIdx) = inLine
    szBuf(bufIdx) = lnSize
    write(crlog,"(a)") inLine(1:lnSize)
    goto 10
  
  20 continue
    flush(crlog)
    if(bufIdx > 0) then
      do i=bufIdx+1,bufMax
        write(error_unit,"(a)") inBuf(i)(:szBuf(i))
  