Index: /issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp	(revision 9373)
+++ /issm/trunk/src/c/modules/ModelProcessorx/CreateElementsVerticesAndMaterials.cpp	(revision 9374)
@@ -20,4 +20,5 @@
 	int numberofelements;
 	int numberofvertices;
+	bool control_analysis;
 
 	/*DataSets: */
@@ -30,4 +31,5 @@
 	iomodel->constants->FindParam(&numberofelements,NumberOfElementsEnum);
 	iomodel->constants->FindParam(&numberofvertices,NumberOfVerticesEnum);
+	iomodel->constants->FindParam(&control_analysis,ControlAnalysisEnum);
 
 	/*Did we already create the elements? : */
@@ -43,10 +45,10 @@
 	
 	/*Fetch data needed: */
-	iomodel->FetchData(9,ElementsEnum,ElementconnectivityEnum,UpperelementsEnum,LowerelementsEnum,
-				RheologyBEnum,RheologyNEnum,ControlTypeEnum,CmMinEnum,CmMaxEnum);
+	iomodel->FetchData(4,ElementsEnum,ElementconnectivityEnum,RheologyBEnum,RheologyNEnum);
+	if(dim==3)          iomodel->FetchData(2,UpperelementsEnum,LowerelementsEnum);
+	if(control_analysis)iomodel->FetchData(3,ControlTypeEnum,CmMinEnum,CmMaxEnum);
 	
 	/*Create elements and materials: */
 	for (i=0;i<numberofelements;i++){
-
 		if(iomodel->my_elements[i]){
 
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp	(revision 9373)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp	(revision 9374)
@@ -39,8 +39,4 @@
 	double *nodeonstokes   = NULL;
 	double *nodeonicesheet = NULL;
-	double *elements       = NULL;
-	double *spcvx          = NULL;
-	double *spcvy          = NULL;
-	double *spcvz          = NULL;
 	double *vertices_type  = NULL;
 	double *penalties      = NULL;
@@ -52,4 +48,6 @@
 	iomodel->constants->FindParam(&isstokes,IsstokesEnum);
 	iomodel->constants->FindParam(&ismacayealpattyn,IsmacayealpattynEnum);
+	iomodel->constants->FindParam(&numrifts,NumRiftsEnum);
+	iomodel->constants->FindParam(&numrifts,NumRiftsEnum);
 
 	/*Recover pointer: */
@@ -136,13 +134,9 @@
 	iomodel->FetchData(&nodeonicesheet,NULL,NULL,NodeOnIceSheetEnum);
 	iomodel->FetchData(&nodeonstokes,NULL,NULL,NodeOnStokesEnum);
-	iomodel->FetchData(&elements,NULL,NULL,ElementsEnum);
-	iomodel->FetchData(&spcvx,NULL,NULL,SpcvxEnum);
-	iomodel->FetchData(&spcvy,NULL,NULL,SpcvyEnum);
-	iomodel->FetchData(&spcvz,NULL,NULL,SpcvzEnum);
 	iomodel->FetchData(&vertices_type,NULL,NULL,VerticesTypeEnum);
+	iomodel->FetchData(1,ElementsEnum);
 	CreateSingleNodeToElementConnectivity(iomodel);
 	
 	for (i=0;i<numberofvertices;i++){
-		
 		if(iomodel->my_vertices[i]==1 && iomodel->singlenodetoelementconnectivity[i]!=0){
 
@@ -153,15 +147,11 @@
 				count++;
 			}
-		} //if((iomodel->my_vertices[i]==1))
+		}
 	}
-
 	xfree((void**)&nodeonbed);
 	xfree((void**)&nodeonstokes);
 	xfree((void**)&nodeonicesheet);
-	xfree((void**)&elements);
-	xfree((void**)&spcvx);
-	xfree((void**)&spcvy);
-	xfree((void**)&spcvz);
 	xfree((void**)&vertices_type);
+	iomodel->DeleteData(1,ElementsEnum);
 
 	/*Create Penpair for penalties: */
@@ -189,23 +179,14 @@
 
 	/*Create Riffront loads for rifts: */
