Ice Sheet System Model
4.18
Code documentation
src
c
toolkits
mpi
commops
GetOwnershipBoundariesFromRange.cpp
Go to the documentation of this file.
1
6
#ifdef HAVE_CONFIG_H
7
#include <config.h>
8
#else
9
#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
10
#endif
11
12
#include <stdio.h>
13
#include "../../../shared/MemOps/MemOps.h"
14
#include "../../../shared/io/Comm/IssmComm.h"
15
16
void
GetOwnershipBoundariesFromRange
(
int
* plower_row,
int
* pupper_row,
int
range,
ISSM_MPI_Comm
comm){
17
18
/*externals :*/
19
int
my_rank;
20
int
num_procs;
21
22
/*recover my_rank and num_procs:*/
23
ISSM_MPI_Comm_size
(comm,&num_procs);
24
ISSM_MPI_Comm_rank
(comm,&my_rank);
25
26
/*output: */
27
int
lower_row,upper_row;
28
29
/*Gather all range values into allranges, for all nodes*/
30
int
* allranges=xNew<int>(num_procs);
31
ISSM_MPI_Allgather
(&range,1,
ISSM_MPI_INT
,allranges,1,
ISSM_MPI_INT
,comm);
32
33
/*From all ranges, get lower row and upper row*/
34
lower_row=0;
35
upper_row=lower_row+allranges[0];
36
for
(
int
i=1;i<=my_rank;i++){
37
lower_row=lower_row+allranges[i-1];
38
upper_row=upper_row+allranges[i];
39
}
40
41
/*Assign output*/
42
*plower_row=lower_row;
43
*pupper_row=upper_row;
44
xDelete<int>(allranges);
45
}
ISSM_MPI_Comm_rank
int ISSM_MPI_Comm_rank(ISSM_MPI_Comm comm, int *rank)
Definition:
issmmpi.cpp:198
ISSM_MPI_INT
#define ISSM_MPI_INT
Definition:
issmmpi.h:127
GetOwnershipBoundariesFromRange
void GetOwnershipBoundariesFromRange(int *plower_row, int *pupper_row, int range, ISSM_MPI_Comm comm)
Definition:
GetOwnershipBoundariesFromRange.cpp:16
ISSM_MPI_Allgather
int ISSM_MPI_Allgather(void *sendbuf, int sendcount, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcount, ISSM_MPI_Datatype recvtype, ISSM_MPI_Comm comm)
Definition:
issmmpi.cpp:45
ISSM_MPI_Comm
int ISSM_MPI_Comm
Definition:
issmmpi.h:118
ISSM_MPI_Comm_size
int ISSM_MPI_Comm_size(ISSM_MPI_Comm comm, int *size)
Definition:
issmmpi.cpp:209
Generated on Thu Jul 2 2020 08:09:22 for Ice Sheet System Model by
1.8.19