/* dfpsav.f -- translated by f2c (version 19950314).
   You must link the resulting object file with the libraries:
	-lF77 -lI77 -lm   (in that order)
*/

#include "f2c.h"

/* Common Block Declarations */

struct {
    char argz[512];
} argz_;

#define argz_1 argz_

struct {
    char keywrd[80];
} keywrd_;

#define keywrd_1 keywrd_

struct {
    char koment[80], title[80];
} titles_;

#define titles_1 titles_

struct {
    doublereal grad[258], gnorm;
} gradnt_;

#define gradnt_1 gradnt_

struct {
    integer nvar, loc[516]	/* was [2][258] */, idumy;
    doublereal dumy[258];
} geovar_;

#define geovar_1 geovar_

struct {
    doublereal p[23220], pa[23220], pb[23220];
} densty_;

#define densty_1 densty_

struct {
    doublereal alparm[774]	/* was [3][258] */, x0, x1, x2;
    integer iloop;
} alparm_;

#define alparm_1 alparm_

struct {
    doublereal step, geoa[258]	/* was [3][86] */, geovec[258]	/* was [3][86]
	     */, calcst;
} reactn_;

#define reactn_1 reactn_

struct {
    doublereal geo[258]	/* was [3][86] */;
} geom_;

#define geom_1 geom_

struct {
    integer natoms, labels[86], na[86], nb[86], nc[86];
} geokst_;

#define geokst_1 geokst_

struct {
    char elemnt[214];
} elemts_;

#define elemts_1 elemts_

struct {
    integer latom, lparam;
    doublereal react[200];
} path_;

#define path_1 path_

struct {
    integer numat, nat[86], nfirst[86], nmidle[86], nlast[86], norbs, nelecs, 
	    nalpha, nbeta, nclose, nopen, ndumy;
    doublereal fract;
} molkst_;

#define molkst_1 molkst_

struct {
    doublereal hesinv[33411];
} fmatrx_;

#define fmatrx_1 fmatrx_

struct {
    integer ndep, locpar[258], idepfn[258], locdep[258];
} geosym_;

#define geosym_1 geosym_

struct {
    doublereal errfn[258];
} errfn_;

#define errfn_1 errfn_

/* Table of constant values */

static integer c__4 = 4;
static integer c__3 = 3;
static integer c__1 = 1;
static doublereal c_b17 = 1.;
static integer c__9 = 9;

