/* cc detspat2b.c -o bdetspat -lm */ #include #include #define MAXTIME 5000 #define OUTTIME 100 #define PSTIME 50 #define CELLS 100 #define PSSKIP 1 #define DELTAT 0.1 #define STEPSPERT 10 /* 1/DELTAT */ #define ALPHA1 0.25 #define ALPHA2 0.25 #define BETA12 0.075 /* b12+b21<0 */ #define BETA21 0.1 #define MU1 0.05 #define MU2 0.05 double n1[CELLS], n2[CELLS]; double babes1[CELLS], babes2[CELLS]; double disp1[CELLS], disp2[CELLS]; int dist1, dist2; double n1cnt, n2cnt; double alpha1, alpha2, beta12, beta21, mu1, mu2; void InitStuff(void); void MakeBabes(void); void CompeteAndDie(void); void DisperseBabes(double *, double *, double *, double *, int); void AddBabes(void); void Measurements(void); void Spit_EPS_Header(FILE *, int, int); void Spit_EPS_Row(FILE *, double *); void Spit_EPS_Trailer(FILE *); int main(void) { int i, j; FILE *fopen(const char *, const char *), *fileid1, *fileid2; fileid1 = fopen("detspat1.eps","w"); fileid2 = fopen("detspat2.eps","w"); InitStuff(); printf("Enter dispersal distances dist1 and dist2:\n"); scanf("%d %d",&dist1,&dist2); Spit_EPS_Header(fileid1,CELLS/PSSKIP,MAXTIME/PSTIME); Spit_EPS_Header(fileid2,CELLS/PSSKIP,MAXTIME/PSTIME); for(i=0;iCELLS) { disp[CELLS-1] += (kmax-CELLS)*babes_per_cell *(1.0-pop1[CELLS-1]-pop2[CELLS-1]); kmax = CELLS; } for(k=kmin;k700.0) { rat = 700.0/newl; newl = 700.0; neww = rat*neww; } /* 8.5x11 page with no margins is 612x792 points */ xorigin = (612 - neww)/2.0; yorigin = (792 - newl)/2.0; /* defines compliance */ fprintf(fileid,"%%!PS-Adobe-2.0 EPSF-2.0\n"); /* defines size of image */ fprintf(fileid,"%%%%BoundingBox: %f %f %f %f\n", xorigin, yorigin,xorigin+neww,yorigin+newl); /* save present graphics state */ fprintf(fileid,"gsave\n"); /* put box around image */ fprintf(fileid,"%f %f moveto\n",xorigin-1,yorigin-1); fprintf(fileid,"%f %f lineto\n",xorigin-1,yorigin+newl+1); fprintf(fileid,"%f %f lineto\n",xorigin+neww+1,yorigin+newl+1); fprintf(fileid,"%f %f lineto\n",xorigin+neww+1,yorigin-1); fprintf(fileid,"%f %f lineto\n",xorigin-1,yorigin-1); fprintf(fileid,"stroke\n\n",xorigin-1,yorigin-1); /* define procedure "bufstr" to read strings of "width" characters */ fprintf(fileid,"/bufstr %d string def\n\n",width); /* move to origin of image */ fprintf(fileid,"%f %f translate\n",xorigin,yorigin); /* define the scale (default is 1 pt I guess) */ fprintf(fileid,"%f %f scale\n\n",neww,newl); /* width, height, and number of bits per pixel */ fprintf(fileid,"%d %d 4\n",width,length); /* a matrix definition that I don't understand */ fprintf(fileid,"[%d 0 0 %d 0 %d]\n",width,-length,length); /* guidelines on how to read the image data */ fprintf(fileid,"{currentfile bufstr readhexstring pop} bind image\n"); } void Spit_EPS_Row(FILE *fileid, double *pop) { int i; for(i=0;i0.5) fprintf(fileid,"0"); else fprintf(fileid,"F"); if((i+1)%60==0) fprintf(fileid,"\n"); } fprintf(fileid,"\n"); } void Spit_EPS_Trailer(FILE *fileid) { fprintf(fileid,"grestore\n"); fprintf(fileid,"showpage\n"); }