13#include "../include/var_struc.h"
14#include "../include/tools.h"
25#define ACCESS(path,mode) _access((path),(mode))
28#define ACCESS(path,mode) access((path),(mode))
39void example_io(
const char *example,
char *add_mkdir,
const int i_or_o)
41 const int dim = (int)
config[0];
42 const int el = (int)
config[8];
43 const int order = (int)
config[9];
45 char *str_tmp, str_order[11];
49 str_tmp =
"one-dim/";
break;
51 str_tmp =
"two-dim/";
break;
53 str_tmp =
"three-dim/";
break;
55 fprintf(stderr,
"Strange computational dimension!\n");
60 strcpy(add_mkdir,
"../../data_out/");
61 strcat(add_mkdir, str_tmp);
65 str_tmp =
"EUL_";
break;
67 str_tmp =
"LAG_";
break;
69 str_tmp =
"ALE_";
break;
71 fprintf(stderr,
"Strange description method of fluid motion!\n");
74 strcat(add_mkdir, str_tmp);
75 sprintf(str_order,
"%d_order/", order);
76 strcat(add_mkdir, str_order);
80 strcpy(add_mkdir,
"../../data_in/");
81 strcat(add_mkdir, str_tmp);
83 strcat(add_mkdir, example);
89 fprintf(stderr,
"Output directory '%s' construction failed.\n", add_mkdir);
93 printf(
"Output directory '%s' is constructed.\n", add_mkdir);
95 else if (ACCESS(add_mkdir,4) == -1)
97 fprintf(stderr,
"Input directory '%s' is unreadable!\n", add_mkdir);
101 strcat(add_mkdir,
"/");
122 while((ch = getc(fp)) != EOF)
124 if (ch == 45 || ch == 46 || ch == 69 || ch == 101 || isdigit(ch))
126 else if (!isspace(ch))
128 fprintf(stderr,
"Input contains illegal character(ASCII=%d, flag=%d) in the file '%s'!\n", ch, flg, add);
152 int line = 0, column = 0;
163 if(ch ==
'\n' || ch == EOF)
172 else if(column != *n_x)
174 printf(
"Error in input data file '%s', line=%d, column=%d, n_x=%d\n", add, line, column, *n_x);
181 else if(ch == 45 || ch == 46 || ch == 69 || ch == 101 || isdigit(ch))
183 else if (!isspace(ch))
185 printf(
"Input contains illigal character(ASCII=%d, flag=%d) in the file '%s', line=%d!\n", ch, flag, add, line);
215 while((ch = getc(fp)) != EOF)
217 if(isspace(ch) && idx)
231 U[j] = strtod(number, &endptr);
232 if (errno == ERANGE || *endptr !=
'\0')
234 printf(
"The %dth entry in the initial data file is not a double-precision floats.\n", j+1);
239 printf(
"Error on the initial data file reading!\n");
244 else if((ch == 46) || (ch == 45) || (ch == 69) || (ch == 101) || isdigit(ch))
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.
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.
double config[]
Initial configuration data array.