Commit 8e241887 authored by Daniel Brown's avatar Daniel Brown
Browse files

refs #121 - adding video information to progress string, progress string is...

refs #121 - adding video information to progress string, progress string is also cleared once done so that it doesn't interfere with later prints
parent 4f38153e
......@@ -257,7 +257,7 @@ void compute_data(void) {
int y_step_index;
for (y_step_index = 0; y_step_index <= inter.x2.xsteps; y_step_index++) {
set_progress_action_text("Calculating");
set_progress_message_text("");
//set_progress_message_text("");
if (inter.x2.xtype == FLOG) {
y_axis_point = exp(y_min + y_step_index * dy);
......@@ -301,7 +301,7 @@ void compute_data(void) {
}
} else {
set_progress_action_text("Calculating");
set_progress_message_text("");
//set_progress_message_text("");
vlocal.respt = mem.restab + x_step_index * inter.num_output_cols;
......@@ -316,6 +316,8 @@ void compute_data(void) {
// (and write output)
write_result();
}
set_progress_action_text("Calculating");
if ((inter.trace & 64 || inter.debug & 32) && inter.rebuild == 2) {
message("x=%s:\n", double_form(x_axis_point));
......@@ -3464,6 +3466,8 @@ void x12_out(void) {
write_data_file();
clear_progress();
int i;
for (i = 0; i < inter.num_light_outputs; i++) {
// print warning if it was not clear to KAT whether this was
......@@ -3619,9 +3623,10 @@ void x3_out(void) {
int i;
double fxz;
set_progress_message_text("");
for (i = 0, fxz = xz0; i <= inter.x3.xsteps; fxz += dxz, i++) {
set_progress_action_text("Calculating");
set_progress_message_text("");
if (inter.x3.xtype == FLOG) {
*inter.x3.xaxis = exp(fxz);
......@@ -3630,6 +3635,24 @@ void x3_out(void) {
}
inter.x3.minus_xaxis = -1.0 * (*inter.x3.xaxis);
if (inter.num_gnuterm_cmds != NO_GNUTERM) {
if (1 + (int) floor(log10(inter.x3.xsteps)) > 3) {
sprintf(text, "_%.4d.", i);
} else if (1 + (int) floor(log10(inter.x3.xsteps)) > 2) {
sprintf(text, "_%.3d.", i);
} else if (1 + (int) floor(log10(inter.x3.xsteps)) > 1) {
sprintf(text, "_%.2d.", i);
} else {
sprintf(text, "_%d.", i);
}
strcpy(gtext, inter.basename);
strcat(gtext, text);
strcat(gtext, init.gnuterm[inter.gnuterm[0]].suffix);
inter.gnutermfn[0] = gtext;
set_progress_message_text("name : %s - %d of %d...", inter.gnutermfn[0], i, inter.x3.xsteps);
}
compute_data();
write_data_file();
......@@ -3664,24 +3687,7 @@ void x3_out(void) {
}
if (inter.num_gnuterm_cmds != NO_GNUTERM) {
if (1 + (int) floor(log10(inter.x3.xsteps)) > 3) {
sprintf(text, "_%.4d.", i);
} else if (1 + (int) floor(log10(inter.x3.xsteps)) > 2) {
sprintf(text, "_%.3d.", i);
} else if (1 + (int) floor(log10(inter.x3.xsteps)) > 1) {
sprintf(text, "_%.2d.", i);
} else {
sprintf(text, "_%d.", i);
}
strcpy(gtext, inter.basename);
strcat(gtext, text);
strcat(gtext, init.gnuterm[inter.gnuterm[0]].suffix);
inter.gnutermfn[0] = gtext;
message("name : %s\n", inter.gnutermfn[0]);
message("writing gnuplot file %d of %d ...\n", i, inter.x3.xsteps);
open_file_to_write_ascii(vglobal.gnuplot_fname, &gfp);
gnufile(i, gfp, vglobal.output_fname);
fclose(gfp);
......@@ -3690,6 +3696,8 @@ void x3_out(void) {
}
}
clear_progress();
fflush(stdout);
if (inter.time) {
print_time(difftime(time(NULL), now));
......
......@@ -1614,7 +1614,16 @@ void write_bs_knm_to_matrix_file(char *filename, bs_knm_t *knm) {
//! Print the progress of the simulation to stderr
size_t prev_progress_print_size = 0;
char progress_buf[LINE_LEN] = {0};
void clear_progress(){
int i=0;
for(i=0; i < prev_progress_print_size; i++){
fprintf(stderr, " ");
}
fprintf(stderr, "\r");
}
/*!
* \param num_points the total number of points in the simulation
......@@ -1660,7 +1669,7 @@ void print_progress(int num_points, int current_point) {
* the progress is printed. Should be a short statement as to what the program
* is doing. e.g. calculating, integrating, saving, calling system, etc..
*/
void set_progress_action_text(char* action, ...){
void set_progress_action_text(const char* action, ...){
assert(action != NULL);
assert(strlen(action) < LINE_LEN);
va_list argptr;
......@@ -1674,12 +1683,13 @@ void set_progress_action_text(char* action, ...){
* the progress is printed. The message appears at the end of the progress and
* should be more informative of the action at present
*/
void set_progress_message_text(char* action, ...){
assert(action != NULL);
assert(strlen(action) < LINE_LEN);
void set_progress_message_text(const char* msg, ...){
assert(msg != NULL);
assert(strlen(msg) < LINE_LEN);
va_list argptr;
va_start(argptr, action);
vsprintf(progress_message, action, argptr);
va_start(argptr, msg);
vsprintf(progress_message, msg, argptr);
va_end(argptr);
}
......
......@@ -99,9 +99,10 @@ void print_version(FILE *file);
void print_help2(void);
void print_help(void);
void max_min(void);
void set_progress_action_text(char* action, ...);
void set_progress_message_text(char* message, ...);
void set_progress_action_text(const char* action, ...);
void set_progress_message_text(const char* message, ...);
void print_progress(int num_points, int current_point);
void clear_progress();
void print_progress_and_time(int num_points, int current_point, time_t starttime);
#endif // KAT_IO_H
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment