c $Header: /usr/people/flittner/radtran/tomrad/pv2.2/src/RCS/setang.f,v 2.22 2000/08/30 16:38:09 flittner Exp $ subroutine setang(adjustangle,u1,u2,u3,pres,scan,azmth,theta) c routine to set the angles for computations for sphericity of the c earth, if adjustangle=.T.. implicit none c passed logical adjustangle real*8 u1,u2,u3,pres,scan,azmth,theta c common include 'consts.cmn' c local real*8 zdef,scanp,psi,thetanotp,costhop,coscapth,cosazmth,shz logical lprt c lprt=.FALSE. shz=81.0d0 if(adjustangle)then c assume that there is a one to one correspondence between theta c and scan and will adjust in the forward direction to mimich the c spherical code using alt. of 6371+shz zdef=-6.95d0*dlog(pres) scanp=(6371.0d0+shz)/(6371.0d0+zdef)*dsin(u1*cnvrt) scanp=dasin(scanp)/cnvrt psi=scanp-u1 costhop=dcos(u3*cnvrt)*dcos(psi*cnvrt)+ &dsin(u3*cnvrt)*dsin(psi*cnvrt)*dcos(u2*cnvrt) costhop=min(costhop,1.0d0) costhop=max(costhop,-1.0d0) thetanotp=dacos(costhop)/cnvrt if(scanp .eq. 0.0d0) then azmth=u2 else if(thetanotp.eq.0.0d0)then azmth=u2 else coscapth=-dcos(u1*cnvrt)*dcos(u3*cnvrt)+ &dsin(u1*cnvrt)*dsin(u3*cnvrt)*dcos(u2*cnvrt) coscapth=min(coscapth,1.0d0) coscapth=max(coscapth,-1.0d0) cosazmth=((coscapth+dcos(scanp*cnvrt)*costhop)/ &(dsin(scanp*cnvrt)*dsin(thetanotp*cnvrt))) cosazmth=min(cosazmth,1.0d0) cosazmth=max(cosazmth,-1.0d0) azmth=dacos(cosazmth)/cnvrt endif scan=scanp theta=thetanotp else azmth=u2 thetanotp=u3 scan=u1 theta=thetanotp psi=0.0d0 endif if(lprt)then write(6,1000)'setang. scan.psi ',u1,psi write(6,1000)'setang. u2.azmth ',u2,azmth write(6,1000)'setang. theta.thetanotp',u3,thetanotp endif 1000 format(a25,2f8.2) return end