15#include "../include/var_struc.h" 
   28#define ACCESS(a,m) _access((a),(m)) 
   31#define ACCESS(a,m) access((a),(m)) 
   41    const int dim = (int)
config[0];
 
   42    printf(
"  dimension\t= %d\n", dim);
 
   48        printf(
"  total time\t= %g\n", 
config[1]);
 
   50    else if(!isfinite(
config[5]))
 
   52        fprintf(stderr, 
"The total time or the maximum number of time steps must be setted properly!\n");
 
   61            printf(
"  delta_t\t= %g\n", 
config[16]);
 
   64    printf(
"  time step\t= %d\n", (
int)
config[5]);
 
   69    if(eps < 0.0 || eps > 0.01)
 
   71        fprintf(stderr, 
"eps(%f) should in (0, 0.01)!\n", eps);
 
   74    printf(
"  eps\t\t= %g\n", eps);
 
   78    else if(
config[6] < 1.0 + eps)
 
   80        fprintf(stderr, 
"The constant of the perfect gas(%f) should be larger than 1.0!\n", 
config[6]);
 
   83    printf(
"  gamma\t\t= %g\n", 
config[6]);
 
   95    else if(
config[7] > 1.0 - eps)
 
   97        fprintf(stderr, 
"The CFL number(%f) should be smaller than 1.0.\n", 
config[7]);
 
  100    printf(
"  CFL number\t= %g\n", 
config[7]);
 
  106        fprintf(stderr, 
"The parameter in minmod limiter(%f) should in [0, 2)!\n", 
config[41]);
 
  112    else if(
config[110] < eps)
 
  114        fprintf(stderr, 
"The specific heat at constant volume(%f) should be larger than 0.0!\n", 
config[110]);
 
  169    while (fgets(one_line, 
sizeof(one_line), fp) != NULL)
 
  172            i = strtoul(one_line, &endptr, 10);
 
  173            for ( ; isspace(*endptr); endptr++) ;
 
  179                    tmp = strtod(endptr, NULL);
 
  182                        fprintf(stderr, 
"Value range error of %d-th configuration in line %d of configuration file!\n", i, line_num);
 
  186                        printf(
"%3d-th configuration: %g\n", i, 
config[i] = tmp);
 
  188                        printf(
"%3d-th configuration is repeatedly assigned with %g and %g(abandon)!\n", i, 
config[i], tmp);
 
  190            else if (i != 0 || (*endptr != 
'#' && *endptr != 
'\0'))
 
  191                fprintf(stderr, 
"Warning: unknown row occurrs in line %d of configuration file!\n", line_num);
 
  196            fprintf(stderr, 
"Read error occurrs in configuration file!\n");
 
  211  char add[FILENAME_MAX+40];
 
  213  strcat(add, 
"config.txt");
 
  215  if((fp_data = fopen(add, 
"r")) == NULL)
 
  218      strcat(add, 
"config.dat");
 
  220  if((fp_data = fopen(add, 
"r")) == NULL)
 
  222      printf(
"Cannot open configuration data file!\n");
 
  236  printf(
"Configurated:\n");
 
  238  printf(
"\x1b[42;36mConfigurated:\x1b[0m\n");
 
  253void config_write(
const char * add_out, 
const double * cpu_time, 
const char * name)
 
  255    char file_data[FILENAME_MAX+40];
 
  256    const int dim = (int)
config[0];
 
  260  strcpy(file_data, add_out);
 
  261  strcat(file_data, 
"log");
 
  262  strcat(file_data, 
".dat");
 
  263  if((fp_write = fopen(file_data, 
"w")) == NULL)
 
  265    printf(
"Cannot open log output file!\n");
 
  269  fprintf(fp_write, 
"%s is initialized with %d grids.\n\n", name, (
int)
config[3]);
 
  270  fprintf(fp_write, 
"Configurated:\n");
 
  271  fprintf(fp_write, 
"dim\t\t= %d\n", dim);
 
  273      fprintf(fp_write, 
"t_all\t= %d\n", (
int)
config[1]);
 
  274  else if(isfinite(
config[16]))
 
  275      fprintf(fp_write, 
"tau\t\t= %g\n", 
config[16]);
 
  276  fprintf(fp_write, 
"eps\t\t= %g\n", 
config[4]);
 
  277  fprintf(fp_write, 
"gamma\t= %g\n", 
config[6]);
 
  278  fprintf(fp_write, 
"CFL\t\t= %g\n", 
config[7]);
 
  279  fprintf(fp_write, 
"h\t\t= %g\n", 
config[10]);
 
  280  fprintf(fp_write, 
"bond\t= %d\n", (
int)
config[17]);
 
  283      fprintf(fp_write, 
"h_y\t\t= %g\n", 
config[11]);
 
  284      fprintf(fp_write, 
"bond_y\t= %d\n", (
int)
config[18]);
 
  286  fprintf(fp_write, 
"\nA total of %d time steps are computed.\n", (
int)
config[5]);
 
static int config_read(FILE *fp)
This function read the configuration data file, and store the configuration data in the array 'config...
 
void configurate(const char *add_in)
This function controls configuration data reading and validation.
 
static void config_check(void)
This function check whether the configuration data is reasonable and set the default....
 
void config_write(const char *add_out, const double *cpu_time, const char *name)
This function write configuration data and program record into the file 'log.dat'.
 
double config[N_CONF]
Initial configuration data array.
 
#define EPS
If the system does not set, the default largest value can be seen as zero is EPS.
 
#define N_CONF
Define the number of configuration parameters.