Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4803)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4804)
@@ -1055,4 +1055,9 @@
 	/*Scale: */
 	yinput->AXPY(xinput,scalar);
+
+	/*Move input to Material if required (needed if control method) TO BE IMPROVED*/
+	if (YEnum==RheologyBEnum){
+		this->matice->inputs->AddInput((Input*)yinput->copy());
+	}
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 4803)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 4804)
@@ -1434,4 +1434,10 @@
 	/*Scale: */
 	yinput->AXPY(xinput,scalar);
+
+	/*Move input to Material if required (needed if control method) TO BE IMPROVED*/
+	if (YEnum==RheologyBEnum){
+		this->matice->inputs->AddInput((Input*)yinput->copy());
+	}
+
 }
 /*}}}*/
Index: /issm/trunk/src/m/solutions/control_core.m
===================================================================
--- /issm/trunk/src/m/solutions/control_core.m	(revision 4803)
+++ /issm/trunk/src/m/solutions/control_core.m	(revision 4804)
@@ -57,5 +57,5 @@
 		scalar=search_scalar*optscal(n);
 		femmodel.elements=InputDuplicate(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,ControlParameterEnum,control_type);
-		femmodel.elements=InputAXPY(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,control_type,scalar,GradientEnum);
+		[femmodel.elements femmodel.materials]=InputAXPY(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,control_type,scalar,GradientEnum);
 
 		displaystring('\n%s',['      constraning the new distribution...']);
Index: /issm/trunk/src/m/solutions/objectivefunctionC.m
===================================================================
--- /issm/trunk/src/m/solutions/objectivefunctionC.m	(revision 4803)
+++ /issm/trunk/src/m/solutions/objectivefunctionC.m	(revision 4804)
@@ -25,5 +25,5 @@
 %Use search scalar to shoot parameter in the gradient direction:
 scalar=search_scalar*optscal;
-femmodel.elements=InputAXPY(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,control_type,scalar,GradientEnum);
+[femmodel.elements femmodel.materials]=InputAXPY(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,control_type,scalar,GradientEnum);
 
 %Constrain:
Index: /issm/trunk/src/mex/InputAXPY/InputAXPY.cpp
===================================================================
--- /issm/trunk/src/mex/InputAXPY/InputAXPY.cpp	(revision 4803)
+++ /issm/trunk/src/mex/InputAXPY/InputAXPY.cpp	(revision 4804)
@@ -45,4 +45,5 @@
 	/*write output : */
 	WriteData(ELEMENTSOUT,elements);
+	WriteData(MATERIALSOUT,materials);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InputAXPY/InputAXPY.h
===================================================================
--- /issm/trunk/src/mex/InputAXPY/InputAXPY.h	(revision 4803)
+++ /issm/trunk/src/mex/InputAXPY/InputAXPY.h	(revision 4804)
@@ -29,8 +29,9 @@
 /* serial output macros: */
 #define ELEMENTSOUT (mxArray**)&plhs[0]
+#define MATERIALSOUT (mxArray**)&plhs[1]
 
 /* serial arg counts: */
 #undef NLHS
-#define NLHS  1
+#define NLHS  2
 #undef NRHS
 #define NRHS  9
