31#define SHOW_CPPSTATE "C++"
33#define SHOW_CPPSTATE "\b"
87 auto now = std::chrono::system_clock::now();
88 auto timenow = std::chrono::system_clock::to_time_t(
now);
107 std::string
h = std::to_string(
time / 3600);
108 std::string
m = std::to_string((
time % 3600) / 60);
109 std::string
s = std::to_string(
time % 60);
113 if (
h.length() < 2) {
114 hh = std::string(2 -
h.length(),
'0') +
h;
119 std::string
mm = std::string(2 -
m.length(),
'0') +
m;
120 std::string
ss = std::string(2 -
s.length(),
'0') +
s;
131 std::chrono::duration_cast<std::chrono::seconds>(
296 "Progress bar must count at least one task in total.\n"
301 this->set_default_pcpt_nodes();
308 this->bar_width =
width;
312 if (nodes.size() < 1) {
314 "Progress bar nodes must have at least one element.\n"
323 "Progress bar task index must be non-negative and "
324 "within the total task count.\n"
336 "Progress bar progress must be within the range [0, 1].\n"
341 this->next_node_idx = 0;
342 while (this->progress > this->nodes[this->next_node_idx]) {
343 this->next_node_idx += 1;
350 this->
update(progress_now);
357 if (this->
progress >= this->nodes[this->next_node_idx]) {
358 int pos = this->bar_width * this->
progress;
360 if (this->
name !=
"") {
361 std::cout << this->
name <<
" [";
376 std::cout <<
"] " <<
int(
progress * 100.) <<
" %\r";
379 this->next_node_idx += 1;
383 "Progress bar has already completed: progress %f > 1.\n", this->
progress
386 if (this->
progress == 1.) {std::cout << std::endl;}
389void ProgressBar::set_default_pcpt_nodes() {
390 this->nodes.resize(101, 0.);
392 this->nodes.push_back(
float(
pcpt) / 100.);
403 "Unimplemented error."
435std::invalid_argument(
436 "Invalid parameter error."
454 "Invalid data error."
478 " //\\ ___ __ __ ___ ___ \n"
479 " // \\ | |__) | | | |\\/| \\ / | |__) /\\ | |__ \n"
480 " // \\ | | \\ | \\__/ | | \\/ | | \\ /~~\\ | |___ \n"
482 " //________\\ • Three-Point Clustering Measurements in LSS • \n"
484 "(C) 2023 Mike S Wang & Naonori S Sugiyama [GPL-3.0] \n"
490 std::printf(
"LICENCE NOTICE >\n\n");
492 "This program is free software: you can redistribute it and/or modify \n"
493 "it under the terms of the GNU General Public License as published by \n"
494 "the Free Software Foundation, either version 3 of the License, or \n"
495 "(at your option) any later version. \n"
497 "This program is distributed in the hope that it will be useful, but \n"
498 "WITHOUT ANY WARRANTY; without even the implied warranty of \n"
499 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \n"
500 "General Public License for more details. \n"
502 "You should have received a copy of the GNU General Public License \n"
503 "along with this program. If not, see <https://www.gnu.org/licenses/>.\n"
509 std::printf(
"RUNTIME INFORMATION >\n\n");
512#define _GSL_VERSION GSL_VERSION
514#define _GSL_VERSION "unknown"
521#define _OMP_VERSION std::to_string(_OPENMP)
522#define _OMP_NTHREADS omp_get_max_threads()
524#define _OMP_VERSION std::string("unknown")
525#define _OMP_NTHREADS 1
527 std::printf(
"OpenMP version: %s\n",
_OMP_VERSION.c_str());
537 std::printf(
"PROGRAM LOG >\n\n");
544 "Invalid endpoint for log bars: %d.\n",
endpoint
IOError(const char *fmt_string,...)
Construct an trv::sys::IOError exception.
std::string err_mesg
error message
virtual const char * what() const noexcept
Exception string representation.
Exception raised when the data to be operated on are invalid.
std::string err_mesg
error message
virtual const char * what() const noexcept
Exception string representation.
InvalidDataError(const char *fmt_string,...)
Construct an trv::sys::InvalidDataError exception.
Exception raised when parameters are invalid.
InvalidParameterError(const char *fmt_string,...)
Construct an trv::sys::InvalidParameterError exception.
virtual const char * what() const noexcept
Exception string representation.
std::string err_mesg
error message
Logger with logging level differentiation.
Logger(LogLevel level)
Construct the logger with the specified threshold level.
void info(const char *fmt_string,...)
Emit a information-level message.
void debug(const char *fmt_string,...)
Emit a debugging-level message.
void error(const char *fmt_string,...)
Emit a warning-level message.
void warn(const char *fmt_string,...)
Emit a warning-level message.
void stat(const char *fmt_string,...)
Emit a status-level message.
int level_limit
logger threshold level
void log(LogLevel level_entry, const char *fmt_string,...)
Log a message at the specified level.
void reset_level(LogLevel level)
Reset the logger threshold level.
float progress
progress value in [0, 1] interval
int task_count
total task count
ProgressBar(int task_count, std::string name="")
Construct a progress bar.
void set_task_idx(int task_idx)
Set current (or initial) task index.
void set_nodes(std::vector< float > nodes)
Set progress bar width.
void set_bar_width(int bar_width)
Set progress bar width.
std::string name
progress bar name
void update(int task_idx_now)
Update the progress bar.
void set_progress(float progress)
Set current (or initial) progress value.
virtual const char * what() const noexcept
Exception string representation.
std::string err_mesg
error message
UnimplementedError(const char *fmt_string,...)
Construct an trv::sys::UnimplementedError exception.
Provide tracking of program resources and exceptions.
double gbytesMem
current memory usage in gibibytes
std::string show_timestamp()
Return the timestamp string including the elapsed time.
auto clockStart
program starting time
double size_in_gb(long long num)
Return size in gibibytes.
void update_maxmem()
Update the maximum memory usage estimate.
void display_prog_licence()
Display program licence in stdout.
bool fftw_wisdom_b_imported
wisdom import status for backward transform
void display_prog_logo()
Display program logo in stdout.
bool fftw_wisdom_f_imported
wisdom import status for forward transform
float max_count_grid
maximum number of grids
Logger logger
default logger (at NSET logging level)
int max_count_rgrid
maximum number of 3-d real grids
float count_grid
number of grids
int max_count_cgrid
maximum number of 3-d complex grids
std::string show_current_datetime()
Return the current date-time string in 'YYYY-MM-DD HH:MM:SS' format.
void display_prog_logbars(int endpoint)
Display program log bars in stdout.
int count_fft
number of FFTs
int count_cgrid
number of 3-d complex grids
double gbytesMaxMem
maximum memory usage in gibibytes
int count_rgrid
number of 3-d real grids
int count_ifft
number of IFFTs
void update_maxcntgrid()
Update the maximum 3-d grid counts.
void display_prog_info()
Display program information in stdout.
std::string show_elapsed_time(double duration_in_seconds)
Return the elapsed-time string in 'HH:MM:SS' format.