subroutine outcoil(got,en0,x0,y0,z0,thx0,thy0,x,y,z,thx,thy) implicit none include 'const.inc' integer i double precision en0, en, lam double precision x0, y0, z0, thx0, thy0, x, y, z, thx, thy double precision gdx1, gdx2, gdx3, gdx4 double precision thtest, testx, xdis, ydis double precision ix1, ix2, ix3, ix4, iy1, iy2, iz, got parameter (ix1 = -3.0, ! cm + ix2 = -0.35, ! cm + ix3 = 0.35, ! cm + ix4 = 3.0, ! cm + iy1 = -2.5, ! cm + iy2 = 2.5, ! cm + iz = 108.) ! cm c lam = 2.*pi*h_par/sqrt(2.*m_n*en0) thtest = got*lam c if((y0.ge.iy1.and.y0.le.iy2).and.((x0.ge.ix1.and.x0.le.ix2) & .or.(x0.ge.ix3.and.x0.le.ix4))) then xdis = x0 + iz*dtan(thx0) ydis = y0 + iz*dtan(thy0) if((x0.ge.ix3.and.x0.le.ix4).and. & (xdis.lt.ix3.or.xdis.gt.ix4)) then if(abs(thx0).le.thtest) then if(thx0.ge.0) then thx = -1.*thx0 x = 2.*ix4 - iz*dtan(thx0) - x0 if(x.lt.ix3) then thx = thx0 x = 2.*ix3 - 2.*ix4 + iz*dtan(thx0) + x0 endif else thx = -1.*thx0 x = 2.*ix3 - iz*dtan(thx0) - x0 if(x.gt.ix4) then thx = thx0 x = 2.*ix4 - 2.*ix3 + iz*dtan(thx0) + x0 endif endif else x = -1.d6 thx = -1.d6 endif elseif((x0.ge.ix1.and.x0.le.ix2).and. & (xdis.lt.ix1.or.xdis.gt.ix2)) then if(abs(thx0).le.thtest) then if(thx0.ge.0) then thx = -1.*thx0 x = 2.*ix2 - iz*dtan(thx0) - x0 if(x.lt.ix1) then thx = thx0 x = 2.*ix1 - 2.*ix2 + iz*dtan(thx0) + x0 endif else thx = -1.*thx0 x = 2.*ix1 - iz*dtan(thx0) - x0 if(x.gt.ix2) then thx = thx0 x = 2.*ix2 - 2.*ix1 + iz*dtan(thx0) + x0 endif endif else x = -1.d6 thx = -1.d6 endif else thx = thx0 x = xdis endif if( (y0.ge.iy1.and.y0.le.iy2) .and. & (ydis.lt.iy1.or.ydis.gt.iy2) ) then if(abs(thy0).le.thtest) then thy = -1.*thy0 if(thy0.ge.0.) then y = 2.*iy2 - iz*dtan(thy0) - y0 else y = 2.*iy1 - iz*dtan(thy0) - y0 endif else y = -1.d6 thy = -1.d6 endif else thy = thy0 y = ydis endif z = z0 + iz else x = -1.d6 y = -1.d6 z = -1.d6 thx = -1.d6 thy = -1.d6 endif return end