      SUBROUTINE PRECESS(J0,J1,RA0,DC0,RA1,DC1)
C
C     PRECESS FROM JULIAN INITIAL EPOCH J0 TO JULIAN FINAL EPOCH J1
C     (IN THE FK5 SYSTEM) AN OBJECT WITH RIGHT ASCENSION RA0 AND
C     DECLINATION DC0.  EPOCHS ARE GREGORIAN YEAR AND FRACTION, AND
C     ALL ANGLES ARE IN RADIANS.
C
C     B. KNAPP, 1993-06-17, 2001-01-02
C
C     BASED ON THE ALGORITHM OF J. H. LIESKE ET AL, ASTRONOMY AND
C     ASTROPHYSICS, VOL 58, PP 1-16 (1977), AS PRESENTED IN SKY AND
C     TELESCOPE, VOL 82, PP 408-410 (OCT 1991).
C
C     THE PRECESSION MATRIX DEPENDS ONLY ON J0 AND J1, SO IS COMPUTED
C     ONLY ON CALLS WITH NEW J0 OR J1.  THIS SAVES TIME IF A NUMBER
C     OF OBJECTS (E.G., AN ENTIRE CATALOG) ARE TO BE PRECESSED BETWEEN
C     THE SAME TWO EPOCHS.
C
C
C     RCS DATA
C     
C     $Header$
C     
C     $Log$
C
C
      IMPLICIT NONE
C
C     INPUT
      REAL*8 J0,J1,RA0,DC0
C
C     OUTPUT
      REAL*8 RA1,DC1
C
C     LOCAL
      REAL*8 PI
      PARAMETER (PI=3.14159265358979324D0)
C
      REAL*8 J0PREV /0./, J1PREV /0./
      REAL*8 XX,YX,ZX,XY,YY,ZY,XZ,YZ,ZZ
      SAVE   J0PREV,J1PREV,XX,YX,ZX,XY,YY,ZY,XZ,YZ,ZZ
C
      REAL*8 P(3,3),X0,Y0,Z0,X1,Y1,Z1,SA,CA,SD,CD
C
C     EXTERNAL SUBROUTINE
      EXTERNAL PRECESS_MATRIX
C
C     DO WE HAVE NEW EPOCHS?
      IF (J0 .NE. J0PREV .OR. J1 .NE. J1PREV) THEN
         J0PREV = J0
         J1PREV = J1
         CALL PRECESS_MATRIX(J0,J1,P)
C
C        PRECESSION MATRIX:
         XX = P(1,1)
         YX = P(1,2)
         ZX = P(1,3)
         XY = P(2,1)
         YY = P(2,2)
         ZY = P(2,3)
         XZ = P(3,1)
         YZ = P(3,2)
         ZZ = P(3,3)
      ENDIF
C
C     APPLY THE PRECESSION MATRIX
      SA = SIN(RA0)
      CA = COS(RA0)
      SD = SIN(DC0)
      CD = COS(DC0)
      X0 = CA*CD
      Y0 = SA*CD
      Z0 = SD
C
      X1 = X0*XX+Y0*YX+Z0*ZX
      Y1 = X0*XY+Y0*YY+Z0*ZY
      Z1 = X0*XZ+Y0*YZ+Z0*ZZ
C
      RA1 = ATAN2(Y1,X1)
      IF (RA1 .LT. 0.) RA1 = RA1+2.*PI
      DC1 = ASIN(Z1)
C
      RETURN
      END
