C $Id: solar_spin_gci_xx.f,v 1.2 1998/07/24 21:54:44 asc Exp $
	subroutine solar_spin_gci_xx (ORB_POS_TIME, SPIN, STATUS)
C
	implicit none
C
C*  Calling parameters
C
	integer*4   ORB_POS_TIME(2) !time or orb vector, YYYYDDD, milli of day
	real*8	    TRANSFORM_MATRIX(3,3) !transformation matrix
	integer*4   STATUS  !Status of getting the transformation matrix
C
C*  Other variables
C
        real*8      spin_x(3), SPIN(3) 
	real*8	    MEAN_MATRIX(3,3)	!mean of date transform matrix
	real*8      DERIV_MATRIX(3,3) !time derivative of transformation matrix
	integer*4   VELOCITY_REQ !flag to compute derivative matrix
	real*8	    CMATRIX(3,3)	!The conversion matrix to rotate from 
	real*8      trans_pos_vec(3)			
C
C*  START EXECUTABLE
C
	call IC_GCI_TO_GSE_xx (ORB_POS_TIME, 
     1                            MEAN_MATRIX,DERIV_MATRIX,
     2                            VELOCITY_REQ,
     3                            STATUS)

C
	call IC_GSE_TO_HSEB_xx (ORB_POS_TIME, 
     1                            CMATRIX,DERIV_MATRIX,
     2                            VELOCITY_REQ,
     3                            STATUS,
     4                            trans_pos_vec)
C
	CALL MULMAT (CMATRIX, MEAN_MATRIX, 3, 3, 3, TRANSFORM_MATRIX)
C
	call IC_HSEB_TO_HSEA_xx (ORB_POS_TIME, 
     1                            CMATRIX,DERIV_MATRIX,
     2                            VELOCITY_REQ,
     3                            STATUS)
C
	CALL MULMAT (CMATRIX, TRANSFORM_MATRIX, 3, 3, 3, MEAN_MATRIX)
C
	call IC_HSEA_TO_HS_xx (ORB_POS_TIME, 
     1                            CMATRIX,DERIV_MATRIX,
     2                            VELOCITY_REQ,
     3                            STATUS)
C
	CALL MULMAT (CMATRIX, MEAN_MATRIX, 3, 3, 3, TRANSFORM_MATRIX)
C
	CMATRIX(1,1) = 0.D0
	CMATRIX(1,2) = 0.D0
	CMATRIX(1,3) = 0.D0
	CMATRIX(2,1) = 0.D0
	CMATRIX(2,2) = 0.D0
	CMATRIX(2,3) = 0.D0
	CMATRIX(3,1) = 0.D0
	CMATRIX(3,2) = 0.D0
	CMATRIX(3,3) = 0.D0
C
        CALL GAUSSJ(TRANSFORM_MATRIX,3,3,CMATRIX,3,3)
C
	SPIN_x(1) = 0.D0
	SPIN_x(2) = 0.D0
	SPIN_x(3) = 1.D0
C
        CALL MULMAT(TRANSFORM_MATRIX,SPIN_x,3,3,1,SPIN)
C
	RETURN
	END











