Index: /issm/trunk-jpl/src/c/classes/Elements/Element.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 25255)
+++ /issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 25256)
@@ -280,4 +280,5 @@
 		virtual void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int rows, int ncols, int name, int type)=0;
 		virtual void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type)=0;
+		virtual void  InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name)=0;
 		#endif
 		virtual void  InputUpdateFromIoModel(int index, IoModel* iomodel)=0;
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 25255)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 25256)
@@ -4707,4 +4707,99 @@
 
 #ifdef _HAVE_DAKOTA_
+void       Penta::InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name){/*{{{*/
+
+	int interp;
+	int type;
+	
+	/*Branch according to whether we have a transient or not input: */
+	type=this->inputs2->GetInputObjectEnum(name);
+	if(type==PentaInput2Enum){
+		/*Figure out if we are P0 or P1 interpolation: */
+		PentaInput2* pentainput = this->inputs2->GetPentaInput(name);
+		PentaInput2* pentainput2 = this->inputs2->GetPentaInput(DummyEnum);
+		interp=pentainput->GetInterpolation();
+		
+		if (interp==P0Enum){
+			/*Update the value if this element belongs to the partition: */
+			if(partition[this->Sid()]!=-1){
+				int lid=this->lid; pentainput->Serve(1,&lid);
+				/*scale P0 value  for this element, corresponding to the partition:*/
+				IssmDouble value = pentainput->element_values[0];
+				value*=distributed_values[(int)partition[this->Sid()]];
+				pentainput2->SetInput(P0Enum,this->lid,value);
+			}
+		}
+		else if (interp==P1Enum){
+			IssmDouble values[NUMVERTICES];
+			int lidlist[NUMVERTICES];
+			this->GetVerticesLidList(&lidlist[0]);
+			pentainput->Serve(NUMVERTICES,&lidlist[0]);
+			for (int i=0;i<NUMVERTICES;i++){
+				values[i]=pentainput->element_values[i];
+				if(partition[this->vertices[i]->Sid()]!=-1) values[i]*=distributed_values[(int)partition[this->vertices[i]->Sid()]];
+			}
+			pentainput2->SetInput(P1Enum,NUMVERTICES,&lidlist[0],&values[0]);
+		}
+		else _error_("Penta::InputScaleFromDakota error message: input interpolation " << EnumToStringx(interp) << " not supported yet!");
+	}
+	else if(type==TransientInput2Enum){
+
+
+		IssmDouble* steps=NULL;
+		int nsteps;
+		TransientInput2* transientinput = NULL;
+		TransientInput2* transientinput2 = NULL;
+
+		/*retrieve transient input:*/
+		transientinput= this->inputs2->GetTransientInput(name);
+		transientinput2= this->inputs2->GetTransientInput(DummyEnum);
+
+		/*retrieve time steps: */
+		transientinput->GetAllTimes(&steps,&nsteps);
+
+		/*double check:*/
+		if (nsteps!=nt && nt!=1) _error_("Penta:InputScaleFromDakota error message: transient input " << EnumToStringx(name) <<  
+				" should have the same number of time steps as the number of time values distributed by Dakota: " << nt << "\n");
+
+		/*needed to update inputs:*/
+		int lidlist[NUMVERTICES];
+		this->GetVerticesLidList(&lidlist[0]);
+
+		/*go through the transient inputs, and update:*/
+		for (int i=0;i<nsteps;i++){
+			PentaInput2* pentainput=transientinput->GetPentaInput(i);
+			PentaInput2* pentainput2=transientinput2->GetPentaInput(i);
+			interp=pentainput->GetInterpolation();
+
+			if (interp==P0Enum){
+				/*Update the value if this element belongs to the partition: */
+				if(partition[this->Sid()]!=-1){
+					int lid=this->lid; pentainput->Serve(1,&lid);
+					/*scale P0 value  for this element, corresponding to the partition:*/
+					IssmDouble value = pentainput->element_values[0];
+					if(nt==1) value*=distributed_values[(int)partition[this->Sid()]]; //we scale all the time steps  with the same distributed_value 
+					else value*=distributed_values[(int)partition[this->Sid()]*nsteps+i]; //we scale all the time steps with distributed value for each step
+
+					pentainput2->SetInput(P0Enum,this->lid,value);
+				}
+			}
+			else if (interp==P1Enum){
+				IssmDouble values[NUMVERTICES];
+				pentainput->Serve(NUMVERTICES,&lidlist[0]);
+				for (int j=0;j<NUMVERTICES;j++){
+					values[j]=pentainput->element_values[j];
+					if(partition[this->vertices[i]->Sid()]!=-1){
+						if(nt==1) values[j]*=distributed_values[(int)partition[this->vertices[j]->Sid()]];//we scale all the time steps  with the same distributed_value 
+						else values[j]*=distributed_values[(int)partition[this->vertices[j]->Sid()]*nsteps+i];//we scale all the time steps with distributed value for each step
+					}
+				}
+				pentainput2->SetInput(P1Enum,NUMVERTICES,&lidlist[0],&values[0]);
+			}
+			else _error_("Penta::InputScaleFromDakota error message: input interpolation " << EnumToStringx(interp) << " not supported yet!");
+		}
+	}
+	else _error_("Penta::InputScaleFromDakota error message: input type " << EnumToStringx(name) << " not supported yet!");
+}
+/*}}}*/
 void       Penta::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*{{{*/
 
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 25255)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 25256)
@@ -200,6 +200,8 @@
 
 		#ifdef _HAVE_DAKOTA_
-		void           InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);
-		void           InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
+		void  InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name);
+
 		#endif
 
