      PROGRAM ALTAZ
C
C     Converts altitude and azimuth to hour angle and declination
C
      IMPLICIT UNDEFINED (A-Z)
C                                  atitude of Mt. Wilson.
      REAL *4 LAT, PI, RAD
      PARAMETER ( LAT = 34.2166944 )
      PARAMETER ( PI  = 3.1415926535 )
      PARAMETER ( RAD = 180. / PI )
      REAL *4 ALT, AZ, HA, DEC, CL, SL, CH, SD
      INTEGER *4 IERR
      CL = COS( LAT / RAD )
      SL = SIN( LAT / RAD )
  100 CONTINUE
          WRITE(6,*) ' INPUT ALTITUDE AND AZIMUTH '
          READ(5,*,iostat=ierr) ALT, AZ
          IF ( IERR .NE. 0 ) GO TO 200
          SD = SIN(ALT/RAD)*SL + COS(ALT/RAD)*CL*COS(AZ/RAD)
          DEC = RAD * ASIN ( SD )
          CH = ( SIN(ALT/RAD) - SD*SL ) / ( COS(DEC/RAD) * CL )
          HA = RAD * ACOS ( CH )
          IF ( AZ .LT. 0 ) HA = - HA
          WRITE(6,1200) DEC, HA
      GO TO 100
  200 CONTINUE
      STOP
 1200 FORMAT ( ' DEC = ', F8.4, ' H.A. = ', F8.4 )
      END
