subroutine ellipse (hm,edm,hc,ed,dndh,xc,yc,a,b) c s/r to determine the parameters of an ellipse c [(x-xc)/a]**2 + [(y-yc)/b]**2 = 1 c which is tangential to a layer peak at (hm,edm) and has a c specified electron density (ed) and slope (dndh) at a height hc c c written by leo mcnamara 4-aug-87 c----- last modified 5-aug-87 c dhdn = 1. / dndh ccc type*,' ELLIPSE c/s ',hm,edm,hc,ed,dndh yc = hm top = (ed-edm) * (hc-yc) - dhdn * (ed-edm) ** 2 bot = (hc-yc) - 2. * dhdn * (ed-edm) a = top / bot ccc type*,' top,bot,a ',top,bot,a b2 = -a * a * dhdn * (hc-yc) / (ed-edm-a) c if there is no solution, set a < 0 b = b2 if(b2.le.0.) return b = sqrt (b2) xc = edm + a ccc type*,' ELLIPSE results ',xc,yc,a,b c return end