/*     CALCULIX - A 3-dimensional finite element program                 */
/*              Copyright (C) 1998 Guido Dhondt                          */

/*     This program is free software; you can redistribute it and/or     */
/*     modify it under the terms of the GNU General Public License as    */
/*     published by the Free Software Foundation; either version 2 of    */
/*     the License, or (at your option) any later version.               */

/*     This program is distributed in the hope that it will be useful,   */
/*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */ 
/*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
/*     GNU General Public License for more details.                      */

/*     You should have received a copy of the GNU General Public License */
/*     along with this program; if not, write to the Free Software       */
/*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */

#define Linux 1
#define IRIX 2
#define IRIX64 3
#define HP 4

#if ARCH == Linux
#define FORTRAN(A,B) A##_  B
#elif ARCH == IRIX || ARCH == IRIX64
#define FORTRAN(A,B) A##_##B
#elif ARCH == HP
#define FORTRAN(A,B) A##B
#endif

#define NNEW(a,b) (a *)u_calloc((b),sizeof(a))
#define RENEW(a,b,c) a=(b *) realloc((b *)(a),(c)*sizeof(b))

void FORTRAN(allocation,(int *nload_,int *nforc_,int *nboun_,
             int *nk_,int *ne_,int *nmpc_,int *nset_,int *nalset_,
	     int *nmat_,int *ntmat_,int *npmat_,int *norien_,int *nam_,
             int *nprint_,int *mint_,int *ntrans_,
             char *set,int *meminset,
             int *rmeminset, int *ncs_, int *namtot_, int *ncmat_,
             int *memmpc_, int *ne1d, int *ne2d, int *nflow,
             char *jobnamec, int *irstrt, int *ithermal, int *nener,
             int *nstate_, int *istep, char *inpc, int *nline, 
             int *ipoinp, int *inp, int *ntie_, int *nbody_,
             int *nprop_));

void arpack(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	     int *ne, 
	     int *nodeboun, int *ndirboun, double *xboun, int *nboun, 
	     int *ipompc, int *nodempc, double *coefmpc, char *labmpc,
             int *nmpc, 
	     int *nodeforc, int *ndirforc,double *xforc, int *nforc, 
	     int *nelemload, char *sideload, double *xload,
	     int *nload, 
	     double *ad, double *au, double *b, int *nactdof, 
	     int *icol, int *jq, int *irow, int *neq, int *nzl, 
	     int *nmethod, int *ikmpc, int *ilmpc, int *ikboun, 
	     int *ilboun, 
	     double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	     double *shcon, int *nshcon, double *cocon, int *ncocon,
	     double *alcon, int *nalcon, double *alzero, int *ielmat,
	     int *ielorien, int *norien, double *orab, int *ntmat_,
	     double *t0, double *t1, double *t1old,
	     int *ithermal,double *prestr, int *iprestr, 
	     double *vold,int *iperturb, double *sti, int *nzs,   
	     int *kode, double *adb, double *aub,int *mei, double *fei,
	     char *filab, double *eme,
             int *iexpl, double *plicon, int *nplicon, double *plkcon,
             int *nplkcon,
             double *xstate, int *npmat_, char *matname, int *mint_,
             int *ncmat_, int *nstate_, double *ener, char *jobnamec,
             char *output, char *set, int *nset, int *istartset,
             int *iendset, int *ialset, int *nprint, char *prlab,
             char *prset, int *nener, int *isolver, double *trab, 
             int *inotr, int *ntrans, double *ttime, double *fmpc,
	     char *cbody, int *ibody,double *xbody, int *nbody);

void arpackbu(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	     int *ne, 
	     int *nodeboun, int *ndirboun, double *xboun, int *nboun, 
	     int *ipompc, int *nodempc, double *coefmpc, char *labmpc,
             int *nmpc, 
	     int *nodeforc, int *ndirforc,double *xforc, int *nforc, 
	     int *nelemload, char *sideload, double *xload,
	     int *nload, 
	     double *ad, double *au, double *b, int *nactdof, 
	     int *icol, int *jq, int *irow, int *neq, int *nzl, 
	     int *nmethod, int *ikmpc, int *ilmpc, int *ikboun, 
	     int *ilboun, 
	     double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	     double *alcon, int *nalcon, double *alzero, int *ielmat,
	     int *ielorien, int *norien, double *orab, int *ntmat_,
	     double *t0, double *t1, double *t1old, 
	     int *ithermal,double *prestr, int *iprestr, 
	     double *vold,int *iperturb, double *sti, int *nzs, 
	     int *kode, double *adb, double *aub,int *mei, double *fei,
             char *filab, double *eme,
             int *iexpl, double *plicon, int *nplicon, double *plkcon,
             int *nplkcon,
             double *xstate, int *npmat_, char *matname, int *mint_,
             int *ncmat_, int *nstate_, double *ener, char *output, 
             char *set, int *nset, int *istartset,
             int *iendset, int *ialset, int *nprint, char *prlab,
             char *prset, int *nener, int *isolver, double *trab, 
             int *inotr, int *ntrans, double *ttime, double *fmpc,
	     char *cbody, int *ibody, double *xbody, int *nbody);

void arpackcs(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	     int *ne, 
	     int *nodeboun, int *ndirboun, double *xboun, int *nboun, 
	     int *ipompc, int *nodempc, double *coefmpc, char *labmpc,
             int *nmpc, 
	     int *nodeforc, int *ndirforc,double *xforc, int *nforc, 
	     int *nelemload, char *sideload, double *xload,
	     int *nload, 
	     double *ad, double *au, double *b, int *nactdof, 
	     int *icol, int *jq, int *irow, int *neq, int *nzl, 
	     int *nmethod, int *ikmpc, int *ilmpc, int *ikboun, 
	     int *ilboun, 
	     double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	     double *alcon, int *nalcon, double *alzero, int *ielmat,
	     int *ielorien, int *norien, double *orab, int *ntmat_,
	     double *t0, double *t1, double *t1old,
	     int *ithermal,double *prestr, int *iprestr, 
	     double *vold,int *iperturb, double *sti, int *nzs,  
	     int *kode, double *adb, double *aub,int *mei, double *fei,
	     char *filab, double *eme,
             int *iexpl, double *plicon, int *nplicon, double *plkcon,
             int *nplkcon,
             double *xstate, int *npmat_, char *matname, int *mint_,
             int *ics, double *cs, int *mpcend, int *ncmat_, int *nstate_,
             int *mcs, int *nkon, double *ener, char *jobnamec,
             char *output, char *set, int *nset, int *istartset,
             int *iendset, int *ialset, int *nprint, char *prlab,
             char *prset, int *nener, int *isolver, double *trab, 
             int *inotr, int *ntrans, double *ttime, double *fmpc,
	     char *cbody, int *ibody,double *xbody, int *nbody, int *nevtot);

