aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/dist.hh
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2006-02-25 17:26:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2006-02-25 17:26:00 +0000
commit7aea996581324bd60f8349779625a26082b45a85 (patch)
tree82b12f93518ca5599675ee5a9dcf2e98ce582316 /Carpet/CarpetLib/src/dist.hh
parent63c13016173d70762f6f23c624f597484c906096 (diff)
CarpetLib: Cache the results of MPI_Comm_rank and MPI_Comm_size
darcs-hash:20060225172648-dae7b-93b93c97212a7fa33c8770200b8f8b1494ad9776.gz
Diffstat (limited to 'Carpet/CarpetLib/src/dist.hh')
-rw-r--r--Carpet/CarpetLib/src/dist.hh8
1 files changed, 4 insertions, 4 deletions
diff --git a/Carpet/CarpetLib/src/dist.hh b/Carpet/CarpetLib/src/dist.hh
index 86fcbf61b..d68c733ee 100644
--- a/Carpet/CarpetLib/src/dist.hh
+++ b/Carpet/CarpetLib/src/dist.hh
@@ -60,16 +60,16 @@ namespace dist {
// Rank in the communicator (this processor's number, 0 .. size-1)
inline int rank ()
{
- int rank_;
- MPI_Comm_rank (comm(), &rank_);
+ static int rank_ = -1;
+ if (rank_ == -1) MPI_Comm_rank (comm(), &rank_);
return rank_;
}
// Size of the communicator
inline int size ()
{
- int size_;
- MPI_Comm_size (comm(), &size_);
+ static int size_ = -1;
+ if (size_ == -1) MPI_Comm_size (comm(), &size_);
return size_;
}