C $Id: rtntogse.f,v 1.7 1999/12/20 17:49:52 asc Exp $
C      subroutine for the transformation from rtn to gse
c
       subroutine rtntogse(time,spacecraft_pos,RTN,GSE)
C
       implicit none
C
       integer*4 time(2)   ! yearday (eg 1998095), millisec of day
       real*8 spacecraft_pos(3) ! position, in J2000GCI
       real*8 RTN(3),GSE(3)  ! RTN input vector and GSE output

       integer*4 VELOCITY_REQ, istatus
       real*8 TRANSFORM_MATRIX(3,3), DERIV_MATRIX(3,3)
       real*8 GCI(3), GSM(3)

C
C CONVERT FROM RTN TO GCI
C
       VELOCITY_REQ = 0    ! Have not completed the derivative path
       call  IC_RTN_TO_GCI (TIME,spacecraft_pos, 
     1                      TRANSFORM_MATRIX,DERIV_MATRIX,
     2                      VELOCITY_REQ,ISTATUS)
       call MULMAT(TRANSFORM_MATRIX,RTN,3,3,1,GCI)
C       WRITE (6,*) ' GCI =',GCI
C
C CONVERT FROM GCI TO GSE
C
       call  IC_GCI_TO_GSE (TIME, 
     1                      TRANSFORM_MATRIX,DERIV_MATRIX,
     2                      VELOCITY_REQ,
     3                      ISTATUS)
       call MULMAT(TRANSFORM_MATRIX,GCI,3,3,1,GSE)
C       WRITE (6,*) ' GSE =',GSE
C
       RETURN
       END








