[petsc-users] PetscInitalize() and console output
Matthew Knepley
knepley at gmail.com
Tue Dec 13 08:45:59 CST 2011
On Tue, Dec 13, 2011 at 8:43 AM, Thomas Leissing <thomas.leissing at cstb.fr>wrote:
> **
> Dear all,
>
> Somewhere in my boundary element solver I have a console progress bar
> which prints to screen the progress of an operation.
> It looks like this:
> INFO : 50% [------------> ]
>
> The function is very simple:
> //i is the current iteration number
> //n is the total number of iterations
> void progressBar(int x, int n)
> {
>
> if ( x % (n/100) != 0 ) return;
>
> // Calculate the ratio of complete-to-incomplete.
> float ratio = x/(float)n;
> int c = ratio * 80
>
> // Show the percentage complete.
> printf("INFO :\t%3d%% [", (int)(ratio*100) );
>
> // Show the load bar.
> for (int x=0; x<c-1; x++)
> printf("-");
>
> printf(">");
>
> for (int x=c; x<pBarWidth; x++)
> printf(" ");
>
> // ANSI Control codes to go back to the
> // previous line and clear it.
> printf("]\n\033[F\033[J");
> }
>
>
> My problem is that the progress bar doesn't print to screen as soon as I
> call the PetscInitialize() function (it works fine otherwise).
> I tried to play with fflush(stdout) commands without any success.
>
> Any ideas ?
>
This sounds like MPI rather than PETSc, since it plays with output. Are you
running with mpiexec?
Matt
> Thanks,
> Thomas Leissing
>
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111213/46badf0c/attachment-0001.htm>
More information about the petsc-users
mailing list