Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 15837)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 15838)
@@ -173,5 +173,4 @@
 					./shared/io/Print/Print.h\
 					./shared/io/Comm/Comm.h\
-					./shared/io/Comm/CommDef.h\
 					./shared/io/Comm/IssmComm.h\
 					./shared/io/Comm/IssmComm.cpp\
@@ -763,5 +762,5 @@
 #Mpi sources  {{{
 mpi_sources= ./toolkits/mpi/issmmpi.h\
-				./toolkits/mpi/issmpi.cpp\
+				./toolkits/mpi/issmmpi.cpp\
 				./toolkits/mpi/commops/commops.h\
 				./toolkits/mpi/commops/DetermineLocalSize.cpp\
Index: /issm/trunk-jpl/src/c/analyses/DakotaSpawnCore.cpp
===================================================================
--- /issm/trunk-jpl/src/c/analyses/DakotaSpawnCore.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/analyses/DakotaSpawnCore.cpp	(revision 15838)
@@ -49,7 +49,5 @@
 
 	/*If counter==-1 on cpu0, it means that the dakota runs are done. In which case, bail out and return 0: */
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&counter,1,MPI_INT,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&counter,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 	if(counter==-1)return 0;
 
@@ -116,9 +114,9 @@
 
 	/*numvariables: */
-	MPI_Bcast(&numvariables,1,MPI_INT,0,IssmComm::GetComm()); 
+	ISSM_MPI_Bcast(&numvariables,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	/*variables:*/
 	if(my_rank!=0)variables=xNew<double>(numvariables);
-	MPI_Bcast(variables,numvariables,MPI_DOUBLE,0,IssmComm::GetComm()); 
+	ISSM_MPI_Bcast(variables,numvariables,MPI_DOUBLE,0,IssmComm::GetComm()); 
 
 	/*variables_descriptors: */
@@ -131,12 +129,12 @@
 			string_length=(strlen(string)+1)*sizeof(char);
 		}
-		MPI_Bcast(&string_length,1,MPI_INT,0,IssmComm::GetComm()); 
+		ISSM_MPI_Bcast(&string_length,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 		if(my_rank!=0)string=xNew<char>(string_length);
-		MPI_Bcast(string,string_length,MPI_CHAR,0,IssmComm::GetComm()); 
+		ISSM_MPI_Bcast(string,string_length,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 
 		if(my_rank!=0)variables_descriptors[i]=string;
 	}
 
 	/*numresponses: */
-	MPI_Bcast(&numresponses,1,MPI_INT,0,IssmComm::GetComm()); 
+	ISSM_MPI_Bcast(&numresponses,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/analyses/EnvironmentFinalize.cpp
===================================================================
--- /issm/trunk-jpl/src/c/analyses/EnvironmentFinalize.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/analyses/EnvironmentFinalize.cpp	(revision 15838)
@@ -12,17 +12,14 @@
 void EnvironmentFinalize(void){
 
-	#ifdef _HAVE_MPI_
+	int my_rank;
 
 	/*Make sure we are all here*/
-	MPI_Barrier(MPI_COMM_WORLD);
+	ISSM_MPI_Barrier(ISSM_MPI_COMM_WORLD);
 
 	/*Print closing statement*/
-	int my_rank;
-	MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
+	ISSM_MPI_Comm_rank(ISSM_MPI_COMM_WORLD,&my_rank);
 	if(!my_rank) printf("closing MPI\n");
 
 	/*Finalize: */
-	MPI_Finalize();
-
-	#endif
+	ISSM_MPI_Finalize();
 }
Index: /issm/trunk-jpl/src/c/analyses/EnvironmentInit.cpp
===================================================================
--- /issm/trunk-jpl/src/c/analyses/EnvironmentInit.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/analyses/EnvironmentInit.cpp	(revision 15838)
@@ -17,6 +17,6 @@
 	/*Initialize MPI environment: */
 	#if defined(_HAVE_MPI_)
-	MPI_Init(&argc,&argv);
-	comm = MPI_COMM_WORLD;
+	ISSM_MPI_Init(&argc,&argv);
+	comm = ISSM_MPI_COMM_WORLD;
 	#else
 	comm = 1; //bogus number for comm, which does not exist anyway.
@@ -25,7 +25,5 @@
 	/*Print Banner*/
 	int my_rank = 0;
-	#ifdef _HAVE_MPI_
-	MPI_Comm_rank(comm,&my_rank);
-	#endif
+	ISSM_MPI_Comm_rank(comm,&my_rank);
 	if(!my_rank) printf("\n");
 	if(!my_rank) printf("Ice Sheet System Model (%s) version  %s\n",PACKAGE_NAME,PACKAGE_VERSION);
Index: /issm/trunk-jpl/src/c/classes/Constraints/Constraints.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Constraints/Constraints.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/classes/Constraints/Constraints.cpp	(revision 15838)
@@ -29,10 +29,6 @@
 
 	/*figure out total number of constraints combining all the cpus (no clones here)*/
-	#ifdef _HAVE_MPI_
-		MPI_Reduce(&localconstraints,&numberofconstraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-		MPI_Bcast(&numberofconstraints,1,MPI_INT,0,IssmComm::GetComm());
-	#else
-		numberofconstraints=localconstraints;
-	#endif
+	ISSM_MPI_Reduce(&localconstraints,&numberofconstraints,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&numberofconstraints,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 
 	return numberofconstraints;
Index: /issm/trunk-jpl/src/c/classes/Elements/Elements.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Elements.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/classes/Elements/Elements.cpp	(revision 15838)
@@ -114,13 +114,11 @@
 
 	/*Synchronize across cluster, so as to not end up with different sizes for each patch on each cpu: */
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&numvertices,&max_numvertices,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&max_numvertices,1,MPI_INT,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&numvertices,&max_numvertices,1,ISSM_MPI_INT,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&max_numvertices,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 	numvertices=max_numvertices;
 
-	MPI_Reduce (&numnodes,&max_numnodes,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&max_numnodes,1,MPI_INT,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&numnodes,&max_numnodes,1,ISSM_MPI_INT,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&max_numnodes,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 	numnodes=max_numnodes;
-	#endif
 
 	/*Ok, initialize Patch object: */
@@ -186,11 +184,7 @@
 
 		/*Get rank of first cpu that has results*/
-		#ifdef _HAVE_MPI_
 		if(this->Size()) rank=my_rank;
 		else rank=num_procs;
-		MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,IssmComm::GetComm());
-		#else
-		minrank=my_rank;
-		#endif
+		ISSM_MPI_Allreduce (&rank,&minrank,1,ISSM_MPI_INT,ISSM_MPI_MIN,IssmComm::GetComm());
 
 		/*see what the first element of this partition has in stock (this is common to all partitions)*/
@@ -200,11 +194,8 @@
 			element->ListResultsInfo(&resultsenums,&resultssizes,&resultstimes,&resultssteps,&numberofresults);
 		}
-		#ifdef _HAVE_MPI_
-		MPI_Bcast(&numberofresults,1,MPI_DOUBLE,minrank,IssmComm::GetComm());
-		#endif
+		ISSM_MPI_Bcast(&numberofresults,1,ISSM_MPI_DOUBLE,minrank,IssmComm::GetComm());
 
 		/*Get out if there is no results. Otherwise broadcast info*/
 		if(!numberofresults) return;
-		#ifdef _HAVE_MPI_
 		if(my_rank!=minrank){
 			resultsenums=xNew<int>(numberofresults);
@@ -213,9 +204,8 @@
 			resultssteps=xNew<int>(numberofresults);
 		}
-		MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank,IssmComm::GetComm());
-		MPI_Bcast(resultssizes,numberofresults,MPI_INT,minrank,IssmComm::GetComm());
-		MPI_Bcast(resultstimes,numberofresults,MPI_DOUBLE,minrank,IssmComm::GetComm());
-		MPI_Bcast(resultssteps,numberofresults,MPI_INT,minrank,IssmComm::GetComm());
-		#endif
+		ISSM_MPI_Bcast(resultsenums,numberofresults,ISSM_MPI_INT,minrank,IssmComm::GetComm());
+		ISSM_MPI_Bcast(resultssizes,numberofresults,ISSM_MPI_INT,minrank,IssmComm::GetComm());
+		ISSM_MPI_Bcast(resultstimes,numberofresults,ISSM_MPI_DOUBLE,minrank,IssmComm::GetComm());
+		ISSM_MPI_Bcast(resultssteps,numberofresults,ISSM_MPI_INT,minrank,IssmComm::GetComm());
 
 		/*Loop over all results and get nodal vector*/
@@ -299,8 +289,6 @@
 
 	/*Grab max of all cpus: */
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
+	ISSM_MPI_Allreduce((void*)&max,(void*)&allmax,1,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
 	max=allmax;
-	#endif
 
 	return max;
@@ -314,9 +302,5 @@
 
 	local_nelem=this->Size();
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)&local_nelem,(void*)&numberofelements,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
-	#else
-	numberofelements=local_nelem;
-	#endif
+	ISSM_MPI_Allreduce ( (void*)&local_nelem,(void*)&numberofelements,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
 
 	return numberofelements;
Index: /issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 15838)
@@ -569,7 +569,5 @@
 
 	/*sum over all cpus*/
-#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)connectivity_clone,(void*)all_connectivity_clone,numnodes,MPI_INT,MPI_SUM,IssmComm::GetComm());
-#endif
+	ISSM_MPI_Allreduce((void*)connectivity_clone,(void*)all_connectivity_clone,numnodes,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
 	xDelete<int>(connectivity_clone);
 
@@ -965,9 +963,7 @@
 
 	/*Figure out minimum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce (&min_dt,&node_min_dt,1,MPI_DOUBLE,MPI_MIN,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_min_dt,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&min_dt,&node_min_dt,1,ISSM_MPI_DOUBLE,ISSM_MPI_MIN,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_min_dt,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	min_dt=node_min_dt;
-#endif
 
 	/*Assign output pointers:*/
@@ -1018,8 +1014,6 @@
 	}
 
-#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)&mass_flux,(void*)&all_mass_flux,1,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
+	ISSM_MPI_Allreduce ( (void*)&mass_flux,(void*)&all_mass_flux,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
 	mass_flux=all_mass_flux;
-#endif
 
 	/*Free ressources:*/
@@ -1052,9 +1046,7 @@
 
 	/*Figure out maximum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&maxabsvx,&node_maxabsvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_maxabsvx,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&maxabsvx,&node_maxabsvx,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_maxabsvx,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	maxabsvx=node_maxabsvx;
-#endif
 
 	/*Assign output pointers:*/
@@ -1078,9 +1070,7 @@
 
 	/*Figure out maximum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&maxabsvy,&node_maxabsvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_maxabsvy,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&maxabsvy,&node_maxabsvy,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_maxabsvy,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	maxabsvy=node_maxabsvy;
-#endif
 
 	/*Assign output pointers:*/
@@ -1104,9 +1094,7 @@
 
 	/*Figure out maximum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&maxabsvz,&node_maxabsvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_maxabsvz,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&maxabsvz,&node_maxabsvz,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_maxabsvz,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	maxabsvz=node_maxabsvz;
-#endif
 
 	/*Assign output pointers:*/
@@ -1130,9 +1118,7 @@
 
 	/*Figure out maximum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&maxvel,&node_maxvel,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_maxvel,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&maxvel,&node_maxvel,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_maxvel,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	maxvel=node_maxvel;
-#endif
 
 	/*Assign output pointers:*/
@@ -1156,9 +1142,7 @@
 
 	/*Figure out maximum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&maxvx,&node_maxvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_maxvx,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&maxvx,&node_maxvx,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_maxvx,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	maxvx=node_maxvx;
-#endif
 
 	/*Assign output pointers:*/
@@ -1182,9 +1166,7 @@
 
 	/*Figure out maximum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&maxvy,&node_maxvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_maxvy,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&maxvy,&node_maxvy,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_maxvy,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	maxvy=node_maxvy;
-#endif
 
 	/*Assign output pointers:*/
@@ -1208,9 +1190,7 @@
 
 	/*Figure out maximum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&maxvz,&node_maxvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_maxvz,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&maxvz,&node_maxvz,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_maxvz,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	maxvz=node_maxvz;
-#endif
 
 	/*Assign output pointers:*/
@@ -1234,9 +1214,7 @@
 
 	/*Figure out minimum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&minvel,&node_minvel,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_minvel,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&minvel,&node_minvel,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_minvel,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	minvel=node_minvel;
-#endif
 
 	/*Assign output pointers:*/
@@ -1260,9 +1238,7 @@
 
 	/*Figure out minimum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&minvx,&node_minvx,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_minvx,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&minvx,&node_minvx,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_minvx,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	minvx=node_minvx;
-#endif
 
 	/*Assign output pointers:*/
@@ -1286,9 +1262,7 @@
 
 	/*Figure out minimum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&minvy,&node_minvy,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_minvy,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&minvy,&node_minvy,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_minvy,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	minvy=node_minvy;
-#endif
 
 	/*Assign output pointers:*/
@@ -1312,9 +1286,7 @@
 
 	/*Figure out minimum across the cluster: */
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&minvz,&node_minvz,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_minvz,1,MPI_DOUBLE,0,IssmComm::GetComm());   
+	ISSM_MPI_Reduce(&minvz,&node_minvz,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_minvz,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());   
 	minvz=node_minvz;
-#endif
 
 	/*Assign output pointers:*/
@@ -1331,10 +1303,6 @@
 		local_smb+=element->TotalSmb();
 	}
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&local_smb,&total_smb,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&total_smb,1,MPI_DOUBLE,0,IssmComm::GetComm());
-#else
-	total_smb=local_smb;
-#endif
+	ISSM_MPI_Reduce(&local_smb,&total_smb,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&total_smb,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 
 	/*Assign output pointers: */
@@ -1351,10 +1319,6 @@
 		local_ice_volume+=element->IceVolume();
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Reduce(&local_ice_volume,&total_ice_volume,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&total_ice_volume,1,MPI_DOUBLE,0,IssmComm::GetComm());
-	#else
-	total_ice_volume=local_ice_volume;
-	#endif
+	ISSM_MPI_Reduce(&local_ice_volume,&total_ice_volume,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&total_ice_volume,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 
 	/*Assign output pointers: */
@@ -1386,8 +1350,6 @@
 
 	/*Broadcast whether we found the element: */
-#ifdef _HAVE_MPI_
-	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
+	ISSM_MPI_Allreduce ( &found,&sumfound,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
 	if(!sumfound)_error_("could not find material with id" << index << " to compute ElementResponse");
-#endif
 
 	/*Ok, we found the element, compute responseocity: */
@@ -1397,8 +1359,6 @@
 
 	/*Broadcast and plug into response: */
-#ifdef _HAVE_MPI_
-	MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
-	MPI_Bcast(&response,1,MPI_DOUBLE,cpu_found,IssmComm::GetComm()); 
-#endif
+	ISSM_MPI_Allreduce ( &cpu_found,&cpu_found,1,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
+	ISSM_MPI_Bcast(&response,1,ISSM_MPI_DOUBLE,cpu_found,IssmComm::GetComm()); 
 
 	/*Assign output pointers: */
@@ -1417,9 +1377,7 @@
 		J+=element->BalancethicknessMisfit(weight_index);
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
@@ -1444,9 +1402,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
@@ -1653,10 +1609,8 @@
 	}
 	xDelete<IssmDouble>(serial_active);
-	#ifdef _HAVE_MPI_
 	int sum_counter;
-	MPI_Reduce(&counter,&sum_counter,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&sum_counter,1,MPI_INT,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce(&counter,&sum_counter,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&sum_counter,1,ISSM_MPI_INT,0,IssmComm::GetComm());                
 	counter=sum_counter;
-	#endif
 	if(VerboseSolution()) _printf0_("   Number of active nodes in EPL layer: "<< counter <<"\n");
 
Index: /issm/trunk-jpl/src/c/classes/IndependentObject.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/IndependentObject.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/classes/IndependentObject.cpp	(revision 15838)
@@ -111,7 +111,5 @@
 		scalar<<=pscalar;
 
-		#ifdef _HAVE_MPI_
-		MPI_Bcast(&scalar,1,MPI_DOUBLE,0,IssmComm::GetComm()); 
-		#endif
+		ISSM_MPI_Bcast(&scalar,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 
 
 		/*Ok, we are almost done. scalar is now an independent variable. We don't want this variable to be fetched again in the 
@@ -145,14 +143,10 @@
 			if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
 		}
-		#ifdef _HAVE_MPI_
-		MPI_Bcast(&M,1,MPI_INT,0,IssmComm::GetComm()); 
-		#endif
+		ISSM_MPI_Bcast(&M,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 		if(my_rank==0){  
 			if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 		}
-		#ifdef _HAVE_MPI_
-		MPI_Bcast(&N,1,MPI_INT,0,IssmComm::GetComm()); 
-		#endif
+		ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 		/*Now allocate matrix: */
@@ -168,7 +162,5 @@
 				for (int i=0;i<M*N;++i) matrix[i]<<=buffer[i];  /*we use the <<= ADOLC overloaded operator to declare the independency*/
 			}
-			#ifdef _HAVE_MPI_
-			MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,IssmComm::GetComm()); 
-			#endif
+			ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 
 
 			xDelete<IssmPDouble>(buffer);
Index: /issm/trunk-jpl/src/c/classes/IoModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 15838)
@@ -343,7 +343,5 @@
 				/*Ok, we have reached the end of the file. break: */
 				record_code=0; //0 means bailout
-				#ifdef _HAVE_MPI_
-				MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm());  /*tell others cpus we are bailing: */
-				#endif
+				ISSM_MPI_Bcast(&record_code,1,ISSM_MPI_INT,0,IssmComm::GetComm());  /*tell others cpus we are bailing: */
 				break;
 			}
