103 printf(
"Error: simulation object array is NULL!\n");
104 printf(
"Please consider killing this run.\n");
111 for (n = 0; n < nsims; n++) {
127 #if defined(HAVE_CUDA)
131 strcpy(sim[n].solver.time_scheme ,
"euler" );
132 strcpy(sim[n].solver.time_scheme_type ,
" " );
133 strcpy(sim[n].solver.spatial_scheme_hyp ,
"1" );
134 strcpy(sim[n].solver.spatial_type_par ,
_NC_1STAGE_ );
135 strcpy(sim[n].solver.spatial_scheme_par ,
"2" );
136 strcpy(sim[n].solver.interp_type ,
"characteristic");
137 strcpy(sim[n].solver.ip_file_type ,
"ascii" );
138 strcpy(sim[n].solver.input_mode ,
"serial" );
139 strcpy(sim[n].solver.output_mode ,
"serial" );
140 strcpy(sim[n].solver.op_file_format ,
"text" );
141 strcpy(sim[n].solver.op_overwrite ,
"no" );
142 strcpy(sim[n].solver.plot_solution ,
"no" );
143 strcpy(sim[n].solver.model ,
"none" );
144 strcpy(sim[n].solver.ConservationCheck ,
"no" );
145 strcpy(sim[n].solver.SplitHyperbolicFlux,
"no" );
146 strcpy(sim[n].solver.ib_filename ,
"none" );
151 printf(
"Reading solver inputs from file \"solver.inp\".\n");
152 in = fopen(
"solver.inp",
"r");
154 fprintf(stderr,
"Error: File \"solver.inp\" not found.\n");
155 fprintf(stderr,
"Please consider killing this run.\n");
161 ferr = fscanf(in,
"%s",word);
if (ferr != 1)
return(1);
163 if (!strcmp(word,
"begin")){
165 while (strcmp(word,
"end")) {
167 ferr = fscanf(in,
"%s",word);
if (ferr != 1)
return(1);
169 if (!strcmp(word,
"ndims")) {
171 ferr = fscanf(in,
"%d",&(sim[0].solver.ndims));
if (ferr != 1)
return(1);
173 sim[0].
mpi.
iproc = (
int*) calloc (sim[0].solver.ndims,
sizeof(
int));
177 for (n = 1; n < nsims; n++) {
180 sim[n].
mpi.
iproc = (
int*) calloc (sim[n].solver.ndims,
sizeof(
int));
184 }
else if (!strcmp(word,
"nvars")) {
186 ferr = fscanf(in,
"%d",&(sim[0].solver.nvars));
187 for (
int n = 1; n < nsims; n++) sim[n].solver.nvars = sim[0].
solver.
nvars;
189 }
else if (!strcmp(word,
"size")) {
191 for (
int n = 0; n < nsims; n++) {
192 if (!sim[n].solver.dim_global) {
193 fprintf(stderr,
"Error in ReadInputs(): dim_global not allocated for n=%d.\n", n);
194 fprintf(stderr,
"Please specify ndims before dimensions.\n" );
198 ferr = fscanf(in,
"%d",&(sim[n].solver.dim_global[i]));
200 fprintf(stderr,
"Error in ReadInputs() while reading grid sizes for domain %d.\n", n);
208 }
else if (!strcmp(word,
"size_exact")) {
210 for (
int n = 0; n < nsims; n++) {
211 if (!sim[n].solver.dim_global_ex) {
212 fprintf(stderr,
"Error in ReadInputs(): dim_global_ex not allocated for n=%d.\n", n);
213 fprintf(stderr,
"Please specify ndims before dimensions.\n" );
217 ferr = fscanf(in,
"%d",&(sim[n].solver.dim_global_ex[i]));
219 fprintf(stderr,
"Error in ReadInputs() while reading exact solution grid sizes for domain %d.\n", n);
226 }
else if (!strcmp(word,
"iproc")) {
229 for (n = 0; n < nsims; n++) {
230 if (!sim[n].mpi.iproc) {
231 fprintf(stderr,
"Error in ReadInputs(): iproc not allocated for n=%d.\n", n);
232 fprintf(stderr,
"Please specify ndims before iproc.\n" );
237 ferr = fscanf(in,
"%d",&(sim[n].mpi.iproc[i]));
239 fprintf(stderr,
"Error in ReadInputs() while reading iproc for domain %d.\n", n);
246 }
else if (!strcmp(word,
"ghost")) {
248 ferr = fscanf(in,
"%d",&(sim[0].solver.ghosts));
251 for (n = 1; n < nsims; n++) sim[n].solver.ghosts = sim[0].
solver.
ghosts;
253 }
else if (!strcmp(word,
"n_iter")) {
255 ferr = fscanf(in,
"%d",&(sim[0].solver.n_iter));
258 for (n = 1; n < nsims; n++) sim[n].solver.n_iter = sim[0].
solver.
n_iter;
260 }
else if (!strcmp(word,
"restart_iter")) {
262 ferr = fscanf(in,
"%d",&(sim[0].solver.restart_iter));
267 }
else if (!strcmp(word,
"time_scheme")) {
269 ferr = fscanf(in,
"%s",sim[0].solver.time_scheme);
272 for (n = 1; n < nsims; n++) strcpy(sim[n].solver.time_scheme, sim[0].
solver.
time_scheme);
274 }
else if (!strcmp(word,
"time_scheme_type" )) {
276 ferr = fscanf(in,
"%s",sim[0].solver.time_scheme_type);
281 }
else if (!strcmp(word,
"hyp_space_scheme")) {
283 ferr = fscanf(in,
"%s",sim[0].solver.spatial_scheme_hyp);
288 }
else if (!strcmp(word,
"hyp_flux_split")) {
290 ferr = fscanf(in,
"%s",sim[0].solver.SplitHyperbolicFlux);
295 }
else if (!strcmp(word,
"hyp_interp_type")) {
297 ferr = fscanf(in,
"%s",sim[0].solver.interp_type);
300 for (n = 1; n < nsims; n++) strcpy(sim[n].solver.interp_type, sim[0].
solver.
interp_type);
302 }
else if (!strcmp(word,
"par_space_type")) {
304 ferr = fscanf(in,
"%s",sim[0].solver.spatial_type_par);
309 }
else if (!strcmp(word,
"par_space_scheme")) {
311 ferr = fscanf(in,
"%s",sim[0].solver.spatial_scheme_par);
316 }
else if (!strcmp(word,
"dt")) {
318 ferr = fscanf(in,
"%lf",&(sim[0].solver.dt));
321 for (n = 1; n < nsims; n++) sim[n].solver.dt = sim[0].
solver.
dt;
323 }
else if (!strcmp(word,
"conservation_check" )) {
325 ferr = fscanf(in,
"%s",sim[0].solver.ConservationCheck);
330 }
else if (!strcmp(word,
"screen_op_iter")) {
332 ferr = fscanf(in,
"%d",&(sim[0].solver.screen_op_iter));
337 }
else if (!strcmp(word,
"file_op_iter")) {
339 ferr = fscanf(in,
"%d",&(sim[0].solver.file_op_iter));
344 }
else if (!strcmp(word,
"op_file_format")) {
346 ferr = fscanf(in,
"%s",sim[0].solver.op_file_format);
351 }
else if (!strcmp(word,
"ip_file_type")) {
353 ferr = fscanf(in,
"%s",sim[0].solver.ip_file_type);
356 for (n = 1; n < nsims; n++) strcpy(sim[n].solver.ip_file_type, sim[0].
solver.
ip_file_type);
358 }
else if (!strcmp(word,
"input_mode")) {
360 ferr = fscanf(in,
"%s",sim[0].solver.input_mode);
361 if (strcmp(sim[0].solver.input_mode,
"serial")) ferr = fscanf(in,
"%d",&(sim[0].mpi.N_IORanks));
364 for (n = 1; n < nsims; n++) {
369 }
else if (!strcmp(word,
"output_mode")) {
371 ferr = fscanf(in,
"%s",sim[0].solver.output_mode);
372 if (strcmp(sim[0].solver.output_mode,
"serial")) ferr = fscanf(in,
"%d",&(sim[0].mpi.N_IORanks));
375 for (n = 1; n < nsims; n++) {
380 }
else if (!strcmp(word,
"op_overwrite")) {
382 ferr = fscanf(in,
"%s",sim[0].solver.op_overwrite);
385 for (n = 1; n < nsims; n++) strcpy(sim[n].solver.op_overwrite, sim[0].
solver.
op_overwrite);
387 }
else if (!strcmp(word,
"plot_solution")) {
389 ferr = fscanf(in,
"%s",sim[0].solver.plot_solution);
392 for (n = 1; n < nsims; n++) strcpy(sim[n].solver.plot_solution, sim[0].
solver.
plot_solution);
394 }
else if (!strcmp(word,
"model")) {
396 ferr = fscanf(in,
"%s",sim[0].solver.model);
399 for (n = 1; n < nsims; n++) strcpy(sim[n].solver.model, sim[0].
solver.
model);
401 }
else if (!strcmp(word,
"immersed_body")) {
403 ferr = fscanf(in,
"%s",sim[0].solver.ib_filename);
406 for (n = 1; n < nsims; n++) strcpy(sim[n].solver.ib_filename, sim[0].
solver.
ib_filename);
409 #if defined(HAVE_CUDA)
410 else if (!strcmp(word,
"use_gpu")) {
411 ferr = fscanf(in,
"%s",word);
412 if (!strcmp(word,
"yes") || !strcmp(word,
"true")) sim[0].
solver.
use_gpu = 1;
415 for (n = 1; n < nsims; n++) sim[n].solver.use_gpu = sim[0].
solver.
use_gpu;
416 }
else if (!strcmp(word,
"gpu_device_no")) {
417 ferr = fscanf(in,
"%d", &sim[0].solver.gpu_device_no);
423 else if (strcmp(word,
"end")) {
426 ferr = fscanf(in,
"%s",useless);
427 printf(
"Warning: keyword %s in file \"solver.inp\" with value %s not recognized or extraneous. Ignoring.\n",
431 if (ferr != 1)
return(1);
437 fprintf(stderr,
"Error: Illegal format in file \"solver.inp\".\n");
446 for (n = 0; n < nsims; n++) {
451 if ((sim[n].solver.ndims != 3) && (strcmp(sim[n].solver.ib_filename,
"none"))) {
452 printf(
"Warning: immersed boundaries not implemented for ndims = %d. ",sim[n].solver.ndims);
453 printf(
"Ignoring input for \"immersed_body\" (%s).\n",sim[n].solver.ib_filename);
454 strcpy(sim[n].solver.ib_filename,
"none");
456 sim[n].
solver.
flag_ib = strcmp(sim[n].solver.ib_filename,
"none");
459 if ((sim[n].solver.restart_iter != 0) && strcmp(sim[n].solver.op_file_format,
"binary")) {
460 if (!sim[n].mpi.rank) fprintf(stderr,
"Error in ReadInputs(): Restart is supported only for binary output files.\n");
467 for (n = 0; n < nsims; n++) {
471 if (sim[n].mpi.rank) {
473 sim[n].
mpi.
iproc = (
int*) calloc (sim[n].solver.ndims,
sizeof(
int));
487 #if defined(HAVE_CUDA)
char spatial_scheme_hyp[_MAX_STRING_SIZE_]
char ib_filename[_MAX_STRING_SIZE_]
int MPIBroadcast_double(double *, int, int, void *)
char input_mode[_MAX_STRING_SIZE_]
char spatial_type_par[_MAX_STRING_SIZE_]
char model[_MAX_STRING_SIZE_]
char plot_solution[_MAX_STRING_SIZE_]
char op_file_format[_MAX_STRING_SIZE_]
#define _MAX_STRING_SIZE_
char ConservationCheck[_MAX_STRING_SIZE_]
char time_scheme[_MAX_STRING_SIZE_]
char op_overwrite[_MAX_STRING_SIZE_]
char ip_file_type[_MAX_STRING_SIZE_]
char spatial_scheme_par[_MAX_STRING_SIZE_]
char time_scheme_type[_MAX_STRING_SIZE_]
char interp_type[_MAX_STRING_SIZE_]
int MPIBroadcast_character(char *, int, int, void *)
Structure defining a simulation.
char SplitHyperbolicFlux[_MAX_STRING_SIZE_]
char output_mode[_MAX_STRING_SIZE_]
int MPIBroadcast_integer(int *, int, int, void *)