HydroCODE_1D 0.1
This is a implementation of fully explict forward Euler scheme for 1-D Euler equations of motion on Lagrangian/Eulerian coordinate
terminal_io.c
浏览该文件的文档.
1
6#include <errno.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <math.h>
10
11#include "../include/var_struc.h"
12
13
26void arg_preprocess(const int argc_least, const int argc, char *argv[], char * scheme)
27{
28 int k, j;
29 printf("\n");
30 for (k = 0; k < argc; k++)
31 printf("%s ", argv[k]);
32 printf("\n\n");
33#ifdef _WIN32
34 printf("TEST:\n %s\n", argv[1]);
35#elif __linux__
36 printf("\x1b[47;34mTEST:\x1b[0m\n \x1b[1;31m%s\x1b[0m\n", argv[1]);
37#endif
38 if(argc < argc_least)
39 {
40#ifdef _WIN32
41 printf("Test Beginning: ARGuments Counter %d is less than %d\n", argc, argc_least);
42#elif __linux__
43 printf("Test Beginning: \x1b[43;37mARGuments Counter %d is less than %d\x1b[0m\n", argc, argc_least);
44#endif
45 exit(4);
46 }
47 else
48#ifdef _WIN32
49 printf("Test Beginning: ARGuments Counter = %d\n", argc);
50#elif __linux__
51 printf("Test Beginning: \x1b[43;37mARGuments Counter = %d\x1b[0m\n", argc);
52#endif
53
54 // Set order and scheme.
55 int order; // 1, 2
56#ifdef _WIN32
57 printf("Order[_Scheme]: %s\n",argv[3]);
58#elif __linux__
59 printf("Order[_Scheme]: \x1b[41;37m%s\x1b[0m\n",argv[3]);
60#endif
61 errno = 0;
62 order = strtoul(argv[3], &scheme, 10);
63 if (*scheme == '_')
64 scheme++;
65 else if (*scheme != '\0' || errno == ERANGE)
66 {
67 printf("No order or Wrog scheme!\n");
68 exit(4);
69 }
70 config[9] = (double)order;
71
72#ifdef _WIN32
73 printf("Configurating:\n");
74#elif __linux__
75 printf("\x1b[42;36mConfigurating:\x1b[0m\n");
76#endif
77 char * endptr;
78 double conf_tmp;
79 for (k = argc_least+1; k < argc; k++)
80 {
81 errno = 0;
82 j = strtoul(argv[k], &endptr, 10);
83 if (errno != ERANGE && *endptr == '=')
84 {
85 endptr++;
86 errno = 0;
87 conf_tmp = strtod(endptr, &endptr);
88 if (errno != ERANGE && *endptr == '\0')
89 {
90 config[j] = conf_tmp;
91 printf("%3d-th configuration: %g (ARGument)\n", j, conf_tmp);
92 }
93 else
94 {
95 printf("Configuration error in ARGument variable %d! ERROR after '='!\n", k);
96 exit(4);
97 }
98 }
99 else
100 {
101 printf("Configuration error in ARGument variable %d! ERROR before '='!\n", k);
102 exit(4);
103 }
104 }
105}
double config[N_CONF]
Initial configuration data array.
Definition: hydrocode.c:111
void arg_preprocess(const int argc_least, const int argc, char *argv[], char *scheme)
This is a functions preprocesses ARGuments.
Definition: terminal_io.c:26