Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 13554)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 13555)
@@ -793,8 +793,5 @@
 mpi_sources= ./toolkits/mpi/mpiincludes.h\
 				./toolkits/mpi/patches/mpipatches.h\
-				./toolkits/mpi/patches/DetermineLocalSize.cpp\
-				./toolkits/mpi/patches/MPI_Upperrow.cpp\
-				./toolkits/mpi/patches/MPI_Lowerrow.cpp\
-				./toolkits/mpi/patches/MPI_Boundariesfromrange.cpp
+				./toolkits/mpi/patches/DetermineLocalSize.cpp
 #}}}
 #Metis sources  {{{
Index: /issm/trunk-jpl/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp	(revision 13554)
+++ /issm/trunk-jpl/src/c/toolkits/mpi/patches/DetermineLocalSize.cpp	(revision 13555)
@@ -7,5 +7,8 @@
 #include "../../../shared/shared.h"
 
-int DetermineLocalSize(int global_size){
+int DetermineLocalSize(int global_size,MPI_Comm comm){
+
+	/*size of comm: */
+	int my_rank,num_procs;
 
 	/*output: */
@@ -17,8 +20,13 @@
 	int* num_local_rows=NULL;
 
-	/*from MPI: */
-	extern int num_procs;
-	extern int my_rank;
-	
+	/*retrieve my_rank: */
+	#ifdef _HAVE_MPI_
+	MPI_Comm_rank(comm,&my_rank);
+	MPI_Comm_size(comm,&num_procs);
+	#else
+	my_rank=0;
+	num_procs=1;
+	#endif
+
 	/*We are  not bound by any library, just use what seems most logical*/
 	num_local_rows=xNew<int>(num_procs);    
Index: sm/trunk-jpl/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mpi/patches/MPI_Boundariesfromrange.cpp	(revision 13554)
+++ 	(revision )
@@ -1,38 +1,0 @@
-/*!\file MPI_Boundariesfromrange.cpp
- * \brief: routine to figure out from a range distribution, the lower and upper 
- * bounds for the current cpu.
- */
-
-#include "./mpipatches.h"
-#include "../../../shared/shared.h"
-
-int MPI_Boundariesfromrange(int* plower_row, int* pupper_row,int range){
-
-	extern int num_procs;
-	extern int my_rank;
-	
-	/*output: */
-	int lower_row,upper_row;
-
-	/*intermediary: */
-	int  i;
-	int* allranges=NULL;
-
-	/*Gather all range values into allranges, for all nodes*/
-	allranges=xNew<int>(num_procs);
-	MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,MPI_COMM_WORLD);
-
-	/*From all ranges, get lower row and upper row*/
-	lower_row=0;
-	upper_row=lower_row+allranges[0];
-	for (i=1;i<=my_rank;i++){
-		lower_row=lower_row+allranges[i-1];
-		upper_row=upper_row+allranges[i];
-	}
-
-	/*Assign output pointers: */
-	xDelete<int>(allranges);
-	*plower_row=lower_row;
-	*pupper_row=upper_row;
-	return 1;
-}
Index: sm/trunk-jpl/src/c/toolkits/mpi/patches/MPI_Lowerrow.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mpi/patches/MPI_Lowerrow.cpp	(revision 13554)
+++ 	(revision )
@@ -1,27 +1,0 @@
-/*!\file MPI_Lowerrow.cpp
- * \brief: routine to distribute jobs in parallel. 
- * This handy routine will provide, along with the MPI_Upperrow, a distributed range 
- * for an index (like i,j, in a for loop). 
- * Ex: for(i=MPI_Lowerrow(num_procs)0;i<MPI_Upperrow(num_procs);i++)
- * This ensures easy parallelisation of loops if needed.
- */
-
-#include "./mpipatches.h"
-
-int MPI_Lowerrow(int n){
-
-
-	int range;
-	int lower_row;
-	int upper_row;
-	
-
-	/*First, figure out our range : */
-	range=DetermineLocalSize(n);
-
-	/*Now determien upper and lower boundaries: */
-	MPI_Boundariesfromrange(&lower_row,&upper_row,range);
-
-	return lower_row;
-	
-}
Index: sm/trunk-jpl/src/c/toolkits/mpi/patches/MPI_Upperrow.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mpi/patches/MPI_Upperrow.cpp	(revision 13554)
+++ 	(revision )
@@ -1,30 +1,0 @@
-/*!\file MPI_Upperrow.cpp
- * \brief: routine to distribute jobs in parallel. 
- * This handy routine will provide, along with the MPI_Lowrrow, a distributed range 
- * for an index (like i,j, in a for loop). 
- * Ex: for(i=MPI_Lowerrow(num_procs)0;i<MPI_Upperrow(num_procs);i++)
- * This ensures easy parallelisation of loops if needed.
- */
-
-#include "./mpipatches.h"
-
-int MPI_Upperrow(int n){
-
-	int range;
-	int lower_row;
-	int upper_row;
-
-	/*First, figure out our range : */
-	range=DetermineLocalSize(n);
-
-	/*Now determien upper and lower boundaries: */
-	MPI_Boundariesfromrange(&lower_row,&upper_row,range);
-
-	return upper_row;
-	
-}
-
-
-
-
-
Index: /issm/trunk-jpl/src/c/toolkits/mpi/patches/mpipatches.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mpi/patches/mpipatches.h	(revision 13554)
+++ /issm/trunk-jpl/src/c/toolkits/mpi/patches/mpipatches.h	(revision 13555)
@@ -6,13 +6,4 @@
 #ifndef MPI_PATCHES_H_ 
 #define MPI_PATCHES_H_
-
-
-int MPI_Boundariesfromrange(int* plower_row, int* pupper_row,int range);
-int MPI_Lowerrow(int n);
-int MPI_Upperrow(int n);
-int DetermineLocalSize(int global_size);
-
-
-
-
+int DetermineLocalSize(int global_size,MPI_Comm comm);
 #endif
