Index: /issm/trunk/src/c/EnumDefinitions/EnumAsString.cpp
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumAsString.cpp	(revision 4531)
+++ /issm/trunk/src/c/EnumDefinitions/EnumAsString.cpp	(revision 4532)
@@ -249,4 +249,7 @@
 		case RhoWaterEnum : return "RhoWater";
 		case GravityEnum : return "Gravity";
+		case ThermalConductivityEnum : return "ThermalConductivity";
+		case MixedLayerCapacityEnum : return "MixedLayerCapacity";
+		case ThermalExchangeVelocityEnum : return "ThermalExchangeVelocity";
 		case BetaEnum : return "Beta";
 		case CmGradientEnum : return "CmGradient";
Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 4531)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 4532)
@@ -285,4 +285,7 @@
 	RhoWaterEnum,
 	GravityEnum,
+	ThermalConductivityEnum,
+	MixedLayerCapacityEnum,
+	ThermalExchangeVelocityEnum,
 	/*}}}*/
 	/*Parameters{{{1*/
Index: /issm/trunk/src/c/EnumDefinitions/StringAsEnum.cpp
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/StringAsEnum.cpp	(revision 4531)
+++ /issm/trunk/src/c/EnumDefinitions/StringAsEnum.cpp	(revision 4532)
@@ -247,4 +247,7 @@
 	else if (strcmp(name,"RhoWater")==0) return RhoWaterEnum;
 	else if (strcmp(name,"Gravity")==0) return GravityEnum;
+	else if (strcmp(name,"ThermalConductivity")==0) return ThermalConductivityEnum;
+	else if (strcmp(name,"MixedLayerCapacity")==0) return MixedLayerCapacityEnum;
+	else if (strcmp(name,"ThermalExchangeVelocity")==0) return ThermalExchangeVelocityEnum;
 	else if (strcmp(name,"Beta")==0) return BetaEnum;
 	else if (strcmp(name,"CmGradient")==0) return CmGradientEnum;
Index: /issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp
===================================================================
--- /issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp	(revision 4531)
+++ /issm/trunk/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp	(revision 4532)
@@ -29,4 +29,9 @@
 		load->InputUpdateFromConstant(constant,name);
 	}
+	
+	for(i=0;i<materials->Size();i++){
+		Material* material=(Material*)materials->GetObjectByOffset(i);
+		material->InputUpdateFromConstant(constant,name);
+	}
 }
 void InputUpdateFromConstantx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,int    constant, int name){
@@ -49,4 +54,9 @@
 		Load* load=(Load*)loads->GetObjectByOffset(i);
 		load->InputUpdateFromConstant(constant,name);
+	}
+	
+	for(i=0;i<materials->Size();i++){
+		Material* material=(Material*)materials->GetObjectByOffset(i);
+		material->InputUpdateFromConstant(constant,name);
 	}
 }
@@ -71,3 +81,9 @@
 		load->InputUpdateFromConstant(constant,name);
 	}
+	
+	for(i=0;i<materials->Size();i++){
+		Material* material=(Material*)materials->GetObjectByOffset(i);
+		material->InputUpdateFromConstant(constant,name);
+	}
+
 }
Index: /issm/trunk/src/c/objects/Elements/Beam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Beam.cpp	(revision 4531)
+++ /issm/trunk/src/c/objects/Elements/Beam.cpp	(revision 4532)
@@ -550,7 +550,4 @@
 	const int numgrids=2;
 	double  gaussgrids[numgrids][2]={{0,1},{1,0}};
-	double  vx_values[numgrids];
-	double  vy_values[numgrids];
-	double  vz_values[numgrids];
 	double  vel_values[numgrids];
 	double  maxvel;
@@ -560,15 +557,5 @@
 
 	/*retrive velocity values at nodes */
