anchor.diff:  !  K. Sjobak, V.K. Berglyd Olsen, BE-ABP-HSS
   !  Last modified: 09-2017
   ! =================================================================================================
  -real(kind=fPrec) function scatter_generator_getCrossSection(idPro, genID, x, y, xp, yp, E)
  +real(kind=fPrec) function scatter_generator_getCrossSection(idPro, idGen, x, y, xp, yp, E)
   
     use string_tools
     use crcoall
   
     implicit none
   
  -  integer,          intent(in) :: idPro, genID
  +  integer,          intent(in) :: idPro, idGen
     real(kind=fPrec), intent(in) :: x, y, xp, yp, E
   
     ! Temporary variables
  
positive.code: #ifdef HDF5
    use hdf5_output
  #endif
  
    use collimation, only : do_coll, scatterhit, part_hit_pos, part_hit_turn
  
    implicit none
  
    integer, intent(in) :: iElem, ix, turn
  
    ! Temp variables
    integer          idElem, idPro, nGen, idGen, iError
    integer          i, j, k, iLost, nLost(9), nScatter(9), procID
    integer          tmpSeed1, tmpSeed2
    logical          isDiff, updateE, hasProc(9)
    real(kind=fPrec) s, t, dEE, dPP, theta, theta2
    real(kind=fPrec) crossSection, N, P
    real(kind=fPrec) rndPhi(napx), rndP(napx)
    real(kind=fPrec) scaling
  
    logical, allocatable :: pLost(:)
    logical, allocatable :: pScattered(:)
  
  #ifdef HDF5
    ! For HDF5 it is best to write in chuncks, so we will make arrays of size napx
    integer                 :: iRecords(3,napx)
    real(kind=fPrec)        :: rRecords(8,napx)
    character(len=mNameLen) :: cRecords(3,napx)
    integer                 :: nRecords
  #endif
  
    idElem  = scatter_elemPointer(ix)
    idPro   = scatter_elemList(idElem)%profileID
    scaling = scatter_elemList(idElem)%elemScale
    nGen    = size(scatter_elemList(idElem)%generatorID,1)
  
    ! if(scatter_debug) then
    !   write(lout,"(a)")       "SCATTER> DEBUG In scatter_thin"
    !   write(lout,"(a,i0)")    "SCATTER> DEBUG  * ix      = ",ix
    !   write(lout,"(a)")       "SCATTER> DEBUG  * bez     = '"//trim(bez(ix))//"'"
    !   write(lout,"(a,i0)")    "SCATTER> DEBUG  * napx    = ",napx
    !   write(lout,"(a,i0)")    "SCATTER> DEBUG  * turn    = ",turn
    !   write(lout,"(a,e13.6)") "SCATTER> DEBUG  * scaling = ",scaling
    ! end if
  
    if(scaling <= pieni) then
      ! Skip the whole thing if the scaling is zero
      return
    end if
  
  
negative.code: 
      ! Write Attributes
      call h5_writeAttr(h5_scatID,"SEED",scatter_seed1)
    else
  #endif
  
    ! Open scatter_log.dat
  