#include /* This saves and loads parameters etc when you are out to lunch .... */ #include #include #include #include #include "xpplim.h" #include "struct.h" #include "shoot.h" #define READEM 1 #define VOLTERRA 6 double atof(); extern Window main_win; extern GRAPH *MyGraph; extern BC_STRUCT my_bc[MAXODE]; typedef struct { char *name,*value; } FIXINFO; extern FIXINFO fixinfo[MAXODE]; extern int FIX_VAR,NFUN; extern int NJMP,NMESH,METHOD,NODE,POIMAP,POIVAR,POISGN,SOS,INFLAG,NMarkov; extern int NUPAR,NEQ,BVP_MAXIT,EVEC_ITER,DelayFlag,MyStart; extern double last_ic[MAXODE],MyData[MAXODE],MyTime,LastTime; extern double TEND,DELTA_T,T0,TRANS,BOUND,HMIN,HMAX,TOLER,ATOLER,DELAY; extern double POIPLN,EVEC_ERR,NEWT_ERR; extern double BVP_TOL,BVP_EPS; extern int MaxPoints; extern char upar_names[MAXPAR][11],this_file[100],delay_string[MAXODE][80]; extern char uvar_names[MAXODE][12]; extern char *ode_names[MAXODE],*fix_names[MAXODE]; file_inf() { int ok; FILE *fp; char filename[256]; sprintf(filename,"%s.pars",this_file); ping(); if(!file_selector("Save info",filename,"*.pars*"))return; /* if(new_string("Filename: ",filename)==0)return; */ open_write_file(&fp,filename,&ok); if(!ok)return; redraw_params(); do_info(fp); fclose(fp); } do_info(fp) FILE *fp; { int i; static char *method[]={"Discrete","Euler","Mod. Euler", "Runge-Kutta","Adams","Gear","Volterra","BackEul","QualRK", "Stiff","CVode"}; int div,rem; int j; double z; char bob[200]; char fstr[15]; fprintf(fp,"File: %s \n\n Equations... \n",this_file); for(i=0;i0)strcpy(fstr,"d%s/dT=%s\n"); if(i=NODE)strcpy(fstr,"%s=%s\n"); fprintf(fp,fstr,uvar_names[i],ode_names[i]); } if(FIX_VAR>0){ fprintf(fp,"\nwhere ...\n"); for(i=0;i0){ fprintf(fp, "\nUser-defined functions:\n"); user_fun_info(fp); } fprintf(fp,"\n\n Numerical parameters ...\n"); fprintf(fp,"NJMP=%d NMESH=%d METHOD=%s EVEC_ITER=%d \n", NJMP,NMESH,method[METHOD],EVEC_ITER); fprintf(fp,"BVP_EPS=%g,BVP_TOL=%g,BVP_MAXIT=%d \n", BVP_EPS,BVP_TOL,BVP_MAXIT); fprintf(fp,"DT=%g T0=%g TRANS=%g TEND=%g BOUND=%g DELAY=%g MaxPts=%d\n", DELTA_T,T0,TRANS,TEND,BOUND,DELAY,MaxPoints); fprintf(fp,"EVEC_ERR=%g, NEWT_ERR=%g HMIN=%g HMAX=%g TOLER=%g \n", EVEC_ERR,NEWT_ERR,HMIN,HMAX,TOLER); if(POIVAR==0)strcpy(bob,"T"); else strcpy(bob,uvar_names[POIVAR-1]); fprintf(fp,"POIMAP=%d POIVAR=%s POIPLN=%g POISGN=%d \n", POIMAP,bob,POIPLN,POISGN); fprintf(fp,"\n\n Delay strings ...\n"); for(i=0;irm[k][j]),fp,f); for(j=0;jxv[j]),fp,f); io_int(&(MyGraph->yv[j]),fp,f); io_int(&(MyGraph->zv[j]),fp,f); io_int(&(MyGraph->line[j]),fp,f); io_int(&(MyGraph->color[j]),fp,f); } io_double(&(MyGraph->ZPlane),fp,f); io_double(&(MyGraph->ZView),fp,f); io_int(&(MyGraph->PerspFlag),fp,f); io_int(&(MyGraph->ThreeDFlag),fp,f); io_int(&(MyGraph->TimeFlag),fp,f); io_int(&(MyGraph->ColorFlag),fp,f); io_int(&(MyGraph->grtype),fp,f); io_double(&(MyGraph->color_scale),fp,f); io_double(&(MyGraph->min_scale),fp,f); io_double(&(MyGraph->xmax),fp,f); io_double(&(MyGraph->xmin),fp,f); io_double(&(MyGraph->ymax),fp,f); io_double(&(MyGraph->ymin),fp,f); io_double(&(MyGraph->zmax),fp,f); io_double(&(MyGraph->zmin),fp,f); io_double(&(MyGraph->xbar),fp,f); io_double(&(MyGraph->dx ),fp,f); io_double(&(MyGraph->ybar),fp,f); io_double(&(MyGraph->dy ),fp,f); io_double(&(MyGraph->zbar),fp,f); io_double(&(MyGraph->dz ),fp,f); io_double(&(MyGraph->Theta),fp,f); io_double(&(MyGraph->Phi),fp,f); io_int(&(MyGraph->xshft),fp,f); io_int(&(MyGraph->yshft),fp,f); io_int(&(MyGraph->zshft),fp,f); io_double(&(MyGraph->xlo),fp,f); io_double(&(MyGraph->ylo),fp,f); io_double(&(MyGraph->oldxlo),fp,f); io_double(&(MyGraph->oldylo),fp,f); io_double(&(MyGraph->xhi),fp,f); io_double(&(MyGraph->yhi),fp,f); io_double(&(MyGraph->oldxhi),fp,f); io_double(&(MyGraph->oldyhi),fp,f); if(f==READEM)redraw_the_graph(); } io_int(i,fp,f) int *i,f; FILE *fp; { char bob[81]; if(f==READEM){ fgets(bob,80,fp); *i=atoi(bob); } else fprintf(fp,"%d\n",*i); } io_double(z,fp,f) int f; FILE *fp; double *z; { char bob[81]; if(f==READEM){ fgets(bob,80,fp); *z=atof(bob); } else fprintf(fp,"%.16g\n",*z); } io_float(z,fp,f) int f; FILE *fp; float *z; { char bob[81]; if(f==READEM){ fgets(bob,80,fp); *z=(float)atof(bob); } else fprintf(fp,"%.16g\n",*z); } io_int_array(k,n,fp,f) int n,f,*k; FILE *fp; { int i; for(i=0;i