void FORTRAN(bodyforce,(char *cbody,int *ibody,int *ipobody,int *nbody,
             char *set,int *istartset,int *iendset,int *ialset,
             int *inewton,int *nset));

void calcresidual(int *nmethod, int *neq, double *b, double *fext, double *f,
        int *iexpl, int *nactdof, double *aux1, double *aux2, double *vold,
        double *vini, double *dtime, double *accold, int *nk, double *adb,
        double *aub, int *icol, int *irow, int *nzl, double *alpha,
	double *fextini, double *fini);

void FORTRAN(calinput,(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	       int *nkon, int *ne,
	       int *nodeboun, int *ndirboun, double *xboun, int *nboun,
	       int *ipompc, int *nodempc, double *coefmpc, int *nmpc,
	       int *nmpc_,int *nodeforc, int *ndirforc, double *xforc,
	       int *nforc, int *nforc_, int *nelemload, char *sideload,
	       double *xload, int *nload, int *nload_,
	       int *nprint, char *prlab, char *prset,int *mpcfree, int *nboun_,
	       int *mei, char *set, int *istartset, 
	       int *iendset, int *ialset, int *nset, int *nalset,
	       double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	       double *alcon, int *nalcon, double *alzero, double *t0,
	       double *t1, char *matname,
	       int *ielmat, char *orname, double *orab, int *ielorien,
	       char *amname, double *amta, int *namta, int *nam,
	       int *nmethod, int *iamforc, int *iamload,
	       int *iamt1,int *ithermal, int *iperturb, 
	       int *istat, int *istep, int *nmat,
	       int *ntmat_, int *norien, double *prestr, int *iprestr,
	       int *isolver, double *fei,double *veold, double *tinc,
	       double *tper, double *xmodal,
               char *filab, int *jout, int *nlabel,
	       int *idrct, int *jmax, double *tmin, double *tmax,
	       int *iexpl, double *alpha, double *haftol, int *iamboun,
	       double *plicon, int *nplicon, double *plkcon, int *nplkcon,
	       int *iplas, int *npmat_, int *mint_, int *nk_,
	       double *trab, int *inotr, int *ntrans, int *ikboun,
               int *ilboun, int *ikmpc, int *ilmpc, int *ics,
	       double *dcs, int *ncs_, int *namtot_, double *cs,
               int *nstate_, int *ncmat_, int *iumat, int *mcs,
               char *labmpc, int *iponor,double *xnor,int *knor,
	       double *thickn,double *thicke,int *ikforc,int *ilforc,
               double *offset,int *iponoel,int *inoel,int *rig,
               int *infree, int *nshcon, double *shcon, double *cocon,
               int *ncocon,double *physcon, int *nflow, double *ctrl,
               int *memmpc_, int *maxlenmpc, int *ne1d, int *ne2d, int *nener, 
               double *vold, int *nodebounold,
               int *ndirbounold, double *xbounold, double *xforcold,
               double *xloadold, double *t1old, double *eme,
               double *sti, double *ener,
               double *xstate, char *jobnamec, int *nnn, int *irstrt,
               double *ttime,double *qaold,
               char *output, char *typeboun, char *inpc, int *nline,
               int *ipoinp,int *inp, char *tieset, double *tietol, 
               int *ntie, double *fmpc, char *cbody, int *ibody, double *xbody,
               int *nbody, int *nbody_, double *xbodyold, int *nam_,
               int *ielprop, int *nprop, int *nprop_, double *prop));    

void cascade(int *ipompc, double **coefmpcp, int **nodempcp, int *nmpc,
   int *mpcfree, int *nodeboun, int *ndirboun, int*nboun, int*ikmpc,
   int *ilmpc, int *ikboun, int *ilboun, int *mpcend, int *mpcmult,
   char *labmpc, int *nk, int *memmpc_, int *icascade, int *maxlenmpc,
   int *callfrommain);

void checkconvergence(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	  int *ne, double *v, double *stn, int *inum, int *nmethod, 
	  int *kode, char *filab, double *een, double *t1act,
          double *fn, double *time, double *epn,int *ielmat,char *matname,
          double *enern, double *xstaten, int *nstate_, int *istep,
          int *iinc, int *iperturb, double *ener, int *mint_, char *output,
          int *ithermal, double *qfn, int *mode, int *noddiam, double *trab,
          int *inotr, int *ntrans, double *orab, int *ielorien, int *norien,
          char *description, double *sti,
	  int *icutb, int *iit, double *dtime, double *qa, double *vold,
          double *qam, double *ram1, double *ram2, double *ram,
          double *cam, double *uam, int *ntg, double *ttime,
          int *icntrl, double *theta, double *dtheta, double *veold,
          double *vini, int *idrct, double *tper,int *istab, double *tmax, 
	  int *nactdof, double *b, double *tmin, double *ctrl);

void FORTRAN(cprint,(char *text, int *before, int *after));

void FORTRAN(datri,(double *au, double *aa, double *ad, int *icol, int *neq, 
	    int *flg));

void FORTRAN(dasol,(double *au, double *aa, double *ad, double *b, int *icol, 
	    int *neq, double *energy));

void FORTRAN(drfftf,(int *ndata, double *r, double *wsave, int *isave));

void FORTRAN(drffti,(int *ndata, double *wsave, int *isave));

void FORTRAN(dsaupd,(int *ido, char *bmat, int *n, char *which, int *nev,
	     double *tol, double *resid, int *ncv, double *z, int *ldz,
	     int *iparam, int *ipntr, double *workd, double *workl,
	     int *lworkl, int *info));

