[petsc-users] printing from some processors to a file

Barry Smith bsmith at mcs.anl.gov
Tue Nov 26 16:15:50 CST 2013


    Thanks for reporting this with a full test case. It is our bug. 

     The implementation keeps the file pointer in a global variable on process 0 that is set in the first call to the PetscViewerASCIISynchronizedPrintf() or in PetscSynchronizedFPrintf() . The reason for the ugly global is that PetscSynchronizedFlush() can be applied to any number of file pointers. But if the SynchronizedPrintf() is never called on process 0 the file pointer global never gets set so it defaults to stdout.

     It may be fixable by having PetscSynchronizedFlush() take a file pointer argument (makes sense). I’ll try to fix it, until make sure process 0 prints at least one thing and it will work ok.


On Nov 26, 2013, at 3:45 PM, Randall Mackie <rlmackie862 at gmail.com> wrote:

> I am trying to print a character string to a file from one or more processors in a communicator. I thought that I could do this using PetscViewerASCIISynchronizedPrintf, but it prints to the screen instead of to the file opened as a viewer. The attached simple program illustrates the issue. If I remove the (if rank == 1) and therefore call PetscViewerASCIISynchronizedPrintf from every process, it works as expected. If called from only 1 process, it prints to the screen. I thought, from the documentation, that it was not collective, but maybe I am not understanding it's usage.
> Randy M.
> <test.F90>

More information about the petsc-users mailing list