tsimulation list shows shorthand status - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 5228996295ba5ad492b056627b552c08aea68821
(DIR) parent 59a52a5999acdcf3c4235c985ca350f0aae79625
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Thu, 8 May 2014 10:41:24 +0200
simulation list shows shorthand status
Diffstat:
M src/sphere_status.c | 46 +++++++++++++++++++------------
1 file changed, 28 insertions(+), 18 deletions(-)
---
(DIR) diff --git a/src/sphere_status.c b/src/sphere_status.c
t@@ -5,6 +5,7 @@
#include <dirent.h>
int print_usage(FILE* stream, char* argv0, int return_status);
+int open_status_file(char* cwd, char* sim_name, int format);
int main(int argc, char *argv[])
{
t@@ -31,7 +32,10 @@ int main(int argc, char *argv[])
while ((ent = readdir(dir)) != NULL) {
if ((dotpos = strstr(ent->d_name, ".status.dat")) != NULL) {
*dotpos = '\0';
- printf("\t%s\n", ent->d_name);
+ printf("\t%s\t(", ent->d_name);
+ (void)open_status_file(cwd, ent->d_name, 1);
+ puts(")");
+
}
}
closedir(dir);
t@@ -47,8 +51,20 @@ int main(int argc, char *argv[])
return print_usage(stdout, argv[0], 0);
}
- char *sim_name = argv[1];
+ return open_status_file(cwd, argv[1], 0);
+}
+int print_usage(FILE* stream, char* argv0, int return_status)
+{
+ fprintf(stream, "sphere simulation status checker. Usage:\n"
+ "%s [simulation id]\n"
+ "If the simulation id isn't specified, a list of simulations \n"
+ "found in the ./output/ folder will be shown\n", argv0);
+ return return_status;
+}
+
+
+int open_status_file(char* cwd, char* sim_name, int format) {
// Open the simulation status file
FILE *fp;
char file[1000]; // Complete file path+name variable
t@@ -65,11 +81,16 @@ int main(int argc, char *argv[])
return 1;
}
- printf("Reading %s:\n"
- " - Current simulation time: %f s\n"
- " - Percentage completed: %f %%\n"
- " - Latest output file: %s.output%05d.bin\n",
- file, time_current, time_percentage, sim_name, file_nr);
+ if (format == 1) {
+ printf("%.2f s / %.0f %% / %d",
+ time_current, time_percentage, file_nr);
+ } else {
+ printf("Reading %s:\n"
+ " - Current simulation time: %f s\n"
+ " - Percentage completed: %f %%\n"
+ " - Latest output file: %s.output%05d.bin\n",
+ file, time_current, time_percentage, sim_name, file_nr);
+ }
fclose(fp);
t@@ -81,15 +102,4 @@ int main(int argc, char *argv[])
}
}
-int print_usage(FILE* stream, char* argv0, int return_status)
-{
- fprintf(stream, "sphere simulation status checker. Usage:\n"
- "%s [simulation id]\n"
- "If the simulation id isn't specified, a list of simulations \n"
- "found in the ./output/ folder will be shown\n", argv0);
- return return_status;
-}
-
-
-
// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4