@@ -354,12 +352,10 @@
 				if(fread(&record_code  ,sizeof(int),1,this->fid)!=1) _error_("Cound not read record_code");
 
-				#ifdef _HAVE_MPI_
 				/*Tell other cpus what we are doing: */
-				MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm());  /*tell other cpus what we are going to do: */
+				ISSM_MPI_Bcast(&record_code,1,ISSM_MPI_INT,0,IssmComm::GetComm());  /*tell other cpus what we are going to do: */
 
 				/*Tell other cpus the name of the data, then branch according to the data type: */
-				MPI_Bcast(&record_enum,1,MPI_INT,0,IssmComm::GetComm());  
-				MPI_Bcast(&record_length,1,MPI_INT,0,IssmComm::GetComm());  
-				#endif
+				ISSM_MPI_Bcast(&record_enum,1,ISSM_MPI_INT,0,IssmComm::GetComm());  
+				ISSM_MPI_Bcast(&record_length,1,ISSM_MPI_INT,0,IssmComm::GetComm());  
 
 				switch(record_code){
@@ -367,7 +363,5 @@
 						/*Read the boolean and broadcast it to other cpus:*/
 						if(fread(&booleanint,sizeof(int),1,this->fid)!=1) _error_("could not read boolean ");
-						#ifdef _HAVE_MPI_
-						MPI_Bcast(&booleanint,1,MPI_INT,0,IssmComm::GetComm()); 
-						#endif
+						ISSM_MPI_Bcast(&booleanint,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 						/*create BoolParam: */
@@ -378,7 +372,5 @@
 						/*Read the integer and broadcast it to other cpus:*/
 						if(fread(&integer,sizeof(int),1,this->fid)!=1) _error_("could not read integer ");
-						#ifdef _HAVE_MPI_
-						MPI_Bcast(&integer,1,MPI_INT,0,IssmComm::GetComm()); 
-						#endif
+						ISSM_MPI_Bcast(&integer,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 						/*create IntParam: */
@@ -395,7 +387,5 @@
 						else{
 							if(fread(&pscalar,sizeof(IssmPDouble),1,this->fid)!=1) _error_("could not read scalar ");
-							#ifdef _HAVE_MPI_
-							MPI_Bcast(&pscalar,1,MPI_DOUBLE,0,IssmComm::GetComm()); 
-							#endif
+							ISSM_MPI_Bcast(&pscalar,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 
 							scalar=reCast<IssmDouble>(pscalar);
 						}
@@ -408,7 +398,5 @@
 						/*We have to read a string from disk. First read the dimensions of the string, then the string: */
 						if(fread(&string_size,sizeof(int),1,this->fid)!=1) _error_("could not read length of string ");
-						#ifdef _HAVE_MPI_
-						MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 
-						#endif
+						ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 						if(string_size){
@@ -418,7 +406,5 @@
 							/*Read string, then broadcast: */
 							if(fread(string,string_size*sizeof(char),1,this->fid)!=1)_error_(" could not read string ");
-							#ifdef _HAVE_MPI_
-							MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 
-							#endif
+							ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 
 						}
 						else{
@@ -474,18 +460,17 @@
 		}
 	} //}}}
-	#ifdef _HAVE_MPI_
 	else{ //cpu ~0 {{{
 		for(;;){ //wait on cpu 0
-			MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm());  /*get from cpu 0 what we are going to do: */
+			ISSM_MPI_Bcast(&record_code,1,ISSM_MPI_INT,0,IssmComm::GetComm());  /*get from cpu 0 what we are going to do: */
 			if(record_code==0){
 				break; //we are done, break from the loop
 			}
 			else{
-				MPI_Bcast(&record_enum,1,MPI_INT,0,IssmComm::GetComm());   //get from cpu 0 name of the data
-				MPI_Bcast(&record_length,1,MPI_INT,0,IssmComm::GetComm());  
+				ISSM_MPI_Bcast(&record_enum,1,ISSM_MPI_INT,0,IssmComm::GetComm());   //get from cpu 0 name of the data
+				ISSM_MPI_Bcast(&record_length,1,ISSM_MPI_INT,0,IssmComm::GetComm());  
 				switch(record_code){
 				case 1: 
 					/*boolean. get it from cpu 0 */
-					MPI_Bcast(&booleanint,1,MPI_INT,0,IssmComm::GetComm()); 
+					ISSM_MPI_Bcast(&booleanint,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 					/*create BoolParam: */
@@ -495,5 +480,5 @@
 				case 2:
 					/*integer. get it from cpu 0 */
-					MPI_Bcast(&integer,1,MPI_INT,0,IssmComm::GetComm()); 
+					ISSM_MPI_Bcast(&integer,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 					/*create IntParam: */
@@ -503,5 +488,5 @@
 				case 3:
 					/*scalar. get it from cpu 0 */
-					MPI_Bcast(&scalar,1,MPI_DOUBLE,0,IssmComm::GetComm()); 
+					ISSM_MPI_Bcast(&scalar,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 
 
 					/*create DoubleParam: */
@@ -510,5 +495,5 @@
 					break;
 				case 4: 
-					MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 
+					ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 					if(string_size){
 						string=xNew<char>((string_size+1));
@@ -516,5 +501,5 @@
 
 						/*Read string from cpu 0: */
-						MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 
+						ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 
 					}
 					else{
@@ -543,5 +528,4 @@
 		}
 	} //}}}
-	#endif
 }
 /*}}}*/
@@ -567,7 +551,5 @@
 		if(fread(&booleanint,sizeof(int),1,fid)!=1) _error_("could not read boolean ");
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&booleanint,1,MPI_INT,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&booleanint,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	/*cast to bool: */
@@ -599,7 +581,5 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&integer,1,MPI_INT,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&integer,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	/*Assign output pointers: */
@@ -628,7 +608,5 @@
 		if(fread(&scalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar ");
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&scalar,1,MPI_DOUBLE,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&scalar,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 
 
 	/*Assign output pointers: */
@@ -662,7 +640,5 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	/*Now allocate string: */
@@ -675,7 +651,5 @@
 			if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string ");
 		}
-		#ifdef _HAVE_MPI_
-		MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 
-		#endif
+		ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 
 	}
 	else{
@@ -716,14 +690,10 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&M,1,MPI_INT,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&M,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	if(my_rank==0){  
 		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&N,1,MPI_INT,0,IssmComm::GetComm());
-	#endif
+	ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 
 	/*Now allocate matrix: */
@@ -736,7 +706,5 @@
 		}
 
-		#ifdef _HAVE_MPI_
-		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,IssmComm::GetComm()); 
-		#endif
+		ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 
 	}
 
@@ -787,14 +755,10 @@
 		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&M,1,MPI_INT,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&M,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	if(my_rank==0){  
 		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&N,1,MPI_INT,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	/*Now allocate matrix: */
@@ -806,7 +770,5 @@
 			if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix ");
 		}
-		#ifdef _HAVE_MPI_
-		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,IssmComm::GetComm()); 
-		#endif
+		ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 
 
 		_assert_(this->independents);
@@ -857,7 +819,5 @@
 		if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_("could not read length of string array");
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&numstrings,1,MPI_INT,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&numstrings,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	/*Now allocate string array: */
@@ -872,7 +832,5 @@
 				if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string ");
 			}
-			#ifdef _HAVE_MPI_
-			MPI_Bcast(&string_size,1,MPI_INT,0,IssmComm::GetComm()); 
-			#endif
+			ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 			if(string_size){
 				string=xNew<char>((string_size+1));
@@ -883,7 +841,5 @@
 					if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string ");
 				}
-				#ifdef _HAVE_MPI_
-				MPI_Bcast(string,string_size,MPI_CHAR,0,IssmComm::GetComm()); 
-				#endif
+				ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm()); 
 			}
 			else{
@@ -930,7 +886,5 @@
 		if(fread(&numrecords,sizeof(int),1,fid)!=1) _error_("could not read number of records in matrix array ");
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&numrecords,1,MPI_INT,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&numrecords,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	if(numrecords){
@@ -953,14 +907,10 @@
 				if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows in " << i << "th matrix of matrix array");
 			}
-			#ifdef _HAVE_MPI_
-			MPI_Bcast(&M,1,MPI_INT,0,IssmComm::GetComm()); 
-			#endif
+			ISSM_MPI_Bcast(&M,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 			if(my_rank==0){  
 				if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns in " << i << "th matrix of matrix array");
 			}
-			#ifdef _HAVE_MPI_
-			MPI_Bcast(&N,1,MPI_INT,0,IssmComm::GetComm()); 
-			#endif
+			ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 			/*Now allocate matrix: */
@@ -973,7 +923,5 @@
 				}
 
-				#ifdef _HAVE_MPI_
-				MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,IssmComm::GetComm()); 
-				#endif
+				ISSM_MPI_Bcast(matrix,M*N,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 
 				matrices[i]=xNew<IssmDouble>(M*N);
 				for (int j=0;j<M*N;++j) {matrices[i][j]=matrix[j];}
@@ -1307,7 +1255,5 @@
 	}
 	/*Broadcast code and vector type: */
-#ifdef _HAVE_MPI_
-	MPI_Bcast(&lastindex,1,MPI_INT,0,IssmComm::GetComm()); 
-#endif
+	ISSM_MPI_Bcast(&lastindex,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	/*Assign output pointers:*/
@@ -1365,15 +1311,11 @@
 		}
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&found,1,MPI_INT,0,IssmComm::GetComm()); 
+	ISSM_MPI_Bcast(&found,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 	if(!found)_error_("could not find data with name " << EnumToStringx(data_enum) << " in binary file");
-	#endif
 
 	/*Broadcast code and vector type: */
-	#ifdef _HAVE_MPI_
-	MPI_Bcast(&record_code,1,MPI_INT,0,IssmComm::GetComm()); 
-	MPI_Bcast(&vector_type,1,MPI_INT,0,IssmComm::GetComm()); 
-	if(record_code==5) MPI_Bcast(&vector_type,1,MPI_INT,0,IssmComm::GetComm()); 
-	#endif
+	ISSM_MPI_Bcast(&record_code,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
+	ISSM_MPI_Bcast(&vector_type,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
+	if(record_code==5) ISSM_MPI_Bcast(&vector_type,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 
 
 	/*Assign output pointers:*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Loads.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Loads.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/classes/Loads/Loads.cpp	(revision 15838)
@@ -67,8 +67,6 @@
 
 	/*Grab sum of all cpus: */
-#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)&ispenalty,(void*)&allispenalty,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
+	ISSM_MPI_Allreduce((void*)&ispenalty,(void*)&allispenalty,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
 	ispenalty=allispenalty;
-#endif
 
 	if(ispenalty)
@@ -96,8 +94,6 @@
 
 	/*Grab max of all cpus: */
-#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
+	ISSM_MPI_Allreduce((void*)&max,(void*)&allmax,1,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
 	max=allmax;
-#endif
 
 	return max;
@@ -114,10 +110,6 @@
 
 	/*figure out total number of loads combining all the cpus (no clones here)*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&numberofloads,1,MPI_INT,0,IssmComm::GetComm());
-	#else
-	numberofloads=localloads;
-	#endif
+	ISSM_MPI_Reduce(&localloads,&numberofloads,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&numberofloads,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 
 	return numberofloads;
@@ -140,10 +132,6 @@
 
 	/*figure out total number of loads combining all the cpus (no clones here)*/
-#ifdef _HAVE_MPI_
-	MPI_Reduce(&localloads,&numberofloads,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&numberofloads,1,MPI_INT,0,IssmComm::GetComm());
-#else
-	numberofloads=localloads;
-#endif
+	ISSM_MPI_Reduce(&localloads,&numberofloads,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&numberofloads,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 
 	return numberofloads;
Index: /issm/trunk-jpl/src/c/classes/Nodes.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Nodes.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/classes/Nodes.cpp	(revision 15838)
@@ -65,10 +65,6 @@
 	 * First: get number of dofs for each cpu*/
 	alldofcount=xNew<int>(num_procs);
-	#ifdef _HAVE_MPI_
-	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,IssmComm::GetComm());
-	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,IssmComm::GetComm());
-	#else
-	alldofcount[0]=dofcount;
-	#endif
+	ISSM_MPI_Gather(&dofcount,1,ISSM_MPI_INT,alldofcount,1,ISSM_MPI_INT,0,IssmComm::GetComm());
+	ISSM_MPI_Bcast(alldofcount,num_procs,ISSM_MPI_INT,0,IssmComm::GetComm());
 
 	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
@@ -102,9 +98,5 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,MPI_INT,MPI_MAX,IssmComm::GetComm());
-	#else
-	for(i=0;i<numnodes*maxdofspernode;i++)alltruedofs[i]=truedofs[i];
-	#endif
+	ISSM_MPI_Allreduce((void*)truedofs,(void*)alltruedofs,numnodes*maxdofspernode,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
 
 	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
@@ -147,9 +139,5 @@
 	 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 
 	 * order of cpu rank. This is also why we initialized this array to num_procs.*/
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)ranks,(void*)minranks,numnodes,MPI_INT,MPI_MIN,IssmComm::GetComm());
-	#else
-	for(i=0;i<numnodes;i++)minranks[i]=ranks[i];
-	#endif
+	ISSM_MPI_Allreduce((void*)ranks,(void*)minranks,numnodes,ISSM_MPI_INT,ISSM_MPI_MIN,IssmComm::GetComm());
 
 	/*Now go through all objects, and use minranks to flag which objects are cloned: */
@@ -192,8 +180,6 @@
 
 	/*Grab max of all cpus: */
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
+	ISSM_MPI_Allreduce((void*)&max,(void*)&allmax,1,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
 	max=allmax;
-	#endif
 
 	return max;
@@ -225,8 +211,6 @@
 
 	/*Grab max of all cpus: */
-#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)&max,(void*)&allmax,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
+	ISSM_MPI_Allreduce((void*)&max,(void*)&allmax,1,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
 	max=allmax;
-#endif
 
 	return max;
@@ -242,9 +226,5 @@
 
 	/*Gather from all cpus: */
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
-	#else
-	allnumdofs=numdofs;
-	#endif
+	ISSM_MPI_Allreduce ( (void*)&numdofs,(void*)&allnumdofs,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
 	return allnumdofs;
 }
@@ -290,9 +270,5 @@
 
 	/*Gather from all cpus: */
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)&numnodes,(void*)&allnumnodes,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
-	#else
-	allnumnodes=numnodes;
-	#endif
+	ISSM_MPI_Allreduce ( (void*)&numnodes,(void*)&allnumnodes,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
 
 	return allnumnodes;
@@ -320,9 +296,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&max_sid,&node_max_sid,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&node_max_sid,1,MPI_INT,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&max_sid,&node_max_sid,1,ISSM_MPI_INT,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&node_max_sid,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 	max_sid=node_max_sid;
-	#endif
 
 	/*sid starts at 0*/
Index: /issm/trunk-jpl/src/c/classes/Patch.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Patch.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/classes/Patch.cpp	(revision 15838)
@@ -111,7 +111,5 @@
 	int         node_numrows;
 	IssmDouble     *total_values  = NULL;
-	#ifdef _HAVE_MPI_
-	MPI_Status  status;
-	#endif
+	ISSM_MPI_Status  status;
 
 	/*recover my_rank:*/
@@ -120,10 +118,6 @@
 
 	/*First, figure out total number of rows combining all the cpus: */
-	#ifdef _HAVE_MPI_
-	MPI_Reduce(&this->numrows,&total_numrows,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&total_numrows,1,MPI_INT,0,IssmComm::GetComm());
-	#else
-	total_numrows=this->numrows;
-	#endif
+	ISSM_MPI_Reduce(&this->numrows,&total_numrows,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&total_numrows,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 
 	/*return if patch empty*/
@@ -141,17 +135,15 @@
 
 	/*Now, ask other nodes to send their values: */
-	#ifdef _HAVE_MPI_
 	for(int i=1;i<num_procs;i++){
 		if (my_rank==i){ 
-			MPI_Send(&this->numrows,1,MPI_INT,0,1,IssmComm::GetComm());   
-			if (this->numrows)MPI_Send(this->values,this->numrows*this->numcols,MPI_DOUBLE,0,1,IssmComm::GetComm()); 
+			ISSM_MPI_Send(&this->numrows,1,ISSM_MPI_INT,0,1,IssmComm::GetComm());   
+			if (this->numrows)ISSM_MPI_Send(this->values,this->numrows*this->numcols,ISSM_MPI_DOUBLE,0,1,IssmComm::GetComm()); 
 		}
 		if (my_rank==0){
-			MPI_Recv(&node_numrows,1,MPI_INT,i,1,IssmComm::GetComm(),&status); 
-			if (node_numrows)MPI_Recv(total_values+count,node_numrows*this->numcols,MPI_DOUBLE,i,1,IssmComm::GetComm(),&status);
+			ISSM_MPI_Recv(&node_numrows,1,ISSM_MPI_INT,i,1,IssmComm::GetComm(),&status); 
+			if (node_numrows)ISSM_MPI_Recv(total_values+count,node_numrows*this->numcols,ISSM_MPI_DOUBLE,i,1,IssmComm::GetComm(),&status);
 			count+=node_numrows*this->numcols;
 		}
 	}	
-	#endif
 
 	/*Now, node 0 has total_values, of size total_numrows*this->numcols. Update the fields in the patch, to reflect this new 
@@ -162,9 +154,7 @@
 		this->values=total_values;
 	}
-	#ifdef _HAVE_MPI_
 	else{
 		this->numrows=0;
 		xDelete<IssmDouble>(this->values);
 	}
-	#endif
 }/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Profiler.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Profiler.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/classes/Profiler.cpp	(revision 15838)
@@ -73,12 +73,10 @@
 	 *in the execution: */
 	if(!dontmpisync){
-		#ifdef _HAVE_MPI_
-		MPI_Barrier(IssmComm::GetComm()); 
-		#endif
+		ISSM_MPI_Barrier(IssmComm::GetComm()); 
 	}
 
 	/*Capture time: */
 	#ifdef _HAVE_MPI_
-	t=MPI_Wtime();
+	t=ISSM_MPI_Wtime();
 	#else
 	t=(IssmPDouble)clock();
Index: /issm/trunk-jpl/src/c/classes/Vertices.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Vertices.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/classes/Vertices.cpp	(revision 15838)
@@ -64,10 +64,6 @@
 	 * First: get number of pids for each cpu*/
 	allpidcount=xNew<int>(num_procs);
-	#ifdef _HAVE_MPI_
-	MPI_Gather(&pidcount,1,MPI_INT,allpidcount,1,MPI_INT,0,IssmComm::GetComm());
-	MPI_Bcast(allpidcount,num_procs,MPI_INT,0,IssmComm::GetComm());
-	#else
-	allpidcount[0]=pidcount;
-	#endif
+	ISSM_MPI_Gather(&pidcount,1,ISSM_MPI_INT,allpidcount,1,ISSM_MPI_INT,0,IssmComm::GetComm());
+	ISSM_MPI_Bcast(allpidcount,num_procs,ISSM_MPI_INT,0,IssmComm::GetComm());
 
 	/* Every cpu should start its own pid count at the end of the pidcount from cpu-1*/
@@ -92,9 +88,5 @@
 		vertex->ShowTruePids(truepids);
 	}
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce((void*)truepids,(void*)alltruepids,numberofobjects,MPI_INT,MPI_MAX,IssmComm::GetComm());
-	#else
-	for(i=0;i<numberofobjects;i++)alltruepids[i]=truepids[i];
-	#endif
+	ISSM_MPI_Allreduce((void*)truepids,(void*)alltruepids,numberofobjects,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
 
 	/* Now every cpu knows the true pids of everyone else that is not a clone*/
@@ -135,9 +127,5 @@
 	 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 
 	 * order of cpu rank. This is also why we initialized this array to num_procs.*/
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofobjects,MPI_INT,MPI_MIN,IssmComm::GetComm());
-	#else
-	for(i=0;i<numberofobjects;i++)minranks[i]=ranks[i];
-	#endif
+	ISSM_MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofobjects,ISSM_MPI_INT,ISSM_MPI_MIN,IssmComm::GetComm());
 
 	/*Now go through all objects, and use minranks to flag which objects are cloned: */
@@ -167,9 +155,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&max_sid,&vertex_max_sid,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&vertex_max_sid,1,MPI_INT,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&max_sid,&vertex_max_sid,1,ISSM_MPI_INT,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&vertex_max_sid,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 	max_sid=vertex_max_sid;
-	#endif
 
 	/*sid starts at 0*/
Index: /issm/trunk-jpl/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp	(revision 15838)
@@ -28,9 +28,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce (&found,&mpi_found,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&mpi_found,1,ISSM_MPI_INT,0,IssmComm::GetComm());                
 	found=mpi_found;
-	#endif
 
 	return found;
@@ -90,9 +88,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&sum_num_unstable_constraints,1,ISSM_MPI_INT,0,IssmComm::GetComm());                
 	num_unstable_constraints=sum_num_unstable_constraints;
-	#endif
 
 	/*Assign output pointers: */
@@ -130,9 +126,7 @@
 
 	/*Is there just one found? that would mean we have frozen! : */
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce (&found,&mpi_found,1,ISSM_MPI_INT,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&mpi_found,1,ISSM_MPI_INT,0,IssmComm::GetComm());                
 	found=mpi_found;
-	#endif
 
 	return found;
@@ -190,9 +184,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce (&found,&mpi_found,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&mpi_found,1,ISSM_MPI_INT,0,IssmComm::GetComm());                
 	found=mpi_found;
-	#endif
 
 	return found;
@@ -222,9 +214,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce (&found,&mpi_found,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&mpi_found,1,ISSM_MPI_INT,0,IssmComm::GetComm());                
 	found=mpi_found;
-	#endif
 
 	if (found){
@@ -282,9 +272,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&sum_num_unstable_constraints,1,ISSM_MPI_INT,0,IssmComm::GetComm());                
 	num_unstable_constraints=sum_num_unstable_constraints;
-	#endif
 
 	/*Assign output pointers: */
@@ -322,9 +310,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&max_penetration,&mpi_max_penetration,1,MPI_DOUBLE,MPI_MAX,0,IssmComm::GetComm() );
-	MPI_Bcast(&mpi_max_penetration,1,MPI_DOUBLE,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce (&max_penetration,&mpi_max_penetration,1,ISSM_MPI_DOUBLE,ISSM_MPI_MAX,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&mpi_max_penetration,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());                
 	max_penetration=mpi_max_penetration;
-	#endif
 
 	/*feed max_penetration to inputs: */
@@ -361,9 +347,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&sum_num_unstable_constraints,1,ISSM_MPI_INT,0,IssmComm::GetComm());                
 	num_unstable_constraints=sum_num_unstable_constraints;
-	#endif
 
 	return num_unstable_constraints;
Index: /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalConstraintsState.cpp	(revision 15838)
@@ -36,9 +36,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&sum_num_unstable_constraints,1,MPI_INT,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce (&num_unstable_constraints,&sum_num_unstable_constraints,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&sum_num_unstable_constraints,1,ISSM_MPI_INT,0,IssmComm::GetComm());                
 	num_unstable_constraints=sum_num_unstable_constraints;
-	#endif
 
 	/*Have we converged? : */
Index: /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/ConstraintsStatex/ThermalIsPresent.cpp	(revision 15838)
@@ -28,9 +28,7 @@
 	}
 
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&mpi_found,1,MPI_INT,0,IssmComm::GetComm());                
+	ISSM_MPI_Reduce (&found,&mpi_found,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&mpi_found,1,ISSM_MPI_INT,0,IssmComm::GetComm());                
 	found=mpi_found;