void FORTRAN(dseupd,(int *, char *, int *, double *, double *,
	     int *, double *, char *, int *, char *, 
	     int *, double *, double *, int *, double *,
	     int *, int *, int *, double *,
	     double *, int *, int *));

void FORTRAN(dspgv,(int *itype, char *jobz, char *uplo, int *n, double *ap,
                    double *bp, double *w, double *z, int *ldz, double *work,
                    int *info));

void dyna(double **cop, int *nk, int **konp, int **ipkonp, char **lakonp, int *ne, 
	       int **nodebounp, int **ndirbounp, double **xbounp, int *nboun,
	       int **ipompcp, int **nodempcp, double **coefmpcp, char **labmpcp,
               int *nmpc, int *nodeforc,int *ndirforc,double *xforc, 
               int *nforc,int *nelemload, char *sideload,double *xload,
	       int *nload, 
	       int **nactdofp,int *neq, int *nzl,int *icol, int *irow, 
	       int *nmethod, int **ikmpcp, int **ilmpcp, int **ikbounp, 
	       int **ilbounp,double *elcon, int *nelcon, double *rhcon, 
	       int *nrhcon,double *cocon, int *ncocon,
               double *alcon, int *nalcon, double *alzero, 
               int **ielmatp,int **ielorienp, int *norien, double *orab, 
               int *ntmat_,double *t0, 
	       double *t1,int *ithermal,double *prestr, int *iprestr, 
	       double **voldp,int *iperturb, double *sti, int *nzs, 
	       double *tinc, double *tper, double *xmodal,
	       double **veoldp, char *amname, double *amta,
	       int *namta, int *nam, int *iamforc, int *iamload,
	       int *iamt1,int *jout,
	       int *kode, char *filab,double **emep, double *xforcold, 
	       double *xloadold,
               double *t1old, int **iambounp, double **xbounoldp, int *iexpl,
               double *plicon, int *nplicon, double *plkcon,int *nplkcon,
               double *xstate, int *npmat_, char *matname, int *mint_,
               int *ncmat_, int *nstate_, double **enerp, char *jobnamec,
               double *ttime, char *set, int *nset, int *istartset,
               int *iendset, int *ialset, int *nprint, char *prlab,
               char *prset, int *nener, double *trab, 
               int **inotrp, int *ntrans, double **fmpcp, char *cbody, int *ibody,
               double *xbody, int *nbody, double *xbodyold, int *istep,
	       int *isolver,int *jq, char *output, int *mcs, int *nkon,
               int *mpcend, int *ics, double *cs);
 
void dynboun(double *amta,int *namta,int *nam,double *ampli, double *time,
             double *ttime,double *dtime,double *xbounold,double *xboun,
             double *xbounact,int *iamboun,int *nboun,int *nodeboun,
             int *ndirboun, double *ad, double *au, double *adb,
             double *aub, int *icol, int *irow, int *neq, int *nzs,
             double *sigma, double *b, int *isolver,
             double *alpham, double *betam, int *nzl,
             int *init, double *bact, double *bmin, int *jq);

void FORTRAN(dynsolv,(double *b, double *z, double *d, double *zeta, int *nev,
	      int *neq, double *tinc, int *jinc, int *jout, double *vold,
	      double *xforcold, int *nodeforc, int *ndirforc,
	      double *xforc, int *iamforc, int *nforc, double *xloadold,
	      double *xload, int *iamload, int *nelemload, char *sideload,
	      int *nload,
	      double *t1old,
	      double *t1, int *iamt1, int *nk, double *amta, int *namta, 
	      int *nam, double *ampli, double *aa, double *bb, double *bj, 
	      double *v, int *nodeboun, int *ndirboun, double *xboun, 
	      int *nboun, int *ipompc, int *nodempc, double *coefmpc, 
              char *labmpc,int *nmpc, int *nactdof, 
	      int *iperturb, int *nmethod, double *co, int *kon,
	      int *ipkon, char *lakon,int *ne, double *stn,double *stx,
	      double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	      double *alcon, int *nalcon, double *alzero, int *ielmat,
	      int *ielorien, int *norien, double *orab, int *ntmat_,
	      double *t0, int *ithermal, int *kode, double *cv,
	      double *cd, int *inum, double *prestr, int *iprestr,
	      int *ikmpc, int *ilmpc, int *ikboun, int *ilboun,
	      char *filab, double *eme, double *een,
	      double *sti, double *f, double *fn, double *xforcact,
	      double *xloadact,
              double *t1act, double *xbounold, double *xbounact,
              int *iamboun, int *iexpl, double *plicon, int *nplicon,
              double *plkcon,
	      int *nplkcon, double *xstateini,double *xstiff,
              double *xstate, int *npmat_, double *epn, char *matname,
              int *mint_, int *ncmat_, int *nstate_, double *stiini,
              double *vini, double *ener, double *enern, double *xstaten,
              double *ttime, double *eei, double *enerini,double *cocon,
              int *ncocon, char *set, int *nset, int *istartset,
              int *iendset, int *ialset, int *nprint, char *prlab,
              char *prset, double *qfx, double *qfn, double *trab,
	      int *inotr, int *ntrans, double *fmpc, double *veold,
	      char *cbody, int *ibody, double *xbody, int *nbody, 
              double *xbodyold, double *xbodyact, int *ipobody,
              double *cgr, double *xmodal,double *au,
              double *aub,double *vbounact, double *abounact, int *nzs));

void FORTRAN(envtemp,(int *itg,int *ieg,int *ntg,int *ntr,char *sideload,
                      int *nelemload,int *ipkon,int *kon,char *lakon,
                      int *ielmat,int *ne, int *nload, int *iptri,
                      int *kontri, int *ntri, int *nloadtr,
                      int *nflow));