-	inputs->GetParameterValues(&vx_values[0],&gaussgrids[0][0],numgrids,VxEnum);
-	inputs->GetParameterValues(&vy_values[0],&gaussgrids[0][0],numgrids,VyEnum);
-	if(dim==3) inputs->GetParameterValues(&vz_values[0],&gaussgrids[0][0],numgrids,VzEnum);
-
-	/*now, compute maximum of velocity :*/
-	if(dim==2){
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2));
-	}
-	else{
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2)+pow(vz_values[i],2));
-	}
+	inputs->GetParameterValues(&vel_values[0],&gaussgrids[0][0],numgrids,VelEnum);
 
 	/*now, compute maximum:*/
@@ -671,7 +658,4 @@
 	const int numgrids=2;
 	double  gaussgrids[numgrids][2]={{0,1},{1,0}};
-	double  vx_values[numgrids];
-	double  vy_values[numgrids];
-	double  vz_values[numgrids];
 	double  vel_values[numgrids];
 	double  minvel;
@@ -681,15 +665,5 @@
 
 	/*retrive velocity values at nodes */
-	inputs->GetParameterValues(&vx_values[0],&gaussgrids[0][0],numgrids,VxEnum);
-	inputs->GetParameterValues(&vy_values[0],&gaussgrids[0][0],numgrids,VyEnum);
-	if(dim==3) inputs->GetParameterValues(&vz_values[0],&gaussgrids[0][0],numgrids,VzEnum);
-
-	/*now, compute minimum of velocity :*/
-	if(dim==2){
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2));
-	}
-	else{
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2)+pow(vz_values[i],2));
-	}
+	inputs->GetParameterValues(&vel_values[0],&gaussgrids[0][0],numgrids,VelEnum);
 
 	/*now, compute minimum:*/
Index: /issm/trunk/src/c/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4531)
+++ /issm/trunk/src/c/objects/Elements/Penta.cpp	(revision 4532)
@@ -1309,7 +1309,4 @@
 	const int numgrids=6;
 	double  gaussgrids[numgrids][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
-	double  vx_values[numgrids];
-	double  vy_values[numgrids];
-	double  vz_values[numgrids];
 	double  vel_values[numgrids];
 	double  maxvel;
@@ -1319,15 +1316,5 @@
 
 	/*retrive velocity values at nodes */
-	inputs->GetParameterValues(&vx_values[0],&gaussgrids[0][0],numgrids,VxEnum);
-	inputs->GetParameterValues(&vy_values[0],&gaussgrids[0][0],numgrids,VyEnum);
-	if(dim==3) inputs->GetParameterValues(&vz_values[0],&gaussgrids[0][0],numgrids,VzEnum);
-
-	/*now, compute maximum of velocity :*/
-	if(dim==2){
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2));
-	}
-	else{
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2)+pow(vz_values[i],2));
-	}
+	inputs->GetParameterValues(&vel_values[0],&gaussgrids[0][0],numgrids,VelEnum);
 
 	/*now, compute maximum:*/
@@ -1430,7 +1417,4 @@
 	const int numgrids=6;
 	double  gaussgrids[numgrids][4]={{1,0,0,-1},{0,1,0,-1},{0,0,1,-1},{1,0,0,1},{0,1,0,1},{0,0,1,1}};
-	double  vx_values[numgrids];
-	double  vy_values[numgrids];
-	double  vz_values[numgrids];
 	double  vel_values[numgrids];
 	double  minvel;
@@ -1440,15 +1424,5 @@
 
 	/*retrive velocity values at nodes */
-	inputs->GetParameterValues(&vx_values[0],&gaussgrids[0][0],numgrids,VxEnum);
-	inputs->GetParameterValues(&vy_values[0],&gaussgrids[0][0],numgrids,VyEnum);
-	if(dim==3) inputs->GetParameterValues(&vz_values[0],&gaussgrids[0][0],numgrids,VzEnum);
-
-	/*now, compute minimum of velocity :*/
-	if(dim==2){
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2));
-	}
-	else{
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2)+pow(vz_values[i],2));
-	}
+	inputs->GetParameterValues(&vel_values[0],&gaussgrids[0][0],numgrids,VelEnum);
 
 	/*now, compute minimum:*/
