Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 5249)
+++ /issm/trunk/src/c/Makefile.am	(revision 5250)
@@ -525,4 +525,6 @@
 					./modules/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp\
 					./modules/PenaltySystemMatricesx/PenaltySystemMatricesx.h\
+					./modules/Responsex/Responsex.h\
+					./modules/Responsex/Responsex.cpp\
 					./modules/Scotchx/Scotchx.cpp\
 					./modules/Scotchx/Scotchx.h\
@@ -1052,4 +1054,6 @@
 					./modules/PenaltySystemMatricesx/PenaltySystemMatricesx.cpp\
 					./modules/PenaltySystemMatricesx/PenaltySystemMatricesx.h\
+					./modules/Responsex/Responsex.h\
+					./modules/Responsex/Responsex.cpp\
 					./modules/Solverx/Solverx.cpp\
 					./modules/Solverx/Solverx.h\
Index: /issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp
===================================================================
--- /issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp	(revision 5249)
+++ /issm/trunk/src/c/modules/DakotaResponsesx/DakotaResponsesx.cpp	(revision 5250)
@@ -35,80 +35,5 @@
 
 		/*Compute response for this response_descriptor:*/
-
-		if(strcmp(response_descriptor,"MinVel")==0){
-			MinVelx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"MaxVel")==0){
-			MaxVelx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"MinVx")==0){
-			MinVxx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"MaxVx")==0){
-			MaxVxx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"MaxAbsVx")==0){
-			MaxAbsVxx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"MinVy")==0){
-			MinVyx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"MaxVy")==0){
-			MaxVyx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"MaxAbsVy")==0){
-			MaxAbsVyx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"MinVz")==0){
-			MinVzx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"MaxVz")==0){
-			MaxVzx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"MaxAbsVz")==0){
-			MaxAbsVzx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strcmp(response_descriptor,"Misfit")==0){
-			Misfitx( &femmodel_response, elements,nodes, vertices, loads, materials, parameters,process_units);
-		}
-		else if(strlen(response_descriptor)>=8){
-			if(strncmp(response_descriptor,"MassFlux",8)==0){
-
-				/*Deal with several mass flux computations: {{{1*/
-				double** array=NULL;
-				int      M;
-				int*     mdims_array=NULL;
-				int*     ndims_array=NULL;
-
-				double*  segments=NULL;
-				int      num_segments;
-
-				/*retrieve qmu_mass_flux_segments: */
-				parameters->FindParam(&array,&M,&mdims_array,&ndims_array,QmuMassFluxSegmentsEnum);
-	
-				/*figure out counter after MassFlux: */
-				sscanf(response_descriptor,"MassFlux%i",&counter);
-
-				/*retrieve segments from array: */
-				segments=array[counter-1]; //matlab to "C" indexing
-				num_segments=mdims_array[counter-1];
-
-				/*call mass flux module: */
-				MassFluxx(&femmodel_response,elements,nodes,vertices,loads,materials,parameters,segments,num_segments,process_units);
-
-				/*Free ressources:*/
-				for(j=0;j<M;j++){
-					double* matrix=array[j];
-					xfree((void**)&matrix);
-				}
-				xfree((void**)&mdims_array);
-				xfree((void**)&ndims_array);
-				xfree((void**)&array);
-				/*}}}*/
-			}
-		}
-		else{
-			ISSMERROR("%s%s%s"," response descriptor : ",response_descriptor," not supported yet!");
-		}
+		Responsex(&femmodel_response,elements,nodes, vertices,loads,materials, parameters,response_descriptor,process_units);
 
 		#ifdef _DEBUG_
Index: /issm/trunk/src/c/modules/MassFluxx/MassFluxx.cpp
===================================================================
--- /issm/trunk/src/c/modules/MassFluxx/MassFluxx.cpp	(revision 5249)
+++ /issm/trunk/src/c/modules/MassFluxx/MassFluxx.cpp	(revision 5250)
@@ -10,5 +10,5 @@
 #include "../../EnumDefinitions/EnumDefinitions.h"
 