void expand(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	     int *ne, int *nodeboun, int *ndirboun, double *xboun, int *nboun, 
	     int *ipompc, int *nodempc, double *coefmpc, char *labmpc,
             int *nmpc, int *nodeforc, int *ndirforc,double *xforc, 
             int *nforc, int *nelemload, char *sideload, double *xload,
             int *nload, int *nactdof, int *neq, 
	     int *nmethod, int *ikmpc, int *ilmpc, int *ikboun, int *ilboun,
	     double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	     double *alcon, int *nalcon, double *alzero, int *ielmat,
	     int *ielorien, int *norien, double *orab, int *ntmat,
	     double *t0,int *ithermal,double *prestr, int *iprestr, 
	     double *vold,int *iperturb, double *sti, int *nzs,  
	     double *adb, double *aub,char *filab, double *eme,
             double *plicon, int *nplicon, double *plkcon,int *nplkcon,
             double *xstate, int *npmat_, char *matname, int *mint_,
	     int *ics, double *cs, int *mpcend, int *ncmat_,
             int *nstate_, int *mcs, int *nkon, double *ener,
             char *jobnamec, char *output, char *set, int *nset,int *istartset,
             int *iendset, int *ialset, int *nprint, char *prlab,
             char *prset, int *nener, double *trab, 
             int *inotr, int *ntrans, double *ttime, double *fmpc,
	     int *nev, double *z, int *iamboun, double *xbounold,
	     int *nsegments, int *nm,int *icol,int *irow,int *nzl,int *nam,
	     int *ipompcold, int *nodempcold, double *coefmpcold,
             char *labmpcold, int *nmpcold, double *xloadold, int *iamload);

double FORTRAN(fcrit,(double *time,double *tend,double *aai,double *bbi,
		      double *zetaj,double *dj,double *ddj,
		      double *h1,double *h2,double *h3,double *h4));

void FORTRAN(frd,(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	  int *ne, double *v, 
	  double *stn, int *inum, int *nmethod, 
	  int *kode, char *filab, double *een, double *t1,
          double *fn, double *time, double *epl,int *ielmat,char *matname,
          double *enern, double *xstaten, int *nstate_, int *istep,
          int *iinc, int *ithermal, double *qfn, double *trab, int *inotr,
          int *ntrans, double *orab, int *ielorien, int *norien, int *ipneigh,
          int *neigh,int *mint_, double *sti));

void FORTRAN(frdphase,(int *kode,double *time,int *nk,int *inum,
             double *vr, double *vi, char *filab));

void FORTRAN(frdclose,());

void frdcyc(double *co,int *nk,int *kon,int *ipkon,char *lakon,int *ne,double *v,
	    double *stn,int *inum,int *nmethod,int *kode,char *filab,
	    double *een,double *t1,double *fn,double *time,double *epn,
	    int *ielmat,char *matname, double *cs, int *mcs, int *nkon,
	    double *enern, double *xstaten, int *nstate_, int *istep,
            int *iinc, int *iperturb, double *ener, int *mint_, char *output,
            int *ithermal, double *qfn, int *ialset, int *istartset,
            int *iendset, double *trab, int *inotr, int *ntrans,double *orab,
	    int *ielorien, int *norien, double *sti);

double FORTRAN(fsub,(double *time,double *tend,double *aai,double *bbi,
		     double *ddj,double *h1,double *h2,double *h3,double *h4));

double FORTRAN(fsuper,(double *time,double *tend,double *aai,double *bbi,
		       double *h1,double *h2,double *h3,double *h4,
		       double *h5,double *h6));

void FORTRAN(getfneig,(char *fneig));

void FORTRAN(includefilename,(char *buff,char *includefn,int *lincludefn));

void insert(int *ipointer, int **mast1p, int **mast2p, int *i1,
	    int *i2, int *ifree, int *nzs_);

void FORTRAN(isortii,(int *ix, int *iy, int *n, int *kflag));

void FORTRAN(isortiid,(int *ix, int *iy, double *dy1, int *n, int *kflag));

void FORTRAN(isortiddc1,(int *ix, double *dy1, double *dy2, char *cy, int *n, int *kflag));

void FORTRAN(isortiddc2,(int *ix1, int *ix2,double *dy1, double *dy2, char *cy, int *n, int *kflag));

void FORTRAN(iter,(double *coef, int *jcoef, int *ndim, int *n, int *p,
	   int *ip, double *u, double *ubar, double *rhs, double *wksp,
	   int *iwksp, int *nw, int *inw, int *iparm, double *rparm));

void FORTRAN(keystart,(int *ifreeinp,int *ipoinp,int *inp,char *name,
           int *iline,int *ikey));

void FORTRAN(mafillpr,(double *co, int *nk, int *kon, int *ipkon, char *lakon, 
	       int *ne, 
	       int *nodeboun, int *ndirboun, double *xboun, int *nboun, 
	       int *ipompc, int *nodempc, double *coefmpc, int *nmpc, 
	       int *nodeforc, int *ndirforc, double *xforc, int *nforc, 
	       int *nelemload, char *sideload, double *xload, int *nload, 
	       double *xbody, int *ipobody, int *nbody, double *cgr,
	       double *ad, double *au, double *b,
	       int *nactdof, 
	       int *icol, int *jq, int *neq, int *nmethod, int *ikmpc, 
	       int *ilmpc, int *ikboun, int *ilboun,
	       double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	       double *alcon, int *nalcon, double *alzero, int *ielmat,
	       int *ielorien, int *norien, double *orab, int *ntmat_,
	       double *t0, double *t1,
	       int *ithermal,double *prestr, int *iprestr, double *vold, 
	       int *iperturb,double *stx, double *sti,
               int *iexpl, double *plicon,
               int *nplicon,double *plkcon,int *nplkcon,
               double *xstiff,
	       int *npmat_, double *dtime, char *matname, int *mint_,
               int *ncmat_,int *mass,int *stiffness,int *buckling,int *rhs,
               int *intscheme));

