PLUTO
cartcoord.c
Go to the documentation of this file.
1 #include
2 
3 GetRankCoordinates (periods, nprocs, coords);
4 
5 /* ********************************************************************* */
6 void GetRankCoordinates (int periods[3], int nprocs[3], int coords[3])
7 /*
8  *
9  *
10  *********************************************************************** */
11 {
12  MPI_Comm cartcomm;
13  MPI_Status status;
14  int nprocs[3], periods[3], coords[3];
15  int rank;
16 
17  MPI_Comm_rank(MPI_COMM_WORLD, &prank);
18 
19  coords[0] = coords[1] = coords[2] = 0;
20  periods[0] = periods[1] = periods[2] = 0;
21  nprocs[0] = nprocs[1] = nprocs[2] = 0;
22 
23  AL_Get_cart_comm(SZ, &cartcomm);
24  MPI_Cart_get(cartcomm, 3, nprocs, periods, coords);
25  MPI_Cart_rank(cartcomm, coords, &rank);
26 }
27 
28 
29 /* ********************************************************************* */
30 int CoordOffRank(Grid *grid, int dir, int poff, MPI_comm *cartcomm)
31 /*
32  * PURPOSE
33  *
34  * Obtain the rank associated to the processor with
35  * Cartesian grid coordinates
36  * [ix, iy, iz] + poff*[dir==IDIR, dir==JDIR, dir==KDIR]
37  *
38  *********************************************************************** */
39 {
40  int coords[3], rnk;
41 
42  coords[IDIR] = grid[IDIR].rank_coord;
43  coords[JDIR] = grid[JDIR].rank_coord;
44  coords[KDIR] = grid[KDIR].rank_coord;
45 
46  coords[dir] += poff;
47 
48  MPI_Cart_rank(cartcomm, coords, &rnk);
49  return rnk;
50 }
GetRankCoordinates(periods, nprocs, coords)
int CoordOffRank(Grid *grid, int dir, int poff, MPI_comm *cartcomm)
Definition: cartcoord.c:30
int prank
Processor rank.
Definition: globals.h:33
#define KDIR
Definition: pluto.h:195
int AL_Get_cart_comm(int, MPI_Comm *)
Definition: al_sz_get.c:117
#define IDIR
Definition: pluto.h:193
Definition: structs.h:78
int rank_coord
Parallel coordinate in a Cartesian topology.
Definition: structs.h:121
Definition: al_hidden.h:38
#define JDIR
Definition: pluto.h:194