Index: /issm/trunk/src/c/objects/Elements/Sing.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Sing.cpp	(revision 4531)
+++ /issm/trunk/src/c/objects/Elements/Sing.cpp	(revision 4532)
@@ -489,21 +489,11 @@
 
 	int dim;
-	double  vx;
-	double  vy;
-	double  vz;
 	double  maxvel;
 
-	/*retrive velocity values at nodes */
-	inputs->GetParameterValue(&vx,VxEnum);
-	inputs->GetParameterValue(&vy,VyEnum);
-	if(dim==3)inputs->GetParameterValue(&vz,VzEnum);
-
-	/*now, compute maximum of velocity :*/
-	if(dim==2){
-		maxvel=sqrt(pow(vx,2)+pow(vy,2));
-	}
-	else{
-		maxvel=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2));
-	}
+	/*retrieve dim parameter: */
+	parameters->FindParam(&dim,DimEnum);
+
+	/*retrive velocity values at nodes */
+	inputs->GetParameterValue(&maxvel,VelEnum);
 
 	/*Assign output pointers:*/
@@ -567,21 +557,11 @@
 
 	int dim;
-	double  vx;
-	double  vy;
-	double  vz;
 	double  minvel;
 
-	/*retrive velocity values at nodes */
-	inputs->GetParameterValue(&vx,VxEnum);
-	inputs->GetParameterValue(&vy,VyEnum);
-	if(dim==3)inputs->GetParameterValue(&vz,VzEnum);
-
-	/*now, compute minimum of velocity :*/
-	if(dim==2){
-		minvel=sqrt(pow(vx,2)+pow(vy,2));
-	}
-	else{
-		minvel=sqrt(pow(vx,2)+pow(vy,2)+pow(vz,2));
-	}
+	/*retrieve dim parameter: */
+	parameters->FindParam(&dim,DimEnum);
+
+	/*retrive velocity values at nodes */
+	inputs->GetParameterValue(&minvel,VelEnum);
 
 	/*Assign output pointers:*/
Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 4531)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 4532)
@@ -1658,8 +1658,5 @@
 	int dim;
 	const int numgrids=3;
-	double  gaussgrids[numgrids][3]={{1,0,0},{0,1,0},{0,0,1}};
-	double  vx_values[numgrids];
-	double  vy_values[numgrids];
-	double  vz_values[numgrids];
+	double  gaussgrids[numgrids][numgrids]={{1,0,0},{0,1,0},{0,0,1}};
 	double  vel_values[numgrids];
 	double  maxvel;
@@ -1669,15 +1666,5 @@
 
 	/*retrive velocity values at nodes */
-	inputs->GetParameterValues(&vx_values[0],&gaussgrids[0][0],numgrids,VxEnum);
-	inputs->GetParameterValues(&vy_values[0],&gaussgrids[0][0],numgrids,VyEnum);
-	if(dim==3) inputs->GetParameterValues(&vz_values[0],&gaussgrids[0][0],numgrids,VzEnum);
-
-	/*now, compute maximum of velocity :*/
-	if(dim==2){
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2));
-	}
-	else{
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2)+pow(vz_values[i],2));
-	}
+	inputs->GetParameterValues(&vel_values[0],&gaussgrids[0][0],numgrids,VelEnum);
 
 	/*now, compute maximum:*/
@@ -1779,8 +1766,5 @@
 	int dim;
 	const int numgrids=3;
-	double  gaussgrids[numgrids][3]={{1,0,0},{0,1,0},{0,0,1}};
-	double  vx_values[numgrids];
-	double  vy_values[numgrids];
-	double  vz_values[numgrids];
+	double  gaussgrids[numgrids][numgrids]={{1,0,0},{0,1,0},{0,0,1}};
 	double  vel_values[numgrids];
 	double  minvel;