void FORTRAN(mafillsm,(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	       int *ne, int *nodeboun, int *ndirboun, double *xboun, 
	       int *nboun,int *ipompc, int *nodempc, double *coefmpc, 
	       int *nmpc, int *nodeforc,int *ndirforc,
	       double *xforc, int *nforc, int *nelemload, char *sideload,
	       double *xload,int *nload,double *xbody,int *ipobody,
	       int *nbody,double *cgr,
	       double *ad, double *au, double *b, double *bb, int *nactdof, 
	       int *icol, int *jq, int *irow, int *neq, int *nzl, 
	       int *nmethod, int *ikmpc, int *ilmpc, int *ikboun, 
	       int *ilboun,
	       double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	       double *alcon, int *nalcon, double *alzero, int *ielmat,
	       int *ielorien, int *norien, double *orab, int *ntmat_,
	       double *t0, double *t1, int *ithermal,
	       double *prestr, int *iprestr, double *vold,
	       int *iperturb, double *sti, int *nzs, double *stx,
	       double *adb, double *aub, int *iexpl,
               double *plicon,
               int *nplicon,double *plkcon,int *nplkcon,
               double *xstiff, 
	       int *npmat_, double *dtime, char *matname, int *mint_,
               int *ncmat_,int *mass,int *stiffness,int *buckling,int *rhs,
               int *intscheme, double *physcon, double *shcon, int *nshcon,
               double *cocon, int *ncocon, double *ttime, double *time,
               int *istep, int *kinc, int *coriolis));

void FORTRAN(mafillsmcs,(double *co, int *nk, int *kon, int *ipkon, 
               char *lakon,
	       int *ne, int *nodeboun, int *ndirboun, double *xboun, 
	       int *nboun,int *ipompc, int *nodempc, double *coefmpc, 
	       int *nmpc, int *nodeforc,int *ndirforc,
	       double *xforc, int *nforc, int *nelemload, char *sideload,
	       double *xload,
	       int *nload,double *xbody,int *ipobody,
	       int *nbody,double *cgr, 
	       double *ad, double *au, double *b, double *bb, int *nactdof, 
	       int *icol, int *jq, int *irow, int *neq, int *nzl, 
	       int *nmethod, int *ikmpc, int *ilmpc, int *ikboun, 
	       int *ilboun,
	       double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	       double *alcon, int *nalcon, double *alzero, int *ielmat,
	       int *ielorien, int *norien, double *orab, int *ntmat_,
	       double *t0, double *t1, int *ithermal,
	       double *prestr, int *iprestr, double *vold,
	       int *iperturb, double *sti, int *nzs, double *stx,
	       double *adb, double *aub, int *iexpl,
               double *plicon,
               int *nplicon,double *plkcon,int *nplkcon,
              double *xstiff, 
	       int *npmat_, double *dtime, char *matname, int *mint_,
               int *ics, double *cs, int *nm, int *ncmat_,char *labmpc,int *mass,
               int *stiffness,int *buckling,int *rhs,
               int *intscheme, int *mcs, int *coriolis));

void mastruct(int *nk, int *kon, int *ipkon, char*lakon, int *ne,
	      int *nodeboun, int *ndirboun, int *nboun, int *ipompc,
	      int *nodempc, int *nmpc, int *nactdof, int *icol,
	      int *jq, int **mast1p, int **irowp, int *isolver, int *neq,
	      int *nnn, int *ikmpc, int *ilmpc, int *ikcol,
	      int *ipointer, int *nsky, int *nzs, int *nmethod,
              int *ithermal, int *ikboun, int *ilboun, int *iperturb);

void mastructcs(int *nk, int *kon, int *ipkon, char *lakon,
	       int *ne, int *nodeboun,
	       int *ndirboun, int *nboun, int *ipompc, int *nodempc,
	       int *nmpc, int *nactdof, int *icol, int *jq, int **mast1p,
	       int **irowp, int *isolver, int *neq, int *nnn, 
	       int *ikmpc, int *ilmpc, int *ikcol, int *ipointer,
	       int *nsky, int *nzs, int *nmethod, int *ics, double *cs,
               char *labmpc, int *mcs);

void FORTRAN(mult,(double *matrix, double *trans, int *n));

void FORTRAN(nident,(int *x, int *px, int *n, int *id));

void nonlingeo(double **co, int *nk, int *kon, int *ipkon, char *lakon,
	     int *ne, 
	     int *nodeboun, int *ndirboun, double *xboun, int *nboun, 
	     int *ipompc, int **nodempcp, double **coefmpcp, char *labmpc,
             int *nmpc, 
	     int *nodeforc, int *ndirforc,double *xforc, int *nforc, 
	     int *nelemload, char *sideload, double *xload,
	     int *nload, 
	     double *ad, double *au, double *b, int *nactdof, 
	     int **icolp, int *jq, int **irowp, int *neq, int *nzl, 
	     int *nmethod, int *ikmpc, int *ilmpc, int *ikboun, 
	     int *ilboun,
	     double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	     double *alcon, int *nalcon, double *alzero, int *ielmat,
	     int *ielorien, int *norien, double *orab, int *ntmat_,
	     double *t0, double *t1, double *t1old, 
	     int *ithermal,double *prestr, int *iprestr, 
	     double **vold,int *iperturb, double *sti, int *nzs,  
	     int *kode, double *adb, double *aub, 
	     char *filab, int *idrct,
	     int *jmax, int *jout, double *tinc, double *tper,
	     double *tmin, double *tmax, double *eme, double *xbounold,
	     double *xforcold, double *xloadold,
             double *veold, double *accold,
             char *amname, double *amta, int *namta, int *nam,
             int *iamforc, int *iamload,
             int *iamt1, double *alpha, double *haftol, int *iexpl,
	     int *iamboun, double *plicon, int *nplicon, double *plkcon,
	     int *nplkcon,
             double *xstate, int *npmat_, int *istep, double *ttime,
	     char *matname, double *qaold, int *mint_,
             int *isolver, int *ncmat_, int *nstate_, int *iumat,
             double *cs, int *mcs, int *nkon, double *ener, int *mpcinfo,
             int *nnn, char *output,
             double *shcon, int *nshcon, double *cocon, int *ncocon,
             double *physcon, int *nflow, double *ctrl, 
             char *set, int *nset, int *istartset,
             int *iendset, int *ialset, int *nprint, char *prlab,
             char *prset, int *nener,int *ikforc, int *ilforc, double *trab, 
             int *inotr, int *ntrans, double *fmpc, char *cbody,
             int *ibody, double *xbody, int *nbody, double *xbodyold,
             int *ielprop, double *prop);

