C$Procedure BEGPD (open file, get record numbers and time bounds) SUBROUTINE BEGPD ( DATTYP, TIMFLG, DATFIL, HANDLE, DESCR, ICD, . NREC, NINTER, TIMMIN, TIMMAX, NEWSEG ) IMPLICIT NONE C$ Abstract C C BEGPG is a subroutine of MAKECK4 program. This subroutine does C preprocessing of CK Type 3 kernel file. It opens input CK file, C get numbers of records in segments. If TIME_INTERVALS_FILE is C not defined in MAKECK4 then BEGPG will analyze time tags to set C bounds for interpolation interval, which are equal to the times C from the first and from the last string (or record) of input C file. The last operation is performed for all types of input C files (CK 3, Quaternions, Euler angles). C C$ Declarations INTEGER DATTYP LOGICAL TIMFLG CHARACTER*80 DATFIL INTEGER HANDLE DOUBLE PRECISION DESCR ( 5 ) INTEGER ICD ( 6 ) INTEGER NREC INTEGER NINTER DOUBLE PRECISION TIMMIN DOUBLE PRECISION TIMMAX LOGICAL NEWSEG C$ Copyright C C Copyright (1997-1998), Jet Propulsion Laboratory C C$ Brief_I/O C C Variable I/O Description C -------- --- -------------------------------------------------- C DATTYP I Input data type: CK, Raw quaternions, Euler angles C TIMFLG I .TRUE. if TIME_INTERVALS_FILE is defined C DATFIL I Input data file name C HANDLE O Handle for input DAF file containing pointing data C (for CK type only) C DESCR O Input data file segment descriptor C (for CK type only) C ICD O Array for integer components of segment descriptor C (for CK type only) C NREC O Number of pointing records in the input file C (for CK type only) C NINTER O Number of approximation intervals in C the input file (for CK3 type only) C TIMMIN O Start time of segment (file) pointing C TIMMAX O End time of segment (file) pointing C NEWSEG O .TRUE. if next segment is found in CK file C C C$ Detailed_Input C C DATTYP Data type for input file which is defined in setup C file of MAKECK4 programme. The type can be: C CK, raw quaternions array, Euler angles array C C TIMFLG This flag determines if approximation intervals are C defined in setup file of MAKECK4 programme C ( .TRUE. - if TIME_INTERVALS_FILE parameter present C .FALSE.- if TIME_INTERVALS_FILE parameter not present ) C C DATFIL Input data file name which is provided by INPUT_FILE C parameter in setup file of MAKECK4 programme C C$ Detailed_Otput C C HANDLE Handle for input DAF file. It is defined only for C CK input data type C C DESCR An array to store double precision components of C segment descriptor from input CK file C C ICD An array to store integer components of segment C descriptor from input CK file C C NREC Number of pointing records in the input CK file. C C NINTER Number of approximation intervals in C the input file (for CK3 type only). c C TIMMIN This parameter is set to a value of a minimal time C tag in a segment of input file (for CK) or in the C input file (for other data types). C The value of TIMMIN is used in MAKECK4 if C TIMFLG = .FALSE. C C TIMMIN Value of the biggest time C tag in a segment of input file (for CK) or in the C input file (for other data types). C The value of TIMMIN is used in MAKECK4 if C TIMFLG = .FALSE. C C NEWSEG This flag defines if input file contains next segment. C For CK files it is set to .TRUE. if the file contains C next segment or .FALSE. if no more segments. C For other input data types the flag will be set to C .TRUE. for the first call of BEGPD subroutine and C .FALSE. for the second and more calls. C C$ Author_and_Institution C C Y.K. Zaiko (BERC) C C$ Version C C- MAKECK4 Version 1.0.0, 1998-09-02 (YKZ) C C-& C C Local parameters. C INTEGER BUFSIZ PARAMETER ( BUFSIZ = 2 ) C C Local variables. C DOUBLE PRECISION BUFFER ( BUFSIZ ) DOUBLE PRECISION DCD ( 2 ) DOUBLE PRECISION RECORD ( 8 ) INTEGER CK1TYP INTEGER CK3TYP INTEGER COUNT INTEGER CURSEG INTEGER ENDSEG INTEGER I INTEGER LOC INTEGER PTR INTEGER QTYP CHARACTER*80 ERROR CHARACTER*200 RECSTR CHARACTER*30 WORD LOGICAL FIRTIM LOGICAL EOF C C Save all. C SAVE C C Initial values. C DATA CURSEG / 1 / DATA EOF / .FALSE. / DATA FIRTIM / .TRUE. / C C Initialize internal variables C CK1TYP = 1 CK3TYP = 3 QTYP = 4 NEWSEG = .FALSE. C C Standard SPICE error handling initialization C CALL CHKIN ( 'BEGPD' ) C C else DATTYP is equal to 4 or more; it is case of C text input file ( quaternions or euler angles ) C IF ( DATTYP .GE. QTYP ) THEN C C If approximation intervals not defined in auxilary file C IF ( .NOT. TIMFLG ) THEN C C Variable COUNT is equal to 0 if we are going to read first C line from input file. The time we'll get from this line C will be used as a start time of approximation interval for C a case when approximation intervals file is not defined in C MAKECK4 setup file. As soon as we read the second or C others strings of input file, COUNT have to be set to C non-zero value. C COUNT = 0 C C Start cycle to read input pointing file records C DO WHILE ( .NOT. EOF ) C C Get next record from input file C CALL RDNBL ( DATFIL, RECSTR, EOF ) IF ( .NOT. EOF ) THEN C C Transform input string to double precision format C CALL NTHWD ( RECSTR, 1, WORD, LOC ) CALL NPARSD ( WORD, RECORD( 1 ), ERROR, PTR ) IF ( PTR .NE. 0 ) THEN CALL SETMSG ( 'the value on the input '// . 'line "#" is not a DP number.' ) CALL ERRCH ( '#', RECSTR ) CALL SIGERR ( 'SPICE(BADINPUTVALUE)' ) END IF IF ( COUNT .EQ. 0 ) THEN C C The time from the first record is less than C times from next records; it is assumed that C input file records are ordered in time C TIMMIN = RECORD( 1 ) COUNT = 1 ELSE TIMMAX = RECORD( 1 ) END IF END IF END DO END IF C C For the first call of BEGPG variable NEWSEG is to be C set to .TRUE. C IF ( FIRTIM ) THEN NEWSEG = .TRUE. END IF END IF C C IF DATTYP is equal to CK1TYP or CK3TYP then it is case of C CK input file C IF ( DATTYP .EQ. CK1TYP .OR. DATTYP .EQ. CK3TYP) THEN C C Standard DAF subroutines are used to open and search for C a next segment C IF ( FIRTIM ) THEN CALL DAFOPR ( DATFIL, HANDLE ) END IF C C Find next segment in DAF file If no more segments in the C input file then set NEWSEG to .FALSE. C CALL DAFBFS ( HANDLE ) DO I = 1, CURSEG CALL DAFFNA ( NEWSEG ) END DO CURSEG = CURSEG + 1 C C If found one then get and unpack Segment Descriptor and C Summary. C IF ( NEWSEG ) THEN CALL DAFGS ( DESCR ) CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) C C Get CK file type number C WARNING: this version currently supports only CK Type 1 & 3 C IF ( ICD( 3 ) .NE. DATTYP ) THEN CALL SETMSG ( 'Data type of the segment should be #:'// . 'Passed descriptor shows type = #.' ) CALL ERRINT ( '#', DATTYP ) CALL ERRINT ( '#', ICD( 3 ) ) CALL SIGERR ( 'SPICE(CKWRONGDATATYPE)' ) CALL CHKOUT ( 'BEGPD' ) RETURN END IF IF ( DATTYP .EQ. CK1TYP ) THEN C C Proceed with CK type 1 input file C CALL CKNR01 ( HANDLE, DESCR, NREC ) C C If approximation intervals not present C IF ( .NOT. TIMFLG ) THEN CALL CKGR01 ( HANDLE, DESCR, 1, RECORD ) TIMMIN = RECORD( 1 ) CALL CKGR01 ( HANDLE, DESCR, NREC, RECORD ) TIMMAX = RECORD( 1 ) END IF ELSE IF ( DATTYP .EQ. CK3TYP ) THEN C C Proceed with CK type 3 input file C CALL CKNR03 ( HANDLE, DESCR, NREC ) ENDSEG = ICD( 6 ) CALL DAFRDA ( HANDLE, ENDSEG - 1, ENDSEG - 1, BUFFER) NINTER = NINT ( BUFFER ( 1 ) ) C C If approximation intervals not present C IF ( .NOT. TIMFLG ) THEN CALL CKGR03 ( HANDLE, DESCR, 1, RECORD ) TIMMIN = RECORD( 1 ) CALL CKGR03 ( HANDLE, DESCR, NREC, RECORD ) TIMMAX = RECORD( 1 ) END IF END IF C C End processing IF ( NEWSEG ) C END IF END IF C C FIRTIM will prevent the second open of input CK file C when next call to BEGPG will occur C FIRTIM = .FALSE. CALL CHKOUT ( 'BEGPD' ) RETURN END