C$Procedure PDSCLS ( PDS Label Closing ) SUBROUTINE PDSCLS ( LBLTYP, TYPE, ARCH, EQUPOS, UNIT ) C$ Abstract C C This is a utility routine for the program MAKLBL. It C appends, as needed, the appropriate information to a PDS C label file. C C$ Copyright C C Copyright (1995), California Institute of Technology. C U.S. Government sponsorship acknowledged. C C$ Required_Reading C C None. C C$ Keywords C C UTILITY C C$ Declarations IMPLICIT NONE CHARACTER*(*) LBLTYP CHARACTER*(*) TYPE CHARACTER*(*) ARCH INTEGER EQUPOS INTEGER UNIT C$ Brief_I/O C C VARIABLE I/O DESCRIPTION C -------- --- -------------------------------------------------- C LBLTYP I Type of label being produced C TYPE I Type of file being labelled C ARCH I Architecture of file being labelled. C EQUPOS I The location where '=' should occur in labels C UNIT I Logical unit of label file C C$ Detailed_Input C C LBLTYP is the type of label that is being generated C by the program that calls this routine. C C TYPE is the type of kernel that is being labelled. C Typically this is extracted from the file C being labelled. C C Types currently supported are: 'CK' C 'IK' C 'LSK' C 'PCK' C 'SCLK' C 'SPK' C 'EK' C 'FK' C C ARCH is the architecture of the file being labelled. C Typically this is extracted from the file C being labelled. C C Types currently architectures are: 'KPL' C 'DAF' C 'DAS' C C EQUPOS is the location of the equal '=' character in C keyword = value pairs of the main portion of the C label. C C UNIT is the logical unit attached to an open text C label file for writing. C C$ Detailed_Output C C None. C C$ Parameters C C None. C C$ Files C C This routine writes PDS label information into the file C that is attached to UNIT C C$ Exceptions C C 1) If the architecture is not recognized, the error C SPICE(UNKNOWNARCHITECTURE) is signalled. C C 2) If the type of the file is not recognized, the error C SPICE(UNKNOWNFILETYPE) is signalled. C C C$ Particulars C C This is a utility routine for handling the clean up C tasks of creating a PDS compliant label. C C$ Examples C C Sorry. See MAKLBL for an example of how to call this C routine. C C$ Restrictions C C None. C C$ Author_and_Institution C C B.V. Semenov (JPL) C W.L. Taber (JPL) C C$ Literature_References C C None. C C$ Version C C- MAKLBL Version 1.1.0, 8-JUL-1998 (BVS) C C Processing of FRAME kernels was added. KERNEL_TYPE values C were changed to correcpond to the PDS definitions: C C 'SPACECRAFT CLOCK' --> 'CLOCK_COEFFICIENTS' C 'PLANETARY CONTANTS' --> 'TARGET_CONSTANTS' C 'EVENT_SEQUENCE' --> 'EVENTS' C C Wrapping for values of keywords OBJECT, INTERCHANGE_FORMAT, C KERNEL_TYPE and END_OBJECT was removed as not correcponding C to Object Data Language (ODL) conventions. C C- MAKLBL Version 1.0.0, 3-DEC-1996 (WLT) C C-& C C SPICELIB Functions C INTEGER ISRCHC LOGICAL RETURN C C The parameters below are integer mnemonics for the various C types files that might get labelled. C INTEGER CK PARAMETER ( CK = 1 ) INTEGER IK PARAMETER ( IK = CK + 1 ) INTEGER LSK PARAMETER ( LSK = IK + 1 ) INTEGER PCK PARAMETER ( PCK = LSK + 1 ) INTEGER SCLK PARAMETER ( SCLK = PCK + 1 ) INTEGER SPK PARAMETER ( SPK = SCLK + 1 ) INTEGER EK PARAMETER ( EK = SPK + 1 ) INTEGER FRAMES PARAMETER ( FRAMES = EK + 1 ) INTEGER NTYPES PARAMETER ( NTYPES = FRAMES ) C C NEW_FILE_TYPES C C In the event that you should ever need to add another type of C data product to the list above, you need to add a new C mnemonic to the above list following the last item (which C is currently SPK). Then set the parameter NTYPES equal to C the new parameter you just set up. For example suppose C you have added the new type of kernel 'DBK', Here's how C you might add this item to the list of integer mnemonics C above. C C . C . C C INTEGER FRAMES C PARAMETER ( FRAMES = EK + 1 ) C C INTEGER DBK C PARAMETER ( DBK = FRAMES + 1 ) C C INTEGER NTYPES C PARAMETER ( NTYPES = DBK ) C C C After doing this you will need to find the point in the C code below where the actual string associated with this C type is located. Look in the executable portion of the C routine for the blocks of code ... C C C TYPES ( CK ) = 'CK' C TYPES ( IK ) = 'IK' C TYPES ( LSK ) = 'LSK' C TYPES ( PCK ) = 'PCK' C TYPES ( SCLK ) = 'SCLK' C TYPES ( SPK ) = 'SPK' C TYPES ( EK ) = 'EK' C TYPES ( FRAMES ) = 'FK' C . C . C . C C KTYPES ( CK ) = 'POINTING' C KTYPES ( IK ) = 'INSTRUMENT' C KTYPES ( LSK ) = 'LEAPSECONDS' C KTYPES ( PCK ) = 'ORIENTATION' C KTYPES ( PCK ) = 'TARGET_CONSTANTS' C KTYPES ( SCLK ) = 'CLOCK_COEFFICIENTS' C KTYPES ( SPK ) = 'EPHEMERIS' C KTYPES ( EK ) = 'EVENTS' C KTYPES ( FRAMES ) = 'FRAMES' C C and add the extra lines pointed to ( ===>> ) below. C C C TYPES ( CK ) = 'CK' C TYPES ( IK ) = 'IK' C TYPES ( LSK ) = 'LSK' C TYPES ( PCK ) = 'PCK' C TYPES ( SCLK ) = 'SCLK' C TYPES ( SPK ) = 'SPK' C TYPES ( EK ) = 'EK' C TYPES ( FRAMES ) = 'FK' C ===>> TYPES ( DBK ) = 'DBK' C . C . C . C C KTYPES ( CK ) = 'POINTING' C KTYPES ( IK ) = 'INSTRUMENT' C KTYPES ( LSK ) = 'LEAPSECONDS' C KTYPES ( PCK ) = 'ORIENTATION' C KTYPES ( PCK ) = 'TARGET_CONSTANTS' C KTYPES ( SCLK ) = 'CLOCK_COEFFICIENTS' C KTYPES ( SPK ) = 'EPHEMERIS' C KTYPES ( EK ) = 'EVENTS' C KTYPES ( FRAMES ) = 'FRAMES' C ===>> KTYPES ( DBK ) = some appropriate descriptive label C C C The parameters below are integer mnemonics for the various C files architectures for files that might get labelled. C C CAUTION: if you need to update this list, you will probably C need to update the same list in PDSOPN. C INTEGER KPL PARAMETER ( KPL = 1 ) INTEGER DAF PARAMETER ( DAF = KPL + 1 ) INTEGER DAS PARAMETER ( DAS = DAF + 1 ) INTEGER NARCH PARAMETER ( NARCH = DAS ) C C NEW_ARCHITECTURES C C Updating this list is similar to updating the file types C above. Should an new file architecture come along, you will C need to add it after the last mnemonic (currently DAS) and C update NARCH to be the value of the last item in the mnemonic C list. For example suppose there is a new architecture called C 'BKP' Make up a new integer mnemonic as shown here. C C INTEGER DAS C PARAMETER ( DAS = DAF + 1 ) C C INTEGER BKP C PARAMETER ( BKP = DAS + 1 ) C C INTEGER NARCH C PARAMETER ( NARCH = BKP ) C C Then find the blocks of code in the executable portion of C this routine that look like this. C C ARCHS ( KPL ) = 'KPL' C ARCHS ( DAF ) = 'DAF' C ARCHS ( DAS ) = 'DAS' C . C . C . C FORMTS ( KPL ) = 'ASCII' C FORMTS ( DAF ) = 'BINARY' C FORMTS ( DAS ) = 'BINARY' C C Add the new lines pointed to ( ===>> ) below. C C C ARCHS ( KPL ) = 'KPL' C ARCHS ( DAF ) = 'DAF' C ARCHS ( DAS ) = 'DAS' C ===>> ARCHS ( BKP ) = 'BKP' C . C . C . C FORMTS ( KPL ) = 'ASCII' C FORMTS ( DAF ) = 'BINARY' C FORMTS ( DAS ) = 'BINARY' C ===>> FORMTS ( BKP ) = ascii or binary as appropriate C C INTEGER SMWDSZ PARAMETER ( SMWDSZ = 8 ) INTEGER LNSIZE PARAMETER ( LNSIZE = 80 ) INTEGER ENDSIZ PARAMETER ( ENDSIZ = 5 ) INTEGER WDSIZE PARAMETER ( WDSIZE = 32 ) CHARACTER*(LNSIZE) ENDLBL ( ENDSIZ ) CHARACTER*(SMWDSZ) ARCHS ( NARCH ) CHARACTER*(SMWDSZ) MYARCH CHARACTER*(SMWDSZ) MYLBLT CHARACTER*(SMWDSZ) MYTYPE CHARACTER*(SMWDSZ) TYPES ( NTYPES ) CHARACTER*(WDSIZE) FORMTS ( NARCH ) CHARACTER*(WDSIZE) KTYPES ( NTYPES ) INTEGER KTYP INTEGER ATYP INTEGER KER INTEGER MYEQU INTEGER FMT INTEGER I C C Standard SPICE introductory exception handling. C IF ( RETURN() ) THEN RETURN END IF CALL CHKIN ( 'PDSCLS' ) C C Normalize the string that describes the type of label C that is being produced. C CALL LJUST ( LBLTYP, MYLBLT ) CALL UCASE ( MYLBLT, MYLBLT ) IF ( MYLBLT .NE. 'PDS' ) THEN C C We can return, there is nothing that this routine C needs to do with the current label file. C CALL CHKOUT ( 'PDSCLS' ) RETURN END IF C C If we are still in this routine, we have the end of a C PDS label to compose. C C The end of a PDS label looks like this. C C OBJECT = SPICE_KERNEL C INTERCHANGE_FORMAT = C KERNEL_TYPE = C DESCRIPTION = " " C END_OBJECT = SPICE_KERNEL C C We determine what to fill in for the <> items from C the type and architecture of the file being labelled. C C Below are the types of files that are currently recognized C as SPICE kernels, these are used to determine the C in the template above. To add to this list see the instructions C in the section NEW_FILE_TYPES in the declarations section C above. C TYPES ( CK ) = 'CK' TYPES ( IK ) = 'IK' TYPES ( LSK ) = 'LSK' TYPES ( PCK ) = 'PCK' TYPES ( SCLK ) = 'SCLK' TYPES ( SPK ) = 'SPK' TYPES ( EK ) = 'EK' TYPES ( FRAMES ) = 'FK' C C Here are the PDS associated with these. Note that C for PCK files the name depends upon whether or not the C file is is a DAF file or a KPL file. This special case C is handled below, but the possible values are listed here C so that you can see both of the possible values. C KTYPES ( CK ) = 'POINTING' KTYPES ( IK ) = 'INSTRUMENT' KTYPES ( LSK ) = 'LEAPSECONDS' KTYPES ( PCK ) = 'ORIENTATION' KTYPES ( PCK ) = 'TARGET_CONSTANTS' KTYPES ( SCLK ) = 'CLOCK_COEFFICIENTS' KTYPES ( SPK ) = 'EPHEMERIS' KTYPES ( EK ) = 'EVENTS' KTYPES ( FRAMES ) = 'FRAMES' C C Below are the known file architectures these determine what C we put in for the in the template above. If a new C architecture comes along, follow the procedure discussed C in the declarations section under NEW_ARCHITECTURES. C ARCHS ( KPL ) = 'KPL' ARCHS ( DAF ) = 'DAF' ARCHS ( DAS ) = 'DAS' C C ... and here are the corresponding labels that C need to be used to describe them. C FORMTS ( KPL ) = 'ASCII' FORMTS ( DAF ) = 'BINARY' FORMTS ( DAS ) = 'BINARY' C C Perform the sanity checks on the type and architecture of the C file that is being labelled. C CALL LJUST ( ARCH, MYARCH ) CALL UCASE ( MYARCH, MYARCH ) CALL LJUST ( TYPE, MYTYPE ) CALL UCASE ( MYTYPE, MYTYPE ) KTYP = ISRCHC ( MYTYPE, NTYPES, TYPES ) ATYP = ISRCHC ( MYARCH, NARCH, ARCHS ) IF ( ATYP .EQ. 0 ) THEN CALL SETMSG ( 'The file architecture was not ' . // 'recognized. The value was ''#''. This ' . // 'may be due to PDSCLS not keeping pace ' . // 'with the architectures supported by ' . // 'SPICELIB. ' ) CALL ERRCH ( '#', MYARCH ) CALL SIGERR ( 'SPICE(UNKNOWNARCHITECTURE)' ) CALL CHKOUT ( 'PDSCLS' ) RETURN END IF IF ( KTYP .EQ. 0 ) THEN CALL SETMSG ( 'The file type was not recognized. The ' . // 'value was ''#''. This may be due to ' . // 'PDSCLS not keeping pace with the file ' . // 'types supported by SPICELIB. ' ) CALL ERRCH ( '#', MYTYPE ) CALL SIGERR ( 'SPICE(UNKNOWNARCHITECTURE)' ) CALL CHKOUT ( 'PDSCLS' ) RETURN END IF C C Adjust the KTYPE value for PCK depending upon the C value of the architecture flag. If you ever have C any other such special situations, this is the place C to handle them. C IF ( MYARCH .EQ. 'DAF' ) THEN KTYPES( PCK ) = 'ORIENTATION' ELSE KTYPES( PCK ) = 'TARGET_CONSTANTS' END IF C C Create the template for the closing portion of the label. C MYEQU = MAX ( EQUPOS, 22 ) ENDLBL( 1 ) = 'OBJECT ' ENDLBL( 1 )(MYEQU:) = '= SPICE_KERNEL' ENDLBL( 2 ) = ' INTERCHANGE_FORMAT ' ENDLBL( 2 )(MYEQU:) = '= ' ENDLBL( 3 ) = ' KERNEL_TYPE ' ENDLBL( 3 )(MYEQU:) = '= ' ENDLBL( 4 ) = ' DESCRIPTION ' ENDLBL( 4 )(MYEQU:) = '= " "' ENDLBL( 5 ) = 'END_OBJECT ' ENDLBL( 5 )(MYEQU:) = '= SPICE_KERNEL' FMT = 2 KER = 3 C C Fill in the template C CALL REPMC ( ENDLBL(FMT), '', FORMTS(ATYP), ENDLBL(FMT) ) CALL REPMC ( ENDLBL(KER), '', KTYPES(KTYP), ENDLBL(KER) ) C C Write out the last part of the label. C DO I = 1, ENDSIZ CALL WRITLN ( ENDLBL(I), UNIT ) END DO C C Checkout and return. C CALL CHKOUT ( 'PDSCLS' ) RETURN END