1212#include " grid.hpp"
1313#include " arrays.hpp"
1414
15+ int Exchanger::nInstances = 0 ;
16+
1517void Exchanger::Init (
1618 Grid *grid,
1719 int direction,
@@ -27,6 +29,9 @@ void Exchanger::Init(
2729 this ->mapNVars = inputMap.size ();
2830 this ->haveVs = inputHaveVs;
2931
32+ // increase the number of instances
33+ this ->thisInstance = nInstances;
34+
3035 // Compute indices of arrays we will be working with
3136 for (int dir = 0 ; dir < 3 ; dir++) {
3237 this ->nghost [dir] = nghost[dir];
@@ -119,28 +124,29 @@ void Exchanger::Init(
119124 // We receive from procRecv, and we send to procSend
120125
121126 MPI_Send_init (BufferSend[faceRight].data (), bufferSize[faceRight], realMPI,
122- procSend[faceRight], thisInstance*100 + 10 *direction ,
127+ procSend[faceRight], thisInstance*2 ,
123128 grid->CartComm , &sendRequest[faceRight]);
124129
125130 MPI_Recv_init (BufferRecv[faceLeft].data (), bufferSize[faceRight], realMPI,
126- procRecv[faceLeft],thisInstance*100 + 10 *direction ,
131+ procRecv[faceLeft],thisInstance*2 ,
127132 grid->CartComm , &recvRequest[faceLeft]);
128133
129134 // Send to the left
130135 // We receive from procRecv, and we send to procSend
131136
132137 MPI_Send_init (BufferSend[faceLeft].data (), bufferSize[faceLeft], realMPI,
133- procSend[faceLeft],thisInstance*100 + 10 *direction +1 ,
138+ procSend[faceLeft],thisInstance*2 +1 ,
134139 grid->CartComm , &sendRequest[faceLeft]);
135140
136141 MPI_Recv_init (BufferRecvX1[faceRight].data (), bufferSizeX1[faceLeft], realMPI,
137- procRecv[faceRight], thisInstance*100 + 10 *direction +1 ,
142+ procRecv[faceRight], thisInstance*2 +1 ,
138143 grid->CartComm , &recvRequest[faceRight]);
139144
140145 #endif // MPI_PERSISTENT
141146
142147 // say this instance is initialized.
143148 isInitialized = true ;
149+ nInstances++;
144150
145151 idfx::popRegion ();
146152}
0 commit comments