CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to extract MPI rank? (https://www.cfd-online.com/Forums/openfoam-solving/223416-how-extract-mpi-rank.html)

ssc0109 January 9, 2020 18:05

How to extract MPI rank?
 
Hello Friends,
I'm wondering how to extract MPI rank in OpenFOAM?
In general, I think this would work:
Code:

#include"mpi.h"

int main(int argc , char **argv)
{
int size,rank;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

Info << "rank: " << rank << nl << endl;
}

But I meet the error:
Code:

Fatal error in PMPI_Init_thread: Other MPI error, error stack:
MPI_Init_thread(1028): Cannot call MPI_INIT or MPI_INIT_THREAD more than once

I am using Intel(R) MPI by the way.

Thanks a lot

ssc0109 January 9, 2020 18:50

solved,
for people who meet the same problem,
use
Code:

rank = Pstream::myProcNo();
Pout << "rank: " << rank << nl << endl;



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