Ice Sheet System Model  4.18
Code documentation
IssmComm.cpp
Go to the documentation of this file.
1 
5 #ifdef HAVE_CONFIG_H
6  #include <config.h>
7 #else
8 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
9 #endif
10 
11 #include "./IssmComm.h"
12 #include "../../Numerics/types.h"
13 #include "../../Exceptions/exceptions.h"
14 
15 void IssmComm::SetComm(ISSM_MPI_Comm incomm){ /*{{{*/
16 
17  /*A comm is provided, we are running in parallel (this is not a module)*/
18  parallel = true;
19  comm = incomm;
20 
21 }/*}}}*/
22 void IssmComm::SetComm(void){ /*{{{*/
23 
24  /*no comm provided, This is a matlab/python module*/
25  parallel = false;
26 
27  /*No need to initialise comm*/
28 
29 }/*}}}*/
31  if(!parallel) _error_("Cannot return comm in serial mode");
32  return comm;
33 }/*}}}*/
34 int IssmComm::GetRank(){ /*{{{*/
35 
36  int my_rank = 0;
37 
38  /*for matlab and python modules*/
39  if(!parallel) return my_rank;
40 
41  ISSM_MPI_Comm_rank(comm,&my_rank);
42 
43  return my_rank;
44 
45 }/*}}}*/
46 int IssmComm::GetSize(){ /*{{{*/
47 
48  int size = 1;
49 
50  /*for matlab and python modules*/
51  if(!parallel) return size;
52 
53  ISSM_MPI_Comm_size(comm,&size);
54 
55  return size;
56 
57 }/*}}}*/
IssmComm::GetComm
static ISSM_MPI_Comm GetComm(void)
Definition: IssmComm.cpp:30
IssmComm::comm
static ISSM_MPI_Comm comm
Definition: IssmComm.h:23
ISSM_MPI_Comm_rank
int ISSM_MPI_Comm_rank(ISSM_MPI_Comm comm, int *rank)
Definition: issmmpi.cpp:198
IssmComm::parallel
static bool parallel
Definition: IssmComm.h:24
IssmComm::GetSize
static int GetSize(void)
Definition: IssmComm.cpp:46
IssmComm::SetComm
static void SetComm(void)
Definition: IssmComm.cpp:22
IssmComm::GetRank
static int GetRank(void)
Definition: IssmComm.cpp:34
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
IssmComm.h
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