@@ -1790,15 +1774,5 @@
 
 	/*retrive velocity values at nodes */
-	inputs->GetParameterValues(&vx_values[0],&gaussgrids[0][0],numgrids,VxEnum);
-	inputs->GetParameterValues(&vy_values[0],&gaussgrids[0][0],numgrids,VyEnum);
-	if(dim==3) inputs->GetParameterValues(&vz_values[0],&gaussgrids[0][0],numgrids,VzEnum);
-
-	/*now, compute minimum of velocity :*/
-	if(dim==2){
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2));
-	}
-	else{
-		for(i=0;i<numgrids;i++)vel_values[i]=sqrt(pow(vx_values[i],2)+pow(vy_values[i],2)+pow(vz_values[i],2));
-	}
+	inputs->GetParameterValues(&vel_values[0],&gaussgrids[0][0],numgrids,VelEnum);
 
 	/*now, compute minimum:*/
Index: /issm/trunk/src/c/objects/Materials/Matpar.cpp
===================================================================
--- /issm/trunk/src/c/objects/Materials/Matpar.cpp	(revision 4531)
+++ /issm/trunk/src/c/objects/Materials/Matpar.cpp	(revision 4532)
@@ -220,4 +220,76 @@
 /*}}}1*/
 
+/*Update virtual functions definitions:*/
+/*FUNCTION Matpar::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
+void   Matpar::InputUpdateFromVector(double* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matpar::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
+void   Matpar::InputUpdateFromVector(int* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matpar::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
+void   Matpar::InputUpdateFromVector(bool* vector, int name, int type){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matpar::InputUpdateFromConstant(double constant, int name) {{{1*/
+void   Matpar::InputUpdateFromConstant(double constant, int name){
+
+	switch(name){
+		case RhoIceEnum:
+			this->rho_ice=constant;
+
+		case  RhoWaterEnum:
+			this->rho_water=constant;
+
+		case  HeatCapacityEnum:
+			this->heatcapacity=constant;
+
+		case  ThermalConductivityEnum:
+			this->thermalconductivity=constant;
+
+		case  LatentHeatEnum:
+			this->latentheat=constant;
+
+		case  BetaEnum:
+			this->beta=constant;
+
+		case  MeltingPointEnum:
+			this->meltingpoint=constant;
+
+		case  MixedLayerCapacityEnum:
+			this->mixed_layer_capacity=constant;
+
+		case  ThermalExchangeVelocityEnum:
+			this->thermalconductivity=constant;
+
+		case  GravityEnum:
+			this->g=constant;
+
+		default: 
+			break;
+	}
+
+}
+/*}}}*/
+/*FUNCTION Matpar::InputUpdateFromConstant(int constant, int name) {{{1*/
+void   Matpar::InputUpdateFromConstant(int constant, int name){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matpar::InputUpdateFromConstant(bool constant, int name) {{{1*/
+void   Matpar::InputUpdateFromConstant(bool constant, int name){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+/*FUNCTION Matpar::InputUpdateFromSolution(double* solution) {{{1*/
+void   Matpar::InputUpdateFromSolution(double* solution){
+	/*Nothing updated yet*/
+}
+/*}}}*/
+
 /*Matpar management: */
 /*FUNCTION Matpar::GetBeta {{{1*/
@@ -272,37 +344,4 @@
 }
 /*}}}1*/
-/*FUNCTION Matpar::InputUpdateFromVector(double* vector, int name, int type) {{{1*/
-void   Matpar::InputUpdateFromVector(double* vector, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matpar::InputUpdateFromVector(int* vector, int name, int type) {{{1*/
-void   Matpar::InputUpdateFromVector(int* vector, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matpar::InputUpdateFromVector(bool* vector, int name, int type) {{{1*/
-void   Matpar::InputUpdateFromVector(bool* vector, int name, int type){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matpar::InputUpdateFromConstant(double constant, int name) {{{1*/
-void   Matpar::InputUpdateFromConstant(double constant, int name){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matpar::InputUpdateFromConstant(int constant, int name) {{{1*/
-void   Matpar::InputUpdateFromConstant(int constant, int name){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matpar::InputUpdateFromConstant(bool constant, int name) {{{1*/
-void   Matpar::InputUpdateFromConstant(bool constant, int name){
-	/*Nothing updated yet*/
-}
-/*}}}*/
-/*FUNCTION Matpar::InputUpdateFromSolution(double* solution) {{{1*/
-void   Matpar::InputUpdateFromSolution(double* solution){
-	/*Nothing updated yet*/
-}
-/*}}}*/
+
+
Index: /issm/trunk/src/m/solutions/SpawnCore.m
===================================================================
--- /issm/trunk/src/m/solutions/SpawnCore.m	(revision 4531)
+++ /issm/trunk/src/m/solutions/SpawnCore.m	(revision 4532)
@@ -11,8 +11,10 @@
 solution_type=femmodel.parameters.SolutionType;
 
+
 displaystring(1,'%s%i',['   qmu iteration:'],counter);
 
 %first update the inputs to the femmodel using the variables provided to us by dakota.
-[femmodel.elements femmodel.loads]=InputUpdateFromDakota(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,femmodel.part,variables,variabledescriptors);
+[femmodel.elements femmodel.loads femmodel.materials]=InputUpdateFromDakota(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,femmodel.part,variables,variabledescriptors);
+Echo(femmodel.materials)
 
 %now run the core solution
@@ -22,2 +24,6 @@
 %now process the results to get response function values
 responses=DakotaResponses(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,responsedescriptors);
+
+format long 
+variables
+responses
Index: /issm/trunk/src/mex/DakotaResponses/DakotaResponses.cpp
===================================================================
--- /issm/trunk/src/mex/DakotaResponses/DakotaResponses.cpp	(revision 4531)
+++ /issm/trunk/src/mex/DakotaResponses/DakotaResponses.cpp	(revision 4532)
@@ -65,9 +65,10 @@
 	delete parameters;
 	
-	xfree((void**)&responses);
 	for(i=0;i<numresponses;i++){
 		char* string=responses_descriptors[i]; xfree((void**)&string);
 	}
 	xfree((void**)&responses_descriptors);
+	
+	//xfree((void**)&responses); do not free responses!
 
 	/*end module: */
Index: /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp
===================================================================
--- /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp	(revision 4531)
+++ /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp	(revision 4532)
@@ -59,4 +59,5 @@
 	WriteData(ELEMENTS,elements);
 	WriteData(LOADS,loads);
+	WriteData(MATERIALS,materials);
 
 	/*Free ressources: */
Index: /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.h
===================================================================
--- /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.h	(revision 4531)
+++ /issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.h	(revision 4532)
@@ -31,8 +31,9 @@
 #define ELEMENTS (mxArray**)&plhs[0]
 #define LOADS (mxArray**)&plhs[1]
+#define MATERIALS (mxArray**)&plhs[2]
 
 /* serial arg counts: */
 #undef NLHS
-#define NLHS  2
+#define NLHS  3
 #undef NRHS
 #define NRHS  9
Index: /issm/trunk/test/Verification/test25_IceSheetIceFrontM2dDakota/Square.par
===================================================================
--- /issm/trunk/test/Verification/test25_IceSheetIceFrontM2dDakota/Square.par	(revision 4531)
+++ /issm/trunk/test/Verification/test25_IceSheetIceFrontM2dDakota/Square.par	(revision 4532)
@@ -42,5 +42,5 @@
 %Dakota options
 md.variables.nuv=normal_uncertain.empty();
-md.variables.nuv(end+1)=normal_uncertain('RhoIce',1,0.01);
+md.variables.nuv(end+1)=normal_uncertain('RhoIce',md.rho_ice,0.01);
 md.variables.nuv(end+1)=normal_uncertain('DragCoefficient',1,0.01);
 
