- MPI_Topology topo = smpi_comm_topo(comm);
- int ndims = topo->ndims;
- int multiplier, coord,i;
- *rank = 0;
- multiplier = 1;
-
-
-
- for ( i=ndims-1; i >=0; i-- ) {
- coord = coords[i];
-
- /* Should we check first for args correction, then process,
- * or check while we work (as it is currently done) ? */
- if (coord >= topo->dims[i]) {
- if ( topo->periodic[i] ) {
- coord = coord % topo->dims[i];
- }
- else {
- // Should I do that ?
- *rank = -1;
- return MPI_ERR_ARG;
- }
- }
- else if (coord < 0) {
- if(topo->periodic[i]) {
- coord = coord % topo->dims[i];
- if (coord) coord = topo->dims[i] + coord;
+ MPI_Topology topo = smpi_comm_topo(comm);
+ int ndims = topo->topo.cart->ndims;
+ int multiplier, coord,i;
+ *rank = 0;
+ multiplier = 1;
+
+ for ( i=ndims-1; i >=0; i-- ) {
+ coord = coords[i];
+
+ /* The user can give us whatever coordinates he wants. If one of them is
+ * out of range, either this dimension is periodic, and then we
+ * consider the equivalent coordinate inside the bounds, or it is not
+ * and then it is an error
+ */
+ if (coord >= topo->topo.cart->dims[i]) {
+ if ( topo->topo.cart->periodic[i] ) {
+ coord = coord % topo->topo.cart->dims[i];
+ }
+ else {
+ // Should I do that ?
+ *rank = -1;
+ return MPI_ERR_ARG;
+ }