18 char name_dim[1024], name_rad[1024];
24 sprintf (name_dim,
"%sdims.dat",
OUTPUTDIR);
25 sprintf (name_rad,
"%sused_rad.dat",
OUTPUTDIR);
26 DIM = fopen (name_dim,
"r");
27 if (DIM == NULL)
return;
28 RAD = fopen (name_rad,
"r");
29 if (RAD == NULL)
return;
30 fscanf (DIM,
"%d %d %d %d %f %d %d %d\n",&foo,&foo,&foo,&foo,&Foo,&foo,&
OldNRAD,&
OldNSEC);
31 for (i = 0; i <=
OldNRAD; i++) {
32 fscanf (RAD,
"%lf", &value);
46 boolean RebinNeeded =
NO, found;
47 char radix[1024], filename[1024];
48 int i, iold, jold, l, j, lo, loip, lojp, loipjp, type;
49 real ifrac, jfrac, jreal, r, angle, dangle;
51 real *Old_r, *OldArray, *NewArray;
55 for (i = 0; i <=
NRAD; i++) {
58 if (!RebinNeeded)
return;
59 printf (
"Restart/Old mesh mismatch. Rebin needed.\n");
62 if ((OldArray == NULL) || (NewArray == NULL)) {
63 mastererr (
"Not enough memory left for rebining.\n");
67 for (type = 0; type < 4; type++) {
72 case 0: sprintf (radix,
"dens");
break;
73 case 1: sprintf (radix,
"vrad");
77 case 2: sprintf (radix,
"vtheta"); dangle = 0.5;
break;
78 case 3: sprintf (radix,
"label");
break;
84 sprintf (filename,
"%sgas%s%d.dat",
OUTPUTDIR, radix, nb);
85 ARR = fopen (filename,
"r");
93 while ((iold <
OldNRAD) && (!found)) {
94 if (Old_r[iold+1] <= r) iold++;
100 }
else if (r >= Old_r[
OldNRAD-1]) {
104 ifrac = (r-Old_r[iold])/(Old_r[iold+1]-Old_r[iold]);
105 printf (
"%d\t%d\t%g\n", i, iold, ifrac);
106 for (j = 0; j <
NSEC; j++) {
108 angle = ((
real)j-dangle)/(
real)NSEC*2.0*M_PI;
109 jreal = angle/2.0/M_PI*(
real)OldNSEC+dangle;
110 while (jreal < 0.0) jreal += (
real)OldNSEC;
113 jfrac = jreal-(
real)jold;
116 lojp = (jold == OldNSEC-1 ? lo-OldNSEC+1 : lo+1);
118 NewArray[l] = OldArray[lo]*(1.0-ifrac)*(1.-jfrac)+\
119 OldArray[lojp]*(1.0-ifrac)*jfrac+\
120 OldArray[loip]*ifrac*(1.0-jfrac)+\
121 OldArray[loipjp]*ifrac*jfrac;
124 ARR =
fopenp (filename,
"w");
129 mastererr(
"Could not rebin %s. File not found\n", filename);
double real
Definition of the type 'real' used throughout the code.
FILE * fopenp(char *string, char *mode)
static real OldRmed[MAX1D]
void mastererr(const char *template,...)
Contains all the include directives requested by the code.
static real OldRadii[MAX1D]