Ice Sheet System Model  4.18
Code documentation
Functions
GetOwnershipBoundariesFromRange.cpp File Reference

from a local range on each cpu, we determine what lower row and upper row from a matrix a cpu owns. More...

#include <stdio.h>
#include "../../../shared/MemOps/MemOps.h"
#include "../../../shared/io/Comm/IssmComm.h"

Go to the source code of this file.

Functions

void GetOwnershipBoundariesFromRange (int *plower_row, int *pupper_row, int range, ISSM_MPI_Comm comm)
 

Detailed Description

from a local range on each cpu, we determine what lower row and upper row from a matrix a cpu owns.

Definition in file GetOwnershipBoundariesFromRange.cpp.

Function Documentation

◆ GetOwnershipBoundariesFromRange()

void GetOwnershipBoundariesFromRange ( int *  plower_row,
int *  pupper_row,
int  range,
ISSM_MPI_Comm  comm 
)

Definition at line 16 of file GetOwnershipBoundariesFromRange.cpp.

16  {
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
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_size
int ISSM_MPI_Comm_size(ISSM_MPI_Comm comm, int *size)
Definition: issmmpi.cpp:209