-	iomodel->FetchData(&riftinfo,&numrifts,NULL,RiftinfoEnum);
-	iomodel->FetchData(&thickness,NULL,NULL,ThicknessEnum);
-	iomodel->FetchData(&bed,NULL,NULL,BedEnum);
-	iomodel->FetchData(&surface,NULL,NULL,SurfaceEnum);
-	iomodel->FetchData(&nodeoniceshelf,NULL,NULL,NodeOnIceShelfEnum);
-
-	for(i=0;i<numrifts;i++){
-		if(iomodel->my_elements[(int)*(riftinfo+RIFTINFOSIZE*i+2)-1]){
-			loads->AddObject(new Riftfront(iomodel->loadcounter+count+1,i,iomodel,DiagnosticHorizAnalysisEnum));
-			count++;
+	if(numrifts){
+		iomodel->FetchData(5,RiftinfoEnum,ThicknessEnum,BedEnum,SurfaceEnum,NodeOnIceShelfEnum);
+		for(i=0;i<numrifts;i++){
+			if(iomodel->my_elements[(int)(iomodel->f(RiftinfoEnum)[RIFTINFOSIZE*i+2])-1]){
+				loads->AddObject(new Riftfront(iomodel->loadcounter+count+1,i,iomodel,DiagnosticHorizAnalysisEnum));
+				count++;
+			}
 		}
+		iomodel->DeleteData(5,RiftinfoEnum,ThicknessEnum,BedEnum,SurfaceEnum,NodeOnIceShelfEnum);
 	}
-				
-	/*free ressources: */
-	xfree((void**)&riftinfo);
-	xfree((void**)&thickness);
-	xfree((void**)&bed);
-	xfree((void**)&surface);
-	xfree((void**)&nodeoniceshelf);
 
 	/*Assign output pointer: */
Index: /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp	(revision 9373)
+++ /issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateNodesDiagnosticHoriz.cpp	(revision 9374)
@@ -25,7 +25,11 @@
 
 	/*Fetch parameters: */
+	printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__); 
 	iomodel->constants->FindParam(&numberofvertices,NumberOfVerticesEnum);
+	printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__); 
 	iomodel->constants->FindParam(&isstokes,IsstokesEnum);
+	printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__); 
 	iomodel->constants->FindParam(&ismacayealpattyn,IsmacayealpattynEnum);
+	printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__); 
 
 	/*Recover pointer: */
@@ -42,9 +46,12 @@
 
 	/*Continuous Galerkin partition of nodes: */
+	printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__); 
 	NodesPartitioning(&iomodel->my_nodes,iomodel->my_elements,iomodel->my_vertices,iomodel,continuous_galerkin);
+	printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__); 
 
 	/*Create nodes: */
 	iomodel->FetchData(10,NodeOnBedEnum,NodeOnSurfaceEnum,NodeOnHutterEnum,NodeOnMacayealEnum,NodeOnStokesEnum,
 				NodeOnIceSheetEnum,NodeOnIceShelfEnum,NodeOnWaterEnum,VerticesTypeEnum,DiagnosticRefEnum);
+	printf("-------------- file: CreateNodesDiagnosticHoriz.cpp line: %i\n",__LINE__); 
 	
 	for (i=0;i<numberofvertices;i++){
Index: /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
===================================================================
--- /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	(revision 9373)
+++ /issm/trunk/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp	(revision 9374)
@@ -86,14 +86,13 @@
 
 	/*Deal with rifts, they have to be included into one partition only, not several: */
-	iomodel->FetchData(&riftinfo,&numrifts,NULL,RiftinfoEnum);
-
-	for(i=0;i<numrifts;i++){
-		el1=(int)*(riftinfo+RIFTINFOSIZE*i+2)-1; //matlab indexing to c indexing
-		el2=(int)*(riftinfo+RIFTINFOSIZE*i+3)-1; //matlab indexing to c indexing
-		epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices;
+	if(numrifts){
+		iomodel->FetchData(&riftinfo,&numrifts,NULL,RiftinfoEnum);
+		for(i=0;i<numrifts;i++){
+			el1=(int)*(riftinfo+RIFTINFOSIZE*i+2)-1; //matlab indexing to c indexing
+			el2=(int)*(riftinfo+RIFTINFOSIZE*i+3)-1; //matlab indexing to c indexing
+			epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices;
+		}
+		xfree((void**)&riftinfo); 
 	}
-
-	/*Free rifts: */
-	xfree((void**)&riftinfo); 
 
 	/*Used later on: */
Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 9373)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 9374)
@@ -5163,5 +5163,5 @@
 
 	double  yts;
-	int     control_analysis;
+	bool    control_analysis;
 	int     num_control_type;
 	int     num_cm_responses;
@@ -5183,5 +5183,4 @@
 	}
 
-	
 	/*Control Inputs*/
 	if (control_analysis && iomodel->f(ControlTypeEnum)){
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 9373)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 9374)
@@ -3276,10 +3276,4 @@
 	int    num_cm_responses;
    
-
-	/*Checks if debuging*/
-	/*{{{2*/
-	_assert_(iomodel->f(ElementEnum));
-	/*}}}*/
-
 	/*Get parameters: */
 	iomodel->constants->FindParam(&control_analysis,ControlAnalysisEnum);
Index: /issm/trunk/src/c/objects/IoModel.cpp
===================================================================
--- /issm/trunk/src/c/objects/IoModel.cpp	(revision 9373)
+++ /issm/trunk/src/c/objects/IoModel.cpp	(revision 9374)
@@ -92,5 +92,5 @@
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 
-	if(code!=1)_error_("%s%s","IoModel::FetchData expecting a boolean for enum ",EnumToStringx(data_enum));
+	if(code!=1)_error_("expecting a boolean for enum %s",EnumToStringx(data_enum));
 	
 	/*We have to read a boolean from disk. */
