      SUBROUTINE UPDATE_START_END 
C
C----------------------------------------------------------------------
C
C.IDENTIFICATION: Subroutine UPDATE_START_END
C.LIBRARY:        XASLIB
C.AUTHOR:         L.Chiappetti - IFCTR Milano
C.VERSIONS:       0.0 - 07 May 96 - original versions
C                 0.1 - 08 Nov 96 - times in double precision
C                 0.2 - 26 Nov 96 - changed CONVERSION variable
C.PURPOSE:        set correct start and end times of accumulation
C.METHOD:         update OPCOMMON based on ACCUMCOMMON content
C.SYNTAX:         CALL  UPDATE_START_END
C.PARAMETERS:     none in version 0.1
C.RESTRICTIONS:
C.NOTES:          the OBT and time array start and end in OPCOMMON are
C                 retained to the default value throughout the program.
C                 In order to update the HISTORY with the user-provided
C                 start and end, the values in ACCUMCOMMON shall be used.
C                 Since SAX_ACC_B*S* may alter such values, it is necessary
C                 that the main saves the start in JZERO beforehand.
C.FILES:
C.REFERENCES
C
C----------------------------------------------------------------------
C
      INTEGER JZERO,IXTIME,ITIME,LSB,START70
      DOUBLE PRECISION XTIMED,TIMED,TREF,UDOUBLE
      INCLUDE 'hcommon.inc'      
      INCLUDE 'bincommon.inc'      
      INCLUDE 'accumcommon.inc'      
      INCLUDE 'opcommon.inc'
      INCLUDE 'timecommon.inc'
C
C     Reference OBT start time in current time units
      TREF=UDOUBLE(STARTOBT)*TIMECOMMON_SCCONVERSION
C
      XTIMED=ACCUMCOMMON_TH
C     elapsed time units (s ms us) since "start observation"
      TIMED=XTIMED-TREF
C     elapsed seconds since "start observation"
      ITIME=TIMED/TIMECOMMON_SCALE
C     start observation as Unix time (redundant also in main)
      CALL TIME_1970(STARTARR,START70)
C     elapsed seconds as Unix time
      ITIME=START70+ITIME
C     end time as time array
      CALL TIME_ARRAY(ITIME,ENDARR)
c     ENDOBT=IXTIME
C
C
C     this is OBT
      XTIMED=ACCUMCOMMON_TL
C     elapsed time units (s ms us) since "start observation"
      TIMED=XTIMED-TREF
C     elapsed seconds since "start observation"
      ITIME=TIMED/TIMECOMMON_SCALE
C     start observation as Unix time (redundant also in main)
*     CALL TIME_1970(STARTARR,START70)
C     elapsed seconds as Unix time
      ITIME=START70+ITIME
C     end time as time array
      CALL TIME_ARRAY(ITIME,STARTARR)
c     STARTOBT=IXTIME
      RETURN
      END
