Hello,

I just created a little package, RcppProgress, to display a progress bar to
monitor the execution status of a C++ code loop, possibly multihreaded with
OpenMP.
I also implemented the possibility to check for user interruption, using
the work-around by Simon Urbanek.

I just uploaded the package on my R-forge project, so you should be able to
get the package from
https://r-forge.r-project.org/scm/viewvc.php/pkg/RcppProgress/?root=gwas-bin-tests

* The progress bar is displayed using REprintf, so that it works also in
the eclipse StatET console, provided that you disable the scroll lock.
* You should be able to nicely interrupt the execution by typing CTRL+C in
the R console, or by clicking the "cancel current task" in the StatET
console.
* I tried to write a small documentation, included in the package, but
basically you use it like this:

The main loop:

Progress p(max, display_progress); // create the progress monitor
#pragma omp parallel for schedule(dynamic)
    for (int i = 0; i < max; ++i) {
        if ( ! p.is_aborted() ) { // the only way to exit an OpenMP loop
            long_computation(nb);
            p.increment(); // update the progress
        }
    }

and in your computation intensive function:

void long_computation(int nb) {
    double sum = 0;
    for (int i = 0; i < nb; ++i) {
        if ( Progress::check_abort() )
            return;
        for (int j = 0; j < nb; ++j) {
            sum += Rf_dlnorm(i+j, 0.0, 1.0, 0);
        }
    }
}

I provided two small R test functions so that you can see how it looks,
please see the doc.

 I would be extremely grateful if you could give me comments, criticisms
and other suggestions.

I try to release this in order to reuse this functionality in my other
packages.

Best regards,
Karl Forner

	[[alternative HTML version deleted]]