void FORTRAN(nonlinmpc,(double *co,double *vold,int *ipompc,int *nodempc,
		   double *coefmpc,char *labmpc,int *nmpc,int *ikboun,
		   int *ilboun,int *nboun,double *xbounact,double *aux,
		   int *iaux, int *maxlenmpc, int *ikmpc, int *ilmpc,
                   int *icascade, int *kon, int *ipkon, char *lakon,
		   int *ne, double *reltime, int *newstep, double *xboun,
                   double *fmpc, int *newinc, int *idiscon));

void FORTRAN(op,(int *, double *, double *, double *, double *, double *, int *,
	 int *, int *));

void FORTRAN(opcs,(int *, double *, double *, double *, double *, double *, int *,
	 int *, int *));

void FORTRAN(openfile,(char *jobname, char *output));

void FORTRAN(out,(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	  int *ne, double *v, 
	  double *stn, int *inum, int *nmethod, 
	  int *kode, char *filab, double *een, double *t1,
          double *fn, double *time, double *epl,int *ielmat,char *matname,
          double *enern, double *xstaten, int *nstate_, int *istep,
          int *iinc, int *iperturb, double *ener, int *mint_, char *output,
          int *ithermal, double *qfn, int *mode, int *noddiam, double *trab,
          int *inotr, int *ntrans, double *orab, int *ielorien, int *norien,
          char *description, int *ipneigh,int *neigh,double *sti));

int cgsolver(double *A, double *x, double *b, int neq, int len, int *ia, int *iz, 
				double *eps, int *niter, int precFlg);

void preiter(double *ad, double **aup, double *b, int **icolp, int **irowp, 
	     int *neq, int *nzs, int *isolver, int *iperturb);
  
void prespooles(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	     int *ne, 
	     int *nodeboun, int *ndirboun, double *xboun, int *nboun, 
	     int *ipompc, int *nodempc, double *coefmpc, char *labmpc,
             int *nmpc, 
	     int *nodeforc, int *ndirforc,double *xforc, int *nforc, 
	     int *nelemload, char *sideload, double *xload,
	     int *nload, 
	     double *ad, double *au, double *b, int *nactdof, 
	     int **icolp, int *jq, int **irowp, int *neq, int *nzl, 
	     int *nmethod, int *ikmpc, int *ilmpc, int *ikboun, 
	     int *ilboun,
	     double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	     double *alcon, int *nalcon, double *alzero, int *ielmat,
	     int *ielorien, int *norien, double *orab, int *ntmat_,
	     double *t0, double *t1, double *t1old, 
	     int *ithermal,double *prestr, int *iprestr, 
	     double *vold,int *iperturb, double *sti, int *nzs, 
	     int *kode, double *adb, double *aub, 
	     char *filab, double *eme,
             int *iexpl, double *plicon, int *nplicon, double *plkcon,
             int *nplkcon,
             double *xstate, int *npmat_, char *matname, int *isolver,
	     int *mint_, int *ncmat_, int *nstate_, double *cs, int *mcs,
             int *nkon, double *ener, double *xbounold,
	     double *xforcold, double *xloadold,
             char *amname, double *amta, int *namta,
             int *nam, int *iamforc, int *iamload,
             int *iamt1, int *iamboun, double *ttime, char *output, 
             char *set, int *nset, int *istartset,
             int *iendset, int *ialset, int *nprint, char *prlab,
             char *prset, int *nener, double *trab, 
             int *inotr, int *ntrans, double *fmpc, char *cbody, int *ibody,
	     double *xbody, int *nbody, double *xbodyold);

void profile(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	     int *ne, 
	     int *nodeboun, int *ndirboun, double *xboun, int *nboun, 
	     int *ipompc, int *nodempc, double *coefmpc, char *labmpc,
             int *nmpc, 
	     int *nodeforc, int *ndirforc,double *xforc, int *nforc, 
	     int *nelemload, char *sideload, double *xload,
	     int *nload, 
	     double *ad, double *au, double *b, int *nactdof, 
	     int *icol, int *jq, int *neq, 
	     int *nmethod, int *ikmpc, int *ilmpc, int *ikboun, 
	     int *ilboun, 
	     double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	     double *alcon, int *nalcon, double *alzero, int *ielmat,
	     int *ielorien, int *norien, double *orab, int *ntmat_,
	     double *t0,double *t1,  double *t1old,int *ithermal,
             double *prestr, int *iprestr, 
	     double *vold,int *iperturb, double *sti,  
	     int *kode, int *nsky, char *filab,
	     double *eme, int *iexpl, 
             double *plicon, int *nplicon, double *plkcon,
             int *nplkcon,
             double *xstate, int *npmat_, char *matname, int *mint_,
             int *ncmat_, int *nstate_, double *cs, int *mcs,int *nkon,
             double *ener, double *xbounold,
	     double *xforcold, double *xloadold,
             char *amname, double *amta, int *namta,
             int *nam, int *iamforc, int *iamload,
             int *iamt1, int *iamboun, double *ttime, char *output, 
             char *set, int *nset, int *istartset,
             int *iendset, int *ialset, int *nprint, char *prlab,
             char *prset, int *nener, double *trab, 
             int *inotr, int *ntrans, double *fmpc, char *cbody, int *ibody,
	     double *xbody, int *nbody, double *xbodyold);

void radcyc(int *nk,int *kon,int *ipkon,char *lakon,int *ne,
	    double *cs, int *mcs, int *nkon,int *ialset, int *istartset,
            int *iendset,int **kontrip,int *ntri,
            double **cop, double **voldp,int *ntrit, int *inocs);

void FORTRAN(radflowload,(int *itg, int *ieg, int *ntg, int *ntr,int *ntm,
       double *ac,double *bc,int *nload,
       char *sideload,int *nelemload,double *xloadact,char *lakon,int *ipiv,
       int *ntmat_,double *vold,double *shcon,int *nshcon,int *ipkon,
       int *kon,double *co,double *pmid,double *e1,double *e2,double *pnor,
       int *iptr,int *kontri,int *ntri,
       int *nloadtr,double *tarea,double *tenv,double *physcon,double *erad,
       double *fij,double *dist,int *idist,double *area,
       int *nflow,int *ikboun,double *xboun,int *nboun,int *ithermal,
       int *iinc,int *iit,double *cs, int *mcs, int *inocs, int *ntrit,
       int *nk, double *fenv,int *istep,double *dtime,double *ttime,
       double *time,int *ilboun,int *ikforc,int *ilforc,double *xforc,
       int *nforc,double *cam, int *ielmat));