@@ -120,5 +120,5 @@
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 	
-	if(code!=2)_error_("%s%s","IoModel::FetchData expecting an integer for enum ",EnumToStringx(data_enum));
+	if(code!=2)_error_("expecting an integer for enum %s",EnumToStringx(data_enum));
 	
 	/*We have to read a integer from disk. First read the dimensions of the integer, then the integer: */
@@ -149,5 +149,5 @@
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 	
-	if(code!=3)_error_("%s%s","IoModel::FetchData expecting a double for enum ",EnumToStringx(data_enum));
+	if(code!=3)_error_("expecting a double for enum %s",EnumToStringx(data_enum));
 	
 	/*We have to read a scalar from disk. First read the dimensions of the scalar, then the scalar: */
@@ -177,5 +177,5 @@
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 	
-	if(code!=4)_error_("%s%s","IoModel::FetchData expecting a string for enum ",EnumToStringx(data_enum));
+	if(code!=4)_error_("expecting a string for enum %s",EnumToStringx(data_enum));
 	
 	/*Now fetch: */
@@ -227,5 +227,5 @@
 	fid=this->SetFilePointerToData(&code,&vector_type,data_enum);
 
-	if((code!=5) && (code!=6) && (code!=7))_error_("%s%s","IoModel::FetchData expecting a double, integer or boolean matrix for enum ",EnumToStringx(data_enum));
+	if((code!=5) && (code!=6) && (code!=7))_error_("expecting a double, integer or boolean matrix for enum %s",EnumToStringx(data_enum));
 	
 	/*Now fetch: */
@@ -290,10 +290,7 @@
 	int vector_type=0;
 	
-	
-	
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,&vector_type,data_enum);
-
-	if((code!=5) && (code!=6) && (code!=7))_error_("%s%s","IoModel::FetchData expecting a double, integer or boolean matrix for enum ",EnumToStringx(data_enum));
+	if((code!=5) && (code!=6) && (code!=7))_error_("expecting a double, integer or boolean matrix for enum %s",EnumToStringx(data_enum));
 	
 	/*Now fetch: */
@@ -304,5 +301,4 @@
 		if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix ");
 	}
-
 	MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 
 
@@ -320,5 +316,4 @@
 			if(fread(matrix,M*N*sizeof(double),1,fid)!=1) _error_("could not read matrix ");
 		}
-		
 		MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 
 	}
@@ -328,5 +323,4 @@
 	if (pM)*pM=M;
 	if (pN)*pN=N;
-
 }
 /*}}}*/
@@ -351,5 +345,5 @@
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
 	
-	if(code!=9)_error_("%s%s","IoModel::FetchData expecting a string array for enum ",EnumToStringx(data_enum));
+	if(code!=9)_error_("expecting a string array for enum %s",EnumToStringx(data_enum));
 	
 	/*We have to read a bunch of strings from disk. First read the number of strings, and allocate: */
@@ -410,14 +404,11 @@
 
 	/*intermediary: */
-	int M,N;
-	double* matrix=NULL;
-	
-	
-	int   code;
+	int     M, N;
+	double *matrix = NULL;
+	int     code;
 	
 	/*Set file pointer to beginning of the data: */
 	fid=this->SetFilePointerToData(&code,NULL,data_enum);
-	
-	if(code!=8)_error_("%s%s","IoModel::FetchData expecting a double mat  array for enum ",EnumToStringx(data_enum));
+	if(code!=8)_error_("expecting a double mat array for enum %s",EnumToStringx(data_enum));
 	
 	/*Now fetch: */
@@ -496,4 +487,8 @@
 		dataenum=va_arg(ap, int); _assert_(this->data->Exist(dataenum)==false);
 		this->FetchData(&matrix,&M,&N,dataenum);
+		if(M*N==0){
+			_error_("Cannot add %s to Iomodel->data because the matrix found is empty",EnumToStringx(dataenum));
+		}
+
 
 		/*Add to this->data: */
Index: /issm/trunk/src/c/objects/Materials/Matice.cpp
===================================================================
--- /issm/trunk/src/c/objects/Materials/Matice.cpp	(revision 9373)
+++ /issm/trunk/src/c/objects/Materials/Matice.cpp	(revision 9374)
@@ -656,5 +656,5 @@
 
 	int    dim;
-	int    control_analysis;
+	bool   control_analysis;
 	int    num_control_type;
 
@@ -663,5 +663,4 @@
 	iomodel->constants->FindParam(&control_analysis,ControlAnalysisEnum);
 	iomodel->constants->FindParam(&num_control_type,NumControlTypeEnum);
-
 
 	/*if 2d*/
