Fast Auxiliary Space Preconditioning  1.8.4 Feb/15/2016
input.c
Go to the documentation of this file.
1 
6 #include "fasp.h"
7 #include "fasp_functs.h"
8 
9 /*---------------------------------*/
10 /*-- Public Functions --*/
11 /*---------------------------------*/
12 
26 {
27  SHORT status = FASP_SUCCESS;
28 
29  if ( inparam->problem_num<0
30  || inparam->solver_type<0
31  || inparam->solver_type>50
32  || inparam->precond_type<0
33  || inparam->itsolver_tol<0
34  || inparam->itsolver_maxit<0
35  || inparam->stop_type<=0
36  || inparam->stop_type>3
37  || inparam->restart<0
38  || inparam->ILU_type<=0
39  || inparam->ILU_type>3
40  || inparam->ILU_lfil<0
41  || inparam->ILU_droptol<=0
42  || inparam->ILU_relax<0
43  || inparam->ILU_permtol<0
44  || inparam->Schwarz_mmsize<0
45  || inparam->Schwarz_maxlvl<0
46  || inparam->Schwarz_type<0
47  || inparam->Schwarz_blksolver<0
48  || inparam->AMG_type<=0
49  || inparam->AMG_type>3
50  || inparam->AMG_cycle_type<=0
51  || inparam->AMG_cycle_type>4
52  || inparam->AMG_levels<0
53  || inparam->AMG_ILU_levels<0
54  || inparam->AMG_coarse_dof<=0
55  || inparam->AMG_tol<0
56  || inparam->AMG_maxit<0
57  || inparam->AMG_coarsening_type<=0
58  || inparam->AMG_coarsening_type>4
59  || inparam->AMG_coarse_solver<0
60  || inparam->AMG_interpolation_type<0
61  || inparam->AMG_interpolation_type>5
62  || inparam->AMG_smoother<0
63  || inparam->AMG_smoother>20
64  || inparam->AMG_strong_threshold<0.0
65  || inparam->AMG_strong_threshold>0.9999
66  || inparam->AMG_truncation_threshold<0.0
67  || inparam->AMG_truncation_threshold>0.9999
68  || inparam->AMG_max_row_sum<0.0
69  || inparam->AMG_presmooth_iter<0
70  || inparam->AMG_postsmooth_iter<0
71  || inparam->AMG_amli_degree<0
72  || inparam->AMG_aggressive_level<0
73  || inparam->AMG_aggressive_path<0
74  || inparam->AMG_aggregation_type<0
75  || inparam->AMG_pair_number<0
76  || inparam->AMG_strong_coupled<0
77  || inparam->AMG_max_aggregation<=0
78  || inparam->AMG_tentative_smooth<0
79  || inparam->AMG_smooth_filter<0
80  ) status = ERROR_INPUT_PAR;
81 
82  return status;
83 }
84 
102 void fasp_param_input (const char *filenm,
103  input_param *inparam)
104 {
105  char buffer[500]; // Note: max number of char for each line!
106  int val;
107  SHORT status = FASP_SUCCESS;
108 
109  // set default input parameters
110  fasp_param_input_init(inparam);
111 
112  // if input file is not specified, use the default values
113  if (filenm==NULL) return;
114 
115  FILE *fp = fopen(filenm,"r");
116  if (fp==NULL) {
117  printf("### ERROR: Could not open file %s...\n", filenm);
118  fasp_chkerr(ERROR_OPEN_FILE, "fasp_param_input");
119 
120  }
121 
122  while ( status == FASP_SUCCESS ) {
123  int ibuff;
124  double dbuff;
125  char sbuff[500];
126 
127  val = fscanf(fp,"%s",buffer);
128  if (val==EOF) break;
129  if (val!=1){ status = ERROR_INPUT_PAR; break; }
130  if (buffer[0]=='[' || buffer[0]=='%' || buffer[0]=='|') {
131  fgets(buffer,500,fp); // skip rest of line
132  continue;
133  }
134 
135  // match keyword and scan for value
136  if (strcmp(buffer,"workdir")==0) {
137  val = fscanf(fp,"%s",buffer);
138  if (val!=1 || strcmp(buffer,"=")!=0) {
139  status = ERROR_INPUT_PAR; break;
140  }
141  val = fscanf(fp,"%s",sbuff);
142  if (val!=1) { status = ERROR_INPUT_PAR; break; }
143  strncpy(inparam->workdir,sbuff,128);
144  fgets(buffer,500,fp); // skip rest of line
145  }
146 
147  else if (strcmp(buffer,"problem_num")==0) {
148  val = fscanf(fp,"%s",buffer);
149  if (val!=1 || strcmp(buffer,"=")!=0) {
150  status = ERROR_INPUT_PAR; break;
151  }
152  val = fscanf(fp,"%d",&ibuff);
153  if (val!=1) { status = ERROR_INPUT_PAR; break; }
154  inparam->problem_num=ibuff;
155  fgets(buffer,500,fp); // skip rest of line
156  }
157 
158  else if (strcmp(buffer,"print_level")==0) {
159  val = fscanf(fp,"%s",buffer);
160  if (val!=1 || strcmp(buffer,"=")!=0) {
161  status = ERROR_INPUT_PAR; break;
162  }
163  val = fscanf(fp,"%d",&ibuff);
164  if (val!=1) { status = ERROR_INPUT_PAR; break; }
165  inparam->print_level = ibuff;
166  fgets(buffer,500,fp); // skip rest of line
167  }
168 
169  else if (strcmp(buffer,"output_type")==0) {
170  val = fscanf(fp,"%s",buffer);
171  if (val!=1 || strcmp(buffer,"=")!=0) {
172  status = ERROR_INPUT_PAR; break;
173  }
174  val = fscanf(fp,"%d",&ibuff);
175  if (val!=1) { status = ERROR_INPUT_PAR; break; }
176  inparam->output_type = ibuff;
177  fgets(buffer,500,fp); // skip rest of line
178  }
179 
180  else if (strcmp(buffer,"solver_type")==0) {
181  val = fscanf(fp,"%s",buffer);
182  if (val!=1 || strcmp(buffer,"=")!=0) {
183  status = ERROR_INPUT_PAR; break;
184  }
185  val = fscanf(fp,"%d",&ibuff);
186  if (val!=1) { status = ERROR_INPUT_PAR; break; }
187  inparam->solver_type = ibuff;
188  fgets(buffer,500,fp); // skip rest of line
189  }
190 
191  else if (strcmp(buffer,"stop_type")==0) {
192  val = fscanf(fp,"%s",buffer);
193  if (val!=1 || strcmp(buffer,"=")!=0) {
194  status = ERROR_INPUT_PAR; break;
195  }
196  val = fscanf(fp,"%d",&ibuff);
197  if (val!=1) { status = ERROR_INPUT_PAR; break; }
198  inparam->stop_type = ibuff;
199  fgets(buffer,500,fp); // skip rest of line
200  }
201 
202  else if (strcmp(buffer,"precond_type")==0) {
203  val = fscanf(fp,"%s",buffer);
204  if (val!=1 || strcmp(buffer,"=")!=0) {
205  status = ERROR_INPUT_PAR; break;
206  }
207  val = fscanf(fp,"%d",&ibuff);
208  if (val!=1) { status = ERROR_INPUT_PAR; break; }
209  inparam->precond_type = ibuff;
210  fgets(buffer,500,fp); // skip rest of line
211  }
212 
213  else if (strcmp(buffer,"itsolver_tol")==0) {
214  val = fscanf(fp,"%s",buffer);
215  if (val!=1 || strcmp(buffer,"=")!=0) {
216  status = ERROR_INPUT_PAR; break;
217  }
218  val = fscanf(fp,"%lf",&dbuff);
219  if (val!=1) { status = ERROR_INPUT_PAR; break; }
220  inparam->itsolver_tol = dbuff;
221  fgets(buffer,500,fp); // skip rest of line
222  }
223 
224  else if (strcmp(buffer,"itsolver_maxit")==0) {
225  val = fscanf(fp,"%s",buffer);
226  if (val!=1 || strcmp(buffer,"=")!=0) {
227  status = ERROR_INPUT_PAR; break;
228  }
229  val = fscanf(fp,"%d",&ibuff);
230  if (val!=1) { status = ERROR_INPUT_PAR; break; }
231  inparam->itsolver_maxit = ibuff;
232  fgets(buffer,500,fp); // skip rest of line
233  }
234 
235  else if (strcmp(buffer,"AMG_ILU_levels")==0) {
236  val = fscanf(fp,"%s",buffer);
237  if (val!=1 || strcmp(buffer,"=")!=0) {
238  status = ERROR_INPUT_PAR; break;
239  }
240  val = fscanf(fp,"%d",&ibuff);
241  if (val!=1) { status = ERROR_INPUT_PAR; break; }
242  inparam->AMG_ILU_levels = ibuff;
243  fgets(buffer,500,fp); // skip rest of line
244  }
245 
246  else if (strcmp(buffer,"AMG_Schwarz_levels")==0) {
247  val = fscanf(fp,"%s",buffer);
248  if (val!=1 || strcmp(buffer,"=")!=0) {
249  status = ERROR_INPUT_PAR; break;
250  }
251  val = fscanf(fp,"%d",&ibuff);
252  if (val!=1) { status = ERROR_INPUT_PAR; break; }
253  inparam->AMG_Schwarz_levels = ibuff;
254  fgets(buffer,500,fp); // skip rest of line
255  }
256 
257  else if (strcmp(buffer,"itsolver_restart")==0) {
258  val = fscanf(fp,"%s",buffer);
259  if (val!=1 || strcmp(buffer,"=")!=0) {
260  status = ERROR_INPUT_PAR; break;
261  }
262  val = fscanf(fp,"%d",&ibuff);
263  if (val!=1) { status = ERROR_INPUT_PAR; break; }
264  inparam->restart = ibuff;
265  fgets(buffer,500,fp); // skip rest of line
266  }
267 
268  else if (strcmp(buffer,"AMG_type")==0) {
269  val = fscanf(fp,"%s",buffer);
270  if (val!=1 || strcmp(buffer,"=")!=0) {
271  status = ERROR_INPUT_PAR; break;
272  }
273  val = fscanf(fp,"%s",buffer);
274  if (val!=1) { status = ERROR_INPUT_PAR; break; }
275 
276  if ((strcmp(buffer,"C")==0)||(strcmp(buffer,"c")==0))
277  inparam->AMG_type = CLASSIC_AMG;
278  else if ((strcmp(buffer,"SA")==0)||(strcmp(buffer,"sa")==0))
279  inparam->AMG_type = SA_AMG;
280  else if ((strcmp(buffer,"UA")==0)||(strcmp(buffer,"ua")==0))
281  inparam->AMG_type = UA_AMG;
282  else
283  { status = ERROR_INPUT_PAR; break; }
284  fgets(buffer,500,fp); // skip rest of line
285  }
286 
287  else if (strcmp(buffer,"AMG_strong_coupled")==0) {
288  val = fscanf(fp,"%s",buffer);
289  if (val!=1 || strcmp(buffer,"=")!=0) {
290  status = ERROR_INPUT_PAR; break;
291  }
292  val = fscanf(fp,"%lf",&dbuff);
293  if (val!=1) { status = ERROR_INPUT_PAR; break; }
294  inparam->AMG_strong_coupled = dbuff;
295  fgets(buffer,500,fp); // skip rest of line
296  }
297 
298  else if (strcmp(buffer,"AMG_max_aggregation")==0) {
299  val = fscanf(fp,"%s",buffer);
300  if (val!=1 || strcmp(buffer,"=")!=0) {
301  status = ERROR_INPUT_PAR; break;
302  }
303  val = fscanf(fp,"%d",&ibuff);
304  if (val!=1) { status = ERROR_INPUT_PAR; break; }
305  inparam->AMG_max_aggregation = ibuff;
306  fgets(buffer,500,fp); // skip rest of line
307  }
308 
309  else if (strcmp(buffer,"AMG_tentative_smooth")==0) {
310  val = fscanf(fp,"%s",buffer);
311  if (val!=1 || strcmp(buffer,"=")!=0) {
312  status = ERROR_INPUT_PAR; break;
313  }
314  val = fscanf(fp,"%lf",&dbuff);
315  if (val!=1) { status = ERROR_INPUT_PAR; break; }
316  inparam->AMG_tentative_smooth = dbuff;
317  fgets(buffer,500,fp); // skip rest of line
318  }
319 
320  else if (strcmp(buffer,"AMG_smooth_filter")==0) {
321  val = fscanf(fp,"%s",buffer);
322  if (val!=1 || strcmp(buffer,"=")!=0) {
323  status = ERROR_INPUT_PAR; break;
324  }
325  val = fscanf(fp,"%s",buffer);
326  if (val!=1) { status = ERROR_INPUT_PAR; break; }
327 
328  if ((strcmp(buffer,"ON")==0)||(strcmp(buffer,"on")==0)||
329  (strcmp(buffer,"On")==0)||(strcmp(buffer,"oN")==0))
330  inparam->AMG_smooth_filter = ON;
331  else if ((strcmp(buffer,"OFF")==0)||(strcmp(buffer,"off")==0)||
332  (strcmp(buffer,"ofF")==0)||(strcmp(buffer,"oFf")==0)||
333  (strcmp(buffer,"Off")==0)||(strcmp(buffer,"oFF")==0)||
334  (strcmp(buffer,"OfF")==0)||(strcmp(buffer,"OFf")==0))
335  inparam->AMG_smooth_filter = OFF;
336  else
337  { status = ERROR_INPUT_PAR; break; }
338  fgets(buffer,500,fp); // skip rest of line
339  }
340 
341  else if (strcmp(buffer,"AMG_coarse_solver")==0) {
342  val = fscanf(fp,"%s",buffer);
343  if (val!=1 || strcmp(buffer,"=")!=0) {
344  status = ERROR_INPUT_PAR; break;
345  }
346  val = fscanf(fp,"%d",&ibuff);
347  if (val!=1) { status = ERROR_INPUT_PAR; break; }
348  inparam->AMG_coarse_solver = ibuff;
349  fgets(buffer,500,fp); // skip rest of line
350  }
351 
352  else if (strcmp(buffer,"AMG_coarse_scaling")==0) {
353  val = fscanf(fp,"%s",buffer);
354  if (val!=1 || strcmp(buffer,"=")!=0) {
355  status = ERROR_INPUT_PAR; break;
356  }
357  val = fscanf(fp,"%s",buffer);
358  if (val!=1) { status = ERROR_INPUT_PAR; break; }
359 
360  if ((strcmp(buffer,"ON")==0)||(strcmp(buffer,"on")==0)||
361  (strcmp(buffer,"On")==0)||(strcmp(buffer,"oN")==0))
362  inparam->AMG_coarse_scaling = ON;
363  else if ((strcmp(buffer,"OFF")==0)||(strcmp(buffer,"off")==0)||
364  (strcmp(buffer,"ofF")==0)||(strcmp(buffer,"oFf")==0)||
365  (strcmp(buffer,"Off")==0)||(strcmp(buffer,"oFF")==0)||
366  (strcmp(buffer,"OfF")==0)||(strcmp(buffer,"OFf")==0))
367  inparam->AMG_coarse_scaling = OFF;
368  else
369  { status = ERROR_INPUT_PAR; break; }
370  fgets(buffer,500,fp); // skip rest of line
371  }
372 
373  else if (strcmp(buffer,"AMG_levels")==0) {
374  val = fscanf(fp,"%s",buffer);
375  if (val!=1 || strcmp(buffer,"=")!=0) {
376  status = ERROR_INPUT_PAR; break;
377  }
378  val = fscanf(fp,"%d",&ibuff);
379  if (val!=1) { status = ERROR_INPUT_PAR; break; }
380  inparam->AMG_levels = ibuff;
381  fgets(buffer,500,fp); // skip rest of line
382  }
383 
384  else if (strcmp(buffer,"AMG_tol")==0) {
385  val = fscanf(fp,"%s",buffer);
386  if (val!=1 || strcmp(buffer,"=")!=0) {
387  status = ERROR_INPUT_PAR; break;
388  }
389  val = fscanf(fp,"%lf",&dbuff);
390  if (val!=1) { status = ERROR_INPUT_PAR; break; }
391  inparam->AMG_tol = dbuff;
392  fgets(buffer,500,fp); // skip rest of line
393  }
394 
395  else if (strcmp(buffer,"AMG_maxit")==0) {
396  val = fscanf(fp,"%s",buffer);
397  if (val!=1 || strcmp(buffer,"=")!=0) {
398  status = ERROR_INPUT_PAR; break;
399  }
400  val = fscanf(fp,"%d",&ibuff);
401  if (val!=1) { status = ERROR_INPUT_PAR; break; }
402  inparam->AMG_maxit = ibuff;
403  fgets(buffer,500,fp); // skip rest of line
404  }
405 
406  else if (strcmp(buffer,"AMG_coarse_dof")==0) {
407  val = fscanf(fp,"%s",buffer);
408  if (val!=1 || strcmp(buffer,"=")!=0) {
409  status = ERROR_INPUT_PAR; break;
410  }
411  val = fscanf(fp,"%d",&ibuff);
412  if (val!=1) { status = ERROR_INPUT_PAR; break; }
413  inparam->AMG_coarse_dof = ibuff;
414  fgets(buffer,500,fp); // skip rest of line
415  }
416 
417  else if (strcmp(buffer,"AMG_cycle_type")==0) {
418  val = fscanf(fp,"%s",buffer);
419  if (val!=1 || strcmp(buffer,"=")!=0) {
420  status = ERROR_INPUT_PAR; break;
421  }
422  val = fscanf(fp,"%s",buffer);
423  if (val!=1) { status = ERROR_INPUT_PAR; break; }
424 
425  if ((strcmp(buffer,"V")==0)||(strcmp(buffer,"v")==0))
426  inparam->AMG_cycle_type = V_CYCLE;
427  else if ((strcmp(buffer,"W")==0)||(strcmp(buffer,"w")==0))
428  inparam->AMG_cycle_type = W_CYCLE;
429  else if ((strcmp(buffer,"A")==0)||(strcmp(buffer,"a")==0))
430  inparam->AMG_cycle_type = AMLI_CYCLE;
431  else if ((strcmp(buffer,"NA")==0)||(strcmp(buffer,"na")==0))
432  inparam->AMG_cycle_type = NL_AMLI_CYCLE;
433  else
434  { status = ERROR_INPUT_PAR; break; }
435  fgets(buffer,500,fp); // skip rest of line
436  }
437 
438  else if (strcmp(buffer,"AMG_smoother")==0) {
439  val = fscanf(fp,"%s",buffer);
440  if (val!=1 || strcmp(buffer,"=")!=0) {
441  status = ERROR_INPUT_PAR; break;
442  }
443  val = fscanf(fp,"%s",buffer);
444  if (val!=1) { status = ERROR_INPUT_PAR; break; }
445 
446  if ((strcmp(buffer,"JACOBI")==0)||(strcmp(buffer,"jacobi")==0))
447  inparam->AMG_smoother = SMOOTHER_JACOBI;
448  else if ((strcmp(buffer,"GS")==0)||(strcmp(buffer,"gs")==0))
449  inparam->AMG_smoother = SMOOTHER_GS;
450  else if ((strcmp(buffer,"SGS")==0)||(strcmp(buffer,"sgs")==0))
451  inparam->AMG_smoother = SMOOTHER_SGS;
452  else if ((strcmp(buffer,"CG")==0)||(strcmp(buffer,"cg")==0))
453  inparam->AMG_smoother = SMOOTHER_CG;
454  else if ((strcmp(buffer,"SOR")==0)||(strcmp(buffer,"sor")==0))
455  inparam->AMG_smoother = SMOOTHER_SOR;
456  else if ((strcmp(buffer,"SSOR")==0)||(strcmp(buffer,"ssor")==0))
457  inparam->AMG_smoother = SMOOTHER_SSOR;
458  else if ((strcmp(buffer,"GSOR")==0)||(strcmp(buffer,"gsor")==0))
459  inparam->AMG_smoother = SMOOTHER_GSOR;
460  else if ((strcmp(buffer,"SGSOR")==0)||(strcmp(buffer,"sgsor")==0))
461  inparam->AMG_smoother = SMOOTHER_SGSOR;
462  else if ((strcmp(buffer,"POLY")==0)||(strcmp(buffer,"poly")==0))
463  inparam->AMG_smoother = SMOOTHER_POLY;
464  else if ((strcmp(buffer,"L1DIAG")==0)||(strcmp(buffer,"l1diag")==0))
465  inparam->AMG_smoother = SMOOTHER_L1DIAG;
466  else if ((strcmp(buffer,"BLKOIL")==0)||(strcmp(buffer,"blkoil")==0))
467  inparam->AMG_smoother = SMOOTHER_BLKOIL;
468  else if ((strcmp(buffer,"SPETEN")==0)||(strcmp(buffer,"speten")==0))
469  inparam->AMG_smoother = SMOOTHER_SPETEN;
470  else
471  { status = ERROR_INPUT_PAR; break; }
472  fgets(buffer,500,fp); // skip rest of line
473  }
474 
475  else if (strcmp(buffer,"AMG_smooth_order")==0) {
476  val = fscanf(fp,"%s",buffer);
477  if (val!=1 || strcmp(buffer,"=")!=0) {
478  status = ERROR_INPUT_PAR; break;
479  }
480  val = fscanf(fp,"%s",buffer);
481  if (val!=1) { status = ERROR_INPUT_PAR; break; }
482 
483  if ((strcmp(buffer,"NO")==0)||(strcmp(buffer,"no")==0))
484  inparam->AMG_smooth_order = NO_ORDER;
485  else if ((strcmp(buffer,"CF")==0)||(strcmp(buffer,"cf")==0))
486  inparam->AMG_smooth_order = CF_ORDER;
487  else
488  { status = ERROR_INPUT_PAR; break; }
489  fgets(buffer,500,fp); // skip rest of line
490  }
491 
492  else if (strcmp(buffer,"AMG_coarsening_type")==0) {
493  val = fscanf(fp,"%s",buffer);
494  if (val!=1 || strcmp(buffer,"=")!=0) {
495  status = ERROR_INPUT_PAR; break;
496  }
497  val = fscanf(fp,"%d",&ibuff);
498  if (val!=1) { status = ERROR_INPUT_PAR; break; }
499  inparam->AMG_coarsening_type = ibuff;
500  fgets(buffer,500,fp); // skip rest of line
501  }
502 
503  else if (strcmp(buffer,"AMG_interpolation_type")==0) {
504  val = fscanf(fp,"%s",buffer);
505  if (val!=1 || strcmp(buffer,"=")!=0) {
506  status = ERROR_INPUT_PAR; break;
507  }
508  val = fscanf(fp,"%d",&ibuff);
509  if (val!=1) { status = ERROR_INPUT_PAR; break; }
510  inparam->AMG_interpolation_type = ibuff;
511  fgets(buffer,500,fp); // skip rest of line
512  }
513 
514  else if (strcmp(buffer,"AMG_aggregation_type")==0) {
515  val = fscanf(fp,"%s",buffer);
516  if (val!=1 || strcmp(buffer,"=")!=0) {
517  status = ERROR_INPUT_PAR; break;
518  }
519  val = fscanf(fp,"%d",&ibuff);
520  if (val!=1) { status = ERROR_INPUT_PAR; break; }
521  inparam->AMG_aggregation_type = ibuff;
522  fgets(buffer,500,fp); // skip rest of line
523  }
524 
525  else if (strcmp(buffer,"AMG_pair_number")==0) {
526  val = fscanf(fp,"%s",buffer);
527  if (val!=1 || strcmp(buffer,"=")!=0) {
528  status = ERROR_INPUT_PAR; break;
529  }
530  val = fscanf(fp,"%d",&ibuff);
531  if (val!=1) { status = ERROR_INPUT_PAR; break; }
532  inparam->AMG_pair_number = ibuff;
533  fgets(buffer,500,fp); // skip rest of line
534  }
535 
536  else if (strcmp(buffer,"AMG_quality_bound")==0) {
537  val = fscanf(fp,"%s",buffer);
538  if (val!=1 || strcmp(buffer,"=")!=0) {
539  status = ERROR_INPUT_PAR; break;
540  }
541  val = fscanf(fp,"%lf",&dbuff);
542  if (val!=1) { status = ERROR_INPUT_PAR; break; }
543  inparam->AMG_quality_bound = dbuff;
544  fgets(buffer,500,fp); // skip rest of line
545  }
546 
547  else if (strcmp(buffer,"AMG_aggressive_level")==0) {
548  val = fscanf(fp,"%s",buffer);
549  if (val!=1 || strcmp(buffer,"=")!=0) {
550  status = ERROR_INPUT_PAR; break;
551  }
552  val = fscanf(fp,"%d",&ibuff);
553  if (val!=1) { status = ERROR_INPUT_PAR; break; }
554  inparam->AMG_aggressive_level = ibuff;
555  fgets(buffer,500,fp); // skip rest of line
556  }
557 
558  else if (strcmp(buffer,"AMG_aggressive_path")==0) {
559  val = fscanf(fp,"%s",buffer);
560  if (val!=1 || strcmp(buffer,"=")!=0) {
561  status = ERROR_INPUT_PAR; break;
562  }
563  val = fscanf(fp,"%d",&ibuff);
564  if (val!=1) { status = ERROR_INPUT_PAR; break; }
565  inparam->AMG_aggressive_path = ibuff;
566  fgets(buffer,500,fp); // skip rest of line
567  }
568 
569  else if (strcmp(buffer,"AMG_presmooth_iter")==0) {
570  val = fscanf(fp,"%s",buffer);
571  if (val!=1 || strcmp(buffer,"=")!=0) {
572  status = ERROR_INPUT_PAR; break;
573  }
574  val = fscanf(fp,"%d",&ibuff);
575  if (val!=1) { status = ERROR_INPUT_PAR; break; }
576  inparam->AMG_presmooth_iter = ibuff;
577  fgets(buffer,500,fp); // skip rest of line
578  }
579 
580  else if (strcmp(buffer,"AMG_postsmooth_iter")==0) {
581  val = fscanf(fp,"%s",buffer);
582  if (val!=1 || strcmp(buffer,"=")!=0) {
583  status = ERROR_INPUT_PAR; break;
584  }
585  val = fscanf(fp,"%d",&ibuff);
586  if (val!=1) { status = ERROR_INPUT_PAR; break; }
587  inparam->AMG_postsmooth_iter = ibuff;
588  fgets(buffer,500,fp); // skip rest of line
589  }
590 
591  else if (strcmp(buffer,"AMG_relaxation")==0) {
592  val = fscanf(fp,"%s",buffer);
593  if (val!=1 || strcmp(buffer,"=")!=0) {
594  status = ERROR_INPUT_PAR; break;
595  }
596  val = fscanf(fp,"%lf",&dbuff);
597  if (val!=1) { status = ERROR_INPUT_PAR; break; }
598  inparam->AMG_relaxation=dbuff;
599  fgets(buffer,500,fp); // skip rest of line
600  }
601 
602  else if (strcmp(buffer,"AMG_polynomial_degree")==0) {
603  val = fscanf(fp,"%s",buffer);
604  if (val!=1 || strcmp(buffer,"=")!=0) {
605  status = ERROR_INPUT_PAR; break;
606  }
607  val = fscanf(fp,"%d",&ibuff);
608  if (val!=1) { status = ERROR_INPUT_PAR; break; }
609  inparam->AMG_polynomial_degree = ibuff;
610  fgets(buffer,500,fp); // skip rest of line
611  }
612 
613  else if (strcmp(buffer,"AMG_strong_threshold")==0) {
614  val = fscanf(fp,"%s",buffer);
615  if (val!=1 || strcmp(buffer,"=")!=0) {
616  status = ERROR_INPUT_PAR; break;
617  }
618  val = fscanf(fp,"%lf",&dbuff);
619  if (val!=1) { status = ERROR_INPUT_PAR; break; }
620  inparam->AMG_strong_threshold = dbuff;
621  fgets(buffer,500,fp); // skip rest of line
622  }
623 
624  else if (strcmp(buffer,"AMG_truncation_threshold")==0) {
625  val = fscanf(fp,"%s",buffer);
626  if (val!=1 || strcmp(buffer,"=")!=0) {
627  status = ERROR_INPUT_PAR; break;
628  }
629  val = fscanf(fp,"%lf",&dbuff);
630  if (val!=1) { status = ERROR_INPUT_PAR; break; }
631  inparam->AMG_truncation_threshold = dbuff;
632  fgets(buffer,500,fp); // skip rest of line
633  }
634 
635  else if (strcmp(buffer,"AMG_max_row_sum")==0) {
636  val = fscanf(fp,"%s",buffer);
637  if (val!=1 || strcmp(buffer,"=")!=0) {
638  status = ERROR_INPUT_PAR; break;
639  }
640  val = fscanf(fp,"%lf",&dbuff);
641  if (val!=1) { status = ERROR_INPUT_PAR; break; }
642  inparam->AMG_max_row_sum = dbuff;
643  fgets(buffer,500,fp); // skip rest of line
644  }
645 
646  else if (strcmp(buffer,"AMG_amli_degree")==0) {
647  val = fscanf(fp,"%s",buffer);
648  if (val!=1 || strcmp(buffer,"=")!=0) {
649  status = ERROR_INPUT_PAR; break;
650  }
651  val = fscanf(fp,"%d",&ibuff);
652  if (val!=1) { status = ERROR_INPUT_PAR; break; }
653  inparam->AMG_amli_degree = ibuff;
654  fgets(buffer,500,fp); // skip rest of line
655  }
656 
657  else if (strcmp(buffer,"AMG_nl_amli_krylov_type")==0) {
658  val = fscanf(fp,"%s",buffer);
659  if (val!=1 || strcmp(buffer,"=")!=0) {
660  status = ERROR_INPUT_PAR; break;
661  }
662  val = fscanf(fp,"%d",&ibuff);
663  if (val!=1) { status = ERROR_INPUT_PAR; break; }
664  inparam->AMG_nl_amli_krylov_type = ibuff;
665  fgets(buffer,500,fp); // skip rest of line
666  }
667 
668  else if (strcmp(buffer,"ILU_type")==0) {
669  val = fscanf(fp,"%s",buffer);
670  if (val!=1 || strcmp(buffer,"=")!=0) {
671  status = ERROR_INPUT_PAR; break;
672  }
673  val = fscanf(fp,"%d",&ibuff);
674  if (val!=1) { status = ERROR_INPUT_PAR; break; }
675  inparam->ILU_type = ibuff;
676  fgets(buffer,500,fp); // skip rest of line
677  }
678 
679  else if (strcmp(buffer,"ILU_lfil")==0) {
680  val = fscanf(fp,"%s",buffer);
681  if (val!=1 || strcmp(buffer,"=")!=0) {
682  status = ERROR_INPUT_PAR; break;
683  }
684  val = fscanf(fp,"%d",&ibuff);
685  if (val!=1) { status = ERROR_INPUT_PAR; break; }
686  inparam->ILU_lfil = ibuff;
687  fgets(buffer,500,fp); // skip rest of line
688  }
689 
690  else if (strcmp(buffer,"ILU_droptol")==0) {
691  val = fscanf(fp,"%s",buffer);
692  if (val!=1 || strcmp(buffer,"=")!=0) {
693  status = ERROR_INPUT_PAR; break;
694  }
695  val = fscanf(fp,"%lf",&dbuff);
696  if (val!=1) { status = ERROR_INPUT_PAR; break; }
697  inparam->ILU_droptol = dbuff;
698  fgets(buffer,500,fp); // skip rest of line
699  }
700 
701  else if (strcmp(buffer,"ILU_relax")==0) {
702  val = fscanf(fp,"%s",buffer);
703  if (val!=1 || strcmp(buffer,"=")!=0) {
704  status = ERROR_INPUT_PAR; break;
705  }
706  val = fscanf(fp,"%lf",&dbuff);
707  if (val!=1) { status = ERROR_INPUT_PAR; break; }
708  inparam->ILU_relax = dbuff;
709  fgets(buffer,500,fp); // skip rest of line
710  }
711 
712  else if (strcmp(buffer,"ILU_permtol")==0) {
713  val = fscanf(fp,"%s",buffer);
714  if (val!=1 || strcmp(buffer,"=")!=0) {
715  status = ERROR_INPUT_PAR; break;
716  }
717  val = fscanf(fp,"%lf",&dbuff);
718  if (val!=1) { status = ERROR_INPUT_PAR; break; }
719  inparam->ILU_permtol = dbuff;
720  fgets(buffer,500,fp); // skip rest of line
721  }
722 
723  else if (strcmp(buffer,"Schwarz_mmsize")==0)
724  {
725  val = fscanf(fp,"%s",buffer);
726  if (val!=1 || strcmp(buffer,"=")!=0) {
727  status = ERROR_INPUT_PAR; break;
728  }
729  val = fscanf(fp,"%d",&ibuff);
730  if (val!=1) { status = ERROR_INPUT_PAR; break; }
731  inparam->Schwarz_mmsize = ibuff;
732  fgets(buffer,500,fp); // skip rest of line
733  }
734 
735  else if (strcmp(buffer,"Schwarz_maxlvl")==0)
736  {
737  val = fscanf(fp,"%s",buffer);
738  if (val!=1 || strcmp(buffer,"=")!=0) {
739  status = ERROR_INPUT_PAR; break;
740  }
741  val = fscanf(fp,"%d",&ibuff);
742  if (val!=1) {status = ERROR_INPUT_PAR; break; }
743  inparam->Schwarz_maxlvl = ibuff;
744  fgets(buffer,500,fp); // skip rest of line
745  }
746 
747  else if (strcmp(buffer,"Schwarz_type")==0)
748  {
749  val = fscanf(fp,"%s",buffer);
750  if (val!=1 || strcmp(buffer,"=")!=0) {
751  status = ERROR_INPUT_PAR; break;
752  }
753  val = fscanf(fp,"%d",&ibuff);
754  if (val!=1) { status = ERROR_INPUT_PAR; break; }
755  inparam->Schwarz_type = ibuff;
756  fgets(buffer,500,fp); // skip rest of line
757  }
758 
759  else if (strcmp(buffer,"Schwarz_blksolver")==0)
760  {
761  val = fscanf(fp,"%s",buffer);
762  if (val!=1 || strcmp(buffer,"=")!=0) {
763  status = ERROR_INPUT_PAR; break;
764  }
765  val = fscanf(fp,"%d",&ibuff);
766  if (val!=1) { status = ERROR_INPUT_PAR; break; }
767  inparam->Schwarz_blksolver = ibuff;
768  fgets(buffer,500,fp); // skip rest of line
769  }
770 
771  else {
772  printf("### WARNING: Unknown input keyword %s!\n", buffer);
773  fgets(buffer,500,fp); // skip rest of line
774  }
775  }
776 
777  fclose(fp);
778 
779  // sanity checks
780  status = fasp_param_check(inparam);
781 
782 #if DEBUG_MODE > 1
783  printf("### DEBUG: Reading input status = %d\n", status);
784 #endif
785 
786  // if meet unexpected input, stop the program
787  fasp_chkerr(status,"fasp_param_input");
788 }
789 
790 /*---------------------------------*/
791 /*-- End of File --*/
792 /*---------------------------------*/
#define SMOOTHER_SGS
Definition: fasp_const.h:185
void fasp_param_input_init(input_param *iniparam)
Initialize input parameters.
Definition: parameters.c:310
#define SMOOTHER_GS
Definition: fasp_const.h:184
void fasp_chkerr(const SHORT status, const char *fctname)
Check error status and print out error messages before quit.
Definition: message.c:199
#define ERROR_OPEN_FILE
Definition: fasp_const.h:29
#define ERROR_INPUT_PAR
Definition: fasp_const.h:31
REAL AMG_quality_bound
Definition: fasp.h:1091
SHORT AMG_postsmooth_iter
Definition: fasp.h:1070
REAL AMG_max_row_sum
Definition: fasp.h:1087
INT itsolver_maxit
Definition: fasp.h:1045
SHORT AMG_smooth_filter
Definition: fasp.h:1097
INT AMG_coarse_dof
Definition: fasp.h:1071
SHORT AMG_presmooth_iter
Definition: fasp.h:1069
SHORT AMG_aggregation_type
Definition: fasp.h:1083
#define SMOOTHER_GSOR
Definition: fasp_const.h:189
SHORT solver_type
Definition: fasp.h:1041
Input parameters.
Definition: fasp.h:1029
#define SMOOTHER_SSOR
Definition: fasp_const.h:188
REAL AMG_relaxation
Definition: fasp.h:1067
SHORT precond_type
Definition: fasp.h:1042
REAL ILU_permtol
Definition: fasp.h:1053
SHORT AMG_smooth_order
Definition: fasp.h:1066
SHORT AMG_smoother
Definition: fasp.h:1065
SHORT ILU_type
Definition: fasp.h:1049
INT Schwarz_maxlvl
Definition: fasp.h:1057
#define SMOOTHER_SOR
Definition: fasp_const.h:187
char workdir[256]
Definition: fasp.h:1037
#define SMOOTHER_POLY
Definition: fasp_const.h:191
#define FASP_SUCCESS
Definition of return status and error messages.
Definition: fasp_const.h:27
REAL AMG_strong_threshold
Definition: fasp.h:1085
#define SMOOTHER_CG
Definition: fasp_const.h:186
REAL AMG_tentative_smooth
Definition: fasp.h:1096
SHORT AMG_nl_amli_krylov_type
Definition: fasp.h:1078
INT restart
Definition: fasp.h:1046
#define V_CYCLE
Definition of cycle types.
Definition: fasp_const.h:175
INT Schwarz_blksolver
Definition: fasp.h:1059
INT ILU_lfil
Definition: fasp.h:1050
INT AMG_maxit
Definition: fasp.h:1073
SHORT AMG_coarse_scaling
Definition: fasp.h:1076
SHORT AMG_interpolation_type
Definition: fasp.h:1084
Main header file for FASP.
REAL ILU_relax
Definition: fasp.h:1052
INT AMG_aggressive_path
Definition: fasp.h:1089
#define CLASSIC_AMG
Definition of AMG types.
Definition: fasp_const.h:162
SHORT AMG_coarse_solver
Definition: fasp.h:1075
#define SMOOTHER_JACOBI
Definition of standard smoother types.
Definition: fasp_const.h:183
#define SMOOTHER_SPETEN
Definition: fasp_block.h:28
#define OFF
Definition: fasp_const.h:74
INT AMG_max_aggregation
Definition: fasp.h:1095
SHORT fasp_param_check(input_param *inparam)
Simple check on input parameters.
Definition: input.c:25
INT AMG_pair_number
Definition: fasp.h:1090
INT AMG_aggressive_level
Definition: fasp.h:1088
#define SHORT
FASP integer and floating point numbers.
Definition: fasp.h:63
#define AMLI_CYCLE
Definition: fasp_const.h:177
SHORT stop_type
Definition: fasp.h:1043
REAL itsolver_tol
Definition: fasp.h:1044
REAL AMG_tol
Definition: fasp.h:1072
INT problem_num
Definition: fasp.h:1038
REAL ILU_droptol
Definition: fasp.h:1051
void fasp_param_input(const char *filenm, input_param *inparam)
Read input parameters from disk file.
Definition: input.c:102
#define ON
Definition of switch.
Definition: fasp_const.h:73
INT Schwarz_type
Definition: fasp.h:1058
REAL AMG_strong_coupled
Definition: fasp.h:1094
SHORT AMG_type
Definition: fasp.h:1062
INT AMG_Schwarz_levels
Definition: fasp.h:1079
#define SMOOTHER_L1DIAG
Definition: fasp_const.h:192
#define CF_ORDER
Definition: fasp_const.h:223
#define SMOOTHER_SGSOR
Definition: fasp_const.h:190
#define NL_AMLI_CYCLE
Definition: fasp_const.h:178
SHORT AMG_cycle_type
Definition: fasp.h:1064
SHORT AMG_coarsening_type
Definition: fasp.h:1082
SHORT print_level
Definition: fasp.h:1032
INT Schwarz_mmsize
Definition: fasp.h:1056
#define SA_AMG
Definition: fasp_const.h:163
SHORT AMG_amli_degree
Definition: fasp.h:1077
REAL AMG_truncation_threshold
Definition: fasp.h:1086
SHORT AMG_levels
Definition: fasp.h:1063
SHORT output_type
Definition: fasp.h:1033
#define SMOOTHER_BLKOIL
Definition of specialized smoother types.
Definition: fasp_block.h:27
#define W_CYCLE
Definition: fasp_const.h:176
SHORT AMG_ILU_levels
Definition: fasp.h:1074
#define UA_AMG
Definition: fasp_const.h:164
SHORT AMG_polynomial_degree
Definition: fasp.h:1068
#define NO_ORDER
Definition of smoothing order.
Definition: fasp_const.h:222