void readinput(char *jobnamec,char **inpc,int *nline,int *nset, int *ipoinp,
        int **inpp); 

void FORTRAN(rearrange,(double *au,int *irow,int *icol,int *ndim,int *neq));


void FORTRAN(rectcyl,(double *co,double *v,double *fn,double *stn,
		      double *qfn, double *een,double *cs,int *nk, 
                      int *icntrl,double *t, char *filab, int *imag));

void remastruct(int *ipompc, double **coefmpcp, int **nodempcp, int *nmpc,
              int *mpcfree, int *nodeboun, int *ndirboun, int *nboun,
              int *ikmpc, int *ilmpc, int *ikboun, int *ilboun,
              char *labmpc, int *nk,
              int *memmpc_, int *icascade, int *maxlenmpc,
              int *kon, int *ipkon, char *lakon, int *ne, int *nnn,
              int *nactdof, int *icol, int *jq, int **irowp, int *isolver,
              int *neq, int *nzs,int *nmethod, double **fp, double **fincp,
              double **fextp, double **bp, double **aux2p, double **finip,
              double **fextinip,double **adbp, double **aubp, int *ithermal,
              int *iperturb);

void FORTRAN(renumber,(int *nk, int *kon, int *ipkon, char *lakon, int *ne, 
	       int *ipompc, int *nodempc, int *nmpc, int *nnn, int *npn, 
	       int *adj,int *xadj, int *iw, int *mmm, int *xnpn, int *inum1, 
               int *inum2));

void FORTRAN(storeresidual,(int *nactdof, double *b, double *fn, char *filab,
             int *ithermal, int *nk));

void FORTRAN(restartshort,(int *nset,int *nload,int *nbody, int *nforc,
    int *nboun,
    int *nk,int *ne,int *nmpc,int *nalset,int *nmat,int *ntmat,int *npmat,
    int *norien,int *nam,int *nprint,int *mint,int *ntrans,int *ncs,
    int *namtot,int *ncmat,int *memmpc,int *ne1d,int *ne2d,int *nflow,
    char *set,int *meminset,int *rmeminset,char *jobnamec,int *irestartstep,
    int *icntrl,int *ithermal,int *nener,int *nstate_,int *ntie));

void FORTRAN(restartwrite,(int *istep, int *nset, int*nload, int *nforc, 
  int * nboun,int *nk, int *ne, int *nmpc, int *nalset, int *nmat, int *ntmat_, 
  int *npmat_, int *norien, int *nam, int *nprint, int *mint_, 
  int *ntrans, int *ncs_, int *namtot_, int *ncmat_, int *mpcend, 
  int *maxlenmpc, int *ne1d, 
  int *ne2d, int *nflow, int *nlabel, int *iplas, int *nkon, int *ithermal, 
  int *nmethod,int *iperturb, int *nstate_,int *nener,char *set, 
  int *istartset, int *iendset, int *ialset, double *co, int *kon, int *ipkon, 
  char *lakon, int *nodeboun, int *ndirboun, int *iamboun, double *xboun, 
  int *ikboun, int *ilboun, int *ipompc, int *nodempc, double *coefmpc, 
  char *labmpc, int *ikmpc, int *ilmpc, int *nodeforc, int *ndirforc, 
  int *iamforc, double *xforc, int *ikforc, int *ilforc, int *nelemload, 
  int *iamload, char *sideload, double *xload,  
  double *elcon, int *nelcon, double *rhcon, int *nrhcon, double *alcon, 
  int *nalcon, double *alzero, double *plicon, int *nplicon, double *plkcon, 
  int *nplkcon, char *orname, double *orab, int *ielorien, double *trab, 
  int *inotr, char *amname, double *amta, int *namta, double *t0, double *t1, 
  int *iamt1, double *veold, int *ielmat,char *matname, 
  char *prlab, char *prset, char *filab, double *vold, 
  int *nodebounold, int *ndirbounold, double *xbounold, double *xforcold, 
  double *xloadold, double *t1old, double *eme, int *iponor, 
  double *xnor, int *knor, double *thickn, double *thicke, double *offset, 
  int *iponoel, int *inoel, int *rig, 
  double *shcon, int *nshcon, double *cocon, int *ncocon, 
  int *ics, double *sti, double *ener, double *xstate, 
  char *jobnamec, int *infree, int *nnn, double *prestr,int *iprestr,
  char *cbody, int *ibody, double *xbody, int *nbody, double *xbodyold,
  double *ttime,double *qaold,double *cs,
  int *mcs, char *output,double *physcon, double *ctrl, char *typeboun,
  double *fmpc,char *tieset, int *ntie));

void FORTRAN(results,(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	     int *ne, double *v, double *stn, int *inum, 
	     double *stx,
	     double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	     double *alcon, int *nalcon, double *alzero, int *ielmat,
	     int *ielorien, int *norien, double *orab, int *ntmat_,
	     double *t0, double *t1,int *ithermal,double *prestr, 
             int *iprestr, char *filab, double *eme, 
             double *een, int *iperturb,double *f, double *fn, int *nactdof,
             int *iout, double *qa,
	     double *vold, double *b, int *nodeboun, int *ndirboun,
	     double *xboun, int *nboun, int *ipompc, int *nodempc,
	     double *coefmpc, char *labmpc, int *nmpc, int *nmethod, 
             double *vmax,int *neq, double *veold, double *accold,
	     double *beta, double *gamma, double *dtime, double *time,
             double *ttime, double *plicon,
             int *nplicon,double *plkcon,int *nplkcon,
             double *xstateini,double *xstiff,double *xstate, int *npmat_,
	     double *epl, char *matname, int *mint_, int *ielas,
	     int *icmd, int *ncmat_, int *nstate_, double *stiini,
	     double *vini, int *ikboun, int *ilboun, double *ener,
	     double *enern, double *sti, double *xstaten, double *eei,
             double *enerini, double *cocon, int *ncocon, char *set, 
             int *nset, int *istartset,
             int *iendset, int *ialset, int *nprint, char *prlab,
             char *prset, double *qfx, double *qfn, double *trab,
             int *inotr, int *ntrans, double *fmpc, int *nelemload,
             int *nload));

