	SUBROUTINE READ_ORBIT_INFO(LZFILENAME)
C+
C 
C FUNCTIONAL DESCRIPTION:	
C 
C    This subroutine reads SOHO orbit information for a given day from a disk
C    file into memory.  The data for the entire day is placed into the common
C    block ORBIT.
C 
C FORMAL ARGUMENTS:
C  
C     LZFILENAME:
C	CHAR(*)	  I	The name of the level zero file for the date of
C			interest
C
C INTERFACE:
C
!	INTERFACE
!	  SUBROUTINE READ_ORBIT_INFO(LZFILENAME)
!	    CHARACTER(LEN=*), INTENT(IN) :: LZFILENAME
!	  END SUBROUTINE READ_ORBIT_INFO
!	END INTERFACE
C      
C COMMON BLOCKS:
C  
C     ORBIT	Contains nine arrays (one CHARACTER, eight REAL*4) which hold
C		the orbit information for a single day.  The arrays are each
C		144 long, since the orbit information is given in 10-minute
C		intervals.  The arrays are declared in the file ORBIT.INC.
C
C INCLUDE FILES:
C
C     ORBIT.INC
C  
C DESIGN:
C  
C 	Construct name of ascii 10 minute file to read
C 	Open ascii 10-minute file
C	If file doesn't exist, use PRE instead of DEF data
C 	Loop through input file, reading each line and saving it at the current
C 	index into the appropriate array
C 	Close the input file and return
C
C	Currently the input file is an ascii file assumed to be located in
C	DISKM1:[GALVIN.ORBIT].  In a later version of this subroutine the input
C	file will be a CDF file located in SOHO_OR_DATA:.
C  
C 
C This version:    1.1  8-OCT-1996
C 
C CREATED: 
C 
C	 5-JUN-1996    Lawrence Bleau
C 
C DEVELOPMENT HISTORY:
C 
C	 Date     | Name  | Description
C ----------------+-------+-----------------------------------------------------
C 1.1  8-OCT-1996    LRB    add code to open PRE file is DEF file isn't there
C     15-APR-1999    LRB    added comments
C 
C-
CDEC$	IDENT '1.1'
	CHARACTER*(*) LZFILENAME
	INCLUDE 'INC_DIR:ORBIT.INC/NOLIST'
C
	INTEGER I,IDX,NCH
	CHARACTER*80 TENMINFILE
C
	IF (LZFILENAME .EQ. 'X') GOTO 100
	RETURN
C
100	CONTINUE
C
C Construct name of ascii 10 minute file to read
C
	I = INDEX(LZFILENAME, ']')
	IF (I .EQ. 0) I = INDEX(LZFILENAME, ':')
	TENMINFILE = LZFILENAME(I+1:)
	I = INDEX(TENMINFILE, '.')
	TENMINFILE(I:) = '.10MIN'
	TENMINFILE(I-3:I-1) = 'V01'
	TENMINFILE(1:9) = 'SO_OR_DEF'
C	TENMINFILE = 'DISKM1:[GALVIN.ORBIT]' // TENMINFILE
	NCH = INDEX(TENMINFILE, ' ') - 1
	IF (NCH .EQ. -1) NCH = LEN(TENMINFILE)
C
C Open ascii 10-minute file
C
	OPEN(29, FILE=TENMINFILE, DEFAULTFILE='DISKM1:[GALVIN.ORBIT]', 
     .       STATUS='OLD', READONLY, ERR=8000)
C
C Loop through input file, reading each line and saving it at the current index
C into the appropriate array
C
120	DO 200 IDX=1,144
	  READ(29,210,END=9010) DAT_TIMESTAMP(IDX),
     .        GSEX(IDX), GSEY(IDX), GSEZ(IDX),
     .        EARTH_SUN_DISTANCE(IDX), SOHO_RANGE(IDX),
     .        DAT_CR_EARTH(IDX), HGLO_SOHO(IDX), HGLA_SOHO(IDX)
210	FORMAT (2X,A42,3X,3(F7.2,1X),2X,2(F10.0,2X),I5,3X,F7.2,3X,F7.2)
200	CONTINUE
C
C Close the input file and return
C
	CLOSE(29)
	RETURN
C
C Could not open input file, probably because it does not exist.  Change file
C name to use predicted data (PRE) rather than definitive data (DEF) and try
C again.  If we fail this this print error message and quit.
C
8000	TENMINFILE(1:9) = 'SO_OR_PRE'
	OPEN(29, FILE=TENMINFILE, DEFAULTFILE='DISKM1:[GALVIN.ORBIT]', 
     .       STATUS='OLD', READONLY, ERR=9000)
	GOTO 120
C
9000	WRITE(6,9001) TENMINFILE(1:NCH)
9001	FORMAT(' UNABLE TO OPEN ASCII 10-MINUTE FILE ',A)
	RETURN
C
9010	WRITE(6,9011) TENMINFILE(1:NCH),IDX-1
9011	FORMAT(' ERROR READING ORBIT FILE ',A/
     .		' ONLY ',I3,' SETS OF ITEMS WERE READ, EXPECTED 144')
	CLOSE(29)
	RETURN
	END
