function datan(y,x) * * Calculate four quadrants of phi from y and x * Return answer in degrees c DATAN runs from 0 to 360 c It is 0 for (x,y)=(1,0), 90 for (x,y)=(0,1) * real x,y,phi,pi pi=acos(-1.) if(x.ne.0)then phi=180*atan(y/x)/pi if(y.ge.0)then if(x.ge.0)then datan=phi else datan=phi+180 endif else if(x.ge.0)then datan=phi+360 else datan=phi+180 endif endif else if(y.ge.0)then datan=90 else datan=270 endif endif *print *,x,y,datan end