commit c615972e6b208614daeb179ce8717698bfe1301b
parent a4db985d9306fc8c1d95d9ea29d29a4a44e84c94
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 23 Feb 2021 14:59:41 +0100
Update the the way the progress message is printed
Diffstat:
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/htsky.h b/src/htsky.h
@@ -93,7 +93,7 @@ struct htsky_args {
HTSKY_SPECTRAL_TYPES_COUNT__, /* spectral type */ \
{DBL_MAX,-DBL_MAX}, /* Spectral integration range */ \
{UINT_MAX, UINT_MAX, UINT_MAX}, /* Maximum definition of the grid */ \
- 1, /* Optical thickness */ \
+ 1, /* Optical thickness */ \
(unsigned)~0, /* #threads */ \
0, /* Repeat clouds */ \
0 /* Verbosity level */ \
diff --git a/src/htsky_cloud.c b/src/htsky_cloud.c
@@ -626,6 +626,15 @@ cloud_vox_challenge_merge
&& vox_challenge_merge_component(HTSKY_CPNT_GAS, voxels, nvoxs, ctx);
}
+static INLINE void
+print_progress(struct htsky* sky, const int progress)
+{
+ ASSERT(sky && progress >= 0 && progress <= 100);
+ log_info(sky, "\033[2K\r"); /* Erase the line */
+ log_info(sky,"Computing clouds data & building octrees: %3d%%\r" , progress);
+}
+
+
static res_T
cloud_build_octrees
(struct htsky* sky,
@@ -671,8 +680,7 @@ cloud_build_octrees
vxsz[2] = vxsz[2] / (double)nvoxs[2];
omp_set_num_threads((int)sky->nthreads);
- #define LOG_MSG "\033[2K\rComputing clouds data & building octrees: %3d%%"
- log_info(sky, LOG_MSG, 0);
+ print_progress(sky, 0);
#pragma omp parallel for schedule(dynamic, 1/*chunksize*/)
for(ispecdata=0; ispecdata < nspecdata; ++ispecdata) {
struct svx_voxel_desc vox_desc = SVX_VOXEL_DESC_NULL;
@@ -732,15 +740,15 @@ cloud_build_octrees
#pragma omp critical
if(pcent > progress) {
progress = pcent;
- log_info(sky, LOG_MSG, pcent);
+ print_progress(sky, pcent);
}
}
if(res != RES_OK)
goto error;
- log_info(sky, LOG_MSG"\n", 100);
- #undef LOG_MSG
+ print_progress(sky, 100);
+ log_info(sky, "\n"); /* New line */
exit:
return (res_T)res;