anchor.diff:          write(iunit,1984) name, apeName(aptype), spos, ape(1), ape(2), atan2_mb(ape(1)*ape(5)+ape(6),ape(1)), &
                &         atan2_mb(ape(2),(ape(2)-ape(6))/ape(5)),   zero,   zero,   zero,   zero, ape(9), ape(10), ape(11)
        case(6) ! Racetrack
  -        write(iunit,1984) name, apeName(aptype), spos, ape(5), ape(6), ape(3), ape(4),   zero,   zero,   zero,   zero, ape(9), ape(10), ape(11)
  +        write(iunit,1984) name, apeName(aptype), spos, ape(5), ape(6), ape(3), ape(4),   zero,   zero, &
  +             zero,   zero, ape(9), ape(10), ape(11)
        end select
     end if
     return
  
positive.code: 
    ! dump info
    if(ldmpaperMem) then
       write(iunit,1984) name, apeName(aptype), spos, ape(1), ape(2), ape(3), ape(4), ape(5), ape(6), ape(7), ape(8), ape(9), ape(10), ape(11)
    else
       select case(aptype)
       case(-1) ! transition
          write(iunit,1984) name, apeName(aptype), spos, ape(1), ape(2), ape(3), ape(4), ape(5), ape(6), ape(7), ape(8), ape(9), ape(10), ape(11)
       case(0) ! not an aperture marker
          write(iunit,1984) name, apeName(aptype), spos, ape(1), ape(2), ape(3), ape(4), ape(5), ape(6), ape(7), ape(8), ape(9), ape(10), ape(11)
       case(1) ! Circle
          write(iunit,1984) name, apeName(aptype), spos, ape(1),   zero,   zero,   zero,   zero,   zero,   zero,   zero, ape(9), ape(10), ape(11)
       case(2) ! Rectangle
          write(iunit,1984) name, apeName(aptype), spos, ape(1), ape(2),   zero,   zero,   zero,   zero,   zero,   zero, ape(9), ape(10), ape(11)
       case(3) ! Ellipse
          write(iunit,1984) name, apeName(aptype), spos, ape(3), ape(4),   zero,   zero,   zero,   zero,   zero,   zero, ape(9), ape(10), ape(11)
       case(4) ! Rectellipse
          write(iunit,1984) name, apeName(aptype), spos, ape(1), ape(2), ape(3), ape(4),   zero,   zero,   zero,   zero, ape(9), ape(10), ape(11)
       case(5) ! Octagon
          ! get angles from points passing through x1,y1 and x2,y2
          ! x1=ape(1)
  
negative.code:   return
  end subroutine intersectOC
  
  subroutine intersectRT( xRay, yRay, thetaRay, xRe, yRe, aa, bb, xChk, yChk, nChk )
    ! 0.0<=thetaRay<=2pi!!!!!
    implicit none
    ! interface variables
    real(kind=fPrec) xRay, yRay, thetaRay, xRe, yRe, aa, bb, xChk, yChk, nChk
    ! temp variables
    real(kind=fPrec) xTmp(2), yTmp(2), nTmp(2)
    call intersectRE( xRay, yRay, thetaRay, xRe, yRe, xTmp(1), yTmp(1), nTmp(1) )
    call intersectEL( xRay, yRay, thetaRay, aa, bb, xRe-aa, yRe-bb, xTmp(2), yTmp(2), nTmp(2) )
    if(nTmp(1).lt.nTmp(2)) then
       xChk=xTmp(1)
       yChk=yTmp(1)
  