Prepare SPHLite 0.2.0 development baseline
This commit is contained in:
+67
-10
@@ -8,13 +8,14 @@ static void sphlite_print_error(void)
|
||||
int code = 0;
|
||||
char message[256];
|
||||
if (sphlite_get_last_error(&code, message, (int)sizeof(message)) == 0) {
|
||||
fprintf(stderr, "SPHLite error %d: %s\n", code, message);
|
||||
fprintf(stderr, "error_code: %d\n", code);
|
||||
fprintf(stderr, "error_message: %s\n", message);
|
||||
}
|
||||
}
|
||||
|
||||
static void sphlite_print_usage(void)
|
||||
{
|
||||
printf("usage: sphlite model.inp [--run]\n");
|
||||
printf("usage: sphlite [--version] model.inp [--check|--run] [--output path]\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
@@ -25,19 +26,50 @@ int main(int argc, char **argv)
|
||||
int patch = 0;
|
||||
int count = 0;
|
||||
int step = 0;
|
||||
int warnings = 0;
|
||||
double time = 0.0;
|
||||
int run_mode = 0;
|
||||
int check_mode = 0;
|
||||
const char *input = NULL;
|
||||
const char *output = NULL;
|
||||
int i;
|
||||
|
||||
if (argc < 2 || argc > 3) {
|
||||
if (argc == 2 && strcmp(argv[1], "--version") == 0) {
|
||||
ierr = sphlite_get_version(&major, &minor, &patch);
|
||||
if (ierr != 0) {
|
||||
sphlite_print_error();
|
||||
return 1;
|
||||
}
|
||||
printf("version: %d.%d.%d\n", major, minor, patch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc < 2) {
|
||||
sphlite_print_usage();
|
||||
return 1;
|
||||
}
|
||||
if (argc == 3) {
|
||||
if (strcmp(argv[2], "--run") != 0) {
|
||||
|
||||
input = argv[1];
|
||||
for (i = 2; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "--run") == 0) {
|
||||
run_mode = 1;
|
||||
} else if (strcmp(argv[i], "--check") == 0) {
|
||||
check_mode = 1;
|
||||
} else if (strcmp(argv[i], "--output") == 0) {
|
||||
if (i + 1 >= argc) {
|
||||
sphlite_print_usage();
|
||||
return 1;
|
||||
}
|
||||
output = argv[i + 1];
|
||||
++i;
|
||||
} else {
|
||||
sphlite_print_usage();
|
||||
return 1;
|
||||
}
|
||||
run_mode = 1;
|
||||
}
|
||||
if (run_mode && check_mode) {
|
||||
sphlite_print_usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
ierr = sphlite_initialize();
|
||||
@@ -53,7 +85,16 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
ierr = sphlite_read_inp(argv[1]);
|
||||
if (output != NULL) {
|
||||
ierr = sphlite_set_output_directory(output);
|
||||
if (ierr != 0) {
|
||||
sphlite_print_error();
|
||||
(void)sphlite_finalize();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
ierr = sphlite_read_inp(input);
|
||||
if (ierr != 0) {
|
||||
sphlite_print_error();
|
||||
(void)sphlite_finalize();
|
||||
@@ -74,6 +115,14 @@ int main(int argc, char **argv)
|
||||
(void)sphlite_finalize();
|
||||
return 1;
|
||||
}
|
||||
if (output != NULL) {
|
||||
ierr = sphlite_write_output(1, 0.0);
|
||||
if (ierr != 0) {
|
||||
sphlite_print_error();
|
||||
(void)sphlite_finalize();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ierr = sphlite_get_particle_count(&count);
|
||||
@@ -88,13 +137,21 @@ int main(int argc, char **argv)
|
||||
(void)sphlite_finalize();
|
||||
return 1;
|
||||
}
|
||||
ierr = sphlite_get_input_warning_count(&warnings);
|
||||
if (ierr != 0) {
|
||||
sphlite_print_error();
|
||||
(void)sphlite_finalize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("SPHLite %d.%d.%d\n", major, minor, patch);
|
||||
printf("input: %s\n", argv[1]);
|
||||
printf("mode: %s\n", run_mode ? "run" : "inspect");
|
||||
printf("version: %d.%d.%d\n", major, minor, patch);
|
||||
printf("input: %s\n", input);
|
||||
printf("mode: %s\n", run_mode ? "run" : (check_mode ? "check" : "inspect"));
|
||||
printf("particles: %d\n", count);
|
||||
printf("warnings: %d\n", warnings);
|
||||
printf("time: %.16e\n", time);
|
||||
printf("step: %d\n", step);
|
||||
printf("status: ok\n");
|
||||
|
||||
ierr = sphlite_finalize();
|
||||
if (ierr != 0) {
|
||||
|
||||
Reference in New Issue
Block a user