CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Obtain the processor id in parallel code (http://www.cfd-online.com/Forums/openfoam-programming-development/66256-obtain-processor-id-parallel-code.html)

albcem July 10, 2009 00:40

Obtain the processor id in parallel code
 
Hello all,

I am trying to obtain the processor id to perform a serial file writing in a parallel simulation.

Essentially, I am using ofstream as it has the append feature that OFstream does not. OFstream seams to be "parallel aware" while ofstream is not. So I would like to execute a statement like

if ( processor == 0 )
{
"Perform ofstream based file writing"
}

So how does one obtain the processor id in the OpenFOAM environment?

Thanks

Cem

olesen July 10, 2009 02:23

Did you check the Pstream documentation?
I think you'll find something useful there.

BTW: assuming you don't care about processor == 0 per se, but if you are on the master process - that information is in the Pstream docs as well.

deepsterblue July 10, 2009 09:07

Try this:

if (Pstream::master())
{
// Do work here
}

Hope this helps.

juho July 11, 2009 03:18

The Doxygen Pstream documentation will also be helpful, I'm sure:
http://foam.sourceforge.net/doc/Doxy..._1Pstream.html

albcem August 7, 2009 13:35

The tips helped.

Thanks a lot!


Cem


All times are GMT -4. The time now is 02:15.