Index: /issm/trunk/src/c/ContourToMeshx/ContourToMeshx.cpp
===================================================================
--- /issm/trunk/src/c/ContourToMeshx/ContourToMeshx.cpp	(revision 1903)
+++ /issm/trunk/src/c/ContourToMeshx/ContourToMeshx.cpp	(revision 1904)
@@ -30,5 +30,5 @@
 	/*Loop through all contours: */
 	for (i=0;i<numcontours;i++){
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			printf("\nHandling contour %i/%i\n",i,numcontours);
 		#endif
Index: /issm/trunk/src/c/ContourToNodesx/ContourToNodesx.cpp
===================================================================
--- /issm/trunk/src/c/ContourToNodesx/ContourToNodesx.cpp	(revision 1903)
+++ /issm/trunk/src/c/ContourToNodesx/ContourToNodesx.cpp	(revision 1904)
@@ -26,5 +26,5 @@
 	/*Loop through all contours: */
 	for (i=0;i<numcontours;i++){
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			printf("\nHandling contour %i/%i\n",i,numcontours);
 		#endif
Index: /issm/trunk/src/c/DataSet/DataSet.cpp
===================================================================
--- /issm/trunk/src/c/DataSet/DataSet.cpp	(revision 1903)
+++ /issm/trunk/src/c/DataSet/DataSet.cpp	(revision 1904)
@@ -214,5 +214,5 @@
 	}
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	_printf_("Number of objects in dataset being demarshalled: %i\n",numobjects);
 	#endif
@@ -641,5 +641,5 @@
 	NodeRank(ranks);
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	for(i=0;i<numberofnodes;i++){
 		_printf_("%i\n",ranks[i]);
@@ -653,5 +653,5 @@
 	MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofnodes,MPI_INT,MPI_MIN,MPI_COMM_WORLD);
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	for(i=0;i<numberofnodes;i++){
 		_printf_("%i\n",minranks[i]);
Index: /issm/trunk/src/c/GriddataMeshToGridx/GriddataMeshToGridx.cpp
===================================================================
--- /issm/trunk/src/c/GriddataMeshToGridx/GriddataMeshToGridx.cpp	(revision 1903)
+++ /issm/trunk/src/c/GriddataMeshToGridx/GriddataMeshToGridx.cpp	(revision 1904)
@@ -137,5 +137,5 @@
 	}
 	for (i=0;i<numcontours;i++){
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			_printf_("Handling contour %i/%i\n",i,numcontours);
 		#endif
Index: /issm/trunk/src/c/HoleFillerx/HoleFillerx.cpp
===================================================================
--- /issm/trunk/src/c/HoleFillerx/HoleFillerx.cpp	(revision 1903)
+++ /issm/trunk/src/c/HoleFillerx/HoleFillerx.cpp	(revision 1904)
@@ -44,5 +44,5 @@
 	int             imageoutsize;
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		if ( smooth == 1 ){
 			printf("Data patches will be SMOOTHED. \n");
@@ -93,5 +93,5 @@
 	#endif
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		printf( "\n" );
 		printf( "Iterations %5ld   and %5ld.", count-1, count );
@@ -119,5 +119,5 @@
 	#endif
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		printf( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
 		printf( "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" );
@@ -367,5 +367,5 @@
 		}
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			if ( !(i%100) ){
 			fprintf(stdout, "\b\b\b\b\b\b%5ld ", i );   /* Count lines on output screen */
@@ -375,5 +375,5 @@
 	}
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		fprintf(stdout, "\b\b\b\b\b\b%5ld ", lines );
 		fflush(stdout);	
@@ -389,5 +389,5 @@
 
 	time(&t2);	
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		printf ( "\n\nEnd                  "); printf( ctime(&t2) );
 		printf( "\n                           Total time:        ");
@@ -403,5 +403,5 @@
 	end:
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		printf( "Done.\a\n" );
 	#endif
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 1903)
+++ /issm/trunk/src/c/Makefile.am	(revision 1904)
@@ -302,5 +302,5 @@
 
 
-libISSM_a_CXXFLAGS = -fPIC -DMATLAB -D_SERIAL_ -ansi -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_ 
+libISSM_a_CXXFLAGS = -fPIC -DMATLAB -D_SERIAL_ -ansi -D_GNU_SOURCE -fno-omit-frame-pointer -pthread -D_CPP_  -g -O0
 if LARGEARRAYS
 libISSM_a_CXXFLAGS += -D__GCC4BUILD__  
Index: /issm/trunk/src/c/MeshPartitionx/MeshPartitionx.cpp
===================================================================
--- /issm/trunk/src/c/MeshPartitionx/MeshPartitionx.cpp	(revision 1903)
+++ /issm/trunk/src/c/MeshPartitionx/MeshPartitionx.cpp	(revision 1904)
@@ -88,5 +88,5 @@
 	}
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	if(my_rank==0){
 		for (i=0;i<numberofelements;i++){
Index: /issm/trunk/src/c/ModelProcessorx/DiagnosticHoriz/CreateElementsNodesAndMaterialsDiagnosticHoriz.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/DiagnosticHoriz/CreateElementsNodesAndMaterialsDiagnosticHoriz.cpp	(revision 1903)
+++ /issm/trunk/src/c/ModelProcessorx/DiagnosticHoriz/CreateElementsNodesAndMaterialsDiagnosticHoriz.cpp	(revision 1904)
@@ -505,5 +505,5 @@
 		VecAssemblyEnd(gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		VecView(gridborder,PETSC_VIEWER_STDOUT_WORLD);
 		#endif
@@ -511,5 +511,5 @@
 		VecToMPISerial(&my_bordergrids,gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		if(my_rank==0){
 			for (i=0;i<iomodel->numberofnodes;i++){
Index: /issm/trunk/src/c/ModelProcessorx/DiagnosticHutter/CreateElementsNodesAndMaterialsDiagnosticHutter.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/DiagnosticHutter/CreateElementsNodesAndMaterialsDiagnosticHutter.cpp	(revision 1903)
+++ /issm/trunk/src/c/ModelProcessorx/DiagnosticHutter/CreateElementsNodesAndMaterialsDiagnosticHutter.cpp	(revision 1904)
@@ -184,5 +184,5 @@
 	VecAssemblyEnd(gridborder);
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	VecView(gridborder,PETSC_VIEWER_STDOUT_WORLD);
 	#endif
@@ -190,5 +190,5 @@
 	VecToMPISerial(&my_bordergrids,gridborder);
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	if(my_rank==0){
 		for (i=0;i<iomodel->numberofnodes;i++){
Index: /issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateElementsNodesAndMaterialsDiagnosticStokes.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateElementsNodesAndMaterialsDiagnosticStokes.cpp	(revision 1903)
+++ /issm/trunk/src/c/ModelProcessorx/DiagnosticStokes/CreateElementsNodesAndMaterialsDiagnosticStokes.cpp	(revision 1904)
@@ -334,5 +334,5 @@
 		VecAssemblyEnd(gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		VecView(gridborder,PETSC_VIEWER_STDOUT_WORLD);
 		#endif
@@ -340,5 +340,5 @@
 		VecToMPISerial(&my_bordergrids,gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		if(my_rank==0){
 			for (i=0;i<iomodel->numberofnodes;i++){
Index: /issm/trunk/src/c/ModelProcessorx/DiagnosticVert/CreateElementsNodesAndMaterialsDiagnosticVert.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/DiagnosticVert/CreateElementsNodesAndMaterialsDiagnosticVert.cpp	(revision 1903)
+++ /issm/trunk/src/c/ModelProcessorx/DiagnosticVert/CreateElementsNodesAndMaterialsDiagnosticVert.cpp	(revision 1904)
@@ -284,5 +284,5 @@
 		VecAssemblyEnd(gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		VecView(gridborder,PETSC_VIEWER_STDOUT_WORLD);
 		#endif
@@ -290,5 +290,5 @@
 		VecToMPISerial(&my_bordergrids,gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		if(my_rank==0){
 			for (i=0;i<iomodel->numberofnodes;i++){
Index: /issm/trunk/src/c/ModelProcessorx/Melting/CreateElementsNodesAndMaterialsMelting.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Melting/CreateElementsNodesAndMaterialsMelting.cpp	(revision 1903)
+++ /issm/trunk/src/c/ModelProcessorx/Melting/CreateElementsNodesAndMaterialsMelting.cpp	(revision 1904)
@@ -301,5 +301,5 @@
 		VecAssemblyEnd(gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		VecView(gridborder,PETSC_VIEWER_STDOUT_WORLD);
 		#endif
@@ -307,5 +307,5 @@
 		VecToMPISerial(&my_bordergrids,gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		if(my_rank==0){
 			for (i=0;i<iomodel->numberofnodes;i++){
Index: /issm/trunk/src/c/ModelProcessorx/Prognostic/CreateElementsNodesAndMaterialsPrognostic.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Prognostic/CreateElementsNodesAndMaterialsPrognostic.cpp	(revision 1903)
+++ /issm/trunk/src/c/ModelProcessorx/Prognostic/CreateElementsNodesAndMaterialsPrognostic.cpp	(revision 1904)
@@ -350,5 +350,5 @@
 		VecAssemblyEnd(gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		VecView(gridborder,PETSC_VIEWER_STDOUT_WORLD);
 		#endif
@@ -356,5 +356,5 @@
 		VecToMPISerial(&my_bordergrids,gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		if(my_rank==0){
 			for (i=0;i<iomodel->numberofnodes;i++){
Index: /issm/trunk/src/c/ModelProcessorx/Qmu/CreateParametersQmu.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Qmu/CreateParametersQmu.cpp	(revision 1903)
+++ /issm/trunk/src/c/ModelProcessorx/Qmu/CreateParametersQmu.cpp	(revision 1904)
@@ -146,5 +146,5 @@
 		parameters->AddObject(param);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			for(i=0;i<iomodel->numberofvariables;i++){
 				_printf_("variable descriptor %s\n",variabledescriptors[i]);
Index: /issm/trunk/src/c/ModelProcessorx/SlopeCompute/CreateElementsNodesAndMaterialsSlopeCompute.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/SlopeCompute/CreateElementsNodesAndMaterialsSlopeCompute.cpp	(revision 1903)
+++ /issm/trunk/src/c/ModelProcessorx/SlopeCompute/CreateElementsNodesAndMaterialsSlopeCompute.cpp	(revision 1904)
@@ -312,5 +312,5 @@
 		VecAssemblyEnd(gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		VecView(gridborder,PETSC_VIEWER_STDOUT_WORLD);
 		#endif
@@ -318,5 +318,5 @@
 		VecToMPISerial(&my_bordergrids,gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		if(my_rank==0){
 			for (i=0;i<iomodel->numberofnodes;i++){
Index: /issm/trunk/src/c/ModelProcessorx/Thermal/CreateElementsNodesAndMaterialsThermal.cpp
===================================================================
--- /issm/trunk/src/c/ModelProcessorx/Thermal/CreateElementsNodesAndMaterialsThermal.cpp	(revision 1903)
+++ /issm/trunk/src/c/ModelProcessorx/Thermal/CreateElementsNodesAndMaterialsThermal.cpp	(revision 1904)
@@ -304,5 +304,5 @@
 		VecAssemblyEnd(gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		VecView(gridborder,PETSC_VIEWER_STDOUT_WORLD);
 		#endif
@@ -310,5 +310,5 @@
 		VecToMPISerial(&my_bordergrids,gridborder);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		if(my_rank==0){
 			for (i=0;i<iomodel->numberofnodes;i++){
Index: /issm/trunk/src/c/PenaltyConstraintsx/RiftConstraints.cpp
===================================================================
--- /issm/trunk/src/c/PenaltyConstraintsx/RiftConstraints.cpp	(revision 1903)
+++ /issm/trunk/src/c/PenaltyConstraintsx/RiftConstraints.cpp	(revision 1904)
@@ -263,5 +263,5 @@
 	#endif
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		printf("Maximum rift penetration2: %g\n",max_penetration);
 	#endif
Index: /issm/trunk/src/c/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp
===================================================================
--- /issm/trunk/src/c/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp	(revision 1903)
+++ /issm/trunk/src/c/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp	(revision 1904)
@@ -28,5 +28,5 @@
 	/*Now, figure out maximum value of K_gg, so that we can penalize it correctly: */
 	MatNorm(Kgg,NORM_INFINITY,&kmax);
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	 _printf_("   K_gg infinity norm: %g\n",kmax);
 	#endif
@@ -47,5 +47,5 @@
 	}
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	MatNorm(Kgg,NORM_INFINITY,&kmax2);
 	 _printf_("   K_gg infinity norm after penalties: %g\n",kmax2);
Index: /issm/trunk/src/c/Qmux/SpawnCoreParallel.cpp
===================================================================
--- /issm/trunk/src/c/Qmux/SpawnCoreParallel.cpp	(revision 1903)
+++ /issm/trunk/src/c/Qmux/SpawnCoreParallel.cpp	(revision 1904)
@@ -69,5 +69,5 @@
 	model->FindParam(&qmu_npart,"qmu_npart");
 	model->FindParam(&qmu_part,"qmu_part");
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	for(i=0;i<numresponses;i++){
 		PetscSynchronizedPrintf(MPI_COMM_WORLD,"response descriptor %i: %s\n",i,responses_descriptors[i]);
@@ -81,5 +81,5 @@
 	MPI_Bcast(variables,numvariables,MPI_DOUBLE,0,MPI_COMM_WORLD); 
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	for(i=0;i<numvariables;i++){
 		PetscSynchronizedPrintf(MPI_COMM_WORLD,"variable %i: %g\n",i,variables[i]);
@@ -103,5 +103,5 @@
 	}
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	for(i=0;i<numvariables;i++){
 		PetscSynchronizedPrintf(MPI_COMM_WORLD,"variable descriptor %i: %s value: %g\n",i,variables_descriptors[i],variables[i]);
Index: /issm/trunk/src/c/Solverx/Solverx.cpp
===================================================================
--- /issm/trunk/src/c/Solverx/Solverx.cpp	(revision 1903)
+++ /issm/trunk/src/c/Solverx/Solverx.cpp	(revision 1904)
@@ -75,5 +75,5 @@
 		
 
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_DEBUG_ 
 		KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD);
 		KSPGetInitialGuessNonzero(ksp,&flag); 
@@ -89,5 +89,5 @@
 	}
 	else{
-		#ifdef _DEBUG_ 
+		#ifdef _ISSM_DEBUG_ 
 		_printf_("%s%i%s\n","Solver converged after ",iteration_number," iterations");
 		#endif
Index: /issm/trunk/src/c/objects/Matice.cpp
===================================================================
--- /issm/trunk/src/c/objects/Matice.cpp	(revision 1903)
+++ /issm/trunk/src/c/objects/Matice.cpp	(revision 1904)
@@ -181,6 +181,6 @@
 		}
 	}
-	#ifdef _DEBUG_
-	_printf_("Viscosity %lf\n",viscosity);
+	#ifdef _ISSM_DEBUG_
+	printf("Viscosity %lf\n",viscosity);
 	#endif
 
@@ -241,6 +241,6 @@
 	}
 		
-	#ifdef _DEBUG_
-	_printf_("viscosity_complement %lf\n",mu2);
+	#ifdef _ISSM_DEBUG_
+	printf("viscosity_complement %lf\n",viscosity_complement);
 	#endif
 
@@ -306,6 +306,6 @@
 		}
 	}
-	#ifdef _DEBUG_
-	_printf_("Viscosity %lf\n",viscosity3d);
+	#ifdef _ISSM_DEBUG_
+	printf("Viscosity %lf\n",viscosity3d);
 	#endif
 
@@ -375,6 +375,6 @@
 	}
 
-	#ifdef _DEBUG_
-	_printf_("Viscosity %lf\n",viscosity3d);
+	#ifdef _ISSM_DEBUG_
+	printf("Viscosity %lf\n",viscosity3d);
 	#endif
 
Index: /issm/trunk/src/c/objects/ParameterInputs.cpp
===================================================================
--- /issm/trunk/src/c/objects/ParameterInputs.cpp	(revision 1903)
+++ /issm/trunk/src/c/objects/ParameterInputs.cpp	(revision 1904)
@@ -329,5 +329,5 @@
 			}
 
-			#ifdef _DEBUG_
+			#ifdef _ISSM_DEBUG_
 				PetscSynchronizedPrintf(MPI_COMM_WORLD,"Parameter vetor:");
 				PetscSynchronizedFlush(MPI_COMM_WORLD);
Index: /issm/trunk/src/c/objects/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Penta.cpp	(revision 1903)
+++ /issm/trunk/src/c/objects/Penta.cpp	(revision 1904)
@@ -710,10 +710,10 @@
 
 	GaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss);
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_DEBUG_ 
 	for (i=0;i<num_area_gauss;i++){
-		_printf_("Area Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(area_gauss_weights+i));
+		printf("Area Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(area_gauss_weights+i));
 	}
 	for (i=0;i<num_vert_gauss;i++){
-		_printf_("Vert Gauss coord %i: %lf Weight: %lf\n",i,*(fourth_gauss_vert_coord+i),*(vert_gauss_weights+i));
+		printf("Vert Gauss coord %i: %lf Weight: %lf\n",i,*(fourth_gauss_vert_coord+i),*(vert_gauss_weights+i));
 	}
 	#endif
@@ -1434,44 +1434,41 @@
 	GetB(&B[0][0], xyz_list, gauss_l1l2l3l4);
 
-	#ifdef _DEBUG_
-	_printf_("B for grid1 : [ %lf   %lf  \n",B[0][0],B[0][1]);
-	_printf_("              [ %lf   %lf  \n",B[1][0],B[1][1]);
-	_printf_("              [ %lf   %lf  ]\n",B[2][0],B[2][1]);
-	_printf_("              [ %lf   %lf  ]\n",B[3][0],B[3][1]);
-	_printf_("              [ %lf   %lf  ]\n",B[4][0],B[4][1]);
-	
-	_printf_("B for grid2 : [ %lf   %lf  \n",B[0][2],B[0][3]);
-	_printf_("              [ %lf   %lf  \n",B[1][2],B[1][3]);
-	_printf_("              [ %lf   %lf  ]\n",B[2][2],B[2][3]);
-	_printf_("              [ %lf   %lf  ]\n",B[3][2],B[3][3]);
-	_printf_("              [ %lf   %lf  ]\n",B[4][2],B[4][3]);
-	
-	_printf_("B for grid3 : [ %lf   %lf  \n", B[0][4],B[0][5]);
-	_printf_("              [ %lf   %lf  \n", B[1][4],B[1][5]);
-	_printf_("              [ %lf   %lf  ]\n",B[2][4],B[2][5]);
-	_printf_("              [ %lf   %lf  ]\n",B[3][4],B[3][5]);
-	_printf_("              [ %lf   %lf  ]\n",B[4][4],B[4][5]);
-	
-	_printf_("B for grid4 : [ %lf   %lf  \n", B[0][6],B[0][7]);
-	_printf_("              [ %lf   %lf  \n", B[1][6],B[1][7]);
-	_printf_("              [ %lf   %lf  ]\n",B[2][6],B[2][7]);
-	_printf_("              [ %lf   %lf  ]\n",B[3][6],B[3][7]);
-	_printf_("              [ %lf   %lf  ]\n",B[4][6],B[4][7]);
+	#ifdef _ISSM_DEBUG_
+	printf("B for grid1 : [ %lf   %lf  \n",B[0][0],B[0][1]);
+	printf("              [ %lf   %lf  \n",B[1][0],B[1][1]);
+	printf("              [ %lf   %lf  ]\n",B[2][0],B[2][1]);
+	printf("              [ %lf   %lf  ]\n",B[3][0],B[3][1]);
+	printf("              [ %lf   %lf  ]\n",B[4][0],B[4][1]);
+	
+	printf("B for grid2 : [ %lf   %lf  \n",B[0][2],B[0][3]);
+	printf("              [ %lf   %lf  \n",B[1][2],B[1][3]);
+	printf("              [ %lf   %lf  ]\n",B[2][2],B[2][3]);
+	printf("              [ %lf   %lf  ]\n",B[3][2],B[3][3]);
+	printf("              [ %lf   %lf  ]\n",B[4][2],B[4][3]);
+	
+	printf("B for grid3 : [ %lf   %lf  \n", B[0][4],B[0][5]);
+	printf("              [ %lf   %lf  \n", B[1][4],B[1][5]);
+	printf("              [ %lf   %lf  ]\n",B[2][4],B[2][5]);
+	printf("              [ %lf   %lf  ]\n",B[3][4],B[3][5]);
+	printf("              [ %lf   %lf  ]\n",B[4][4],B[4][5]);
+	
+	printf("B for grid4 : [ %lf   %lf  \n", B[0][6],B[0][7]);
+	printf("              [ %lf   %lf  \n", B[1][6],B[1][7]);
+	printf("              [ %lf   %lf  ]\n",B[2][6],B[2][7]);
+	printf("              [ %lf   %lf  ]\n",B[3][6],B[3][7]);
+	printf("              [ %lf   %lf  ]\n",B[4][6],B[4][7]);
 				
-	_printf_("B for grid5 : [ %lf   %lf  \n", B[0][8],B[0][9]);
-	_printf_("              [ %lf   %lf  \n", B[1][8],B[1][9]);
-	_printf_("              [ %lf   %lf  ]\n",B[2][8],B[2][9]);
-	_printf_("              [ %lf   %lf  ]\n",B[3][8],B[3][9]);
-	_printf_("              [ %lf   %lf  ]\n",B[4][8],B[4][9]);
-
-	_printf_("B for grid6 : [ %lf   %lf  \n", B[0][10],B[0][11]);
-	_printf_("              [ %lf   %lf  \n", B[1][10],B[1][11]);
-	_printf_("              [ %lf   %lf  ]\n",B[2][10],B[2][11]);
-	_printf_("              [ %lf   %lf  ]\n",B[3][10],B[3][11]);
-	_printf_("              [ %lf   %lf  ]\n",B[4][10],B[4][11]);
-
-	for (i=0;i<numgrids;i++){
-		_printf_("Velocity for grid %i %lf %lf\n",i,*(vxvy_list+2*i+0),*(vxvy_list+2*i+1));
-	}
+	printf("B for grid5 : [ %lf   %lf  \n", B[0][8],B[0][9]);
+	printf("              [ %lf   %lf  \n", B[1][8],B[1][9]);
+	printf("              [ %lf   %lf  ]\n",B[2][8],B[2][9]);
+	printf("              [ %lf   %lf  ]\n",B[3][8],B[3][9]);
+	printf("              [ %lf   %lf  ]\n",B[4][8],B[4][9]);
+
+	printf("B for grid6 : [ %lf   %lf  \n", B[0][10],B[0][11]);
+	printf("              [ %lf   %lf  \n", B[1][10],B[1][11]);
+	printf("              [ %lf   %lf  ]\n",B[2][10],B[2][11]);
+	printf("              [ %lf   %lf  ]\n",B[3][10],B[3][11]);
+	printf("              [ %lf   %lf  ]\n",B[4][10],B[4][11]);
+
 	#endif
 
@@ -1510,7 +1507,7 @@
 	GetNodalFunctionsDerivativesBasic(&dh1dh2dh3dh4dh5dh6_basic[0][0],xyz_list, gauss_l1l2l3l4);
 
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_DEBUG_ 
 	for (i=0;i<numgrids;i++){
-		_printf_("Node %i  dh/dx=%lf dh/dy=%lf dh/dz=%lf\n",i,dh1dh2dh3dh4dh5dh6_basic[0][i],dh1dh2dh3dh4dh5dh6_basic[1][i],dh1dh2dh3dh4dh5dh6_basic[2][i]);
+		printf("Node %i  dh/dx=%lf dh/dy=%lf dh/dz=%lf\n",i,dh1dh2dh3dh4dh5dh6_basic[0][i],dh1dh2dh3dh4dh5dh6_basic[1][i],dh1dh2dh3dh4dh5dh6_basic[2][i]);
 	}
 	#endif
@@ -1564,7 +1561,7 @@
 	GetNodalFunctionsDerivativesBasic(&dh1dh2dh3dh4dh5dh6_basic[0][0],xyz_list, gauss_l1l2l3l4);
 
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_DEBUG_ 
 	for (i=0;i<numgrids;i++){
-		_printf_("Node %i  dh/dx=%lf dh/dy=%lf dh/dz=%lf\n",i,dh1dh2dh3dh4dh5dh6_basic[0][i],dh1dh2dh3dh4dh5dh6_basic[1][i],dh1dh2dh3dh4dh5dh6_basic[2][i]);
+		printf("Node %i  dh/dx=%lf dh/dy=%lf dh/dz=%lf\n",i,dh1dh2dh3dh4dh5dh6_basic[0][i],dh1dh2dh3dh4dh5dh6_basic[1][i],dh1dh2dh3dh4dh5dh6_basic[2][i]);
 	}
 	#endif
@@ -1704,5 +1701,5 @@
 	*(J+NDOF3*2+2)=sqrt3/12.0*(z1+z2-2*z3-z4-z5+2*z6)*eta+1.0/4.0*(z1-z2-z4+z5)*xi+1.0/4.0*(-z1+z5-z2+z4);
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	for(i=0;i<3;i++){
 		for (j=0;j<3;j++){
@@ -1869,10 +1866,10 @@
 
 		GaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss);
-		#ifdef _DEBUG_ 
+		#ifdef _ISSM_DEBUG_ 
 		for (i=0;i<num_area_gauss;i++){
-			_printf_("Area Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(area_gauss_weights+i));
+			printf("Area Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(area_gauss_weights+i));
 		}
 		for (i=0;i<num_vert_gauss;i++){
-			_printf_("Vert Gauss coord %i: %lf Weight: %lf\n",i,*(fourth_gauss_vert_coord+i),*(vert_gauss_weights+i));
+			printf("Vert Gauss coord %i: %lf Weight: %lf\n",i,*(fourth_gauss_vert_coord+i),*(vert_gauss_weights+i));
 		}
 		#endif
@@ -2151,7 +2148,7 @@
 	GetNodalFunctionsDerivativesBasic(&dh1dh2dh3dh4dh5dh6_basic[0][0],xyz_list, gauss_l1l2l3l4);
 
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_DEBUG_ 
 	for (i=0;i<numgrids;i++){
-		_printf_("Node %i  dh/dx=%lf dh/dy=%lf dh/dz=%lf\n",i,dh1dh2dh3dh4dh5dh6_basic[0][i],dh1dh2dh3dh4dh5dh6_basic[1][i],dh1dh2dh3dh4dh5dh6_basic[2][i]);
+		printf("Node %i  dh/dx=%lf dh/dy=%lf dh/dz=%lf\n",i,dh1dh2dh3dh4dh5dh6_basic[0][i],dh1dh2dh3dh4dh5dh6_basic[1][i],dh1dh2dh3dh4dh5dh6_basic[2][i]);
 	}
 	#endif
@@ -2261,10 +2258,10 @@
 
 	GaussPenta( &num_area_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &area_gauss_weights, &fourth_gauss_vert_coord,&vert_gauss_weights,order_area_gauss,num_vert_gauss);
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_DEBUG_ 
 	for (i=0;i<num_area_gauss;i++){
-		_printf_("Area Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(area_gauss_weights+i));
+		printf("Area Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(area_gauss_weights+i));
 	}
 	for (i=0;i<num_vert_gauss;i++){
-		_printf_("Vert Gauss coord %i: %lf Weight: %lf\n",i,*(fourth_gauss_vert_coord+i),*(vert_gauss_weights+i));
+		printf("Vert Gauss coord %i: %lf Weight: %lf\n",i,*(fourth_gauss_vert_coord+i),*(vert_gauss_weights+i));
 	}
 	#endif
@@ -2293,6 +2290,6 @@
 			/* Get Jacobian determinant: */
 			GetJacobianDeterminant(&Jdet, &xyz_list[0][0],gauss_l1l2l3l4);
-			#ifdef _DEBUG_ 
-			_printf_("Element id %i Jacobian determinant: %lf\n",PentaElementGetID(this),Jdet);
+			#ifdef _ISSM_DEBUG_ 
+			printf("Element id %i Jacobian determinant: %lf\n",GetId(),Jdet);
 			#endif
 		
@@ -2629,5 +2626,5 @@
 	GetNodalFunctions(l1l6, gauss_coord);
 	
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_DEBUG_ 
 	for (i=0;i<7;i++){
 		printf("Node %i  dh/dx=%lf dh/dy=%lf dh/dz=%lf \n",i,dh1dh7_basic[0][i],dh1dh7_basic[1][i],dh1dh7_basic[2][i]);
@@ -2711,5 +2708,5 @@
 	GetNodalFunctions(l1l6, gauss_coord);
 	
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_DEBUG_ 
 	for (i=0;i<6;i++){
 		printf("Node %i  dh/dx=%lf dh/dy=%lf dh/dz=%lf \n",i,dh1dh7_basic[0][i],dh1dh7_basic[1][i]);
Index: /issm/trunk/src/c/objects/Riftfront.cpp
===================================================================
--- /issm/trunk/src/c/objects/Riftfront.cpp	(revision 1903)
+++ /issm/trunk/src/c/objects/Riftfront.cpp	(revision 1904)
@@ -341,5 +341,5 @@
 		 *contact slip friction. */
 		  
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		printf("Dealing with grid pair (%i,%i)\n",nodes[0]->GetId(),nodes[1]->GetId());
 		#endif
@@ -350,5 +350,5 @@
 		thickness=h[0];
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			printf("Thickness at grid (%i,%i): %lg\n",nodes[0]->GetId(),nodes[1]->GetID(),thickness);
 		#endif
@@ -446,5 +446,5 @@
 		 * and we want to avoid zigzagging of the loads, we want lump the loads onto grids, not onto surfaces between grids.:*/
 	
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		_printf_("Grids  (%i,%i) are free of constraints\n",nodes[0]->GetId(),nodes[1]->GetID());
 		#endif
Index: /issm/trunk/src/c/objects/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Tria.cpp	(revision 1903)
+++ /issm/trunk/src/c/objects/Tria.cpp	(revision 1904)
@@ -284,5 +284,5 @@
 
 }
-int    Tria::GetId(void){ return id; }
+int    Tria::GetId(){ return id; }
 
 int    Tria::MyRank(void){ 
@@ -1559,22 +1559,4 @@
 	GetB(&B[0][0], xyz_list, gauss_l1l2l3);
 
-	#ifdef _DEBUG_
-	printf("B for grid1 : [ %lf   %lf  \n",B[0][0],B[0][1]);
-	printf("              [ %lf   %lf  \n",B[1][0],B[1][1]);
-	printf("              [ %lf   %lf  ]\n",B[2][0],B[2][1]);
-
-	printf("B for grid2 : [ %lf   %lf  \n",B[0][2],B[0][3]);
-	printf("              [ %lf   %lf  \n",B[1][2],B[1][3]);
-	printf("              [ %lf   %lf  ]\n",B[2][2],B[2][3]);
-
-	printf("B for grid3 : [ %lf   %lf  \n",B[0][4],B[0][5]);
-	printf("              [ %lf   %lf  \n",B[1][4],B[1][5]);
-	printf("              [ %lf   %lf  ]\n",B[2][4],B[2][5]);
-		
-	for (i=0;i<numgrids;i++){
-		printf("Velocity for grid %i %lf %lf\n",i,*(vxvy_list+2*i+0),*(vxvy_list+2*i+1));
-	}
-	#endif
-
 	/*Multiply B by velocity, to get strain rate: */
 	MatrixMultiply( &B[0][0],3,NDOF2*numgrids,0,
@@ -1665,5 +1647,5 @@
 	GetNodalFunctionsDerivativesBasic(&dh1dh2dh3_basic[0][0],xyz_list, gauss_l1l2l3);
 
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_ISSM_DEBUG_ 
 	for (i=0;i<3;i++){
 		printf("Node %i  dh/dx=%lf dh/dy=%lf \n",i,dh1dh2dh3_basic[0][i],dh1dh2dh3_basic[1][i]);
@@ -1795,5 +1777,5 @@
 	GetNodalFunctions(&l1l2l3[0],gauss_l1l2l3);
 
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_ISSM_DEBUG_ 
 	for (i=0;i<3;i++){
 		printf("Node %i  h=%lf \n",i,l1l2l3[i]);
@@ -2146,6 +2128,6 @@
 		/* Get Jacobian determinant: */
 		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3);
-		#ifdef _DEBUG_ 
-		printf("Element id %i Jacobian determinant: %lf\n",TriaElementGetID(this),Jdet);
+		#ifdef _ISSM_ISSM_DEBUG_ 
+		printf("Element id %i Jacobian determinant: %g\n",GetId(),Jdet);
 		#endif
 		
@@ -2383,5 +2365,5 @@
 		GetParameterValue(&alpha_complement, &alpha_complement_list[0],gauss_l1l2l3);
 		GetParameterValue(&drag, &k[0],gauss_l1l2l3);
-		#ifdef _DEBUG_ 
+		#ifdef _ISSM_ISSM_DEBUG_ 
 			printf("Drag complement: %20.20lf Drag: %20.20lf\n",alpha_complement,drag);
 		#endif
@@ -2390,5 +2372,5 @@
 		GetParameterValue(&lambda, &adjx_list[0],gauss_l1l2l3);
 		GetParameterValue(&mu, &adjy_list[0],gauss_l1l2l3);
-		#ifdef _DEBUG_ 
+		#ifdef _ISSM_ISSM_DEBUG_ 
 			printf("Adjoint vector %20.20lf %20.20lf\n",lambda,mu);
 		#endif
@@ -2397,5 +2379,5 @@
 		GetParameterValue(&vx, &vx_list[0],gauss_l1l2l3);
 		GetParameterValue(&vy, &vy_list[0],gauss_l1l2l3);
-		#ifdef _DEBUG_ 
+		#ifdef _ISSM_ISSM_DEBUG_ 
 			printf("Velocity vector %20.20lf %20.20lf\n",vx,vy);
 		#endif
@@ -2403,6 +2385,6 @@
 		/* Get Jacobian determinant: */
 		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3);
-		#ifdef _DEBUG_ 
-		printf("Element id %i Jacobian determinant: %lf\n",TriaElementGetID(this),Jdet);
+		#ifdef _ISSM_ISSM_DEBUG_ 
+		printf("Element id %i Jacobian determinant: %lf\n",GetId(),Jdet);
 		#endif
 		
@@ -2581,5 +2563,5 @@
 		GetParameterValue(&alpha_complement, &alpha_complement_list[0],gauss_l1l2l3);
 		GetParameterValue(&drag, &k[0],gauss_l1l2l3);
-#ifdef _DEBUG_ 
+#ifdef _ISSM_ISSM_DEBUG_ 
 		printf("Drag complement: %20.20lf Drag: %20.20lf\n",alpha_complement,drag);
 #endif
@@ -2589,5 +2571,5 @@
 		GetParameterValue(&mu, &adjy_list[0],gauss_l1l2l3);
 		GetParameterValue(&xi, &adjz_list[0],gauss_l1l2l3);
-#ifdef _DEBUG_ 
+#ifdef _ISSM_ISSM_DEBUG_ 
 		printf("Adjoint vector %20.20lf %20.20lf\n",lambda,mu);
 #endif
@@ -2597,5 +2579,5 @@
 		GetParameterValue(&vy, &vy_list[0],gauss_l1l2l3);
 		GetParameterValue(&vz, &vz_list[0],gauss_l1l2l3);
-#ifdef _DEBUG_ 
+#ifdef _ISSM_ISSM_DEBUG_ 
 		printf("Velocity vector %20.20lf %20.20lf\n",vx,vy);
 
@@ -2610,6 +2592,6 @@
 		/* Get Jacobian determinant: */
 		GetJacobianDeterminant3d(&Jdet, &xyz_list[0][0],gauss_l1l2l3);
-#ifdef _DEBUG_ 
-		printf("Element id %i Jacobian determinant: %lf\n",TriaElementGetID(this),Jdet);
+#ifdef _ISSM_ISSM_DEBUG_ 
+		printf("Element id %i Jacobian determinant: %lf\n",GetId(),Jdet);
 #endif
 
@@ -2761,5 +2743,5 @@
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
 	GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4);
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_ISSM_DEBUG_ 
 	for (i=0;i<num_gauss;i++){
 		printf("Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(gauss_weights+i));
@@ -2795,6 +2777,6 @@
 		/* Get nodal functions value at gaussian point:*/
 		GetNodalFunctions(l1l2l3, gauss_l1l2l3);
-		#ifdef _DEBUG_
-			_printf_("viscositycomp %g thickness %g dvx [%g %g] dvy [%g %g]  dadjx [%g %g] dadjy[%g %g]\n",viscosity_complement,thickness,dvx[0],dvx[1],dvy[0],dvy[1],dadjx[0],dadjx[1],dadjy[0],dadjy[1]);
+		#ifdef _ISSM_ISSM_DEBUG_
+			printf("viscositycomp %g thickness %g dvx [%g %g] dvy [%g %g]  dadjx [%g %g] dadjy[%g %g]\n",viscosity_complement,thickness,dvx[0],dvx[1],dvy[0],dvy[1],dadjx[0],dadjx[1],dadjy[0],dadjy[1]);
 		#endif
 
@@ -2931,5 +2913,5 @@
 	GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);
 	
-	#ifdef _DEBUG_ 
+	#ifdef _ISSM_ISSM_DEBUG_ 
 	for (i=0;i<num_gauss;i++){
 		printf("Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(gauss_weights+i));
@@ -2947,6 +2929,6 @@
 		/* Get Jacobian determinant: */
 		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3);
-		#ifdef _DEBUG_ 
-		printf("Element id %i Jacobian determinant: %lf\n",TriaElementGetID(this),Jdet);
+		#ifdef _ISSM_ISSM_DEBUG_ 
+		printf("Element id %i Jacobian determinant: %lf\n",GetId(),Jdet);
 		#endif
 		
Index: /issm/trunk/src/c/shared/Exp/DomainOutlineRead.cpp
===================================================================
--- /issm/trunk/src/c/shared/Exp/DomainOutlineRead.cpp	(revision 1903)
+++ /issm/trunk/src/c/shared/Exp/DomainOutlineRead.cpp	(revision 1904)
@@ -60,5 +60,5 @@
 		nprof++;
 	}
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		printf("Number of profiles in domain outline file: %i\n",nprof);
 	#endif
@@ -115,5 +115,5 @@
 
 	
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	for (i=0;i<nprof;i++){
 		printf("Profile #%i\n",i);
Index: /issm/trunk/src/c/shared/Sorting/binary_search.cpp
===================================================================
--- /issm/trunk/src/c/shared/Sorting/binary_search.cpp	(revision 1903)
+++ /issm/trunk/src/c/shared/Sorting/binary_search.cpp	(revision 1904)
@@ -40,5 +40,5 @@
 	else{
 		while((beg <= end) && (*mid != target)){
-			#ifdef _DEBUG_
+			#ifdef _ISSM_DEBUG_
 				printf("1: %i %i %i\n",*beg,*mid,*(end-1));
 			#endif
@@ -52,5 +52,5 @@
 				mid = beg + (end-beg)/2;  //new middle
 			}
-			#ifdef _DEBUG_
+			#ifdef _ISSM_DEBUG_
 				printf("2: %i %i %i\n",*beg,*mid,*(end-1));
 			#endif
Index: /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp
===================================================================
--- /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 1903)
+++ /issm/trunk/src/c/shared/TriMesh/TriMeshUtils.cpp	(revision 1904)
@@ -159,5 +159,5 @@
 		if (el2!=-1){
 			/*el and el2 are on a segment rift, facing one another, plug them into riftsegments_uncompressed: */
-			#ifdef _DEBUG_
+			#ifdef _ISSM_DEBUG_
 				printf("Elements %i and %i are on a rift\n",el+1,el2+1);
 			#endif
@@ -184,5 +184,5 @@
 	}
 
- 	#ifdef _DEBUG_
+ 	#ifdef _ISSM_DEBUG_
 	for (i=0;i<nriftsegs;i++){
 		printf("Elements %i and %i are on a rift, joined by grids %i and %i\n",*(riftsegments+4*i+0)+1,*(riftsegments+4*i+1)+1,*(riftsegments+4*i+2),*(riftsegments+4*i+3));
@@ -215,5 +215,5 @@
 	/*Build a list of all the elements connected to this grid: */
 	GridElementsList(&GridElements,&NumGridElements,grid,index,nel);
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		printf("Connected elements for grid %i\n",grid);
 		for (k=0;k<NumGridElements;k++){
@@ -230,5 +230,5 @@
 															   done rotating*/
 	GridElementListOnOneSideOfRift[1]=*(riftsegments+4*segmentnumber+1);
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	printf("Starting with elements %i and %i for grid %i\n",GridElementListOnOneSideOfRift[0]+1,GridElementListOnOneSideOfRift[1]+1,grid);
 	#endif
@@ -238,5 +238,5 @@
 		 * equal to GridElementListOnOneSideOfRift[counter-1]*/
 		for (k=0;k<NumGridElements;k++){
-			#ifdef _DEBUG_
+			#ifdef _ISSM_DEBUG_
 			printf("k: %i GridElements[k]: %i GridElementListOnOneSideOfRift[counter-1]: %i GridElementListOnOneSideOfRift[counter] %i Neighboor %i\n",k,GridElements[k]+1,
 				GridElementListOnOneSideOfRift[counter-1]+1,GridElementListOnOneSideOfRift[counter]+1,IsNeighbor(GridElements[k],GridElementListOnOneSideOfRift[counter],index));
@@ -266,5 +266,5 @@
 			GridElementListOnOneSideOfRift[l]=GridElementListOnOneSideOfRift[l+1];
 		}
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		printf("Grid %i is owned by  the following elements  on the same side of the rift: \n",grid);
 		for (l=0;l<NumGridElementListOnOneSideOfRift;l++){
@@ -313,5 +313,5 @@
 		for (j=0;j<nsegs;j++){
 			if (*(segments+3*j+2)==(el1+1)){
-				#ifdef _DEBUG_
+				#ifdef _ISSM_DEBUG_
 					printf("Segment %i is the same as rift segment %i\n",j,i);
 				#endif
@@ -348,5 +348,5 @@
 			}
 			if (*(segments+3*j+2)==(el2+1)){
-				#ifdef _DEBUG_
+				#ifdef _ISSM_DEBUG_
 					printf("Segment %i is the same as rift segment %i\n",j,i);
 				#endif
@@ -441,5 +441,5 @@
 	int n;
 	int el=-1;
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		printf("Looking for %lf %lf\n",A,B);
 	#endif
@@ -447,5 +447,5 @@
 		if (((*(index+3*n+0)==A)  || (*(index+3*n+1)==A) || (*(index+3*n+2)==A) ) && ((*(index+3*n+0)==B)  || (*(index+3*n+1)==B) || (*(index+3*n+2)==B))){
 			el=n;
-			#ifdef _DEBUG_
+			#ifdef _ISSM_DEBUG_
 				printf("Found them: %lf %lf %lf\n",*(index+3*n+0),*(index+3*n+1),*(index+3*n+2));
 			#endif
@@ -938,5 +938,5 @@
 		}
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			printf("Tips for rift#%i   (%i-%i)\n",i,tip1,tip2);
 		#endif
@@ -977,5 +977,5 @@
 		}
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		for (j=0;j<numsegs;j++){
 			printf("%i\n",order[j]);
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp	(revision 1903)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatPartition.cpp	(revision 1904)
@@ -66,5 +66,5 @@
 		upper_row--;
 		range=upper_row-lower_row+1;
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		 	PetscSynchronizedPrintf(MPI_COMM_WORLD,"My rank %i Range %i",my_rank,range);
 			PetscSynchronizedFlush(MPI_COMM_WORLD);
@@ -88,5 +88,5 @@
 		/*Now each node has a node_rows vectors holding which rows they should extract from matrixA. Create an Index Set from node_rows.*/
 		ISCreateGeneral(MPI_COMM_WORLD,count,node_rows,&row_index);
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			ISView(row_index,PETSC_VIEWER_STDOUT_WORLD);
 		#endif
@@ -98,5 +98,5 @@
 		}
 		ISCreateGeneral(MPI_COMM_WORLD,col_partition_vector_size,node_cols,&col_index);
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			ISView(col_index,PETSC_VIEWER_STDOUT_WORLD);
 		#endif
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatlabMatrixToDoubleMatrix.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatlabMatrixToDoubleMatrix.cpp	(revision 1903)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatlabMatrixToDoubleMatrix.cpp	(revision 1904)
@@ -86,5 +86,5 @@
 		}
 		
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		for(i=0;i<rows;i++){
 			for(j=0;j<cols;j++){
Index: /issm/trunk/src/c/toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp	(revision 1903)
+++ /issm/trunk/src/c/toolkits/petsc/patches/MatlabMatrixToPetscMatrix.cpp	(revision 1904)
@@ -80,5 +80,5 @@
 		cols=mxGetN(mxmatrix);
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		for(i=0;i<rows;i++){
 			for(j=0;j<cols;j++){
Index: /issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp	(revision 1903)
+++ /issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp	(revision 1904)
@@ -85,5 +85,5 @@
 			MatGetRow(matrix,i,&ncols,&columns,&column_values);
 
-			#ifdef _DEBUG_
+			#ifdef _ISSM_DEBUG_
 			for(j=0;j<ncols;j++){
 				printf("%i %i: %g\n",i,columns[j],column_values[j]);
Index: /issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp	(revision 1903)
+++ /issm/trunk/src/c/toolkits/petsc/patches/VecMerge.cpp	(revision 1904)
@@ -34,5 +34,5 @@
 	VecGetSize(B,&MB);
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		OutputServerMessages(0,0,"\n%s%s\n",STROFFSET,"Row partition vector:");
 		if (my_rank==0){
@@ -73,5 +73,5 @@
 	VecAssemblyEnd(A);
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		_printf_("Vector B:\n");
 		fflush(stdout);
Index: /issm/trunk/src/c/toolkits/petsc/patches/VecPartition.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/VecPartition.cpp	(revision 1903)
+++ /issm/trunk/src/c/toolkits/petsc/patches/VecPartition.cpp	(revision 1904)
@@ -58,5 +58,5 @@
 		upper_row--;
 		range=upper_row-lower_row+1;
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 		 	PetscSynchronizedPrintf(MPI_COMM_WORLD,"My rank %i Range %i\n",my_rank,range);
 			PetscSynchronizedFlush(MPI_COMM_WORLD);
@@ -86,5 +86,5 @@
 		}
 
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			PetscSynchronizedPrintf(MPI_COMM_WORLD,"My rank: %i My count: %i node_rows: %p values: %p\n",my_rank,count,node_rows,values);
 			PetscSynchronizedFlush(MPI_COMM_WORLD);
@@ -123,5 +123,5 @@
 	}
 	
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		_printf_("Vector A:\n");
 		fflush(stdout);
Index: /issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp	(revision 1903)
+++ /issm/trunk/src/c/toolkits/petsc/patches/VecToMPISerial.cpp	(revision 1904)
@@ -64,5 +64,5 @@
 		if (my_rank==0){
 			MPI_Recv(buffer,3,MPI_INT,i,1,MPI_COMM_WORLD,&status); 
-			#ifdef _DEBUG_
+			#ifdef _ISSM_DEBUG_
 				_printf_("Received from node %i: %i-%i\n",buffer[0],buffer[1],buffer[2]); 
 			#endif
Index: /issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp	(revision 1903)
+++ /issm/trunk/src/c/toolkits/plapack/patches/CyclicalFactorization.cpp	(revision 1904)
@@ -38,5 +38,5 @@
 	*pnprows=nprows;
 	*pnpcols=npcols;
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		_printf_("Decomposition: %i-%i\n",nprows,npcols);
 	#endif
@@ -56,5 +56,5 @@
 	for (i=0;i<input;i++){
 		SmallestPrimeFactor(&prime_factor,*(decomp+i));
-		#ifdef _DEBUG_
+		#ifdef _ISSM_DEBUG_
 			_printf_("Smallest prime factor for term %i : %i\n",i,prime_factor);
 		#endif
@@ -68,5 +68,5 @@
 		}
 	}
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		_printf_("Prime factor decomposition for integer %i: \n",input);
 		for(i=0;i<*pdecomp_size;i++){
Index: /issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp
===================================================================
--- /issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp	(revision 1903)
+++ /issm/trunk/src/c/toolkits/plapack/patches/PlapackInvertMatrix.cpp	(revision 1904)
@@ -119,5 +119,5 @@
 	PLA_API_end(); 
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		PLA_Global_show("Matrix A",a," %lf","Done with A");
 		MatView(*A,PETSC_VIEWER_STDOUT_WORLD);
@@ -131,5 +131,5 @@
 	PlapackToPetsc(inv_A,local_mA,local_nA,mA,nA,type,a,templ,nprows,npcols,nb);
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 		PLA_Global_show("Inverse of A",a," %lf","Done...");
 		MatView(*inv_A,PETSC_VIEWER_STDOUT_WORLD);
Index: /issm/trunk/src/m/classes/@model/model.m
===================================================================
--- /issm/trunk/src/m/classes/@model/model.m	(revision 1903)
+++ /issm/trunk/src/m/classes/@model/model.m	(revision 1904)
@@ -202,4 +202,5 @@
 	md.element_debug=0;
 	md.element_debugid=NaN;
+	md.mem_debug=0;
 
 	%Results fields
Index: /issm/trunk/src/m/classes/public/BuildQueueingScriptGeneric.m
===================================================================
--- /issm/trunk/src/m/classes/public/BuildQueueingScriptGeneric.m	(revision 1903)
+++ /issm/trunk/src/m/classes/public/BuildQueueingScriptGeneric.m	(revision 1904)
@@ -4,4 +4,6 @@
 %   Usage:
 %      BuildQueueingScriptGeneric(md,executionpath,codepath)
+
+global ISSM_DIR
 
 %Open queuing script file 
@@ -15,4 +17,10 @@
 fprintf(fid,'#!/bin/sh\n');
 fprintf(fid,'rm -rf %s/%s.lock\n',executionpath,md.name);
+
+if md.mem_debug==0,
 fprintf(fid,'mpirun -np %i %s/%s.exe %s %s.bin %s.outbin %s.lock  2> %s.errlog >%s.outlog & ',md.np,codepath,AnalysisTypeFromEnum(md.analysis_type),executionpath,md.name,md.name,md.name,md.name,md.name);
+else
+fprintf(fid,'LD_PRELOAD=%s mpirun -np %i %s --leak-check=full %s/%s.exe %s %s.bin %s.outbin %s.lock  2> %s.errlog >%s.outlog & ',[ISSM_DIR '/externalpackages/valgrind/install/lib/libmpidebug.so'],md.np,[ISSM_DIR '/externalpackages/valgrind/install/bin/valgrind'],codepath,AnalysisTypeFromEnum(md.analysis_type),executionpath,md.name,md.name,md.name,md.name,md.name);
+end
+
 fclose(fid);
Index: /issm/trunk/src/mex/ContourToMesh/ContourToMesh.cpp
===================================================================
--- /issm/trunk/src/mex/ContourToMesh/ContourToMesh.cpp	(revision 1903)
+++ /issm/trunk/src/mex/ContourToMesh/ContourToMesh.cpp	(revision 1904)
@@ -82,5 +82,5 @@
 	}
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	for(i=0;i<numcontours;i++){
 		printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
Index: /issm/trunk/src/mex/ContourToNodes/ContourToNodes.cpp
===================================================================
--- /issm/trunk/src/mex/ContourToNodes/ContourToNodes.cpp	(revision 1903)
+++ /issm/trunk/src/mex/ContourToNodes/ContourToNodes.cpp	(revision 1904)
@@ -75,5 +75,5 @@
 	}
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	for(i=0;i<numcontours;i++){
 		printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
Index: /issm/trunk/src/mex/TriMesh/TriMesh.cpp
===================================================================
--- /issm/trunk/src/mex/TriMesh/TriMesh.cpp	(revision 1903)
+++ /issm/trunk/src/mex/TriMesh/TriMesh.cpp	(revision 1904)
@@ -98,5 +98,5 @@
 	}
 	
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	printf("Domain name: %s\n",domainname);
 	printf("Rift name: %s\n",riftname);
@@ -122,5 +122,5 @@
 	}
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	printf("# points in domain outline: %i\n",nprof); 
 	#endif
@@ -137,5 +137,5 @@
 
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	printf("# points in rift outline: %i\n",numrifts); 
 	#endif
Index: /issm/trunk/src/mex/TriMeshProcessRifts/TriMeshProcessRifts.cpp
===================================================================
--- /issm/trunk/src/mex/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 1903)
+++ /issm/trunk/src/mex/TriMeshProcessRifts/TriMeshProcessRifts.cpp	(revision 1904)
@@ -142,5 +142,5 @@
 	}
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	printf("Index: \n");
 	for (i=0;i<nel;i++){
Index: /issm/trunk/src/mex/TriMeshRefine/TriMeshRefine.cpp
===================================================================
--- /issm/trunk/src/mex/TriMeshRefine/TriMeshRefine.cpp	(revision 1903)
+++ /issm/trunk/src/mex/TriMeshRefine/TriMeshRefine.cpp	(revision 1904)
@@ -160,5 +160,5 @@
 
 
-	#ifdef _DEBUG_
+	#ifdef _ISSM_DEBUG_
 	/*printf("Index: \n");
 	for (i=0;i<nel;i++){
