Index: /issm/trunk-jpl/src/c/Container/Elements.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Elements.cpp	(revision 13593)
+++ /issm/trunk-jpl/src/c/Container/Elements.cpp	(revision 13594)
@@ -168,6 +168,6 @@
 	int i;
 	
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
+	int num_procs2;
 
 	Patch  *patch        = NULL;
@@ -184,4 +184,8 @@
 	int    rank;
 	int    minrank;
+	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
+	num_procs2=IssmComm::GetSize();
 
 	/*Recover parameters: */
@@ -196,13 +200,13 @@
 		/*Get rank of first cpu that has results*/
 		#ifdef _HAVE_MPI_
-		if(this->Size()) rank=my_rank;
-		else rank=num_procs;
+		if(this->Size()) rank=my_rank2;
+		else rank=num_procs2;
 		MPI_Allreduce (&rank,&minrank,1,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
 		#else
-		minrank=my_rank;
+		minrank=my_rank2;
 		#endif
 
 		/*see what the first element of this partition has in stock (this is common to all partitions)*/
-		if(my_rank==minrank){
+		if(my_rank2==minrank){
 			if(this->Size()==0) _error_("Cannot write results because there is no element??");
 			Element* element=(Element*)this->GetObjectByOffset(0);
@@ -216,5 +220,5 @@
 		if(!numberofresults) return;
 		#ifdef _HAVE_MPI_
-		if(my_rank!=minrank){
+		if(my_rank2!=minrank){
 			resultsenums=xNew<int>(numberofresults);
 			resultssizes=xNew<int>(numberofresults);
@@ -245,5 +249,5 @@
 			/*Serialize and add to results*/
 			vector_serial=vector->ToMPISerial();
-			if(my_rank==0){
+			if(my_rank2==0){
 				/*No need to add this vector for all cpus*/
 				#ifdef _HAVE_ADOLC_
Index: /issm/trunk-jpl/src/c/Container/Nodes.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Nodes.cpp	(revision 13593)
+++ /issm/trunk-jpl/src/c/Container/Nodes.cpp	(revision 13594)
@@ -56,6 +56,6 @@
 void  Nodes::DistributeDofs(int analysis_type,int setenum){
 
-	extern int num_procs;
-	extern int my_rank;
+	int num_procs2;
+	int my_rank2;
 
 	int  i;
@@ -66,4 +66,8 @@
 	int* alltruedofs=NULL;
 	int  numnodes=0;
+	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
+	num_procs2=IssmComm::GetSize();
 
 	/*some check: */
@@ -84,8 +88,8 @@
 	 * cpus by the total last dofs of the previus cpu, starting from 0.
 	 * First: get number of dofs for each cpu*/
-	alldofcount=xNew<int>(num_procs);
+	alldofcount=xNew<int>(num_procs2);
 	#ifdef _HAVE_MPI_
 	MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD);
-	MPI_Bcast(alldofcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Bcast(alldofcount,num_procs2,MPI_INT,0,MPI_COMM_WORLD);
 	#else
 	alldofcount[0]=dofcount;
@@ -94,6 +98,6 @@
 	/* Every cpu should start its own dof count at the end of the dofcount from cpu-1*/
 	dofcount=0;
-	if(my_rank!=0){
-		for(i=0;i<my_rank;i++){
+	if(my_rank2!=0){
+		for(i=0;i<my_rank2;i++){
 			dofcount+=alldofcount[i];
 		}
@@ -328,6 +332,9 @@
 void   Nodes::Ranks(int* ranks,int analysis_type){
 
-	extern int my_rank;
+	int my_rank2;
 	int        sid;
+	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
 
 	/*Go through nodes, and for each object, report it cpu: */
@@ -340,5 +347,5 @@
 			/*Plug rank into ranks, according to sid: */
 			sid=node->Sid();
-			ranks[sid]=my_rank; 
+			ranks[sid]=my_rank2; 
 		}
 	}
Index: /issm/trunk-jpl/src/c/Container/Vertices.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Vertices.cpp	(revision 13593)
+++ /issm/trunk-jpl/src/c/Container/Vertices.cpp	(revision 13594)
@@ -41,6 +41,6 @@
 void  Vertices::DistributePids(int numberofobjects){
 
-	extern int num_procs;
-	extern int my_rank;
+	int num_procs2;
+	int my_rank2;
 
 	int  i;
@@ -49,4 +49,8 @@
 	int *truepids    = NULL;
 	int *alltruepids = NULL;
+	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
+	num_procs2=IssmComm::GetSize();
 
 	/*Go through objects, and distribute pids locally, from 0 to numberofpidsperobject*/
@@ -60,8 +64,8 @@
 	 * cpus by the total last pids of the previus cpu, starting from 0.
 	 * First: get number of pids for each cpu*/
-	allpidcount=xNew<int>(num_procs);
+	allpidcount=xNew<int>(num_procs2);
 	#ifdef _HAVE_MPI_
 	MPI_Gather(&pidcount,1,MPI_INT,allpidcount,1,MPI_INT,0,MPI_COMM_WORLD);
-	MPI_Bcast(allpidcount,num_procs,MPI_INT,0,MPI_COMM_WORLD);
+	MPI_Bcast(allpidcount,num_procs2,MPI_INT,0,MPI_COMM_WORLD);
 	#else
 	allpidcount[0]=pidcount;
@@ -70,6 +74,6 @@
 	/* Every cpu should start its own pid count at the end of the pidcount from cpu-1*/
 	pidcount=0;
-	if(my_rank!=0){
-		for(i=0;i<my_rank;i++){
+	if(my_rank2!=0){
+		for(i=0;i<my_rank2;i++){
 			pidcount+=allpidcount[i];
 		}
@@ -111,8 +115,11 @@
 
 	int i;
-	extern int num_procs;
+	int num_procs2;
 
 	int* ranks=NULL;
 	int* minranks=NULL;
+	
+	/*recover num_procs2:*/
+	num_procs2=IssmComm::GetSize();
 
 	/*Allocate ranks: */
@@ -120,5 +127,5 @@
 	minranks=xNew<int>(numberofobjects);
 
-	for(i=0;i<numberofobjects;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit.
+	for(i=0;i<numberofobjects;i++)ranks[i]=num_procs2; //no cpu can have rank num_procs. This is the maximum limit.
 
 	/*Now go through all our objects and ask them to report to who they belong (which rank): */
@@ -177,6 +184,9 @@
 void   Vertices::Ranks(int* ranks){
 
-	extern int my_rank;
+	int my_rank2;
 	int        sid;
+	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
 
 	/*Go through a dataset, and for each object, report it cpu: */
@@ -185,6 +195,6 @@
 		Vertex* vertex=(Vertex*)this->GetObjectByOffset(i);
 		sid=vertex->Sid();
-		ranks[sid]=my_rank; 
-	}
-}
-/*}}}*/
+		ranks[sid]=my_rank2; 
+	}
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/IoModel.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 13593)
+++ /issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 13594)
@@ -104,12 +104,15 @@
 void  IoModel::CheckEnumSync(void){
 
-	extern int my_rank;
+	int my_rank2;
 	int record_enum = 0;
 
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
+
 	/*Check that some fields have been allocated*/
-	_assert_(this->fid || my_rank);
+	_assert_(this->fid || my_rank2);
 
 	/*Go find in the binary file, the position of the data we want to fetch: */
-	if(my_rank==0){ //cpu 0
+	if(my_rank2==0){ //cpu 0
 
 		/*First set FILE* position to the beginning of the file: */
@@ -296,6 +299,5 @@
 void  IoModel::FetchConstants(void){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
 	
 	/*record descriptions; */
@@ -312,10 +314,13 @@
 	int   string_size;
 
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
+
 	/*Check that some fields have been allocated*/
-	_assert_(this->fid || my_rank);
+	_assert_(this->fid || my_rank2);
 	_assert_(this->constants);
 
 	/*Go find in the binary file, the position of the data we want to fetch: */
-	if(my_rank==0){ //cpu 0{{{
+	if(my_rank2==0){ //cpu 0{{{
 	
 		/*First set FILE* position to the beginning of the file: */
@@ -535,6 +540,5 @@
 void  IoModel::FetchData(bool* pboolean,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
 	
 
@@ -543,4 +547,8 @@
 	int   code;
 	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
+
+	
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
@@ -549,5 +557,5 @@
 	
 	/*We have to read a boolean from disk. */
-	if(my_rank==0){  
+	if(my_rank2==0){  
 		if(fread(&booleanint,sizeof(int),1,fid)!=1) _error_("could not read boolean ");
 	}
@@ -565,6 +573,5 @@
 void  IoModel::FetchData(int* pinteger,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
 
 	/*output: */
@@ -572,4 +579,7 @@
 	int   code;
 	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
+	
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
@@ -578,5 +588,5 @@
 	
 	/*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */
-	if(my_rank==0){  
+	if(my_rank2==0){  
 		if(fread(&integer,sizeof(int),1,fid)!=1) _error_("could not read integer ");
 	}
@@ -594,6 +604,5 @@
 
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
 	
 
@@ -601,4 +610,7 @@
 	IssmPDouble   scalar;
 	int      code;
+	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
 
 	/*Set file pointer to beginning of the data: */
@@ -608,5 +620,5 @@
 	
 	/*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
-	if(my_rank==0){
+	if(my_rank2==0){
 		if(fread(&scalar,sizeof(IssmPDouble),1,fid)!=1)_error_("could not read scalar ");
 	}
@@ -623,6 +635,5 @@
 void  IoModel::FetchData(char** pstring,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
 	
 
@@ -631,4 +642,7 @@
 	int   string_size;
 	int code=0;
+	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
 
 	/*Set file pointer to beginning of the data: */
@@ -640,5 +654,5 @@
 	
 	/*We have to read a string from disk. First read the dimensions of the string, then the string: */
-	if(my_rank==0){  
+	if(my_rank2==0){  
 		if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string ");
 	}
@@ -654,5 +668,5 @@
 
 		/*Read string on node 0, then broadcast: */
-		if(my_rank==0){  
+		if(my_rank2==0){  
 			if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string ");
 		}
@@ -674,6 +688,5 @@
 void  IoModel::FetchData(int** pmatrix,int* pM,int* pN,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
 	int i,j;
 
@@ -684,5 +697,7 @@
 	int code=0;
 	int vector_type=0;
-
+	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
 
 	/*Set file pointer to beginning of the data: */
@@ -695,5 +710,5 @@
 	/*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
 	/*numberofelements: */
-	if(my_rank==0){  
+	if(my_rank2==0){  
 		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
 	}
@@ -703,5 +718,5 @@
 	#endif
 
-	if(my_rank==0){  
+	if(my_rank2==0){  
 		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 	}
@@ -715,5 +730,5 @@
 
 		/*Read matrix on node 0, then broadcast: */
-		if(my_rank==0){  
+		if(my_rank2==0){  
 			if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix ");
 		}
@@ -749,6 +764,5 @@
 void  IoModel::FetchData(IssmDouble** pmatrix,int* pM,int* pN,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
 
 	/*output: */
@@ -757,4 +771,7 @@
 	int code=0;
 	int vector_type=0;
+	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
 
 	/*Set file pointer to beginning of the data: */
@@ -766,5 +783,5 @@
 	/*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
 	/*numberofelements: */
-	if(my_rank==0){  
+	if(my_rank2==0){  
 		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
 	}
@@ -773,5 +790,5 @@
 	#endif
 
-	if(my_rank==0){  
+	if(my_rank2==0){  
 		if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix ");
 	}
@@ -785,5 +802,5 @@
 
 		/*Read matrix on node 0, then broadcast: */
-		if(my_rank==0){  
+		if(my_rank2==0){  
 			if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix ");
 		}
@@ -814,6 +831,5 @@
 void  IoModel::FetchData(char*** pstrings,int* pnumstrings,int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
 	
 	int i;
@@ -828,4 +844,7 @@
 	int   code;
 	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
+
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
@@ -834,5 +853,5 @@
 	
 	/*We have to read a bunch of strings from disk. First read the number of strings, and allocate: */
-	if(my_rank==0){  
+	if(my_rank2==0){  
 		if(fread(&numstrings,sizeof(int),1,fid)!=1) _error_("could not read length of string array");
 	}
@@ -849,5 +868,5 @@
 		for(i=0;i<numstrings;i++){
 			
-			if(my_rank==0){  
+			if(my_rank2==0){  
 				if(fread(&string_size,sizeof(int),1,fid)!=1) _error_("could not read length of string ");
 			}
@@ -860,5 +879,5 @@
 
 				/*Read string on node 0, then broadcast: */
-				if(my_rank==0){  
+				if(my_rank2==0){  
 					if(fread(string,string_size*sizeof(char),1,fid)!=1)_error_(" could not read string ");
 				}
@@ -886,6 +905,5 @@
 	int i;
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
 
 	/*output: */
@@ -900,4 +918,7 @@
 	int     code;
 	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
+
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
@@ -905,5 +926,5 @@
 	
 	/*Now fetch: */
-	if(my_rank==0){  
+	if(my_rank2==0){  
 		if(fread(&numrecords,sizeof(int),1,fid)!=1) _error_("could not read number of records in matrix array ");
 	}
@@ -928,5 +949,5 @@
 		for(i=0;i<numrecords;i++){
 
-			if(my_rank==0){  
+			if(my_rank2==0){  
 				if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows in " << i << "th matrix of matrix array");
 			}
@@ -935,5 +956,5 @@
 			#endif
 
-			if(my_rank==0){  
+			if(my_rank2==0){  
 				if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns in " << i << "th matrix of matrix array");
 			}
@@ -947,5 +968,5 @@
 
 				/*Read matrix on node 0, then broadcast: */
-				if(my_rank==0){  
+				if(my_rank2==0){  
 					if(fread(matrix,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix ");
 				}
@@ -976,11 +997,8 @@
 void  IoModel::FetchData(Option** poption,int index){
 
-	extern int my_rank;
-	extern int num_procs;
-
 	/*output: */
 	int     code;
 	char   *name        = NULL;
-
+	
 	/*First get option name*/
 	this->FetchData(&name,index);
@@ -1261,10 +1279,13 @@
 void IoModel::LastIndex(int *pindex){
 
-	extern int my_rank;
+	int my_rank2;
 	int        lastindex,index;
 	int        record_length;
+	
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
 
 	/*Go find in the binary file, the position of the data we want to fetch: */
-	if(my_rank==0){
+	if(my_rank2==0){
 
 		/*First set FILE* position to the beginning of the file: */
@@ -1297,6 +1318,5 @@
 FILE* IoModel::SetFilePointerToData(int* pcode,int* pvector_type, int data_enum){
 
-	extern int my_rank;
-	extern int num_procs;
+	int my_rank2;
 
 	int found         = 0;
@@ -1306,6 +1326,9 @@
 	int vector_type   = 0; //nodal or elementary
 
+	/*recover my_rank2:*/
+	my_rank2=IssmComm::GetRank();
+
 	/*Go find in the binary file, the position of the data we want to fetch: */
-	if(my_rank==0){
+	if(my_rank2==0){
 
 		/*First set FILE* position to the beginning of the file: */
Index: /issm/trunk-jpl/src/c/shared/Exceptions/Exceptions.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Exceptions/Exceptions.cpp	(revision 13593)
+++ /issm/trunk-jpl/src/c/shared/Exceptions/Exceptions.cpp	(revision 13594)
@@ -29,8 +29,13 @@
 
 ErrorException::~ErrorException() throw(){
-	extern int num_procs;
+	
+	int num_procs2;
+	
+	/*recover num_procs2:*/
+	num_procs2=IssmComm::GetSize();
+
 	/*We want the report only for matlab modules, otherwise we get twice the report
 	 * We assume that if num_procs==1, it is a module (FIXME)*/
-	if(num_procs==1) this->Report();
+	if(num_procs2==1) this->Report();
 }
 
@@ -40,6 +45,13 @@
 
 void ErrorException::Report() const{
-	extern int my_rank;
-	extern int num_procs;
+	
+	int my_rank2;
+	int num_procs2;
+	
+	/*recover my_rank2 and num_procs2:*/
+	my_rank2=IssmComm::GetRank();
+	num_procs2=IssmComm::GetSize();
+
+
 
 	if (function_name=="" || file_line==0){ //WINDOWS
@@ -47,11 +59,11 @@
 	}
 	else{
-		if(num_procs==1){
+		if(num_procs2==1){
 			_printLine_("\n??? Error using ==> " << file_name.c_str() << ":" << file_line);
 			_printLine_(function_name.c_str() << " error message: " << what() << "\n");
 		}
 		else{
-			_printLine_("\n[" << my_rank << "] ??? Error using ==> " << file_name.c_str() << ":" << file_line);
-			_printLine_("[" << my_rank << "] " << function_name.c_str() << " error message: " << what() << "\n");
+			_printLine_("\n[" << my_rank2<< "] ??? Error using ==> " << file_name.c_str() << ":" << file_line);
+			_printLine_("[" << my_rank2 << "] " << function_name.c_str() << " error message: " << what() << "\n");
 		}
 	}
