20 #define MAXVARIABLES 500
34 var(name, ptr, type, necessary, deflt)
44 sscanf (deflt,
"%lf", &temp);
45 valuer = (
real) (temp);
46 valuei = (int) valuer;
52 if (necessary ==
NO) {
54 *((
int *) ptr) = valuei;
55 }
else if (type ==
REAL) {
56 *((
real *) ptr) = valuer;
57 }
else if (type ==
STRING) {
68 char nm[300], s[350],stringval[290];
72 int i, found, valuei, success, type;
78 input = fopen(filename,
"r");
80 mastererr (
"Unable to read '%s'. Program stopped.\n",filename);
83 mastererr (
"Reading parameters file '%s'.\n", filename);
84 while (fgets(s, 349, input) != NULL) {
85 success = sscanf(s,
"%s ", nm);
86 if ((nm[0] !=
'#') && (success == 1)) {
89 sscanf(s1 + strspn(s1,
"\t :=>_"),
"%lf", &temp);
90 sscanf(s1 + strspn(s1,
"\t :=>_"),
"%289s ", stringval);
93 for (i = 0; i < strlen(nm); i++) {
94 nm[i] = (char) toupper(nm[i]);
98 if (strcmp(nm, VariableSet[i].name) == 0) {
99 if (VariableSet[i].read ==
YES) {
100 mastererr(
"Warning : %s defined more than once.\n", nm);
104 ptri = (
int *) (VariableSet[i].variable);
105 ptrr = (
real *) (VariableSet[i].variable);
106 if (VariableSet[i].type ==
INT) {
108 }
else if (VariableSet[i].type ==
REAL) {
110 }
else if (VariableSet[i].type ==
STRING) {
111 strcpy (VariableSet[i].variable, stringval);
116 mastererr(
"Warning : variable %s defined but non-existent in code.\n", nm);
123 if ((VariableSet[i].read ==
NO) && (VariableSet[i].necessary ==
YES)) {
125 mastererr(
"Fatal error : undefined mandatory variable(s):\n");
136 if (VariableSet[i].read ==
NO) {
138 mastererr(
"Secondary variables omitted :\n");
141 if ((type = VariableSet[i].type) ==
REAL)
142 mastererr(
"%s ;\t Default Value : %.5g\n", VariableSet[i].name, *((
real *) VariableSet[i].variable));
144 mastererr(
"%s ;\t Default Value : %d\n", VariableSet[i].name, *((
int *) VariableSet[i].variable));
146 mastererr(
"%s ;\t Default Value : %s\n", VariableSet[i].name, VariableSet[i].variable);
173 mastererr (
"You cannot use at the same time\n");
174 mastererr (
"VISCOSITY and ALPHAVISCOSITY.\n");
175 mastererr (
"Edit the parameter file so as to remove\n");
176 mastererr (
"one of these variables and run again.\n");
184 mastererr (
"You cannot use at the same time\n");
185 mastererr (
"`ThicknessSmoothing' and `RocheSmoothing'.\n");
186 mastererr (
"Edit the parameter file so as to remove\n");
187 mastererr (
"one of these variables and run again.\n");
191 mastererr (
"A non-vanishing potential smoothing length is required.\n");
192 mastererr (
"Please use either of the following variables:\n");
193 mastererr (
"`ThicknessSmoothing' *or* `RocheSmoothing'.\n");
194 mastererr (
"before launching the run again.\n");
199 masterprint (
"Planet potential smoothing scales with their Hill sphere.\n");
241 mastererr(
"\n#THORIN : Please note that the following usage description corresponds\n");
242 mastererr(
"to the original FARGO code and thus may be inaccurate when using the\n");
243 mastererr(
"THORIN modification. See the THORIN code documentation, README file and\n");
244 mastererr(
"user guide for more information about usage. 2DO: The usage log will be\n");
245 mastererr(
"updated in the next version.\n\n");
246 mastererr(
"Usage : %s [-abcdeimnptvz] [-(0-9)] [-s number] [-f scaling] parameters file\n", execname);
247 mastererr(
"\n-a : Monitor mass and angular momentum at each timestep\n");
248 mastererr(
"-b : Adjust azimuthal velocity to impose strict centrifugal balance at t=0\n");
249 mastererr(
"-c : Sloppy CFL condition (checked at each DT, not at each timestep)\n");
250 mastererr(
"-d : Print some debugging information on 'stdout' at each timestep\n");
251 mastererr(
"-e : Activate EU test problem torque file output\n");
252 mastererr(
"-f : Scale density array by 'scaling'. Useful to increase/decrease\n");
253 mastererr(
" disk surface density after a restart, for instance. \n");
254 mastererr(
"-i : tabulate Sigma profile as given by restart files\n");
255 mastererr(
"-m : Merge output files from different CPUs\n");
256 mastererr(
"-n : Disable simulation. The program just reads parameters file\n");
257 mastererr(
"-o : Overrides output directory of input file.\n");
258 mastererr(
"-p : Give profiling information at each time step\n");
259 mastererr(
"-s : Restart simulation, taking #'number' files as initial conditions\n");
260 mastererr(
"-t : Monitor CPU time usage at each time step\n");
261 mastererr(
"-v : Verbose mode. Tells everything about parameters file\n");
262 mastererr(
"-z : fake sequential built when evaluating sums on HD meshes\n");
263 mastererr(
"-(0-9) : only write initial (or restart) HD meshes,\n");
264 mastererr(
" proceed to the next nth output and exit\n");
265 mastererr(
" This option must stand alone on one switch (-va -4 is legal, -v4a is not)\n");
272 return time/2.0/
PI*sqrt(
G*1.0/1.0/1.0/1.0);
285 printf (
"\n#THORIN: Please note that the information below correspond\n");
286 printf (
"to the original version of FARGO and are inaccurate in some\n");
287 printf (
"cases when using the THORIN modification. 2DO: this will be\n");
288 printf (
"improved in the next version.\n\n");
289 printf (
"\nDisc properties:\n");
290 printf (
"----------------\n");
291 printf (
"Inner Radius : %g\n",
RMIN);
292 printf (
"Outer Radius : %g\n",
RMAX);
294 printf (
"VKep at inner edge : %.3g\n", sqrt(
G*1.0*(1.-0.0)/
RMIN));
295 printf (
"VKep at outer edge : %.3g\n", sqrt(
G*1.0/
RMAX));
297 printf (
"Disk Mass : %g\n", temp);
299 printf (
"Mass inner to r=1.0 : %g \n", temp);
301 printf (
"Mass outer to r=1.0 : %g \n", temp);
302 printf (
"Travelling time for acoustic density waves :\n");
310 printf (
"Orbital time at Rmin : %.3g ~ %.2f outputs\n", temp,
TellNbOutputs(temp));
312 printf (
"Orbital time at Rmax : %.3g ~ %.2f outputs\n", temp,
TellNbOutputs(temp));
313 printf (
"Sound speed :\n");
314 printf (
" * At unit radius : %.3g\n",
ASPECTRATIO*sqrt(
G*1.0));
317 printf (
"\nGrid properties:\n");
318 printf (
"----------------\n");
319 printf (
"Number of rings : %d\n",
NRAD);
320 printf (
"Number of sectors : %d\n",
NSEC);
321 printf (
"Total cells : %d\n",
NRAD*
NSEC);
322 printf (
"\nOutputs properties:\n");
323 printf (
"-------------------\n");
325 printf (
"At each output #i, the following files are written:\n");
326 printf (
"gasdens[i].dat : %d bytes\n",(
int)(
NRAD*NSEC*
sizeof(
real)));
327 printf (
"gasvrad[i].dat : %d bytes\n",(
int)(
NRAD*NSEC*
sizeof(
real)));
328 printf (
"gasvtheta[i].dat : %d bytes\n",(
int)(
NRAD*NSEC*
sizeof(
real)));
330 printf (
"gastemper[i].dat : %d bytes\n",(
int)(
NRAD*NSEC*
sizeof(
real)));
332 printf (
"gaslabel[i].dat : %d bytes\n",(
int)(
NRAD*NSEC*
sizeof(
real)));
333 printf (
"There will be in total %d outputs\n",
NTOT/
NINTERM);
334 printf (
"(which correspond to an elapsed time = %.3f or to %.2f orbits)\n",
NTOT*DT,
TellNbOrbits(
NTOT*DT));
341 temp /= 1024.0*1024.0;
342 printf (
"So the code will produce ~%.2f Mbytes of data\n", temp);
343 printf (
"Check (eg by issuing a 'df' command) that you have enough disk space,\n");
344 printf (
"otherwise you will get a system full and the code will stop.\n");
346 printf (
"\nSpecifications of the energy setup:\n");
347 printf (
"----------------\n");
349 printf (
"This run is isothermal.\n");
351 printf (
"This run is non-isothermal (solves the energy equation).\n");
353 if (
ParametricCooling &&
EnergyEq) printf (
"Parametric cooling is set. No self-consistent heating/cooling source terms will be used!\n\n");
354 if (!
ParametricCooling &&
EnergyEq) printf (
"Implicit solution of the energy equation with all implemented heating/cooling source terms will be performed.\n\n");
362 real total, last, mean, totalu;
368 fprintf (stderr,
"Time counters initialized\n");
370 Ticks = sysconf (_SC_CLK_TCK);
377 mean = totalu / number;
378 fprintf (stderr,
"Total Real Time elapsed : %.3f s\n", total);
379 fprintf (stderr,
"Total CPU Time of process : %.3f s (%.1f %%)\n", totalu, 100.*totalu/total);
380 fprintf (stderr,
"CPU Time since last time step : %.3f s\n", last);
381 fprintf (stderr,
"Mean CPU Time between time steps : %.3f s\n", mean);
395 if (profiling ==
NO)
return;
396 Ticks = sysconf (_SC_CLK_TCK);
398 process_name->
clicks = buffer.tms_utime;
399 strcpy (process_name->
name, title);
409 if (profiling ==
NO)
return;
410 Ticks = sysconf (_SC_CLK_TCK);
412 ticks = buffer.tms_utime - process_name.
clicks;
414 fprintf (stderr,
"Time spent in %s : %.3f s\n", process_name.
name, t);
void PrintUsage(char *execname)
double real
Definition of the type 'real' used throughout the code.
This structure is used for monitoring CPU time usage.
boolean PrescribedAccretion
char TORQUEMAPINFILE[512]
boolean StellarIrradiation
int boolean
The boolean type will be used mainly for the variables corresponding to the command line switches...
char WRITETEMPERATURE[512]
char WRITETORQUEFILES[512]
boolean WriteTorqueMapFile
char PEBBLEACCRETION[512]
char PLANETSFEELDISK[512]
real TellNbOrbits(real time)
int necessary
Tell whether defining the parameter is optional or mandatory.
char RESOLVECOLLISIONS[512]
char ACCRETIONALHEATING[512]
char OUTERSOURCEMASS[512]
char INITIALIZEFROMFILE[512]
char STELLARIRRADIATION[512]
char * variable
A pointer to the corresponding variable.
void GiveTimeInfo(int number)
The Param structure handles the parameters of the parameter file.
void var(char *name, char *ptr, int type, int necessary, char *deflt)
char OPENINNERBOUNDARY[512]
void mastererr(const char *template,...)
static clock_t PreceedingUser
real TellNbOutputs(real time)
int read
This variable is set to YES if and only if the parameter has been found in the parameter file...
static Param VariableSet[MAXVARIABLES]
Contains all the include directives requested by the code.
boolean Write_Temperature
int type
Type of the parameter (e.g.
static clock_t CurrentUser
boolean ParametricCooling
void GiveSpecificTime(boolean profiling, TimeProcess process_name)
void ReadVariables(char *filename)
static clock_t Preceeding
void InitSpecificTime(boolean profiling, TimeProcess *process_name, char *title)
boolean OverridesOutputdir
char PARTICLEDIFFUSION[512]
void masterprint(const char *template,...)
boolean DiffusiveParticles