/* Subroutine */ int dfpsav_(doublereal *totime, doublereal *xparam, 
	doublereal *gd, doublereal *xlast, doublereal *funct1, integer *mdfp, 
	doublereal *xdfp)
{
    /* Initialized data */

    static logical first = TRUE_;

    /* System generated locals */
    integer i__1, i__2;
    olist o__1;
    cllist cl__1;
    alist al__1;

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

    /* Local variables */
    static integer ivar, i, j, k;
    static doublereal q[3], x, coord[258]	/* was [3][86] */, degree;
    static integer ir;
    extern /* Subroutine */ int getarg_(integer *, char *, ftnlen);
    static integer linear;
    static logical intxyz;
    extern /* Subroutine */ int xyzint_(doublereal *, integer *, integer *, 
	    integer *, integer *, doublereal *, doublereal *);
    static integer iel1[3];

    /* Fortran I/O blocks */
    static cilist io___4 = { 0, 6, 0, "(//10X,'- - - - - - - TIME UP - - - -"
	    " - - -',//)", 0 };
    static cilist io___5 = { 0, 6, 0, "(//10X,' NO RESTART EXISTS FOR SADDLE"
	    "',//       10X,' HERE IS A DATA-FILE FILES THAT MIGHT BE SUITABL"
	    "E',/       10X,' FOR RESTARTING THE CALCULATION',///)", 0 };
    static cilist io___6 = { 0, 6, 0, "(A)", 0 };
    static cilist io___14 = { 0, 6, 0, "(2X,A2,3(F12.6,I3),I4,2I3)", 0 };
    static cilist io___17 = { 0, 6, 0, "(I4,3(F12.6,I3),I4,2I3)", 0 };
    static cilist io___18 = { 0, 6, 0, "(///10X,'CALCULATION TERMINATED HERE"
	    "')", 0 };
    static cilist io___19 = { 0, 6, 0, "(//10X,' - THE CALCULATION IS BEING "
	    "DUMPED TO DISK',  /10X,'   RESTART IT USING THE MAGIC WORD \"RES"
	    "TART\"')", 0 };
    static cilist io___20 = { 0, 6, 0, "(//10X,'CURRENT VALUE OF HEAT OF FOR"
	    "MATION ='      ,F12.6)", 0 };
    static cilist io___21 = { 0, 6, 0, "(A)", 0 };
    static cilist io___22 = { 0, 6, 0, "(2X,A2,3(F12.6,I3),I4,2I3)", 0 };
    static cilist io___23 = { 0, 6, 0, "(I4,3(F12.6,I3),I4,2I3)", 0 };
    static cilist io___24 = { 0, 6, 0, "(3(I4,','))", 0 };
    static cilist io___25 = { 0, 6, 0, 0, 0 };
    static cilist io___26 = { 0, 0, 0, 0, 0 };
    static cilist io___27 = { 0, 0, 0, 0, 0 };
    static cilist io___28 = { 0, 0, 0, 0, 0 };
    static cilist io___30 = { 0, 0, 0, 0, 0 };
    static cilist io___31 = { 0, 10, 0, 0, 0 };
    static cilist io___32 = { 0, 10, 0, 0, 0 };
    static cilist io___33 = { 0, 0, 0, 0, 0 };
    static cilist io___34 = { 0, 0, 0, 0, 0 };
    static cilist io___35 = { 0, 0, 0, 0, 0 };
    static cilist io___36 = { 0, 6, 0, "(//10X,' RESTORING DATA FROM DISK'/)",
	     0 };
    static cilist io___37 = { 1, 0, 1, 0, 0 };
    static cilist io___38 = { 0, 6, 0, "(10X,'FUNCTION =',F13.6//)", 0 };
    static cilist io___39 = { 0, 0, 0, 0, 0 };
    static cilist io___40 = { 0, 0, 0, 0, 0 };
    static cilist io___41 = { 0, 0, 0, 0, 0 };
    static cilist io___42 = { 0, 10, 0, 0, 0 };
    static cilist io___43 = { 0, 10, 0, 0, 0 };
    static cilist io___44 = { 0, 0, 0, 0, 0 };
    static cilist io___45 = { 0, 0, 0, 0, 0 };
    static cilist io___46 = { 0, 0, 0, 0, 0 };
    static cilist io___47 = { 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  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)  
**/
/*                                                                        
**/
/*                                                                        
**/
/************************************************************************
****/
/*                                                                        
**/
/*  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                               
**/
/************************************************************************
****/
/************************************************************************
****/
/*  FOR SHORT VERSION USE LINE WITH NMECI=1, FOR LONG VERSION USE LINE    
**/
/*  WITH NMECI=10                                                         
**/
/************************************************************************
****/
/*     PARAMETER (NMECI=1,   NPULAY=1) */
/************************************************************************
****/
/* DECK MOPAC */
/* next line added for Unix implementation for command line arguments */

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

/* DFPSAV STORES AND RESTORES DATA USED IN THE D-F-P GEOMETRY */
/*        OPTIMISATION. */

/*  ON INPUT TOTIME = TOTAL CPU TIME ELAPSED DURING THE CALCULATION. */
/*           XPARAM = CURRENT VALUE OF PARAMETERS. */
/*           GD     = OLD GRADIENT. */
/*           XLAST  = OLD VALUE OF PARAMETERS. */
/*           FUNCT1 = CURRENT VALUE OF HEAT OF FORMATION. */
/*           MDFP   = INTEGER CONSTANTS USED IN D-F-P. */
/*           XDFP   = REAL CONSTANTS USED IN D-F-P. */
/*           MDFP(9)= 1 FOR DUMP, 0 FOR RESTORE. */
/* ********************************************************************* 
*/
    /* Parameter adjustments */
    --xdfp;
    --mdfp;
    --xlast;
    --gd;
    --xparam;

    /* Function Body */
    getarg_(&c__4, argz_1.argz, 512L);
    o__1.oerr = 0;
    o__1.ounit = 9;
    o__1.ofnmlen = 512;
    o__1.ofnm = argz_1.argz;
    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);
    getarg_(&c__3, argz_1.argz, 512L);
    o__1.oerr = 0;
    o__1.ounit = 10;
    o__1.ofnmlen = 512;
    o__1.ofnm = argz_1.argz;
    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);
    degree = 57.29577951;
    ir = 9;
    if (mdfp[9] != 0) {
	if (mdfp[9] == 1) {
	    s_wsfe(&io___4);
	    e_wsfe();
	    if (i_indx(keywrd_1.keywrd, "SADDLE", 80L, 6L) != 0) {
		s_wsfe(&io___5);
		e_wsfe();
		s_wsfe(&io___6);
		do_fio(&c__1, keywrd_1.keywrd, 80L);
		do_fio(&c__1, titles_1.koment, 80L);
		do_fio(&c__1, titles_1.title, 80L);
		e_wsfe();
		intxyz = geokst_1.na[0] == 0;
		for (alparm_1.iloop = 1; alparm_1.iloop <= 2; 
			++alparm_1.iloop) {
		    if (intxyz) {
			geom_1.geo[1] = 0.;
			geom_1.geo[2] = 0.;
			geom_1.geo[0] = 0.;
			geom_1.geo[4] = 0.;
			geom_1.geo[5] = 0.;
			geom_1.geo[8] = 0.;
			i__1 = geokst_1.natoms;
			for (i = 1; i <= i__1; ++i) {
			    for (j = 1; j <= 3; ++j) {
/* L10: */
				coord[j + i * 3 - 4] = geom_1.geo[j + i * 3 - 
					4];
			    }
			}
		    } else {
			xyzint_(geom_1.geo, &molkst_1.numat, geokst_1.na, 
				geokst_1.nb, geokst_1.nc, &c_b17, coord);
		    }
		    ivar = 1;
		    geokst_1.na[0] = 0;
		    i__1 = geokst_1.natoms;
		    for (i = 1; i <= i__1; ++i) {
			for (j = 1; j <= 3; ++j) {
/* L20: */
			    iel1[j - 1] = 0;
			}
L30:
			if (geovar_1.loc[(ivar << 1) - 2] == i) {
			    iel1[geovar_1.loc[(ivar << 1) - 1] - 1] = 1;
			    ++ivar;
			    goto L30;
			}
			if (i < 4) {
			    iel1[2] = 0;
			    if (i < 3) {
				iel1[1] = 0;
				if (i < 2) {
				    iel1[0] = 0;
				}
			    }
			}
			if (i == path_1.latom) {
			    iel1[path_1.lparam - 1] = -1;
			}
			q[0] = coord[i * 3 - 3];
			q[1] = coord[i * 3 - 2] * degree;
			q[2] = coord[i * 3 - 1] * degree;
/* L40: */
			s_wsfe(&io___14);
			do_fio(&c__1, elemts_1.elemnt + (geokst_1.labels[i - 
				1] - 1 << 1), 2L);
			for (k = 1; k <= 3; ++k) {
			    do_fio(&c__1, (char *)&q[k - 1], (ftnlen)sizeof(
				    doublereal));
			    do_fio(&c__1, (char *)&iel1[k - 1], (ftnlen)
				    sizeof(integer));
			}
			do_fio(&c__1, (char *)&geokst_1.na[i - 1], (ftnlen)
				sizeof(integer));
			do_fio(&c__1, (char *)&geokst_1.nb[i - 1], (ftnlen)
				sizeof(integer));
			do_fio(&c__1, (char *)&geokst_1.nc[i - 1], (ftnlen)
				sizeof(integer));
			e_wsfe();
		    }
		    i = 0;
		    x = 0.;
		    s_wsfe(&io___17);
		    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
		    do_fio(&c__1, (char *)&x, (ftnlen)sizeof(doublereal));
		    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
		    do_fio(&c__1, (char *)&x, (ftnlen)sizeof(doublereal));
		    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
		    do_fio(&c__1, (char *)&x, (ftnlen)sizeof(doublereal));
		    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
		    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
		    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
		    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
		    e_wsfe();
		    i__1 = geokst_1.natoms;
		    for (i = 1; i <= i__1; ++i) {
			for (j = 1; j <= 3; ++j) {
/* L50: */
			    geom_1.geo[j + i * 3 - 4] = reactn_1.geoa[j + i * 
				    3 - 4];
			}
		    }
		    geokst_1.na[0] = 99;
/* L60: */
		}
		s_wsfe(&io___18);
		e_wsfe();
		s_stop("", 0L);
	    }
	    s_wsfe(&io___19);
	    e_wsfe();
	    s_wsfe(&io___20);
	    do_fio(&c__1, (char *)&(*funct1), (ftnlen)sizeof(doublereal));
	    e_wsfe();
	}
	if (mdfp[9] == 1) {
	    if (geokst_1.na[0] == 99) {

/*  CONVERT FROM CARTESIAN COORDINATES TO INTERNAL */

		i__1 = geokst_1.natoms;
		for (i = 1; i <= i__1; ++i) {
		    for (j = 1; j <= 3; ++j) {
/* L70: */
			coord[j + i * 3 - 4] = geom_1.geo[j + i * 3 - 4];
		    }
		}
		xyzint_(coord, &molkst_1.numat, geokst_1.na, geokst_1.nb, 
			geokst_1.nc, &c_b17, geom_1.geo);
	    }
	    geom_1.geo[1] = 0.;
	    geom_1.geo[2] = 0.;
	    geom_1.geo[0] = 0.;
	    geom_1.geo[4] = 0.;
	    geom_1.geo[5] = 0.;
	    geom_1.geo[8] = 0.;
	    ivar = 1;
	    geokst_1.na[0] = 0;
	    s_wsfe(&io___21);
	    do_fio(&c__1, keywrd_1.keywrd, 80L);
	    do_fio(&c__1, titles_1.koment, 80L);
	    do_fio(&c__1, titles_1.title, 80L);
	    e_wsfe();
	    i__1 = geokst_1.natoms;
	    for (i = 1; i <= i__1; ++i) {
		for (j = 1; j <= 3; ++j) {
/* L80: */
		    iel1[j - 1] = 0;
		}
L90:
		if (geovar_1.loc[(ivar << 1) - 2] == i) {
		    iel1[geovar_1.loc[(ivar << 1) - 1] - 1] = 1;
		    ++ivar;
		    goto L90;
		}
		if (i < 4) {
		    iel1[2] = 0;
		    if (i < 3) {
			iel1[1] = 0;
			if (i < 2) {
			    iel1[0] = 0;
			}
		    }
		}
		if (i == path_1.latom) {
		    iel1[path_1.lparam - 1] = -1;
		}
		q[0] = geom_1.geo[i * 3 - 3];
		q[1] = geom_1.geo[i * 3 - 2] * degree;
		q[2] = geom_1.geo[i * 3 - 1] * degree;
/* L100: */
		s_wsfe(&io___22);
		do_fio(&c__1, elemts_1.elemnt + (geokst_1.labels[i - 1] - 1 <<
			 1), 2L);
		for (k = 1; k <= 3; ++k) {
		    do_fio(&c__1, (char *)&q[k - 1], (ftnlen)sizeof(
			    doublereal));
		    do_fio(&c__1, (char *)&iel1[k - 1], (ftnlen)sizeof(
			    integer));
		}
		do_fio(&c__1, (char *)&geokst_1.na[i - 1], (ftnlen)sizeof(
			integer));
		do_fio(&c__1, (char *)&geokst_1.nb[i - 1], (ftnlen)sizeof(
			integer));
		do_fio(&c__1, (char *)&geokst_1.nc[i - 1], (ftnlen)sizeof(
			integer));
		e_wsfe();
	    }
	    i = 0;
	    x = 0.;
	    s_wsfe(&io___23);
	    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&x, (ftnlen)sizeof(doublereal));
	    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&x, (ftnlen)sizeof(doublereal));
	    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&x, (ftnlen)sizeof(doublereal));
	    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
	    do_fio(&c__1, (char *)&i, (ftnlen)sizeof(integer));
	    e_wsfe();
	    if (geosym_1.ndep != 0) {
		i__1 = geosym_1.ndep;
		for (i = 1; i <= i__1; ++i) {
/* L110: */
		    s_wsfe(&io___24);
		    do_fio(&c__1, (char *)&geosym_1.locpar[i - 1], (ftnlen)
			    sizeof(integer));
		    do_fio(&c__1, (char *)&geosym_1.idepfn[i - 1], (ftnlen)
			    sizeof(integer));
		    do_fio(&c__1, (char *)&geosym_1.locdep[i - 1], (ftnlen)
			    sizeof(integer));
		    e_wsfe();
		}
		s_wsle(&io___25);
		e_wsle();
	    }
	}
	io___26.ciunit = ir;
	s_wsue(&io___26);
	do_uio(&c__9, (char *)&mdfp[1], (ftnlen)sizeof(integer));
	do_uio(&c__9, (char *)&xdfp[1], (ftnlen)sizeof(doublereal));
	do_uio(&c__1, (char *)&(*totime), (ftnlen)sizeof(doublereal));
	do_uio(&c__1, (char *)&(*funct1), (ftnlen)sizeof(doublereal));
	e_wsue();
	io___27.ciunit = ir;
	s_wsue(&io___27);
	i__1 = geovar_1.nvar;
	for (i = 1; i <= i__1; ++i) {
	    do_uio(&c__1, (char *)&xparam[i], (ftnlen)sizeof(doublereal));
	}
	i__2 = geovar_1.nvar;
	for (i = 1; i <= i__2; ++i) {
	    do_uio(&c__1, (char *)&gd[i], (ftnlen)sizeof(doublereal));
	}
	e_wsue();
	io___28.ciunit = ir;
	s_wsue(&io___28);
	i__1 = geovar_1.nvar;
	for (i = 1; i <= i__1; ++i) {
	    do_uio(&c__1, (char *)&xlast[i], (ftnlen)sizeof(doublereal));
	}
	i__2 = geovar_1.nvar;
	for (i = 1; i <= i__2; ++i) {
	    do_uio(&c__1, (char *)&gradnt_1.grad[i - 1], (ftnlen)sizeof(
		    doublereal));
	}
	e_wsue();
	linear = geovar_1.nvar * (geovar_1.nvar + 1) / 2;
	io___30.ciunit = ir;
	s_wsue(&io___30);
	i__1 = linear;
	for (i = 1; i <= i__1; ++i) {
	    do_uio(&c__1, (char *)&fmatrx_1.hesinv[i - 1], (ftnlen)sizeof(
		    doublereal));
	}
	e_wsue();
	linear = molkst_1.norbs * (molkst_1.norbs + 1) / 2;
	s_wsue(&io___31);
	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___32);
	    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();
	}
	if (path_1.latom != 0) {
	    io___33.ciunit = ir;
	    s_wsue(&io___33);
	    i__1 = geovar_1.nvar;
	    for (i = 1; i <= i__1; ++i) {
		for (j = 1; j <= 3; ++j) {
		    do_uio(&c__1, (char *)&alparm_1.alparm[j + i * 3 - 4], (
			    ftnlen)sizeof(doublereal));
		}
	    }
	    e_wsue();
	    io___34.ciunit = ir;
	    s_wsue(&io___34);
	    do_uio(&c__1, (char *)&alparm_1.iloop, (ftnlen)sizeof(integer));
	    do_uio(&c__1, (char *)&alparm_1.x0, (ftnlen)sizeof(doublereal));
	    do_uio(&c__1, (char *)&alparm_1.x1, (ftnlen)sizeof(doublereal));
	    do_uio(&c__1, (char *)&alparm_1.x2, (ftnlen)sizeof(doublereal));
	    e_wsue();
	}
	io___35.ciunit = ir;
	s_wsue(&io___35);
	i__1 = geovar_1.nvar;
	for (i = 1; i <= i__1; ++i) {
	    do_uio(&c__1, (char *)&errfn_1.errfn[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);
    } else {
	if (first) {
	    s_wsfe(&io___36);
	    e_wsfe();
	}
	io___37.ciunit = ir;
	i__1 = s_rsue(&io___37);
	if (i__1 != 0) {
	    goto L130;
	}
	i__1 = do_uio(&c__9, (char *)&mdfp[1], (ftnlen)sizeof(integer));
	if (i__1 != 0) {
	    goto L130;
	}
	i__1 = do_uio(&c__9, (char *)&xdfp[1], (ftnlen)sizeof(doublereal));
	if (i__1 != 0) {
	    goto L130;
	}
	i__1 = do_uio(&c__1, (char *)&(*totime), (ftnlen)sizeof(doublereal));
	if (i__1 != 0) {
	    goto L130;
	}
	i__1 = do_uio(&c__1, (char *)&(*funct1), (ftnlen)sizeof(doublereal));
	if (i__1 != 0) {
	    goto L130;
	}
	i__1 = e_rsue();
	if (i__1 != 0) {
	    goto L130;
	}
	if (first) {
	    s_wsfe(&io___38);
	    do_fio(&c__1, (char *)&(*funct1), (ftnlen)sizeof(doublereal));
	    e_wsfe();
	}
	io___39.ciunit = ir;
	s_rsue(&io___39);
	i__1 = geovar_1.nvar;
	for (i = 1; i <= i__1; ++i) {
	    do_uio(&c__1, (char *)&xparam[i], (ftnlen)sizeof(doublereal));
	}
	i__2 = geovar_1.nvar;
	for (i = 1; i <= i__2; ++i) {
	    do_uio(&c__1, (char *)&gd[i], (ftnlen)sizeof(doublereal));
	}
	e_rsue();
	io___40.ciunit = ir;
	s_rsue(&io___40);
	i__1 = geovar_1.nvar;
	for (i = 1; i <= i__1; ++i) {
	    do_uio(&c__1, (char *)&xlast[i], (ftnlen)sizeof(doublereal));
	}
	i__2 = geovar_1.nvar;
	for (i = 1; i <= i__2; ++i) {
	    do_uio(&c__1, (char *)&gradnt_1.grad[i - 1], (ftnlen)sizeof(
		    doublereal));
	}
	e_rsue();
	linear = geovar_1.nvar * (geovar_1.nvar + 1) / 2;
	io___41.ciunit = ir;
	s_rsue(&io___41);
	i__1 = linear;
	for (i = 1; i <= i__1; ++i) {
	    do_uio(&c__1, (char *)&fmatrx_1.hesinv[i - 1], (ftnlen)sizeof(
		    doublereal));
	}
	e_rsue();
	linear = molkst_1.norbs * (molkst_1.norbs + 1) / 2;
	s_rsue(&io___42);
	i__1 = linear;
	for (i = 1; i <= i__1; ++i) {
	    do_uio(&c__1, (char *)&densty_1.pa[i - 1], (ftnlen)sizeof(
		    doublereal));
	}
	e_rsue();
	if (molkst_1.nalpha != 0) {
	    s_rsue(&io___43);
	    i__1 = linear;
	    for (i = 1; i <= i__1; ++i) {
		do_uio(&c__1, (char *)&densty_1.pb[i - 1], (ftnlen)sizeof(
			doublereal));
	    }
	    e_rsue();
	}
	if (path_1.latom != 0) {
	    io___44.ciunit = ir;
	    s_rsue(&io___44);
	    i__1 = geovar_1.nvar;
	    for (i = 1; i <= i__1; ++i) {
		for (j = 1; j <= 3; ++j) {
		    do_uio(&c__1, (char *)&alparm_1.alparm[j + i * 3 - 4], (
			    ftnlen)sizeof(doublereal));
		}
	    }
	    e_rsue();
	    io___45.ciunit = ir;
	    s_rsue(&io___45);
	    do_uio(&c__1, (char *)&alparm_1.iloop, (ftnlen)sizeof(integer));
	    do_uio(&c__1, (char *)&alparm_1.x0, (ftnlen)sizeof(doublereal));
	    do_uio(&c__1, (char *)&alparm_1.x1, (ftnlen)sizeof(doublereal));
	    do_uio(&c__1, (char *)&alparm_1.x2, (ftnlen)sizeof(doublereal));
	    e_rsue();
	}
	io___46.ciunit = ir;
	s_rsue(&io___46);
	i__1 = geovar_1.nvar;
	for (i = 1; i <= i__1; ++i) {
	    do_uio(&c__1, (char *)&errfn_1.errfn[i - 1], (ftnlen)sizeof(
		    doublereal));
	}
	e_rsue();
/* L120: */
	first = FALSE_;
	return 0;
L130:
	s_wsfe(&io___47);
	e_wsfe();
	s_stop("", 0L);
    }
    return 0;
} /* dfpsav_ */

