title: Overloading the operator () in MPI
body: <p>Hope you are doing well in these times.</p>
  <p>I am attempting to write a parallelized solver in C/C++ and have an array distributed over the processes (p).</p>
  <p>In an attempt to overload the operator '( )'; in order to return the local value of the distributed array from the respective process, I have a function as follows:</p>
  <pre><code>**double&amp;** operator()(int r, int c)
  {
             int rank = MPI::COMM_WORLD.Get_rank();
             int size = MPI::COMM_WORLD.Get_size();
             int globalIndex = r * mcols() + c;
             if (globalIndex &gt;= lo &amp;&amp; globalIndex &lt;= (lo + bloc))
                          **return localData [ globalIndex % lo];**
  }
  </code></pre>
  <p>The problem comes in the highlighted sections where I would like only one process (the one that has the value) to return it, however all the processes attempt on the returning some value. I end up with an mpi runtime error where the processes have a function without a return value (for when the condition fails).</p>
  <p>(1) Is there a way in which I can selectively choose a specific process to execute a function
  (2) Or is there a way I can exit a function without returning a value.
  (3) this is a semantics problem, is there way that this case is handled</p>