-	#endif
 
 	return found;
Index: /issm/trunk-jpl/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp	(revision 15838)
@@ -25,9 +25,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 15838)
@@ -160,10 +160,6 @@
 		vec_nodes_on_floatingice->Assemble();
 
-		#ifdef _HAVE_MPI_
-		MPI_Allreduce(&local_nflipped,&nflipped,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
+		ISSM_MPI_Allreduce(&local_nflipped,&nflipped,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
 		if(VerboseConvergence()) _printf0_("   Additional number of vertices allowed to unground: " << nflipped << "\n");
-		#else
-		nflipped=local_nflipped;
-		#endif
 
 		/*Avoid leaks: */
Index: /issm/trunk-jpl/src/c/modules/Krigingx/pKrigingx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/Krigingx/pKrigingx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/Krigingx/pKrigingx.cpp	(revision 15838)
@@ -37,5 +37,5 @@
 
 	/*Get some Options*/
-	MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
+	ISSM_MPI_Barrier(ISSM_MPI_COMM_WORLD); start=ISSM_MPI_Wtime();
 	options->Get(&radius,"searchradius",0.);
 	options->Get(&mindata,"mindata",1);
@@ -43,7 +43,7 @@
 
 	/*Process observation dataset*/
-	MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
+	ISSM_MPI_Barrier(ISSM_MPI_COMM_WORLD); start_init=ISSM_MPI_Wtime();
 	observations=new Observations(obs_list,obs_x,obs_y,obs_length,options);
-	MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
+	ISSM_MPI_Barrier(ISSM_MPI_COMM_WORLD); finish_init=ISSM_MPI_Wtime();
 
 	/*Allocate output*/
@@ -54,5 +54,5 @@
 	options->Get(&output,"output",(char*)"prediction");
 
-	MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
+	ISSM_MPI_Barrier(ISSM_MPI_COMM_WORLD); start_core=ISSM_MPI_Wtime( );
 	if(strcmp(output,"quadtree")==0){
 		observations->QuadtreeColoring(predictions,x_interp,y_interp,n_interp);
@@ -73,12 +73,10 @@
 		_printf0_("      interpolation progress: "<<fixed<<setw(6)<<setprecision(4)<<100.<<"%  \n");
 
-#ifdef _HAVE_MPI_
 		double *sumpredictions =xNew<double>(n_interp);
 		double *sumerror       =xNew<double>(n_interp);
-		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
-		MPI_Allreduce(error,sumerror,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
+		ISSM_MPI_Allreduce(predictions,sumpredictions,n_interp,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
+		ISSM_MPI_Allreduce(error,sumerror,n_interp,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
 		xDelete<double>(error); error=sumerror;
 		xDelete<double>(predictions); predictions=sumpredictions;
-#endif
 	}
 	else if(strcmp(output,"v4")==0){
@@ -91,9 +89,7 @@
 		_printf0_("      interpolation progress: "<<fixed<<setw(6)<<setprecision(4)<<100.<<"%  \n");
 
-#ifdef _HAVE_MPI_
 		double *sumpredictions =xNew<double>(n_interp);
-		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
+		ISSM_MPI_Allreduce(predictions,sumpredictions,n_interp,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
 		xDelete<double>(predictions); predictions=sumpredictions;
-#endif
 	}
 	else if(strcmp(output,"nearestneighbor")==0){
@@ -106,9 +102,7 @@
 		_printf0_("      interpolation progress: "<<fixed<<setw(6)<<setprecision(4)<<100.<<"%  \n");
 
-#ifdef _HAVE_MPI_
 		double *sumpredictions =xNew<double>(n_interp);
-		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
+		ISSM_MPI_Allreduce(predictions,sumpredictions,n_interp,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
 		xDelete<double>(predictions); predictions=sumpredictions;
-#endif
 	}
 	else if(strcmp(output,"idw")==0){
@@ -123,14 +117,12 @@
 		_printf0_("      interpolation progress: "<<fixed<<setw(6)<<setprecision(4)<<100.<<"%  \n");
 
-#ifdef _HAVE_MPI_
 		double *sumpredictions =xNew<double>(n_interp);
-		MPI_Allreduce(predictions,sumpredictions,n_interp,MPI_DOUBLE,MPI_SUM,IssmComm::GetComm());
+		ISSM_MPI_Allreduce(predictions,sumpredictions,n_interp,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,IssmComm::GetComm());
 		xDelete<double>(predictions); predictions=sumpredictions;
-#endif
 	}
 	else{
 		_error_("output '" << output << "' not supported yet");
 	}
-	MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
+	ISSM_MPI_Barrier(ISSM_MPI_COMM_WORLD); finish_core=ISSM_MPI_Wtime( );
 
 	/*clean-up and Assign output pointer*/
@@ -141,5 +133,5 @@
 	*perror       = error;
 
-	MPI_Barrier(MPI_COMM_WORLD); finish=MPI_Wtime( );
+	ISSM_MPI_Barrier(ISSM_MPI_COMM_WORLD); finish=ISSM_MPI_Wtime( );
 	_printf0_("\n   " << setw(34) << left << "Observation fitering elapsed time: " << finish_init-start_init << " seconds  \n\n");
 	_printf0_("   " << setw(34) << left << "Kriging prediction elapsed time: " << finish_core-start_core << " seconds  \n\n");
Index: /issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp	(revision 15838)
@@ -37,16 +37,10 @@
 
 	/*Broadcast whether we found the element: */
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
+	ISSM_MPI_Allreduce ( &found,&sumfound,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
 	if(!sumfound)_error_("could not find element with vertex with id" << index << " to compute nodal value " << EnumToStringx(natureofdataenum));
-	#endif
 
 	/*Broadcast and plug into response: */
-	#ifdef _HAVE_MPI_
-	MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,IssmComm::GetComm());
-	MPI_Bcast(&value,1,MPI_DOUBLE,cpu_found,IssmComm::GetComm()); 
-	#else
-	value=cpu_found;
-	#endif
+	ISSM_MPI_Allreduce ( &cpu_found,&cpu_found,1,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
+	ISSM_MPI_Bcast(&value,1,ISSM_MPI_DOUBLE,cpu_found,IssmComm::GetComm()); 
 
 	*pnodalvalue=value;
Index: /issm/trunk-jpl/src/c/modules/ParseToolkitsOptionsx/ParseToolkitsOptionsx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ParseToolkitsOptionsx/ParseToolkitsOptionsx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/ParseToolkitsOptionsx/ParseToolkitsOptionsx.cpp	(revision 15838)
@@ -95,12 +95,10 @@
 
 	/*Ok, broadcast to other cpus: */
- 	#ifdef _HAVE_MPI_
-	MPI_Bcast(&numanalyses,1,MPI_INT,0,IssmComm::GetComm());
+	ISSM_MPI_Bcast(&numanalyses,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 	if(my_rank!=0){
 		analyses=xNew<IssmDouble>(numanalyses);
 		strings=xNew<char*>(numanalyses);
 	}
-	MPI_Bcast(analyses,numanalyses,MPI_DOUBLE,0,IssmComm::GetComm());
-	#endif
+	ISSM_MPI_Bcast(analyses,numanalyses,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	for(i=0;i<numanalyses;i++){
 		char* string=strings[i];
@@ -109,10 +107,8 @@
 		}
 		if(my_rank==0)stringlength=(strlen(string)+1)*sizeof(char);
-		#ifdef _HAVE_MPI_
-		MPI_Bcast(&stringlength,1,MPI_INT,0,IssmComm::GetComm());
+		ISSM_MPI_Bcast(&stringlength,1,ISSM_MPI_INT,0,IssmComm::GetComm());
 		if(my_rank!=0)string=xNew<char>(stringlength);
-		MPI_Bcast(string,stringlength,MPI_CHAR,0,IssmComm::GetComm());
+		ISSM_MPI_Bcast(string,stringlength,ISSM_MPI_CHAR,0,IssmComm::GetComm());
 		if(my_rank!=0)strings[i]=string;
-		#endif
 	}
 
Index: /issm/trunk-jpl/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp	(revision 15838)
@@ -25,9 +25,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp	(revision 15838)
@@ -25,9 +25,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/SurfaceAreax/SurfaceAreax.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	(revision 15838)
@@ -26,9 +26,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
- 	MPI_Reduce (&S,&S_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&S_sum,1,MPI_DOUBLE,0,IssmComm::GetComm()); 
+ 	ISSM_MPI_Reduce (&S,&S_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&S_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm()); 
 	S=S_sum;
-	#endif
 
 	/*add surface area to element inputs:*/
Index: /issm/trunk-jpl/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp	(revision 15838)
@@ -29,9 +29,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp	(revision 15838)
@@ -25,9 +25,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp	(revision 15838)
@@ -25,9 +25,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp	(revision 15838)
@@ -25,9 +25,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp	(revision 15838)
@@ -25,9 +25,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp	(revision 15838)
@@ -25,9 +25,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp	(revision 15838)
@@ -25,9 +25,7 @@
 
 	/*Sum all J from all cpus of the cluster:*/
-	#ifdef _HAVE_MPI_
-	MPI_Reduce (&J,&J_sum,1,MPI_DOUBLE,MPI_SUM,0,IssmComm::GetComm() );
-	MPI_Bcast(&J_sum,1,MPI_DOUBLE,0,IssmComm::GetComm());
+	ISSM_MPI_Reduce (&J,&J_sum,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
+	ISSM_MPI_Bcast(&J_sum,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 	J=J_sum;
-	#endif
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/shared/Numerics/types.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Numerics/types.h	(revision 15837)
+++ /issm/trunk-jpl/src/c/shared/Numerics/types.h	(revision 15838)
@@ -17,8 +17,6 @@
 #if ISSM_USE_64BIT_INDICES == 1
 typedef long long IssmInt;
-//#define MPIU_INT MPI_LONG_LONG_INT already define in petsc
 #else
 typedef int IssmInt;
-//#define MPIU_INT MPI_INT already defined in petsc
 #endif  
 
Index: /issm/trunk-jpl/src/c/shared/io/Comm/Comm.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/io/Comm/Comm.h	(revision 15837)
+++ /issm/trunk-jpl/src/c/shared/io/Comm/Comm.h	(revision 15838)
@@ -6,5 +6,5 @@
 #define _IO_COMM_H_
 
-#include "./CommDef.h"
+#include "../../../toolkits/mpi/issmmpi.h"
 #include "./IssmComm.h"
 
Index: sm/trunk-jpl/src/c/shared/io/Comm/CommDef.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/io/Comm/CommDef.h	(revision 15837)
+++ 	(revision )
@@ -1,16 +1,0 @@
-/*\file CommDef.h
- *\brief: defined communicator typedefs
- */
-
-#ifndef _IO_COMMDEF_H_
-#define _IO_COMMDEF_H_
-
-/*Define communicator: */
-#ifdef _HAVE_MPI_
-	#include <mpi.h>
-	typedef MPI_Comm COMM;
-#else
-	typedef int COMM;
-#endif
-
-#endif
Index: /issm/trunk-jpl/src/c/shared/io/Comm/IssmComm.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/io/Comm/IssmComm.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/shared/io/Comm/IssmComm.cpp	(revision 15838)
@@ -13,5 +13,5 @@
 #include "../../Exceptions/exceptions.h"
 
-void IssmComm::SetComm(COMM incomm){ /*{{{*/
+void IssmComm::SetComm(ISSM_MPI_COMM incomm){ /*{{{*/
 
 	/*A comm is provided, we are running in parallel (this is not a module)*/
@@ -28,5 +28,5 @@
 
 }/*}}}*/
-COMM IssmComm::GetComm(){  /*{{{*/
+ISSM_MPI_COMM IssmComm::GetComm(){  /*{{{*/
 	if(!parallel) _error_("Cannot return comm in serial mode");
 	return comm;
@@ -39,7 +39,5 @@
 	if(!parallel) return my_rank;
 
-	#ifdef _HAVE_MPI_
-	MPI_Comm_rank(comm,&my_rank);
-	#endif
+	ISSM_MPI_Comm_rank(comm,&my_rank);
 
 	return my_rank;
@@ -53,7 +51,5 @@
 	if(!parallel) return size;
 
-	#ifdef _HAVE_MPI_
-	MPI_Comm_size(comm,&size);
-	#endif
+	ISSM_MPI_Comm_size(comm,&size);
 
 	return size;
Index: /issm/trunk-jpl/src/c/shared/io/Comm/IssmComm.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/io/Comm/IssmComm.h	(revision 15837)
+++ /issm/trunk-jpl/src/c/shared/io/Comm/IssmComm.h	(revision 15838)
@@ -21,11 +21,11 @@
 
 	private:
-		static COMM comm;
+		static ISSM_MPI_Comm comm;
 		static bool parallel;
 
 	public:
-		static void SetComm(COMM incomm);
+		static void SetComm(ISSM_MPI_COMM incomm);
 		static void SetComm(void);
-		static COMM GetComm(void);
+		static ISSM_MPI_COMM GetComm(void);
 		static int GetRank(void);
 		static int GetSize(void);
Index: /issm/trunk-jpl/src/c/shared/io/Disk/pfopen.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/io/Disk/pfopen.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/shared/io/Disk/pfopen.cpp	(revision 15838)
@@ -39,7 +39,5 @@
 	for(int i=0;i<num_proc;i++){
 		if(my_rank==i) fid = fopen(filename,format);
-#ifdef _HAVE_MPI_
-		MPI_Barrier(IssmComm::GetComm());
-#endif
+		ISSM_MPI_Barrier(IssmComm::GetComm());
 	}
 	if(fid==NULL) _error_("could not open file " << filename << " for binary reading or writing");
Index: /issm/trunk-jpl/src/c/toolkits/issm/Bucket.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/Bucket.h	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/issm/Bucket.h	(revision 15838)
@@ -13,5 +13,5 @@
 /*}}}*/
 
-/*how many MPI_Isend requests does it take to transfer the contents of a bucket to another cpu?*/
+/*how many ISSM_MPI_Isend requests does it take to transfer the contents of a bucket to another cpu?*/
 #define MATRIXBUCKETSIZEOFREQUESTS 7 
 #define VECTORBUCKETSIZEOFREQUESTS 5 
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiDenseMat.h	(revision 15838)
@@ -153,5 +153,5 @@
 					}
 				}
-				MPI_Barrier(IssmComm::GetComm());
+				ISSM_MPI_Barrier(IssmComm::GetComm());
 			}
 
@@ -187,5 +187,5 @@
 			/*some communicator info: */
 			num_procs=IssmComm::GetSize();
-			MPI_Comm comm=IssmComm::GetComm();
+			ISSM_MPI_Comm comm=IssmComm::GetComm();
 
 			/*First, make a vector of size M, which for each row between 0 and M-1, tells which cpu this row belongs to: */
@@ -215,5 +215,5 @@
 			numvalues_fromcpu   = xNew<int>(num_procs);
 			for(i=0;i<num_procs;i++){
-				MPI_Scatter(numvalues_forcpu,1,MPI_INT,numvalues_fromcpu+i,1,MPI_INT,i,comm);
+				ISSM_MPI_Scatter(numvalues_forcpu,1,ISSM_MPI_INT,numvalues_fromcpu+i,1,ISSM_MPI_INT,i,comm);
 			}
 
@@ -241,6 +241,6 @@
 			/*Scatter values around: {{{*/
 			/*Now, to scatter values across the cluster, we need sendcnts and displs. Our sendbufs have been built by BucketsBuildScatterBuffers, with a stride given 
-			 * by numvalues_forcpu. Get this ready to go before starting the scatter itslef. For reference, here is the MPI_Scatterv prototype: 
-			 * int MPI_Scatterv( void *sendbuf, int *sendcnts, int *displs, MPI_Datatype sendtype, void *recvbuf, int recvcnt, MPI_Datatype recvtype, int root, MPI_Comm comm) :*/
+			 * by numvalues_forcpu. Get this ready to go before starting the scatter itslef. For reference, here is the ISSM_MPI_Scatterv prototype: 
+			 * int ISSM_MPI_Scatterv( void *sendbuf, int *sendcnts, int *displs, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSM_MPI_Datatype recvtype, int root, ISSM_MPI_Comm comm) :*/
 			sendcnts=xNew<int>(num_procs);
 			displs=xNew<int>(num_procs);
@@ -253,8 +253,8 @@
 
 			for(i=0;i<num_procs;i++){
-				MPI_Scatterv( row_indices_forcpu, sendcnts, displs, MPI_INT, row_indices_fromcpu[i], numvalues_fromcpu[i], MPI_INT, i, comm);
-				MPI_Scatterv( col_indices_forcpu, sendcnts, displs, MPI_INT, col_indices_fromcpu[i], numvalues_fromcpu[i], MPI_INT, i, comm);
-				MPI_Scatterv( values_forcpu, sendcnts, displs, MPI_DOUBLE, values_fromcpu[i], numvalues_fromcpu[i], MPI_DOUBLE, i, comm);
-				MPI_Scatterv( modes_forcpu, sendcnts, displs, MPI_INT, modes_fromcpu[i], numvalues_fromcpu[i], MPI_INT, i, comm);
+				ISSM_MPI_Scatterv( row_indices_forcpu, sendcnts, displs, ISSM_MPI_INT, row_indices_fromcpu[i], numvalues_fromcpu[i], ISSM_MPI_INT, i, comm);
+				ISSM_MPI_Scatterv( col_indices_forcpu, sendcnts, displs, ISSM_MPI_INT, col_indices_fromcpu[i], numvalues_fromcpu[i], ISSM_MPI_INT, i, comm);
+				ISSM_MPI_Scatterv( values_forcpu, sendcnts, displs, ISSM_MPI_DOUBLE, values_fromcpu[i], numvalues_fromcpu[i], ISSM_MPI_DOUBLE, i, comm);
+				ISSM_MPI_Scatterv( modes_forcpu, sendcnts, displs, ISSM_MPI_INT, modes_fromcpu[i], numvalues_fromcpu[i], ISSM_MPI_INT, i, comm);
 			}
 			/*}}}*/
@@ -330,6 +330,6 @@
 						local_norm=max(local_norm,absolute);
 					}
-					MPI_Reduce(&local_norm, &norm, 1, MPI_DOUBLE, MPI_MAX, 0, IssmComm::GetComm());
-					MPI_Bcast(&norm,1,MPI_DOUBLE,0,IssmComm::GetComm());
+					ISSM_MPI_Reduce(&local_norm, &norm, 1, ISSM_MPI_DOUBLE, ISSM_MPI_MAX, 0, IssmComm::GetComm());
+					ISSM_MPI_Bcast(&norm,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 					return norm;
 					break; 
@@ -341,6 +341,6 @@
 						}
 					}
-					MPI_Reduce(&local_norm, &norm, 1, MPI_DOUBLE, MPI_SUM, 0, IssmComm::GetComm());
-					MPI_Bcast(&norm,1,MPI_DOUBLE,0,IssmComm::GetComm());
+					ISSM_MPI_Reduce(&local_norm, &norm, 1, ISSM_MPI_DOUBLE, ISSM_MPI_SUM, 0, IssmComm::GetComm());
+					ISSM_MPI_Bcast(&norm,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 					return sqrt(norm);
 					break; 
Index: /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h	(revision 15838)
@@ -21,7 +21,5 @@
 #include "../../shared/MemOps/MemOps.h"
 #include "../../shared/io/io.h"
-#ifdef _HAVE_MPI_
-#include "../mpi/mpiincludes.h"
-#endif
+#include "../mpi/issmmpi.h"
 #include <math.h>
 
@@ -138,5 +136,5 @@
 					_printf_("\n");
 				}
-				MPI_Barrier(IssmComm::GetComm());
+				ISSM_MPI_Barrier(IssmComm::GetComm());
 			}
 		}
@@ -171,5 +169,5 @@
 			/*some communicator info: */
 			num_procs=IssmComm::GetSize();
-			MPI_Comm comm=IssmComm::GetComm();
+			ISSM_MPI_Comm comm=IssmComm::GetComm();
 
 			/*First, make a vector of size M, which for each row between 0 and M-1, tells which cpu this row belongs to: */
@@ -199,5 +197,5 @@
 			numvalues_fromcpu   = xNew<int>(num_procs);
 			for(i=0;i<num_procs;i++){
-				MPI_Scatter(numvalues_forcpu,1,MPI_INT,numvalues_fromcpu+i,1,MPI_INT,i,comm);
+				ISSM_MPI_Scatter(numvalues_forcpu,1,ISSM_MPI_INT,numvalues_fromcpu+i,1,ISSM_MPI_INT,i,comm);
 			}
 
@@ -222,6 +220,6 @@
 			/*Scatter values around: {{{*/
 			/*Now, to scatter values across the cluster, we need sendcnts and displs. Our sendbufs have been built by BucketsBuildScatterBuffers, with a stride given 
-			 * by numvalues_forcpu. Get this ready to go before starting the scatter itslef. For reference, here is the MPI_Scatterv prototype: 
-			 * int MPI_Scatterv( void *sendbuf, int *sendcnts, int *displs, MPI_Datatype sendtype, void *recvbuf, int recvcnt, MPI_Datatype recvtype, int root, MPI_Comm comm) :*/
+			 * by numvalues_forcpu. Get this ready to go before starting the scatter itslef. For reference, here is the ISSM_MPI_Scatterv prototype: 
+			 * int ISSM_MPI_Scatterv( void *sendbuf, int *sendcnts, int *displs, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSM_MPI_Datatype recvtype, int root, ISSM_MPI_Comm comm) :*/
 			sendcnts=xNew<int>(num_procs);
 			displs=xNew<int>(num_procs);
@@ -234,7 +232,7 @@
 
 			for(i=0;i<num_procs;i++){
-				MPI_Scatterv( row_indices_forcpu, sendcnts, displs, MPI_INT, row_indices_fromcpu[i], numvalues_fromcpu[i], MPI_INT, i, comm);
-				MPI_Scatterv( values_forcpu, sendcnts, displs, MPI_DOUBLE, values_fromcpu[i], numvalues_fromcpu[i], MPI_DOUBLE, i, comm);
-				MPI_Scatterv( modes_forcpu, sendcnts, displs, MPI_INT, modes_fromcpu[i], numvalues_fromcpu[i], MPI_INT, i, comm);
+				ISSM_MPI_Scatterv( row_indices_forcpu, sendcnts, displs, ISSM_MPI_INT, row_indices_fromcpu[i], numvalues_fromcpu[i], ISSM_MPI_INT, i, comm);
+				ISSM_MPI_Scatterv( values_forcpu, sendcnts, displs, ISSM_MPI_DOUBLE, values_fromcpu[i], numvalues_fromcpu[i], ISSM_MPI_DOUBLE, i, comm);
+				ISSM_MPI_Scatterv( modes_forcpu, sendcnts, displs, ISSM_MPI_INT, modes_fromcpu[i], numvalues_fromcpu[i], ISSM_MPI_INT, i, comm);
 			}
 			/*}}}*/
@@ -378,8 +376,8 @@
 
 			/*communicator info: */
-			MPI_Comm comm;
+			ISSM_MPI_Comm comm;
 			int num_procs;
 
-			/*MPI_Allgatherv info: */
+			/*ISSM_MPI_Allgatherv info: */
 			int  lower_row,upper_row;
 			int* recvcounts=NULL;
@@ -399,5 +397,5 @@
 
 			/*recvcounts:*/
-			MPI_Allgather(&this->m,1,MPI_INT,recvcounts,1,MPI_INT,comm);
+			ISSM_MPI_Allgather(&this->m,1,ISSM_MPI_INT,recvcounts,1,ISSM_MPI_INT,comm);
 
 			/*get lower_row: */
@@ -405,8 +403,8 @@
 
 			/*displs: */
-			MPI_Allgather(&lower_row,1,MPI_INT,displs,1,MPI_INT,comm);
+			ISSM_MPI_Allgather(&lower_row,1,ISSM_MPI_INT,displs,1,ISSM_MPI_INT,comm);
 
 			/*All gather:*/
-			MPI_Allgatherv(this->vector, this->m, MPI_DOUBLE, buffer, recvcounts, displs, MPI_DOUBLE,comm);
+			ISSM_MPI_Allgatherv(this->vector, this->m, ISSM_MPI_DOUBLE, buffer, recvcounts, displs, ISSM_MPI_DOUBLE,comm);
 
 			/*free ressources: */
@@ -445,6 +443,6 @@
 					//local_norm=0; for(i=0;i<this->m;i++)local_norm=max(local_norm,fabs(this->vector[i]));
 					local_norm=0; for(i=0;i<this->m;i++)local_norm=max(local_norm,this->vector[i]);
-					MPI_Reduce(&local_norm, &norm, 1, MPI_DOUBLE, MPI_MAX, 0, IssmComm::GetComm());
-					MPI_Bcast(&norm,1,MPI_DOUBLE,0,IssmComm::GetComm());
+					ISSM_MPI_Reduce(&local_norm, &norm, 1, ISSM_MPI_DOUBLE, ISSM_MPI_MAX, 0, IssmComm::GetComm());
+					ISSM_MPI_Bcast(&norm,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 					return norm;
 					break;
@@ -452,6 +450,6 @@
 					local_norm=0; 
 					for(i=0;i<this->m;i++)local_norm+=pow(this->vector[i],2);
-					MPI_Reduce(&local_norm, &norm, 1, MPI_DOUBLE, MPI_SUM, 0, IssmComm::GetComm());
-					MPI_Bcast(&norm,1,MPI_DOUBLE,0,IssmComm::GetComm());
+					ISSM_MPI_Reduce(&local_norm, &norm, 1, ISSM_MPI_DOUBLE, ISSM_MPI_SUM, 0, IssmComm::GetComm());
+					ISSM_MPI_Bcast(&norm,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 					return sqrt(norm);
 					break;
@@ -484,9 +482,7 @@
 			for(i=0;i<this->m;i++)local_dot+=this->vector[i]*input->vector[i];
 
-			#ifdef _HAVE_MPI_
-			/*MPI_SUM all the dots across the cluster: */
-			MPI_Reduce(&local_dot, &dot, 1, MPI_DOUBLE, MPI_SUM, 0, IssmComm::GetComm());
-			MPI_Bcast(&dot,1,MPI_DOUBLE,0,IssmComm::GetComm());
-			#endif
+			/*ISSM_MPI_SUM all the dots across the cluster: */
+			ISSM_MPI_Reduce(&local_dot, &dot, 1, ISSM_MPI_DOUBLE, ISSM_MPI_SUM, 0, IssmComm::GetComm());
+			ISSM_MPI_Bcast(&dot,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
 
 			return dot;
Index: /issm/trunk-jpl/src/c/toolkits/mpi/commops/DetermineGlobalSize.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mpi/commops/DetermineGlobalSize.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/mpi/commops/DetermineGlobalSize.cpp	(revision 15838)
@@ -13,6 +13,6 @@
 	int  global_size;
 
-	MPI_Reduce(&local_size, &global_size, 1, MPI_INT, MPI_SUM, 0, comm);
-	MPI_Bcast(&global_size,1,MPI_INT,0,comm);
+	ISSM_MPI_Reduce(&local_size, &global_size, 1, ISSM_MPI_INT, ISSM_MPI_SUM, 0, comm);
+	ISSM_MPI_Bcast(&global_size,1,ISSM_MPI_INT,0,comm);
 
 	return global_size;
Index: /issm/trunk-jpl/src/c/toolkits/mpi/commops/DetermineLocalSize.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mpi/commops/DetermineLocalSize.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/mpi/commops/DetermineLocalSize.cpp	(revision 15838)
@@ -22,6 +22,6 @@
 
 	/*recover my_rank*/
-	MPI_Comm_rank(comm,&my_rank);
-	MPI_Comm_size(comm,&num_procs);
+	ISSM_MPI_Comm_rank(comm,&my_rank);
+	ISSM_MPI_Comm_size(comm,&num_procs);
 
 	/* TODO replace the following with ->
Index: /issm/trunk-jpl/src/c/toolkits/mpi/commops/DetermineRowRankFromLocalSize.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mpi/commops/DetermineRowRankFromLocalSize.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/mpi/commops/DetermineRowRankFromLocalSize.cpp	(revision 15838)
@@ -21,6 +21,6 @@
 	int* RowRank=NULL;
 
-	MPI_Comm_rank(comm,&my_rank);
-	MPI_Comm_size(comm,&num_procs);
+	ISSM_MPI_Comm_rank(comm,&my_rank);
+	ISSM_MPI_Comm_size(comm,&num_procs);
 
 	/*allocate: */
@@ -29,5 +29,5 @@
 	/*Gather all local_size values into alllocalsizes, for all cpus*/
 	int* alllocalsizes=xNew<int>(num_procs);
-	MPI_Allgather(&localsize,1,MPI_INT,alllocalsizes,1,MPI_INT,comm);
+	ISSM_MPI_Allgather(&localsize,1,ISSM_MPI_INT,alllocalsizes,1,ISSM_MPI_INT,comm);
 
 	/*From all localsizes, get lower row and upper row*/
Index: /issm/trunk-jpl/src/c/toolkits/mpi/commops/GetOwnershipBoundariesFromRange.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mpi/commops/GetOwnershipBoundariesFromRange.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/mpi/commops/GetOwnershipBoundariesFromRange.cpp	(revision 15838)
@@ -21,6 +21,6 @@
 
 	/*recover my_rank and num_procs:*/
-	MPI_Comm_size(comm,&num_procs);
-	MPI_Comm_rank(comm,&my_rank);
+	ISSM_MPI_Comm_size(comm,&num_procs);
+	ISSM_MPI_Comm_rank(comm,&my_rank);
 
 	/*output: */
@@ -29,5 +29,5 @@
 	/*Gather all range values into allranges, for all nodes*/
 	int* allranges=xNew<int>(num_procs);
-	MPI_Allgather(&range,1,MPI_INT,allranges,1,MPI_INT,comm);
+	ISSM_MPI_Allgather(&range,1,ISSM_MPI_INT,allranges,1,ISSM_MPI_INT,comm);
 
 	/*From all ranges, get lower row and upper row*/
Index: /issm/trunk-jpl/src/c/toolkits/mumps/MpiDenseMumpsSolve.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/mumps/MpiDenseMumpsSolve.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/mumps/MpiDenseMumpsSolve.cpp	(revision 15838)
@@ -14,5 +14,5 @@
 #include "../../shared/Exceptions/exceptions.h"
 #include "../../shared/io/Comm/Comm.h"
-#include "../mpi/patches/mpipatches.h"
+#include "../mpi/issmmpi.h"
 
 /*Mumps header files: */
@@ -28,5 +28,5 @@
 	/*Variables: {{{*/
 
-	MPI_Comm   comm;
+	ISSM_MPI_Comm   comm;
 	int        my_rank;
 	int        num_procs;
@@ -84,6 +84,6 @@
 	}
 
-	MPI_Reduce(&local_nnz,&nnz,1,MPI_INT,MPI_SUM,0,comm);
-	MPI_Bcast(&nnz,1,MPI_INT,0,comm);
+	ISSM_MPI_Reduce(&local_nnz,&nnz,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,comm);
+	ISSM_MPI_Bcast(&nnz,1,ISSM_MPI_INT,0,comm);
 	id.nz=nnz;
 	id.nz_loc=local_nnz;
@@ -113,5 +113,5 @@
 	id.a_loc=a_loc;
 
-	/*Deal with right hand side. We need to MPI_Gather it onto cpu 0: */
+	/*Deal with right hand side. We need to ISSM_MPI_Gather it onto cpu 0: */
 	rhs=xNew<IssmPDouble>(pf_M);
 
@@ -120,11 +120,11 @@
 
 	/*recvcounts:*/
-	MPI_Allgather(&pf_m,1,MPI_INT,recvcounts,1,MPI_INT,comm);
+	ISSM_MPI_Allgather(&pf_m,1,ISSM_MPI_INT,recvcounts,1,ISSM_MPI_INT,comm);
 
 	/*displs: */
-	MPI_Allgather(&lower_row,1,MPI_INT,displs,1,MPI_INT,comm);
+	ISSM_MPI_Allgather(&lower_row,1,ISSM_MPI_INT,displs,1,ISSM_MPI_INT,comm);
 
 	/*Gather:*/
-	MPI_Gatherv(pf, pf_m, MPI_DOUBLE, rhs, recvcounts, displs, MPI_DOUBLE,0,comm);
+	ISSM_MPI_Gatherv(pf, pf_m, ISSM_MPI_DOUBLE, rhs, recvcounts, displs, ISSM_MPI_DOUBLE,0,comm);
 	id.rhs=rhs;
 	id.nrhs=1;
@@ -137,5 +137,5 @@
 	/*}}}*/
 	/*Now scatter from cpu 0 to all other cpus: {{{*/
-	MPI_Scatterv( rhs, recvcounts, displs, MPI_DOUBLE, uf, uf_m, MPI_DOUBLE, 0, comm); 
+	ISSM_MPI_Scatterv( rhs, recvcounts, displs, ISSM_MPI_DOUBLE, uf, uf_m, ISSM_MPI_DOUBLE, 0, comm); 
 
 	/*}}}*/
Index: /issm/trunk-jpl/src/c/toolkits/petsc/patches/MatMultPatch.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/MatMultPatch.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/petsc/patches/MatMultPatch.cpp	(revision 15838)
@@ -14,5 +14,5 @@
 #include <petscksp.h>
 
-#include "../../mpi/mpiincludes.h"
+#include "../../mpi/issmmpi.h"
 #include "../../../shared/shared.h"
 
@@ -54,5 +54,5 @@
 
 	/*recover num_procs:*/
-	MPI_Comm_size(comm,&num_procs);
+	ISSM_MPI_Comm_size(comm,&num_procs);
 
 	MatGetLocalSize(A,&local_m,&local_n);;
@@ -62,6 +62,6 @@
 
 	/*synchronize result: */
-	MPI_Reduce (&result,&sumresult,1,MPI_INT,MPI_SUM,0,comm );
-	MPI_Bcast(&sumresult,1,MPI_INT,0,comm);                
+	ISSM_MPI_Reduce (&result,&sumresult,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,comm );
+	ISSM_MPI_Bcast(&sumresult,1,ISSM_MPI_INT,0,comm);                
 	if (sumresult!=num_procs){
 		result=0;
Index: /issm/trunk-jpl/src/c/toolkits/petsc/patches/MatToSerial.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/MatToSerial.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/petsc/patches/MatToSerial.cpp	(revision 15838)
@@ -22,5 +22,5 @@
 	int range;
 	int M,N; //size of matrix
-	MPI_Status status;
+	ISSM_MPI_Status status;
 	int* idxm=NULL;
 	int* idxn=NULL; 
@@ -29,6 +29,6 @@
 
 	/*recover my_rank and num_procs:*/
-	MPI_Comm_size(comm,&num_procs);
-	MPI_Comm_rank(comm,&my_rank);
+	ISSM_MPI_Comm_size(comm,&num_procs);
+	ISSM_MPI_Comm_rank(comm,&my_rank);
 
 	/*Output*/
@@ -69,10 +69,10 @@
 			buffer[1]=lower_row;
 			buffer[2]=range;
-			MPI_Send(buffer,3,MPI_INT,0,1,comm);   
-			if (range)MPI_Send(local_matrix,N*range,MPI_DOUBLE,0,1,comm); 
+			ISSM_MPI_Send(buffer,3,ISSM_MPI_INT,0,1,comm);   
+			if (range)ISSM_MPI_Send(local_matrix,N*range,ISSM_MPI_DOUBLE,0,1,comm); 
 		}
 		if (my_rank==0){
-			MPI_Recv(buffer,3,MPI_INT,i,1,comm,&status); 
-			if (buffer[2])MPI_Recv(outmatrix+(buffer[1]*N),N*buffer[2],MPI_DOUBLE,i,1,comm,&status);
+			ISSM_MPI_Recv(buffer,3,ISSM_MPI_INT,i,1,comm,&status); 
+			if (buffer[2])ISSM_MPI_Recv(outmatrix+(buffer[1]*N),N*buffer[2],ISSM_MPI_DOUBLE,i,1,comm,&status);
 		}
 	} 
Index: /issm/trunk-jpl/src/c/toolkits/petsc/patches/NewMat.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/petsc/patches/NewMat.cpp	(revision 15838)
@@ -15,7 +15,6 @@
 
 #include "./petscpatches.h"
-
 #include "../../../shared/shared.h"
-#include "../../mpi/patches/mpipatches.h"
+#include "../../mpi/issmmpi.h"
 
 /*NewMat(int M,int N){{{*/
Index: /issm/trunk-jpl/src/c/toolkits/petsc/patches/NewVec.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/NewVec.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/petsc/patches/NewVec.cpp	(revision 15838)
@@ -15,5 +15,5 @@
 
 #include "./petscpatches.h"
-#include "../../mpi/patches/mpipatches.h"
+#include "../../mpi/issmmpi.h"
 
 Vec NewVec(int size,COMM comm,bool fromlocalsize){
Index: /issm/trunk-jpl/src/c/toolkits/petsc/patches/VecToMPISerial.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/petsc/patches/VecToMPISerial.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/petsc/patches/VecToMPISerial.cpp	(revision 15838)
@@ -19,5 +19,5 @@
 
 	/*Petsc*/
-	MPI_Status status;
+	ISSM_MPI_Status status;
 	PetscInt lower_row,upper_row; 
 	int range;
@@ -35,6 +35,6 @@
 
 	/*recover my_rank and num_procs*/
-	MPI_Comm_size(comm,&num_procs);
-	MPI_Comm_rank(comm,&my_rank);
+	ISSM_MPI_Comm_size(comm,&num_procs);
+	ISSM_MPI_Comm_rank(comm,&my_rank);
 
 	VecGetSize(vector,&vector_size);
@@ -69,10 +69,10 @@
 			buffer[1]=lower_row;
 			buffer[2]=range;
-			MPI_Send(buffer,3,MPI_INT,0,1,comm);  
-			if (range)MPI_Send(local_vector,range,MPI_DOUBLE,0,1,comm); 
+			ISSM_MPI_Send(buffer,3,ISSM_MPI_INT,0,1,comm);  
+			if (range)ISSM_MPI_Send(local_vector,range,ISSM_MPI_DOUBLE,0,1,comm); 
 		}
 		if (my_rank==0){
-			MPI_Recv(buffer,3,MPI_INT,i,1,comm,&status); 
-			if (buffer[2])MPI_Recv(gathered_vector+buffer[1],buffer[2],MPI_DOUBLE,i,1,comm,&status);
+			ISSM_MPI_Recv(buffer,3,ISSM_MPI_INT,i,1,comm,&status); 
+			if (buffer[2])ISSM_MPI_Recv(gathered_vector+buffer[1],buffer[2],ISSM_MPI_DOUBLE,i,1,comm,&status);
 		}
 	}
@@ -84,5 +84,5 @@
 
 	/*Now, broadcast gathered_vector from node 0 to other nodes: */
-	MPI_Bcast(gathered_vector,vector_size,MPI_DOUBLE,0,comm);
+	ISSM_MPI_Bcast(gathered_vector,vector_size,ISSM_MPI_DOUBLE,0,comm);
 
 	/*Assign output pointers: */
Index: /issm/trunk-jpl/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp	(revision 15838)
@@ -12,5 +12,5 @@
 #include "../../scalapack/FortranMapping.h"
 
-void PlapackInvertMatrixLocalCleanup(PLA_Obj* pa,PLA_Template* ptempl,double** parrayA,int** pidxnA,MPI_Comm* pcomm_2d);
+void PlapackInvertMatrixLocalCleanup(PLA_Obj* pa,PLA_Template* ptempl,double** parrayA,int** pidxnA,ISSM_MPI_Comm* pcomm_2d);
 
 int PlapackInvertMatrix(Mat* A,Mat* inv_A,int status,int con,COMM comm){ 
@@ -27,6 +27,6 @@
 
 	/*Plapack: */
-	MPI_Datatype   datatype;
-	MPI_Comm       comm_2d;
+	ISSM_MPI_Datatype   datatype;
+	ISSM_MPI_Comm       comm_2d;
 	PLA_Obj a=NULL;
 	PLA_Template   templ;	
@@ -85,5 +85,5 @@
 
 	/* Set the datatype */
-	datatype = MPI_DOUBLE;
+	datatype = ISSM_MPI_DOUBLE;
 
 	/* Copy A into a*/
@@ -123,4 +123,4 @@
 	/*Finalize PLAPACK*/
 	PLA_Finalize();
-	MPI_Comm_free(&comm_2d);
+	ISSM_MPI_Comm_free(&comm_2d);
 }
Index: /issm/trunk-jpl/src/c/toolkits/toolkits.h
===================================================================
--- /issm/trunk-jpl/src/c/toolkits/toolkits.h	(revision 15837)
+++ /issm/trunk-jpl/src/c/toolkits/toolkits.h	(revision 15838)
@@ -16,7 +16,5 @@
 #endif
 
-#ifdef _HAVE_MPI_
-#include "./mpi/mpiincludes.h"
-#endif
+#include "./mpi/issmmpi.h"
 
 #ifdef _HAVE_METIS_
