      SUBROUTINE SATPOINTING(ZRA,ZDEC,ZROLL)
C
C     read pointing from image header or ask user
C
C
C----------------------------------------------------------------------
C
C.IDENTIFICATION: Subroutine SATPOINTING
C.LIBRARY:        XASLIB               
C.AUTHOR:         L.Chiappetti - IFCTR Milano
C.VERSIONS:       0.0 - 25 Aug 97 - original version
C.PURPOSE:        retrieve satellite pointing on the sky
C.METHOD:         from header keywords or asking user
C.SYNTAX:         CALL  SATPOINTING(ZRA,ZDEC,ZROLL)
C.PARAMETERS:     REAL*8 ZRA    detector pointing RA (out)
C                 REAL*8 ZDEC   detector pointing Dec (out)
C                 REAL*8 ZROLL  detector roll angle (out)
C.RESTRICTIONS:   keyword names are similar to OGIP, but ROLL is added
C.NOTES:          ZRA ZDEC ZROLL are here in DECIMAL DEGREES
C.FILES:          
C.REFERENCES:     
C
C----------------------------------------------------------------------
C
      DOUBLE PRECISION ZRA,ZDEC,ZROLL
      CHARACTER BUFFER*80
      INTEGER IER1,IER2,IER3,I
      INCLUDE 'pixcommon.inc'
C
C     test if spacecraft pointing is already in image header
C-->  use convention similar to OGIP recomm. R3 but add roll !!
      IF(.NOT.NOIMAGE)THEN
          I=1
          CALL H_READ_DKEYWORD('RA_SCZ',ZRA,0.0d0,IER1,I)
          CALL H_READ_DKEYWORD('DEC_SCZ',ZDEC,0.0d0,IER2,I)
          CALL H_READ_DKEYWORD('ROLL_SCZ',ZROLL,0.0d0,IER3,I)
          IF(IER1+IER2+IER3.EQ.0)RETURN
          WRITE(*,*)' No spacecraft pointing found in header'  
      ENDIF
C     if not found ask user
      CALL X_PROMPT('satellite RA Dec roll (dec. degrees) ',0)
      IF(SKIPBACK)THEN
C         must read first parameter after word "cursor" and reset
          SKIPBACK=.FALSE.
          CALL X_READ  (2,3,BUFFER)
      ELSE
          CALL X_READ  (0,3,BUFFER)
      ENDIF
      READ(BUFFER,*)ZRA,ZDEC,ZROLL
      RETURN
      END
