Пример #1
0
f_exit(void)
#endif
{	int i;
	static cllist xx;
	if (!xx.cerr) {
		xx.cerr=1;
		xx.csta=NULL;
		for(i=0;i<MXUNIT;i++)
		{
			xx.cunit=i;
			(void) f_clos(&xx);
		}
	}
}
Пример #2
0
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Subroutine */ int snfilewrapper_(char *name__, integer *ispec, integer *
	inform__, char *cw, integer *lencw, integer *iw, integer *leniw, 
	doublereal *rw, integer *lenrw, ftnlen name_len, ftnlen cw_len)
{
    /* System generated locals */
    olist o__1;
    cllist cl__1;

    /* Builtin functions */
    integer f_open(olist *), f_clos(cllist *);

    /* Local variables */
    extern /* Subroutine */ int snspec_(integer *, integer *, char *, integer 
	    *, integer *, integer *, doublereal *, integer *, ftnlen);
    static integer iostat;

/*     ================================================================== */
/*     Read options for snopt from the file named name. inform .eq 0 if */
/*     successful. */

/*     09 Jan 2000: First version of snfilewrapper. */
/*     ================================================================== */
    /* Parameter adjustments */
    cw -= 8;
    --iw;
    --rw;

    /* Function Body */
    o__1.oerr = 1;
    o__1.ounit = *ispec;
    o__1.ofnmlen = name_len;
    o__1.ofnm = name__;
    o__1.orl = 0;
    o__1.osta = "old";
    o__1.oacc = 0;
    o__1.ofm = 0;
    o__1.oblnk = 0;
    iostat = f_open(&o__1);
    if (0 != iostat) {
	*inform__ = iostat + 2;
    } else {
	snspec_(ispec, inform__, cw + 8, lencw, &iw[1], leniw, &rw[1], lenrw, 
		(ftnlen)8);
	cl__1.cerr = 0;
	cl__1.cunit = *ispec;
	cl__1.csta = 0;
	f_clos(&cl__1);
    }
    return 0;
} /* snfilewrapper_ */
Пример #3
0
/* subroutine snoptopenappend */
/* Subroutine */ int snclose_(integer *iunit)
{
    /* System generated locals */
    cllist cl__1;

    /* Builtin functions */
    integer f_clos(cllist *);

/*     ================================================================== */
/*     Close unit iunit. */

/*     09 Jan 2000: First version of snoptclose */
/*     ================================================================== */
    cl__1.cerr = 0;
    cl__1.cunit = *iunit;
    cl__1.csta = 0;
    f_clos(&cl__1);
    return 0;
} /* snclose_ */
Пример #4
0
void
f_exit(void)
{
	static int run = 0;
	int i;
	static cllist xx;
	/* Do not execute f_exit() twice */
	if (run)
		return;
	run = 1;
	if (!xx.cerr) {
		xx.cerr=1;
		xx.csta=NULL;
		for(i=0;i<MXUNIT;i++)
		{
			xx.cunit=i;
			(void) f_clos(&xx);
		}
	}
}
Пример #5
0
/* $Procedure SPCA2B ( SPK and CK, ASCII to binary ) */
/* Subroutine */ int spca2b_(char *text, char *binary, ftnlen text_len, 
	ftnlen binary_len)
{
    /* System generated locals */
    cllist cl__1;

    /* Builtin functions */
    integer f_clos(cllist *);

    /* Local variables */
    integer unit;
    extern /* Subroutine */ int chkin_(char *, ftnlen), spct2b_(integer *, 
	    char *, ftnlen), chkout_(char *, ftnlen);
    extern logical return_(void);
    extern /* Subroutine */ int txtopr_(char *, integer *, ftnlen);

/* $ Abstract */

/*     Convert a text (ASCII) format SPK or CK file to an equivalent */
/*     binary file, including comments. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     SPC */

/* $ Keywords */

/*     FILES */

/* $ Declarations */
/* $ Brief_I/O */

/*     Variable  I/O  Description */
/*     --------  ---  -------------------------------------------------- */
/*     TEXT       I   Name of an existing text format SPK or CK file. */
/*     BINARY     I   Name of a binary SPK or CK file to be created. */

/* $ Detailed_Input */

/*     TEXT        is the name of an existing text format SPK or CK */
/*                 file that may contain comments in the appropriate */
/*                 SPC format, as written by SPCB2A or SPCB2T.  This */
/*                 file is unchanged by calling SPCA2B. */

/*     BINARY      is the name of a binary SPK or CK file to be created. */
/*                 The binary file contains the same data and comments */
/*                 as the text file, but in the binary format required */
/*                 for use with the SPICELIB reader subroutines. */

/* $ Detailed_Output */

/*     None. */

/* $ Parameters */

/*     None. */

/* $ Files */

/*     See arguments TEXT and BINARY above. */

/* $ Exceptions */

/*     1) If there is an IOSTAT error while opening, reading, */
/*        or writing a file, a routine that SPCA2B calls will */
/*        diagnose and signal an error. */

/*     2) If the text file is not in the correct format, a */
/*        routine that SPCA2B calls will diagnose and signal */
/*        an error. */

/* $ Particulars */

/*     The SPICELIB SPK and CK reader subroutines read binary files. */
/*     However, because different computing environments have different */
/*     binary representations of numbers, you must convert SPK and CK */
/*     files to text format when porting from one system to another. */
/*     After converting the file to text, you can transfer it using */
/*     a transfer protocol program like Kermit or FTP.  Then, convert */
/*     the text file back to binary format. */

/*     The following is a list of the SPICELIB routines that convert */
/*     SPK and CK files between binary and text format: */

/*        SPCA2B    converts text to binary.  It opens the text file, */
/*                  creates a new binary file, and closes both files. */

/*        SPCB2A    converts binary to text.  It opens the binary file, */
/*                  creates a new text file, and closes both files. */

/*        SPCT2B    converts text to binary.  It creates a new binary */
/*                  file and closes it.  The text file is open on */
/*                  entrance and exit. */

/*        SPCB2T    converts binary to text.  It opens the binary */
/*                  file and closes it.  The text file is open on */
/*                  entrance and exit */

/*     See the SPC required reading for more information */
/*     about SPC routines and the SPK and CK file formats. */

/* $ Examples */

/*     This is an example of how to use SPCB2A and SPCA2B for */
/*     transferring files.  Suppose A.BSP is a binary SPK file in */
/*     environment 1; to transfer it to environment 2, follow */
/*     these three steps: */

/*        1) Call SPCB2A within a program in environment 1 to convert */
/*           the file to text: */

/*              CALL SPCB2A ( 'A.BSP', 'A.TSP' ) */

/*        2) Transfer the text file from environment 1 to environment 2 */
/*           using FTP, Kermit, or some other file transfer utility, */
/*           for example, */

/*              ftp> put A.TSP */

/*        3) Call SPCA2B within a program in environment 2 to convert */
/*           the file to binary on the new machine, */

/*              CALL SPCA2B ( 'A.TSP', 'A.BSP' ) */

/* $ Restrictions */

/*     1)  This routine assumes that the data and comments in the */
/*         text format SPK or CK file come from a binary file */
/*         and were written by one of the routines SPCB2A or SPCB2T. */
/*         Data and/or comments written any other way may not be */
/*         in the correct format and, therefore, may not be handled */
/*         properly. */

/* $ Literature_References */

/*     None. */

/* $ Author_and_Institution */

/*     J.E. McLean    (JPL) */
/*     H.A. Neilan    (JPL) */

/* $ Version */

/* -    SPICELIB Version 1.1.1, 10-MAR-1992 (WLT) */

/*        Comment section for permuted index source lines was added */
/*        following the header. */

/* -    SPICELIB Version 1.1.0, 05-SEP-1991 (HAN) */

/*        Removed declarations of unused variables. */

/* -    SPICELIB Version 1.0.0, 05-APR-1991 (JEM) */

/* -& */
/* $ Index_Entries */

/*     ascii spk or ck to binary */

/* -& */

/*     SPICELIB functions */


/*     Local parameters */

/*     Local variables */


/*     Standard SPICE error handling. */

    if (return_()) {
	return 0;
    } else {
	chkin_("SPCA2B", (ftnlen)6);
    }

/*     Open the text file with read access.  SPCT2B will */
/*     create the binary file and write the data and comments */
/*     to it.  Then we close the text file, and we're done. */

    txtopr_(text, &unit, text_len);
    spct2b_(&unit, binary, binary_len);
    cl__1.cerr = 0;
    cl__1.cunit = unit;
    cl__1.csta = 0;
    f_clos(&cl__1);
    chkout_("SPCA2B", (ftnlen)6);
    return 0;
} /* spca2b_ */
Пример #6
0
/* $Procedure GETFAT ( Get file architecture and type ) */
/* Subroutine */ int getfat_(char *file, char *arch, char *kertyp, ftnlen 
	file_len, ftnlen arch_len, ftnlen kertyp_len)
{
    /* System generated locals */
    integer i__1;
    cilist ci__1;
    olist o__1;
    cllist cl__1;
    inlist ioin__1;

    /* Builtin functions */
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
    integer s_cmp(char *, char *, ftnlen, ftnlen), f_inqu(inlist *), s_rnge(
	    char *, integer, char *, integer), f_open(olist *), s_rdue(cilist 
	    *), do_uio(integer *, char *, ftnlen), e_rdue(void), f_clos(
	    cllist *), s_rsfe(cilist *), do_fio(integer *, char *, ftnlen), 
	    e_rsfe(void);

    /* Local variables */
    integer unit;
    extern /* Subroutine */ int zzddhfnh_(char *, integer *, logical *, 
	    ftnlen), zzddhgsd_(char *, integer *, char *, ftnlen, ftnlen), 
	    zzddhnfo_(integer *, char *, integer *, integer *, integer *, 
	    logical *, ftnlen), zzddhhlu_(integer *, char *, logical *, 
	    integer *, ftnlen);
    integer i__;
    extern integer cardi_(integer *);
    char fname[255];
    extern /* Subroutine */ int chkin_(char *, ftnlen), ucase_(char *, char *,
	     ftnlen, ftnlen);
    integer which;
    extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
    logical found, exist;
    extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen), 
	    idw2at_(char *, char *, char *, ftnlen, ftnlen, ftnlen);
    integer handle;
    extern /* Subroutine */ int dafcls_(integer *);
    char filarc[32];
    extern /* Subroutine */ int dashof_(integer *);
    integer intbff;
    logical opened;
    extern /* Subroutine */ int dafopr_(char *, integer *, ftnlen);
    integer intarc;
    extern /* Subroutine */ int dashlu_(integer *, integer *);
    char idword[12];
    integer intamn, number;
    logical diropn, notdas;
    extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *, 
	    ftnlen), getlun_(integer *), setmsg_(char *, ftnlen);
    integer iostat;
    extern /* Subroutine */ int errint_(char *, integer *, ftnlen), ssizei_(
	    integer *, integer *), nextwd_(char *, char *, char *, ftnlen, 
	    ftnlen, ftnlen);
    char tmpwrd[12];
    extern logical return_(void);
    integer myunit, handles[106];
    extern /* Subroutine */ int zzckspk_(integer *, char *, ftnlen);

    /* Fortran I/O blocks */
    static cilist io___19 = { 1, 0, 1, 0, 1 };


/* $ Abstract */

/*     Determine the architecture and type of SPICE kernels. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     None. */

/* $ Keywords */

/*     KERNEL */
/*     UTILITY */

/* $ Declarations */

/* $ Abstract */

/*     Parameter declarations for the DAF/DAS handle manager. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     DAF, DAS */

/* $ Keywords */

/*     PRIVATE */

/* $ Particulars */

/*     This include file contains parameters defining limits and */
/*     integer codes that are utilized in the DAF/DAS handle manager */
/*     routines. */

/* $ Restrictions */

/*     None. */

/* $ Author_and_Institution */

/*     F.S. Turner       (JPL) */

/* $ Literature_References */

/*     None. */

/* $ Version */

/* -    SPICELIB Version 2.5.0, 10-MAR-2014 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-INTEL. */

/* -    SPICELIB Version 2.4.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-LINUX-64BIT-IFORT. */

/* -    SPICELIB Version 2.3.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-GFORTRAN. */

/* -    SPICELIB Version 2.2.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-64BIT-GFORTRAN. */

/* -    SPICELIB Version 2.1.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-64BIT-GCC_C. */

/* -    SPICELIB Version 2.0.0, 12-APR-2012 (BVS) */

/*        Increased FTSIZE (from 1000 to 5000). */

/* -    SPICELIB Version 1.20.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL. */

/* -    SPICELIB Version 1.19.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL-CC_C. */

/* -    SPICELIB Version 1.18.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL-64BIT-CC_C. */

/* -    SPICELIB Version 1.17.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-NATIVE_C. */

/* -    SPICELIB Version 1.16.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-WINDOWS-64BIT-IFORT. */

/* -    SPICELIB Version 1.15.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-LINUX-64BIT-GFORTRAN. */

/* -    SPICELIB Version 1.14.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-64BIT-MS_C. */

/* -    SPICELIB Version 1.13.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-INTEL_C. */

/* -    SPICELIB Version 1.12.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-IFORT. */

/* -    SPICELIB Version 1.11.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-GFORTRAN. */

/* -    SPICELIB Version 1.10.0, 18-MAR-2009 (BVS) */

/*        Updated for PC-LINUX-GFORTRAN. */

/* -    SPICELIB Version 1.9.0, 18-MAR-2009 (BVS) */

/*        Updated for MAC-OSX-GFORTRAN. */

/* -    SPICELIB Version 1.8.0, 19-FEB-2008 (BVS) */

/*        Updated for PC-LINUX-IFORT. */

/* -    SPICELIB Version 1.7.0, 14-NOV-2006 (BVS) */

/*        Updated for PC-LINUX-64BIT-GCC_C. */

/* -    SPICELIB Version 1.6.0, 14-NOV-2006 (BVS) */

/*        Updated for MAC-OSX-INTEL_C. */

/* -    SPICELIB Version 1.5.0, 14-NOV-2006 (BVS) */

/*        Updated for MAC-OSX-IFORT. */

/* -    SPICELIB Version 1.4.0, 14-NOV-2006 (BVS) */

/*        Updated for PC-WINDOWS-IFORT. */

/* -    SPICELIB Version 1.3.0, 26-OCT-2005 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-GCC_C. */

/* -    SPICELIB Version 1.2.0, 03-JAN-2005 (BVS) */

/*        Updated for PC-CYGWIN_C. */

/* -    SPICELIB Version 1.1.0, 03-JAN-2005 (BVS) */

/*        Updated for PC-CYGWIN. */

/* -    SPICELIB Version 1.0.1, 17-JUL-2002 */

/*        Added MAC-OSX environments. */

/* -    SPICELIB Version 1.0.0, 07-NOV-2001 */

/* -& */

/*     Unit and file table size parameters. */

/*     FTSIZE     is the maximum number of files (DAS and DAF) that a */
/*                user may have open simultaneously. */


/*     RSVUNT     is the number of units protected from being locked */
/*                to a particular handle by ZZDDHHLU. */


/*     SCRUNT     is the number of units protected for use by scratch */
/*                files. */


/*     UTSIZE     is the maximum number of logical units this manager */
/*                will utilize at one time. */


/*     Access method enumeration.  These parameters are used to */
/*     identify which access method is associated with a particular */
/*     handle.  They need to be synchronized with the STRAMH array */
/*     defined in ZZDDHGSD in the following fashion: */

/*        STRAMH ( READ   ) = 'READ' */
/*        STRAMH ( WRITE  ) = 'WRITE' */
/*        STRAMH ( SCRTCH ) = 'SCRATCH' */
/*        STRAMH ( NEW    ) = 'NEW' */

/*     These values are used in the file table variable FTAMH. */


/*     Binary file format enumeration.  These parameters are used to */
/*     identify which binary file format is associated with a */
/*     particular handle.  They need to be synchronized with the STRBFF */
/*     array defined in ZZDDHGSD in the following fashion: */

/*        STRBFF ( BIGI3E ) = 'BIG-IEEE' */
/*        STRBFF ( LTLI3E ) = 'LTL-IEEE' */
/*        STRBFF ( VAXGFL ) = 'VAX-GFLT' */
/*        STRBFF ( VAXDFL ) = 'VAX-DFLT' */

/*     These values are used in the file table variable FTBFF. */


/*     Some random string lengths... more documentation required. */
/*     For now this will have to suffice. */


/*     Architecture enumeration.  These parameters are used to identify */
/*     which file architecture is associated with a particular handle. */
/*     They need to be synchronized with the STRARC array defined in */
/*     ZZDDHGSD in the following fashion: */

/*        STRARC ( DAF ) = 'DAF' */
/*        STRARC ( DAS ) = 'DAS' */

/*     These values will be used in the file table variable FTARC. */


/*     For the following environments, record length is measured in */
/*     characters (bytes) with eight characters per double precision */
/*     number. */

/*     Environment: Sun, Sun FORTRAN */
/*     Source:      Sun Fortran Programmer's Guide */

/*     Environment: PC, MS FORTRAN */
/*     Source:      Microsoft Fortran Optimizing Compiler User's Guide */

/*     Environment: Macintosh, Language Systems FORTRAN */
/*     Source:      Language Systems FORTRAN Reference Manual, */
/*                  Version 1.2, page 12-7 */

/*     Environment: PC/Linux, g77 */
/*     Source:      Determined by experiment. */

/*     Environment: PC, Lahey F77 EM/32 Version 4.0 */
/*     Source:      Lahey F77 EM/32 Language Reference Manual, */
/*                  page 144 */

/*     Environment: HP-UX 9000/750, FORTRAN/9000 Series 700 computers */
/*     Source:      FORTRAN/9000 Reference-Series 700 Computers, */
/*                  page 5-110 */

/*     Environment: NeXT Mach OS (Black Hardware), */
/*                  Absoft Fortran Version 3.2 */
/*     Source:      NAIF Program */


/*     The following parameter defines the size of a string used */
/*     to store a filenames on this target platform. */


/*     The following parameter controls the size of the character record */
/*     buffer used to read data from non-native files. */

/* $ Brief_I/O */

/*      VARIABLE  I/O  DESCRIPTION */
/*      --------  ---  -------------------------------------------------- */
/*      FILE       I   The name of a file to be examined. */
/*      ARCH       O   The architecture of the kernel file. */
/*      KERTYP     O   The type of the kernel file. */

/* $ Detailed_Input */

/*     FILE        is the name of a SPICE kernel file whose architecture */
/*                 and type are desired. */

/* $ Detailed_Output */

/*     ARCH        is the file architecture of the SPICE kernel file */
/*                 specified be FILE. If the architecture cannot be */
/*                 determined or is not recognized the value '?' is */
/*                 returned. */

/*                 Architectures currently recognized are: */

/*                    DAF - The file is based on the DAF architecture. */
/*                    DAS - The file is based on the DAS architecture. */
/*                    XFR - The file is in a SPICE transfer file format. */
/*                    DEC - The file is an old SPICE decimal text file. */
/*                    ASC -- An ASCII text file. */
/*                    KPL -- Kernel Pool File (i.e., a text kernel) */
/*                    TXT -- An ASCII text file. */
/*                    TE1 -- Text E-Kernel type 1. */
/*                     ?  - The architecture could not be determined. */

/*                 This variable must be at least 3 characters long. */

/*     KERTYP      is the type of the SPICE kernel file. If the type */
/*                 can not be determined the value '?' is returned. */

/*                 Kernel file types may be any sequence of at most four */
/*                 printing characters. NAIF has reserved for its use */
/*                 types which contain all upper case letters. */

/*                 A file type of 'PRE' means that the file is a */
/*                 pre-release file. */

/*                 This variable may be at most 4 characters long. */

/* $ Parameters */

/*     RECL        is the record length of a binary kernel file. Each */
/*                 record must be large enough to hold 128 double */
/*                 precision numbers. The units in which the record */
/*                 length must be specified vary from environment to */
/*                 environment. For example, VAX Fortran requires */
/*                 record lengths to be specified in longwords, */
/*                 where two longwords equal one double precision */
/*                 number. */

/* $ Exceptions */

/*      1) If the filename specified is blank, then the error */
/*         SPICE(BLANKFILENAME) is signaled. */

/*      2) If any inquire on the filename specified by FILE fails for */
/*         some reason, the error SPICE(INQUIREERROR) is signaled. */

/*      3) If the file specified by FILE does not exist, the error */
/*         SPICE(FILENOTFOUND) is signaled. */

/*      4) If the file specified by FILE is already open but not through */
/*         SPICE interfaces, the error SPICE(EXTERNALOPEN) is signaled. */

/*      5) If an attempt to open the file specified by FILE fails when */
/*         this routine requires that it succeed, the error */
/*         SPICE(FILEOPENFAILED) is signaled. */

/*      6) If an attempt to read the file specified by FILE fails when */
/*         this routine requires that it succeed, the error */
/*         SPICE(FILEREADFAILED) is signaled. */

/*      7) Routines in the call tree of this routine may trap and */
/*         signal errors. */

/*      8) If the ID word in a DAF based kernel is NAIF/DAF, then the */
/*         algorithm GETFAT uses to distinguish between CK and SPK */
/*         kernels may result in an indeterminate KERTYP if the SPK or */
/*         CK files have invalid first segments. */

/* $ Files */

/*     The SPICE kernel file specified by FILE is examined by this */
/*     routine to determine its architecture and type.  If the file */
/*     named by FILE is not connected to a logical unit or loaded */
/*     in the handle manager, this routine will OPEN and CLOSE it. */

/* $ Particulars */

/*     This subroutine is a support utility routine that determines the */
/*     architecture and type of a SPICE kernel file. */

/* $ Examples */

/*     Suppose you wish to write a single routine for loading binary */
/*     kernels. You can use this routine to determine the type of the */
/*     file and  then pass the file to the appropriate low level file */
/*     loader to handle the actual loading of the file. */

/*        CALL GETFAT ( FILE, ARCH, KERTYP ) */

/*        IF ( KERTYP .EQ. 'SPK' ) THEN */

/*           CALL SPKLEF ( FILE, HANDLE ) */

/*        ELSE IF ( KERTYP .EQ. 'CK' ) THEN */

/*           CALL CKLPF ( FILE, HANDLE ) */

/*        ELSE IF ( KERTYP .EQ. 'EK' ) THEN */

/*           CALL EKLEF ( FILE, HANDLE ) */

/*        ELSE */

/*           WRITE (*,*) 'The file could not be identified as a known' */
/*           WRITE (*,*) 'kernel type.  Did you load the wrong file' */
/*           WRITE (*,*) 'by mistake?' */

/*        END IF */


/* $ Restrictions */

/*     1) In order to properly determine the type of DAF based binary */
/*        kernels, the routine requires that their first segments and */
/*        the meta data necessary to address them are valid. */

/* $ Literature_References */

/*     None. */

/* $ Author_and_Institution */

/*     K.R. Gehringer  (JPL) */
/*     H.A. Neilan     (JPL) */
/*     W.L. Taber      (JPL) */
/*     F.S. Turner     (JPL) */
/*     E.D. Wright     (JPL) */

/* $ Version */

/* -    SPICELIB Version 4.25.0, 10-MAR-2014 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-INTEL. */

/* -    SPICELIB Version 4.24.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-LINUX-64BIT-IFORT. */

/* -    SPICELIB Version 4.23.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-GFORTRAN. */

/* -    SPICELIB Version 4.22.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-64BIT-GFORTRAN. */

/* -    SPICELIB Version 4.21.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-64BIT-GCC_C. */

/* -    SPICELIB Version 4.20.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL. */

/* -    SPICELIB Version 4.19.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL-CC_C. */

/* -    SPICELIB Version 4.18.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL-64BIT-CC_C. */

/* -    SPICELIB Version 4.17.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-NATIVE_C. */

/* -    SPICELIB Version 4.16.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-WINDOWS-64BIT-IFORT. */

/* -    SPICELIB Version 4.15.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-LINUX-64BIT-GFORTRAN. */

/* -    SPICELIB Version 4.14.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-64BIT-MS_C. */

/* -    SPICELIB Version 4.13.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-INTEL_C. */

/* -    SPICELIB Version 4.12.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-IFORT. */

/* -    SPICELIB Version 4.11.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-GFORTRAN. */

/* -    SPICELIB Version 4.10.0, 18-MAR-2009 (BVS) */

/*        Updated for PC-LINUX-GFORTRAN. */

/* -    SPICELIB Version 4.9.0, 18-MAR-2009 (BVS) */

/*        Updated for MAC-OSX-GFORTRAN. */

/* -    SPICELIB Version 4.8.0, 19-FEB-2008 (BVS) */

/*        Updated for PC-LINUX-IFORT. */

/* -    SPICELIB Version 4.7.0, 14-NOV-2006 (BVS) */

/*        Updated for PC-LINUX-64BIT-GCC_C. */

/* -    SPICELIB Version 4.6.0, 14-NOV-2006 (BVS) */

/*        Updated for MAC-OSX-INTEL_C. */

/* -    SPICELIB Version 4.5.0, 14-NOV-2006 (BVS) */

/*        Updated for MAC-OSX-IFORT. */

/* -    SPICELIB Version 4.4.0, 14-NOV-2006 (BVS) */

/*        Updated for PC-WINDOWS-IFORT. */

/* -    SPICELIB Version 4.3.0, 26-OCT-2005 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-GCC_C. */

/* -    SPICELIB Version 4.2.0, 03-JAN-2005 (BVS) */

/*        Updated for PC-CYGWIN_C. */

/* -    SPICELIB Version 4.1.0, 03-JAN-2005 (BVS) */

/*        Updated for PC-CYGWIN. */

/* -    SPICELIB Version 4.0.2, 24-APR-2003 (EDW) */

/*        Added MAC-OSX-F77 to the list of platforms */
/*        that require READONLY to read write protected */
/*        kernels. */

/* -    SPICELIB Version 4.0.1, 17-JUL-2002 (BVS) */

/*        Added MAC-OSX environments. */

/* -    SPICELIB Version 4.0.0, 22-AUG-2001 (WLT) (FST) (EDW) */

/*        Added code so that the architecture and type of open binary */
/*        SPICE kernels can be determined. */

/*        Added exception for MACPPC_C (CodeWarrior Mac classic). */
/*        Reduced RECL value to 12 to prevent expression of */
/*        the fseek bug. */

/* -    SPICELIB Version 3.2.0, 06-DEC-1999 (WLT) */

/*        The heuristics for distinguishing between CK and SPK have */
/*        been enhanced so that the routine is no longer requires */
/*        that TICKS in C-kernels be positive or integral. */

/* -    SPICELIB Version 3.1.4, 08-OCT-1999 (WLT) */

/*        The environment lines were expanded so that the supported */
/*        environments are now explicitely given.  New */
/*        environments are WIN-NT */

/* -    SPICELIB Version 3.1.3, 22-SEP-1999 (NJB) */

/*        CSPICE environments were added.  Some typos were corrected. */

/* -    SPICELIB Version 3.1.2, 28-JUL-1999 (WLT) */

/*        The environment lines were expanded so that the supported */
/*        environments are now explicitly given.  New */
/*        environments are PC-DIGITAL, SGI-O32 and SGI-N32. */

/* -    SPICELIB Version 3.1.1, 18-MAR-1999 (WLT) */

/*        The environment lines were expanded so that the supported */
/*        environments are now explicitly given.  Previously, */
/*        environments such as SUN-SUNOS and SUN-SOLARIS were implied */
/*        by the environment label SUN. */

/* -    SPICELIB Version 3.1.0, 11-FEB-1999 (FST) */

/*        Added an integrality check to Test 3. If LASTDP is not */
/*        an integral value, then GETFAT simply returns KERTYP = '?', */
/*        since it is of an indeterminate type. */

/* -    SPICELIB Version 3.0.0, 07-APR-1998 (NJB) */

/*        Module was updated for the PC-LINUX platform. */

/* -     SPICELIB Version 2.0.0, 19-DEC-1995 (KRG) */

/*         Added several new features to the subroutine: */

/*         - Error handling has been enhanced. */
/*         - Several new file architectures have been added. */

/*         Removed the mention of 1000 characters as a candidate for the */
/*         record length of a file. */

/*         Added the exception for a blank filename to the header. The */
/*         error is signalled, but it was not listed in the header. */

/*         Added IOSTAT values to the appropriate error messages. */

/*         Non-printing characters are replaced with blanks in the ID */
/*         word when it is read. This deals with the case where a */
/*         platform allows a text file to be opened as an unformatted */
/*         file and the ID word does not completely fill 8 characters. */

/* -    SPICELIB Version 1.4.0, 5-JAN-1995 (HAN) */

/*        Removed ENV11 since it is now the same as ENV2. */
/*        Removed ENV10 since it is the same as the VAX environment. */

/* -    SPICELIB Version 1.3.0, 30-AUG-1994 (HAN) */

/*        Added two new environments, DEC Alpha/OpenVMS and */
/*        Sun/Solaris, to the source master file. */

/* -     SPICELIB Version 1.2.0, 25-MAR-1994 (HAN) */

/*         Added two new environments, DEC Alpha/OpenVMS and */
/*         Sun/Solaris, to the source master file. */

/* -     SPICELIB Version 1.1.0, 25-MAR-1994 (HAN) */

/*         Modified master source code file to use READONLY on platforms */
/*         that support it. Also, changed some local declaration comment */
/*         lines to match the standard NAIF template. */

/* -     SPICELIB Version 1.0.0, 24-JUL-1993 (WLT) (HAN) (KRG) */

/* -& */
/* $ Index_Entries */

/*     determine the architecture and type of a kernel file */

/* -& */
/* $ Revisions */

/* -    SPICELIB Version 4.0.0, 22-AUG-2001 (WLT) (FST) */

/*        Added code so that the architecture and type of open binary */
/*        SPICE kernels can be determined.  This uses the new DAF/DAS */
/*        handle manager as well as examination of handles of open DAS */
/*        files.  Currently the handle manager deals only with DAF */
/*        files. This routine should be updated again when the DAS */
/*        system is integrated with the handle manager. */

/*        Some slight changes were required to support ZZDDHFNH on */
/*        the VAX environment.  This resulted in the addition of */
/*        the logical USEFNH that is set to true in most */
/*        environments, and never used again other than to allow */
/*        the invocation of the ZZDDHFNH module. */

/* -     SPICELIB Version 2.0.0, 19-DEC-1995 (KRG) */

/*         Added several new features to the subroutine: */

/*         - Error handling has been enhanced. */
/*         - Several new file architectures have been added. */

/*         Removed the mention of 1000 characters as a candidate for the */
/*         record length of a file. It seems unlikely that we will */
/*         encounter an environment where 1000 characters of storage is */
/*         larger than the storage necessary for 128 double precision */
/*         numbers; typically there are 8 characters per double precision */
/*         number, yeilding 1024 characters. */

/*         Added the exception for a blank filename to the header. The */
/*         error is signalled, but it was not listed in the header. */

/*         Added IOSTAT values to the appropriate error messages. */

/*         Non-printing characters are replaced with blanks in the ID */
/*         word when it is read. This deals with the case where a */
/*         platform allows a text file to be opened as an unformatted */
/*         file and the ID word does not completely fill 8 characters. */

/* -& */

/*     SPICELIB functions */


/*     Local parameters */


/*     Set the length of a SPICE kernel file ID word. */


/*     Set minimum and maximum values for the range of ASCII printing */
/*     characters. */


/*     Local Variables */


/*     Standard SPICE error handling. */

    if (return_()) {
	return 0;
    } else {
	chkin_("GETFAT", (ftnlen)6);
    }

/*     Initialize the temporary storage variables that we use. */

    s_copy(idword, " ", (ftnlen)12, (ftnlen)1);

/*     If the filename we have is blank, signal an error and return. */

    if (s_cmp(file, " ", file_len, (ftnlen)1) == 0) {
	setmsg_("The file name is blank.", (ftnlen)23);
	sigerr_("SPICE(BLANKFILENAME)", (ftnlen)20);
	chkout_("GETFAT", (ftnlen)6);
	return 0;
    }

/*     See if this is a binary file that is currently open */
/*     within the SPICE binary file management subsystem.  At */
/*     the moment, as far as we know, the file is not opened. */

    opened = FALSE_;
    zzddhfnh_(file, &handle, &found, file_len);
    if (found) {

/*        If the file was recognized, we need to get the unit number */
/*        associated with it. */

	zzddhnfo_(&handle, fname, &intarc, &intbff, &intamn, &found, (ftnlen)
		255);

/*        Translate the architecture ID to a string and retrieve the */
/*        logical unit to use with this file. */

	zzddhgsd_("ARCH", &intarc, filarc, (ftnlen)4, (ftnlen)32);
	zzddhhlu_(&handle, filarc, &c_false, &number, (ftnlen)32);
	opened = TRUE_;
    } else {

/*        We'll do a bit of inquiring before we try opening anything. */

	ioin__1.inerr = 1;
	ioin__1.infilen = file_len;
	ioin__1.infile = file;
	ioin__1.inex = &exist;
	ioin__1.inopen = &opened;
	ioin__1.innum = 0;
	ioin__1.innamed = 0;
	ioin__1.inname = 0;
	ioin__1.inacc = 0;
	ioin__1.inseq = 0;
	ioin__1.indir = 0;
	ioin__1.infmt = 0;
	ioin__1.inform = 0;
	ioin__1.inunf = 0;
	ioin__1.inrecl = 0;
	ioin__1.innrec = 0;
	ioin__1.inblank = 0;
	iostat = f_inqu(&ioin__1);

/*        Not too likely, but if the INQUIRE statement fails... */

	if (iostat != 0) {
	    setmsg_("IOSTAT error in INQUIRE statement. IOSTAT = #.", (ftnlen)
		    46);
	    errint_("#", &iostat, (ftnlen)1);
	    sigerr_("SPICE(INQUIREERROR)", (ftnlen)19);
	    chkout_("GETFAT", (ftnlen)6);
	    return 0;
	}

/*        Note: the following two tests MUST be performed in the order */
/*        in which they appear, since in some environments files that do */
/*        not exist are considered to be open. */

	if (! exist) {
	    setmsg_("The kernel file '#' does not exist.", (ftnlen)35);
	    errch_("#", file, (ftnlen)1, file_len);
	    sigerr_("SPICE(FILENOTFOUND)", (ftnlen)19);
	    chkout_("GETFAT", (ftnlen)6);
	    return 0;
	}

/*        If the file is already open, it may be a DAS file. */

	if (opened) {

/*           At the moment, the handle manager doesn't manage DAS */
/*           handles.  As a result we need to treat the case of an open */
/*           DAS separately. When the Handle Manager is hooked in with */
/*           DAS as well as DAF, we should remove the block below. */

/*           =================================================== */
/*           DAS DAS DAS DAS DAS DAS DAS DAS DAS DAS DAS DAS DAS */
/*           vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */

/*           This file may or may not be a DAS file.  Until we */
/*           have determined otherwise, we assume it is not */
/*           a DAS file. */

	    notdas = TRUE_;
	    ioin__1.inerr = 1;
	    ioin__1.infilen = file_len;
	    ioin__1.infile = file;
	    ioin__1.inex = 0;
	    ioin__1.inopen = 0;
	    ioin__1.innum = &unit;
	    ioin__1.innamed = 0;
	    ioin__1.inname = 0;
	    ioin__1.inacc = 0;
	    ioin__1.inseq = 0;
	    ioin__1.indir = 0;
	    ioin__1.infmt = 0;
	    ioin__1.inform = 0;
	    ioin__1.inunf = 0;
	    ioin__1.inrecl = 0;
	    ioin__1.innrec = 0;
	    ioin__1.inblank = 0;
	    iostat = f_inqu(&ioin__1);
	    if (iostat != 0) {
		setmsg_("IOSTAT error in INQUIRE statement. IOSTAT = #.", (
			ftnlen)46);
		errint_("#", &iostat, (ftnlen)1);
		sigerr_("SPICE(INQUIREERROR)", (ftnlen)19);
		chkout_("GETFAT", (ftnlen)6);
		return 0;
	    }

/*           Get the set of handles of open DAS files.  We will */
/*           translate each of these handles to the associated */
/*           logical unit.  If the tranlation matches the result */
/*           of the inquire, this must be a DAS file and we */
/*           can proceed to determine the type. */

	    ssizei_(&c__100, handles);
	    dashof_(handles);
	    which = cardi_(handles);
	    while(which > 0) {
		dashlu_(&handles[(i__1 = which + 5) < 106 && 0 <= i__1 ? i__1 
			: s_rnge("handles", i__1, "getfat_", (ftnlen)654)], &
			myunit);
		if (unit == myunit) {
		    number = myunit;
		    which = 0;
		    notdas = FALSE_;
		} else {
		    --which;
		}
	    }

/*           If we reach this point and do not have a DAS, there */
/*           is no point in going on.  The user has opened this */
/*           file outside the SPICE system.  We shall not attempt */
/*           to determine its type. */

	    if (notdas) {
		setmsg_("The file '#' is already open.", (ftnlen)29);
		errch_("#", file, (ftnlen)1, file_len);
		sigerr_("SPICE(EXTERNALOPEN)", (ftnlen)19);
		chkout_("GETFAT", (ftnlen)6);
		return 0;
	    }
/*           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
/*           DAS DAS DAS DAS DAS DAS DAS DAS DAS DAS DAS DAS DAS */
/*           =================================================== */

	}
    }

/*     Open the file with a record length of RECL (the length of the */
/*     DAF and DAS records). We assume, for now, that opening the file as */
/*     a direct access file will work. */

    diropn = TRUE_;

/*     If the file is not already open (probably the case that */
/*     happens most frequently) we try opening it for direct access */
/*     and see if we can locate the idword. */

    if (! opened) {
	getlun_(&number);
	o__1.oerr = 1;
	o__1.ounit = number;
	o__1.ofnmlen = file_len;
	o__1.ofnm = file;
	o__1.orl = 1024;
	o__1.osta = "OLD";
	o__1.oacc = "DIRECT";
	o__1.ofm = 0;
	o__1.oblnk = 0;
	iostat = f_open(&o__1);

/*     If we had trouble opening the file, try opening it as a */
/*     sequential file. */

	if (iostat != 0) {
	    diropn = FALSE_;
	    o__1.oerr = 1;
	    o__1.ounit = number;
	    o__1.ofnmlen = file_len;
	    o__1.ofnm = file;
	    o__1.orl = 0;
	    o__1.osta = "OLD";
	    o__1.oacc = "SEQUENTIAL";
	    o__1.ofm = 0;
	    o__1.oblnk = 0;
	    iostat = f_open(&o__1);

/*        If we still have problems opening the file, we don't have a */
/*        clue about the file architecture and type. */

	    if (iostat != 0) {
		s_copy(arch, "?", arch_len, (ftnlen)1);
		s_copy(kertyp, "?", kertyp_len, (ftnlen)1);
		setmsg_("Attempt to open the file '#' failed. IOSTAT = #.", (
			ftnlen)48);
		errch_("#", file, (ftnlen)1, file_len);
		errint_("#", &iostat, (ftnlen)1);
		sigerr_("SPICE(FILEOPENFAILED)", (ftnlen)21);
		chkout_("GETFAT", (ftnlen)6);
		return 0;
	    }
	}
    }

/*     We opened the file successfully, so let's try to read from the */
/*     file. We need to be sure to use the correct form of the read */
/*     statement, depending on whether the file was opened with direct */
/*     acces or sequential access. */

    if (diropn) {
	io___19.ciunit = number;
	iostat = s_rdue(&io___19);
	if (iostat != 0) {
	    goto L100001;
	}
	iostat = do_uio(&c__1, tmpwrd, (ftnlen)12);
	if (iostat != 0) {
	    goto L100001;
	}
	iostat = e_rdue();
L100001:

/*        If we couldn't read from the file as a direct access file with */
/*        a fixed record length, then try to open the file as a */
/*        sequential file and read from it. */

	if (iostat != 0) {
	    if (opened) {

/*              Something has gone wrong here.  The file was opened */
/*              as either a DAF or DAS prior to the call to GETFAT. */
/*              We retrieved the unit number maintained by the */
/*              underlying binary file management system, but we */
/*              were unable to read the file as direct access. */
/*              There's nothing we can do but abandon our quest to */
/*              determine the type of the file. */

		setmsg_("The file '#' is opened as a binary SPICE kernel.  B"
			"ut it cannot be read using a direct access read. The"
			" value of IOSTAT returned by the attempted READ is #"
			". ", (ftnlen)157);
		errch_("#", file, (ftnlen)1, file_len);
		errint_("#", &iostat, (ftnlen)1);
		sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
		chkout_("GETFAT", (ftnlen)6);
		return 0;
	    }

/*           If we reach this point, the file was opened locally */
/*           as a direct access file.  We could not read it that */
/*           way, so we'll try using a sequential read.   However, */
/*           we first need to close the file and then reopen it */
/*           for sequential reading. */

	    cl__1.cerr = 0;
	    cl__1.cunit = number;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    o__1.oerr = 1;
	    o__1.ounit = number;
	    o__1.ofnmlen = file_len;
	    o__1.ofnm = file;
	    o__1.orl = 0;
	    o__1.osta = "OLD";
	    o__1.oacc = "SEQUENTIAL";
	    o__1.ofm = 0;
	    o__1.oblnk = 0;
	    iostat = f_open(&o__1);

/*           If we could not open the file, we don't have a clue about */
/*           the file architecture and type. */

	    if (iostat != 0) {
		s_copy(arch, "?", arch_len, (ftnlen)1);
		s_copy(kertyp, "?", kertyp_len, (ftnlen)1);
		setmsg_("Attempt to open the file '#' failed. IOSTAT = #.", (
			ftnlen)48);
		errch_("#", file, (ftnlen)1, file_len);
		errint_("#", &iostat, (ftnlen)1);
		sigerr_("SPICE(FILEOPENFAILED)", (ftnlen)21);
		chkout_("GETFAT", (ftnlen)6);
		return 0;
	    }

/*           Try to read from the file. */

	    ci__1.cierr = 1;
	    ci__1.ciend = 1;
	    ci__1.ciunit = number;
	    ci__1.cifmt = "(A)";
	    iostat = s_rsfe(&ci__1);
	    if (iostat != 0) {
		goto L100002;
	    }
	    iostat = do_fio(&c__1, tmpwrd, (ftnlen)12);
	    if (iostat != 0) {
		goto L100002;
	    }
	    iostat = e_rsfe();
L100002:
	    ;
	}
    } else {
	ci__1.cierr = 1;
	ci__1.ciend = 1;
	ci__1.ciunit = number;
	ci__1.cifmt = "(A)";
	iostat = s_rsfe(&ci__1);
	if (iostat != 0) {
	    goto L100003;
	}
	iostat = do_fio(&c__1, tmpwrd, (ftnlen)12);
	if (iostat != 0) {
	    goto L100003;
	}
	iostat = e_rsfe();
L100003:
	;
    }

/*     If we had an error while reading, we don't recognize this file. */

    if (iostat != 0) {
	s_copy(arch, "?", arch_len, (ftnlen)1);
	s_copy(kertyp, "?", kertyp_len, (ftnlen)1);
	cl__1.cerr = 0;
	cl__1.cunit = number;
	cl__1.csta = 0;
	f_clos(&cl__1);
	setmsg_("Attempt to read from file '#' failed. IOSTAT = #.", (ftnlen)
		49);
	errch_("#", file, (ftnlen)1, file_len);
	errint_("#", &iostat, (ftnlen)1);
	sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
	chkout_("GETFAT", (ftnlen)6);
	return 0;
    }

/*     Close the file (if we opened it here), as we do not need it */
/*     to be open any more. */

    if (! opened) {
	cl__1.cerr = 0;
	cl__1.cunit = number;
	cl__1.csta = 0;
	f_clos(&cl__1);
    }

/*     At this point, we have a candidate for an ID word. To avoid */
/*     difficulties with Fortran I/O and other things, we will now */
/*     replace any non printing ASCII characters with blanks. */

    for (i__ = 1; i__ <= 12; ++i__) {
	if (*(unsigned char *)&tmpwrd[i__ - 1] < 32 || *(unsigned char *)&
		tmpwrd[i__ - 1] > 126) {
	    *(unsigned char *)&tmpwrd[i__ - 1] = ' ';
	}
    }

/*     Identify the architecture and type, if we can. */

    ljust_(tmpwrd, tmpwrd, (ftnlen)12, (ftnlen)12);
    ucase_(tmpwrd, tmpwrd, (ftnlen)12, (ftnlen)12);
    nextwd_(tmpwrd, idword, tmpwrd, (ftnlen)12, (ftnlen)12, (ftnlen)12);
    if (s_cmp(idword, "DAFETF", (ftnlen)12, (ftnlen)6) == 0) {

/*        We have a DAF encoded transfer file. */

	s_copy(arch, "XFR", arch_len, (ftnlen)3);
	s_copy(kertyp, "DAF", kertyp_len, (ftnlen)3);
    } else if (s_cmp(idword, "DASETF", (ftnlen)12, (ftnlen)6) == 0) {

/*        We have a DAS encoded transfer file. */

	s_copy(arch, "XFR", arch_len, (ftnlen)3);
	s_copy(kertyp, "DAS", kertyp_len, (ftnlen)3);
    } else if (s_cmp(idword, "'NAIF/DAF'", (ftnlen)10, (ftnlen)10) == 0) {

/*        We have an old DAF decimal text file. */

	s_copy(arch, "DEC", arch_len, (ftnlen)3);
	s_copy(kertyp, "DAF", kertyp_len, (ftnlen)3);
    } else if (s_cmp(idword, "NAIF/DAS", (ftnlen)8, (ftnlen)8) == 0) {

/*        We have a pre release DAS binary file. */

	s_copy(arch, "DAS", arch_len, (ftnlen)3);
	s_copy(kertyp, "PRE", kertyp_len, (ftnlen)3);
    } else {

/*        Get the architecture and type from the ID word, if we can. */

	idw2at_(idword, arch, kertyp, (ftnlen)8, arch_len, kertyp_len);
    }

/*     If the architecture is DAF and the type is unknown, '?', then we */
/*     have either an SPK file, a CK file, or something we don't */
/*     understand. Let's check it out. */

    if (s_cmp(arch, "DAF", arch_len, (ftnlen)3) == 0 && s_cmp(kertyp, "?", 
	    kertyp_len, (ftnlen)1) == 0) {

/*        We have a DAF file and we do not know what the type is. This */
/*        situation can occur for older SPK and CK files, before the ID */
/*        word was used to store type information. */

/*        We use Bill's (WLT'S) magic heuristics to determine the type */
/*        of the file. */

/*        Open the file and pass the handle to the private routine */
/*        that deals with the dirty work. */

	dafopr_(file, &handle, file_len);
	zzckspk_(&handle, kertyp, kertyp_len);
	dafcls_(&handle);
    }
    chkout_("GETFAT", (ftnlen)6);
    return 0;
} /* getfat_ */
Пример #7
0
/* $Procedure   COMMNT ( Comment utility program ) */
/* Main program */ MAIN__(void)
{
    /* Initialized data */

    static logical insbln = TRUE_;
    static char maintl[20] = "COMMNT Options      ";
    static char mainvl[20*5] = "QUIT                " "ADD_COMMENTS        " 
	    "READ_COMMENTS       " "EXTRACT_COMMENTS    " "DELETE_COMMENTS  "
	    "   ";
    static char maintx[40*5] = "Quit.                                   " 
	    "Add comments to a binary file.          " "Read the comments in"
	    " a binary file.     " "Extract comments from a binary file.    " 
	    "Delete the comments in a binary file.   ";
    static char mainnm[1*5] = "Q" "A" "R" "E" "D";

    /* System generated locals */
    address a__1[3];
    integer i__1[3], i__2, i__3, i__4, i__5;
    cllist cl__1;

    /* Builtin functions */
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen), s_cat(char *,
	     char **, integer *, integer *, ftnlen);
    integer s_rnge(char *, integer, char *, integer), s_cmp(char *, char *, 
	    ftnlen, ftnlen), f_clos(cllist *);

    /* Local variables */
    static char arch[3];
    static logical done;
    static char line[1000];
    static logical more;
    static integer iopt;
    static char type__[4];
    static integer i__;
    extern /* Subroutine */ int dasdc_(integer *);
    extern integer cardi_(integer *);
    static integer r__;
    extern /* Subroutine */ int spcac_(integer *, integer *, char *, char *, 
	    ftnlen, ftnlen), chkin_(char *, ftnlen), spcec_(integer *, 
	    integer *), spcdc_(integer *), errch_(char *, char *, ftnlen, 
	    ftnlen), repmc_(char *, char *, char *, char *, ftnlen, ftnlen, 
	    ftnlen, ftnlen), reset_(void);
    extern integer rtrim_(char *, ftnlen);
    extern logical failed_(void);
    extern /* Subroutine */ int dafhof_(integer *);
    static integer handle;
    extern /* Subroutine */ int dafcls_(integer *), dasacu_(integer *, char *,
	     char *, logical *, integer *, ftnlen, ftnlen), cleari_(integer *,
	     integer *), delfil_(char *, ftnlen), dasecu_(integer *, integer *
	    , logical *), scardi_(integer *, integer *), dashof_(integer *);
    static logical fileok;
    extern /* Subroutine */ int clcomm_(void), getfat_(char *, char *, char *,
	     ftnlen, ftnlen, ftnlen), cnfirm_(char *, logical *, ftnlen);
    static char fnmtbl[128*2], messag[1000], errmsg[320], messgs[1000*7], 
	    option[20], prmtbl[80*2], statbl[3*2];
    extern logical exists_(char *, ftnlen);
    static integer comlun;
    static char status[1000*2];
    static integer numfnm;
    static char prmpts[80*2];
    static integer numopn, opnset[7], tblidx[2];
    static logical comnts, contnu, ndfnms, tryagn;
    extern /* Subroutine */ int tkvrsn_(char *, char *, ftnlen, ftnlen), 
	    erract_(char *, char *, ftnlen, ftnlen), errprt_(char *, char *, 
	    ftnlen, ftnlen), tostdo_(char *, ftnlen), ssizei_(integer *, 
	    integer *), getopt_(char *, integer *, char *, char *, integer *, 
	    ftnlen, ftnlen, ftnlen), getfnm_(char *, char *, char *, logical *
	    , char *, ftnlen, ftnlen, ftnlen, ftnlen), setmsg_(char *, ftnlen)
	    , sigerr_(char *, ftnlen), txtopr_(char *, integer *, ftnlen), 
	    dafopw_(char *, integer *, ftnlen), dasopw_(char *, integer *, 
	    ftnlen), dascls_(integer *), dafopr_(char *, integer *, ftnlen), 
	    spcrfl_(integer *, char *, logical *, ftnlen), spcrnl_(char *, 
	    logical *, ftnlen), dasopr_(char *, integer *, ftnlen), txtopn_(
	    char *, integer *, ftnlen), chkout_(char *, ftnlen);
    static logical eoc;
    static char tkv[12];

/* $ Abstract */

/*     NAIF Toolkit utility program for adding, reading, extracting, */
/*     and deleting comments from a binary file. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     SPC */
/*     DAS */

/* $ Author_and_Institution */

/*     W.L. Taber     (JPL) */
/*     K.R. Gehringer (JPL) */
/*     J.E. McLean    (JPL) */
/*     M.J. Spencer   (JPL) */

/* $ Version */

/* -    Version 6.0.1, 08-MAY-2001 (BVS) */

/*       Increased LINLEN from 255 to 1000 to make it consistent */
/*       with SPICELIB's SPC* and SUPPORT's DAF* internal line sizes. */

/* -    Version 5.0.1, 21-JUL-1997 (WLT) */

/*       Modified the banner at start up so that the version of the */
/*       toolkit used to link COMMNT will be displayed. */

/*       In addition all WRITE statements were replaced by calls to */
/*       TOSTDO. */

/* -    Version 5.0.0, 05-MAY-1994 (KRG) */

/*       Modified the program to use the new file type identification */
/*       capability that was added to spicelib. No file type menu is */
/*       necessary now, as the file type is determined during the */
/*       execution of the program. */

/*       The prompts for the begin and end markers used to extract a */
/*       subset of text lines from an input comment file which were then */
/*       placed into the comment area of a SPICE binary kernel file have */
/*       been removed. The entire input comment file is now placed into */
/*       the comment area of the binary kernel file. This change */
/*       simplifies the user interaction with the program. */

/*       Added support for the new PCK binary kernel files. */

/*       If an error occurs during the extraction of comments to a file, */
/*       the file that was being created is deleted. We cannot know */
/*       whether the file had been successfully created before the error */
/*       occurred. */

/* -    Version 4.0.0, 11-DEC-1992 (KRG) */

/*        Added code to support the E-Kernel, and redesigned the */
/*        user interface. */

/* -    Version 3.1.0, 19-NOV-1991 (MJS) */

/*        Variable QUIT initialized to FALSE. */

/* -    Version 3.0.1, 10-AUG-1991 (CHA) (NJB) */

/*        Updated comments to reflect status as a Toolkit */
/*        utility program.  Message indicating that no comments */
/*        were found in the specified file was changed to include */
/*        the file name. */

/* -    Version 2.0.0, 28-JUN-1991 (JEM) */

/*        The option to read the comments from the comment */
/*        area of a binary SPK or CK was added to the menu. */

/* -    Version 1.0.0, 05-APR-1991 (JEM) */

/* -& */

/*     SPICELIB functions */


/*     Parameters */

/*     Set the version of the comment program. This should be updated */
/*     every time a change is made, and it should agree with the */
/*     version number in the header. */


/*     Set a value for the logical unit which represents the standard */
/*     output device, commonly a terminal. A value of 6 is widely used, */
/*     but the Fortran standard does not specify a value, so it may be */
/*     different for different Fortran implementations. */


/*     Lower bound for a SPICELIB CELL data structure. */


/*     Maximum number of open binary files allowed. */


/*     Set a value for a replacement marker. */


/*     Set a value for a filename prompt. */


/*     File types */


/*     Set a value for the length of a text line. */


/*     Set a value for the length of an error message. */


/*     Set a value for the length of a filename. */


/*     Set a length for the prompts in the prompt table. */


/*     Set a length for the status of a file: 'OLD' or 'NEW'. */


/*     Set the length for the architecture of a file. */


/*     Set the length for the type of a file. */


/*     Set a length for the option values. */


/*     Set a length for the title of a menu. */


/*     Set a length for an option name (what is typed to select it) */
/*     for a menu. */


/*     Set the length of the text description of an option on a menu. */


/*     The number of options available on the main menu. */


/*     Set up some mnemonics for indexing the prompts in the prompt */
/*     table. */


/*     Set the maximum size of the filename table: this must be the */
/*     number of distinct ``types'' of files that the program may */
/*     require. */


/*     Set up some mnemonics for indexing the messages in the message */
/*     table. */


/*     Set the maximum size of the message table: There should be a */
/*     message for each ``type'' of action that the program can take. */


/*     Set up some mnemonics for the OK and not OK status messages. */


/*     Set the maximum number of status messages that are available. */


/*     We need to have TKVLEN characters to hold the current version */
/*     of the toolkit. */


/*     Variables */


/*     We want to insert a blank line between additions if there are */
/*     already comments in the binary file. We indicate this by giving */
/*     the variable INSBLN the value .TRUE.. */


/*     Define the main menu title ... */


/*     Define the main menu option values ... */


/*     Define the main menu descriptive text for each option ... */


/*     Define the main menu option names ... */


/*     Register the COMMNT main program with the SPICELIB error handler. */

    chkin_("COMMNT", (ftnlen)6);
    clcomm_();
    tkvrsn_("TOOLKIT", tkv, (ftnlen)7, (ftnlen)12);
    r__ = rtrim_(tkv, (ftnlen)12);

/*     Set the error action to 'RETURN'. We don't want the program */
/*     to abort if an error is signalled. We check FAILED where */
/*     necessary. If an error is signalled, we'll just handle the */
/*     error, display an appropriate message, then call RESET at the */
/*     end of the loop to continue. */

    erract_("SET", "RETURN", (ftnlen)3, (ftnlen)6);

/*     Set the error messages that we want to have displayed. We will */
/*     diaplay the SPICELIB short and long error messages. This is done */
/*     to ensure that some sort of an error message is displayed if an */
/*     error occurs. In several places, long error messages are not set, */
/*     so if only the long error messages were displayed, it would be */
/*     possible to have an error signalled and not see any error */
/*     information. This is not a very useful thing. */

    errprt_("SET", "NONE, SHORT, LONG, TRACEBACK", (ftnlen)3, (ftnlen)28);

/*     Set up the prompt table for the different types of files. */

    s_copy(prmtbl + 80, "Enter the name of the comment file to be #.", (
	    ftnlen)80, (ftnlen)43);
    s_copy(prmtbl, "Enter the name of the binary file.", (ftnlen)80, (ftnlen)
	    34);

/*     Set up the message table for the different ``types'' of */
/*     operations. The message table contains generic messages which will */
/*     have their missing parts filled in after the option and file type */
/*     havve been selected. */

    s_copy(messgs, "Reading the comment area of the # file.", (ftnlen)1000, (
	    ftnlen)39);
    s_copy(messgs + 1000, "Adding comments to the # file.", (ftnlen)1000, (
	    ftnlen)30);
    s_copy(messgs + 2000, "Extracting comments from the # file.", (ftnlen)
	    1000, (ftnlen)36);
    s_copy(messgs + 3000, "Deleting the comment area of # file.", (ftnlen)
	    1000, (ftnlen)36);
    s_copy(messgs + 4000, "Quitting the program.", (ftnlen)1000, (ftnlen)21);
    s_copy(messgs + 5000, "The comments were successfully #.", (ftnlen)1000, (
	    ftnlen)33);
    s_copy(messgs + 6000, "The comments were NOT successfully #.", (ftnlen)
	    1000, (ftnlen)37);

/*     Display a brief commercial with the name of the program and the */
/*     version. */

    s_copy(line, "   Welcome to COMMNT Version: #", (ftnlen)1000, (ftnlen)31);
    repmc_(line, "#", "6.0.1", line, (ftnlen)1000, (ftnlen)1, (ftnlen)5, (
	    ftnlen)1000);
    tostdo_(" ", (ftnlen)1);
    tostdo_(line, (ftnlen)1000);
/* Writing concatenation */
    i__1[0] = 23, a__1[0] = "        (Spice Toolkit ";
    i__1[1] = r__, a__1[1] = tkv;
    i__1[2] = 1, a__1[2] = ")";
    s_cat(line, a__1, i__1, &c__3, (ftnlen)1000);
    tostdo_(line, (ftnlen)1000);
    tostdo_(" ", (ftnlen)1);

/*     Initialize the CELL oriented set for collecting open DAF or DAS */
/*     files in the event of an error. */

    ssizei_(&c__1, opnset);

/*     While there is still more to do ... */

    done = FALSE_;
    while(! done) {

/*        We initialize a few things here, so that they get reset for */
/*        every trip through the loop. */

/*        Initialize the logical flags that we use. */

	comnts = FALSE_;
	contnu = TRUE_;
	eoc = FALSE_;
	ndfnms = FALSE_;

/*        Initialize the filename table, ... */

	s_copy(fnmtbl, " ", (ftnlen)128, (ftnlen)1);
	s_copy(fnmtbl + 128, " ", (ftnlen)128, (ftnlen)1);

/*        the file status table, ... */

	s_copy(statbl, " ", (ftnlen)3, (ftnlen)1);
	s_copy(statbl + 3, " ", (ftnlen)3, (ftnlen)1);

/*        the table indices, ... */

	tblidx[0] = 0;
	tblidx[1] = 0;

/*        set the number of file names to zero, ... */

	numfnm = 0;

/*        the prompts in the prompt table, ... */

	s_copy(prmpts, " ", (ftnlen)80, (ftnlen)1);
	s_copy(prmpts + 80, " ", (ftnlen)80, (ftnlen)1);

/*        the message, and the option. */

	s_copy(messag, " ", (ftnlen)1000, (ftnlen)1);
	s_copy(option, " ", (ftnlen)20, (ftnlen)1);

/*        Set the status messages. */

	s_copy(status, messgs + 5000, (ftnlen)1000, (ftnlen)1000);
	s_copy(status + 1000, messgs + 6000, (ftnlen)1000, (ftnlen)1000);

/*        Get the option to be performed from the main menu. */

	getopt_(maintl, &c__5, mainnm, maintx, &iopt, (ftnlen)20, (ftnlen)1, (
		ftnlen)40);
	s_copy(option, mainvl + ((i__2 = iopt - 1) < 5 && 0 <= i__2 ? i__2 : 
		s_rnge("mainvl", i__2, "commnt_", (ftnlen)502)) * 20, (ftnlen)
		20, (ftnlen)20);

/*        Set up the messages and other information for the option */
/*        selected. */

	if (contnu) {
	    if (s_cmp(option, "ADD_COMMENTS", (ftnlen)20, (ftnlen)12) == 0) {
		ndfnms = TRUE_;
		numfnm = 2;
		s_copy(messag, messgs + 1000, (ftnlen)1000, (ftnlen)1000);
		tblidx[0] = 2;
		s_copy(prmpts, prmtbl + 80, (ftnlen)80, (ftnlen)80);
		repmc_(prmpts, "#", "added", prmpts, (ftnlen)80, (ftnlen)1, (
			ftnlen)5, (ftnlen)80);
		s_copy(statbl + 3, "OLD", (ftnlen)3, (ftnlen)3);
		tblidx[1] = 1;
		s_copy(prmpts + 80, prmtbl, (ftnlen)80, (ftnlen)80);
		s_copy(statbl, "OLD", (ftnlen)3, (ftnlen)3);

/*              Set the operation status messages. */

		s_copy(status, messgs + 5000, (ftnlen)1000, (ftnlen)1000);
		repmc_(status, "#", "added", status, (ftnlen)1000, (ftnlen)1, 
			(ftnlen)5, (ftnlen)1000);
		s_copy(status + 1000, messgs + 6000, (ftnlen)1000, (ftnlen)
			1000);
		repmc_(status + 1000, "#", "added", status + 1000, (ftnlen)
			1000, (ftnlen)1, (ftnlen)5, (ftnlen)1000);
	    } else if (s_cmp(option, "READ_COMMENTS", (ftnlen)20, (ftnlen)13) 
		    == 0) {
		ndfnms = TRUE_;
		numfnm = 1;
		s_copy(messag, messgs, (ftnlen)1000, (ftnlen)1000);
		tblidx[0] = 1;
		s_copy(prmpts, prmtbl, (ftnlen)80, (ftnlen)80);
		s_copy(statbl, "OLD", (ftnlen)3, (ftnlen)3);

/*              Set the operation status messages. */

		s_copy(status, messgs + 5000, (ftnlen)1000, (ftnlen)1000);
		repmc_(status, "#", "read", status, (ftnlen)1000, (ftnlen)1, (
			ftnlen)4, (ftnlen)1000);
		s_copy(status + 1000, messgs + 6000, (ftnlen)1000, (ftnlen)
			1000);
		repmc_(status + 1000, "#", "read", status + 1000, (ftnlen)
			1000, (ftnlen)1, (ftnlen)4, (ftnlen)1000);
	    } else if (s_cmp(option, "EXTRACT_COMMENTS", (ftnlen)20, (ftnlen)
		    16) == 0) {
		ndfnms = TRUE_;
		numfnm = 2;
		s_copy(messag, messgs + 2000, (ftnlen)1000, (ftnlen)1000);
		tblidx[0] = 1;
		s_copy(prmpts, prmtbl, (ftnlen)80, (ftnlen)80);
		s_copy(statbl, "OLD", (ftnlen)3, (ftnlen)3);
		tblidx[1] = 2;
		s_copy(prmpts + 80, prmtbl + 80, (ftnlen)80, (ftnlen)80);
		repmc_(prmpts + 80, "#", "created", prmpts + 80, (ftnlen)80, (
			ftnlen)1, (ftnlen)7, (ftnlen)80);
		s_copy(statbl + 3, "NEW", (ftnlen)3, (ftnlen)3);

/*              Set the operation status messages. */

		s_copy(status, messgs + 5000, (ftnlen)1000, (ftnlen)1000);
		repmc_(status, "#", "extracted", status, (ftnlen)1000, (
			ftnlen)1, (ftnlen)9, (ftnlen)1000);
		s_copy(status + 1000, messgs + 6000, (ftnlen)1000, (ftnlen)
			1000);
		repmc_(status + 1000, "#", "extracted", status + 1000, (
			ftnlen)1000, (ftnlen)1, (ftnlen)9, (ftnlen)1000);
	    } else if (s_cmp(option, "DELETE_COMMENTS", (ftnlen)20, (ftnlen)
		    15) == 0) {
		ndfnms = TRUE_;
		numfnm = 1;
		s_copy(messag, messgs + 3000, (ftnlen)1000, (ftnlen)1000);
		tblidx[0] = 1;
		s_copy(prmpts, prmtbl, (ftnlen)80, (ftnlen)80);
		s_copy(statbl, "OLD", (ftnlen)3, (ftnlen)3);

/*              Set the operation status messages. */

		s_copy(status, messgs + 5000, (ftnlen)1000, (ftnlen)1000);
		repmc_(status, "#", "deleted", status, (ftnlen)1000, (ftnlen)
			1, (ftnlen)7, (ftnlen)1000);
		s_copy(status + 1000, messgs + 6000, (ftnlen)1000, (ftnlen)
			1000);
		repmc_(status + 1000, "#", "deleted", status + 1000, (ftnlen)
			1000, (ftnlen)1, (ftnlen)7, (ftnlen)1000);
	    } else if (s_cmp(option, "QUIT", (ftnlen)20, (ftnlen)4) == 0) {
		s_copy(messag, messgs + 4000, (ftnlen)1000, (ftnlen)1000);
	    }
	}

/*        Collect any filenames that we may need. */

	if (contnu && ndfnms) {

/*           we always need at least one filename if we get to here. */

	    i__ = 1;
	    more = TRUE_;
	    while(more) {
		fileok = FALSE_;
		tryagn = TRUE_;
		while(tryagn) {
		    tostdo_(" ", (ftnlen)1);
		    tostdo_(prmpts + ((i__2 = i__ - 1) < 2 && 0 <= i__2 ? 
			    i__2 : s_rnge("prmpts", i__2, "commnt_", (ftnlen)
			    614)) * 80, (ftnlen)80);
		    tostdo_(" ", (ftnlen)1);
		    getfnm_("Filename? ", statbl + ((i__3 = tblidx[(i__2 = 
			    i__ - 1) < 2 && 0 <= i__2 ? i__2 : s_rnge("tblidx"
			    , i__2, "commnt_", (ftnlen)617)] - 1) < 2 && 0 <= 
			    i__3 ? i__3 : s_rnge("statbl", i__3, "commnt_", (
			    ftnlen)617)) * 3, fnmtbl + (((i__5 = tblidx[(i__4 
			    = i__ - 1) < 2 && 0 <= i__4 ? i__4 : s_rnge("tbl"
			    "idx", i__4, "commnt_", (ftnlen)617)] - 1) < 2 && 
			    0 <= i__5 ? i__5 : s_rnge("fnmtbl", i__5, "commn"
			    "t_", (ftnlen)617)) << 7), &fileok, errmsg, (
			    ftnlen)10, (ftnlen)3, (ftnlen)128, (ftnlen)320);

/*                 If the filename is OK, increment the filename index */
/*                 and leave the try again loop. Otherwise, write out the */
/*                 error message, and give the opportunity to go around */
/*                 again. */

		    if (fileok) {
			++i__;
			tryagn = FALSE_;
		    } else {
			tostdo_(" ", (ftnlen)1);
			tostdo_(errmsg, (ftnlen)320);
			tostdo_(" ", (ftnlen)1);
			cnfirm_("Try again? (Yes/No) ", &tryagn, (ftnlen)20);
			if (! tryagn) {
			    contnu = FALSE_;
			    more = FALSE_;
			}
		    }
		}
		if (i__ > numfnm) {
		    more = FALSE_;
		}
	    }
	}

/*        Get the file architecture and type. */

	if (contnu && ndfnms) {
	    getfat_(fnmtbl, arch, type__, (ftnlen)128, (ftnlen)3, (ftnlen)4);
	    if (failed_()) {
		contnu = FALSE_;
	    }
	}

/*        Check to see that we got back a valid architecture and type. */

	if (contnu && ndfnms) {
	    if (s_cmp(arch, "?", (ftnlen)3, (ftnlen)1) == 0 || s_cmp(type__, 
		    "?", (ftnlen)4, (ftnlen)1) == 0) {
		contnu = FALSE_;
		setmsg_("The architecture and type of the binary file '#' co"
			"uld not be determined. A common error is to give the"
			" name of a text file instead of the name of a binary"
			" file.", (ftnlen)161);
		errch_("#", fnmtbl, (ftnlen)1, (ftnlen)128);
		sigerr_("SPICE(BADFILEFORMAT)", (ftnlen)20);
	    }
	}

/*        Customize the message. We know we can do this, because we */
/*        need files, and so we don't have the QUIT message. */

	if (contnu && ndfnms) {
	    repmc_(messag, "#", type__, messag, (ftnlen)1000, (ftnlen)1, (
		    ftnlen)4, (ftnlen)1000);
	}

/*        Process the option that was selected so long ago. */

	if (contnu) {
	    if (s_cmp(option, "QUIT", (ftnlen)20, (ftnlen)4) == 0) {
		tostdo_(" ", (ftnlen)1);
		tostdo_(messag, (ftnlen)1000);
		tostdo_(" ", (ftnlen)1);
		done = TRUE_;
	    } else if (s_cmp(option, "ADD_COMMENTS", (ftnlen)20, (ftnlen)12) 
		    == 0) {
		tostdo_(" ", (ftnlen)1);
		tostdo_(messag, (ftnlen)1000);
		s_copy(line, "From File: #", (ftnlen)1000, (ftnlen)12);
		repmc_(line, "#", fnmtbl + 128, line, (ftnlen)1000, (ftnlen)1,
			 (ftnlen)128, (ftnlen)1000);
		tostdo_(" ", (ftnlen)1);
		tostdo_(line, (ftnlen)1000);
		s_copy(line, "To File  : #", (ftnlen)1000, (ftnlen)12);
		repmc_(line, "#", fnmtbl, line, (ftnlen)1000, (ftnlen)1, (
			ftnlen)128, (ftnlen)1000);
		tostdo_(line, (ftnlen)1000);

/*              Open the text file which contains the comments to be */
/*              added to the binary file. */

		txtopr_(fnmtbl + 128, &comlun, (ftnlen)128);
		if (! failed_()) {
		    if (s_cmp(type__, "CK", (ftnlen)4, (ftnlen)2) == 0) {

/*                    Open the binary file, add the comments, and close */
/*                    the binary file. */

			dafopw_(fnmtbl, &handle, (ftnlen)128);
			spcac_(&handle, &comlun, " ", " ", (ftnlen)1, (ftnlen)
				1);
			dafcls_(&handle);
		    } else if (s_cmp(type__, "PCK", (ftnlen)4, (ftnlen)3) == 
			    0) {

/*                    Open the binary file, add the comments, and close */
/*                    the binary file. */

			dafopw_(fnmtbl, &handle, (ftnlen)128);
			spcac_(&handle, &comlun, " ", " ", (ftnlen)1, (ftnlen)
				1);
			dafcls_(&handle);
		    } else if (s_cmp(type__, "SPK", (ftnlen)4, (ftnlen)3) == 
			    0) {

/*                    Open the binary file, add the comments, and close */
/*                    the binary file. */

			dafopw_(fnmtbl, &handle, (ftnlen)128);
			spcac_(&handle, &comlun, " ", " ", (ftnlen)1, (ftnlen)
				1);
			dafcls_(&handle);
		    } else if (s_cmp(type__, "EK", (ftnlen)4, (ftnlen)2) == 0)
			     {

/*                    Open the binary file, add the comments, and close */
/*                    the binary file. */

			dasopw_(fnmtbl, &handle, (ftnlen)128);
			dasacu_(&comlun, " ", " ", &insbln, &handle, (ftnlen)
				1, (ftnlen)1);
			dascls_(&handle);
		    }

/*                 Close the comment file. */

		    cl__1.cerr = 0;
		    cl__1.cunit = comlun;
		    cl__1.csta = 0;
		    f_clos(&cl__1);
		}

/*              Display the status of the operation that was selected. */

		tostdo_(" ", (ftnlen)1);
		if (failed_()) {
		    tostdo_(status + 1000, (ftnlen)1000);
		} else {
		    tostdo_(status, (ftnlen)1000);
		}
	    } else if (s_cmp(option, "READ_COMMENTS", (ftnlen)20, (ftnlen)13) 
		    == 0) {
		tostdo_(" ", (ftnlen)1);
		tostdo_(messag, (ftnlen)1000);
		s_copy(line, "File: #", (ftnlen)1000, (ftnlen)7);
		repmc_(line, "#", fnmtbl, line, (ftnlen)1000, (ftnlen)1, (
			ftnlen)128, (ftnlen)1000);
		tostdo_(" ", (ftnlen)1);
		tostdo_(line, (ftnlen)1000);
		tostdo_(" ", (ftnlen)1);
		if (s_cmp(type__, "CK", (ftnlen)4, (ftnlen)2) == 0) {

/*                 Open the binary file, read the comments, and close */
/*                 the binary file. */

		    dafopr_(fnmtbl, &handle, (ftnlen)128);

/*                 The comments are read a line at a time and displayed */
/*                 on the screen. */

		    spcrfl_(&handle, line, &eoc, (ftnlen)1000);
		    if (! failed_()) {
			if (eoc) {
			    tostdo_("There were no comments found in the fil"
				    "e.", (ftnlen)41);
			}
			while(! eoc && ! failed_()) {
			    tostdo_(line, (ftnlen)1000);
			    spcrnl_(line, &eoc, (ftnlen)1000);
			}
		    }
		    dafcls_(&handle);
		} else if (s_cmp(type__, "PCK", (ftnlen)4, (ftnlen)3) == 0) {

/*                 Open the binary file, read the comments, and close */
/*                 the binary file. */

		    dafopr_(fnmtbl, &handle, (ftnlen)128);

/*                 The comments are read a line at a time and displayed */
/*                 on the screen. */

		    spcrfl_(&handle, line, &eoc, (ftnlen)1000);
		    if (! failed_()) {
			if (eoc) {
			    tostdo_("There were no commentfound in the file.",
				     (ftnlen)39);
			}
			while(! eoc && ! failed_()) {
			    tostdo_(line, (ftnlen)1000);
			    spcrnl_(line, &eoc, (ftnlen)1000);
			}
		    }
		    dafcls_(&handle);
		} else if (s_cmp(type__, "SPK", (ftnlen)4, (ftnlen)3) == 0) {

/*                 Open the binary file, read the comments, and close */
/*                 the binary file. */

		    dafopr_(fnmtbl, &handle, (ftnlen)128);

/*                 The comments are read a line at a time and displayed */
/*                 on the screen. */

		    spcrfl_(&handle, line, &eoc, (ftnlen)1000);
		    if (! failed_()) {
			if (eoc) {
			    tostdo_("There were no comments found in the fil"
				    "e.", (ftnlen)41);
			}
			while(! eoc && ! failed_()) {
			    tostdo_(line, (ftnlen)1000);
			    spcrnl_(line, &eoc, (ftnlen)1000);
			}
		    }
		    dafcls_(&handle);
		} else if (s_cmp(type__, "EK", (ftnlen)4, (ftnlen)2) == 0) {

/*                 Open the binary file, read the comments, and close */
/*                 the binary file. */

		    dasopr_(fnmtbl, &handle, (ftnlen)128);
		    dasecu_(&handle, &c__6, &comnts);
		    dascls_(&handle);
		    if (! comnts) {
			s_copy(line, "There were no comments found in the fi"
				"le.", (ftnlen)1000, (ftnlen)41);
			tostdo_(line, (ftnlen)1000);
		    }
		}

/*              Display the status of the operation that was selected. */

		tostdo_(" ", (ftnlen)1);
		if (failed_()) {
		    tostdo_(status + 1000, (ftnlen)1000);
		} else {
		    tostdo_(status, (ftnlen)1000);
		}
	    } else if (s_cmp(option, "EXTRACT_COMMENTS", (ftnlen)20, (ftnlen)
		    16) == 0) {
		tostdo_(" ", (ftnlen)1);
		tostdo_(messag, (ftnlen)1000);
		s_copy(line, "From File: #", (ftnlen)1000, (ftnlen)12);
		repmc_(line, "#", fnmtbl, line, (ftnlen)1000, (ftnlen)1, (
			ftnlen)128, (ftnlen)1000);
		tostdo_(" ", (ftnlen)1);
		tostdo_(line, (ftnlen)1000);
		s_copy(line, "To File  : #", (ftnlen)1000, (ftnlen)12);
		repmc_(line, "#", fnmtbl + 128, line, (ftnlen)1000, (ftnlen)1,
			 (ftnlen)128, (ftnlen)1000);
		tostdo_(line, (ftnlen)1000);

/*              Open the text file. */

		txtopn_(fnmtbl + 128, &comlun, (ftnlen)128);
		if (! failed_()) {
		    if (s_cmp(type__, "CK", (ftnlen)4, (ftnlen)2) == 0) {

/*                    Open the binary file, extract the comments, and */
/*                    close the binary file. */

			dafopr_(fnmtbl, &handle, (ftnlen)128);
			spcec_(&handle, &comlun);
			dafcls_(&handle);
		    } else if (s_cmp(type__, "PCK", (ftnlen)4, (ftnlen)3) == 
			    0) {

/*                    Open the binary file, extract the comments, and */
/*                    close the binary file. */

			dafopr_(fnmtbl, &handle, (ftnlen)128);
			spcec_(&handle, &comlun);
			dafcls_(&handle);
		    } else if (s_cmp(type__, "SPK", (ftnlen)4, (ftnlen)3) == 
			    0) {

/*                    Open the binary file, extract the comments, and */
/*                    close the binary file. */

			dafopr_(fnmtbl, &handle, (ftnlen)128);
			spcec_(&handle, &comlun);
			dafcls_(&handle);
		    } else if (s_cmp(type__, "EK", (ftnlen)4, (ftnlen)2) == 0)
			     {

/*                    Open the binary file, extract the comments, and */
/*                    close the binary file. */

			dasopr_(fnmtbl, &handle, (ftnlen)128);
			dasecu_(&handle, &comlun, &comnts);
			dascls_(&handle);
			if (! comnts) {
			    s_copy(line, "There were no comments found in th"
				    "e file.", (ftnlen)1000, (ftnlen)41);
			    tostdo_(line, (ftnlen)1000);
			}
		    }

/*                 Close the text file that we opened. */

		    cl__1.cerr = 0;
		    cl__1.cunit = comlun;
		    cl__1.csta = 0;
		    f_clos(&cl__1);
		}

/*              Display the status of the operation that was selected. */

		tostdo_(" ", (ftnlen)1);
		if (failed_()) {
		    tostdo_(status + 1000, (ftnlen)1000);
		} else {
		    tostdo_(status, (ftnlen)1000);
		}
	    } else if (s_cmp(option, "DELETE_COMMENTS", (ftnlen)20, (ftnlen)
		    15) == 0) {
		tostdo_(" ", (ftnlen)1);
		tostdo_(messag, (ftnlen)1000);
		s_copy(line, "File: #", (ftnlen)1000, (ftnlen)7);
		repmc_(line, "#", fnmtbl, line, (ftnlen)1000, (ftnlen)1, (
			ftnlen)128, (ftnlen)1000);
		tostdo_(" ", (ftnlen)1);
		tostdo_(line, (ftnlen)1000);
		if (s_cmp(type__, "CK", (ftnlen)4, (ftnlen)2) == 0) {

/*                 Open the binary file, delete the comments, and close */
/*                 the binary file. */

		    dafopw_(fnmtbl, &handle, (ftnlen)128);
		    spcdc_(&handle);
		    dafcls_(&handle);
		} else if (s_cmp(type__, "PCK", (ftnlen)4, (ftnlen)3) == 0) {

/*                 Open the binary file, delete the comments, and close */
/*                 the binary file. */

		    dafopw_(fnmtbl, &handle, (ftnlen)128);
		    spcdc_(&handle);
		    dafcls_(&handle);
		} else if (s_cmp(type__, "SPK", (ftnlen)4, (ftnlen)3) == 0) {

/*                 Open the binary file, delete the comments, and close */
/*                 the binary file. */

		    dafopw_(fnmtbl, &handle, (ftnlen)128);
		    spcdc_(&handle);
		    dafcls_(&handle);
		} else if (s_cmp(type__, "EK", (ftnlen)4, (ftnlen)2) == 0) {

/*                 Open the binary file, delete the comments, and close */
/*                 the binary file. */

		    dasopw_(fnmtbl, &handle, (ftnlen)128);
		    dasdc_(&handle);
		    dascls_(&handle);
		}

/*              Display the status of the operation that was selected. */

		tostdo_(" ", (ftnlen)1);
		if (failed_()) {
		    tostdo_(status + 1000, (ftnlen)1000);
		} else {
		    tostdo_(status, (ftnlen)1000);
		}
	    }
	}

/*        If anything failed, close any binary files that might still be */
/*        open and reset the error handling before getting the next */
/*        option. */

	if (failed_()) {

/*           Before we can attempt to perform any clean up actions if an */
/*           error occurred, we need to reset the SPICELIB error handling */
/*           mechanism so that we can call the SPICELIB routines that we */
/*           need to. */

	    reset_();

/*           Clear out any binary file handles in the open set, OPNSET. */

	    scardi_(&c__0, opnset);
	    cleari_(&c__1, &opnset[6]);

/*           Get the handles for any DAF files which may still be open. */

	    dafhof_(opnset);
	    numopn = cardi_(opnset);
	    if (numopn > 0) {
		i__2 = numopn;
		for (i__ = 1; i__ <= i__2; ++i__) {
		    dafcls_(&opnset[(i__3 = i__ + 5) < 7 && 0 <= i__3 ? i__3 :
			     s_rnge("opnset", i__3, "commnt_", (ftnlen)1100)])
			    ;
		}
	    }

/*           Clear out any binary file handles in the open set, OPNSET. */

	    scardi_(&c__0, opnset);
	    cleari_(&c__1, &opnset[6]);

/*           Get the handles for any DAS files which may still be open. */

	    dashof_(opnset);
	    numopn = cardi_(opnset);
	    if (numopn > 0) {
		i__2 = numopn;
		for (i__ = 1; i__ <= i__2; ++i__) {
		    dascls_(&opnset[(i__3 = i__ + 5) < 7 && 0 <= i__3 ? i__3 :
			     s_rnge("opnset", i__3, "commnt_", (ftnlen)1121)])
			    ;
		}
	    }

/*           If there was an error and we were extracting comments to a */
/*           file, then we should delete the file that was created, */
/*           because we do not know whether the extraction was completed */
/*           successfully. */

	    if (s_cmp(option, "EXTRACT_COMMENTS", (ftnlen)20, (ftnlen)16) == 
		    0) {
		if (exists_(fnmtbl + 128, (ftnlen)128)) {
		    delfil_(fnmtbl + 128, (ftnlen)128);
		}
	    }

/*           Finally, reset the error handling, and go get the next */
/*           option. This is just to be sure. */

	    reset_();
	}
    }
    chkout_("COMMNT", (ftnlen)6);
    return 0;
} /* MAIN__ */
Пример #8
0
/* $Procedure SPCT2B ( SPK and CK, text to binary ) */
/* Subroutine */ int spct2b_(integer *unit, char *binary, ftnlen binary_len)
{
    /* System generated locals */
    integer i__1;
    cilist ci__1;
    olist o__1;
    cllist cl__1;

    /* Builtin functions */
    integer s_rsfe(cilist *), do_fio(integer *, char *, ftnlen), e_rsfe(void),
	     s_cmp(char *, char *, ftnlen, ftnlen), f_open(olist *), s_wsfe(
	    cilist *), e_wsfe(void), f_clos(cllist *);

    /* Local variables */
    char line[1000];
    extern /* Subroutine */ int spcac_(integer *, integer *, char *, char *, 
	    ftnlen, ftnlen), chkin_(char *, ftnlen);
    extern integer ltrim_(char *, ftnlen), rtrim_(char *, ftnlen);
    extern /* Subroutine */ int daft2b_(integer *, char *, integer *, ftnlen);
    integer handle;
    extern /* Subroutine */ int dafcls_(integer *), dafopw_(char *, integer *,
	     ftnlen);
    integer scrtch;
    extern /* Subroutine */ int errfnm_(char *, integer *, ftnlen), sigerr_(
	    char *, ftnlen), chkout_(char *, ftnlen), getlun_(integer *), 
	    setmsg_(char *, ftnlen);
    integer iostat;
    extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
    extern logical return_(void);

/* $ Abstract */

/*     Reconstruct a binary SPK or CK file including comments */
/*     from a text file opened by the calling program. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     SPC */

/* $ Keywords */

/*     FILES */

/* $ Declarations */
/* $ Brief_I/O */

/*     Variable  I/O  Description */
/*     --------  ---  -------------------------------------------------- */
/*     UNIT       I   Logical unit connected to the text format file. */
/*     BINARY     I   Name of a binary SPK or CK file to be created. */

/* $ Detailed_Input */

/*     UNIT        is the logical unit connected to an existing text */
/*                 format SPK or CK file that may contain comments in */
/*                 the appropriate SPC format, as written by SPCB2A or */
/*                 SPCB2T.  This file must be opened for read access */
/*                 using the routine TXTOPR. */

/*                 This file may contain text that precedes and */
/*                 follows the SPK or CK data and comments, however, */
/*                 when calling this routine, the file pointer must be */
/*                 in a position in the file such that the next line */
/*                 returned by a READ statement is */

/*                      ''NAIF/DAF'' */

/*                 which marks the beginning of the data. */

/*     BINARY      is the name of a binary SPK or CK file to be created. */
/*                 The binary file contains the same data and comments */
/*                 as the text file, but in the binary format required */
/*                 for use with the SPICELIB reader subroutines. */

/* $ Detailed_Output */

/*     None. */

/* $ Parameters */

/*     None. */

/* $ Files */

/*     1)  See arguments UNIT and BINARY above. */

/*     2)  This routine uses a Fortran scratch file to temporarily */
/*         store the lines of comments if there are any. */

/* $ Exceptions */

/*     1) If there is a problem opening or writing to the binary */
/*        file, a routine that SPCT2B calls diagnoses and signals */
/*        an error. */

/*     2) If there is a problem reading from the text file, the */
/*        error SPICE(FILEREADFAILED) is signalled. */

/*     3) If there is a problem opening a scratch file, the error */
/*        SPICE(FILEOPENERROR) is signalled. */

/*     4) If there is a problem writing to the scratch file, the */
/*        error SPICE(FILEWRITEFAILED) is signalled. */

/* $ Particulars */

/*     The SPICELIB SPK and CK reader subroutines read binary files. */
/*     However, because different computing environments have different */
/*     binary representations of numbers, you must convert SPK and CK */
/*     files to text format when porting from one system to another. */
/*     After converting the file to text, you can transfer it using */
/*     a transfer protocol program like Kermit or FTP.  Then, convert */
/*     the text file back to binary format. */

/*     The following is a list of the SPICELIB routines that convert */
/*     SPK and CK files between binary and text format: */

/*        SPCA2B    converts text to binary.  It opens the text file, */
/*                  creates a new binary file, and closes both files. */

/*        SPCB2A    converts binary to text.  It opens the binary file, */
/*                  creates a new text file, and closes both files. */

/*        SPCT2B    converts text to binary.  It creates a new binary */
/*                  file and closes it.  The text file is open on */
/*                  entrance and exit. */

/*        SPCB2T    converts binary to text.  It opens the binary */
/*                  file and closes it.  The text file is open on */
/*                  entrance and exit */

/*     See the SPC required reading for more information */
/*     about SPC routines and the SPK and CK file formats. */

/* $ Examples */

/*     1)  The following code fragment creates a text file containing */
/*         text format SPK data and comments preceded and followed */
/*         by a standard label. */

/*         The SPICELIB routine TXTOPN opens a new text file and TXTOPR */
/*         opens an existing text file for read access.  TEXT and */
/*         BINARY are character strings that contain the names of the */
/*         text and binary files. */

/*            CALL TXTOPN ( TEXT, UNIT ) */

/*            (Write header label to UNIT) */

/*            CALL SPCB2T ( BINARY, UNIT ) */

/*            (Write trailing label to UNIT) */

/*            CLOSE ( UNIT ) */


/*         The following code fragment reconverts the text format */
/*         SPK data and comments back into binary format. */

/*            CALL TXTOPR ( TEXT, UNIT ) */

/*            (Read, or just read past, header label from UNIT) */

/*            CALL SPCT2B ( UNIT, BINARY ) */

/*            (Read trailing label from UNIT, if desired ) */

/*            CLOSE ( UNIT ) */


/*     2)  Suppose three text format SPK files have been appended */
/*         together into one text file called THREE.TSP.  The following */
/*         code fragment converts each set of data and comments into */
/*         its own binary file. */

/*            CALL TXTOPR ( 'THREE.TSP', UNIT  ) */

/*            CALL SPCT2B ( UNIT, 'FIRST.BSP'  ) */
/*            CALL SPCT2B ( UNIT, 'SECOND.BSP' ) */
/*            CALL SPCT2B ( UNIT, 'THIRD.BSP'  ) */

/*            CLOSE ( UNIT ) */

/* $ Restrictions */

/*     1)  This routine assumes that the data and comments in the */
/*         text format SPK or CK file come from a binary file */
/*         and were written by one of the routines SPCB2A or SPCB2T. */
/*         Data and/or comments written any other way may not be */
/*         in the correct format and, therefore, may not be handled */
/*         properly. */

/*     2)  Older versions of SPK and CK files did not have a comment */
/*         area.  These files, in text format, may still be converted */
/*         to binary using SPCT2B.  However, upon exit, the file pointer */
/*         will not be in position ready to read the first line of text */
/*         after the data.  Instead, the next READ statement after */
/*         calling SPCT2B will return the second line of text after */
/*         the data.  Therefore, example 1 may not work as desired */
/*         if the trailing label begins on the first line after the */
/*         data.  To solve this problem, use DAFT2B instead of SPCT2B. */

/*     3)  UNIT must be obtained via TXTOPR.  Use TXTOPR to open text */
/*         files for read access and get the logical unit.  System */
/*         dependencies regarding opening text files have been isolated */
/*         in the routines TXTOPN and TXTOPR. */

/* $ Literature_References */

/*     None. */

/* $ Author_and_Institution */

/*     J.E. McLean    (JPL) */

/* $ Version */

/* -    SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */

/*        Comment section for permuted index source lines was added */
/*        following the header. */

/* -    SPICELIB Version 1.0.0, 05-APR-1991 (JEM) */

/* -& */
/* $ Index_Entries */

/*     text spk or ck to binary */

/* -& */

/*     SPICELIB functions */


/*     Local parameters */


/*     Local variables */


/*     Standard SPICE error handling. */

    if (return_()) {
	return 0;
    } else {
	chkin_("SPCT2B", (ftnlen)6);
    }

/*     DAFT2B creates the new binary file and writes the data to */
/*     it.  If the 'NAIF/DAF' keyword is not the first line that */
/*     it reads from the text file, it will signal an error. */
/*     Initially, no records are reserved. */

    daft2b_(unit, binary, &c__0, binary_len);

/*     The comments follow the data and are surrounded by markers. */
/*     BMARK should be the next line that we read.  If it isn't, */
/*     then this is an old file, created before the comment area */
/*     existed.  In this case, we've read one line too far, but */
/*     we can't backspace because the file was written using list- */
/*     directed formatting (See the ANSI standard).  All we can do */
/*     is check out, leaving the file pointer where it is, but */
/*     that's better than signalling an error. */

    ci__1.cierr = 1;
    ci__1.ciend = 1;
    ci__1.ciunit = *unit;
    ci__1.cifmt = "(A)";
    iostat = s_rsfe(&ci__1);
    if (iostat != 0) {
	goto L100001;
    }
    iostat = do_fio(&c__1, line, (ftnlen)1000);
    if (iostat != 0) {
	goto L100001;
    }
    iostat = e_rsfe();
L100001:
    if (iostat > 0) {
	setmsg_("Error reading the text file named FNM.  Value of IOSTAT is "
		"#.", (ftnlen)61);
	errint_("#", &iostat, (ftnlen)1);
	errfnm_("FNM", unit, (ftnlen)3);
	sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
	chkout_("SPCT2B", (ftnlen)6);
	return 0;
    }
    i__1 = ltrim_(line, (ftnlen)1000) - 1;
    if (s_cmp(line + i__1, "~NAIF/SPC BEGIN COMMENTS~", 1000 - i__1, (ftnlen)
	    25) != 0 || iostat < 0) {
	chkout_("SPCT2B", (ftnlen)6);
	return 0;
    }

/*     We're not at the end of the file, and the line we read */
/*     is BMARK, so we write the comments to a scratch file. */
/*     We do this because we have to use SPCAC to add the comments */
/*     to the comment area of the binary file, and SPCAC rewinds */
/*     the file.  It's okay for SPCAC to rewind a scratch file, */
/*     but it's not okay to rewind the file connected to UNIT -- */
/*     we don't know the initial location of the file pointer. */

    getlun_(&scrtch);
    o__1.oerr = 1;
    o__1.ounit = scrtch;
    o__1.ofnm = 0;
    o__1.orl = 0;
    o__1.osta = "SCRATCH";
    o__1.oacc = "SEQUENTIAL";
    o__1.ofm = "FORMATTED";
    o__1.oblnk = 0;
    iostat = f_open(&o__1);
    if (iostat != 0) {
	setmsg_("Error opening a scratch file.  File name was FNM.  Value of"
		" IOSTAT is #.", (ftnlen)72);
	errint_("#", &iostat, (ftnlen)1);
	errfnm_("FNM", &scrtch, (ftnlen)3);
	sigerr_("SPICE(FILEOPENERROR)", (ftnlen)20);
	chkout_("SPCT2B", (ftnlen)6);
	return 0;
    }
    ci__1.cierr = 1;
    ci__1.ciunit = scrtch;
    ci__1.cifmt = "(A)";
    iostat = s_wsfe(&ci__1);
    if (iostat != 0) {
	goto L100002;
    }
    iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)1000));
    if (iostat != 0) {
	goto L100002;
    }
    iostat = e_wsfe();
L100002:
    if (iostat != 0) {
	setmsg_("Error writing to scratch file. File name is FNM.  Value of "
		"IOSTAT is #.", (ftnlen)71);
	errint_("#", &iostat, (ftnlen)1);
	errfnm_("FNM", &scrtch, (ftnlen)3);
	sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
	chkout_("SPCT2B", (ftnlen)6);
	return 0;
    }

/*     Continue reading lines from the text file and storing them */
/*     in the scratch file until we get to the end marker. */

    for(;;) { /* while(complicated condition) */
	i__1 = ltrim_(line, (ftnlen)1000) - 1;
	if (!(s_cmp(line + i__1, "~NAIF/SPC END COMMENTS~", 1000 - i__1, (
		ftnlen)23) != 0))
		break;
	ci__1.cierr = 1;
	ci__1.ciend = 1;
	ci__1.ciunit = *unit;
	ci__1.cifmt = "(A)";
	iostat = s_rsfe(&ci__1);
	if (iostat != 0) {
	    goto L100003;
	}
	iostat = do_fio(&c__1, line, (ftnlen)1000);
	if (iostat != 0) {
	    goto L100003;
	}
	iostat = e_rsfe();
L100003:
	if (iostat != 0) {
	    setmsg_("Error reading the text file named FNM.  Value of IOSTAT"
		    " is #.", (ftnlen)61);
	    errint_("#", &iostat, (ftnlen)1);
	    errfnm_("FNM", unit, (ftnlen)3);
	    sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
	    chkout_("SPCT2B", (ftnlen)6);
	    return 0;
	}
	ci__1.cierr = 1;
	ci__1.ciunit = scrtch;
	ci__1.cifmt = "(A)";
	iostat = s_wsfe(&ci__1);
	if (iostat != 0) {
	    goto L100004;
	}
	iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)1000));
	if (iostat != 0) {
	    goto L100004;
	}
	iostat = e_wsfe();
L100004:
	if (iostat != 0) {
	    setmsg_("Error writing to scratch file.  File name is FNM.  Valu"
		    "e of IOSTAT is #.", (ftnlen)72);
	    errint_("#", &iostat, (ftnlen)1);
	    errfnm_("FNM", &scrtch, (ftnlen)3);
	    sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
	    chkout_("SPCT2B", (ftnlen)6);
	    return 0;
	}
    }

/*     Open the new binary file and add the comments that have been */
/*     stored temporarily in a scratch file. */

    dafopw_(binary, &handle, binary_len);
    spcac_(&handle, &scrtch, "~NAIF/SPC BEGIN COMMENTS~", "~NAIF/SPC END COM"
	    "MENTS~", (ftnlen)25, (ftnlen)23);

/*     Close the files.  The scratch file is automatically deleted. */

    dafcls_(&handle);
    cl__1.cerr = 0;
    cl__1.cunit = scrtch;
    cl__1.csta = 0;
    f_clos(&cl__1);
    chkout_("SPCT2B", (ftnlen)6);
    return 0;
} /* spct2b_ */
Пример #9
0
/* $Procedure ZZASCII ( determine/verify EOL terminators in a text file ) */
/* Subroutine */ int zzascii_(char *file, char *line, logical *check, char *
	termin, ftnlen file_len, ftnlen line_len, ftnlen termin_len)
{
    /* System generated locals */
    olist o__1;
    cllist cl__1;

    /* Builtin functions */
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
    integer i_len(char *, ftnlen), f_open(olist *), f_clos(cllist *), s_rdue(
	    cilist *), do_uio(integer *, char *, ftnlen), e_rdue(void);

    /* Local variables */
    extern /* Subroutine */ int zzplatfm_(char *, char *, ftnlen, ftnlen);
    integer i__;
    extern /* Subroutine */ int chkin_(char *, ftnlen), errch_(char *, char *,
	     ftnlen, ftnlen);
    extern integer rtrim_(char *, ftnlen);
    extern logical eqstr_(char *, char *, ftnlen, ftnlen);
    integer maccnt, reclen;
    char native[5];
    integer number, doscnt;
    extern /* Subroutine */ int sigerr_(char *, ftnlen), chkout_(char *, 
	    ftnlen), getlun_(integer *), setmsg_(char *, ftnlen);
    integer iostat;
    extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
    extern logical return_(void);
    integer unxcnt;

    /* Fortran I/O blocks */
    static cilist io___5 = { 1, 0, 1, 0, 1 };


/* $ Abstract */

/*     Returns a string indicating the line terminators of an ASCII file */
/*     and, if requested, stops execution if the terminator does match */
/*     the one that is native to the platform on which the toolkit was */
/*     compiled. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     None. */

/* $ Keywords */

/*     FILE TYPE */

/* $ Declarations */
/* $ Brief_I/O */

/*     Variable  I/O  Description */
/*     --------  ---  -------------------------------------------------- */
/*     FILE       I   Name of the text file to scan. */
/*     LINE       I   The work string for file reads. */
/*     CHECK      I   Flag directing to check for mismatched EOL. */
/*     TERMIN     0   The deduced terminator ID. */

/* $ Detailed_Input */

/*     FILE       the name of the ASCII file to scan for a line */
/*                terminator */

/*     LINE       a character string of sufficient length to perform the */
/*                line reads from FILE. */

/*     CHECK      a logical flag that, if set to .TRUE., instructs this */
/*                routine to check terminator that has been determined */
/*                against the one that is native to the platform, on */
/*                which the toolkit was compiled, and to generate error */
/*                if it was not the case. If set to .FALSE., instructs */
/*                the routine to bypass the check. */

/* $ Detailed_Output */

/*     TERMIN     the terminator ID extracted from FILE. The possible */
/*                values: */

/*                'CR'    - carriage return (Mac classic) */
/*                'LF'    - line feed (Unix) */
/*                'CR-LF' - carriage return and line feed (DOS) */
/*                '?'     - unable to determine, possibly */
/*                          due to an error event */

/* $ Parameters */

/*     None. */

/* $ Exceptions */

/*     1) A SPICE(STRINGTOOSHORT) error signals if LINE has length less */
/*        than 3. */

/*     2) A SPICE(FILEOPENFAILED) error signals if the file of interest */
/*        fails to open, i.e. IOSTAT < 0. */

/*     3) A text kernel found to contain non-native line terminators */
/*        and abort of the run was requested by causes this routine to */
/*        signal the error SPICE(INCOMPATIBLEEOL). */

/* $ Files */

/*     None. */

/* $ Particulars */

/*     The function scans a string read from a text file to determine */
/*     the native platform of the file. The functions response is */
/*     unpredictable if it scans a binary file. */

/* $ Examples */

/*     To return EOL terminator for a given file: */

/*         CHARACTER*(5)    TERMIN */
/*         CHARACTER*(64)   LINE */

/*          ... given a file name */
/*          ... and a line long enough to hold a text string */
/*              from FILE */

/*         CALL ZZASCII( FILE, LINE, .FALSE., TERMIN ) */

/*         CALL TOSTDO( 'FOUND FILE TERMINATOR '//TERMIN ) */

/*     To stop if EOL terminator for a given file, if detected */
/*     successfully, is not native to this platform: */

/*         CHARACTER*(5)    TERMIN */
/*         CHARACTER*(64)   LINE */

/*          ... given a file name */
/*          ... and a line long enough to hold a text string */
/*              from FILE */

/*         CALL ZZASCII( FILE, LINE, .TRUE., TERMIN ) */

/*     If the EOL terminator was not native, the call will generate */
/*     SPICE(INCOMPATIBLEEOL) error. */

/* $ Restrictions */

/*     1) The terminator detection is not performed if the read from */
/*        the file fails because the file is smaller than the allocated */
/*        LINE size or for any other reason. */

/*     2) The terminator detection is not possible if the length of the */
/*        first text line in the file exceeds the length of the LINE */
/*        work space. */

/* $ Literature_References */

/*     None. */

/* $ Author_and_Institution */

/*     E.D. Wright      (JPL) */
/*     B.V. Semenov     (JPL) */

/* $ Version */

/* -    SPICELIB Version 1.20.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL. */

/* -    SPICELIB Version 1.19.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL-CC_C. */

/* -    SPICELIB Version 1.18.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL-64BIT-CC_C. */

/* -    SPICELIB Version 1.17.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-NATIVE_C. */

/* -    SPICELIB Version 1.16.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-WINDOWS-64BIT-IFORT. */

/* -    SPICELIB Version 1.15.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-LINUX-64BIT-GFORTRAN. */

/* -    SPICELIB Version 1.14.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-64BIT-MS_C. */

/* -    SPICELIB Version 1.13.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-INTEL_C. */

/* -    SPICELIB Version 1.12.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-IFORT. */

/* -    SPICELIB Version 1.11.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-GFORTRAN. */

/* -    SPICELIB Version 1.10.0, 18-MAR-2009 (BVS) */

/*        Updated for PC-LINUX-GFORTRAN. */

/* -    SPICELIB Version 1.9.0, 18-MAR-2009 (BVS) */

/*        Updated for MAC-OSX-GFORTRAN. */

/* -    SPICELIB Version 1.8.0, 19-FEB-2008 (BVS) */

/*        Updated for PC-LINUX-IFORT. */

/* -    SPICELIB Version 1.7.0, 14-NOV-2006 (BVS) */

/*        Updated for PC-LINUX-64BIT-GCC_C. */

/* -    SPICELIB Version 1.6.0, 14-NOV-2006 (BVS) */

/*        Updated for MAC-OSX-INTEL_C. */

/* -    SPICELIB Version 1.5.0, 14-NOV-2006 (BVS) */

/*        Updated for MAC-OSX-IFORT. */

/* -    SPICELIB Version 1.4.0, 14-NOV-2006 (BVS) */

/*        Updated for PC-WINDOWS-IFORT. */

/* -    SPICELIB Version 1.3.1, 26-OCT-2006 (EDW) */

/*        Expanded error message explanation the */
/*        routine outputs when the file-of-interest */
/*        includes non-native text line terminators. */

/* -    SPICELIB Version 1.3.0, 26-OCT-2005 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-GCC_C. */

/* -    SPICELIB Version 1.2.0, 03-JAN-2005 (BVS) */

/*        Updated for PC-CYGWIN_C. */

/* -    SPICELIB Version 1.1.0, 03-JAN-2005 (BVS) */

/*        Updated for PC-CYGWIN. */

/* -    SPICELIB Version 1.0.0, 17-FEB-2004 (EDW) (BVS) */

/* -& */
/* $ Index_Entries */

/*     determine ascii text file end-of-line type */

/* -& */

/*     SPICELIB functions. */


/*     Local parameters. */


/*     Local variables. */


/*     Discovery check-in. Can't determine the terminator in RETURN */
/*     mode. */

    if (return_()) {
	s_copy(termin, "?", termin_len, (ftnlen)1);
	return 0;
    }

/*     Check-in to the error system. */

    chkin_("ZZASCII", (ftnlen)7);

/*     Retrieve the native line terminator. */

    zzplatfm_("TEXT_FORMAT", native, (ftnlen)11, (ftnlen)5);

/*     If it is VAX, return immediately with undefined terminator. */

    if (eqstr_(native, "VAX", (ftnlen)5, (ftnlen)3)) {
	s_copy(termin, "?", termin_len, (ftnlen)1);
	chkout_("ZZASCII", (ftnlen)7);
	return 0;
    }

/*     Set the record lenght that will be used to read data from */
/*     the file. */

    reclen = i_len(line, line_len);

/*     Check the length of the work string is sufficient to perform the */
/*     operations. Less than 3 is a no-op. */

    if (i_len(line, line_len) < 3) {
	s_copy(termin, "?", termin_len, (ftnlen)1);
	setmsg_("Work string lacks sufficient length to perform operation.", (
		ftnlen)57);
	sigerr_("SPICE(STRINGTOOSHORT)", (ftnlen)21);
	chkout_("ZZASCII", (ftnlen)7);
	return 0;
    }

/*     Find a free logical unit for file access. */

    getlun_(&number);

/*     Open the file for DIRECT access. */

    o__1.oerr = 1;
    o__1.ounit = number;
    o__1.ofnmlen = rtrim_(file, file_len);
    o__1.ofnm = file;
    o__1.orl = reclen;
    o__1.osta = "OLD";
    o__1.oacc = "DIRECT";
    o__1.ofm = 0;
    o__1.oblnk = 0;
    iostat = f_open(&o__1);
    if (iostat != 0) {

/*        The open failed, can't determine the terminator if the routine */
/*        can't open the file. */

	s_copy(termin, "?", termin_len, (ftnlen)1);

/*        Execute a close, J.I.C. */

	cl__1.cerr = 0;
	cl__1.cunit = number;
	cl__1.csta = 0;
	f_clos(&cl__1);
	setmsg_("File open failed for file '$1'. IOSTAT  value $2.", (ftnlen)
		49);
	errch_("$1", file, (ftnlen)2, file_len);
	errint_("$2", &iostat, (ftnlen)2);
	sigerr_("SPICE(FILEOPENFAIL)", (ftnlen)19);
	chkout_("ZZASCII", (ftnlen)7);
	return 0;
    }

/*     Read a line into the LINE variable assigned by the user. */

    s_copy(line, " ", line_len, (ftnlen)1);
    io___5.ciunit = number;
    iostat = s_rdue(&io___5);
    if (iostat != 0) {
	goto L100001;
    }
    iostat = do_uio(&c__1, line, line_len);
    if (iostat != 0) {
	goto L100001;
    }
    iostat = e_rdue();
L100001:
    if (iostat != 0) {

/*        If something went wrong during this read, a part or the whole */
/*        returned line may contain garbage. Instead of examining it and */
/*        making wrong determination based on it, set terminator to */
/*        undefined and return. */

	s_copy(termin, "?", termin_len, (ftnlen)1);

/*        Execute a close, J.I.C. */

	cl__1.cerr = 0;
	cl__1.cunit = number;
	cl__1.csta = 0;
	f_clos(&cl__1);
	chkout_("ZZASCII", (ftnlen)7);
	return 0;
    }

/*     We have a line of text data. Use ICHAR to scan for carriage */
/*     returns and line feeds and count how may of various recognized */
/*     line termination sequences are in this line. */

    doscnt = 0;
    unxcnt = 0;
    maccnt = 0;
    i__ = 1;
    while(i__ < i_len(line, line_len)) {

/*        Check for ICHAR values of 10 (LF) and 13 (CR). */

	if (*(unsigned char *)&line[i__ - 1] == 10) {

/*           Found a UNIX line terminator LF. */

	    ++unxcnt;
	} else if (*(unsigned char *)&line[i__ - 1] == 13) {

/*           Found CR, increment character counter and check */
/*           the next character. */

	    ++i__;
	    if (*(unsigned char *)&line[i__ - 1] == 10) {

/*              Found a DOS line terminator CR+LF. */

		++doscnt;
	    } else {

/*              Found a Classic Mac line terminator CR. */

		++maccnt;
	    }
	}
	++i__;
    }

/*     Examine the counters. */

    if (doscnt > 0 && unxcnt == 0 && maccnt == 0) {

/*        Only DOS terminator counter is non-zero. ID the file as DOS. */

	s_copy(termin, "CR-LF", termin_len, (ftnlen)5);
    } else if (doscnt == 0 && unxcnt > 0 && maccnt == 0) {

/*        Only Unix terminator counter is non-zero. ID the file as UNIX. */

	s_copy(termin, "LF", termin_len, (ftnlen)2);
    } else if (doscnt == 0 && unxcnt == 0 && maccnt > 0) {

/*        Only Mac terminator counter is non-zero. ID the file as Mac */
/*        Classic. */

	s_copy(termin, "CR", termin_len, (ftnlen)2);
    } else {

/*        We can get here in two cases. First if the line did not */
/*        contain any CRs or LFs. Second if the line contained more than */
/*        one kind of terminators. In either case the format of the file */
/*        is unclear. */

	s_copy(termin, "?", termin_len, (ftnlen)1);
    }

/*     Close the file. */

    cl__1.cerr = 0;
    cl__1.cunit = number;
    cl__1.csta = 0;
    f_clos(&cl__1);

/*     If we were told check the terminator against the native one, do */
/*     it. */

    if (*check) {

/*        If the terminator was identified and does not match the native */
/*        one, error out. */

	if (! eqstr_(termin, native, termin_len, (ftnlen)5) && ! eqstr_(
		termin, "?", termin_len, (ftnlen)1)) {
	    setmsg_("Text file '$1' contains lines terminated with '$2' whil"
		    "e the expected terminator for this platform is '$3'. SPI"
		    "CE cannot process the file in the current form. This pro"
		    "blem likely occurred because the file was copied in bina"
		    "ry mode between operating systems where the operating sy"
		    "stems use different text line terminators. Try convertin"
		    "g the file to native text form using a utility such as d"
		    "os2unix or unix2dos.", (ftnlen)411);
	    errch_("$1", file, (ftnlen)2, file_len);
	    errch_("$2", termin, (ftnlen)2, termin_len);
	    errch_("$3", native, (ftnlen)2, (ftnlen)5);
	    sigerr_("SPICE(INCOMPATIBLEEOL)", (ftnlen)22);
	    chkout_("ZZASCII", (ftnlen)7);
	    return 0;
	}
    }
    chkout_("ZZASCII", (ftnlen)7);
    return 0;
} /* zzascii_ */
Пример #10
0
/* Main program */ int MAIN__(void)
{
    /* Format strings */
    static char fmt_9994[] = "(/\002 Tests of the DOUBLE PRECISION LAPACK RF"
                             "P routines \002,/\002 LAPACK VERSION \002,i1,\002.\002,i1,\002"
                             ".\002,i1,//\002 The following parameter values will be used:\002)"
                             ;
    static char fmt_9996[] = "(\002 !! Invalid input value: \002,a4,\002="
                             "\002,i6,\002; must be >=\002,i6)";
    static char fmt_9995[] = "(\002 !! Invalid input value: \002,a4,\002="
                             "\002,i6,\002; must be <=\002,i6)";
    static char fmt_9993[] = "(4x,a4,\002:  \002,10i6,/11x,10i6)";
    static char fmt_9992[] = "(/\002 Routines pass computational tests if te"
                             "st ratio is \002,\002less than\002,f8.2,/)";
    static char fmt_9999[] = "(/\002 Execution not attempted due to input er"
                             "rors\002)";
    static char fmt_9991[] = "(\002 Relative machine \002,a,\002 is taken to"
                             " be\002,d16.6)";
    static char fmt_9998[] = "(/\002 End of tests\002)";
    static char fmt_9997[] = "(\002 Total time used = \002,f12.2,\002 seco"
                             "nds\002,/)";

    /* System generated locals */
    integer i__1;
    doublereal d__1;
    cllist cl__1;

    /* Builtin functions */
    integer s_rsle(cilist *), e_rsle(void), s_wsfe(cilist *), do_fio(integer *
            , char *, ftnlen), e_wsfe(void), do_lio(integer *, integer *,
                    char *, ftnlen);
    /* Subroutine */ int s_stop(char *, ftnlen);
    integer s_wsle(cilist *), e_wsle(void), f_clos(cllist *);

    /* Local variables */
    doublereal workafac[2500]	/* was [50][50] */, workasav[2500]	/*
	    was [50][50] */, workbsav[800]	/* was [50][16] */, workainv[
        2500]	/* was [50][50] */, workxact[800]	/* was [50][
	    16] */;
    integer i__;
    doublereal s1, s2;
    integer nn, vers_patch__, vers_major__, vers_minor__;
    doublereal workarfinv[1275], eps;
    integer nns, nnt, nval[12];
    doublereal d_temp_dpot02__[800]	/* was [50][16] */, d_temp_dpot03__[
        2500]	/* was [50][50] */, d_work_dpot01__[50],
                d_work_dpot02__[50], d_work_dpot03__[50];
    logical fatal;
    integer nsval[12], ntval[9];
    doublereal worka[2500]	/* was [50][50] */, workb[800]	/* was [50][
	    16] */, workx[800]	/* was [50][16] */, d_work_dlatms__[150],
                 d_work_dlansy__[50];
    extern doublereal dlamch_(char *), dsecnd_(void);
    extern /* Subroutine */ int ilaver_(integer *, integer *, integer *);
    doublereal thresh, workap[1275];
    logical tsterr;
    extern /* Subroutine */ int ddrvrf1_(integer *, integer *, integer *,
                                         doublereal *, doublereal *, integer *, doublereal *, doublereal *)
    , ddrvrf2_(integer *, integer *, integer *, doublereal *, integer
               *, doublereal *, doublereal *, doublereal *), ddrvrf3_(integer *,
                       integer *, integer *, doublereal *, doublereal *, integer *,
                       doublereal *, doublereal *, doublereal *, doublereal *,
                       doublereal *, doublereal *), ddrvrf4_(integer *, integer *,
                               integer *, doublereal *, doublereal *, doublereal *, integer *,
                               doublereal *, doublereal *, integer *, doublereal *), derrrfp_(
                                   integer *), ddrvrfp_(integer *, integer *, integer *, integer *,
                                           integer *, integer *, integer *, doublereal *, doublereal *,
                                           doublereal *, doublereal *, doublereal *, doublereal *,
                                           doublereal *, doublereal *, doublereal *, doublereal *,
                                           doublereal *, doublereal *, doublereal *, doublereal *,
                                           doublereal *, doublereal *, doublereal *, doublereal *);
    doublereal workarf[1275];

    /* Fortran I/O blocks */
    static cilist io___3 = { 0, 5, 0, 0, 0 };
    static cilist io___7 = { 0, 6, 0, fmt_9994, 0 };
    static cilist io___8 = { 0, 5, 0, 0, 0 };
    static cilist io___10 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___11 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___12 = { 0, 5, 0, 0, 0 };
    static cilist io___15 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___16 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___17 = { 0, 6, 0, fmt_9993, 0 };
    static cilist io___18 = { 0, 5, 0, 0, 0 };
    static cilist io___20 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___21 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___22 = { 0, 5, 0, 0, 0 };
    static cilist io___24 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___25 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___26 = { 0, 6, 0, fmt_9993, 0 };
    static cilist io___27 = { 0, 5, 0, 0, 0 };
    static cilist io___29 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___30 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___31 = { 0, 5, 0, 0, 0 };
    static cilist io___33 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___34 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___35 = { 0, 6, 0, fmt_9993, 0 };
    static cilist io___36 = { 0, 5, 0, 0, 0 };
    static cilist io___38 = { 0, 6, 0, fmt_9992, 0 };
    static cilist io___39 = { 0, 5, 0, 0, 0 };
    static cilist io___41 = { 0, 6, 0, fmt_9999, 0 };
    static cilist io___42 = { 0, 6, 0, fmt_9999, 0 };
    static cilist io___44 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___45 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___46 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___47 = { 0, 6, 0, 0, 0 };
    static cilist io___67 = { 0, 6, 0, fmt_9998, 0 };
    static cilist io___68 = { 0, 6, 0, fmt_9997, 0 };



    /*  -- LAPACK test routine (version 3.2.0) -- */
    /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
    /*     November 2008 */

    /*  Purpose */
    /*  ======= */

    /*  DCHKRFP is the main test program for the DOUBLE PRECISION linear */
    /*  equation routines with RFP storage format */


    /*  Internal Parameters */
    /*  =================== */

    /*  MAXIN   INTEGER */
    /*          The number of different values that can be used for each of */
    /*          M, N, or NB */

    /*  MAXRHS  INTEGER */
    /*          The maximum number of right hand sides */

    /*  NTYPES  INTEGER */

    /*  NMAX    INTEGER */
    /*          The maximum allowable value for N. */

    /*  NIN     INTEGER */
    /*          The unit number for input */

    /*  NOUT    INTEGER */
    /*          The unit number for output */

    /*  ===================================================================== */

    /*     .. Parameters .. */
    /*     .. */
    /*     .. Local Scalars .. */
    /*     .. */
    /*     .. Local Arrays .. */
    /*     .. */
    /*     .. External Functions .. */
    /*     .. */
    /*     .. External Subroutines .. */
    /*     .. */
    /*     .. Executable Statements .. */

    s1 = dsecnd_();
    fatal = FALSE_;

    /*     Read a dummy line. */

    s_rsle(&io___3);
    e_rsle();

    /*     Report LAPACK version tag (e.g. LAPACK-3.2.0) */

    ilaver_(&vers_major__, &vers_minor__, &vers_patch__);
    s_wsfe(&io___7);
    do_fio(&c__1, (char *)&vers_major__, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&vers_minor__, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&vers_patch__, (ftnlen)sizeof(integer));
    e_wsfe();

    /*     Read the values of N */

    s_rsle(&io___8);
    do_lio(&c__3, &c__1, (char *)&nn, (ftnlen)sizeof(integer));
    e_rsle();
    if (nn < 1) {
        s_wsfe(&io___10);
        do_fio(&c__1, " NN ", (ftnlen)4);
        do_fio(&c__1, (char *)&nn, (ftnlen)sizeof(integer));
        do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
        e_wsfe();
        nn = 0;
        fatal = TRUE_;
    } else if (nn > 12) {
        s_wsfe(&io___11);
        do_fio(&c__1, " NN ", (ftnlen)4);
        do_fio(&c__1, (char *)&nn, (ftnlen)sizeof(integer));
        do_fio(&c__1, (char *)&c__12, (ftnlen)sizeof(integer));
        e_wsfe();
        nn = 0;
        fatal = TRUE_;
    }
    s_rsle(&io___12);
    i__1 = nn;
    for (i__ = 1; i__ <= i__1; ++i__) {
        do_lio(&c__3, &c__1, (char *)&nval[i__ - 1], (ftnlen)sizeof(integer));
    }
    e_rsle();
    i__1 = nn;
    for (i__ = 1; i__ <= i__1; ++i__) {
        if (nval[i__ - 1] < 0) {
            s_wsfe(&io___15);
            do_fio(&c__1, " M  ", (ftnlen)4);
            do_fio(&c__1, (char *)&nval[i__ - 1], (ftnlen)sizeof(integer));
            do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
            e_wsfe();
            fatal = TRUE_;
        } else if (nval[i__ - 1] > 50) {
            s_wsfe(&io___16);
            do_fio(&c__1, " M  ", (ftnlen)4);
            do_fio(&c__1, (char *)&nval[i__ - 1], (ftnlen)sizeof(integer));
            do_fio(&c__1, (char *)&c__50, (ftnlen)sizeof(integer));
            e_wsfe();
            fatal = TRUE_;
        }
        /* L10: */
    }
    if (nn > 0) {
        s_wsfe(&io___17);
        do_fio(&c__1, "N   ", (ftnlen)4);
        i__1 = nn;
        for (i__ = 1; i__ <= i__1; ++i__) {
            do_fio(&c__1, (char *)&nval[i__ - 1], (ftnlen)sizeof(integer));
        }
        e_wsfe();
    }

    /*     Read the values of NRHS */

    s_rsle(&io___18);
    do_lio(&c__3, &c__1, (char *)&nns, (ftnlen)sizeof(integer));
    e_rsle();
    if (nns < 1) {
        s_wsfe(&io___20);
        do_fio(&c__1, " NNS", (ftnlen)4);
        do_fio(&c__1, (char *)&nns, (ftnlen)sizeof(integer));
        do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
        e_wsfe();
        nns = 0;
        fatal = TRUE_;
    } else if (nns > 12) {
        s_wsfe(&io___21);
        do_fio(&c__1, " NNS", (ftnlen)4);
        do_fio(&c__1, (char *)&nns, (ftnlen)sizeof(integer));
        do_fio(&c__1, (char *)&c__12, (ftnlen)sizeof(integer));
        e_wsfe();
        nns = 0;
        fatal = TRUE_;
    }
    s_rsle(&io___22);
    i__1 = nns;
    for (i__ = 1; i__ <= i__1; ++i__) {
        do_lio(&c__3, &c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer))
        ;
    }
    e_rsle();
    i__1 = nns;
    for (i__ = 1; i__ <= i__1; ++i__) {
        if (nsval[i__ - 1] < 0) {
            s_wsfe(&io___24);
            do_fio(&c__1, "NRHS", (ftnlen)4);
            do_fio(&c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer));
            do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
            e_wsfe();
            fatal = TRUE_;
        } else if (nsval[i__ - 1] > 16) {
            s_wsfe(&io___25);
            do_fio(&c__1, "NRHS", (ftnlen)4);
            do_fio(&c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer));
            do_fio(&c__1, (char *)&c__16, (ftnlen)sizeof(integer));
            e_wsfe();
            fatal = TRUE_;
        }
        /* L30: */
    }
    if (nns > 0) {
        s_wsfe(&io___26);
        do_fio(&c__1, "NRHS", (ftnlen)4);
        i__1 = nns;
        for (i__ = 1; i__ <= i__1; ++i__) {
            do_fio(&c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer));
        }
        e_wsfe();
    }

    /*     Read the matrix types */

    s_rsle(&io___27);
    do_lio(&c__3, &c__1, (char *)&nnt, (ftnlen)sizeof(integer));
    e_rsle();
    if (nnt < 1) {
        s_wsfe(&io___29);
        do_fio(&c__1, " NMA", (ftnlen)4);
        do_fio(&c__1, (char *)&nnt, (ftnlen)sizeof(integer));
        do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
        e_wsfe();
        nnt = 0;
        fatal = TRUE_;
    } else if (nnt > 9) {
        s_wsfe(&io___30);
        do_fio(&c__1, " NMA", (ftnlen)4);
        do_fio(&c__1, (char *)&nnt, (ftnlen)sizeof(integer));
        do_fio(&c__1, (char *)&c__9, (ftnlen)sizeof(integer));
        e_wsfe();
        nnt = 0;
        fatal = TRUE_;
    }
    s_rsle(&io___31);
    i__1 = nnt;
    for (i__ = 1; i__ <= i__1; ++i__) {
        do_lio(&c__3, &c__1, (char *)&ntval[i__ - 1], (ftnlen)sizeof(integer))
        ;
    }
    e_rsle();
    i__1 = nnt;
    for (i__ = 1; i__ <= i__1; ++i__) {
        if (ntval[i__ - 1] < 0) {
            s_wsfe(&io___33);
            do_fio(&c__1, "TYPE", (ftnlen)4);
            do_fio(&c__1, (char *)&ntval[i__ - 1], (ftnlen)sizeof(integer));
            do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
            e_wsfe();
            fatal = TRUE_;
        } else if (ntval[i__ - 1] > 9) {
            s_wsfe(&io___34);
            do_fio(&c__1, "TYPE", (ftnlen)4);
            do_fio(&c__1, (char *)&ntval[i__ - 1], (ftnlen)sizeof(integer));
            do_fio(&c__1, (char *)&c__9, (ftnlen)sizeof(integer));
            e_wsfe();
            fatal = TRUE_;
        }
        /* L320: */
    }
    if (nnt > 0) {
        s_wsfe(&io___35);
        do_fio(&c__1, "TYPE", (ftnlen)4);
        i__1 = nnt;
        for (i__ = 1; i__ <= i__1; ++i__) {
            do_fio(&c__1, (char *)&ntval[i__ - 1], (ftnlen)sizeof(integer));
        }
        e_wsfe();
    }

    /*     Read the threshold value for the test ratios. */

    s_rsle(&io___36);
    do_lio(&c__5, &c__1, (char *)&thresh, (ftnlen)sizeof(doublereal));
    e_rsle();
    s_wsfe(&io___38);
    do_fio(&c__1, (char *)&thresh, (ftnlen)sizeof(doublereal));
    e_wsfe();

    /*     Read the flag that indicates whether to test the error exits. */

    s_rsle(&io___39);
    do_lio(&c__8, &c__1, (char *)&tsterr, (ftnlen)sizeof(logical));
    e_rsle();

    if (fatal) {
        s_wsfe(&io___41);
        e_wsfe();
        s_stop("", (ftnlen)0);
    }

    if (fatal) {
        s_wsfe(&io___42);
        e_wsfe();
        s_stop("", (ftnlen)0);
    }

    /*     Calculate and print the machine dependent constants. */

    eps = dlamch_("Underflow threshold");
    s_wsfe(&io___44);
    do_fio(&c__1, "underflow", (ftnlen)9);
    do_fio(&c__1, (char *)&eps, (ftnlen)sizeof(doublereal));
    e_wsfe();
    eps = dlamch_("Overflow threshold");
    s_wsfe(&io___45);
    do_fio(&c__1, "overflow ", (ftnlen)9);
    do_fio(&c__1, (char *)&eps, (ftnlen)sizeof(doublereal));
    e_wsfe();
    eps = dlamch_("Epsilon");
    s_wsfe(&io___46);
    do_fio(&c__1, "precision", (ftnlen)9);
    do_fio(&c__1, (char *)&eps, (ftnlen)sizeof(doublereal));
    e_wsfe();
    s_wsle(&io___47);
    e_wsle();

    /*     Test the error exit of: */

    if (tsterr) {
        derrrfp_(&c__6);
    }

    /*     Test the routines: dpftrf, dpftri, dpftrs (as in DDRVPO). */
    /*     This also tests the routines: dtfsm, dtftri, dtfttr, dtrttf. */

    ddrvrfp_(&c__6, &nn, nval, &nns, nsval, &nnt, ntval, &thresh, worka,
             workasav, workafac, workainv, workb, workbsav, workxact, workx,
             workarf, workarfinv, d_work_dlatms__, d_work_dpot01__,
             d_temp_dpot02__, d_temp_dpot03__, d_work_dlansy__,
             d_work_dpot02__, d_work_dpot03__);

    /*     Test the routine: dlansf */

    ddrvrf1_(&c__6, &nn, nval, &thresh, worka, &c__50, workarf,
             d_work_dlansy__);

    /*     Test the convertion routines: */
    /*       dtfttp, dtpttf, dtfttr, dtrttf, dtrttp and dtpttr. */

    ddrvrf2_(&c__6, &nn, nval, worka, &c__50, workarf, workap, workasav);

    /*     Test the routine: dtfsm */

    ddrvrf3_(&c__6, &nn, nval, &thresh, worka, &c__50, workarf, workainv,
             workafac, d_work_dlansy__, d_work_dpot03__, d_work_dpot01__);


    /*     Test the routine: dsfrk */

    ddrvrf4_(&c__6, &nn, nval, &thresh, worka, workafac, &c__50, workarf,
             workainv, &c__50, d_work_dlansy__);

    cl__1.cerr = 0;
    cl__1.cunit = 5;
    cl__1.csta = 0;
    f_clos(&cl__1);
    s2 = dsecnd_();
    s_wsfe(&io___67);
    e_wsfe();
    s_wsfe(&io___68);
    d__1 = s2 - s1;
    do_fio(&c__1, (char *)&d__1, (ftnlen)sizeof(doublereal));
    e_wsfe();


    /*     End of DCHKRFP */

    return 0;
} /* MAIN__ */
Пример #11
0
integer
f_open (olist * a)
{
  unit *b;
  integer rv;
  char buf[256], *s, *env;
  cllist x;
  int ufmt;
  FILE *tf;
  int fd, len;
#ifndef NON_UNIX_STDIO
  int n;
#endif
  if (f__init != 1)
    f_init ();
  f__external = 1;
  if (a->ounit >= MXUNIT || a->ounit < 0)
    err (a->oerr, 101, "open");
  f__curunit = b = &f__units[a->ounit];
  if (b->ufd)
    {
      if (a->ofnm == 0)
	{
	same:if (a->oblnk)
	    b->ublnk = *a->oblnk == 'z' || *a->oblnk == 'Z';
	  return (0);
	}
#ifdef NON_UNIX_STDIO
      if (b->ufnm
	  && strlen (b->ufnm) == a->ofnmlen
	  && !strncmp (b->ufnm, a->ofnm, (unsigned) a->ofnmlen))
	goto same;
#else
      g_char (a->ofnm, a->ofnmlen, buf);
      if (f__inode (buf, &n) == b->uinode && n == b->udev)
	goto same;
#endif
      x.cunit = a->ounit;
      x.csta = 0;
      x.cerr = a->oerr;
      if ((rv = f_clos (&x)) != 0)
	return rv;
    }
  b->url = (int) a->orl;
  b->ublnk = a->oblnk && (*a->oblnk == 'z' || *a->oblnk == 'Z');
  if (a->ofm == 0)
    if ((a->oacc) && (*a->oacc == 'D' || *a->oacc == 'd'))
      b->ufmt = 0;
    else
      b->ufmt = 1;
  else if (*a->ofm == 'f' || *a->ofm == 'F')
    b->ufmt = 1;
  else
    b->ufmt = 0;
  ufmt = b->ufmt;
#ifdef url_Adjust
  if (b->url && !ufmt)
    url_Adjust (b->url);
#endif
  if (a->ofnm)
    {
      g_char (a->ofnm, a->ofnmlen, buf);
      if (!buf[0])
	opnerr (a->oerr, 107, "open");
    }
  else
    sprintf (buf, "fort.%ld", (long) a->ounit);
  b->uscrtch = 0;
  b->uend = 0;
  b->uwrt = 0;
  b->ufd = 0;
  b->urw = 3;
  switch (a->osta ? *a->osta : 'u')
    {
    case 'o':
    case 'O':
#ifdef NON_POSIX_STDIO
      if (!(tf = fopen (buf, "r")))
	opnerr (a->oerr, errno, "open");
      fclose (tf);
#else
      if (access (buf, 0))
	opnerr (a->oerr, errno, "open");
#endif
      break;
    case 's':
    case 'S':
      b->uscrtch = 1;
#ifdef HAVE_MKSTEMP		/* Allow use of TMPDIR preferentially. */
      env = getenv ("TMPDIR");
      if (!env)
	env = getenv ("TEMP");
      if (!env)
	env = "/tmp";
      len = strlen (env);
      if (len > 256 - (int) sizeof ("/tmp.FXXXXXX"))
	err (a->oerr, 132, "open");
      strcpy (buf, env);
      strcat (buf, "/tmp.FXXXXXX");
      fd = mkstemp (buf);
      if (fd == -1 || close (fd))
	err (a->oerr, 132, "open");
#else /* ! defined (HAVE_MKSTEMP) */
#ifdef HAVE_TEMPNAM		/* Allow use of TMPDIR preferentially. */
      s = tempnam (0, buf);
      if (strlen (s) >= sizeof (buf))
	err (a->oerr, 132, "open");
      (void) strcpy (buf, s);
      free (s);
#else /* ! defined (HAVE_TEMPNAM) */
#ifdef HAVE_TMPNAM
      tmpnam (buf);
#else
      (void) strcpy (buf, "tmp.FXXXXXX");
      (void) mktemp (buf);
#endif
#endif /* ! defined (HAVE_TEMPNAM) */
#endif /* ! defined (HAVE_MKSTEMP) */
      goto replace;
    case 'n':
    case 'N':
#ifdef NON_POSIX_STDIO
      if ((tf = fopen (buf, "r")) || (tf = fopen (buf, "a")))
	{
	  fclose (tf);
	  opnerr (a->oerr, 128, "open");
	}
#else
      if (!access (buf, 0))
	opnerr (a->oerr, 128, "open");
#endif
      /* no break */
    case 'r':			/* Fortran 90 replace option */
    case 'R':
    replace:
      if ((tf = fopen (buf, f__w_mode[0])))
	fclose (tf);
    }

  b->ufnm = (char *) malloc ((unsigned int) (strlen (buf) + 1));
  if (b->ufnm == NULL)
    opnerr (a->oerr, 113, "no space");
  (void) strcpy (b->ufnm, buf);
  if ((s = a->oacc) && b->url)
    ufmt = 0;
  if (!(tf = fopen (buf, f__w_mode[ufmt | 2])))
    {
      if ((tf = fopen (buf, f__r_mode[ufmt])))
	b->urw = 1;
      else if ((tf = fopen (buf, f__w_mode[ufmt])))
	{
	  b->uwrt = 1;
	  b->urw = 2;
	}
      else
	err (a->oerr, errno, "open");
    }
  b->useek = f__canseek (b->ufd = tf);
#ifndef NON_UNIX_STDIO
  if ((b->uinode = f__inode (buf, &b->udev)) == -1)
    opnerr (a->oerr, 108, "open");
#endif
  if (b->useek)
    {
      if (a->orl)
	FSEEK (b->ufd, 0, SEEK_SET);
      else if ((s = a->oacc) && (*s == 'a' || *s == 'A')
	       && FSEEK (b->ufd, 0, SEEK_END))
	opnerr (a->oerr, 129, "open");
    }
  return (0);
}
Пример #12
0
/* Main program */ int MAIN__(void)
{
    /* System generated locals */
    integer i__1, i__2;
    olist o__1;
    cllist cl__1;

    /* Builtin functions */
    integer s_wsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 
	    e_wsle(void), f_open(olist *), s_rsle(cilist *), e_rsle(void), 
	    f_clos(cllist *), s_cmp(char *, char *, ftnlen, ftnlen);

    /* Local variables */
    static real a[1000000]	/* was [1000][1000] */, b[1000];
    static integer i__, j, k, n;
    static real p[1000];
    static char orientacao[6];
    static real num;
    static integer argc;
    extern /* Subroutine */ int exit_(void);
    static char nome_arquivo__[20];
    extern integer iargc_(void), lucol_(integer *, integer *, real *, real *),
	     sscol_(integer *, integer *, real *, real *, real *), lurow_(
	    integer *, integer *, real *, real *), ssrow_(integer *, integer *
	    , real *, real *, real *);
    extern /* Subroutine */ int getarg_(integer *, char *, ftnlen);

    /* Fortran I/O blocks */
    static cilist io___4 = { 0, 6, 0, 0, 0 };
    static cilist io___5 = { 0, 1, 0, 0, 0 };
    static cilist io___8 = { 0, 1, 0, 0, 0 };
    static cilist io___13 = { 0, 1, 0, 0, 0 };
    static cilist io___16 = { 0, 6, 0, 0, 0 };
    static cilist io___17 = { 0, 6, 0, 0, 0 };
    static cilist io___18 = { 0, 6, 0, 0, 0 };
    static cilist io___19 = { 0, 6, 0, 0, 0 };
    static cilist io___20 = { 0, 6, 0, 0, 0 };




/*     Matriz LU */


    argc = iargc_();
    if (argc > 1) {
	getarg_(&c__1, nome_arquivo__, (ftnlen)20);
	getarg_(&c__2, orientacao, (ftnlen)6);
    } else {
	s_wsle(&io___4);
	do_lio(&c__9, &c__1, "Digite o nome do arquivo e se e orientada a li"
		"nha ou coluna. (Ex: m1.dat linha)", (ftnlen)79);
	e_wsle();
	exit_();
    }

    o__1.oerr = 0;
    o__1.ounit = 1;
    o__1.ofnmlen = 20;
    o__1.ofnm = nome_arquivo__;
    o__1.orl = 0;
    o__1.osta = "old";
    o__1.oacc = 0;
    o__1.ofm = 0;
    o__1.oblnk = 0;
    f_open(&o__1);

    s_rsle(&io___5);
    do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
    e_rsle();
/* Computing 2nd power */
    i__2 = n;
    i__1 = i__2 * i__2;
    for (k = 1; k <= i__1; ++k) {
	s_rsle(&io___8);
	do_lio(&c__3, &c__1, (char *)&i__, (ftnlen)sizeof(integer));
	do_lio(&c__3, &c__1, (char *)&j, (ftnlen)sizeof(integer));
	do_lio(&c__4, &c__1, (char *)&num, (ftnlen)sizeof(real));
	e_rsle();
	a[i__ + 1 + (j + 1) * 1000 - 1001] = num;
    }

    i__1 = n;
    for (k = 1; k <= i__1; ++k) {
	s_rsle(&io___13);
	do_lio(&c__3, &c__1, (char *)&i__, (ftnlen)sizeof(integer));
	do_lio(&c__4, &c__1, (char *)&num, (ftnlen)sizeof(real));
	e_rsle();
	b[i__] = num;
    }

    cl__1.cerr = 0;
    cl__1.cunit = 1;
    cl__1.csta = 0;
    f_clos(&cl__1);

/* ====================================================== */
/*     OPERACAO POR LINHA */

    if (s_cmp(orientacao, "linha", (ftnlen)6, (ftnlen)5) == 0 && lurow_(&n, &
	    c__1000, a, p) == -1) {
	s_wsle(&io___16);
	do_lio(&c__9, &c__1, "Matriz singular.", (ftnlen)16);
	e_wsle();
	exit_();
    }
    if (s_cmp(orientacao, "linha", (ftnlen)6, (ftnlen)5) == 0 && ssrow_(&n, &
	    c__1000, a, p, b) == -1) {
	s_wsle(&io___17);
	do_lio(&c__9, &c__1, "Matriz singular.", (ftnlen)16);
	e_wsle();
	exit_();
    }
/* ====================================================== */
/*     OPERACAO POR COLUNA */

    if (s_cmp(orientacao, "coluna", (ftnlen)6, (ftnlen)6) == 0 && lucol_(&n, &
	    c__1000, a, p) == -1) {
	s_wsle(&io___18);
	do_lio(&c__9, &c__1, "Matriz singular.", (ftnlen)16);
	e_wsle();
	exit_();
    }
    if (s_cmp(orientacao, "coluna", (ftnlen)6, (ftnlen)6) == 0 && sscol_(&n, &
	    c__1000, a, p, b) == -1) {
	s_wsle(&io___19);
	do_lio(&c__9, &c__1, "Matriz singular.", (ftnlen)16);
	e_wsle();
	exit_();
    }
/* ====================================================== */

    i__1 = n;
    for (i__ = 1; i__ <= i__1; ++i__) {
	s_wsle(&io___20);
	do_lio(&c__4, &c__1, (char *)&b[i__ - 1], (ftnlen)sizeof(real));
	e_wsle();
    }

    return 0;
} /* MAIN__ */
Пример #13
0
/* Main program */ int MAIN__(void)
{
    /* Initialized data */

    static char intstr[10] = "0123456789";

    /* Format strings */
    static char fmt_9994[] = "(\002 Tests of the DOUBLE PRECISION LAPACK DSG"
	    "ESV/DSPOSV\002,\002 routines \002,/\002 LAPACK VERSION \002,i1"
	    ",\002.\002,i1,\002.\002,i1,//\002 The following parameter values"
	    " will be used:\002)";
    static char fmt_9996[] = "(\002 Invalid input value: \002,a4,\002=\002,i"
	    "6,\002; must be >=\002,i6)";
    static char fmt_9995[] = "(\002 Invalid input value: \002,a4,\002=\002,i"
	    "6,\002; must be <=\002,i6)";
    static char fmt_9993[] = "(4x,a4,\002:  \002,10i6,/11x,10i6)";
    static char fmt_9992[] = "(/\002 Routines pass computational tests if te"
	    "st ratio is \002,\002less than\002,f8.2,/)";
    static char fmt_9999[] = "(/\002 Execution not attempted due to input er"
	    "rors\002)";
    static char fmt_9991[] = "(\002 Relative machine \002,a,\002 is taken to"
	    " be\002,d16.6)";
    static char fmt_9990[] = "(/1x,a6,\002 routines were not tested\002)";
    static char fmt_9989[] = "(/1x,a6,\002 driver routines were not teste"
	    "d\002)";
    static char fmt_9998[] = "(/\002 End of tests\002)";
    static char fmt_9997[] = "(\002 Total time used = \002,f12.2,\002 seco"
	    "nds\002,/)";

    /* System generated locals */
    integer i__1;
    doublereal d__1;
    cilist ci__1;
    cllist cl__1;

    /* Local variables */
    doublereal a[34848]	/* was [17424][2] */, b[4224]	/* was [2112][2] */;
    integer i__, k;
    char c1[1], c2[2];
    doublereal s1, s2;
    integer ic, nm, vers_patch__, vers_major__, vers_minor__, lda;
    doublereal eps;
    integer nns;
    char path[3];
    integer mval[12], nrhs;
    real seps;
    doublereal work[4224];
    logical fatal;
    char aline[72];
    integer nmats, nsval[12], iwork[132];
    doublereal rwork[132];
    real swork[19536];
    doublereal thresh;
    logical dotype[30];
    integer ntypes;
    logical tsterr, tstdrv;

    /* Fortran I/O blocks */
    static cilist io___5 = { 0, 5, 0, 0, 0 };
    static cilist io___9 = { 0, 6, 0, fmt_9994, 0 };
    static cilist io___10 = { 0, 5, 0, 0, 0 };
    static cilist io___12 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___13 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___14 = { 0, 5, 0, 0, 0 };
    static cilist io___17 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___18 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___19 = { 0, 6, 0, fmt_9993, 0 };
    static cilist io___20 = { 0, 5, 0, 0, 0 };
    static cilist io___22 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___23 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___24 = { 0, 5, 0, 0, 0 };
    static cilist io___26 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___27 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___28 = { 0, 6, 0, fmt_9993, 0 };
    static cilist io___29 = { 0, 5, 0, 0, 0 };
    static cilist io___31 = { 0, 6, 0, fmt_9992, 0 };
    static cilist io___32 = { 0, 5, 0, 0, 0 };
    static cilist io___34 = { 0, 5, 0, 0, 0 };
    static cilist io___36 = { 0, 6, 0, fmt_9999, 0 };
    static cilist io___38 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___39 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___40 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___41 = { 0, 6, 0, 0, 0 };
    static cilist io___43 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___44 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___45 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___46 = { 0, 6, 0, 0, 0 };
    static cilist io___55 = { 0, 6, 0, fmt_9990, 0 };
    static cilist io___56 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___65 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___66 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___68 = { 0, 6, 0, fmt_9998, 0 };
    static cilist io___69 = { 0, 6, 0, fmt_9997, 0 };



/*  -- LAPACK test routine (version 3.1.1) -- */
/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
/*     January 2007 */

/*  Purpose */
/*  ======= */

/*  DCHKAB is the test program for the DOUBLE PRECISION LAPACK */
/*  DSGESV/DSPOSV routine */

/*  The program must be driven by a short data file. The first 5 records */
/*  specify problem dimensions and program options using list-directed */
/*  input. The remaining lines specify the LAPACK test paths and the */
/*  number of matrix types to use in testing.  An annotated example of a */
/*  data file can be obtained by deleting the first 3 characters from the */
/*  following 10 lines: */
/*  Data file for testing DOUBLE PRECISION LAPACK DSGESV */
/*  7                      Number of values of M */
/*  0 1 2 3 5 10 16        Values of M (row dimension) */
/*  1                      Number of values of NRHS */
/*  2                      Values of NRHS (number of right hand sides) */
/*  20.0                   Threshold value of test ratio */
/*  T                      Put T to test the LAPACK routines */
/*  T                      Put T to test the error exits */
/*  DGE    11              List types on next line if 0 < NTYPES < 11 */
/*  DPO    9               List types on next line if 0 < NTYPES <  9 */

/*  Internal Parameters */
/*  =================== */

/*  NMAX    INTEGER */
/*          The maximum allowable value for N */

/*  MAXIN   INTEGER */
/*          The number of different values that can be used for each of */
/*          M, N, NRHS, NB, and NX */

/*  MAXRHS  INTEGER */
/*          The maximum number of right hand sides */

/*  NIN     INTEGER */
/*          The unit number for input */

/*  NOUT    INTEGER */
/*          The unit number for output */

/*  ===================================================================== */

/*     .. Parameters .. */
/*     .. */
/*     .. Local Scalars .. */
/*     .. */
/*     .. Local Arrays .. */
/*     .. */
/*     .. External Functions .. */
/*     .. */
/*     .. External Subroutines .. */
/*     .. */
/*     .. Scalars in Common .. */
/*     .. */
/*     .. Common blocks .. */
/*     .. */
/*     .. Data statements .. */
/*     .. */
/*     .. Executable Statements .. */

    s1 = dsecnd_();
    lda = 132;
    fatal = FALSE_;

/*     Read a dummy line. */

    s_rsle(&io___5);
    e_rsle();

/*     Report values of parameters. */

    ilaver_(&vers_major__, &vers_minor__, &vers_patch__);
    s_wsfe(&io___9);
    do_fio(&c__1, (char *)&vers_major__, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&vers_minor__, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&vers_patch__, (ftnlen)sizeof(integer));
    e_wsfe();

/*     Read the values of M */

    s_rsle(&io___10);
    do_lio(&c__3, &c__1, (char *)&nm, (ftnlen)sizeof(integer));
    e_rsle();
    if (nm < 1) {
	s_wsfe(&io___12);
	do_fio(&c__1, " NM ", (ftnlen)4);
	do_fio(&c__1, (char *)&nm, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
	e_wsfe();
	nm = 0;
	fatal = TRUE_;
    } else if (nm > 12) {
	s_wsfe(&io___13);
	do_fio(&c__1, " NM ", (ftnlen)4);
	do_fio(&c__1, (char *)&nm, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__12, (ftnlen)sizeof(integer));
	e_wsfe();
	nm = 0;
	fatal = TRUE_;
    }
    s_rsle(&io___14);
    i__1 = nm;
    for (i__ = 1; i__ <= i__1; ++i__) {
	do_lio(&c__3, &c__1, (char *)&mval[i__ - 1], (ftnlen)sizeof(integer));
    }
    e_rsle();
    i__1 = nm;
    for (i__ = 1; i__ <= i__1; ++i__) {
	if (mval[i__ - 1] < 0) {
	    s_wsfe(&io___17);
	    do_fio(&c__1, " M  ", (ftnlen)4);
	    do_fio(&c__1, (char *)&mval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	} else if (mval[i__ - 1] > 132) {
	    s_wsfe(&io___18);
	    do_fio(&c__1, " M  ", (ftnlen)4);
	    do_fio(&c__1, (char *)&mval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__132, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	}
/* L10: */
    }
    if (nm > 0) {
	s_wsfe(&io___19);
	do_fio(&c__1, "M   ", (ftnlen)4);
	i__1 = nm;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_fio(&c__1, (char *)&mval[i__ - 1], (ftnlen)sizeof(integer));
	}
	e_wsfe();
    }

/*     Read the values of NRHS */

    s_rsle(&io___20);
    do_lio(&c__3, &c__1, (char *)&nns, (ftnlen)sizeof(integer));
    e_rsle();
    if (nns < 1) {
	s_wsfe(&io___22);
	do_fio(&c__1, " NNS", (ftnlen)4);
	do_fio(&c__1, (char *)&nns, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
	e_wsfe();
	nns = 0;
	fatal = TRUE_;
    } else if (nns > 12) {
	s_wsfe(&io___23);
	do_fio(&c__1, " NNS", (ftnlen)4);
	do_fio(&c__1, (char *)&nns, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__12, (ftnlen)sizeof(integer));
	e_wsfe();
	nns = 0;
	fatal = TRUE_;
    }
    s_rsle(&io___24);
    i__1 = nns;
    for (i__ = 1; i__ <= i__1; ++i__) {
	do_lio(&c__3, &c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer))
		;
    }
    e_rsle();
    i__1 = nns;
    for (i__ = 1; i__ <= i__1; ++i__) {
	if (nsval[i__ - 1] < 0) {
	    s_wsfe(&io___26);
	    do_fio(&c__1, "NRHS", (ftnlen)4);
	    do_fio(&c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	} else if (nsval[i__ - 1] > 16) {
	    s_wsfe(&io___27);
	    do_fio(&c__1, "NRHS", (ftnlen)4);
	    do_fio(&c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__16, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	}
/* L30: */
    }
    if (nns > 0) {
	s_wsfe(&io___28);
	do_fio(&c__1, "NRHS", (ftnlen)4);
	i__1 = nns;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_fio(&c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer));
	}
	e_wsfe();
    }

/*     Read the threshold value for the test ratios. */

    s_rsle(&io___29);
    do_lio(&c__5, &c__1, (char *)&thresh, (ftnlen)sizeof(doublereal));
    e_rsle();
    s_wsfe(&io___31);
    do_fio(&c__1, (char *)&thresh, (ftnlen)sizeof(doublereal));
    e_wsfe();

/*     Read the flag that indicates whether to test the driver routine. */

    s_rsle(&io___32);
    do_lio(&c__8, &c__1, (char *)&tstdrv, (ftnlen)sizeof(logical));
    e_rsle();

/*     Read the flag that indicates whether to test the error exits. */

    s_rsle(&io___34);
    do_lio(&c__8, &c__1, (char *)&tsterr, (ftnlen)sizeof(logical));
    e_rsle();

    if (fatal) {
	s_wsfe(&io___36);
	e_wsfe();
	s_stop("", (ftnlen)0);
    }

/*     Calculate and print the machine dependent constants. */

    seps = slamch_("Underflow threshold");
    s_wsfe(&io___38);
    do_fio(&c__1, "(single precision) underflow", (ftnlen)28);
    do_fio(&c__1, (char *)&seps, (ftnlen)sizeof(real));
    e_wsfe();
    seps = slamch_("Overflow threshold");
    s_wsfe(&io___39);
    do_fio(&c__1, "(single precision) overflow ", (ftnlen)28);
    do_fio(&c__1, (char *)&seps, (ftnlen)sizeof(real));
    e_wsfe();
    seps = slamch_("Epsilon");
    s_wsfe(&io___40);
    do_fio(&c__1, "(single precision) precision", (ftnlen)28);
    do_fio(&c__1, (char *)&seps, (ftnlen)sizeof(real));
    e_wsfe();
    s_wsle(&io___41);
    e_wsle();

    eps = dlamch_("Underflow threshold");
    s_wsfe(&io___43);
    do_fio(&c__1, "(double precision) underflow", (ftnlen)28);
    do_fio(&c__1, (char *)&eps, (ftnlen)sizeof(doublereal));
    e_wsfe();
    eps = dlamch_("Overflow threshold");
    s_wsfe(&io___44);
    do_fio(&c__1, "(double precision) overflow ", (ftnlen)28);
    do_fio(&c__1, (char *)&eps, (ftnlen)sizeof(doublereal));
    e_wsfe();
    eps = dlamch_("Epsilon");
    s_wsfe(&io___45);
    do_fio(&c__1, "(double precision) precision", (ftnlen)28);
    do_fio(&c__1, (char *)&eps, (ftnlen)sizeof(doublereal));
    e_wsfe();
    s_wsle(&io___46);
    e_wsle();

L80:

/*     Read a test path and the number of matrix types to use. */

    ci__1.cierr = 0;
    ci__1.ciend = 1;
    ci__1.ciunit = 5;
    ci__1.cifmt = "(A72)";
    i__1 = s_rsfe(&ci__1);
    if (i__1 != 0) {
	goto L140;
    }
    i__1 = do_fio(&c__1, aline, (ftnlen)72);
    if (i__1 != 0) {
	goto L140;
    }
    i__1 = e_rsfe();
    if (i__1 != 0) {
	goto L140;
    }
    s_copy(path, aline, (ftnlen)3, (ftnlen)3);
    nmats = 30;
    i__ = 3;
L90:
    ++i__;
    if (i__ > 72) {
	nmats = 30;
	goto L130;
    }
    if (*(unsigned char *)&aline[i__ - 1] == ' ') {
	goto L90;
    }
    nmats = 0;
L100:
    *(unsigned char *)c1 = *(unsigned char *)&aline[i__ - 1];
    for (k = 1; k <= 10; ++k) {
	if (*(unsigned char *)c1 == *(unsigned char *)&intstr[k - 1]) {
	    ic = k - 1;
	    goto L120;
	}
/* L110: */
    }
    goto L130;
L120:
    nmats = nmats * 10 + ic;
    ++i__;
    if (i__ > 72) {
	goto L130;
    }
    goto L100;
L130:
    *(unsigned char *)c1 = *(unsigned char *)path;
    s_copy(c2, path + 1, (ftnlen)2, (ftnlen)2);
    nrhs = nsval[0];

/*     Check first character for correct precision. */

    if (! lsame_(c1, "Double precision")) {
	s_wsfe(&io___55);
	do_fio(&c__1, path, (ftnlen)3);
	e_wsfe();

    } else if (nmats <= 0) {

/*        Check for a positive number of tests requested. */

	s_wsfe(&io___56);
	do_fio(&c__1, path, (ftnlen)3);
	e_wsfe();
	goto L140;

    } else if (lsamen_(&c__2, c2, "GE")) {

/*        GE:  general matrices */

	ntypes = 11;
	alareq_("DGE", &nmats, dotype, &ntypes, &c__5, &c__6);

/*        Test the error exits */

	if (tsterr) {
	    derrab_(&c__6);
	}

	if (tstdrv) {
	    ddrvab_(dotype, &nm, mval, &nns, nsval, &thresh, &lda, a, &a[
		    17424], b, &b[2112], work, rwork, swork, iwork, &c__6);
	} else {
	    s_wsfe(&io___65);
	    do_fio(&c__1, "DSGESV", (ftnlen)6);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "PO")) {

/*        PO:  positive definite matrices */

	ntypes = 9;
	alareq_("DPO", &nmats, dotype, &ntypes, &c__5, &c__6);


	if (tsterr) {
	    derrac_(&c__6);
	}


	if (tstdrv) {
	    ddrvac_(dotype, &nm, mval, &nns, nsval, &thresh, &lda, a, &a[
		    17424], b, &b[2112], work, rwork, swork, &c__6);
	} else {
	    s_wsfe(&io___66);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}
    } else {

    }

/*     Go back to get another input line. */

    goto L80;

/*     Branch to this line when the last record is read. */

L140:
    cl__1.cerr = 0;
    cl__1.cunit = 5;
    cl__1.csta = 0;
    f_clos(&cl__1);
    s2 = dsecnd_();
    s_wsfe(&io___68);
    e_wsfe();
    s_wsfe(&io___69);
    d__1 = s2 - s1;
    do_fio(&c__1, (char *)&d__1, (ftnlen)sizeof(doublereal));
    e_wsfe();

/* L9988: */

/*     End of DCHKAB */

    return 0;
} /* MAIN__ */
Пример #14
0
/* Subroutine */ int forsav_(doublereal *time, doublereal *deldip, integer *
	ipt, doublereal *fmatrx, doublereal *coord, integer *nvar, doublereal 
	*refh, doublereal *evecs, integer *jstart, doublereal *fconst)
{
    /* System generated locals */
    integer i__1, i__2;
    char ch__1[80];
    olist o__1;
    cllist cl__1;
    alist al__1;

    /* Builtin functions */
    integer f_open(olist *), f_rew(alist *), s_rsue(cilist *), do_uio(integer 
	    *, char *, ftnlen), e_rsue(void), s_wsue(cilist *), e_wsue(void), 
	    f_clos(cllist *), s_wsfe(cilist *), e_wsfe(void);
    /* Subroutine */ int s_stop(char *, ftnlen);

    /* Local variables */
    static integer i__, j, n33, ir, iw;
    extern /* Character */ VOID getnam_(char *, ftnlen, char *, ftnlen);
    static integer linear;

    /* Fortran I/O blocks */
    static cilist io___3 = { 1, 0, 1, 0, 0 };
    static cilist io___5 = { 0, 0, 0, 0, 0 };
    static cilist io___7 = { 1, 0, 1, 0, 0 };
    static cilist io___8 = { 0, 0, 0, 0, 0 };
    static cilist io___11 = { 0, 0, 0, 0, 0 };
    static cilist io___12 = { 0, 0, 0, 0, 0 };
    static cilist io___13 = { 0, 0, 0, 0, 0 };
    static cilist io___14 = { 0, 0, 0, 0, 0 };
    static cilist io___15 = { 0, 0, 0, 0, 0 };
    static cilist io___16 = { 0, 0, 0, 0, 0 };
    static cilist io___17 = { 0, 0, 0, 0, 0 };
    static cilist io___18 = { 0, 0, 0, 0, 0 };
    static cilist io___19 = { 0, 10, 0, 0, 0 };
    static cilist io___20 = { 0, 10, 0, 0, 0 };
    static cilist io___21 = { 0, 6, 0, "(10X,'INSUFFICIENT DATA ON DISK FILE"
	    "S FOR A FORCE ',   'CALCULATION',/10X,'RESTART. PERHAPS THIS STA"
	    "RTED OF AS A ',  'FORCE CALCULATION ')", 0 };
    static cilist io___22 = { 0, 6, 0, "(10X,'BUT THE GEOMETRY HAD TO BE OPT"
	    "IMIZED FIRST, ',   'IN WHICH CASE ',/10X,'REMOVE THE KEY-WORD \""
	    "FORCE\".')", 0 };
    static cilist io___23 = { 0, 6, 0, "(//10X,'NO RESTART FILE EXISTS!')", 0 
	    };


/* COMDECK SIZES */
/* *********************************************************************** */
/*   THIS FILE CONTAINS ALL THE ARRAY SIZES FOR USE IN MOPAC. */

/*     THERE ARE ONLY 5 PARAMETERS THAT THE PROGRAMMER NEED SET: */
/*     MAXHEV = MAXIMUM NUMBER OF HEAVY ATOMS (HEAVY: NON-HYDROGEN ATOMS) */
/*     MAXLIT = MAXIMUM NUMBER OF HYDROGEN ATOMS. */
/*     MAXTIM = DEFAULT TIME FOR A JOB. (SECONDS) */
/*     MAXDMP = DEFAULT TIME FOR AUTOMATIC RESTART FILE GENERATION (SECS) */
/*     ISYBYL = 1 IF MOPAC IS TO BE USED IN THE SYBYL PACKAGE, =0 OTHERWISE */
/*     SEE ALSO NMECI, NPULAY AND MESP AT THE END OF THIS FILE */


/* *********************************************************************** */

/*   THE FOLLOWING CODE DOES NOT NEED TO BE ALTERED BY THE PROGRAMMER */

/* *********************************************************************** */

/*    ALL OTHER PARAMETERS ARE DERIVED FUNCTIONS OF THESE TWO PARAMETERS */

/*      NAME                   DEFINITION */
/*     NUMATM         MAXIMUM NUMBER OF ATOMS ALLOWED. */
/*     MAXORB         MAXIMUM NUMBER OF ORBITALS ALLOWED. */
/*     MAXPAR         MAXIMUM NUMBER OF PARAMETERS FOR OPTIMISATION. */
/*     N2ELEC         MAXIMUM NUMBER OF TWO ELECTRON INTEGRALS ALLOWED. */
/*     MPACK          AREA OF LOWER HALF TRIANGLE OF DENSITY MATRIX. */
/*     MORB2          SQUARE OF THE MAXIMUM NUMBER OF ORBITALS ALLOWED. */
/*     MAXHES         AREA OF HESSIAN MATRIX */
/*     MAXALL         LARGER THAN MAXORB OR MAXPAR. */
/* *********************************************************************** */

/* *********************************************************************** */
/* DECK MOPAC */
/* *********************************************************************** */

/*  FORSAV SAVES AND RESTORES DATA USED IN THE FORCE CALCULATION. */

/* ON INPUT TIME = TOTAL TIME ELAPSED SINCE THE START OF THE CALCULATION. */
/*          IPT  = LINE OF FORCE MATRIX REACHED, IF IN WRITE MODE, */
/*               = 0 IF IN READ MODE. */
/*        FMATRX = FORCE MATRIX */
/* *********************************************************************** */
    /* Parameter adjustments */
    --fconst;
    --evecs;
    --coord;
    --fmatrx;
    deldip -= 4;

    /* Function Body */
    o__1.oerr = 0;
    o__1.ounit = 9;
    o__1.ofnmlen = 80;
    getnam_(ch__1, (ftnlen)80, "FOR009", (ftnlen)6);
    o__1.ofnm = ch__1;
    o__1.orl = 0;
    o__1.osta = "UNKNOWN";
    o__1.oacc = 0;
    o__1.ofm = "UNFORMATTED";
    o__1.oblnk = 0;
    f_open(&o__1);
    al__1.aerr = 0;
    al__1.aunit = 9;
    f_rew(&al__1);
    o__1.oerr = 0;
    o__1.ounit = 10;
    o__1.ofnmlen = 80;
    getnam_(ch__1, (ftnlen)80, "FOR010", (ftnlen)6);
    o__1.ofnm = ch__1;
    o__1.orl = 0;
    o__1.osta = "UNKNOWN";
    o__1.oacc = 0;
    o__1.ofm = "UNFORMATTED";
    o__1.oblnk = 0;
    f_open(&o__1);
    al__1.aerr = 0;
    al__1.aunit = 10;
    f_rew(&al__1);
    ir = 9;
    iw = 9;
    if (*ipt == 0) {

/*   READ IN FORCE DATA */

	io___3.ciunit = ir;
	i__1 = s_rsue(&io___3);
	if (i__1 != 0) {
	    goto L20;
	}
	i__1 = do_uio(&c__1, (char *)&(*time), (ftnlen)sizeof(doublereal));
	if (i__1 != 0) {
	    goto L20;
	}
	i__1 = do_uio(&c__1, (char *)&(*ipt), (ftnlen)sizeof(integer));
	if (i__1 != 0) {
	    goto L20;
	}
	i__1 = do_uio(&c__1, (char *)&(*refh), (ftnlen)sizeof(doublereal));
	if (i__1 != 0) {
	    goto L20;
	}
	i__1 = e_rsue();
	if (i__1 != 0) {
	    goto L20;
	}
	linear = *nvar * (*nvar + 1) / 2;
	io___5.ciunit = ir;
	s_rsue(&io___5);
	i__1 = *nvar;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_uio(&c__1, (char *)&coord[i__], (ftnlen)sizeof(doublereal));
	}
	e_rsue();
	io___7.ciunit = ir;
	i__1 = s_rsue(&io___7);
	if (i__1 != 0) {
	    goto L10;
	}
	i__2 = linear;
	for (i__ = 1; i__ <= i__2; ++i__) {
	    i__1 = do_uio(&c__1, (char *)&fmatrx[i__], (ftnlen)sizeof(
		    doublereal));
	    if (i__1 != 0) {
		goto L10;
	    }
	}
	i__1 = e_rsue();
	if (i__1 != 0) {
	    goto L10;
	}
	io___8.ciunit = ir;
	s_rsue(&io___8);
	i__1 = *ipt;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    for (j = 1; j <= 3; ++j) {
		do_uio(&c__1, (char *)&deldip[j + i__ * 3], (ftnlen)sizeof(
			doublereal));
	    }
	}
	e_rsue();
	n33 = *nvar * *nvar;
	io___11.ciunit = ir;
	s_rsue(&io___11);
	i__1 = n33;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_uio(&c__1, (char *)&evecs[i__], (ftnlen)sizeof(doublereal));
	}
	e_rsue();
	io___12.ciunit = ir;
	s_rsue(&io___12);
	do_uio(&c__1, (char *)&(*jstart), (ftnlen)sizeof(integer));
	i__1 = *nvar;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_uio(&c__1, (char *)&fconst[i__], (ftnlen)sizeof(doublereal));
	}
	e_rsue();
	return 0;
    } else {

/*    WRITE FORCE DATA */

	al__1.aerr = 0;
	al__1.aunit = iw;
	f_rew(&al__1);
	if (*time > 1e6) {
	    *time += -1e6;
	}
	io___13.ciunit = iw;
	s_wsue(&io___13);
	do_uio(&c__1, (char *)&(*time), (ftnlen)sizeof(doublereal));
	do_uio(&c__1, (char *)&(*ipt), (ftnlen)sizeof(integer));
	do_uio(&c__1, (char *)&(*refh), (ftnlen)sizeof(doublereal));
	e_wsue();
	linear = *nvar * (*nvar + 1) / 2;
	io___14.ciunit = iw;
	s_wsue(&io___14);
	i__1 = *nvar;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_uio(&c__1, (char *)&coord[i__], (ftnlen)sizeof(doublereal));
	}
	e_wsue();
	io___15.ciunit = iw;
	s_wsue(&io___15);
	i__1 = linear;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_uio(&c__1, (char *)&fmatrx[i__], (ftnlen)sizeof(doublereal));
	}
	e_wsue();
	io___16.ciunit = iw;
	s_wsue(&io___16);
	i__1 = *ipt;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    for (j = 1; j <= 3; ++j) {
		do_uio(&c__1, (char *)&deldip[j + i__ * 3], (ftnlen)sizeof(
			doublereal));
	    }
	}
	e_wsue();
	n33 = *nvar * *nvar;
	io___17.ciunit = ir;
	s_wsue(&io___17);
	i__1 = n33;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_uio(&c__1, (char *)&evecs[i__], (ftnlen)sizeof(doublereal));
	}
	e_wsue();
	io___18.ciunit = ir;
	s_wsue(&io___18);
	do_uio(&c__1, (char *)&(*jstart), (ftnlen)sizeof(integer));
	i__1 = *nvar;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_uio(&c__1, (char *)&fconst[i__], (ftnlen)sizeof(doublereal));
	}
	e_wsue();
	linear = molkst_1.norbs * (molkst_1.norbs + 1) / 2;
	s_wsue(&io___19);
	i__1 = linear;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_uio(&c__1, (char *)&densty_1.pa[i__ - 1], (ftnlen)sizeof(
		    doublereal));
	}
	e_wsue();
	if (molkst_1.nalpha != 0) {
	    s_wsue(&io___20);
	    i__1 = linear;
	    for (i__ = 1; i__ <= i__1; ++i__) {
		do_uio(&c__1, (char *)&densty_1.pb[i__ - 1], (ftnlen)sizeof(
			doublereal));
	    }
	    e_wsue();
	}
	cl__1.cerr = 0;
	cl__1.cunit = 9;
	cl__1.csta = 0;
	f_clos(&cl__1);
	cl__1.cerr = 0;
	cl__1.cunit = 10;
	cl__1.csta = 0;
	f_clos(&cl__1);
    }
    return 0;
L10:
    s_wsfe(&io___21);
    e_wsfe();
    s_wsfe(&io___22);
    e_wsfe();
    s_stop("", (ftnlen)0);
L20:
    s_wsfe(&io___23);
    e_wsfe();
    s_stop("", (ftnlen)0);
    return 0;
} /* forsav_ */
Пример #15
0
/* $ Procedure CONVBT ( Convert Kernel file from binary to text ) */
/* Subroutine */ int convbt_(char *binfil, char *txtfil, ftnlen binfil_len, 
	ftnlen txtfil_len)
{
    /* System generated locals */
    cllist cl__1;

    /* Builtin functions */
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
    integer s_cmp(char *, char *, ftnlen, ftnlen), f_clos(cllist *), s_wsle(
	    cilist *), do_lio(integer *, integer *, char *, ftnlen), e_wsle(
	    void);

    /* Local variables */
    extern /* Subroutine */ int dafbt_(char *, integer *, ftnlen);
    char farch[3];
    extern /* Subroutine */ int chkin_(char *, ftnlen), spcec_(integer *, 
	    integer *), dasbt_(char *, integer *, ftnlen), errch_(char *, 
	    char *, ftnlen, ftnlen);
    char ftype[4];
    extern logical failed_(void);
    integer handle;
    extern /* Subroutine */ int dafcls_(integer *), getfat_(char *, char *, 
	    char *, ftnlen, ftnlen, ftnlen), dafopr_(char *, integer *, 
	    ftnlen), sigerr_(char *, ftnlen), chkout_(char *, ftnlen), 
	    setmsg_(char *, ftnlen);
    integer iostat;
    logical comnts;
    extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
    extern logical return_(void);
    extern /* Subroutine */ int txtopn_(char *, integer *, ftnlen);
    integer txtlun;

    /* Fortran I/O blocks */
    static cilist io___7 = { 1, 0, 0, 0, 0 };
    static cilist io___8 = { 1, 0, 0, 0, 0 };


/* $ Abstract */

/*     Convert a SPICE binary file to an equivalent text file format. */

/*     NOTE: This routine is currently for use ONLY with the SPACIT */
/*           utility program. Use it at your own risk. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     None. */

/* $ Keywords */

/*     CONVERSION */
/*     FILES */
/*     UTILITY */

/* $ Declarations */
/* $ Brief_I/O */

/*     Variable  I/O  Description */
/*     --------  ---  -------------------------------------------------- */
/*      BINFIL    I   Name of an existing SPICE binary file. */
/*      TXTFIL    I   Name of the text file to be created. */

/* $ Detailed_Input */

/*     None. */

/* $ Detailed_Output */

/*     None. */

/* $ Parameters */

/*     None. */

/* $ Files */

/*     None. */

/* $ Exceptions */

/*     1) */

/* $ Particulars */

/*     This routine accepts as inputs the name of a binary file to be */
/*     converted to text and the name of the text file to be created. */
/*     The binary file must already exist and the text file must not */
/*     exist for this routine to work correctly. The architecture and the */
/*     file type are determined and then an appropriate file conversion */
/*     is performed. */

/* $ Examples */

/*     None. */

/* $ Restrictions */

/*     1) */

/* $ Literature_References */

/*     None. */

/* $ Author_and_Institution */

/*     K.R. Gehringer (JPL) */

/* $ Version */

/* -    Beta Version 3.2.0, 30-AUG-1994 (KRG) */

/*        Improved the error diagnostics when incorrect inputs are */
/*        provided, e.g., a transfer filename instead of a binary kernel */
/*        filename. */

/* -    Beta Version 3.1.0, 12-AUG-1994 (KRG) */

/*        Fixed a minor bug that would occur when formatting a long error */
/*        message. ERRFNM was called with a logical unit that had already */
/*        been closed. */

/* -    Beta Version 3.0.0, 22-APR-1994 (KRG) */

/*        Made updates to the routine to make use of the new SPICE */
/*        capability of determining binary kernel file types at run time. */

/*        Removed the arguments for the file architecture and file type */
/*        from the calling list. This information was no longer */
/*        necessary. */

/*        Rearranged some of the code to make it easier to understand. */

/*        Added a new error: if the architecture or type are not */
/*        recognized, we can't process the file. */

/* -    Beta Version 2.0.0, 28-JAN-1994 (KRG) */

/* -& */
/* $ Index_Entries */

/*     convert binary SPICE files to text */

/* -& */

/*     SPICELIB functions */


/*     Local parameters */

/*     Begin and end markers in the file for the comment area. */


/*     File types that are recognized. */


/*     Length of a file architecture. */


/*     Maximum length for a file type. */


/*     Local variables */


/*     Standard SPICE error handling. */

    if (return_()) {
	return 0;
    } else {
	chkin_("CONVBT", (ftnlen)6);
    }

/*     Initialize the file architecture and the file type. */

    s_copy(farch, " ", (ftnlen)3, (ftnlen)1);
    s_copy(ftype, " ", (ftnlen)4, (ftnlen)1);

/*     Get the architecture and type of the binary file. */

    getfat_(binfil, farch, ftype, binfil_len, (ftnlen)3, (ftnlen)4);
    if (failed_()) {

/*        If there was an error getting the file architecture, just */
/*        return. An appropriate error message should have been set. */
/*        So, all we need to do here is return to the caller. */

	chkout_("CONVBT", (ftnlen)6);
	return 0;
    }

/*     Check to see that we got back a valid architecture and type. */


/*     Open the text file for output, obtaining a Fortran logical */
/*     unit. */

    txtopn_(txtfil, &txtlun, txtfil_len);
    if (failed_()) {

/*        If there was an error opening the text file, just return. */
/*        An appropriate error message should have been set by TXTOPN. */
/*        So, all we need to do here is return to the caller. */

	chkout_("CONVBT", (ftnlen)6);
	return 0;
    }

/*     Process the files based on their binary architectures */

    if (s_cmp(farch, "DAF", (ftnlen)3, (ftnlen)3) == 0) {

/*        If the file is a NAIF SPK, CK, or PCK binary file, it may have */
/*        a comment area. So set the COMNTS flag appropriately. */

	comnts = s_cmp(ftype, "SPK", (ftnlen)4, (ftnlen)3) == 0;
	comnts = comnts || s_cmp(ftype, "CK", (ftnlen)4, (ftnlen)2) == 0;
	comnts = comnts || s_cmp(ftype, "PCK", (ftnlen)4, (ftnlen)3) == 0;

/*        First, convert the data portion of the binary file to text. */
/*        We only support the latest and greatest text file format for */
/*        conversion of the binary files to text. */

	dafbt_(binfil, &txtlun, binfil_len);
	if (failed_()) {

/*           If an error occurred while attempting to convert the */
/*           data portion of the DAF file to text, we need to close */
/*           the text file and return to the caller. We will delete */
/*           the text file when we close it. */

	    cl__1.cerr = 0;
	    cl__1.cunit = txtlun;
	    cl__1.csta = "DELETE";
	    f_clos(&cl__1);
	    chkout_("CONVBT", (ftnlen)6);
	    return 0;
	}

/*        The DAF file may or may not have a comment area. If it is a */
/*        NAIF SPICE kernel file, then it does and we need to deal with */
/*        it. Otherwise we do nothing. */

	if (comnts) {

/*           We need to open the binary DAF file so that we can extract */
/*           the comments from its comment area and place them in the */
/*           text file. */

	    dafopr_(binfil, &handle, binfil_len);
	    if (failed_()) {

/*              If an error occurred, we need to close the text file and */
/*              return to the caller. We will delete the text file when */
/*              we close it. */

		cl__1.cerr = 0;
		cl__1.cunit = txtlun;
		cl__1.csta = "DELETE";
		f_clos(&cl__1);
		chkout_("CONVBT", (ftnlen)6);
		return 0;
	    }

/*           Write the begin comments marker to the text file. */

	    io___7.ciunit = txtlun;
	    iostat = s_wsle(&io___7);
	    if (iostat != 0) {
		goto L100001;
	    }
	    iostat = do_lio(&c__9, &c__1, "~NAIF/SPC BEGIN COMMENTS~", (
		    ftnlen)25);
	    if (iostat != 0) {
		goto L100001;
	    }
	    iostat = e_wsle();
L100001:
	    if (iostat != 0) {

/*              An error occurred, so close both the text and binary */
/*              files, set an appropriate error message, and return to */
/*              the caller. The text file is deleted when it is closed. */

		cl__1.cerr = 0;
		cl__1.cunit = txtlun;
		cl__1.csta = "DELETE";
		f_clos(&cl__1);
		dafcls_(&handle);
		setmsg_("Error writing the begin comments marker to the text"
			" file: #. IOSTAT = #.", (ftnlen)72);
		errch_("#", txtfil, (ftnlen)1, txtfil_len);
		errint_("#", &iostat, (ftnlen)1);
		sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
		chkout_("CONVBT", (ftnlen)6);
		return 0;
	    }

/*           Extract the comment area of the binary file to the text */
/*           file. */

	    spcec_(&handle, &txtlun);
	    if (failed_()) {

/*              If the comment extraction failed, then an appropriate */
/*              error message should have already been set, so close */
/*              the text and binary files and return to the caller. The */
/*              text file is deleted when it is closed. */

		cl__1.cerr = 0;
		cl__1.cunit = txtlun;
		cl__1.csta = "DELETE";
		f_clos(&cl__1);
		chkout_("CONVBT", (ftnlen)6);
		return 0;
	    }

/*           Write the end comments marker. */

	    io___8.ciunit = txtlun;
	    iostat = s_wsle(&io___8);
	    if (iostat != 0) {
		goto L100002;
	    }
	    iostat = do_lio(&c__9, &c__1, "~NAIF/SPC END COMMENTS~", (ftnlen)
		    23);
	    if (iostat != 0) {
		goto L100002;
	    }
	    iostat = e_wsle();
L100002:
	    if (iostat != 0) {

/*              An error occurred, so close both the text and binary */
/*              files, set an appropriate error message, and return to */
/*              the caller. The text file is deleted when it is closed. */

		cl__1.cerr = 0;
		cl__1.cunit = txtlun;
		cl__1.csta = "DELETE";
		f_clos(&cl__1);
		dafcls_(&handle);
		setmsg_("Error writing the end comments marker to the text f"
			"ile: #. IOSTAT = #.", (ftnlen)70);
		errch_("#", txtfil, (ftnlen)1, txtfil_len);
		errint_("#", &iostat, (ftnlen)1);
		sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
		chkout_("CONVBT", (ftnlen)6);
		return 0;
	    }

/*           Close the binary DAF file that we opened to extract the */
/*           comments. */

	    dafcls_(&handle);
	}
    } else if (s_cmp(farch, "DAS", (ftnlen)3, (ftnlen)3) == 0) {

/*        DAS files are easy. Everything is integrated into the files */
/*        so we do not need to worry about comments or reserved records */
/*        or anything. We just convert it. */

/*        Convert the data portion of the binary file to text. We */
/*        only support the latest and greatest text file format for */
/*        conversion of the binary files to text. */

	dasbt_(binfil, &txtlun, binfil_len);
	if (failed_()) {

/*           If an error occurred while attempting to convert the */
/*           DAS file to text, we need to close the text file and */
/*           return to the caller. We will delete the text file */
/*           when we close it. */

	    cl__1.cerr = 0;
	    cl__1.cunit = txtlun;
	    cl__1.csta = "DELETE";
	    f_clos(&cl__1);
	    chkout_("CONVBT", (ftnlen)6);
	    return 0;
	}
    } else if (s_cmp(farch, "XFR", (ftnlen)3, (ftnlen)3) == 0) {

/*        This is an error case, most likely caused by reading a transfer */
/*        file by accident. So signal an appropriate error. */

	cl__1.cerr = 0;
	cl__1.cunit = txtlun;
	cl__1.csta = "DELETE";
	f_clos(&cl__1);
	setmsg_("The file '#' appears to be a transfer file and not a binary"
		" kernel file.", (ftnlen)72);
	errch_("#", binfil, (ftnlen)1, binfil_len);
	sigerr_("SPICE(NOTABINARYKERNEL)", (ftnlen)23);
	chkout_("CONVBT", (ftnlen)6);
	return 0;
    } else if (s_cmp(farch, "DEC", (ftnlen)3, (ftnlen)3) == 0) {

/*        This is an error case, most likely caused by reading a transfer */
/*        file by accident. So signal an appropriate error. */

	cl__1.cerr = 0;
	cl__1.cunit = txtlun;
	cl__1.csta = "DELETE";
	f_clos(&cl__1);
	setmsg_("The file '#' appears to be a decimal transfer file and not "
		"a binary kernel file.", (ftnlen)80);
	errch_("#", binfil, (ftnlen)1, binfil_len);
	sigerr_("SPICE(NOTABINARYKERNEL)", (ftnlen)23);
	chkout_("CONVBT", (ftnlen)6);
	return 0;
    } else {

/*        This is the catch all error case. At this point, we didn't */
/*        match any of the files whose architecture and types are */
/*        recognized. So, we toss our hands in the air and signal an */
/*        error. */

	cl__1.cerr = 0;
	cl__1.cunit = txtlun;
	cl__1.csta = "DELETE";
	f_clos(&cl__1);
	setmsg_("The architecture and type of the file '#' were not recogniz"
		"ed.", (ftnlen)62);
	errch_("#", binfil, (ftnlen)1, binfil_len);
	sigerr_("SPICE(BADFILEFORMAT)", (ftnlen)20);
	chkout_("CONVBT", (ftnlen)6);
	return 0;
    }

/*     Close the text file that was created. */

    cl__1.cerr = 0;
    cl__1.cunit = txtlun;
    cl__1.csta = 0;
    f_clos(&cl__1);
    chkout_("CONVBT", (ftnlen)6);
    return 0;
} /* convbt_ */
Пример #16
0
/* Subroutine */ int neclumpn_(real *x, real *y, real *z__, real *necn, real *
	fcn, integer *hitclump)
{
    /* Initialized data */

    static logical first = TRUE_;
    static integer luclump = 11;

    /* System generated locals */
    integer i__1;
    real r__1, r__2, r__3, r__4;
    olist o__1;
    cllist cl__1;

    /* Builtin functions */
    integer f_open(olist *), s_rsle(cilist *), e_rsle(void), do_lio(integer *,
	     integer *, char *, ftnlen);
    double sin(doublereal), cos(doublereal);
    integer f_clos(cllist *);
    double exp(doublereal);

    /* Local variables */
    static integer j, clumpflag;
    static real bc[2000], dc[2000], fc[2000], lc[2000], rc[2000], xc[2000], 
	    yc[2000], zc[2000], cbc, clc, nec[2000], sbc, arg, slc;
    static integer edge[2000];
    static real rgalc;

    /* Fortran I/O blocks */
    static cilist io___4 = { 0, 0, 0, 0, 0 };
    static cilist io___5 = { 0, 0, 1, 0, 0 };


/* returns electron density necN and fluctuation parameter FcN */
/* at position designated by l,b,d,x,y,z c for a set of */
/* clumps with parameters read in from file  neclumpN.dat */
/* input: */
/* 	x,y,z	coordinates	(kpc)  (as in TC93) */

/* output: */
/* 	necN	electron density in clump at (x,y,z) */
/* 	FcN	fluctuation parameter */
/* 	hitclump = 0:   no clump hit */
/* 		   j>0: j-th clump hit */
/* 	character*15 losname(nclumpsmax) */
/* 	character*1 type(nclumpsmax) */
/* parameters: */
/* 	lc	= galactic longitude of clump center */
/* 	bc	= galactic latitude of clump center */
/* 	(xc,yc,zc) = clump center location (calculated) */
/*       nec	= internal peak electron density */
/* 	rc	= clump radius at 1/e */
/*       Fc      = clump fluctuation parameter */
/* 	edge    = 0 => use exponential rolloff out to 5rc */
/*                 1 => uniform and truncated at 1/e */
/* 	data first/.true./ */
/* 	data luclump/11/ */
/* first time through, read input clump parameters and calculate */
/* LOS quantities. */
/* lc,bc = Galactic coordinates (deg) */
/*   nec = clump electron density (cm^{-3}) */
/*    Fc = fluctuation parameter */
/*    dc = clump distance from Earth (kpc) */
/*    rc = clump radius (kpc) */
/*  edge = 0,1  0=> Gaussian, 1=> Gaussian w/ hard edge at e^{-1} */
/*  type = LOS type (P pulsar, G other Galactic, X extragalactic */
/* losname = useful name */
    if (first) {
/* read clump parameters */
	j = 1;
/* 	  write(6,*) 'reading neclumpN.NE2001.dat' */
	o__1.oerr = 0;
	o__1.ounit = luclump;
	o__1.ofnmlen = 19;
	o__1.ofnm = "neclumpN.NE2001.dat";
	o__1.orl = 0;
	o__1.osta = "old";
	o__1.oacc = 0;
	o__1.ofm = 0;
	o__1.oblnk = 0;
	f_open(&o__1);
	io___4.ciunit = luclump;
	s_rsle(&io___4);
	e_rsle();
/* label line */
L5:
	io___5.ciunit = luclump;
	i__1 = s_rsle(&io___5);
	if (i__1 != 0) {
	    goto L99;
	}
	i__1 = do_lio(&c__3, &c__1, (char *)&clumpflag, (ftnlen)sizeof(
		integer));
	if (i__1 != 0) {
	    goto L99;
	}
	i__1 = do_lio(&c__4, &c__1, (char *)&lc[j - 1], (ftnlen)sizeof(real));
	if (i__1 != 0) {
	    goto L99;
	}
	i__1 = do_lio(&c__4, &c__1, (char *)&bc[j - 1], (ftnlen)sizeof(real));
	if (i__1 != 0) {
	    goto L99;
	}
	i__1 = do_lio(&c__4, &c__1, (char *)&nec[j - 1], (ftnlen)sizeof(real))
		;
	if (i__1 != 0) {
	    goto L99;
	}
	i__1 = do_lio(&c__4, &c__1, (char *)&fc[j - 1], (ftnlen)sizeof(real));
	if (i__1 != 0) {
	    goto L99;
	}
	i__1 = do_lio(&c__4, &c__1, (char *)&dc[j - 1], (ftnlen)sizeof(real));
	if (i__1 != 0) {
	    goto L99;
	}
	i__1 = do_lio(&c__4, &c__1, (char *)&rc[j - 1], (ftnlen)sizeof(real));
	if (i__1 != 0) {
	    goto L99;
	}
	i__1 = do_lio(&c__3, &c__1, (char *)&edge[j - 1], (ftnlen)sizeof(
		integer));
	if (i__1 != 0) {
	    goto L99;
	}
	i__1 = e_rsle();
	if (i__1 != 0) {
	    goto L99;
	}
	if (clumpflag == 0) {
	    slc = sin(lc[j - 1] / 57.29577951f);
	    clc = cos(lc[j - 1] / 57.29577951f);
	    sbc = sin(bc[j - 1] / 57.29577951f);
	    cbc = cos(bc[j - 1] / 57.29577951f);
	    rgalc = dc[j - 1] * cbc;
	    xc[j - 1] = rgalc * slc;
	    yc[j - 1] = 8.5f - rgalc * clc;
	    zc[j - 1] = dc[j - 1] * sbc;
/* 	  write(6,"(a15,1x,8(f8.3,1x))") */
/*    .           losname(j),lc(j),bc(j),dc(j), */
/*    .           nec(j),Fc(j),xc(j),yc(j),zc(j) */
	    ++j;
	}
	goto L5;
L99:
	first = FALSE_;
	clumps_1.nclumps = j - 1;
	cl__1.cerr = 0;
	cl__1.cunit = luclump;
	cl__1.csta = 0;
	f_clos(&cl__1);
    }
    *necn = 0.f;
    *hitclump = 0;
    *fcn = 0.f;
    i__1 = clumps_1.nclumps;
    for (j = 1; j <= i__1; ++j) {
/* Computing 2nd power */
	r__1 = *x - xc[j - 1];
/* Computing 2nd power */
	r__2 = *y - yc[j - 1];
/* Computing 2nd power */
	r__3 = *z__ - zc[j - 1];
/* Computing 2nd power */
	r__4 = rc[j - 1];
	arg = (r__1 * r__1 + r__2 * r__2 + r__3 * r__3) / (r__4 * r__4);
	if (edge[j - 1] == 0 && arg < 5.f) {
	    *necn += nec[j - 1] * exp(-arg);
	    *fcn = fc[j - 1];
	    *hitclump = j;
	    clumps_1.hitclumpflag[j - 1] = 1;
	}
	if (edge[j - 1] == 1 && arg <= 1.f) {
/*    	    necN = necN + nec(j) * exp(-arg) */
	    *necn += nec[j - 1];
	    *fcn = fc[j - 1];
	    *hitclump = j;
	    clumps_1.hitclumpflag[j - 1] = 1;
	}
    }
    return 0;
} /* neclumpn_ */
Пример #17
0
/* $ Procedure ZZCONVTB ( Convert kernel file from text to binary ) */
/* Subroutine */ int zzconvtb_(char *txtfil, char *arch, char *type__, char *
	binfil, integer *number, ftnlen txtfil_len, ftnlen arch_len, ftnlen 
	type_len, ftnlen binfil_len)
{
    /* System generated locals */
    integer i__1;
    cilist ci__1;
    olist o__1;
    cllist cl__1;
    alist al__1;

    /* Builtin functions */
    integer s_cmp(char *, char *, ftnlen, ftnlen), f_clos(cllist *), f_back(
	    alist *), s_rsfe(cilist *), do_fio(integer *, char *, ftnlen), 
	    e_rsfe(void), f_open(olist *), s_wsfe(cilist *), e_wsfe(void);

    /* Local variables */
    char line[255];
    extern /* Subroutine */ int daftb_(integer *, char *, ftnlen), spcac_(
	    integer *, integer *, char *, char *, ftnlen, ftnlen), chkin_(
	    char *, ftnlen), dastb_(integer *, char *, ftnlen), errch_(char *,
	     char *, ftnlen, ftnlen);
    extern integer ltrim_(char *, ftnlen), rtrim_(char *, ftnlen);
    extern /* Subroutine */ int daft2b_(integer *, char *, integer *, ftnlen);
    extern logical failed_(void);
    integer handle;
    extern /* Subroutine */ int dafcls_(integer *);
    logical havcom;
    extern /* Subroutine */ int dafopw_(char *, integer *, ftnlen), sigerr_(
	    char *, ftnlen), chkout_(char *, ftnlen), getlun_(integer *), 
	    setmsg_(char *, ftnlen);
    integer iostat;
    extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
    integer scrlun;
    extern logical return_(void);
    logical eoc;

/* $ Abstract */

/*     Convert a SPICE text file into its equivalent binary format. */

/*     NOTE: This routine is currently for use ONLY with the SPACIT */
/*           utility program. Use it at your own risk. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     None. */

/* $ Keywords */

/*     FILES */

/* $ Declarations */
/* $ Brief_I/O */

/*     Variable  I/O  Description */
/*     --------  ---  -------------------------------------------------- */
/*     TXTFIL     I   Name of text file to be converted. */
/*     BINARY     I   Name of a binary file to be created. */

/* $ Detailed_Input */

/*     None. */

/* $ Detailed_Output */

/*     None. */

/* $ Parameters */

/*     None. */

/* $ Files */

/*     1)  This routine uses a Fortran scratch file to temporarily */
/*         store any lines of comments. */

/* $ Exceptions */

/*     1) If there is a problem opening or writing to the binary */
/*        file, a routine that ZZCONVTB calls diagnoses and signals */
/*        an error. */

/*     2) If there is a problem reading from the text file, the */
/*        error SPICE(FILEREADFAILED) is signalled. */

/*     3) If there is a problem opening the scratch file, the error */
/*        SPICE(FILEOPENERROR) is signalled. */

/*     4) If there is a problem writing to the scratch file, the */
/*        error SPICE(FILEWRITEFAILED) is signalled. */

/*     5) If the binary file archictecture is not recognized, the error */
/*        SPICE(UNSUPPBINARYARCH) will be signalled. */

/*     7) If the transfer file format is not recognized, the error */
/*        SPICE(NOTATRANSFERFILE) will be signalled. */

/*     8) If the input file format cannot be identified, the error */
/*        SPICE(UNRECOGNIZABLEFILE) will be signalled.. */

/* $ Particulars */

/*     This routine is currently only for use with the SPACIT program. */

/* $ Examples */



/* $ Restrictions */

/*     1)  This routine assumes that the data and comments in the */
/*         text format SPK, PCK or CK file come from a binary file */
/*         and were written by one of the SPICELIB binary to text */
/*         conversion routines. Data and/or comments written any */
/*         other way may not be in the correct format and, therefore, */
/*         may not be handled properly. */

/* $ Literature_References */

/*     None. */

/* $ Author_and_Institution */

/*     K.R. Gehringer  (JPL) */
/*     E.D. Wright     (JPL) */

/* $ Version */

/* -    Beta Version 1.0.0, 20-MAR-1999 (EDW) */

/*        This routine is a modification of the CONVTB routine. */
/*        Both have the same basic functionality, but this routine */
/*        takes the unit number of the text file opened by ZZGETFAT, */
/*        the architecture, and file type as input.  ZZCONVTB does */
/*        not open the file, ZZGETFAT performs that function. */

/* -& */
/* $ Index_Entries */

/*     convert text SPICE files to binary */

/* -& */

/*     SPICELIB functions */


/*     Local parameters */

/*     Begin and end markers in the file for the comment area. */


/*     Maximum length of an input text line. */


/*     Maximum length of a file architecture. */


/*     Maximum length of a file type. */


/*     Number of reserved records to use when creating a binar DAF file. */


/*     Local variables */


/*     Standard SPICE error handling. */

    if (return_()) {
	return 0;
    } else {
	chkin_("ZZCONVTB", (ftnlen)8);
    }

/*     Process the file based on the derived architecture and type. */

    if (s_cmp(arch, "XFR", arch_len, (ftnlen)3) == 0 && s_cmp(type__, "DAF", 
	    type_len, (ftnlen)3) == 0) {

/*        We got a DAF file. */

/*        Convert the data portion of the text file to binary. At this */
/*        point, we know that we have a current DAF text file format. */

/*        We expect to have comments. */

	havcom = TRUE_;

/*        Convert it. */

	daftb_(number, binfil, binfil_len);
	if (failed_()) {

/*           If there was an error then we need to close the */
/*           text file, and then check out and return to the */
/*           caller. */

	    cl__1.cerr = 0;
	    cl__1.cunit = *number;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    chkout_("ZZCONVTB", (ftnlen)8);
	    return 0;
	}
    } else if (s_cmp(arch, "XFR", arch_len, (ftnlen)3) == 0 && s_cmp(type__, 
	    "DAS", type_len, (ftnlen)3) == 0) {

/*        We got a DAS file. So we should begin converting it to binary. */
/*        DAS files are easier: all we do is call one routine. */

/*        We do not have comments. Actually, we might but they are */
/*        included as part of the DAS file conversion process. */

	havcom = FALSE_;

/*        Convert it. */

	dastb_(number, binfil, binfil_len);
	if (failed_()) {

/*           If there was an error then we need to close the */
/*           text file, and then check out and return to the */
/*           caller. */

	    cl__1.cerr = 0;
	    cl__1.cunit = *number;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    chkout_("ZZCONVTB", (ftnlen)8);
	    return 0;
	}
    } else if (s_cmp(arch, "DAS", arch_len, (ftnlen)3) == 0) {

/*        This is an error case, most likely caused by reading a binary */
/*        DAS file by accident. So signal an appropriate error. */

	setmsg_("The file '#' appears to be a binary DAS file and not a tran"
		"sfer file.", (ftnlen)69);
	errch_("#", txtfil, (ftnlen)1, txtfil_len);
	sigerr_("SPICE(NOTATRANSFERFILE)", (ftnlen)23);
	chkout_("ZZCONVTB", (ftnlen)8);
	return 0;
    } else if (s_cmp(arch, "DAS", arch_len, (ftnlen)3) == 0 && s_cmp(type__, 
	    "PRE", type_len, (ftnlen)3) == 0) {

/*        This is an error case, most likely caused by reading a binary */
/*        DAS file by accident. So signal an appropriate error. */

	cl__1.cerr = 0;
	cl__1.cunit = *number;
	cl__1.csta = 0;
	f_clos(&cl__1);
	setmsg_("The file '#' appears to be a pre-release binary DAS file an"
		"d not a transfer file.", (ftnlen)81);
	errch_("#", txtfil, (ftnlen)1, txtfil_len);
	sigerr_("SPICE(NOTATRANSFERFILE)", (ftnlen)23);
	chkout_("ZZCONVTB", (ftnlen)8);
	return 0;
    } else if (s_cmp(arch, "DAF", arch_len, (ftnlen)3) == 0) {

/*        This is an error case, most likely caused by reading a binary */
/*        DAF file by accident. So signal an appropriate error. */

	setmsg_("The file '#' appears to be a binary DAF file and not a tran"
		"sfer file.", (ftnlen)69);
	errch_("#", txtfil, (ftnlen)1, txtfil_len);
	sigerr_("SPICE(NOTATRANSFERFILE)", (ftnlen)23);
	chkout_("ZZCONVTB", (ftnlen)8);
	return 0;
    } else if (s_cmp(arch, "DEC", arch_len, (ftnlen)3) == 0 && s_cmp(type__, 
	    "DAF", type_len, (ftnlen)3) == 0) {

/*        This is the case for the old text file format. It has no */
/*        identifying marks whatsoever, so we simply have to try and */
/*        convert it. */

/*        We expect to have comments. */

	havcom = TRUE_;

/*        Back up one record so that we are positioned in the file where */
/*        we were when this routine was entered. */

	al__1.aerr = 0;
	al__1.aunit = *number;
	f_back(&al__1);

/*        Convert it. */

	daft2b_(number, binfil, &c__0, binfil_len);
	if (failed_()) {

/*           If there was an error then we need to close the text */
/*           file, and then check out and return to the caller. */

	    cl__1.cerr = 0;
	    cl__1.cunit = *number;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    chkout_("ZZCONVTB", (ftnlen)8);
	    return 0;
	}
    } else {

/*        This is the catch all error case. At this point, we didn't */
/*        match any of the files whose architecture and types are */
/*        recognized. So, we toss our hands in the air and signal an */
/*        error. */

	setmsg_("The architecture and type of the file '#'could not be deter"
		"mined.", (ftnlen)65);
	errch_("#", txtfil, (ftnlen)1, txtfil_len);
	sigerr_("SPICE(UNRECOGNIZABLEFILE)", (ftnlen)25);
	chkout_("ZZCONVTB", (ftnlen)8);
	return 0;
    }

/*     If we have comments to process, then process them. */

    if (havcom) {

/*        There are three situations that we need to consider here: */

/*           1) We have a SPICE text file with comments. This implies */
/*              that we have a bunch of comments to be put into the */
/*              comment area that are surrounded by the begin comments */
/*              marker, BCMARK, and the end comemnts marker, ECMARK. */

/*           2) We are at the end of the file. This means that we have */
/*              an old SPICE kernel file, from the good old days before */
/*              the comment area was implemented, or we ahve a plain old */
/*              ordinary DAF file. */

/*           3) We are not at the end of the file, but there are no */
/*              comments. This means a text DAF file may be embedded */
/*              in a larger text file or something. PDS does things like */
/*              this: SFDUs and such. */

/*        So, we need to look out for and deal with each of these */
/*        possibilities. */

	ci__1.cierr = 1;
	ci__1.ciend = 1;
	ci__1.ciunit = *number;
	ci__1.cifmt = "(A)";
	iostat = s_rsfe(&ci__1);
	if (iostat != 0) {
	    goto L100001;
	}
	iostat = do_fio(&c__1, line, (ftnlen)255);
	if (iostat != 0) {
	    goto L100001;
	}
	iostat = e_rsfe();
L100001:
	if (iostat > 0) {

/*           If there was an error then we need to close the text */
/*           file, and then check out and return to the caller. */

	    cl__1.cerr = 0;
	    cl__1.cunit = *number;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    setmsg_("Error reading the text file: #. IOSTAT = #.", (ftnlen)43)
		    ;
	    errch_("#", txtfil, (ftnlen)1, txtfil_len);
	    errint_("#", &iostat, (ftnlen)1);
	    sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
	    chkout_("ZZCONVTB", (ftnlen)8);
	    return 0;
	}

/*        If we encountered the end of the file, just check out and */
/*        return. This is not an error. */

	if (iostat < 0) {
	    chkout_("ZZCONVTB", (ftnlen)8);
	    return 0;
	}

/*        We got a line, so left justify it and see if it matches the */
/*        begin comments marker. If not, then use the Fortran BACKSPACE */
/*        command to reposition the file pointer to be ready to read the */
/*        line we just read. */

	i__1 = ltrim_(line, (ftnlen)255) - 1;
	if (s_cmp(line + i__1, "~NAIF/SPC BEGIN COMMENTS~", 255 - i__1, (
		ftnlen)25) != 0) {
	    al__1.aerr = 0;
	    al__1.aunit = *number;
	    f_back(&al__1);
	    chkout_("ZZCONVTB", (ftnlen)8);
	    return 0;
	}

/*        We're not at the end of the file, and the line we read */
/*        is BCMARK, so we write the comments to a scratch file. */
/*        We do this because we have to use SPCAC to add the comments */
/*        to the comment area of the binary file, and SPCAC rewinds */
/*        the file. It's okay for SPCAC to rewind a scratch file, since */
/*        it will probably not be very big, but it's not okay to rewind */
/*        the file connected to NUMBER -- we don't know the initial */
/*        location of the file pointer or how big the file is. */

	getlun_(&scrlun);
	o__1.oerr = 1;
	o__1.ounit = scrlun;
	o__1.ofnm = 0;
	o__1.orl = 0;
	o__1.osta = "SCRATCH";
	o__1.oacc = "SEQUENTIAL";
	o__1.ofm = "FORMATTED";
	o__1.oblnk = 0;
	iostat = f_open(&o__1);
	if (iostat != 0) {

/*           If there was an error then we need to close the text */
/*           file, and then check out and return to the caller. */

	    cl__1.cerr = 0;
	    cl__1.cunit = scrlun;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    cl__1.cerr = 0;
	    cl__1.cunit = *number;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    setmsg_("Error opening temporary file. IOSTAT = #.", (ftnlen)41);
	    errint_("#", &iostat, (ftnlen)1);
	    sigerr_("SPICE(FILEOPENERROR)", (ftnlen)20);
	    chkout_("ZZCONVTB", (ftnlen)8);
	    return 0;
	}

/*        Continue reading lines from the text file and storing them */
/*        in the scratch file until we get to the end marker. We do not */
/*        write the begin and end markers to the scratch file. We do not */
/*        need them. */

	eoc = FALSE_;
	while(! eoc) {
	    ci__1.cierr = 1;
	    ci__1.ciend = 1;
	    ci__1.ciunit = *number;
	    ci__1.cifmt = "(A)";
	    iostat = s_rsfe(&ci__1);
	    if (iostat != 0) {
		goto L100002;
	    }
	    iostat = do_fio(&c__1, line, (ftnlen)255);
	    if (iostat != 0) {
		goto L100002;
	    }
	    iostat = e_rsfe();
L100002:
	    if (iostat != 0) {

/*              If there was an error then we need to close the */
/*              scratch file, the text file, and then check out */
/*              and return to the caller. */

		cl__1.cerr = 0;
		cl__1.cunit = scrlun;
		cl__1.csta = 0;
		f_clos(&cl__1);
		cl__1.cerr = 0;
		cl__1.cunit = *number;
		cl__1.csta = 0;
		f_clos(&cl__1);
		setmsg_("Error reading the text file: #. IOSTAT = #.", (
			ftnlen)43);
		errch_("#", txtfil, (ftnlen)1, txtfil_len);
		errint_("#", &iostat, (ftnlen)1);
		sigerr_("SPICE(FILEREADFAILED)", (ftnlen)21);
		chkout_("ZZCONVTB", (ftnlen)8);
		return 0;
	    }

/*           If we are not at the end of the comments, then write the */
/*           line ot the scratch file. Otherwise set the end of comments */
/*           flag to .TRUE.. */

	    i__1 = ltrim_(line, (ftnlen)255) - 1;
	    if (s_cmp(line + i__1, "~NAIF/SPC END COMMENTS~", 255 - i__1, (
		    ftnlen)23) != 0) {
		ci__1.cierr = 1;
		ci__1.ciunit = scrlun;
		ci__1.cifmt = "(A)";
		iostat = s_wsfe(&ci__1);
		if (iostat != 0) {
		    goto L100003;
		}
		iostat = do_fio(&c__1, line, rtrim_(line, (ftnlen)255));
		if (iostat != 0) {
		    goto L100003;
		}
		iostat = e_wsfe();
L100003:
		if (iostat != 0) {

/*                 If there was an error then we need to close the */
/*                 scratch file, the text file, and then check out */
/*                 and return to the caller. */

		    cl__1.cerr = 0;
		    cl__1.cunit = scrlun;
		    cl__1.csta = 0;
		    f_clos(&cl__1);
		    cl__1.cerr = 0;
		    cl__1.cunit = *number;
		    cl__1.csta = 0;
		    f_clos(&cl__1);
		    setmsg_("Error writing to temporary file. IOSTAT = #.", (
			    ftnlen)44);
		    errint_("#", &iostat, (ftnlen)1);
		    sigerr_("SPICE(FILEWRITEFAILED)", (ftnlen)22);
		    chkout_("ZZCONVTB", (ftnlen)8);
		    return 0;
		}
	    } else {
		eoc = TRUE_;
	    }
	}

/*        Open the new binary file and add the comments that have been */
/*        stored temporarily in a scratch file. */

	dafopw_(binfil, &handle, binfil_len);
	if (failed_()) {

/*           If there was an error then we need to close the scratch */
/*           file and the text file, and then check out and return to */
/*           the caller. */

	    cl__1.cerr = 0;
	    cl__1.cunit = scrlun;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    cl__1.cerr = 0;
	    cl__1.cunit = *number;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    chkout_("ZZCONVTB", (ftnlen)8);
	    return 0;
	}
	spcac_(&handle, &scrlun, " ", " ", (ftnlen)1, (ftnlen)1);
	if (failed_()) {

/*           If there was an error then we need to close the scratch */
/*           file and the text file, and then check out and return to */
/*           the caller. */

	    cl__1.cerr = 0;
	    cl__1.cunit = scrlun;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    cl__1.cerr = 0;
	    cl__1.cunit = *number;
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    dafcls_(&handle);
	    chkout_("ZZCONVTB", (ftnlen)8);
	    return 0;
	}

/*        We succeeded, so close the files we opened to deal with the */
/*        comments. The scratch file is automatically deleted. */

	cl__1.cerr = 0;
	cl__1.cunit = scrlun;
	cl__1.csta = 0;
	f_clos(&cl__1);
	dafcls_(&handle);
    }

/*     Close the transfer file. We know it is open, because we got here. */

    cl__1.cerr = 0;
    cl__1.cunit = *number;
    cl__1.csta = 0;
    f_clos(&cl__1);
    chkout_("ZZCONVTB", (ftnlen)8);
    return 0;
} /* zzconvtb_ */
Пример #18
0
/* $Procedure      WRLINE ( Write Output Line to a Device ) */
/* Subroutine */ int wrline_0_(int n__, char *device, char *line, ftnlen 
	device_len, ftnlen line_len)
{
    /* System generated locals */
    integer i__1;
    cilist ci__1;
    olist o__1;
    cllist cl__1;
    inlist ioin__1;

    /* Builtin functions */
    integer s_cmp(char *, char *, ftnlen, ftnlen), s_wsfe(cilist *), do_fio(
	    integer *, char *, ftnlen), e_wsfe(void), f_inqu(inlist *), 
	    s_wsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 
	    e_wsle(void), f_open(olist *);
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
    integer f_clos(cllist *);

    /* Local variables */
    integer unit;
    extern /* Subroutine */ int ucase_(char *, char *, ftnlen, ftnlen);
    extern integer ltrim_(char *, ftnlen);
    char error[240];
    extern integer rtrim_(char *, ftnlen);
    extern /* Subroutine */ int ljust_(char *, char *, ftnlen, ftnlen);
    logical opened;
    extern /* Subroutine */ int fndlun_(integer *);
    char tmpnam[128];
    integer iostat;
    extern /* Subroutine */ int suffix_(char *, integer *, char *, ftnlen, 
	    ftnlen);
    logical exists;
    char errstr[11];
    extern /* Subroutine */ int intstr_(integer *, char *, ftnlen);

    /* Fortran I/O blocks */
    static cilist io___6 = { 0, 6, 0, 0, 0 };
    static cilist io___7 = { 0, 6, 0, 0, 0 };
    static cilist io___8 = { 0, 6, 0, 0, 0 };
    static cilist io___9 = { 0, 6, 0, 0, 0 };
    static cilist io___10 = { 0, 6, 0, 0, 0 };
    static cilist io___11 = { 0, 6, 0, 0, 0 };
    static cilist io___12 = { 0, 6, 0, 0, 0 };
    static cilist io___15 = { 0, 6, 0, 0, 0 };
    static cilist io___16 = { 0, 6, 0, 0, 0 };
    static cilist io___17 = { 0, 6, 0, 0, 0 };
    static cilist io___18 = { 0, 6, 0, 0, 0 };


/* $ Abstract */

/*     Write a character string to an output device. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     None. */

/* $ Keywords */

/*     TEXT */
/*     FILES */
/*     ERROR */

/* $ Declarations */
/* $ Brief_I/O */

/*     VARIABLE  I/O  DESCRIPTION */
/*     --------  ---  -------------------------------------------------- */
/*     DEVICE     I   A string specifying an output device. */
/*     LINE       I   A line of text to be output. */
/*     FILEN      P   Maximum length of a file name. */

/* $ Detailed_Input */

/*     LINE           is a line of text to be written to the output */
/*                    device specified by DEVICE. */

/*     DEVICE         is the output device to which the line of text */
/*                    will be written. */

/*                    Possible values and meanings of DEVICE are: */

/*                       a device name   This may be the name of a */
/*                                       file, or any other name that */
/*                                       is valid in a FORTRAN OPEN */
/*                                       statement.  For example, on a */
/*                                       VAX, a logical name may be */
/*                                       used. */

/*                                       The device name must not */
/*                                       be any of the reserved strings */
/*                                       below. */


/*                       'SCREEN'        The output will go to the */
/*                                       terminal screen. */


/*                       'NULL'          The data will not be output. */


/*                 'SCREEN' and 'NULL' can be written in mixed */
/*                  case.  For example, the following call will work: */

/*                  CALL WRLINE ( 'screEn', LINE ) */

/* $ Detailed_Output */

/*     None. */

/* $ Parameters */

/*     FILEN        is the maximum length of a file name. */

/* $ Exceptions */

/*     This routine is a special case as far as error handling */
/*     is concerned because it is called to output error */
/*     messages resulting from errors detected by other routines. */
/*     In such a case, calling SIGERR would constitute recursion. */
/*     Therefore, this routine prints error messages rather */
/*     than signalling errors via SIGERR and setting the long */
/*     error message via SETMSG. */

/*     The following exceptional cases are treated as errors: */

/*     1)  SPICE(NOFREELOGICALUNIT) -- No logical unit number */
/*         is available to refer to the device. */

/*     2)  SPICE(FILEOPENFAILED) -- General file open error. */

/*     3)  SPICE(FILEWRITEFAILED) -- General file write error. */

/*     4)  SPICE(INQUIREFAILED) -- INQUIRE statement failed. */

/*     5)  Leading blanks in (non-blank) file names are not */
/*         significant.  The file names */

/*             'MYFILE.DAT' */
/*             '   MYFILE.DAT' */

/*         are considered to name the same file. */

/*     6)  If different names that indicate the same file are supplied */
/*         to this routine on different calls, all output associated */
/*         with these calls WILL be written to the file.  For example, */
/*         on a system where logical filenames are supported, if */
/*         ALIAS is a logical name pointing to MYFILE, then the calls */

/*             CALL WRLINE ( 'MYFILE', 'This is the first line'  ) */
/*             CALL WRLINE ( 'ALIAS',  'This is the second line' ) */

/*         will place the lines of text */

/*              'This is the first line' */
/*              'This is the second line' */

/*         in MYFILE.  See $Restrictions for more information on use */
/*         of logical names on VAX systems. */

/* $ Files */

/*     1)  If DEVICE specifies a device other than 'SCREEN' or 'NULL', */
/*         that device is opened (if it's not already open) as a NEW, */
/*         SEQUENTIAL, FORMATTED file.  The logical unit used is */
/*         determined at run time. */

/* $ Particulars */

/*     If the output device is a file that is not open, the file will */
/*     be opened (if possible) as a NEW, sequential, formatted file, */
/*     and the line of text will be written to the file.  If the file */
/*     is already opened as a sequential, formatted file, the line of */
/*     text will be written to the file. */

/*     Use the entry point CLLINE to close files opened by WRLINE. */

/* $ Examples */

/*     1)  Write a message to the screen: */

/*                CALL WRLINE ( 'SCREEN', 'Here''s a message.' ) */

/*         The text */

/*                Here's a message. */

/*         will be written to the screen. */


/*     2)  Write out all of the elements of a character string array */
/*         to a file. */

/*                CHARACTER*(80)          STRING ( ASIZE ) */
/*                             . */
/*                             . */
/*                             . */
/*                DO I = 1, ASIZE */
/*                   CALL WRLINE ( FILE, STRING(I) ) */
/*                END DO */


/*     3)  Set DEVICE to NULL to suppress output: */

/*             C */
/*             C     Ask the user whether verbose program output is */
/*             C     desired.  Set the output device accordingly. */
/*             C */
/*                   WRITE (*,*) 'Do you want to see test results '    // */
/*                  .            'on the screen?' */
/*                   READ  (*,FMT='(A)') VERBOS */

/*                   CALL LJUST ( VERBOS, VERBOS ) */
/*                   CALL UCASE ( VERBOS, VERBOS ) */

/*                   IF ( VERBOS(1:1) .EQ. 'Y' ) THEN */
/*                      DEVICE = 'SCREEN' */
/*                   ELSE */
/*                      DEVICE = 'NULL' */
/*                   ENDIF */
/*                             . */
/*                             . */
/*                             . */
/*             C */
/*             C     Output test results. */
/*             C */
/*                   CALL WRLINE ( DEVICE, STRING ) */
/*                             . */
/*                             . */
/*                             . */

/* $ Restrictions */

/*     1)  File names must not exceed FILEN characters. */

/*     2)  On VAX systems, caution should be exercised when using */
/*         multiple logical names to point to the same file.  Logical */
/*         name translation supporting execution of the Fortran */
/*         INQUIRE statement does not appear to work reliably in all */
/*         cases, which may lead this routine to believe that different */
/*         logical names indicate different files.  The specific problem */
/*         that has been observed is that logical names that include */
/*         disk specifications are not always recognized as pointing */
/*         to the file they actually name. */

/* $ Literature_References */

/*     None. */

/* $ Author_and_Institution */

/*     N.J. Bachman    (JPL) */
/*     H.A. Neilan     (JPL) */

/* $ Version */

/* -    SPICELIB Version 4.25.0, 10-MAR-2014 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-INTEL. */

/* -    SPICELIB Version 4.24.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-LINUX-64BIT-IFORT. */

/* -    SPICELIB Version 4.23.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-GFORTRAN. */

/* -    SPICELIB Version 4.22.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-64BIT-GFORTRAN. */

/* -    SPICELIB Version 4.21.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-64BIT-GCC_C. */

/* -    SPICELIB Version 4.20.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL. */

/* -    SPICELIB Version 4.19.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL-CC_C. */

/* -    SPICELIB Version 4.18.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL-64BIT-CC_C. */

/* -    SPICELIB Version 4.17.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-NATIVE_C. */

/* -    SPICELIB Version 4.16.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-WINDOWS-64BIT-IFORT. */

/* -    SPICELIB Version 4.15.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-LINUX-64BIT-GFORTRAN. */

/* -    SPICELIB Version 4.14.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-64BIT-MS_C. */

/* -    SPICELIB Version 4.13.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-INTEL_C. */

/* -    SPICELIB Version 4.12.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-IFORT. */

/* -    SPICELIB Version 4.11.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-GFORTRAN. */

/* -    SPICELIB Version 4.10.0, 18-MAR-2009 (BVS) */

/*        Updated for PC-LINUX-GFORTRAN. */

/* -    SPICELIB Version 4.9.0, 18-MAR-2009 (BVS) */

/*        Updated for MAC-OSX-GFORTRAN. */

/* -    SPICELIB Version 4.8.0, 19-FEB-2008 (BVS) */

/*        Updated for PC-LINUX-IFORT. */

/* -    SPICELIB Version 4.7.0, 14-NOV-2006 (BVS) */

/*        Updated for PC-LINUX-64BIT-GCC_C. */

/* -    SPICELIB Version 4.6.0, 14-NOV-2006 (BVS) */

/*        Updated for MAC-OSX-INTEL_C. */

/* -    SPICELIB Version 4.5.0, 14-NOV-2006 (BVS) */

/*        Updated for MAC-OSX-IFORT. */

/* -    SPICELIB Version 4.4.0, 14-NOV-2006 (BVS) */

/*        Updated for PC-WINDOWS-IFORT. */

/* -    SPICELIB Version 4.3.0, 26-OCT-2005 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-GCC_C. */

/* -    SPICELIB Version 4.2.0, 03-JAN-2005 (BVS) */

/*        Updated for PC-CYGWIN_C. */

/* -    SPICELIB Version 4.1.0, 03-JAN-2005 (BVS) */

/*        Updated for PC-CYGWIN. */

/* -    SPICELIB Version 4.0.5, 17-JUL-2002 (BVS) */

/*        Added MAC-OSX environments. */

/* -    SPICELIB Version 4.0.4, 08-OCT-1999 (WLT) */

/*        The environment lines were expanded so that the supported */
/*        environments are now explicitely given.  New */
/*        environments are WIN-NT */

/* -    SPICELIB Version 4.0.3, 16-SEP-1999 (NJB) */

/*        CSPICE environments were added.  Some typos were corrected. */

/* -    SPICELIB Version 4.0.2, 28-JUL-1999 (WLT) */

/*        The environment lines were expanded so that the supported */
/*        environments are now explicitly given.  New */
/*        environments are PC-DIGITAL, SGI-O32 and SGI-N32. */

/* -    SPICELIB Version 4.0.1, 18-MAR-1999 (WLT) */

/*        The environment lines were expanded so that the supported */
/*        environments are now explicitly given.  Previously, */
/*        environments such as SUN-SUNOS and SUN-SOLARIS were implied */
/*        by the environment label SUN. */

/* -    SPICELIB Version 4.0.0, 07-APR-1998 (NJB) */

/*        References to the PC-LINUX environment were added.  The */
/*        write format for the case where the output device is the */
/*        screen has been made system-dependent; list-directed output */
/*        format is now used for systems that require a leading carriage */
/*        control character; other systems use character format. The */
/*        write format for the case where the output device is a file */
/*        has been changed from list-directed to character. */


/* -    SPICELIB Version 3.0.0, 11-NOV-1993 (HAN) */

/*        Module was updated to include the value for FILEN */
/*        and the appropriate OPEN statement for the Silicon */
/*        Graphics, DEC Alpha-OSF/1, and NeXT platforms. The previous */
/*        value of 256 for Unix platforms was changed to 255. */

/* -    SPICELIB Version 2.1.0, 13-OCT-1992 (HAN) */

/*       Module was updated to include the value of FILEN for the */
/*       Hewlett Packard UX 9000/750 environment. */

/*       The code was also reformatted so that a utility program can */
/*       create the source file for a specific environment given a */
/*       master source file. */

/* -    SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */

/*       Comment section for permuted index source lines was added */
/*       following the header. */

/* -    SPICELIB Version 2.0.0, 26-MAR-1991 (NJB) */

/*       This routine now can write to files that have been opened */
/*       by other routines. */

/*       The limit imposed by this routine on the number of files it */
/*       can open has been removed. */

/*       The output file is now opened as a normal text file on */
/*       VAX systems. */

/*       Improper treatment of the case where DEVICE is blank was */
/*       remedied. */

/*       Unneeded variable declarations and references were removed. */

/*       Initialization of SAVED variables was added. */

/*       All occurrences of "PRINT *" have been replaced by */
/*       "WRITE (*,*)". */

/*       Calls to UCASE and LJUST replace in-line code that performed */
/*       these operations. */

/* -    SPICELIB Version 1.0.0, 31-JAN-1990 (NJB) */

/* -& */
/* $ Index_Entries */

/*     write output line to a device */

/* -& */
/* $ Revisions */

/* -    SPICELIB Version 4.0.0, 07-APR-1998 (NJB) */

/*        References to the PC-LINUX environment were added. */

/*        The write format for the case where the output device is the */
/*        screen has been made system-dependent; list-directed output */
/*        format is now used for systems that require a leading carriage */
/*        control character; other systems use character format. The */
/*        write format for the case where the output device is a file */
/*        has been changed from list-directed to character. */

/* -    SPICELIB Version 3.0.0, 11-NOV-1993 (HAN) */

/*         Module was updated to include the value for FILEN */
/*         and the appropriate OPEN statement for the Silicon */
/*         Graphics, DEC Alpha-OSF/1, and NeXT platforms. The previous */
/*         value of 256 for Unix platforms was changed to 255. */

/* -     SPICELIB Version 2.1.0, 13-OCT-1992 (HAN) */

/*        Module was updated to include the value of FILEN for the */
/*        Hewlett Packard UX 9000/750 environment. */

/*        The code was also reformatted so that a utility program can */
/*        create the source file for a specific environment given a */
/*        master source file. */

/* -    SPICELIB Version 2.0.0, 25-MAR-1991 (NJB) */

/*        1)  This routine now can write to files that have been opened */
/*            by other routines.  WRLINE uses an INQUIRE statement to */
/*            determine whether the file indicated by DEVICE is open, */
/*            and if it is, WRLINE does not attempt to open it.  This */
/*            allows use of WRLINE to feed error output into a log file */
/*            opened by another routine. */

/*            The header has been updated accordingly. */

/*            This fix also fixes a bug wherein this routine would treat */
/*            different character strings naming the same file as though */
/*            they indicated different files. */

/*        2)  The limit imposed by this routine on the number of files it */
/*            can open has been removed.  The file database used in */
/*            previous versions of this routine is no longer used. */

/*        3)  On VAX systems, this routine now opens the output file */
/*            (when required to do so) as a normal text file. */

/*        4)  Improper treatment of the case where DEVICE is blank was */
/*            remedied.  Any value of DEVICE that is not equal to */
/*            'SCREEN' or 'NULL' after being left-justified and */
/*            converted to upper case is considered to be a file name. */

/*        5)  Unneeded variable declarations and references were removed. */
/*            The arrays called STATUS and FILES are not needed. */

/*        6)  All instances if "PRINT *" have been replaced by */
/*            "WRITE (*,*)" because Language Systems Fortran on the */
/*            Macintosh interprets "PRINT *" in a non-standard manner. */

/*        7)  Use of the EXIST specifier was added to the INQUIRE */
/*            statement used to determine whether the file named by */
/*            DEVICE is open.  This is a work-around for a rather */
/*            peculiar behavior of at least one version of Sun Fortran: */
/*            files that don't exist may be considered to be open, as */
/*            indicated by the OPENED specifier of the INQUIRE statement. */

/*        8)  One other thing:  now that LJUST and UCASE are error-free, */
/*            WRLINE uses them; this simplifies the code. */


/* -    Beta Version 1.2.0, 27-FEB-1989 (NJB) */

/*        Call to GETLUN replaced by call to FNDLUN, which is error-free. */
/*        Call to IOERR replaced with in-line code to construct long */
/*        error message indicating file open failure. Arrangement of */
/*        declarations changed.  Keywords added. FILEN declaration */
/*        moved to "declarations" section.  Parameters section added. */

/* -    Beta Version 1.1.0, 06-OCT-1988 (NJB) */

/*        Upper bound of written substring changed to prevent use of */
/*        invalid substring bound.  Specifically, LASTNB ( LINE ) was */
/*        replaced by  MAX ( 1, LASTNB (LINE) ).  This upper bound */
/*        now used in the PRINT statement as well. */

/* -& */

/*     SPICELIB functions */


/*     Local variables */


/*     Executable Code: */

    switch(n__) {
	case 1: goto L_clline;
	}

    ljust_(device, tmpnam, device_len, (ftnlen)128);
    ucase_(tmpnam, tmpnam, (ftnlen)128, (ftnlen)128);

/*     TMPNAM is now left justified and is in upper case. */

    if (s_cmp(tmpnam, "NULL", (ftnlen)128, (ftnlen)4) == 0) {
	return 0;
    } else if (s_cmp(tmpnam, "SCREEN", (ftnlen)128, (ftnlen)6) == 0) {
	ci__1.cierr = 1;
	ci__1.ciunit = 6;
	ci__1.cifmt = "(A)";
	iostat = s_wsfe(&ci__1);
	if (iostat != 0) {
	    goto L100001;
	}
	iostat = do_fio(&c__1, line, rtrim_(line, line_len));
	if (iostat != 0) {
	    goto L100001;
	}
	iostat = e_wsfe();
L100001:
	return 0;
    }

/*     Find out whether we'll need to open the file. */

/*     We use the EXIST inquiry specifier because files that don't exist */
/*     may be (possibly due to a Sun compiler bug) deemed to be OPEN by */
/*     Sun Fortran. */

    i__1 = ltrim_(device, device_len) - 1;
    ioin__1.inerr = 1;
    ioin__1.infilen = device_len - i__1;
    ioin__1.infile = device + i__1;
    ioin__1.inex = &exists;
    ioin__1.inopen = &opened;
    ioin__1.innum = &unit;
    ioin__1.innamed = 0;
    ioin__1.inname = 0;
    ioin__1.inacc = 0;
    ioin__1.inseq = 0;
    ioin__1.indir = 0;
    ioin__1.infmt = 0;
    ioin__1.inform = 0;
    ioin__1.inunf = 0;
    ioin__1.inrecl = 0;
    ioin__1.innrec = 0;
    ioin__1.inblank = 0;
    iostat = f_inqu(&ioin__1);
    if (iostat != 0) {

/*        This is weird.  How can an INQUIRE statement fail, */
/*        if the syntax is correct?  But just in case... */

	s_wsle(&io___6);
	do_lio(&c__9, &c__1, "SPICE(INQUIREFAILED)", (ftnlen)20);
	e_wsle();
	s_wsle(&io___7);
	do_lio(&c__9, &c__1, "WRLINE: File = ", (ftnlen)15);
	do_lio(&c__9, &c__1, device, device_len);
	do_lio(&c__9, &c__1, "IOSTAT = ", (ftnlen)9);
	do_lio(&c__3, &c__1, (char *)&iostat, (ftnlen)sizeof(integer));
	e_wsle();
	return 0;
    }
    if (! (opened && exists)) {

/*        We will need a free logical unit.  There is always the chance */
/*        that no units are available. */

	fndlun_(&unit);
	if (unit < 1) {
	    s_wsle(&io___8);
	    do_lio(&c__9, &c__1, "SPICE(NOFREELOGICALUNIT)", (ftnlen)24);
	    e_wsle();
	    s_wsle(&io___9);
	    do_lio(&c__9, &c__1, " ", (ftnlen)1);
	    e_wsle();
	    s_wsle(&io___10);
	    do_lio(&c__9, &c__1, "WRLINE: Maximum number of logical units th"
		    "at can be allocated by SPICELIB has already been reached",
		     (ftnlen)98);
	    e_wsle();
	    return 0;
	}

/*        Okay, we have a unit. Open the file, and hope nothing */
/*        goes awry. (On the VAX, the qualifier */

/*           CARRIAGECONTROL = 'LIST' */

/*        may be inserted into the OPEN statement.) */

	i__1 = ltrim_(device, device_len) - 1;
	o__1.oerr = 1;
	o__1.ounit = unit;
	o__1.ofnmlen = device_len - i__1;
	o__1.ofnm = device + i__1;
	o__1.orl = 0;
	o__1.osta = "NEW";
	o__1.oacc = 0;
	o__1.ofm = 0;
	o__1.oblnk = 0;
	iostat = f_open(&o__1);
	if (iostat != 0) {
	    s_wsle(&io___11);
	    do_lio(&c__9, &c__1, "SPICE(FILEOPENFAILED)", (ftnlen)21);
	    e_wsle();
	    s_wsle(&io___12);
	    do_lio(&c__9, &c__1, " ", (ftnlen)1);
	    e_wsle();
	    s_copy(error, "WRLINE: An error occurred while attempting to open"
		    , (ftnlen)240, (ftnlen)50);
	    suffix_(device, &c__1, error, device_len, (ftnlen)240);
	    suffix_(".", &c__0, error, (ftnlen)1, (ftnlen)240);
	    suffix_("The value of IOSTAT returned was", &c__2, error, (ftnlen)
		    32, (ftnlen)240);
	    suffix_(":", &c__0, error, (ftnlen)1, (ftnlen)240);
	    intstr_(&iostat, errstr, (ftnlen)11);
	    suffix_(errstr, &c__1, error, (ftnlen)11, (ftnlen)240);
	    suffix_(".", &c__0, error, (ftnlen)1, (ftnlen)240);
	    s_wsle(&io___15);
	    do_lio(&c__9, &c__1, error, (ftnlen)240);
	    e_wsle();
	    return 0;
	}

/*        Whew! We're ready to write to this file. */

    }

/*     At this point, either we opened the file, or it was already */
/*     opened by somebody else. */

/*     This is the easy part. Write the next line to the file. */

    ci__1.cierr = 1;
    ci__1.ciunit = unit;
    ci__1.cifmt = "(A)";
    iostat = s_wsfe(&ci__1);
    if (iostat != 0) {
	goto L100002;
    }
    iostat = do_fio(&c__1, line, rtrim_(line, line_len));
    if (iostat != 0) {
	goto L100002;
    }
    iostat = e_wsfe();
L100002:

/*     Well, what happened? Any non-zero value for IOSTAT indicates */
/*     an error. */

    if (iostat != 0) {
	s_copy(error, "WRLINE: An error occurred while attempting to WRITE t"
		"o ", (ftnlen)240, (ftnlen)55);
	suffix_(device, &c__1, error, device_len, (ftnlen)240);
	suffix_(".", &c__0, error, (ftnlen)1, (ftnlen)240);
	suffix_("The value of IOSTAT returned was", &c__2, error, (ftnlen)32, 
		(ftnlen)240);
	suffix_(":", &c__0, error, (ftnlen)1, (ftnlen)240);
	intstr_(&iostat, errstr, (ftnlen)11);
	suffix_(errstr, &c__1, error, (ftnlen)11, (ftnlen)240);
	suffix_(".", &c__0, error, (ftnlen)1, (ftnlen)240);
	s_wsle(&io___16);
	do_lio(&c__9, &c__1, error, (ftnlen)240);
	e_wsle();
	return 0;
    }
    return 0;
/* $Procedure  CLLINE ( Close a device ) */

L_clline:
/* $ Abstract */

/*      Close a device. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*      None. */

/* $ Keywords */

/*      TEXT, FILES, ERROR */

/* $ Declarations */

/*      CHARACTER*(*)        DEVICE */

/* $ Brief_I/O */

/*      VARIABLE  I/O  DESCRIPTION */
/*      --------  ---  -------------------------------------------------- */
/*      DEVICE     I   Device to be closed. */

/* $ Detailed_Input */

/*      DEVICE         is the name of a device which is currently */
/*                     opened for reading or writing. */

/* $ Detailed_Output */

/*      None. */

/* $ Parameters */

/*      None. */

/* $ Exceptions */

/*      This routine is called by SPICELIB error handling routines, so */
/*      it cannot use the normal SPICELIB error signalling mechanism. */
/*      Instead, it writes error messages to the screen if necessary. */

/*      1)  If the device indicated by DEVICE was not opened by WRLINE, */
/*          this routine closes it anyway. */

/*      2)  If the INQUIRE performed by this routine fails, an error */
/*          diagnosis is printed to the screen. */

/* $ Files */

/*      This routin */

/* $ Particulars */

/*      CLLINE closes a device that is currently open. */

/* $ Examples */

/*      1)  Write two lines to the file, SPUD.DAT (VAX file name */
/*          syntax), and then close the file. */

/*          CALL WRLINE ( 'SPUD.DAT', ' This is line 1 ' ) */
/*          CALL WRLINE ( 'SPUD.DAT', ' This is line 2 ' ) */
/*          CALL CLLINE ( 'SPUD.DAT' ) */

/* $ Restrictions */

/*      None. */

/* $ Literature_References */

/*      None. */

/* $ Author_and_Institution */

/*      N.J. Bachman    (JPL) */

/* $ Version */

/* -    SPICELIB Version 4.0.5, 17-JUL-2002 (BVS) */

/*        Added MAC-OSX environments. */

/* -    SPICELIB Version 4.0.4, 08-OCT-1999 (WLT) */

/*        The environment lines were expanded so that the supported */
/*        environments are now explicitely given.  New */
/*        environments are WIN-NT */

/* -    SPICELIB Version 4.0.2, 28-JUL-1999 (WLT) */

/*        The environment lines were expanded so that the supported */
/*        environments are now explicitly given.  New */
/*        environments are PC-DIGITAL, SGI-O32 and SGI-N32. */

/* -    SPICELIB Version 4.0.1, 18-MAR-1999 (WLT) */

/*        The environment lines were expanded so that the supported */
/*        environments are now explicitly given.  Previously, */
/*        environments such as SUN-SUNOS and SUN-SOLARIS were implied */
/*        by the environment label SUN. */

/* -    SPICELIB Version 2.0.1, 10-MAR-1992 (WLT) */

/*        Comment section for permuted index source lines was added */
/*        following the header. */

/* -    SPICELIB Version 2.0.0, 26-MAR-1991 (NJB) */

/*        All occurrences of "PRINT *" have been replaced by */
/*        "WRITE (*,*)". */

/*        Also, this routine now closes the device named by DEVICE */
/*        whether or not the device was opened by WRLINE. */

/* -    SPICELIB Version 1.0.0, 31-JAN-1990 (NJB) */

/* -& */
/* $ Index_Entries */

/*     None. */

/* -& */
/* $ Revisions */

/* -    SPICELIB Version 2.0.0, 26-MAR-1991 (NJB) */

/*        All instances if "PRINT *" have been replaced by "WRITE (*,*)" */
/*        because Language Systems Fortran on the Macintosh interprets */
/*        "PRINT *" in a non-standard manner. */

/*        This routine no longer has to maintain the file database, since */
/*        WRLINE does not use it any more. */

/*        Also, this routine now closes the device named by DEVICE, */
/*        whether or not the device was opened by WRLINE. */

/* -    Beta Version 1.0.1, 08-NOV-1988 (NJB) */

/*        Keywords added. */
/* -& */

/*     Find the unit connected to DEVICE. */

    i__1 = ltrim_(device, device_len) - 1;
    ioin__1.inerr = 1;
    ioin__1.infilen = device_len - i__1;
    ioin__1.infile = device + i__1;
    ioin__1.inex = 0;
    ioin__1.inopen = 0;
    ioin__1.innum = &unit;
    ioin__1.innamed = 0;
    ioin__1.inname = 0;
    ioin__1.inacc = 0;
    ioin__1.inseq = 0;
    ioin__1.indir = 0;
    ioin__1.infmt = 0;
    ioin__1.inform = 0;
    ioin__1.inunf = 0;
    ioin__1.inrecl = 0;
    ioin__1.innrec = 0;
    ioin__1.inblank = 0;
    iostat = f_inqu(&ioin__1);
    if (iostat != 0) {

/*        This is weird.  How can an INQUIRE statement fail, */
/*        if the syntax is correct?  But just in case... */

	s_wsle(&io___17);
	do_lio(&c__9, &c__1, "SPICE(INQUIREFAILED)", (ftnlen)20);
	e_wsle();
	s_wsle(&io___18);
	do_lio(&c__9, &c__1, "CLLINE:  File = ", (ftnlen)16);
	do_lio(&c__9, &c__1, device, device_len);
	do_lio(&c__9, &c__1, "IOSTAT = ", (ftnlen)9);
	do_lio(&c__3, &c__1, (char *)&iostat, (ftnlen)sizeof(integer));
	e_wsle();
	return 0;
    }
    cl__1.cerr = 0;
    cl__1.cunit = unit;
    cl__1.csta = 0;
    f_clos(&cl__1);
    return 0;
} /* wrline_ */
Пример #19
0
/* Main program */ int MAIN__(void)
{
    /* Initialized data */

    static doublereal threq = 2.;
    static char intstr[10] = "0123456789";

    /* Format strings */
    static char fmt_9994[] = "(\002 Tests of the COMPLEX*16 LAPACK routines"
	    " \002,/\002 LAPACK VERSION \002,i1,\002.\002,i1,\002.\002,i1,/"
	    "/\002 The following parameter values will be used:\002)";
    static char fmt_9996[] = "(\002 Invalid input value: \002,a4,\002=\002,i"
	    "6,\002; must be >=\002,i6)";
    static char fmt_9995[] = "(\002 Invalid input value: \002,a4,\002=\002,i"
	    "6,\002; must be <=\002,i6)";
    static char fmt_9993[] = "(4x,a4,\002:  \002,10i6,/11x,10i6)";
    static char fmt_9992[] = "(/\002 Routines pass computational tests if te"
	    "st ratio is \002,\002less than\002,f8.2,/)";
    static char fmt_9999[] = "(/\002 Execution not attempted due to input er"
	    "rors\002)";
    static char fmt_9991[] = "(\002 Relative machine \002,a,\002 is taken to"
	    " be\002,d16.6)";
    static char fmt_9990[] = "(/1x,a3,\002:  Unrecognized path name\002)";
    static char fmt_9989[] = "(/1x,a3,\002 routines were not tested\002)";
    static char fmt_9988[] = "(/1x,a3,\002 driver routines were not teste"
	    "d\002)";
    static char fmt_9998[] = "(/\002 End of tests\002)";
    static char fmt_9997[] = "(\002 Total time used = \002,f12.2,\002 seco"
	    "nds\002,/)";

    /* System generated locals */
    integer i__1, i__2;
    doublereal d__1;
    cilist ci__1;
    cllist cl__1;

    /* Builtin functions */
    integer s_rsle(cilist *), e_rsle(void), s_wsfe(cilist *), do_fio(integer *
	    , char *, ftnlen), e_wsfe(void), do_lio(integer *, integer *, 
	    char *, ftnlen);
    /* Subroutine */ int s_stop(char *, ftnlen);
    integer s_wsle(cilist *), e_wsle(void), s_rsfe(cilist *), e_rsfe(void);
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
    integer f_clos(cllist *);

    /* Local variables */
    doublecomplex a[153384]	/* was [21912][7] */, b[8448]	/* was [2112][
	    4] */;
    integer i__, j, k;
    doublereal s[264];
    char c1[1], c2[2];
    doublereal s1, s2;
    integer ic, la, nb, nm, nn, vers_patch__, vers_major__, vers_minor__, lda,
	     nnb;
    doublereal eps;
    integer nns, nnb2;
    char path[3];
    integer mval[12], nval[12], nrhs;
    doublecomplex work[20856]	/* was [132][158] */;
    integer lafac;
    logical fatal;
    char aline[72];
    extern logical lsame_(char *, char *);
    integer nbval[12], nmats, nsval[12], nxval[12], iwork[3300];
    doublereal rwork[19832];
    integer nbval2[12];
    extern /* Subroutine */ int zchkq3_(logical *, integer *, integer *, 
	    integer *, integer *, integer *, integer *, integer *, doublereal 
	    *, doublecomplex *, doublecomplex *, doublereal *, doublereal *, 
	    doublecomplex *, doublecomplex *, doublereal *, integer *, 
	    integer *);
    extern doublereal dlamch_(char *), dsecnd_(void);
    extern /* Subroutine */ int alareq_(char *, integer *, logical *, integer 
	    *, integer *, integer *), zchkgb_(logical *, integer *, 
	    integer *, integer *, integer *, integer *, integer *, integer *, 
	    integer *, doublereal *, logical *, doublecomplex *, integer *, 
	    doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublereal *, integer *, 
	    integer *), zchkge_(logical *, integer *, integer *, integer *, 
	    integer *, integer *, integer *, integer *, integer *, doublereal 
	    *, logical *, integer *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublereal *, integer *, integer *), zchkhe_(
	    logical *, integer *, integer *, integer *, integer *, integer *, 
	    integer *, doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublereal *, integer *, 
	    integer *);
    extern logical lsamen_(integer *, char *, char *);
    extern /* Subroutine */ int zchkpb_(logical *, integer *, integer *, 
	    integer *, integer *, integer *, integer *, doublereal *, logical 
	    *, integer *, doublecomplex *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublereal *, integer *), ilaver_(integer *, integer *, integer 
	    *), zchkeq_(doublereal *, integer *), zchktb_(logical *, integer *
, integer *, integer *, integer *, doublereal *, logical *, 
	    integer *, doublecomplex *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublereal *, 
	    integer *), zchkhp_(logical *, integer *, integer *, integer *, 
	    integer *, doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublereal *, integer *, 
	    integer *), zchkgt_(logical *, integer *, integer *, integer *, 
	    integer *, doublereal *, logical *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublereal *, integer *, integer *), zchklq_(
	    logical *, integer *, integer *, integer *, integer *, integer *, 
	    integer *, integer *, integer *, doublereal *, logical *, integer 
	    *, doublecomplex *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublecomplex *, doublereal *, 
	     integer *, integer *);
    doublereal thresh;
    extern /* Subroutine */ int zchkpo_(logical *, integer *, integer *, 
	    integer *, integer *, integer *, integer *, doublereal *, logical 
	    *, integer *, doublecomplex *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublereal *, integer *), zchkpp_(logical *, integer *, integer 
	    *, integer *, integer *, doublereal *, logical *, integer *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublecomplex *, doublereal *, 
	     integer *);
    logical tstchk;
    extern /* Subroutine */ int zchkql_(logical *, integer *, integer *, 
	    integer *, integer *, integer *, integer *, integer *, integer *, 
	    doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublereal *, integer *, 
	    integer *), zchkpt_(logical *, integer *, integer *, integer *, 
	    integer *, doublereal *, logical *, doublecomplex *, doublereal *, 
	     doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex 
	    *, doublecomplex *, doublereal *, integer *);
    logical dotype[30];
    extern /* Subroutine */ int zchkqp_(logical *, integer *, integer *, 
	    integer *, integer *, doublereal *, logical *, doublecomplex *, 
	    doublecomplex *, doublereal *, doublereal *, doublecomplex *, 
	    doublecomplex *, doublereal *, integer *, integer *), zchkqr_(
	    logical *, integer *, integer *, integer *, integer *, integer *, 
	    integer *, integer *, integer *, doublereal *, logical *, integer 
	    *, doublecomplex *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublecomplex *, doublereal *, 
	     integer *, integer *), zchkrq_(logical *, integer *, integer *, 
	    integer *, integer *, integer *, integer *, integer *, integer *, 
	    doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublereal *, integer *, 
	    integer *), zchksp_(logical *, integer *, integer *, integer *, 
	    integer *, doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublereal *, integer *, 
	    integer *), zchktp_(logical *, integer *, integer *, integer *, 
	    integer *, doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublereal *, integer *), zchktr_(logical *, 
	    integer *, integer *, integer *, integer *, integer *, integer *, 
	    doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublereal *, integer *), zchksy_(logical *, 
	    integer *, integer *, integer *, integer *, integer *, integer *, 
	    doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublereal *, integer *, 
	    integer *), zdrvgb_(logical *, integer *, integer *, integer *, 
	    doublereal *, logical *, doublecomplex *, integer *, 
	    doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublereal *, 
	    doublecomplex *, doublereal *, integer *, integer *), zchktz_(
	    logical *, integer *, integer *, integer *, integer *, doublereal 
	    *, logical *, doublecomplex *, doublecomplex *, doublereal *, 
	    doublereal *, doublecomplex *, doublecomplex *, doublereal *, 
	    integer *), zdrvge_(logical *, integer *, integer *, integer *, 
	    doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublereal *, doublecomplex *, 
	     doublereal *, integer *, integer *), zdrvhe_(logical *, integer *
, integer *, integer *, doublereal *, logical *, integer *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublecomplex *, doublereal *, 
	     integer *, integer *), zdrvgt_(logical *, integer *, integer *, 
	    integer *, doublereal *, logical *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublereal *, integer *, integer *), zdrvhp_(
	    logical *, integer *, integer *, integer *, doublereal *, logical 
	    *, integer *, doublecomplex *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublereal *, integer *, integer *);
    integer ntypes;
    logical tsterr;
    extern /* Subroutine */ int zdrvls_(logical *, integer *, integer *, 
	    integer *, integer *, integer *, integer *, integer *, integer *, 
	    integer *, doublereal *, logical *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublereal *, doublereal *, doublecomplex *, doublereal *, 
	    integer *, integer *);
    logical tstdrv;
    extern /* Subroutine */ int zdrvpb_(logical *, integer *, integer *, 
	    integer *, doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublereal *, doublecomplex *, 
	     doublereal *, integer *), zdrvpo_(logical *, integer *, integer *
, integer *, doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublereal *, doublecomplex *, 
	     doublereal *, integer *), zdrvpp_(logical *, integer *, integer *
, integer *, doublereal *, logical *, integer *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublecomplex *, doublereal *, doublecomplex *, 
	     doublereal *, integer *), zdrvpt_(logical *, integer *, integer *
, integer *, doublereal *, logical *, doublecomplex *, doublereal 
	    *, doublecomplex *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublereal *, integer *), 
	    zdrvsp_(logical *, integer *, integer *, integer *, doublereal *, 
	    logical *, integer *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublecomplex *, doublereal *, integer *, integer *), zdrvsy_(
	    logical *, integer *, integer *, integer *, doublereal *, logical 
	    *, integer *, doublecomplex *, doublecomplex *, doublecomplex *, 
	    doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
, doublereal *, integer *, integer *);

    /* Fortran I/O blocks */
    static cilist io___6 = { 0, 5, 0, 0, 0 };
    static cilist io___10 = { 0, 6, 0, fmt_9994, 0 };
    static cilist io___11 = { 0, 5, 0, 0, 0 };
    static cilist io___13 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___14 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___15 = { 0, 5, 0, 0, 0 };
    static cilist io___18 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___19 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___20 = { 0, 6, 0, fmt_9993, 0 };
    static cilist io___21 = { 0, 5, 0, 0, 0 };
    static cilist io___23 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___24 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___25 = { 0, 5, 0, 0, 0 };
    static cilist io___27 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___28 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___29 = { 0, 6, 0, fmt_9993, 0 };
    static cilist io___30 = { 0, 5, 0, 0, 0 };
    static cilist io___32 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___33 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___34 = { 0, 5, 0, 0, 0 };
    static cilist io___36 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___37 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___38 = { 0, 6, 0, fmt_9993, 0 };
    static cilist io___39 = { 0, 5, 0, 0, 0 };
    static cilist io___41 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___42 = { 0, 6, 0, fmt_9995, 0 };
    static cilist io___43 = { 0, 5, 0, 0, 0 };
    static cilist io___45 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___46 = { 0, 6, 0, fmt_9993, 0 };
    static cilist io___51 = { 0, 5, 0, 0, 0 };
    static cilist io___53 = { 0, 6, 0, fmt_9996, 0 };
    static cilist io___54 = { 0, 6, 0, fmt_9993, 0 };
    static cilist io___55 = { 0, 5, 0, 0, 0 };
    static cilist io___57 = { 0, 6, 0, fmt_9992, 0 };
    static cilist io___58 = { 0, 5, 0, 0, 0 };
    static cilist io___60 = { 0, 5, 0, 0, 0 };
    static cilist io___62 = { 0, 5, 0, 0, 0 };
    static cilist io___64 = { 0, 6, 0, fmt_9999, 0 };
    static cilist io___66 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___67 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___68 = { 0, 6, 0, fmt_9991, 0 };
    static cilist io___69 = { 0, 6, 0, 0, 0 };
    static cilist io___78 = { 0, 6, 0, fmt_9990, 0 };
    static cilist io___79 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___87 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___89 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___92 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___93 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___94 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___95 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___96 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___97 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___98 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___99 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___100 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___101 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___102 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___103 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___104 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___105 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___106 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___107 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___108 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___109 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___110 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___111 = { 0, 6, 0, fmt_9988, 0 };
    static cilist io___112 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___113 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___114 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___115 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___116 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___117 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___118 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___119 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___120 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___121 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___122 = { 0, 6, 0, fmt_9989, 0 };
    static cilist io___123 = { 0, 6, 0, fmt_9990, 0 };
    static cilist io___125 = { 0, 6, 0, fmt_9998, 0 };
    static cilist io___126 = { 0, 6, 0, fmt_9997, 0 };



/*  -- LAPACK test routine (version 3.1.1) -- */
/*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
/*     January 2007 */

/*  Purpose */
/*  ======= */

/*  ZCHKAA is the main test program for the COMPLEX*16 linear equation */
/*  routines. */

/*  The program must be driven by a short data file. The first 14 records */
/*  specify problem dimensions and program options using list-directed */
/*  input.  The remaining lines specify the LAPACK test paths and the */
/*  number of matrix types to use in testing.  An annotated example of a */
/*  data file can be obtained by deleting the first 3 characters from the */
/*  following 38 lines: */
/*  Data file for testing COMPLEX*16 LAPACK linear equation routines */
/*  7                      Number of values of M */
/*  0 1 2 3 5 10 16        Values of M (row dimension) */
/*  7                      Number of values of N */
/*  0 1 2 3 5 10 16        Values of N (column dimension) */
/*  1                      Number of values of NRHS */
/*  2                      Values of NRHS (number of right hand sides) */
/*  5                      Number of values of NB */
/*  1 3 3 3 20             Values of NB (the blocksize) */
/*  1 0 5 9 1              Values of NX (crossover point) */
/*  30.0                   Threshold value of test ratio */
/*  T                      Put T to test the LAPACK routines */
/*  T                      Put T to test the driver routines */
/*  T                      Put T to test the error exits */
/*  ZGE   11               List types on next line if 0 < NTYPES < 11 */
/*  ZGB    8               List types on next line if 0 < NTYPES <  8 */
/*  ZGT   12               List types on next line if 0 < NTYPES < 12 */
/*  ZPO    9               List types on next line if 0 < NTYPES <  9 */
/*  ZPP    9               List types on next line if 0 < NTYPES <  9 */
/*  ZPB    8               List types on next line if 0 < NTYPES <  8 */
/*  ZPT   12               List types on next line if 0 < NTYPES < 12 */
/*  ZHE   10               List types on next line if 0 < NTYPES < 10 */
/*  ZHP   10               List types on next line if 0 < NTYPES < 10 */
/*  ZSY   11               List types on next line if 0 < NTYPES < 11 */
/*  ZSP   11               List types on next line if 0 < NTYPES < 11 */
/*  ZTR   18               List types on next line if 0 < NTYPES < 18 */
/*  ZTP   18               List types on next line if 0 < NTYPES < 18 */
/*  ZTB   17               List types on next line if 0 < NTYPES < 17 */
/*  ZQR    8               List types on next line if 0 < NTYPES <  8 */
/*  ZRQ    8               List types on next line if 0 < NTYPES <  8 */
/*  ZLQ    8               List types on next line if 0 < NTYPES <  8 */
/*  ZQL    8               List types on next line if 0 < NTYPES <  8 */
/*  ZQP    6               List types on next line if 0 < NTYPES <  6 */
/*  ZTZ    3               List types on next line if 0 < NTYPES <  3 */
/*  ZLS    6               List types on next line if 0 < NTYPES <  6 */
/*  ZEQ */

/*  Internal Parameters */
/*  =================== */

/*  NMAX    INTEGER */
/*          The maximum allowable value for N. */

/*  MAXIN   INTEGER */
/*          The number of different values that can be used for each of */
/*          M, N, or NB */

/*  MAXRHS  INTEGER */
/*          The maximum number of right hand sides */

/*  NIN     INTEGER */
/*          The unit number for input */

/*  NOUT    INTEGER */
/*          The unit number for output */

/*  ===================================================================== */

/*     .. Parameters .. */
/*     .. */
/*     .. Local Scalars .. */
/*     .. */
/*     .. Local Arrays .. */
/*     .. */
/*     .. External Functions .. */
/*     .. */
/*     .. External Subroutines .. */
/*     .. */
/*     .. Scalars in Common .. */
/*     .. */
/*     .. Arrays in Common .. */
/*     .. */
/*     .. Common blocks .. */
/*     .. */
/*     .. Data statements .. */
/*     .. */
/*     .. Executable Statements .. */

    s1 = dsecnd_();
    lda = 132;
    fatal = FALSE_;

/*     Read a dummy line. */

    s_rsle(&io___6);
    e_rsle();

/*     Report values of parameters. */

    ilaver_(&vers_major__, &vers_minor__, &vers_patch__);
    s_wsfe(&io___10);
    do_fio(&c__1, (char *)&vers_major__, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&vers_minor__, (ftnlen)sizeof(integer));
    do_fio(&c__1, (char *)&vers_patch__, (ftnlen)sizeof(integer));
    e_wsfe();

/*     Read the values of M */

    s_rsle(&io___11);
    do_lio(&c__3, &c__1, (char *)&nm, (ftnlen)sizeof(integer));
    e_rsle();
    if (nm < 1) {
	s_wsfe(&io___13);
	do_fio(&c__1, " NM ", (ftnlen)4);
	do_fio(&c__1, (char *)&nm, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
	e_wsfe();
	nm = 0;
	fatal = TRUE_;
    } else if (nm > 12) {
	s_wsfe(&io___14);
	do_fio(&c__1, " NM ", (ftnlen)4);
	do_fio(&c__1, (char *)&nm, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__12, (ftnlen)sizeof(integer));
	e_wsfe();
	nm = 0;
	fatal = TRUE_;
    }
    s_rsle(&io___15);
    i__1 = nm;
    for (i__ = 1; i__ <= i__1; ++i__) {
	do_lio(&c__3, &c__1, (char *)&mval[i__ - 1], (ftnlen)sizeof(integer));
    }
    e_rsle();
    i__1 = nm;
    for (i__ = 1; i__ <= i__1; ++i__) {
	if (mval[i__ - 1] < 0) {
	    s_wsfe(&io___18);
	    do_fio(&c__1, " M  ", (ftnlen)4);
	    do_fio(&c__1, (char *)&mval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	} else if (mval[i__ - 1] > 132) {
	    s_wsfe(&io___19);
	    do_fio(&c__1, " M  ", (ftnlen)4);
	    do_fio(&c__1, (char *)&mval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__132, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	}
/* L10: */
    }
    if (nm > 0) {
	s_wsfe(&io___20);
	do_fio(&c__1, "M   ", (ftnlen)4);
	i__1 = nm;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_fio(&c__1, (char *)&mval[i__ - 1], (ftnlen)sizeof(integer));
	}
	e_wsfe();
    }

/*     Read the values of N */

    s_rsle(&io___21);
    do_lio(&c__3, &c__1, (char *)&nn, (ftnlen)sizeof(integer));
    e_rsle();
    if (nn < 1) {
	s_wsfe(&io___23);
	do_fio(&c__1, " NN ", (ftnlen)4);
	do_fio(&c__1, (char *)&nn, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
	e_wsfe();
	nn = 0;
	fatal = TRUE_;
    } else if (nn > 12) {
	s_wsfe(&io___24);
	do_fio(&c__1, " NN ", (ftnlen)4);
	do_fio(&c__1, (char *)&nn, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__12, (ftnlen)sizeof(integer));
	e_wsfe();
	nn = 0;
	fatal = TRUE_;
    }
    s_rsle(&io___25);
    i__1 = nn;
    for (i__ = 1; i__ <= i__1; ++i__) {
	do_lio(&c__3, &c__1, (char *)&nval[i__ - 1], (ftnlen)sizeof(integer));
    }
    e_rsle();
    i__1 = nn;
    for (i__ = 1; i__ <= i__1; ++i__) {
	if (nval[i__ - 1] < 0) {
	    s_wsfe(&io___27);
	    do_fio(&c__1, " N  ", (ftnlen)4);
	    do_fio(&c__1, (char *)&nval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	} else if (nval[i__ - 1] > 132) {
	    s_wsfe(&io___28);
	    do_fio(&c__1, " N  ", (ftnlen)4);
	    do_fio(&c__1, (char *)&nval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__132, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	}
/* L20: */
    }
    if (nn > 0) {
	s_wsfe(&io___29);
	do_fio(&c__1, "N   ", (ftnlen)4);
	i__1 = nn;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_fio(&c__1, (char *)&nval[i__ - 1], (ftnlen)sizeof(integer));
	}
	e_wsfe();
    }

/*     Read the values of NRHS */

    s_rsle(&io___30);
    do_lio(&c__3, &c__1, (char *)&nns, (ftnlen)sizeof(integer));
    e_rsle();
    if (nns < 1) {
	s_wsfe(&io___32);
	do_fio(&c__1, " NNS", (ftnlen)4);
	do_fio(&c__1, (char *)&nns, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
	e_wsfe();
	nns = 0;
	fatal = TRUE_;
    } else if (nns > 12) {
	s_wsfe(&io___33);
	do_fio(&c__1, " NNS", (ftnlen)4);
	do_fio(&c__1, (char *)&nns, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__12, (ftnlen)sizeof(integer));
	e_wsfe();
	nns = 0;
	fatal = TRUE_;
    }
    s_rsle(&io___34);
    i__1 = nns;
    for (i__ = 1; i__ <= i__1; ++i__) {
	do_lio(&c__3, &c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer))
		;
    }
    e_rsle();
    i__1 = nns;
    for (i__ = 1; i__ <= i__1; ++i__) {
	if (nsval[i__ - 1] < 0) {
	    s_wsfe(&io___36);
	    do_fio(&c__1, "NRHS", (ftnlen)4);
	    do_fio(&c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	} else if (nsval[i__ - 1] > 16) {
	    s_wsfe(&io___37);
	    do_fio(&c__1, "NRHS", (ftnlen)4);
	    do_fio(&c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__16, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	}
/* L30: */
    }
    if (nns > 0) {
	s_wsfe(&io___38);
	do_fio(&c__1, "NRHS", (ftnlen)4);
	i__1 = nns;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_fio(&c__1, (char *)&nsval[i__ - 1], (ftnlen)sizeof(integer));
	}
	e_wsfe();
    }

/*     Read the values of NB */

    s_rsle(&io___39);
    do_lio(&c__3, &c__1, (char *)&nnb, (ftnlen)sizeof(integer));
    e_rsle();
    if (nnb < 1) {
	s_wsfe(&io___41);
	do_fio(&c__1, "NNB ", (ftnlen)4);
	do_fio(&c__1, (char *)&nnb, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer));
	e_wsfe();
	nnb = 0;
	fatal = TRUE_;
    } else if (nnb > 12) {
	s_wsfe(&io___42);
	do_fio(&c__1, "NNB ", (ftnlen)4);
	do_fio(&c__1, (char *)&nnb, (ftnlen)sizeof(integer));
	do_fio(&c__1, (char *)&c__12, (ftnlen)sizeof(integer));
	e_wsfe();
	nnb = 0;
	fatal = TRUE_;
    }
    s_rsle(&io___43);
    i__1 = nnb;
    for (i__ = 1; i__ <= i__1; ++i__) {
	do_lio(&c__3, &c__1, (char *)&nbval[i__ - 1], (ftnlen)sizeof(integer))
		;
    }
    e_rsle();
    i__1 = nnb;
    for (i__ = 1; i__ <= i__1; ++i__) {
	if (nbval[i__ - 1] < 0) {
	    s_wsfe(&io___45);
	    do_fio(&c__1, " NB ", (ftnlen)4);
	    do_fio(&c__1, (char *)&nbval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	}
/* L40: */
    }
    if (nnb > 0) {
	s_wsfe(&io___46);
	do_fio(&c__1, "NB  ", (ftnlen)4);
	i__1 = nnb;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_fio(&c__1, (char *)&nbval[i__ - 1], (ftnlen)sizeof(integer));
	}
	e_wsfe();
    }

/*     Set NBVAL2 to be the set of unique values of NB */

    nnb2 = 0;
    i__1 = nnb;
    for (i__ = 1; i__ <= i__1; ++i__) {
	nb = nbval[i__ - 1];
	i__2 = nnb2;
	for (j = 1; j <= i__2; ++j) {
	    if (nb == nbval2[j - 1]) {
		goto L60;
	    }
/* L50: */
	}
	++nnb2;
	nbval2[nnb2 - 1] = nb;
L60:
	;
    }

/*     Read the values of NX */

    s_rsle(&io___51);
    i__1 = nnb;
    for (i__ = 1; i__ <= i__1; ++i__) {
	do_lio(&c__3, &c__1, (char *)&nxval[i__ - 1], (ftnlen)sizeof(integer))
		;
    }
    e_rsle();
    i__1 = nnb;
    for (i__ = 1; i__ <= i__1; ++i__) {
	if (nxval[i__ - 1] < 0) {
	    s_wsfe(&io___53);
	    do_fio(&c__1, " NX ", (ftnlen)4);
	    do_fio(&c__1, (char *)&nxval[i__ - 1], (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&c__0, (ftnlen)sizeof(integer));
	    e_wsfe();
	    fatal = TRUE_;
	}
/* L70: */
    }
    if (nnb > 0) {
	s_wsfe(&io___54);
	do_fio(&c__1, "NX  ", (ftnlen)4);
	i__1 = nnb;
	for (i__ = 1; i__ <= i__1; ++i__) {
	    do_fio(&c__1, (char *)&nxval[i__ - 1], (ftnlen)sizeof(integer));
	}
	e_wsfe();
    }

/*     Read the threshold value for the test ratios. */

    s_rsle(&io___55);
    do_lio(&c__5, &c__1, (char *)&thresh, (ftnlen)sizeof(doublereal));
    e_rsle();
    s_wsfe(&io___57);
    do_fio(&c__1, (char *)&thresh, (ftnlen)sizeof(doublereal));
    e_wsfe();

/*     Read the flag that indicates whether to test the LAPACK routines. */

    s_rsle(&io___58);
    do_lio(&c__8, &c__1, (char *)&tstchk, (ftnlen)sizeof(logical));
    e_rsle();

/*     Read the flag that indicates whether to test the driver routines. */

    s_rsle(&io___60);
    do_lio(&c__8, &c__1, (char *)&tstdrv, (ftnlen)sizeof(logical));
    e_rsle();

/*     Read the flag that indicates whether to test the error exits. */

    s_rsle(&io___62);
    do_lio(&c__8, &c__1, (char *)&tsterr, (ftnlen)sizeof(logical));
    e_rsle();

    if (fatal) {
	s_wsfe(&io___64);
	e_wsfe();
	s_stop("", (ftnlen)0);
    }

/*     Calculate and print the machine dependent constants. */

    eps = dlamch_("Underflow threshold");
    s_wsfe(&io___66);
    do_fio(&c__1, "underflow", (ftnlen)9);
    do_fio(&c__1, (char *)&eps, (ftnlen)sizeof(doublereal));
    e_wsfe();
    eps = dlamch_("Overflow threshold");
    s_wsfe(&io___67);
    do_fio(&c__1, "overflow ", (ftnlen)9);
    do_fio(&c__1, (char *)&eps, (ftnlen)sizeof(doublereal));
    e_wsfe();
    eps = dlamch_("Epsilon");
    s_wsfe(&io___68);
    do_fio(&c__1, "precision", (ftnlen)9);
    do_fio(&c__1, (char *)&eps, (ftnlen)sizeof(doublereal));
    e_wsfe();
    s_wsle(&io___69);
    e_wsle();
    nrhs = nsval[0];

L80:

/*     Read a test path and the number of matrix types to use. */

    ci__1.cierr = 0;
    ci__1.ciend = 1;
    ci__1.ciunit = 5;
    ci__1.cifmt = "(A72)";
    i__1 = s_rsfe(&ci__1);
    if (i__1 != 0) {
	goto L140;
    }
    i__1 = do_fio(&c__1, aline, (ftnlen)72);
    if (i__1 != 0) {
	goto L140;
    }
    i__1 = e_rsfe();
    if (i__1 != 0) {
	goto L140;
    }
    s_copy(path, aline, (ftnlen)3, (ftnlen)3);
    nmats = 30;
    i__ = 3;
L90:
    ++i__;
    if (i__ > 72) {
	goto L130;
    }
    if (*(unsigned char *)&aline[i__ - 1] == ' ') {
	goto L90;
    }
    nmats = 0;
L100:
    *(unsigned char *)c1 = *(unsigned char *)&aline[i__ - 1];
    for (k = 1; k <= 10; ++k) {
	if (*(unsigned char *)c1 == *(unsigned char *)&intstr[k - 1]) {
	    ic = k - 1;
	    goto L120;
	}
/* L110: */
    }
    goto L130;
L120:
    nmats = nmats * 10 + ic;
    ++i__;
    if (i__ > 72) {
	goto L130;
    }
    goto L100;
L130:
    *(unsigned char *)c1 = *(unsigned char *)path;
    s_copy(c2, path + 1, (ftnlen)2, (ftnlen)2);

/*     Check first character for correct precision. */

    if (! lsame_(c1, "Zomplex precision")) {
	s_wsfe(&io___78);
	do_fio(&c__1, path, (ftnlen)3);
	e_wsfe();

    } else if (nmats <= 0) {

/*        Check for a positive number of tests requested. */

	s_wsfe(&io___79);
	do_fio(&c__1, path, (ftnlen)3);
	e_wsfe();

    } else if (lsamen_(&c__2, c2, "GE")) {

/*        GE:  general matrices */

	ntypes = 11;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkge_(dotype, &nm, mval, &nn, nval, &nnb2, nbval2, &nns, nsval, 
		    &thresh, &tsterr, &lda, a, &a[21912], &a[43824], b, &b[
		    2112], &b[4224], work, rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___87);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvge_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, &lda, a, &a[
		    21912], &a[43824], b, &b[2112], &b[4224], &b[6336], s, 
		    work, rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___89);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "GB")) {

/*        GB:  general banded matrices */

	la = 43692;
	lafac = 65472;
	ntypes = 8;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkgb_(dotype, &nm, mval, &nn, nval, &nnb2, nbval2, &nns, nsval, 
		    &thresh, &tsterr, a, &la, &a[43824], &lafac, b, &b[2112], 
		    &b[4224], work, rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___92);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvgb_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, a, &la, &a[
		    43824], &lafac, &a[109560], b, &b[2112], &b[4224], &b[
		    6336], s, work, rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___93);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "GT")) {

/*        GT:  general tridiagonal matrices */

	ntypes = 12;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkgt_(dotype, &nn, nval, &nns, nsval, &thresh, &tsterr, a, &a[
		    21912], b, &b[2112], &b[4224], work, rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___94);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvgt_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, a, &a[21912], 
		    b, &b[2112], &b[4224], work, rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___95);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "PO")) {

/*        PO:  positive definite matrices */

	ntypes = 9;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkpo_(dotype, &nn, nval, &nnb2, nbval2, &nns, nsval, &thresh, &
		    tsterr, &lda, a, &a[21912], &a[43824], b, &b[2112], &b[
		    4224], work, rwork, &c__6);
	} else {
	    s_wsfe(&io___96);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvpo_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, &lda, a, &a[
		    21912], &a[43824], b, &b[2112], &b[4224], &b[6336], s, 
		    work, rwork, &c__6);
	} else {
	    s_wsfe(&io___97);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "PP")) {

/*        PP:  positive definite packed matrices */

	ntypes = 9;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkpp_(dotype, &nn, nval, &nns, nsval, &thresh, &tsterr, &lda, a, 
		     &a[21912], &a[43824], b, &b[2112], &b[4224], work, rwork, 
		     &c__6);
	} else {
	    s_wsfe(&io___98);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvpp_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, &lda, a, &a[
		    21912], &a[43824], b, &b[2112], &b[4224], &b[6336], s, 
		    work, rwork, &c__6);
	} else {
	    s_wsfe(&io___99);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "PB")) {

/*        PB:  positive definite banded matrices */

	ntypes = 8;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkpb_(dotype, &nn, nval, &nnb2, nbval2, &nns, nsval, &thresh, &
		    tsterr, &lda, a, &a[21912], &a[43824], b, &b[2112], &b[
		    4224], work, rwork, &c__6);
	} else {
	    s_wsfe(&io___100);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvpb_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, &lda, a, &a[
		    21912], &a[43824], b, &b[2112], &b[4224], &b[6336], s, 
		    work, rwork, &c__6);
	} else {
	    s_wsfe(&io___101);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "PT")) {

/*        PT:  positive definite tridiagonal matrices */

	ntypes = 12;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkpt_(dotype, &nn, nval, &nns, nsval, &thresh, &tsterr, a, s, &
		    a[21912], b, &b[2112], &b[4224], work, rwork, &c__6);
	} else {
	    s_wsfe(&io___102);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvpt_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, a, s, &a[
		    21912], b, &b[2112], &b[4224], work, rwork, &c__6);
	} else {
	    s_wsfe(&io___103);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "HE")) {

/*        HE:  Hermitian indefinite matrices */

	ntypes = 10;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkhe_(dotype, &nn, nval, &nnb2, nbval2, &nns, nsval, &thresh, &
		    tsterr, &lda, a, &a[21912], &a[43824], b, &b[2112], &b[
		    4224], work, rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___104);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvhe_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, &lda, a, &a[
		    21912], &a[43824], b, &b[2112], &b[4224], work, rwork, 
		    iwork, &c__6);
	} else {
	    s_wsfe(&io___105);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "HP")) {

/*        HP:  Hermitian indefinite packed matrices */

	ntypes = 10;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkhp_(dotype, &nn, nval, &nns, nsval, &thresh, &tsterr, &lda, a, 
		     &a[21912], &a[43824], b, &b[2112], &b[4224], work, rwork, 
		     iwork, &c__6);
	} else {
	    s_wsfe(&io___106);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvhp_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, &lda, a, &a[
		    21912], &a[43824], b, &b[2112], &b[4224], work, rwork, 
		    iwork, &c__6);
	} else {
	    s_wsfe(&io___107);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "SY")) {

/*        SY:  symmetric indefinite matrices */

	ntypes = 11;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchksy_(dotype, &nn, nval, &nnb2, nbval2, &nns, nsval, &thresh, &
		    tsterr, &lda, a, &a[21912], &a[43824], b, &b[2112], &b[
		    4224], work, rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___108);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvsy_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, &lda, a, &a[
		    21912], &a[43824], b, &b[2112], &b[4224], work, rwork, 
		    iwork, &c__6);
	} else {
	    s_wsfe(&io___109);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "SP")) {

/*        SP:  symmetric indefinite packed matrices */

	ntypes = 11;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchksp_(dotype, &nn, nval, &nns, nsval, &thresh, &tsterr, &lda, a, 
		     &a[21912], &a[43824], b, &b[2112], &b[4224], work, rwork, 
		     iwork, &c__6);
	} else {
	    s_wsfe(&io___110);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

	if (tstdrv) {
	    zdrvsp_(dotype, &nn, nval, &nrhs, &thresh, &tsterr, &lda, a, &a[
		    21912], &a[43824], b, &b[2112], &b[4224], work, rwork, 
		    iwork, &c__6);
	} else {
	    s_wsfe(&io___111);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "TR")) {

/*        TR:  triangular matrices */

	ntypes = 18;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchktr_(dotype, &nn, nval, &nnb2, nbval2, &nns, nsval, &thresh, &
		    tsterr, &lda, a, &a[21912], b, &b[2112], &b[4224], work, 
		    rwork, &c__6);
	} else {
	    s_wsfe(&io___112);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "TP")) {

/*        TP:  triangular packed matrices */

	ntypes = 18;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchktp_(dotype, &nn, nval, &nns, nsval, &thresh, &tsterr, &lda, a, 
		     &a[21912], b, &b[2112], &b[4224], work, rwork, &c__6);
	} else {
	    s_wsfe(&io___113);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "TB")) {

/*        TB:  triangular banded matrices */

	ntypes = 17;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchktb_(dotype, &nn, nval, &nns, nsval, &thresh, &tsterr, &lda, a, 
		     &a[21912], b, &b[2112], &b[4224], work, rwork, &c__6);
	} else {
	    s_wsfe(&io___114);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "QR")) {

/*        QR:  QR factorization */

	ntypes = 8;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkqr_(dotype, &nm, mval, &nn, nval, &nnb, nbval, nxval, &nrhs, &
		    thresh, &tsterr, &c__132, a, &a[21912], &a[43824], &a[
		    65736], &a[87648], b, &b[2112], &b[4224], &b[6336], work, 
		    rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___115);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "LQ")) {

/*        LQ:  LQ factorization */

	ntypes = 8;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchklq_(dotype, &nm, mval, &nn, nval, &nnb, nbval, nxval, &nrhs, &
		    thresh, &tsterr, &c__132, a, &a[21912], &a[43824], &a[
		    65736], &a[87648], b, &b[2112], &b[4224], &b[6336], work, 
		    rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___116);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "QL")) {

/*        QL:  QL factorization */

	ntypes = 8;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkql_(dotype, &nm, mval, &nn, nval, &nnb, nbval, nxval, &nrhs, &
		    thresh, &tsterr, &c__132, a, &a[21912], &a[43824], &a[
		    65736], &a[87648], b, &b[2112], &b[4224], &b[6336], work, 
		    rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___117);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "RQ")) {

/*        RQ:  RQ factorization */

	ntypes = 8;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkrq_(dotype, &nm, mval, &nn, nval, &nnb, nbval, nxval, &nrhs, &
		    thresh, &tsterr, &c__132, a, &a[21912], &a[43824], &a[
		    65736], &a[87648], b, &b[2112], &b[4224], &b[6336], work, 
		    rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___118);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "EQ")) {

/*        EQ:  Equilibration routines for general and positive definite */
/*             matrices (THREQ should be between 2 and 10) */

	if (tstchk) {
	    zchkeq_(&threq, &c__6);
	} else {
	    s_wsfe(&io___119);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "TZ")) {

/*        TZ:  Trapezoidal matrix */

	ntypes = 3;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchktz_(dotype, &nm, mval, &nn, nval, &thresh, &tsterr, a, &a[
		    21912], s, &s[132], b, work, rwork, &c__6);
	} else {
	    s_wsfe(&io___120);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "QP")) {

/*        QP:  QR factorization with pivoting */

	ntypes = 6;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstchk) {
	    zchkqp_(dotype, &nm, mval, &nn, nval, &thresh, &tsterr, a, &a[
		    21912], s, &s[132], b, work, rwork, iwork, &c__6);
	    zchkq3_(dotype, &nm, mval, &nn, nval, &nnb, nbval, nxval, &thresh, 
		     a, &a[21912], s, &s[132], b, work, rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___121);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else if (lsamen_(&c__2, c2, "LS")) {

/*        LS:  Least squares drivers */

	ntypes = 6;
	alareq_(path, &nmats, dotype, &ntypes, &c__5, &c__6);

	if (tstdrv) {
	    zdrvls_(dotype, &nm, mval, &nn, nval, &nns, nsval, &nnb, nbval, 
		    nxval, &thresh, &tsterr, a, &a[21912], &a[43824], &a[
		    65736], &a[87648], s, &s[132], work, rwork, iwork, &c__6);
	} else {
	    s_wsfe(&io___122);
	    do_fio(&c__1, path, (ftnlen)3);
	    e_wsfe();
	}

    } else {

	s_wsfe(&io___123);
	do_fio(&c__1, path, (ftnlen)3);
	e_wsfe();
    }

/*     Go back to get another input line. */

    goto L80;

/*     Branch to this line when the last record is read. */

L140:
    cl__1.cerr = 0;
    cl__1.cunit = 5;
    cl__1.csta = 0;
    f_clos(&cl__1);
    s2 = dsecnd_();
    s_wsfe(&io___125);
    e_wsfe();
    s_wsfe(&io___126);
    d__1 = s2 - s1;
    do_fio(&c__1, (char *)&d__1, (ftnlen)sizeof(doublereal));
    e_wsfe();


/*     End of ZCHKAA */

    return 0;
} /* MAIN__ */
Пример #20
0
/* *********************************************************************** */
/* Subroutine */ int pdsrd_(char *filnam, real *work, integer *leng, integer *
	ierr, ftnlen filnam_len)
{
    /* System generated locals */
    integer i__1;
    olist o__1;
    cllist cl__1;

    /* Builtin functions */
    integer f_open(olist *), s_rsue(cilist *), do_uio(integer *, char *, 
	    ftnlen), e_rsue(void), f_clos(cllist *);

    /* Local variables */
    static integer i__, ios, iopds;

    /* Fortran I/O blocks */
    static cilist io___3 = { 1, 0, 1, 0, 0 };




/* -------------------------------INPUT----------------------------------- */
/*     FILNAM     : FULL PDS MEMBER NAME : /XXX/XXX/MACRO/CASEA010 */
/* -------------------------------OUTPUT---------------------------------- */
/*     WORK       : CONTENTS OF MEMBER */
/*     LENG       : LENGTH OF DATA IN MEMBER (EXCEPT LENG ITSELF) */
/*     IERR       : ERROR CODE =0 : NORMAL END */
/*                             =1 : OPEN ERROR */
/*                             =2 : CLOSE ERROR */
/*                             =3 : READ ERROR */
/* ----------------------------------------------------------------------- */

    /* Parameter adjustments */
    --work;

    /* Function Body */
    *ierr = 0;
    iopds = 49;

    o__1.oerr = 1;
    o__1.ounit = iopds;
    o__1.ofnmlen = 81;
    o__1.ofnm = filnam;
    o__1.orl = 0;
    o__1.osta = "UNKNOWN";
    o__1.oacc = "SEQUENTIAL";
    o__1.ofm = "UNFORMATTED";
    o__1.oblnk = 0;
    ios = f_open(&o__1);
    if (ios != 0) {
	goto L100;
    }
    io___3.ciunit = iopds;
    ios = s_rsue(&io___3);
    if (ios != 0) {
	goto L100001;
    }
    ios = do_uio(&c__1, (char *)&(*leng), (ftnlen)sizeof(integer));
    if (ios != 0) {
	goto L100001;
    }
    i__1 = *leng;
    for (i__ = 1; i__ <= i__1; ++i__) {
	ios = do_uio(&c__1, (char *)&work[i__], (ftnlen)sizeof(real));
	if (ios != 0) {
	    goto L100001;
	}
    }
    ios = e_rsue();
L100001:
    if (ios > 0) {
	goto L300;
    }
    cl__1.cerr = 1;
    cl__1.cunit = iopds;
    cl__1.csta = "KEEP";
    ios = f_clos(&cl__1);
    if (ios != 0) {
	goto L200;
    }
    return 0;
L100:
    *ierr = 1;
/*     WRITE(6,*) ' OPEN ERROR , IOSTAT=',IOS */
    return 0;
L200:
    *ierr = 2;
/*     WRITE(6,*) ' CLOSE ERROR , IOSTAT=',IOS */
    return 0;
L300:
    *ierr = 3;
/*     WRITE(6,*) ' READ ERROR , IOSTAT=',IOS */
    return 0;
} /* pdsrd_ */
Пример #21
0
/* $Procedure ZZDDHF2H ( Private --- DDH Filename to Handle ) */
/* Subroutine */ int zzddhf2h_(char *fname, integer *ftabs, integer *ftamh, 
	integer *ftarc, integer *ftbff, integer *fthan, char *ftnam, integer *
	ftrtm, doublereal *ftmnm, integer *nft, integer *utcst, integer *
	uthan, logical *utlck, integer *utlun, integer *nut, logical *exists, 
	logical *opened, integer *handle, logical *found, doublereal *mnm, 
	ftnlen fname_len, ftnlen ftnam_len)
{
    /* System generated locals */
    olist o__1;
    cllist cl__1;
    inlist ioin__1;

    /* Builtin functions */
    integer s_cmp(char *, char *, ftnlen, ftnlen), f_inqu(inlist *), f_open(
	    olist *), f_clos(cllist *);

    /* Local variables */
    integer unit;
    extern doublereal zzddhmnm_(integer *);
    extern /* Subroutine */ int zzddhgtu_(integer *, integer *, logical *, 
	    integer *, integer *, integer *), zzddhrmu_(integer *, integer *, 
	    integer *, integer *, logical *, integer *, integer *);
    integer i__;
    extern /* Subroutine */ int chkin_(char *, ftnlen);
    integer rchar;
    extern /* Subroutine */ int errch_(char *, char *, ftnlen, ftnlen);
    extern integer rtrim_(char *, ftnlen);
    extern logical failed_(void);
    extern integer isrchi_(integer *, integer *, integer *);
    logical locopn;
    extern /* Subroutine */ int sigerr_(char *, ftnlen);
    integer uindex;
    logical locexs;
    extern /* Subroutine */ int chkout_(char *, ftnlen), setmsg_(char *, 
	    ftnlen);
    integer iostat;
    extern /* Subroutine */ int errint_(char *, integer *, ftnlen);
    extern logical return_(void);

/* $ Abstract */

/*     SPICE Private routine intended solely for the support of SPICE */
/*     routines.  Users should not call this routine directly due */
/*     to the volatile nature of this routine. */

/*     Convert filename to a handle. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     None. */

/* $ Keywords */

/*     PRIVATE */

/* $ Declarations */

/* $ Abstract */

/*     Parameter declarations for the DAF/DAS handle manager. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     DAF, DAS */

/* $ Keywords */

/*     PRIVATE */

/* $ Particulars */

/*     This include file contains parameters defining limits and */
/*     integer codes that are utilized in the DAF/DAS handle manager */
/*     routines. */

/* $ Restrictions */

/*     None. */

/* $ Author_and_Institution */

/*     F.S. Turner       (JPL) */

/* $ Literature_References */

/*     None. */

/* $ Version */

/* -    SPICELIB Version 2.5.0, 10-MAR-2014 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-INTEL. */

/* -    SPICELIB Version 2.4.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-LINUX-64BIT-IFORT. */

/* -    SPICELIB Version 2.3.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-GFORTRAN. */

/* -    SPICELIB Version 2.2.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-64BIT-GFORTRAN. */

/* -    SPICELIB Version 2.1.0, 10-MAR-2014 (BVS) */

/*        Updated for PC-CYGWIN-64BIT-GCC_C. */

/* -    SPICELIB Version 2.0.0, 12-APR-2012 (BVS) */

/*        Increased FTSIZE (from 1000 to 5000). */

/* -    SPICELIB Version 1.20.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL. */

/* -    SPICELIB Version 1.19.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL-CC_C. */

/* -    SPICELIB Version 1.18.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-INTEL-64BIT-CC_C. */

/* -    SPICELIB Version 1.17.0, 13-MAY-2010 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-NATIVE_C. */

/* -    SPICELIB Version 1.16.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-WINDOWS-64BIT-IFORT. */

/* -    SPICELIB Version 1.15.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-LINUX-64BIT-GFORTRAN. */

/* -    SPICELIB Version 1.14.0, 13-MAY-2010 (BVS) */

/*        Updated for PC-64BIT-MS_C. */

/* -    SPICELIB Version 1.13.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-INTEL_C. */

/* -    SPICELIB Version 1.12.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-IFORT. */

/* -    SPICELIB Version 1.11.0, 13-MAY-2010 (BVS) */

/*        Updated for MAC-OSX-64BIT-GFORTRAN. */

/* -    SPICELIB Version 1.10.0, 18-MAR-2009 (BVS) */

/*        Updated for PC-LINUX-GFORTRAN. */

/* -    SPICELIB Version 1.9.0, 18-MAR-2009 (BVS) */

/*        Updated for MAC-OSX-GFORTRAN. */

/* -    SPICELIB Version 1.8.0, 19-FEB-2008 (BVS) */

/*        Updated for PC-LINUX-IFORT. */

/* -    SPICELIB Version 1.7.0, 14-NOV-2006 (BVS) */

/*        Updated for PC-LINUX-64BIT-GCC_C. */

/* -    SPICELIB Version 1.6.0, 14-NOV-2006 (BVS) */

/*        Updated for MAC-OSX-INTEL_C. */

/* -    SPICELIB Version 1.5.0, 14-NOV-2006 (BVS) */

/*        Updated for MAC-OSX-IFORT. */

/* -    SPICELIB Version 1.4.0, 14-NOV-2006 (BVS) */

/*        Updated for PC-WINDOWS-IFORT. */

/* -    SPICELIB Version 1.3.0, 26-OCT-2005 (BVS) */

/*        Updated for SUN-SOLARIS-64BIT-GCC_C. */

/* -    SPICELIB Version 1.2.0, 03-JAN-2005 (BVS) */

/*        Updated for PC-CYGWIN_C. */

/* -    SPICELIB Version 1.1.0, 03-JAN-2005 (BVS) */

/*        Updated for PC-CYGWIN. */

/* -    SPICELIB Version 1.0.1, 17-JUL-2002 */

/*        Added MAC-OSX environments. */

/* -    SPICELIB Version 1.0.0, 07-NOV-2001 */

/* -& */

/*     Unit and file table size parameters. */

/*     FTSIZE     is the maximum number of files (DAS and DAF) that a */
/*                user may have open simultaneously. */


/*     RSVUNT     is the number of units protected from being locked */
/*                to a particular handle by ZZDDHHLU. */


/*     SCRUNT     is the number of units protected for use by scratch */
/*                files. */


/*     UTSIZE     is the maximum number of logical units this manager */
/*                will utilize at one time. */


/*     Access method enumeration.  These parameters are used to */
/*     identify which access method is associated with a particular */
/*     handle.  They need to be synchronized with the STRAMH array */
/*     defined in ZZDDHGSD in the following fashion: */

/*        STRAMH ( READ   ) = 'READ' */
/*        STRAMH ( WRITE  ) = 'WRITE' */
/*        STRAMH ( SCRTCH ) = 'SCRATCH' */
/*        STRAMH ( NEW    ) = 'NEW' */

/*     These values are used in the file table variable FTAMH. */


/*     Binary file format enumeration.  These parameters are used to */
/*     identify which binary file format is associated with a */
/*     particular handle.  They need to be synchronized with the STRBFF */
/*     array defined in ZZDDHGSD in the following fashion: */

/*        STRBFF ( BIGI3E ) = 'BIG-IEEE' */
/*        STRBFF ( LTLI3E ) = 'LTL-IEEE' */
/*        STRBFF ( VAXGFL ) = 'VAX-GFLT' */
/*        STRBFF ( VAXDFL ) = 'VAX-DFLT' */

/*     These values are used in the file table variable FTBFF. */


/*     Some random string lengths... more documentation required. */
/*     For now this will have to suffice. */


/*     Architecture enumeration.  These parameters are used to identify */
/*     which file architecture is associated with a particular handle. */
/*     They need to be synchronized with the STRARC array defined in */
/*     ZZDDHGSD in the following fashion: */

/*        STRARC ( DAF ) = 'DAF' */
/*        STRARC ( DAS ) = 'DAS' */

/*     These values will be used in the file table variable FTARC. */


/*     For the following environments, record length is measured in */
/*     characters (bytes) with eight characters per double precision */
/*     number. */

/*     Environment: Sun, Sun FORTRAN */
/*     Source:      Sun Fortran Programmer's Guide */

/*     Environment: PC, MS FORTRAN */
/*     Source:      Microsoft Fortran Optimizing Compiler User's Guide */

/*     Environment: Macintosh, Language Systems FORTRAN */
/*     Source:      Language Systems FORTRAN Reference Manual, */
/*                  Version 1.2, page 12-7 */

/*     Environment: PC/Linux, g77 */
/*     Source:      Determined by experiment. */

/*     Environment: PC, Lahey F77 EM/32 Version 4.0 */
/*     Source:      Lahey F77 EM/32 Language Reference Manual, */
/*                  page 144 */

/*     Environment: HP-UX 9000/750, FORTRAN/9000 Series 700 computers */
/*     Source:      FORTRAN/9000 Reference-Series 700 Computers, */
/*                  page 5-110 */

/*     Environment: NeXT Mach OS (Black Hardware), */
/*                  Absoft Fortran Version 3.2 */
/*     Source:      NAIF Program */


/*     The following parameter defines the size of a string used */
/*     to store a filenames on this target platform. */


/*     The following parameter controls the size of the character record */
/*     buffer used to read data from non-native files. */

/* $ Brief_I/O */

/*     VARIABLE  I/O  DESCRIPTION */
/*     --------  ---  -------------------------------------------------- */
/*     FNAME      I   Name of the file to convert to a handle. */
/*     FTABS, */
/*     FTAMH, */
/*     FTARC, */
/*     FTBFF, */
/*     FTHAN, */
/*     FTNAM, */
/*     FTRTM, */
/*     FTMNM      I   File table. */
/*     NFT        I   Number of entries in the file table. */
/*     UTCST, */
/*     UTHAN, */
/*     UTLCK, */
/*     UTLUN     I/O  Unit table. */
/*     NUT       I/O  Number of entries in the unit table. */
/*     EXISTS     O   Logical indicating if FNAME exists. */
/*     OPENED     O   Logical indicating if FNAME is opened. */
/*     HANDLE     O   Handle associated with FNAME. */
/*     FOUND      O   Logical indicating if FNAME's HANDLE was found. */
/*     MNM        O   Unique DP (Magic NuMber) associated with FNAME. */

/* $ Detailed_Input */

/*     FNAME      is the name of the file to locate in the file table. */

/*     FTABS, */
/*     FTAMH, */
/*     FTARC, */
/*     FTBFF, */
/*     FTHAN, */
/*     FTNAM, */
/*     FTRTM, */
/*     FTMNM      are the arrays respectively containing the absolute */
/*                value of the handle, access method, architecture, */
/*                binary file format, handle, name, RTRIM and */
/*                magic number columns of the file table. */

/*     NFT        is the number of entries in the file table. */

/*     UTCST, */
/*     UTHAN, */
/*     UTLCK, */
/*     UTLUN      are the arrays respectively containing the cost, */
/*                handle, locked, and logical unit columns of the unit */
/*                table. */

/*     NUT        is the number of entries in the unit table. */

/* $ Detailed_Output */

/*     UTCST, */
/*     UTHAN, */
/*     UTLCK, */
/*     UTLUN      are the arrays respectively containing the cost, */
/*                handle, locked, and logical unit columns of the unit */
/*                table.  If ZZDDHF2H requires a logical unit, then */
/*                it will borrow one from the unit table.  Depending */
/*                on the state of the table passed in from the caller */
/*                one of three possible scenarios may occur (Recall */
/*                that 'zero-cost' rows are ones whose units are */
/*                reserved with RESLUN and not currently connected */
/*                to any file.) */

/*                   A 'zero-cost' row exists in the table, in */
/*                   which case the row is used temporarily and */
/*                   may be removed depending on the number of entries */
/*                   in the file table (NFT). */

/*                   The unit table is full (NUT=UTSIZE), in which */
/*                   case the unit with the lowest cost that is not */
/*                   locked to its handle will be disconnected, used, */
/*                   and then returned to the table as a 'zero-cost' */
/*                   row before returning to the caller. */

/*                   The unit table is not full (NUT<UTSIZE) and there */
/*                   are no 'zero-cost' rows.  In this case NUT is */
/*                   temporarily increased by one, and the new row */
/*                   is used.  After this routine no longer requires */
/*                   the unit, depending on the number of entries in */
/*                   the file table (NFT) the row may be left in the */
/*                   table as a 'zero-handle' row or removed entirely. */

/*                In the event an error is signaled, the contents of the */
/*                unit table are placed into a usable state before */
/*                returning to the caller. */

/*     NUT        is the number of entries in the unit table. Since */
/*                this routine borrows a unit from the unit table, which */
/*                may involve allocation of a new unit, this value may */
/*                change. */

/*     EXISTS     is a logical if set to TRUE, indicates that FNAME */
/*                exists.  If FALSE, FNAME does not exist.  In the event */
/*                an exception is signaled the value is undefined. */

/*     OPENED     is a logical if set to TRUE, indicates that FNAME */
/*                is opened and attached to a logical unit.  If FALSE, */
/*                FNAME is not attached to a unit.  In the event an */
/*                exception is signaled the value is undefined. */

/*     HANDLE     is the handle in the file table associated with */
/*                FNAME.  If FOUND is FALSE, then HANDLE is returned as */
/*                0. */

/*     FOUND      is a logical if TRUE indicates that FNAME was found */
/*                in the file table.  If FALSE indicates that it was not */
/*                located. */

/*     MNM        is a unique (enough) DP number -- the Magic NuMber -- */
/*                associated with FNAME computed by this examining the */
/*                file contents. */

/* $ Parameters */

/*     None. */

/* $ Exceptions */

/*     1) If any of the INQUIRE statments this routine performs fail, */
/*        the error SPICE(INQUIREFAILED) is signaled. FOUND is set to */
/*        FALSE and HANDLE to 0. */

/*     2) If the attempt to open FNAME fails, then SPICE(FILEOPENFAILED) */
/*        is signaled. FOUND is set to FALSE, and HANDLE to 0. */

/*     3) If FNAME is determined not to be loaded into the file table */
/*        then FOUND is set to FALSE and HANDLE is set to 0. */

/* $ Files */

/*     If the file named by FNAME is not connected to a logical unit, */
/*     this routine will open it for direct access to complete its */
/*     examination. */

/* $ Particulars */

/*     This routine encapsulates the logic necessary to determine if */
/*     a particular filename names a file already loaded into the */
/*     DAF/DAS handle manager.  If it discovers the file is loaded, */
/*     the routine returns the handle to the caller. */

/* $ Examples */

/*     See ZZDDHFNH for sample usage. */

/* $ Restrictions */

/*     None. */

/* $ Literature_References */

/*     None. */

/* $ Author_and_Institution */

/*     F.S. Turner     (JPL) */
/*     E.D. Wright     (JPL) */
/*     B.V. Semenov    (JPL) */

/* $ Version */

/* -    SPICELIB Version 3.0.0, 26-APR-2012 (BVS) */

/*        Changed calling sequence to include FTMNM and MNM. Change */
/*        algorithm to compute MNM and use it to bypass n^2 INQUIREs */
/*        for files opened for READ access, if possible. */

/* -    SPICELIB Version 2.0.1, 24-APR-2003 (EDW) */

/*        Added MAC-OSX-F77 to the list of platforms */
/*        that require READONLY to read write protected */
/*        kernels. */

/* -    SPICELIB Version 2.0.0, 05-AUG-2002 (FST) */

/*        Bug fix: this module was updated to allow proper loading */
/*        of read-only files on VAX environments. */

/* -    SPICELIB Version 1.0.0, 04-OCT-2001 (FST) */


/* -& */
/* $ Revisions */

/* -    SPICELIB Version 2.0.0, 05-AUG-2002 (FST) */

/*        An OPEN statement that is exercised by this module under */
/*        certain circumstances, failed to pass the non-standard */
/*        READONLY option for the VAX environments.  This had the */
/*        undesirable side-effect of not permitting files available */
/*        only for READ access to be opened. */

/*        This file was promoted from a standard portable module */
/*        to a master file. */

/* -& */

/*     SPICELIB Functions */


/*     Local Variables */


/*     Standard SPICE error handling. */

    if (return_()) {
	return 0;
    } else {
	chkin_("ZZDDHF2H", (ftnlen)8);
    }

/*     First check to see if FNAME is blank.  If so, set FOUND to .FALSE. */
/*     and return.  ZZDDHOPN prevents any blank filenames from being */
/*     loaded into the file table. */

    if (s_cmp(fname, " ", fname_len, (ftnlen)1) == 0) {
	*found = FALSE_;
	*handle = 0;
	*opened = FALSE_;
	*exists = FALSE_;
	chkout_("ZZDDHF2H", (ftnlen)8);
	return 0;
    }

/*     Start by trimming the file name in preparation for the INQUIRE. */

    rchar = rtrim_(fname, fname_len);

/*     Now INQUIRE on the input file FNAME. */

    ioin__1.inerr = 1;
    ioin__1.infilen = rchar;
    ioin__1.infile = fname;
    ioin__1.inex = &locexs;
    ioin__1.inopen = &locopn;
    ioin__1.innum = &unit;
    ioin__1.innamed = 0;
    ioin__1.inname = 0;
    ioin__1.inacc = 0;
    ioin__1.inseq = 0;
    ioin__1.indir = 0;
    ioin__1.infmt = 0;
    ioin__1.inform = 0;
    ioin__1.inunf = 0;
    ioin__1.inrecl = 0;
    ioin__1.innrec = 0;
    ioin__1.inblank = 0;
    iostat = f_inqu(&ioin__1);

/*     Check IOSTAT for failure. */

    if (iostat != 0) {
	*found = FALSE_;
	*handle = 0;
	setmsg_("INQUIRE failed. Value of IOSTAT was #.", (ftnlen)38);
	errint_("#", &iostat, (ftnlen)1);
	sigerr_("SPICE(INQUIREFAILED)", (ftnlen)20);
	chkout_("ZZDDHF2H", (ftnlen)8);
	return 0;
    }

/*     First, set some of the output arguments.  Remember, some */
/*     systems consider non-existant files as open.  Compensate for */
/*     this unusual behavior. */

    *exists = locexs;
    *opened = locopn && *exists;

/*     Now check to see if the file exists.  If it does not, then */
/*     set FOUND to false and HANDLE to 0 as non-existant files */
/*     can not possibly be present in the file table. */

    if (! (*exists)) {
	*found = FALSE_;
	*handle = 0;
	chkout_("ZZDDHF2H", (ftnlen)8);
	return 0;
    }

/*     Now check to see if the file is opened.  If it is, we need to */
/*     determine whether or not the logical unit to which it is */
/*     attached is present in the unit table. */

    if (*opened) {

/*        Since the file is opened, see if we can find its unit */
/*        in the unit table. */

	uindex = isrchi_(&unit, nut, utlun);

/*        When UINDEX is 0, the file is opened, but not by */
/*        the DAF/DAS handle manager.  Set FOUND to FALSE, HANDLE */
/*        to 0, and return to the caller. */

	if (uindex == 0) {
	    *handle = 0;
	    *found = FALSE_;
	    chkout_("ZZDDHF2H", (ftnlen)8);
	    return 0;
	}

/*        If we end up here, then we found UNIT in the unit table. */
/*        Set FOUND to TRUE if the handle associated with UNIT is */
/*        non-zero. */

	*handle = uthan[uindex - 1];
	*found = *handle != 0;
	chkout_("ZZDDHF2H", (ftnlen)8);
	return 0;
    }

/*     At this point, we took action for all simple cases.  Now */
/*     we need to find out if FNAME is one of the files in the */
/*     file table that isn't open.  To determine this, we open FNAME, */
/*     and then INQUIRE on every file in the table.  To do this, we */
/*     need a unit. Get one. */

    zzddhgtu_(utcst, uthan, utlck, utlun, nut, &uindex);
    if (failed_()) {
	*handle = 0;
	*found = FALSE_;
	chkout_("ZZDDHF2H", (ftnlen)8);
	return 0;
    }

/*     Now open the file (which we know exists and isn't open). Since */
/*     we effectively are just borrowing this unit, we are not going to */
/*     set UTHAN or UTCST from the defaults that ZZDDHGTU sets up. */

    o__1.oerr = 1;
    o__1.ounit = utlun[uindex - 1];
    o__1.ofnmlen = rchar;
    o__1.ofnm = fname;
    o__1.orl = 1024;
    o__1.osta = "OLD";
    o__1.oacc = "DIRECT";
    o__1.ofm = 0;
    o__1.oblnk = 0;
    iostat = f_open(&o__1);

/*     Check IOSTAT. */

    if (iostat != 0) {

/*        Since an error has occurred, set FOUND to false and HANDLE */
/*        to 0. */

	*found = FALSE_;
	*handle = 0;

/*        Close the unit and remove it from the unit table. */

	cl__1.cerr = 0;
	cl__1.cunit = utlun[uindex - 1];
	cl__1.csta = 0;
	f_clos(&cl__1);
	zzddhrmu_(&uindex, nft, utcst, uthan, utlck, utlun, nut);

/*        Signal the error and return. */

	setmsg_("Attempt to open file '#' failed. Value of IOSTAT was #.", (
		ftnlen)55);
	errch_("#", fname, (ftnlen)1, fname_len);
	errint_("#", &iostat, (ftnlen)1);
	sigerr_("SPICE(FILEOPENFAILED)", (ftnlen)21);
	chkout_("ZZDDHF2H", (ftnlen)8);
	return 0;
    }

/*     Get a unique enough DP number -- the Magic NuMber (MNM) ;) -- for */
/*     this file. */

    *mnm = zzddhmnm_(&utlun[uindex - 1]);

/*     Now loop through all the files in the file table. Unfortunately */
/*     we have no other choice. */

    i__ = 1;
    *found = FALSE_;
    while(i__ <= *nft && ! (*found)) {

/*        If this file's magic number is non-zero and is different from */
/*        the magic number of the currently checked, opened-for-READ */
/*        file, we will declare that these files are not the same file */
/*        and will skip INQUIRE. In all other cases we will do INQUIRE */
/*        and check UNITs. */

	if (*mnm != 0. && (*mnm != ftmnm[i__ - 1] && ftamh[i__ - 1] == 1)) {

/*           These files are not the same file. Clear IOSTAT and set */
/*           UNIT to not match the UNIT of the input file. */

	    iostat = 0;
	    unit = utlun[uindex - 1] + 1;
	} else {

/*           Do the INQUIRE. ;( */

	    ioin__1.inerr = 1;
	    ioin__1.infilen = ftrtm[i__ - 1];
	    ioin__1.infile = ftnam + (i__ - 1) * ftnam_len;
	    ioin__1.inex = &locexs;
	    ioin__1.inopen = &locopn;
	    ioin__1.innum = &unit;
	    ioin__1.innamed = 0;
	    ioin__1.inname = 0;
	    ioin__1.inacc = 0;
	    ioin__1.inseq = 0;
	    ioin__1.indir = 0;
	    ioin__1.infmt = 0;
	    ioin__1.inform = 0;
	    ioin__1.inunf = 0;
	    ioin__1.inrecl = 0;
	    ioin__1.innrec = 0;
	    ioin__1.inblank = 0;
	    iostat = f_inqu(&ioin__1);
	}

/*        Check IOSTAT. */

	if (iostat != 0) {

/*           Since we have an error condition, set FOUND to FALSE */
/*           and HANDLE to 0. */

	    *found = FALSE_;
	    *handle = 0;

/*           Close the unit and clean up the unit table. */

	    cl__1.cerr = 0;
	    cl__1.cunit = utlun[uindex - 1];
	    cl__1.csta = 0;
	    f_clos(&cl__1);
	    zzddhrmu_(&uindex, nft, utcst, uthan, utlck, utlun, nut);

/*           Signal the error and return. */

	    setmsg_("INQUIRE failed. Value of IOSTAT was #.", (ftnlen)38);
	    errint_("#", &iostat, (ftnlen)1);
	    sigerr_("SPICE(INQUIREFAILED)", (ftnlen)20);
	    chkout_("ZZDDHF2H", (ftnlen)8);
	    return 0;
	}

/*        Now check to see if FILE exists, is currently open. and */
/*        its UNIT matches UTLUN(UINDEX). */

	if (locexs && locopn && unit == utlun[uindex - 1]) {
	    *handle = fthan[i__ - 1];
	    *found = TRUE_;

/*        Otherwise, continue searching. */

	} else {
	    ++i__;
	}
    }

/*     Check to see if we found the file in the file table. */

    if (! (*found)) {
	*handle = 0;
    }

/*     Close the unit and clean up the unit table. */

    cl__1.cerr = 0;
    cl__1.cunit = utlun[uindex - 1];
    cl__1.csta = 0;
    f_clos(&cl__1);
    zzddhrmu_(&uindex, nft, utcst, uthan, utlck, utlun, nut);
    chkout_("ZZDDHF2H", (ftnlen)8);
    return 0;
} /* zzddhf2h_ */
Пример #22
0
/* Subroutine */ int prcomf_0_(int n__, char *file, char *delim, char *
	command, char *error, char *level, ftnlen file_len, ftnlen delim_len, 
	ftnlen command_len, ftnlen error_len, ftnlen level_len)
{
    /* Initialized data */

    static integer nest = 0;

    /* System generated locals */
    integer i__1;
    cilist ci__1;
    cllist cl__1;

    /* Builtin functions */
    integer s_rnge(char *, integer, char *, integer), f_clos(cllist *);
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
    integer s_rsfe(cilist *), do_fio(integer *, char *, ftnlen), e_rsfe(void),
	     i_indx(char *, char *, ftnlen, ftnlen);

    /* Local variables */
    extern logical have_(char *, ftnlen);
    static integer i__, j;
    static char files[80*8];
    static integer units[8];
    extern /* Subroutine */ int lbuild_(char *, integer *, char *, char *, 
	    ftnlen, ftnlen, ftnlen);
    extern integer lastnb_(char *, ftnlen);
    static integer iostat;
    extern /* Subroutine */ int rstbuf_(void), putbuf_(char *, ftnlen), 
	    txtopr_(char *, integer *, ftnlen);


/* $ Abstract */

/*     Keep track of nested command files. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Keywords */

/*     PARSE */

/* $ Declarations */
/* $ Brief_I/O */

/*     VARIABLE  I/O  DESCRIPTION */
/*     --------  ---  --------------------------------------------------- */
/*     FILE       I   Command file. */
/*     DELIM      I   Symbol delimiting the end of a command. */
/*     COMMAND    O   Command read from FILE. */
/*     ERROR      O   Error flag. */
/*     LEVEL      O   A list of all files currently open. */

/* $ Detailed_Input */

/*     FILE       is the name of a file from which a sequence of commands */
/*                is to be read. These commands may include commands to */
/*                read from other files. */

/*     DELIM      is the character which delimits the end of each */
/*                instruction in FILE. */

/* $ Detailed_Output */

/*     COMMAND    is a command read from the current file. */
/*                If no files are currently open, COMMAND = DELIM. */

/*     ERROR      is a descriptive error message, which is blank when */
/*                no error occurs. */

/*     LEVEL      is a list of the files currently open, in the order */
/*                in which they were opened. It is provided for trace- */
/*                back purposes. */

/* $ Detailed_Description */

/*     PRCOMF opens, reads, and closes sets of (possibly nested) */
/*     command files. For example, consider the following command */
/*     files. */

/*        FILE_A : A1             FILE_B : B1               FILE_C : C1 */
/*                 A2                      START FILE_C              C2 */
/*                 A3                      B2                        C3 */
/*                 START FILE_B            B3 */
/*                 A4                      B4 */
/*                 A5 */

/*     If the command 'START FILE_A' were issued, we would expect the */
/*     following sequence of commands to ensue: */

/*        A1, A2, A3, B1, C1, C2, C3, B2, B3, B4, A4, A5. */

/*     The first file immediately becomes, ipso facto, the current file. */
/*     Subsequently, instructions are read from the current file until */
/*     either a START or the end of the file is encountered. Each time */
/*     a new START is encountered, the current file (that is, the */
/*     location of the next command in the file) is placed on a stack, */
/*     and the first command is read from the new file (which then */
/*     becomes the current file). Each time the end of the current file */
/*     is encountered, the previous file is popped off the top of the */
/*     stack to become the current file. This continues until there are */
/*     no files remaining on the stack. */

/*     On occasion, the user may wish to exit from a file without */
/*     reading the rest of the file. In this case, the previous file */
/*     is popped off the stack without further ado. */

/*     Also, the user may wish to abruptly stop an entire nested */
/*     set of files. In this case, all of the files are popped off */
/*     the stack, and no further commands are returned. */

/*     PRCOMF and its entry points may be used to process any such */
/*     set of files. These entry points are: */

/*        - PRCLR ( ERROR ) */

/*          This clears the stack. It may thus be used to implement */
/*          a STOP command. In any case, it must be called before */
/*          any of the other entry points are called. */

/*        - PRSTRT ( FILE, ERROR ) */

/*          This introduces a new file, causing the current file (if */
/*          any) to be placed on the stack, and replacing it with FILE. */
/*          It may thus be used to implement a START command. */

/*          If the file cannot be opened, or the stack is already */
/*          full (it can hold up to seven files), ERROR will contain */
/*          a descriptive error message upon return. Otherwise, it */
/*          will be blank. */

/*        - PRREAD ( COMMAND ) */

/*          This causes the next command to be read from the current */
/*          file. If the end of the current file is reached, the */
/*          previous file is popped off the stack, and the next command */
/*          from this file is read instead. (If no files remain to be */
/*          read, DELIM is returned.) */

/*        - PREXIT */

/*          This causes the previous file to be popped off the top of */
/*          the stack to replace the current file. It may thus be used */
/*          to implement an EXIT command. */

/*        - PRTRCE ( LEVEL ) */

/*          Should an error occur during the execution of a nested */
/*          file, it may be helpful to know the sequence in which */
/*          the nested files were invoked. PRTRCE returns a list of */
/*          the files currently open, in the order in which they were */
/*          invoked. */

/* $ Input_Files */

/*     All files read by PRCOMF are opened with logical units */
/*     determined at run time. */

/* $ Output_Files */

/*     None. */

/* $ Input_Common */

/*     None. */

/* $ Output_Common */

/*     None. */

/* $ Examples */

/*     See Detailed_Description. */

/* $ Restrictions */

/*     The declared length of ERROR should be at least 80, to avoid */
/*     truncationof error messages. */

/* $ Author_and_Institution */

/*     W. L. Taber     (JPL) */
/*     I. M. Underwood (JPL) */

/* $ Version */

/* -     Command Loop Configured Version 1.0.0, 3-MAY-1994 (WLT) */

/*         This is the configured version of the Command Loop */
/*         software as of May 4, 1994 */


/*     Version 1, 6-SEP-1986 */

/* -& */

/*   OPTLIB functions */


/*     Local variables */


/*     NFILES is the maximum number of files that may be open at */
/*     any given time. THus, nesting of procedures is limited to */
/*     a depth of NFILES. */


/*     NEST is the number of files currently open. */


/*     FILES are the names of the files on the stack. UNITS are */
/*     the logical units to which they are connected. */

    switch(n__) {
	case 1: goto L_prclr;
	case 2: goto L_prstrt;
	case 3: goto L_prread;
	case 4: goto L_prexit;
	case 5: goto L_prtrce;
	}

    return 0;

/* $ Procedure PRCLR */


L_prclr:

/* $ Abstract */

/*     Clear the file stack. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Brief_I/O */

/*     None. */

/* $ Detailed_Input */

/*     None. */

/* $ Detailed_Output */

/*     None. */

/* $ Input_Files */

/*     None. */

/* $ Output_Files */

/*     None. */

/* $ Input_Output_Common */

/*     None. */

/* $ Detailed_Description */

/*     Pop all the files off the stack. */

/* $ Examples */

/*     None. */

/* $ Restrictions */

/*     None. */
/* $ Version */

/* -     Command Loop Configured Version 1.0.0, 3-MAY-1994 (WLT) */

/*         This is the configured version of the Command Loop */
/*         software as of May 4, 1994 */

/* - */
    while(nest > 0) {
	cl__1.cerr = 0;
	cl__1.cunit = units[(i__1 = nest - 1) < 8 && 0 <= i__1 ? i__1 : 
		s_rnge("units", i__1, "prcomf_", (ftnlen)326)];
	cl__1.csta = 0;
	f_clos(&cl__1);
	--nest;
    }
    return 0;

/* $ Procedure PRSTRT */


L_prstrt:

/* $ Abstract */

/*     Put the current file on the stack, and replace it with FILE. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Brief_I/O */

/*     VARIABLE  I/O  DESCRIPTION */
/*     --------  ---  --------------------------------------------------- */
/*     FILE       I   New command file. */
/*     ERROR      O   Error flag. */

/* $ Detailed_Input */

/*     FILE       is the new current file from which commands are */
/*                to be read. */

/* $ Detailed_Output */

/*     ERROR      is blank when no error occurs, and otherwise contains */
/*                a descriptive message. Possible errors are: */

/*                     - The stack is full. */

/*                     - FILE could not be opened. */

/* $ Input_Files */

/*     FILE is opened with a logical unit determined at run time. */

/* $ Output_Files */

/*     None. */

/* $ Input_Output_Common */

/*     None. */

/* $ Detailed_Description */

/*     If the stack is full, return an error. Otherwise, try to open */
/*     FILE. If an error occurs, return immediately. Otherwise, put */
/*     the current file on the stack, and increase the nesting level. */

/* $ Examples */

/*     None. */

/* $ Restrictions */

/*     None. */

/* $ Version */

/* -     Command Loop Configured Version 1.0.0, 3-MAY-1994 (WLT) */

/*         This is the configured version of the Command Loop */
/*         software as of May 4, 1994 */

/* - */

/*     No error yet. */

    s_copy(error, " ", error_len, (ftnlen)1);

/*     Proceed only if the stack is not full. */

    if (nest == 8) {
	s_copy(error, "PRSTRT: Command files are nested too deeply.", 
		error_len, (ftnlen)44);
	return 0;
    } else {
	++nest;
    }

/*     Get a new logical unit. If none are available, abort. */

    txtopr_(file, &units[(i__1 = nest - 1) < 8 && 0 <= i__1 ? i__1 : s_rnge(
	    "units", i__1, "prcomf_", (ftnlen)445)], file_len);
    if (have_(error, error_len)) {
	--nest;
    } else {
	s_copy(files + ((i__1 = nest - 1) < 8 && 0 <= i__1 ? i__1 : s_rnge(
		"files", i__1, "prcomf_", (ftnlen)450)) * 80, file, (ftnlen)
		80, file_len);
    }
    return 0;

/* $ Procedure PRREAD */


L_prread:

/* $ Abstract */

/*     Read the next command from the current file. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Brief_I/O */

/*     VARIABLE  I/O  DESCRIPTION */
/*     --------  ---  --------------------------------------------------- */
/*     DELIM      I   Character delimiting the end of a command. */
/*     COMMAND    O   Next command from the current file. */

/* $ Detailed_Input */

/*     DELIM      is the character used to delimit the end of a */
/*                command within a command file. */

/* $ Detailed_Output */

/*     COMMAND    is the next command read from the current file. */
/*                If there is no current file, COMMND = DELIM. */

/* $ Input_Files */

/*     All files read by PRCOMF are opened with logical units */
/*     determined at run time. */

/* $ Output_Files */

/*     None. */

/* $ Input_Output_Common */

/*     None. */

/* $ Detailed_Description */

/*     Attempt to read the next statement from the current file. */
/*     If the end of the file is encountered, pop the previous file */
/*     off the top of the stack, and try to read from it. Keep this */
/*     up until a command is read, or until no files remain open. */


/* $ Examples */

/*     None. */

/* $ Restrictions */

/*     None. */

/* $ Version */

/* -     Command Loop Configured Version 1.0.0, 3-MAY-1994 (WLT) */

/*         This is the configured version of the Command Loop */
/*         software as of May 4, 1994 */

/* - */

/*     Don't even bother unless at least one file is open. */

    if (nest == 0) {
	s_copy(command, delim, command_len, (ftnlen)1);
	return 0;
    }

/*     Keep trying to read until we run out of files. */

    ci__1.cierr = 1;
    ci__1.ciend = 1;
    ci__1.ciunit = units[(i__1 = nest - 1) < 8 && 0 <= i__1 ? i__1 : s_rnge(
	    "units", i__1, "prcomf_", (ftnlen)558)];
    ci__1.cifmt = "(A)";
    iostat = s_rsfe(&ci__1);
    if (iostat != 0) {
	goto L100001;
    }
    iostat = do_fio(&c__1, command, command_len);
    if (iostat != 0) {
	goto L100001;
    }
    iostat = e_rsfe();
L100001:
    while(iostat != 0 && nest > 0) {
	cl__1.cerr = 0;
	cl__1.cunit = units[(i__1 = nest - 1) < 8 && 0 <= i__1 ? i__1 : 
		s_rnge("units", i__1, "prcomf_", (ftnlen)562)];
	cl__1.csta = 0;
	f_clos(&cl__1);
	--nest;
	if (nest >= 1) {
	    ci__1.cierr = 1;
	    ci__1.ciend = 1;
	    ci__1.ciunit = units[(i__1 = nest - 1) < 8 && 0 <= i__1 ? i__1 : 
		    s_rnge("units", i__1, "prcomf_", (ftnlen)566)];
	    ci__1.cifmt = "(A)";
	    iostat = s_rsfe(&ci__1);
	    if (iostat != 0) {
		goto L100002;
	    }
	    iostat = do_fio(&c__1, command, command_len);
	    if (iostat != 0) {
		goto L100002;
	    }
	    iostat = e_rsfe();
L100002:
	    ;
	}
    }
    rstbuf_();
    if (nest == 0) {
	s_copy(command, delim, command_len, (ftnlen)1);
	putbuf_(command, command_len);
	return 0;
    }
    putbuf_(command, command_len);

/*     Okay, we have something. Keep reading until DELIM is found. */
/*     (Or until the file ends.) Add each successive line read to */
/*     the end of COMMAND. Do not return the delimiter itself. */

    j = 1;
    i__ = i_indx(command, delim, command_len, (ftnlen)1);
    while(i__ == 0 && iostat == 0) {
	j = lastnb_(command, command_len) + 1;
	*(unsigned char *)&command[j - 1] = ' ';
	++j;
	ci__1.cierr = 1;
	ci__1.ciend = 1;
	ci__1.ciunit = units[(i__1 = nest - 1) < 8 && 0 <= i__1 ? i__1 : 
		s_rnge("units", i__1, "prcomf_", (ftnlen)597)];
	ci__1.cifmt = "(A)";
	iostat = s_rsfe(&ci__1);
	if (iostat != 0) {
	    goto L100003;
	}
	iostat = do_fio(&c__1, command + (j - 1), command_len - (j - 1));
	if (iostat != 0) {
	    goto L100003;
	}
	iostat = e_rsfe();
L100003:
	putbuf_(command + (j - 1), command_len - (j - 1));
	i__ = i_indx(command, delim, command_len, (ftnlen)1);
    }
    if (i__ > 0) {
	s_copy(command + (i__ - 1), " ", command_len - (i__ - 1), (ftnlen)1);
    }
    return 0;

/* $ Procedure PREXIT */


L_prexit:

/* $ Abstract */

/*     Replace the current file with the one at the top of the stack. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Brief_I/O */

/*     None. */

/* $ Detailed_Input */

/*     None. */

/* $ Detailed_Output */

/*     None. */

/* $ Input_Files */

/*     None. */

/* $ Output_Files */

/*     None. */

/* $ Input_Output_Common */

/*     None. */

/* $ Detailed_Description */

/*     Close the current file. Pop the previous file off the top of */
/*     the stack. If there is no current file, of if there are no */
/*     files on the stack, that's cool too. */

/* $ Examples */

/*     None. */

/* $ Restrictions */

/*     None. */
/* $ Version */

/* -     Command Loop Configured Version 1.0.0, 3-MAY-1994 (WLT) */

/*         This is the configured version of the Command Loop */
/*         software as of May 4, 1994 */

/* - */
    if (nest > 0) {
	cl__1.cerr = 0;
	cl__1.cunit = units[(i__1 = nest - 1) < 8 && 0 <= i__1 ? i__1 : 
		s_rnge("units", i__1, "prcomf_", (ftnlen)695)];
	cl__1.csta = 0;
	f_clos(&cl__1);
	--nest;
    }
    return 0;

/* $ Procedure PRTRCE */


L_prtrce:

/* $ Abstract */

/*     Provide a list of the files currently open, in the order in */
/*     which they were opened. */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Brief_I/O */

/*     VARIABLE  I/O  DESCRIPTION */
/*     --------  ---  --------------------------------------------------- */
/*     LEVEL      O   List of all files currently open. */

/* $ Detailed_Input */

/*     None. */

/* $ Detailed_Output */

/*     LEVEL      A list of all files that are currently open, in */
/*                the order in which they were opened. For example, */
/*                if FILE_A starts FILE_B, and FILE_B starts FILE_C, */
/*                LEVEL would be 'FILE_A:FILE_B:_FILE_C'. */

/* $ Input_Files */

/*     None. */

/* $ Output_Files */

/*     None. */

/* $ Input_Output_Common */

/*     None. */

/* $ Detailed_Description */

/*     Just step through the stack, Jack. */

/* $ Examples */

/*     See Detailed_Description. */

/* $ Restrictions */

/*     LEVEL should be declared to be at least CHARACTER*640 by the */
/*     calling program to ensure that enough space is available to */
/*     list all open files. */
/* $ Version */

/* -     Command Loop Configured Version 1.0.0, 3-MAY-1994 (WLT) */

/*         This is the configured version of the Command Loop */
/*         software as of May 4, 1994 */

/* - */

/*     Not much to explain. Use LBUILD to build a list, delimited */
/*     by colons. */

    s_copy(level, " ", level_len, (ftnlen)1);
    if (nest > 0) {
	lbuild_(files, &nest, ":", level, (ftnlen)80, (ftnlen)1, level_len);
    }
    return 0;
} /* prcomf_ */
Пример #23
0
/*<       subroutine timeloop >*/
/* Subroutine */ int timeloop_(void)
{
    /* System generated locals */
    doublereal d__1, d__2;
    olist o__1;
    cllist cl__1;

    /* Builtin functions */
    integer f_open(olist *), s_wsle(cilist *), do_lio(integer *, integer *, 
	    char *, ftnlen), e_wsle(void), f_clos(cllist *);

    /* Local variables */
    doublereal time, y[2];
    extern /* Subroutine */ int adv_rk2__(doublereal *, integer *, doublereal 
	    *, doublereal *, doublereal *, doublereal *);
    doublereal scratch1[2], scratch2[2];

    /* Fortran I/O blocks */
    static cilist io___20 = { 0, 21, 0, 0, 0 };


/*<       integer n >*/
/*<       parameter (n=2) >*/
/*<       real*8 time, y(n), scratch1(n), scratch2(n) >*/
/*<       real*8 m, b, c, A, w, y0, tstop, dt >*/
/*<       character func*20 >*/
/*<       common /data/ m, b, c, A, w, y0, tstop, dt, func >*/
/*      write(*,*) 'timeloop', ' m=', m, ' b=', b, ' c=', c, ' A=', A, */
/*     >           ' w=', w, ' y0=', y0, ' tstop=', tstop, ' dt=', dt, */
/*     >           ' c-term function:', func */
/*     initial conditions: */
/*<       y(1) = y0 >*/
#line 106 "oscillator.f"
    y[0] = data_1.y0;
/*<       y(2) = 0.0 >*/
#line 107 "oscillator.f"
    y[1] = 0.f;
/*<       open(21, FILE='sim.dat', status='unknown', form='formatted') >*/
#line 109 "oscillator.f"
    o__1.oerr = 0;
#line 109 "oscillator.f"
    o__1.ounit = 21;
#line 109 "oscillator.f"
    o__1.ofnmlen = 7;
#line 109 "oscillator.f"
    o__1.ofnm = "sim.dat";
#line 109 "oscillator.f"
    o__1.orl = 0;
#line 109 "oscillator.f"
    o__1.osta = "unknown";
#line 109 "oscillator.f"
    o__1.oacc = 0;
#line 109 "oscillator.f"
    o__1.ofm = "formatted";
#line 109 "oscillator.f"
    o__1.oblnk = 0;
#line 109 "oscillator.f"
    f_open(&o__1);
/*<       do 10 time = 0.0, tstop, dt >*/
#line 110 "oscillator.f"
    d__1 = data_1.tstop;
#line 110 "oscillator.f"
    d__2 = data_1.dt;
#line 110 "oscillator.f"
    for (time = 0.; d__2 < 0 ? time >= d__1 : time <= d__1; time += d__2) {
/*         call adv_fe (y, n, time, dt, scratch1) */
/*<          call adv_rk2 (y, n, time, dt, scratch1, scratch2) >*/
#line 112 "oscillator.f"
	adv_rk2__(y, &c__2, &time, &data_1.dt, scratch1, scratch2);
/*<          write(21,*) time, y(1) >*/
#line 113 "oscillator.f"
	s_wsle(&io___20);
#line 113 "oscillator.f"
	do_lio(&c__5, &c__1, (char *)&time, (ftnlen)sizeof(doublereal));
#line 113 "oscillator.f"
	do_lio(&c__5, &c__1, (char *)&y[0], (ftnlen)sizeof(doublereal));
#line 113 "oscillator.f"
	e_wsle();
/*<  10   continue >*/
#line 114 "oscillator.f"
/* L10: */
#line 114 "oscillator.f"
    }
/*<       close(21) >*/
#line 115 "oscillator.f"
    cl__1.cerr = 0;
#line 115 "oscillator.f"
    cl__1.cunit = 21;
#line 115 "oscillator.f"
    cl__1.csta = 0;
#line 115 "oscillator.f"
    f_clos(&cl__1);
/*<       return >*/
#line 116 "oscillator.f"
    return 0;
/*<       end >*/
} /* timeloop_ */
Пример #24
0
/* $Procedure DAFB2A ( DAF, binary to ASCII ) */
/* Subroutine */ int dafb2a_(char *binary, char *ascii, ftnlen binary_len, 
	ftnlen ascii_len)
{
    /* System generated locals */
    cllist cl__1;

    /* Builtin functions */
    integer f_clos(cllist *);

    /* Local variables */
    integer unit;
    extern /* Subroutine */ int chkin_(char *, ftnlen), dafb2t_(char *, 
	    integer *, ftnlen);
    extern logical failed_(void);
    extern /* Subroutine */ int chkout_(char *, ftnlen);
    extern logical return_(void);
    extern /* Subroutine */ int txtopn_(char *, integer *, ftnlen);

/* $ Abstract */

/*     Convert a binary DAF to an equivalent ASCII (text) DAF. */
/*     (Obsolete, maintained for backward compatibility only.) */

/* $ Disclaimer */

/*     THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
/*     CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
/*     GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
/*     ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
/*     PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
/*     TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
/*     WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
/*     PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
/*     SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
/*     SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */

/*     IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
/*     BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
/*     LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
/*     INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
/*     REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
/*     REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */

/*     RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
/*     THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
/*     CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
/*     ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */

/* $ Required_Reading */

/*     DAF */

/* $ Keywords */

/*     FILES */

/* $ Declarations */
/* $ Brief_I/O */

/*     Variable  I/O  Description */
/*     --------  ---  -------------------------------------------------- */
/*     BINARY     I   Name of an existing binary DAF. */
/*     ASCII      I   Name of an ASCII (text) DAF to be created. */

/* $ Detailed_Input */

/*     BINARY      is the name of an existing binary DAF. */

/*     ASCII       is the name of an ASCII (text) DAF to be created. */
/*                 The ASCII file contains the same data as the binary */
/*                 file, but in a form more suitable for transfer */
/*                 between heterogeneous computing environments. */

/* $ Detailed_Output */

/*     None. */

/* $ Parameters */

/*      None. */

/* $ Files */

/*     See arguments BINARY, ASCII. */

/* $ Exceptions */

/*     None. */

/*     Errors are detected and signalled by routines called by this */
/*     routine. */

/* $ Particulars */

/*     This routine has been made obsolete by the new DAF binary to text */
/*     conversion routine DAFBT. This routine remains available for */
/*     reasons of backward compatibility. We strongly recommend that the */
/*     conversion routine DAFBT be used for any new software development. */
/*     Please see the header of the routine DAFBT for details. */

/*     Note that the contents of reserved records in the binary file */
/*     are not stored in the ASCII file. */

/* $ Examples */

/*     DAFB2A and DAFA2B are typically used to transfer files. */
/*     If file A.DAF is a binary DAF in environment 1, it can be */
/*     transferred to environment 2 in three steps. */

/*        1) Convert it to ASCII, */

/*              CALL DAFB2A ( 'A.DAF', 'A.ASCII' ) */

/*        2) Transfer the ASCII file, using FTP, Kermit, or some other */
/*           file transfer utility, */

/*              ftp> put a.ascii */

/*        3) Convert it to binary on the new machine, */

/*              CALL DAFA2B ( 'A.ASCII', 'A.DAF', RESV ) */

/*     Note that DAFB2A and DAFA2B work in any standard Fortran-77 */
/*     environment. */

/* $ Restrictions */

/*     None. */

/* $ Literature_References */

/*     NAIF Document 167.0, "Double Precision Array Files (DAF) */
/*     Specification and User's Guide" */

/* $ Author_and_Institution */

/*     K.R. Gehringer  (JPL) */
/*     I.M. Underwood  (JPL) */

/* $ Version */

/* -    SPICELIB Version 2.1.0, 18-JUN-1999 (WLT) */

/*        Fixed call to CHKOUT with wrong name. */

/* -    SPICELIB Version 2.0.0, 04-OCT-1993 (KRG) */

/*        This routine was completely rewritten to make use of the */
/*        routines DAFB2T and TXTOPN, for converting a text file to */
/*        binary and opening a text file. It now simply calls the */
/*        routine DAFT2B after opening the text file with TXTOPN. */

/*        Added a statement to the $ Particulars section to the effect */
/*        that this routine has been made obsolete by the introduction of */
/*        the routine DAFBT, and that we strongly recommend the use of */
/*        the new routine. */

/*        Modified the $ Abstract section to reflect the fact that this */
/*        routine is obsolete. */

/* -    SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */

/*        Comment section for permuted index source lines was added */
/*        following the header. */

/* -    SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */

/*        Literature references added to the header. */

/* -    SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */

/* -& */
/* $ Index_Entries */

/*     binary daf to ascii */

/* -& */
/* $ Revisions */

/* -    SPICELIB Version 2.0.0, 04-OCT-1993 (KRG) */

/*        This routine was completely rewritten to make use of the */
/*        routines DAFB2T and TXTOPN, for converting a text file to */
/*        binary and opening a text file. It now simply calls the */
/*        routine DAFT2B after opening the text file with TXTOPN. */

/*        Added a statement to the $ Particulars section to the effect */
/*        that this routine has been made obsolete by the introduction of */
/*        the routine DAFBT, and that we strongly recommend the use of */
/*        the new routine. */

/*        Modified the $ Abstract section to reflect the fact that this */
/*        routine is obsolete. */

/* -    SPICELIB Version 1.0.2, 10-MAR-1992 (WLT) */

/*        Comment section for permuted index source lines was added */
/*        following the header. */

/* -    SPICELIB Version 1.0.1, 22-MAR-1990 (HAN) */

/*        Literature references added to the header. */

/* -    SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) */

/* -& */

/*     SPICELIB functions */


/*     Local variables */


/*     Standard SPICE error handling. */

    if (return_()) {
	return 0;
    } else {
	chkin_("DAFB2A", (ftnlen)6);
    }

/*     Open the ASCII file for writing. If an error occurs, then check */
/*     out and return. An appropriate error message will have already */
/*     been set. */

    txtopn_(ascii, &unit, ascii_len);
    if (failed_()) {
	chkout_("DAFB2A", (ftnlen)6);
	return 0;
    }

/*     Attempt to perform the file conversion. If it fails, close the */
/*     text file with STATUS = 'DELETE', check out and return, as an */
/*     appropriate error message should have already been set. */

    dafb2t_(binary, &unit, binary_len);
    if (failed_()) {
	cl__1.cerr = 0;
	cl__1.cunit = unit;
	cl__1.csta = "DELETE";
	f_clos(&cl__1);
	chkout_("DAFB2A", (ftnlen)6);
	return 0;
    }

/*     Close the text file. */

    cl__1.cerr = 0;
    cl__1.cunit = unit;
    cl__1.csta = 0;
    f_clos(&cl__1);
    chkout_("DAFB2A", (ftnlen)6);
    return 0;
} /* dafb2a_ */
Пример #25
0
/* ========================IDENTIFICATION DIVISION================================ */
/* Subroutine */ int check_(void)
{
    /* Format strings */
    static char fmt_200[] = "(7(e13.5,\002 \002))";

    /* System generated locals */
    olist o__1;
    cllist cl__1;

    /* Builtin functions */
    integer f_open(olist *), s_wsfe(cilist *), do_fio(integer *, char *, 
	    ftnlen), e_wsfe(void), f_clos(cllist *);

    /* Fortran I/O blocks */
    static cilist io___1 = { 0, 3, 0, fmt_200, 0 };


/* ----------REMARKS. */
/*     This is an interface subroutine, */
/*     a flexible module which allows user to manipulate physical quantities */
/*     of interest at certain key points during the computer run. */
/*     Included within this subroutine is a roster of all global variables */
/*     and their respective COMMON areas. */
/*     Current instructions accumulate abundances of deuterium, helium-3, */
/*     helium-4, and lithium-7 for eventual plotting, taking into account */
/*     the contribution of beryllium-7 to lithium-7 and tritium to helium-3. */
/* ----------PARAMETERS. */
/* Number of nuclear reactions. */
/* Number of variables to be evolved. */
/* Number of nuclides in calculation. */
/* ----------COMMON AREAS. */
/* Maximum # of lines to be printed. */
/* Reaction parameter */
/* Reaction parameter */
/* Reaction rates. */
/* Evolution paramete */
/* Evolution paramete */
/* Evolution paramete */
/* Default comp param */
/* Computation parame */
/* Default model para */
/* Model parameters. */
/* Default variationl */
/* Variational parame */
/* Time variables. */
/* Dynamic variables. */
/* Energy densities. */
/* Linear eqn coeffi */
/* Nuclide data. */
/* Eval function bl */
/* Eval function bm(z */
/* Eval function bn(z */
/* Coefficients K. */
/* Flags,counters. */
/* Computation locati */
/* Output data. */
/* Neutrino parameter */
/* Run options. */
/* ==========================DECLARATION DIVISION================================= */
/* ----------REACTION PARAMETER VALUES. */
/* Output option. */
/* ----------REACTION PARAMETER NAMES. */
/* Reaction parameters. */
/* Reaction type code (1-11). */
/* Incoming nuclide type (1-26). */
/* Incoming light nuclide type (1-6). */
/* Outgoing light nuclide type (1-6). */
/* Outgoing nuclide type (1-26). */
/* Reverse reaction coefficient. */
/* ----------REACTION RATES. */
/* Energy released in reaction (in 10** */
/* Forward reaction rate coefficients. */
/* ----------EVOLUTION PARAMETERS. */
/* Reverse reaction rate coefficients. */
/* Temperature of photons (units of 10* */
/* Defined by hv = M(atomic)n(baryon)/t */
/* Chemical potential of electron. */
/* ----------EVOLUTION PARAMETERS (DERIVATIVES). */
/* Relative number abundances. */
/* Change in temperature. */
/* Change in hv. */
/* Change in chemical potential. */
/* ----------EVOLUTION PARAMETERS (ORIGINAL VALUES). */
/* Change in relative number abundances */
/* ----------DEFAULT COMPUTATION PARAMETERS. */
/* Rel # abundances at end of 1st R-K l */
/* Default cy. */
/* Default ct. */
/* Default t9i. */
/* Default t9f. */
/* Default ytmin. */
/* ----------COMPUTATION PARAMETERS. */
/* Default accumulation increment. */
/* Time step limiting constant on abund */
/* Time step limiting constant on tempe */
/* Initial temperature (in 10**9 K). */
/* Final temperature (in 10**9 K). */
/* Smallest abundances allowed. */
/* ----------DEFAULT MODEL PARAMETERS. */
/* Accumulation increment. */
/* Default c. */
/* Default cosmological constant. */
/* ----------EARLY UNIVERSE MODEL PARAMETERS. */
/* Default neutrino degeneracy paramete */
/* Gravitational constant. */
/* Neutron lifetime (sec). */
/* Number of neutrino species. */
/* c(1) is variation of gravitational c */
/* c(2) is neutron half-life (min). */
/* c(3) is number of neutrino species. */
/* Cosmological constant. */
/* Neutrino degeneracy parameters. */
/* xi(1) is e neutrino degeneracy param */
/* xi(2) is m neutrino degeneracy param */
/* xi(3) is t neutrino degeneracy param */
/* ----------DEFAULT VARIATIONAL PARAMETERS. */
/* Fierz parameter */
/* Default initial time step. */
/* ----------VARIATIONAL PARAMETERS. */
/* Default baryon-to-photon ratio. */
/* Initial time step. */
/* ----------TIME VARIABLES. */
/* Baryon-to-photon ratio. */
/* Time. */
/* Time step. */
/* ----------DYNAMIC VARIABLES. */
/* (1/t9)*d(t9)/d(t). */
/* Thermodynamic variables (energy dens */
/* ----------ENERGY DENSITIES. */
/* Expansion rate of the universe. */
/* Initial electron neutrino energy den */
/* Initial baryon energy density. */
/* Baryon energy density. */
/* ----------MATRIX COEFFICIENTS FOR LINEAR EQUATION. */
/* Baryon energy density (ratio to init */
/* Relates y(t+dt) to y(t). */
/* Contains y0 in inverse order. */
/* ----------NUCLIDE DATA. */
/* yy in reverse order. */
/* Atomic number of nuclide. */
/* Charge of nuclide. */
/* ----------EVALUATION OF FUNCTIONS bl,bm,bn. */
/* Mass excess of nuclide. */
/* Evaluation of function bl(z). */
/* Evaluation of function bm(z). */
/* ----------EVALUATION OF MODIFIED BESSEL FUNCTIONS. */
/* Evaluation of function bn(z). */
/* ----------FLAGS AND COUNTERS. */
/* Values k0(r),k1(r),k2(r),k3(r),k4(r) */
/* Indicates if output buffer printed. */
/* # total iterations for particular mo */
/* # iterations after outputing a line. */
/* # times accumulated in output buffer */
/* ----------COMPUTATION LOCATION. */
/* Indicates if gaussian elimination fa */
/* ----------OUTPUT ARRAYS. */
/* Time check. */
/* Nuclide mass fractions. */
/* Thermodynamic variables. */
/* Temperature (in units of 10**9 K). */
/* Time. */
/* Time step. */
/* Baryon to photon ratio. */
/* ----------NEUTRINO PARAMETERS. */
/* Expansion rate. */
/* Temperature (in units of MeV). */
/* Neutrino temperature (in units of Me */
/* Neutrino temperature. */
/* Normalizing constant. */
/* Neutrino energy density. */
/* ----------RUN OPTION. */
/* Type of neutrino. */
/* Run network size. */
/* Number of nuclides in computation. */
/* ----------OUTPUT FILE STATUS. */
/* Number of reactions in computation. */
/* Number of output requests. */
/* ===========================PROCEDURE DIVISION================================== */
/* 10--------OPEN FILE------------------------------------------------------------ */
/* Indicates if output file used. */
    if (checkcb_1.itime == 1) {
/* Beginning of program. */
	o__1.oerr = 0;
	o__1.ounit = 3;
	o__1.ofnmlen = 10;
	o__1.ofnm = "newint.dat";
	o__1.orl = 0;
	o__1.osta = "new";
	o__1.oacc = 0;
	o__1.ofm = 0;
	o__1.oblnk = 0;
	f_open(&o__1);
    }
/* 20--------WRITE INTO FILE------------------------------------------------------ */
    if (checkcb_1.itime == 8) {
/* Right after a run. */
	outdat_1.xout[flags_1.it + 279] += outdat_1.xout[flags_1.it + 319];
/* Add beryllium to lithium. */
	outdat_1.xout[flags_1.it + 159] += outdat_1.xout[flags_1.it + 119];
/* Add tritium to helium-3. */
	outdat_1.xout[flags_1.it + 199] += -3e-4f;
/* my correction for fitted rates+coarse steps */
	s_wsfe(&io___1);
	do_fio(&c__1, (char *)&modpr_1.c__[2], (ftnlen)sizeof(real));
	do_fio(&c__1, (char *)&modpr_1.c__[1], (ftnlen)sizeof(real));
	do_fio(&c__1, (char *)&outdat_1.etaout[flags_1.it - 1], (ftnlen)
		sizeof(real));
	do_fio(&c__1, (char *)&outdat_1.xout[flags_1.it + 79], (ftnlen)sizeof(
		real));
	do_fio(&c__1, (char *)&outdat_1.xout[flags_1.it + 159], (ftnlen)
		sizeof(real));
	do_fio(&c__1, (char *)&outdat_1.xout[flags_1.it + 199], (ftnlen)
		sizeof(real));
	do_fio(&c__1, (char *)&outdat_1.xout[flags_1.it + 279], (ftnlen)
		sizeof(real));
	e_wsfe();
/* Output N_nu, tau_n, eta, H2, He3, He4, an */
    }
/* 30--------CLOSE FILE----------------------------------------------------------- */
    if (checkcb_1.itime == 10) {
/* End of program. */
	cl__1.cerr = 0;
	cl__1.cunit = 3;
	cl__1.csta = 0;
	f_clos(&cl__1);
    }
    return 0;
/* ----------REFERENCES----------------------------------------------------------- */
/*     1) D.A. Dicus, E.W. Kolb, A.M. Gleeson, E.C.G. Sudarshan, V.L. Teplitz, */
/*        M.S. Turner, Phys. Rev. D26 (1982) 2694. (Rad corr, Coulomb Corr) */
/*     2) D. Seckel, Bartol preprint BA-93-16; G. Guyk and M.S. Turner, */
/*         FERMILAB preprint FERMILAB-Pub-93/181-A. (Nucleon mass) */
/*     4) S. Dodelson and M.S. Turner, Phys. Rev. D46 (1992) 3372; B. Fields, */
/*         S. Dodelson and M.S. Turner, Phys. Rev. D47 (1993) 4309. (Nu heating) */
/*     5) S. Sarkar, Rep. Prog Phys. 59 (1996) 1493 (review) */
} /* check_ */