14#include "../include/var_struc.h" 
   15#include "../include/tools.h" 
   26#define ACCESS(path,mode) _access((path),(mode)) 
   29#define ACCESS(path,mode) access((path),(mode)) 
   40void example_io(
const char *example, 
char *add_mkdir, 
const int i_or_o)
 
   42    const int dim   = (int)
config[0];
 
   43    const int el    = (int)
config[8];
 
   44    const int order = (int)
config[9];
 
   46    static int output_const = 0;
 
   47    char str_tmp[11], str_order[11];
 
   51        strcpy(str_tmp, 
"one-dim/");   
break;
 
   53        strcpy(str_tmp, 
"two-dim/");   
break;
 
   55        strcpy(str_tmp, 
"three-dim/"); 
break;
 
   57        fprintf(stderr, 
"Strange computational dimension!\n");
 
   62            strcpy(add_mkdir, 
"../../data_out/");
 
   63            strcat(add_mkdir, str_tmp);
 
   67                strcpy(str_tmp, 
"EUL_"); 
break;
 
   69                strcpy(str_tmp, 
"LAG_"); 
break;
 
   71                strcpy(str_tmp, 
"ALE_"); 
break;
 
   73                fprintf(stderr, 
"Strange description method of fluid motion!\n");
 
   76            strcat(add_mkdir, str_tmp);
 
   77            sprintf(str_order, 
"%d_order/", order);
 
   78            strcat(add_mkdir, str_order);
 
   82            strcpy(add_mkdir, 
"../../data_in/");
 
   83            strcat(add_mkdir, str_tmp);
 
   85    strcat(add_mkdir, example);
 
   92            fprintf(stderr, 
"Output directory '%s' construction failed!\n", add_mkdir);
 
   94            fprintf(stderr, 
"\x1b[47;34mOutput directory '%s' construction failed!\x1b[0m\n", add_mkdir);
 
   98        else if(output_const == 0)
 
  101            printf(
"Output directory '%s' has been constructed.\n", add_mkdir);             
 
  103            printf(
"\x1b[47;34mOutput directory '%s' has been constructed.\x1b[0m\n", add_mkdir);
 
  108    else if (ACCESS(add_mkdir,4) == -1)
 
  110        fprintf(stderr, 
"Input directory '%s' is nonexistent or unreadable!\n", add_mkdir);
 
  114    strcat(add_mkdir, 
"/");
 
  135    while((ch = getc(fp)) != EOF) 
 
  137        if (ch == 45 || ch == 46 || ch == 69 || ch == 101 || isdigit(ch))
 
  139        else if (!isspace(ch))
 
  141            fprintf(stderr, 
"Input contains illegal character(ASCII=%d, flag=%d) in the file '%s'!\n", ch, flg, add);
 
  165  int line = 0, column = 0;
 
  176      if(ch == 
'\n' || ch == EOF)
 
  185              else if(column != *n_x)
 
  187                  printf(
"Error in input data file '%s', line=%d, column=%d, n_x=%d\n", add, line, column, *n_x);
 
  194      else if(ch == 45 || ch == 46 || ch == 69 || ch == 101 || isdigit(ch))
 
  196      else if (!isspace(ch))
 
  198          printf(
"Input contains illigal character(ASCII=%d, flag=%d) in the file '%s', line=%d!\n", ch, flag, add, line);
 
  228  while((ch = getc(fp)) != EOF)
 
  230    if(isspace(ch) && idx)
 
  244      U[j] = strtod(number, &endptr);
 
  245      if (errno == ERANGE || *endptr != 
'\0')
 
  247          printf(
"The %dth entry in the initial data file is not a double-precision floats.\n", j+1);
 
  252          printf(
"Error on the initial data file reading!\n");
 
  257    else if((ch == 46) || (ch == 45) || (ch == 69) || (ch == 101) || isdigit(ch))
 
  269    double ret = *(
double*)a - *(
double*)b;
 
  288int time_plot_read(
const char * add_in, 
const int N_max, 
int * N_plot, 
double * time_plot[])
 
  292    char add[FILENAME_MAX+40];
 
  294    strcat(add, 
"time_plot.txt");
 
  296    if((fp = fopen(add, 
"r")) == NULL)
 
  299        strcat(add, 
"time_plot.dat");
 
  301    if((fp = fopen(add, 
"r")) == NULL)
 
  303        printf(
"No time data file for plotting! Only the initial data and final result will be plotted.\n");
 
  311        printf(
"Error in counting time data file for plotting!\n");
 
  315    *time_plot = (
double*)malloc((*N_plot)*
sizeof(double));
 
  316    if(*time_plot == NULL)
 
  318        printf(
"NOT enough memory! time_plot[]\n");
 
  321    (*time_plot)[0] = 0.0;
 
  322    (*time_plot)[*N_plot - 1] = 
config[1];
 
  330        printf(
"Load time data file for plotting! Plot time step is %d.\n", *N_plot - 2);
 
  334    return N_max<(*N_plot) ? N_max : (*N_plot);
 
double config[N_CONF]
Initial configuration data array.
 
int flu_var_read(FILE *fp, double *U, const int num)
This function reads the initial data file to generate the initial data.
 
int flu_var_count_line(FILE *fp, const char *add, int *n_x)
This function counts the line and column number of the numbers are there in the initial data file.
 
static int compare_double(const void *a, const void *b)
Compare function of double for sort function 'qsort()'.
 
void example_io(const char *example, char *add_mkdir, const int i_or_o)
This function produces folder path for data input or output.
 
int flu_var_count(FILE *fp, const char *add)
This function counts how many numbers are there in the initial data file.
 
int time_plot_read(const char *add_in, const int N_max, int *N_plot, double *time_plot[])
This function reads the time data file for plotting 'time_plot.dat' and initialize tha array 'time_pl...