void FORTRAN(rhs,(double *co, int *nk, int *kon, int *ipkon, char *lakon,
	       int *ne,int *ipompc, int *nodempc, double *coefmpc, 
	       int *nmpc, int *nodeforc,int *ndirforc,
	       double *xforc, int *nforc, int *nelemload, char *sideload,
	       double *xload,int *nload, double *xbody, int *ipobody,
               int *nbody, double *cgr, double *bb, int *nactdof, int *neq, 
	       int *nmethod, int *ikmpc, int *ilmpc,
	       double *elcon, int *nelcon, double *rhcon, int *nrhcon,
	       double *alcon, int *nalcon, double *alzero, int *ielmat,
	       int *ielorien, int *norien, double *orab, int *ntmat_,
	       double *t0, double *t1, int *ithermal, 
               int *iprestr, double *vold,int *iperturb,int *iexpl,
               double *plicon,int *nplicon,double *plkcon,int *nplkcon,
               int *npmat_, double *ttime, double *time, int *istep,
               int *iinc, double *dtime, double *physcon));


void FORTRAN(spcmatch,(double *xboun, int *nodeboun, int *ndirboun, int *nboun,
	       double *xbounold, int *nodebounold, int *ndirbounold,
	       int *nbounold, int *ikboun, int *ilboun, double *vold,
	       double *reorder, int *nreorder));

void FORTRAN(splitline,(char *text,char *textpart,int *n));

void spooles(double *ad, double *au, double *adb, double *aub,
             double *sigma, double *b,
	     int *icol, int *irow, int *neq, int *nzs);

void steadystate(double **co, int *nk, int **kon, int **ipkon, char **lakon, int *ne, 
	  int **nodeboun, int **ndirboun, double **xboun, int *nboun,
	  int **ipompcp, int **nodempcp, double **coefmpcp, char **labmpcp, int *nmpc, 
	  int *nodeforc,int *ndirforc,double *xforc, int *nforc, 
	  int *nelemload, char *sideload,double *xload,
	  int *nload, 
	  int **nactdof, int *neq, int *nzl,int *icol, int *irow, 
	  int *nmethod, int **ikmpcp, int **ilmpcp, int **ikboun, 
	  int **ilboun,
	  double *elcon, int *nelcon, double *rhcon, int *nrhcon,
          double *cocon, int *ncocon,
	  double *alcon, int *nalcon, double *alzero, int **ielmat,
	  int **ielorien, int *norien, double *orab, int *ntmat_,
	  double *t0, 
	  double *t1,int *ithermal,double *prestr, int *iprestr, 
	  double **voldp,int *iperturb, double *sti, int *nzs, 
	  double *tinc, double *tper, double *xmodal,
	  double *veold, char *amname, double *amta,
	  int *namta, int *nam, int *iamforc, int *iamload,
	  int *iamt1, int *jout,int *kode, char *filab,
	  double **emep, double *xforcold, double *xloadold,
          double *t1old, int **iamboun,
          double **xbounold, int *iexpl, double *plicon, int *nplicon,
          double *plkcon,int *nplkcon,
          double *xstate, int *npmat_, char *matname, int *mint_,
          int *ncmat_, int *nstate_, double **enerp, char *jobnamec,
          double *ttime, char *set, int *nset, int *istartset,
          int *iendset, int *ialset, int *nprint, char *prlab,
          char *prset, int *nener, double *trab, 
          int **inotr, int *ntrans, double **fmpcp, char *cbody, int *ibody,
          double *xbody, int *nbody, double *xbodyold,int *istep,
          int *isolver, int *jq, char *output, int *mcs, int *nkon,
          int *ics, double *cs, int *mpcend);

void FORTRAN(stop,());

int strcmp1(const char *s1, const char *s2);

int strcpy1(char *s1, const char *s2, int length);

void FORTRAN(tempload,(double *xforcold, double *xforc, double *xforcact,
               int *iamforc, int *nforc, double *xloadold, double *xload,
               double *xloadact, int *iamload, int *nload, int *ibody,
               double *xbody, int *nbody,double *xbodyold,double *xbodyact, 
               double *t1old, double *t1, double *t1act, int *iamt1,
               int *nk, double *amta, int *namta, int *nam, double *ampli,
               double *time, double *reltime, double *ttime, double *dtime,
               int *ithermal, int *nmethod,
	       double *xbounold, double *xboun, double *xbounact,
	       int *iamboun, int *nboun,int *nodeboun,
               int *ndirboun,int *nodeforc,int *ndirforc,int *istep,
               int *iint,double *co,double *vold));

void FORTRAN(temploadmodal,(double *amta,int *namta,int *nam,double *ampli,
         double *timemin,double *ttimemin,double *dtime,double *xbounold,
         double *xboun,double *xbounmin,int *iamboun,int *nboun,
         int *nodeboun,int *ndirboun));

void FORTRAN(transformatrix,(double *xab, double *p, double *a));

void *u_calloc(size_t num,size_t size);

void FORTRAN(writebv,(double *, int *));

void writec(char *ifield, int nfield, FILE *f1);

void FORTRAN(writeev,(double *, int *, double *, double *));

void FORTRAN(writehe,(int *));

void FORTRAN(writeevcs,(double *, int *, int *, double *, double *));

void writef(double *ifield, int nfield, FILE *f1);

void writei(int *ifield, int nfield, FILE *f1);

void FORTRAN(writeim,());

void FORTRAN(writeinput,(char *inpc,int *ipoinp,int *inp,int *nline,int *ninp));

void FORTRAN(writempc,(int *, int *, double *, char *,int *));

void FORTRAN(writere,());

void FORTRAN(writesummary,(int *istep, int *j, int *icutb, int *l, double *ttime,
		   double *time, double *dtime));