Index: /issm/trunk-jpl/src/c/classes/Elements/Seg.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 25255)
+++ /issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 25256)
@@ -182,6 +182,8 @@
 
 #ifdef _HAVE_DAKOTA_
-		void        InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};
-		void        InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};
+		void  InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name){_error_("not implemented yet!");}
+;
 #endif
 		/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/Tetra.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 25255)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 25256)
@@ -188,6 +188,7 @@
 
 #ifdef _HAVE_DAKOTA_
-		void        InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};
-		void        InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};
+		void  InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name){_error_("not implemented yet!");}
 #endif
 		/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 25255)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 25256)
@@ -6021,4 +6021,97 @@
 
 #ifdef _HAVE_DAKOTA_
+void       Tria::InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name){/*{{{*/
+
+	int interp;
+	int type;
+	
+	/*Branch according to whether we have a transient or not input: */
+	type=this->inputs2->GetInputObjectEnum(name);
+	if(type==TriaInput2Enum){
+		/*Figure out if we are P0 or P1 interpolation: */
+		TriaInput2* triainput = this->inputs2->GetTriaInput(name);
+		TriaInput2* triainput2 = this->inputs2->GetTriaInput(DummyEnum);
+		this->InputServe(triainput);
+		interp=triainput->GetInterpolation();
+		
+		if (interp==P0Enum){
+			/*Update the value if this element belongs to the partition: */
+			if(partition[this->Sid()]!=-1){
+				/*scale P0 value  for this element, corresponding to the partition:*/
+				IssmDouble value = triainput->element_values[0];
+				value*=distributed_values[(int)partition[this->Sid()]];
+				triainput2->SetInput(P0Enum,this->lid,value);
+			}
+		}
+		else if (interp==P1Enum){
+			IssmDouble values[NUMVERTICES];
+			int lidlist[NUMVERTICES];
+			this->GetVerticesLidList(&lidlist[0]);
+			for (int i=0;i<NUMVERTICES;i++){
+				values[i]=triainput->element_values[i];
+				if(partition[this->vertices[i]->Sid()]!=-1) values[i]*=distributed_values[(int)partition[this->vertices[i]->Sid()]];
+			}
+			triainput2->SetInput(P1Enum,NUMVERTICES,&lidlist[0],&values[0]);
+		}
+		else _error_("Tria::InputScaleFromDakota error message: input interpolation " << EnumToStringx(interp) << " not supported yet!");
+	}
+	else if(type==TransientInput2Enum){
+
+
+		IssmDouble* steps=NULL;
+		int nsteps;
+		TransientInput2* transientinput = NULL;
+		TransientInput2* transientinput2 = NULL;
+
+		/*retrieve transient input:*/
+		transientinput= this->inputs2->GetTransientInput(name);
+		transientinput2= this->inputs2->GetTransientInput(DummyEnum);
+
+		/*retrieve time steps: */
+		transientinput->GetAllTimes(&steps,&nsteps);
+
+		/*double check:*/
+		if (nsteps!=nt && nt!=1) _error_("Tria:InputScaleFromDakota error message: transient input " << EnumToStringx(name) <<  
+				" should have the same number of time steps as the number of time values distributed by Dakota: " << nt << "\n");
+
+		/*needed to update inputs:*/
+		int lidlist[NUMVERTICES];
+		this->GetVerticesLidList(&lidlist[0]);
+
+		/*go through the transient inputs, and update:*/
+		for (int i=0;i<nsteps;i++){
+			TriaInput2* triainput=transientinput->GetTriaInput(i);
+			TriaInput2* triainput2=transientinput2->GetTriaInput(i);
+			this->InputServe(triainput);
+			interp=triainput->GetInterpolation();
+
+			if (interp==P0Enum){
+				/*Update the value if this element belongs to the partition: */
+				if(partition[this->Sid()]!=-1){
+					/*scale P0 value  for this element, corresponding to the partition:*/
+					IssmDouble value = triainput->element_values[0];
+					if(nt==1) value*=distributed_values[(int)partition[this->Sid()]]; //we scale all the time steps  with the same distributed_value 
+					else value*=distributed_values[(int)partition[this->Sid()]*nsteps+i]; //we scale all the time steps with distributed value for each step
+
+					triainput2->SetInput(P0Enum,this->lid,value);
+				}
+			}
+			else if (interp==P1Enum){
+				IssmDouble values[NUMVERTICES];
+				for (int j=0;j<NUMVERTICES;j++){
+					values[j]=triainput->element_values[j];
+					if(partition[this->vertices[i]->Sid()]!=-1){
+						if(nt==1) values[j]*=distributed_values[(int)partition[this->vertices[j]->Sid()]];//we scale all the time steps  with the same distributed_value 
+						else values[j]*=distributed_values[(int)partition[this->vertices[j]->Sid()]*nsteps+i];//we scale all the time steps with distributed value for each step
+					}
+				}
+				triainput2->SetInput(P1Enum,NUMVERTICES,&lidlist[0],&values[0]);
+			}
+			else _error_("Tria::InputScaleFromDakota error message: input interpolation " << EnumToStringx(interp) << " not supported yet!");
+		}
+	}
+	else _error_("Tria::InputScaleFromDakota error message: input type " << EnumToStringx(name) << " not supported yet!");
+}
+/*}}}*/
 void       Tria::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols, int name, int type){/*{{{*/
 
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 25255)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 25256)
@@ -46,4 +46,5 @@
 		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type);
 		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
+		void  InputScaleFromDakota(IssmDouble* distributed_values, IssmDouble* partition, int npart, int nt, int name);
 		#endif
 		void  InputUpdateFromIoModel(int index, IoModel* iomodel);