-void MassFluxx(double* pmass_flux, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,  double* segments,int num_segments,bool process_units){
+void MassFluxx(double* pmass_flux, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,char* descriptor,bool process_units){
 
 	int i,j;
@@ -23,7 +23,28 @@
 	double all_mass_flux=0;
 
+	int  counter;
+
+	/*all segments: */
+	double** array=NULL;
+	int      M;
+	int*     mdims_array=NULL;
+	int*     ndims_array=NULL;
+
+	/*our segments of interest: */
+	double*  segments=NULL;
+	int      num_segments;
+
+	/*First, figure out which segment to compute our mass flux on. Start with retrieving qmu_mass_flux_segments: */
+	parameters->FindParam(&array,&M,&mdims_array,&ndims_array,QmuMassFluxSegmentsEnum);
+
+	/*figure out counter in the descriptor: */
+	sscanf(descriptor,"MassFlux%i",&counter);
+
+	/*retrieve segments from array: */
+	segments=array[counter-1]; //matlab to "C" indexing
+	num_segments=mdims_array[counter-1];
+
 	/*Go through segments, and then elements, and figure out which elements belong to a segment. 
 	 * When we find one, use the element to compute the mass flux on the segment: */
-
 	for(i=0;i<num_segments;i++){
 		element_id=(int)*(segments+5*i+4);
@@ -43,4 +64,13 @@
 	#endif
 
+	/*Free ressources:*/
+	for(j=0;j<M;j++){
+		double* matrix=array[j];
+		xfree((void**)&matrix);
+	}
+	xfree((void**)&mdims_array);
+	xfree((void**)&ndims_array);
+	xfree((void**)&array);
+
 	/*Assign output pointers: */
 	*pmass_flux=mass_flux;
Index: /issm/trunk/src/c/modules/MassFluxx/MassFluxx.h
===================================================================
--- /issm/trunk/src/c/modules/MassFluxx/MassFluxx.h	(revision 5249)
+++ /issm/trunk/src/c/modules/MassFluxx/MassFluxx.h	(revision 5250)
@@ -10,5 +10,5 @@
 
 /* local prototypes: */
-void MassFluxx(double* pmass_flux, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double* segments,int num_segments,bool process_units);
+void MassFluxx(double* pmass_flux, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,char* descriptor,bool process_units);
 
 
Index: /issm/trunk/src/c/modules/Responsex/Responsex.cpp
===================================================================
--- /issm/trunk/src/c/modules/Responsex/Responsex.cpp	(revision 5250)
+++ /issm/trunk/src/c/modules/Responsex/Responsex.cpp	(revision 5250)
@@ -0,0 +1,62 @@
+/*!\file Responsex
+ * \brief: compute response according to a response descriptor
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../../Container/Container.h"    
+#include "../../shared/shared.h"
+#include "../../include/include.h"
+#include "../../EnumDefinitions/EnumDefinitions.h"
+#include "../../toolkits/toolkits.h"
+#include "../modules.h"
+
+void Responsex(double* presponse,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,char* response_descriptor,bool process_units){
+
+	if(strcmp(response_descriptor,"MinVel")==0){
+		MinVelx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"MaxVel")==0){
+		MaxVelx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"MinVx")==0){
+		MinVxx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"MaxVx")==0){
+		MaxVxx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"MaxAbsVx")==0){
+		MaxAbsVxx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"MinVy")==0){
+		MinVyx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"MaxVy")==0){
+		MaxVyx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"MaxAbsVy")==0){
+		MaxAbsVyx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"MinVz")==0){
+		MinVzx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"MaxVz")==0){
+		MaxVzx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"MaxAbsVz")==0){
+		MaxAbsVzx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strcmp(response_descriptor,"Misfit")==0){
+		Misfitx( presponse, elements,nodes, vertices, loads, materials, parameters,process_units);
+	}
+	else if(strlen(response_descriptor)>=8){
+		if(strncmp(response_descriptor,"MassFlux",8)==0) MassFluxx(presponse,elements,nodes,vertices,loads,materials,parameters,response_descriptor,process_units);
+	}
+	else{
+		ISSMERROR("%s%s%s"," response descriptor : ",response_descriptor," not supported yet!");
+	}
+}
Index: /issm/trunk/src/c/modules/Responsex/Responsex.h
===================================================================
--- /issm/trunk/src/c/modules/Responsex/Responsex.h	(revision 5250)
+++ /issm/trunk/src/c/modules/Responsex/Responsex.h	(revision 5250)
@@ -0,0 +1,13 @@
+/*!\file:  Responsesx.h
+ * \brief header file for computing dakota responses
+ */ 
+
+#ifndef _RESPONSESX_H
+#define _RESPONSESX_H
+
+#include "../../objects/objects.h"
+#include "../../Container/Container.h"
+
+void Responsex(double* presponse,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,char* response_descriptor,bool process_units);
+
+#endif  /* _RESPONSESXX_H */
Index: /issm/trunk/src/c/modules/modules.h
===================================================================
--- /issm/trunk/src/c/modules/modules.h	(revision 5249)
+++ /issm/trunk/src/c/modules/modules.h	(revision 5250)
@@ -70,4 +70,5 @@
 #include "./Reducevectorgtosx/Reducevectorgtosx.h"
 #include "./Reducevectorgtofx/Reducevectorgtofx.h"
+#include "./Responsex/Responsex.h"
 #include "./Scotchx/Scotchx.h"
 #include "./Solverx/Solverx.h"
Index: /issm/trunk/src/m/classes/public/parameterization/parametercontrolB.m
===================================================================
--- /issm/trunk/src/m/classes/public/parameterization/parametercontrolB.m	(revision 5249)
+++ /issm/trunk/src/m/classes/public/parameterization/parametercontrolB.m	(revision 5250)
@@ -22,5 +22,5 @@
 
 %control type
-md.control_type='B';
+md.control_type='rheology_B';
 
 %weights
