C$Procedure LSKLBL ( Generate an MGSO or PDS LSK label file ) SUBROUTINE LSKLBL ( LBLTYP, LSKFNM, KWTBLE, KWPTR, KWVALS ) C$ Abstract C C Collect label information from a specified LSK file and generate C labels, writing them to a file. C C$ Copyright C C Copyright (1996), California Institute of Technology. C U.S. Government sponsorship acknowledged. C C$ Required_Reading C C None C C$ Keywords C C None. C C$ Declarations IMPLICIT NONE INTEGER LBCELL PARAMETER ( LBCELL = -5 ) CHARACTER*(*) LBLTYP CHARACTER*(*) LSKFNM CHARACTER*(*) KWTBLE( LBCELL:*) INTEGER KWPTR ( LBCELL:*) CHARACTER*(*) KWVALS( LBCELL:*) C$ Brief_I/O C C Variable I/O Description C -------- --- -------------------------------------------------- C LBLTYP I The type of label file to produce: MGSO or PDS. C LSKFNM I The name of the LSK file to use. C KWTBLE I/O The names portion of a symbol table C KWPTR I/O The pointers portion of a symbol table C KWVALS I/O The values portion of a symbol table C C$ Detailed_Input C C LBLTYP The type of label file to be produced. The allowed C types are: 'MGSO' or 'PDS'. C C LSKFNM The name of a binary leapsecond file to use when C generating values for keywords in the label file. C This file must already exist. C C KWTBLE The symbol table of keyword value lists that will C KWPTR later be converted into an label file for the C KWVALS input LSK file. On input, this symbol table contains C the values that were supplied in the MAKLABEL C template file. C C C$ Detailed_Output C C KWTBLE The symbol table of keyword value lists that will C KWPTR later be converted into an label file for the C KWVALS input LSK file. On output, this symbol table contains C the values that were supplied in the MAKLABEL C template file as well as all values that are C appropriate for an LSK label. C C$ Parameters C C None. C C$ Exceptions C C 1) If the label type is not one of 'MGSO' or 'PDS' then the error C MAKLABEL(BADLABELTYPE) will be signalled. C C 2) If the leapsecond SPICE kernel file does not exist, the error C MAKLABEL(FILEDOESNOTEXIST) will be signalled. C C 3) If the type of the SPICE kernel file cannot be C determined, the error MAKLABEL(UNKNOWNFILETYPE) will be C signalled. C C 4) If the SPICE binary kernel file is not an LSK file, the error C MAKLABEL(NOTALSKFILE) will be signalled. C C 6) If the name for a body ID code cannot be found, the error C MAKLABEL(BODYNOTFOUND) will be signalled. C C$ Files C C None. C C$ Particulars C C This subroutine scans an ASCII LSK file collecting C information used to generate a set of labels. C C$ Examples C C None. C C$ Restrictions C C This subroutine is to be used only with the MAKLABEL program. C C$ Literature_References C C None. C C$ Author_and_Institution C C B.V. Semenov (JPL) C W.L. Taber (JPL) C K.R. Gehringer (JPL) C C$ Version C C- Beta Version 2.1.0, 9-JUL-1998 (BVS) C C Keyword INSTRUMENT_ID was changed to NAIF_INSTRUMENT_ID. C C- Beta Version 2.0.0, 4-DEC-1996 (WLT) C C Really and truly this routine should have a new name, C the calling sequence and functionality are totally C different from the last edition of this routine. C C- Beta Version 1.0.0, 25-JAN-1996 (KRG) C C-& C$ Index_Entries C C create a NAIF label file from an lsk file C C-& C C SPICELIB functions C INTEGER RTRIM INTEGER CPOSR LOGICAL EXISTS LOGICAL FAILED C C Local parameters C C Template for the CDB data set ID value. C CHARACTER*(*) MGSODI PARAMETER ( MGSODI = 'SPICE_LSK_FILE' ) C C Maximum length of keyword-value labels. C INTEGER LBLLEN PARAMETER ( LBLLEN = 132 ) C C Length of a file architecture. C INTEGER ALEN PARAMETER ( ALEN = 3 ) C C Length of a file type. C INTEGER TYPLEN PARAMETER ( TYPLEN = 4 ) C C Local variables C CHARACTER*(ALEN) ARCH CHARACTER*(TYPLEN) TYPE CHARACTER*(TYPLEN) MYLBLT CHARACTER*(LBLLEN) NOTE CHARACTER*(LBLLEN) PRODID CHARACTER*(LBLLEN) VALUE INTEGER DIRLOC LOGICAL FOUND C C Standard SPICE error handling. C CALL CHKIN ( 'LSKLBL' ) C C Check to see if the label type we were given is one we recognize. C We only recognize 'PDS' and 'MGSO'. C CALL LJUST ( LBLTYP, MYLBLT ) CALL LJUST ( MYLBLT, MYLBLT ) IF ( ( MYLBLT .NE. 'PDS' ) .AND. ( MYLBLT .NE. 'MGSO' ) ) THEN CALL SETMSG ( 'The label type ''#'' was not recognized.' . // ' Only label types ''PDS'' and ''MGSO''' . // ' are recognized.' ) CALL ERRCH ( '#', MYLBLT ) CALL SIGERR ( 'MAKLABEL(BADLABELTYPE)' ) CALL CHKOUT( 'LSKLBL' ) RETURN END IF C C Check to see that the file exists, and that it is a SPICE file, C and hence one we know how to process. C IF ( .NOT. EXISTS ( LSKFNM ) ) THEN CALL SETMSG ( 'The LSK file ''#'' does not exist.' ) CALL ERRCH ( '#', LSKFNM ) CALL SIGERR ( 'MAKLABEL(FILEDOESNOTEXIST)' ) CALL CHKOUT( 'LSKLBL' ) RETURN END IF CALL GETFAT ( LSKFNM, ARCH, TYPE ) IF ( FAILED() ) THEN CALL CHKOUT( 'LSKLBL' ) RETURN END IF IF ( ( ARCH .EQ. '?' ) .OR. ( TYPE .EQ. '?' ) ) THEN C C We didn't have a file that we know how to deal with. So, C we toss our hands in the air and signal an error. C CALL SETMSG ( 'The architecture or type of the file' . // ' ''#'' was not recognized.' ) CALL ERRCH ( '#', LSKFNM ) CALL SIGERR ( 'MAKLABEL(UNKNOWNFILETYPE)' ) CALL CHKOUT ( 'LSKLBL' ) RETURN END IF IF ( TYPE .NE. 'LSK' ) THEN CALL SETMSG ( 'The file ''#'' has a file type, ''#'',' . // ' and this subroutine only works with' . // ' LSK files.' ) CALL ERRCH ( '#', LSKFNM ) CALL ERRCH ( '#', TYPE ) CALL SIGERR ( 'MAKLABEL(NOTANLSKFILE)' ) CALL CHKOUT( 'LSKLBL' ) RETURN END IF C C At this point, we know that: C C 1) We have a SPICE file available for generating labels. C 2) We know that the label file that we are to produce does not C exist, so we can safely create it. C C So we will try to create the label file for the LSK file now. C C C First, load the LSK file into the kernel pool. We do this t C verify that it is a correctly formated leapseconds file. C CALL LDPOOL ( LSKFNM ) IF ( FAILED() ) THEN CALL CHKOUT( 'LSKLBL' ) RETURN END IF C C Set the value of the note. C NOTE = 'SPICE text LSK file.' C C Set the product ID. This is the filename with all leading C directory stuff removed. C C Remove any leading path or directory elements. C DIRLOC = CPOSR ( LSKFNM, '/]', RTRIM(LSKFNM) ) IF ( DIRLOC .EQ. 0 ) THEN PRODID = LSKFNM ELSE PRODID = LSKFNM(DIRLOC+1:) END IF C C Without any further processing we can fill in all of the C following items. Note that if there is already a SPACECRAFT_NAME C we don't overwrite it. C CALL SYIFSC ('SPACECRAFT_NAME', 'N/A', KWTBLE, KWPTR, KWVALS ) CALL SYIFSC ('KERNEL_TYPE_ID', TYPE, KWTBLE, KWPTR, KWVALS ) CALL SYIFSC ('PRODUCT_ID', PRODID, KWTBLE, KWPTR, KWVALS ) CALL SYIFSC ('START_TIME', 'N/A', KWTBLE, KWPTR, KWVALS ) CALL SYIFSC ('STOP_TIME', 'N/A', KWTBLE, KWPTR, KWVALS ) CALL SYIFSC ('TARGET_NAME', 'N/A', KWTBLE, KWPTR, KWVALS ) CALL SYIFSC ('INSTRUMENT_NAME', 'N/A', KWTBLE, KWPTR, KWVALS ) CALL SYIFSC ('NAIF_INSTRUMENT_ID','N/A', KWTBLE, KWPTR, KWVALS ) CALL SYIFSC ('SOURCE_PRODUCT_ID', 'N/A', KWTBLE, KWPTR, KWVALS ) CALL SYIFSC ('NOTE', NOTE, KWTBLE, KWPTR, KWVALS ) CALL SYIFSC ('SPACECRAFT_CLOCK_START_COUNT', 'N/A', KWTBLE, . KWPTR, . KWVALS ) CALL SYIFSC ('SPACECRAFT_CLOCK_STOP_COUNT', 'N/A', KWTBLE, . KWPTR, . KWVALS ) CALL SYIFSC ('PLATFORM_OR_MOUNTING_NAME', 'N/A', KWTBLE, . KWPTR, . KWVALS ) C C Keyword: DATA_SET_ID C ==================== C C Look up the current value for the DATA_SET_ID. This will C be overridden by the SYPOPC call below if anything at all C is present. C VALUE = MGSODI CALL SYPOPC( 'DATA_SET_ID', KWTBLE, KWPTR, KWVALS, VALUE, FOUND ) IF ( MYLBLT .EQ. 'PDS' .AND. .NOT. FOUND ) THEN C C If we didn't get a value back from the call above C we are totally out of luck. C CALL SETMSG ( 'There was no template value supplied ' . // 'for the DATA_SET_ID in the TEMPLATE ' . // 'file. Until that information is ' . // 'supplied the label file can not be ' . // 'created. ' ) CALL SIGERR ( 'MAKLABEL(NODATASETID)' ) CALL CHKOUT ( 'LSKLBL' ) RETURN END IF C C A blank value for the DATA_SET_ID is not acceptable. C IF ( VALUE .EQ. ' ' ) THEN VALUE = MGSODI END IF C C If the current value is just a template, fill in the marker C (this has no effect if there isn't a marker present). C CALL REPMC ( VALUE, '#', TYPE, VALUE ) CALL SYSETC ('DATA_SET_ID', VALUE, KWTBLE, KWPTR,KWVALS ) C C That's all folks!!! C CALL CHKOUT ( 'LSKLBL' ) RETURN END