	implicit real*8 (a-h,o-z)
	xp=190.
	yp=0.
	call dewarp(x,y,xp,yp)
	write(6,12) x,y,xp,yp
12	format('FINAL',4f10.3)
	stop
	end

C warp subroutine:
	subroutine dewarp(xin,yin,xout,yout)
	implicit real*8 (a-h,o-z)
C These are Sam's estimage of the radius from the pupil to the focal
C surface
	data rfocal/5675.2/

C
C What is the actual orthogonal distance that we want from the
C radius vector to the top of the fiber.
	din=dsqrt(xin**2+yin**2)
C The following were modified as per Sam's 13 March note
C re the "mid radius" where length is conserved....

	if(din.lt.151.9325) then
	reff=5679.881
	else
	temp=din*400.
	reff=5670.799 + temp*(2.988726e-4 - 2.458933e-9 * temp)
C Note that Sam's equation was in terms of encoder units.
	end if
C Great.  Now, what is the distance we want along the plate prior to
C being warped?
	dout=reff*dasin(din/rfocal)
	write(6,*) reff,r,din,dout,din/dout
C Now make sure that the proportions work out:
	xout=0.
	yout=0.
	if(din.gt.0.) then
	yout=(dout/din)*yin
	xout=(dout/din)*xin
	end if
Cwrite(9,1234) din,dout,reff,rfocal,xin,xout,yin,yout
1234	format('Din='f10.3,' Dout=',f10.3,' reff=',f10.3, 'rfoc=',
     &  f10.3,'xin,out; yin,out=',f10.3)
	return
	end
