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 |
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. |
Try this:
if (Pstream::master()) { // Do work here } Hope this helps. |
The Doxygen Pstream documentation will also be helpful, I'm sure:
http://foam.sourceforge.net/doc/Doxy..._1Pstream.html |
The tips helped.
Thanks a lot! Cem |
All times are GMT -4. The time now is 19:55. |