if(DISDEC.gt.DISIJ.and.DISDEC.gt.DISCIJ) then ! DISCIJ is the side opposite the obtuse angle ANUM = DISIJ**2 + DISCIJ**2 - DISDEC**2 C print*,'ANUM =',ANUM,'2.0*DISIJ*DISCIJ =',2.0*DISIJ*DISCIJ ADISDEC = acosd(ANUM/(2.0*DISIJ*DISCIJ)) ! Law of Cosines to solve the obtuse angle C print*,'ADISDEC =',ADISDEC if(DISIJ.lt.DISCIJ) then ANUM = DISDEC**2 + DISCIJ**2 - DISIJ**2 ! Law of Cosines to solve the smaller angle C print*,'ANUM =',ANUM,'2.0*DISDEC*DISCIJ =',2.0*DISDEC*DISCIJ ADISIJ = acosd(ANUM/(2.0*DISDEC*DISCIJ)) C print*,'ADISIJ =',ADISIJ HAIJ(II,JJ) = 180.0 - (ADISDEC + ADISIJ) ! Then solve for the Hour angle C print*,'HAIJ(II,JJ) =',HAIJ(II,JJ) else ANUM = DISDEC**2 + DISIJ**2 - DISCIJ**2 ! Law of Cosines to solve the smaller angle HAIJ(II,JJ) = acosd(ANUM/(2.0*DISDEC*DISIJ)) ! This is the Hour angle! end if end if if(DISIJ.gt.DISDEC.and.DISIJ.gt.DISCIJ) then ! DISIJ is the side opposite the obtuse angle ANUM = DISDEC**2 + DISCIJ**2 - DISIJ**2 ADISIJ = acosd(ANUM/(2.0*DISDEC*DISCIJ)) ! Law of Cosines to solve the obtuse angle if(DISDEC.lt.DISCIJ) then ANUM = DISIJ**2 + DISCIJ**2 - DISDEC**2 ! Law of Cosines to solve the smaller angle ADISDEC = acosd(ANUM/(2.0*DISIJ*DISCIJ)) HAIJ(II,JJ) = 180.0 -(ADISIJ + ADISDEC) ! Then solve for the Hour angle else ANUM = DISIJ**2 + DISDEC**2 - DISCIJ**2 HAIJ(II,JJ) = acosd(ANUM/(2.0*DISIJ*DISDEC)) ! This is the Hour angle! end if end if if(DISCIJ.gt.DISIJ.and.DISCIJ.gt.DISDEC) then ! Use the law of cosines to solve the obtuse angle ANUM = DISIJ**2 + DISDEC**2 - DISCIJ**2 HAIJ(II,JJ) = acosd(ANUM/(2.0*DISTIJ*DISDEC)) ! This is the hour angle! end if