C$Procedure PDSBEG ( PDS Label Beginning ) SUBROUTINE PDSBEG ( LBLTYP, ARCH, PDSVRS, PRODID, EQUPOS, UNIT ) C$ Abstract C C This is a utility routine for the program MAKLBL. It C inserts, as needed, the appropriate information at the C beginning of a PDS label 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 UTILITY C C$ Declarations IMPLICIT NONE CHARACTER*(*) LBLTYP CHARACTER*(*) ARCH CHARACTER*(*) PDSVRS CHARACTER*(*) PRODID INTEGER EQUPOS INTEGER UNIT C$ Brief_I/O C C VARIABLE I/O DESCRIPTION C -------- --- -------------------------------------------------- C LBLTYP I Type of label being produced C ARCH I Architecture of file being labelled. C PDSVRS I Version of PDS label C PRODID I The product ID for the 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 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 PDSVRS is the value to associated with the PDS_VERSION C keyword. C C PRODID is the product ID associated with the kernel C being labelled. 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 C$ Particulars C C This is a utility routine for handling the start 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 Keyword RECORD_TYPE value "ASCII" was replaced with "STREAM" C because "ASCII" was not a value allowed by PDS. Wrapping for C values of keywords PDS_VERSION_ID, RECORD_TYPE and C RECORD_BYTES was removed as not correcponding to Object Data C Language (ODL) conventions. C C- MAKLBL Version 1.0.0, 3-DEC-1996 (WLT) C C C-& C C SPICELIB Functions C INTEGER ISRCHC LOGICAL RETURN 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 PDSBEG. 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 RECTYP ( KPL ) = 'STREAM' C RECTYP ( DAF ) = 'FIXED_LENGTH' C RECTYP ( DAS ) = 'FIXED_LENGTH' 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 RECTYP ( KPL ) = 'STREAM' C RECTYP ( DAF ) = 'FIXED_LENGTH' C RECTYP ( DAS ) = 'FIXED_LENGTH' C ===>> RECTYP ( BKP ) = ascii or binary as appropriate C C INTEGER SMWDSZ PARAMETER ( SMWDSZ = 8 ) INTEGER LNSIZE PARAMETER ( LNSIZE = 80 ) INTEGER BEGSIZ PARAMETER ( BEGSIZ = 4 ) INTEGER WDSIZE PARAMETER ( WDSIZE = 32 ) CHARACTER*(LNSIZE) BEGLBL ( BEGSIZ ) CHARACTER*(SMWDSZ) ARCHS ( NARCH ) CHARACTER*(SMWDSZ) MYARCH CHARACTER*(SMWDSZ) MYLBLT CHARACTER*(WDSIZE) RECTYP ( NARCH ) CHARACTER*(SMWDSZ) BYTES ( NARCH ) INTEGER ATYP INTEGER I INTEGER MYEQU INTEGER PID INTEGER REC INTEGER BYT INTEGER VRS C C Standard SPICE introductory exception handling. C IF ( RETURN() ) THEN RETURN END IF CALL CHKIN ( 'PDSBEG' ) 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 ( 'PDSBEG' ) RETURN END IF C C If we are still in this routine, we have the beginning of a C PDS label to compose. C C The beginning of a PDS label looks like this. C C PDS_VERSION_ID = "" C RECORD_TYPE = "" C RECORD_BYTES = "" C ^SPICE_KERNEL = "" C C We determine what to fill in for the <> items from C the input arguments PDSVRS, ARCH, and PRODID. C 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 RECTYP ( KPL ) = 'STREAM' RECTYP ( DAF ) = 'FIXED_LENGTH' RECTYP ( DAS ) = 'FIXED_LENGTH' BYTES ( KPL ) = '"N/A"' BYTES ( DAF ) = '1024' BYTES ( DAS ) = '1024' C C Perform the sanity checks on the architecture of the C file that is being labelled. C CALL LJUST ( ARCH, MYARCH ) CALL UCASE ( MYARCH, MYARCH ) 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 PDSBEG not keeping pace ' . // 'with the architectures supported by ' . // 'SPICELIB. ' ) CALL ERRCH ( '#', MYARCH ) CALL SIGERR ( 'SPICE(UNKNOWNARCHITECTURE)' ) CALL CHKOUT ( 'PDSBEG' ) RETURN END IF MYEQU = MAX ( EQUPOS, 15 ) BEGLBL( 1 ) = 'PDS_VERSION_ID ' BEGLBL( 1 )(MYEQU:) = '= ' BEGLBL( 2 ) = 'RECORD_TYPE ' BEGLBL( 2 )(MYEQU:) = '= ' BEGLBL( 3 ) = 'RECORD_BYTES ' BEGLBL( 3 )(MYEQU:) = '= ' BEGLBL( 4 ) = '^SPICE_KERNEL' BEGLBL( 4 )(MYEQU:) = '= ""' VRS = 1 REC = 2 BYT = 3 PID = 4 CALL REPMC( BEGLBL(VRS), '', PDSVRS, BEGLBL(VRS)) CALL REPMC( BEGLBL(REC), '', RECTYP(ATYP), BEGLBL(REC)) CALL REPMC( BEGLBL(BYT), '', BYTES (ATYP), BEGLBL(BYT)) CALL REPMC( BEGLBL(PID), ' ', PRODID, BEGLBL(PID)) C C Write out the last part of the label. C DO I = 1, BEGSIZ CALL WRITLN ( BEGLBL(I), UNIT ) END DO C C Checkout and return. C CALL CHKOUT ( 'PDSBEG' ) RETURN END