22#define ACCESS(path,mode) _access((path),(mode))
23#define MKDIR(path) _mkdir((path))
27#define ACCESS(path,mode) access((path),(mode))
28#define MKDIR(path) mkdir((path), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
37void DispPro(
const double pro,
const int step)
40 static double pro_print = 0.0;
41 const double dpro_print = 0.1;
44 for (j = 0; j < 77; j++)
46 for (j = 0; j < lround(pro/2); j++)
50 printf(
"\x1b[45m \x1b[0m");
52 for (j = 1; j <= 50-lround(pro/2); j++)
56 printf(
"\x1b[47m \x1b[0m");
58 fprintf(stdout,
" %6.2f%% STEP=%-8d", pro, step);
60 pro_print += dpro_print;
74 if(0 == ACCESS(pPath,2))
77 const char* pCur = pPath;
78 char tmpPath[FILENAME_MAX+40];
79 memset(tmpPath,0,
sizeof(tmpPath));
84 tmpPath[pos++] = *(pCur-1);
86 if(*pCur==
'/' || *pCur==
'\0')
88 if(0!=ACCESS(tmpPath,0) && strlen(tmpPath)>0)
94 if(0 == ACCESS(pPath,2))
107void init_mem(
double * p[],
const int n,
int ** cell_pt)
109 for(
int k = 0; k < n; ++k)
111 p[k] = (
double *)calloc(cell_pt[k][0],
sizeof(
double));
114 printf(
"Initialize memory fail! DOUBLE data at grid cell points.\n");
115 for(
int j = 0; j < k; j++)
134 for(
int k = 0; k < n; ++k)
136 p[k] = (
int *)malloc(cell_pt[k][0] *
sizeof(
int));
139 printf(
"Initialize memory fail! INT data at grid cell points.\n");
140 for(
int j = 0; j < k; j++)
void init_mem_int(int *p[], const int n, int **cell_pt)
This is a function that initializes memory for integer data.
int CreateDir(const char *pPath)
This is a function that recursively creates folders.
void init_mem(double *p[], const int n, int **cell_pt)
This is a function that initializes memory for double-precision floating-point data.
void DispPro(const double pro, const int step)
This function print a progress bar on one line of standard output.