Index: /issm/trunk/configs/linux64/linux64.sh.petsc2
===================================================================
--- /issm/trunk/configs/linux64/linux64.sh.petsc2	(revision 3598)
+++ /issm/trunk/configs/linux64/linux64.sh.petsc2	(revision 3599)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-./configure --prefix=$ISSM_DIR --with-matlab-dir=$MATLAB_DIR --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install --with-metis-dir=$ISSM_DIR/externalpackages/metis/install --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich" --with-petsc-arch=$ISSM_ARCH --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/fblaslapack/$ISSM_ARCH --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH -lPLAPACK" --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH/INCLUDE" --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/SCALAPACK/$ISSM_ARCH --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/MUMPS_4.6.3/$ISSM_ARCH --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/ -lgfortran" --with-graphics-lib=/usr/lib64/libX11.so --with-cxxoptflags="-march=opteron -O2" --with-numthreads=32 --with-petsc-version=2 
+./configure --prefix=$ISSM_DIR --with-matlab-dir=$MATLAB_DIR --with-triangle-dir=$ISSM_DIR/externalpackages/triangle/install --with-metis-dir=$ISSM_DIR/externalpackages/metis/install --with-petsc-dir=$ISSM_DIR/externalpackages/petsc/install --with-mpi-include=$ISSM_DIR/externalpackages/mpich2/install/include  --with-mpi-lib="-L$ISSM_DIR/externalpackages/mpich2/install/lib/ -lmpich" --with-petsc-arch=$ISSM_ARCH --with-dakota-dir=$ISSM_DIR/externalpackages/dakota/install --with-blas-lapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/fblaslapack/$ISSM_ARCH --with-plapack-lib="-L$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH -lPLAPACK" --with-plapack-include="-I$ISSM_DIR/externalpackages/petsc/install/externalpackages/PLAPACKR32-hg/$ISSM_ARCH/INCLUDE" --with-blacs-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/blacs-dev/$ISSM_ARCH --with-scalapack-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/SCALAPACK/$ISSM_ARCH --with-mumps-dir=$ISSM_DIR/externalpackages/petsc/install/externalpackages/MUMPS_4.6.3/$ISSM_ARCH --with-fortran-lib="-L/usr/lib/gcc/x86_64-redhat-linux/4.1.1/ -lgfortran" --with-graphics-lib=/usr/lib64/libX11.so --with-cxxoptflags="-march=opteron -O2" --with-numthreads=32 --with-petsc-version=2
Index: /issm/trunk/externalpackages/matlab/install.sh
===================================================================
--- /issm/trunk/externalpackages/matlab/install.sh	(revision 3598)
+++ /issm/trunk/externalpackages/matlab/install.sh	(revision 3599)
@@ -2,5 +2,5 @@
 
 #Matlab version: used by Petsc to detect some weird behaviour starting at version 7.6 (all blas and lapack prototypes changed! damn them!)
-MATLAB_VERSION=7.8
+MATLAB_VERSION=7.6
 
 #Erase symlink
Index: /issm/trunk/src/c/DataSet/DataSet.cpp
===================================================================
--- /issm/trunk/src/c/DataSet/DataSet.cpp	(revision 3598)
+++ /issm/trunk/src/c/DataSet/DataSet.cpp	(revision 3599)
@@ -152,4 +152,11 @@
 /*FUNCTION DataSet::Demarshall{{{1*/
 DataSet* DataSetDemarshall(char* marshalled_dataset){
+
+	return DataSetDemarshallRaw(&marshalled_dataset);
+
+}
+/*}}}*/
+/*FUNCTION DataSet::DemarshallRaw{{{1*/
+DataSet* DataSetDemarshallRaw(char** pmarshalled_dataset){
 
 	int i;
@@ -162,4 +169,8 @@
 	int*     sorted_ids=NULL;
 	int*     id_offsets=NULL;
+	char*    marshalled_dataset=NULL;
+
+	/*recover marshalled_dataset pointer: */
+	marshalled_dataset=*pmarshalled_dataset;
 
 	/*initialize dataset: */
@@ -291,10 +302,39 @@
 
 	}
+
+	/*Assign output pointers:*/
+	*pmarshalled_dataset=marshalled_dataset;
+	
 	return dataset;
-
+}
+/*}}}*/
+/*FUNCTION DataSet::Spawn{{{1*/
+DataSet* DataSet::Spawn(int* indices, int num){
+	ISSMERROR(" not supported yet!");
 }
 /*}}}*/
 
 /*Specific methods*/
+/*FUNCTION DataSet::AddEinput{{{1*/
+int  DataSet::AddEinput(Einput* in_einput){
+
+	/*First, go through dataset of inputs and check whether any input 
+	 * with the same name is already in. If so, erase the corresponding 
+	 * object before adding this new one: */
+	vector<Object*>::iterator object;
+	Einput* einput=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		einput=(Einput*)(*object); //assume this is an inputs dataset
+
+		if (einput->EnumType()==in_einput->EnumType()){
+			this->DeleteObject(einput);
+			break;
+		}
+	}
+	this->AddObject(in_einput);
+}
+/*}}}*/
 /*FUNCTION DataSet::AddObject{{{1*/
 int  DataSet::AddObject(Object* object){
@@ -1577,4 +1617,21 @@
 }
 /*}}}*/
+/*FUNCTION DataSet::UpdateInputs{{{1*/
+void  DataSet::UpdateInputs(double* solution, int analysis_type, int sub_analysis_type){
+
+	vector<Object*>::iterator object;
+	Element* element=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		if(EnumIsElement((*object)->Enum())){
+
+			element=(Element*)(*object);
+			element->UpdateInputs(solution,analysis_type,sub_analysis_type);
+		}
+		else ISSMERROR("%s%i%s"," object with id: ",(*object)->GetId()," is not an element, in a function that deals only with elements!");
+	}
+}
+/*}}}*/
 /*FUNCTION DataSet::UpdateFromInputs{{{1*/
 void  DataSet::UpdateFromInputs(void* inputs){
Index: /issm/trunk/src/c/DataSet/DataSet.h
===================================================================
--- /issm/trunk/src/c/DataSet/DataSet.h	(revision 3598)
+++ /issm/trunk/src/c/DataSet/DataSet.h	(revision 3599)
@@ -12,4 +12,5 @@
 #include <vector>
 #include "../toolkits/toolkits.h"
+#include "../objects/Einput.h"
 #include "../objects/Object.h"
 
@@ -46,4 +47,5 @@
 		int   MarshallSize();
 		int   AddObject(Object* object);
+		int   AddEinput(Einput* in_einput);
 		int   DeleteObject(int id);
 		int   Size();
@@ -77,4 +79,5 @@
 		void  CreatePVector(Vec pg,void* inputs, int analysis_type,int sub_analysis_type);
 		void  UpdateFromInputs(void* inputs);
+		void  UpdateInputs(double* solution,int analysis_type,int sub_analysis_type);
 		void  PenaltyCreateKMatrix(Mat Kgg,void* inputs,double kmax,int analysis_type,int sub_analysis_type);
 		void  PenaltyCreatePVector(Vec pg,void* inputs,double kmax,int analysis_type,int sub_analysis_type);
@@ -98,4 +101,5 @@
 		void  UpdateVertexPositions(double* thickness,double* bed);
 		void  OutputRifts(Vec riftproperties);
+		DataSet* Spawn(int* indices, int num);
 		/*}}}*/
 
@@ -104,4 +108,5 @@
 /*This routine cannot be object oriented, but need for demarshalling: */
 DataSet* DataSetDemarshall(char* marshalled_dataset);
+DataSet* DataSetDemarshallRaw(char** pmarshalled_dataset);
 
 #endif
Index: /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 3598)
+++ /issm/trunk/src/c/EnumDefinitions/EnumDefinitions.h	(revision 3599)
@@ -98,4 +98,5 @@
 	/*Inputs: */
 	InputEnum,
+	TriaVertexInputEnum,
 	/*Params: */
 	ParamEnum,
@@ -120,4 +121,8 @@
 	MelangeEnum,
 	/*}}}*/
+	/*Inputs {{{1*/
+	VxEnum,
+	VyEnum,
+	/*}}}*/
 
 };
Index: /issm/trunk/src/c/Makefile.am
===================================================================
--- /issm/trunk/src/c/Makefile.am	(revision 3598)
+++ /issm/trunk/src/c/Makefile.am	(revision 3599)
@@ -30,5 +30,4 @@
 					./objects/BamgOpts.cpp\
 					./objects/Element.h\
-					./objects/Element.cpp\
 					./objects/ElementProperties.h\
 					./objects/ElementProperties.cpp\
@@ -66,4 +65,6 @@
 					./objects/Tria.h\
 					./objects/Tria.cpp\
+					./objects/TriaVertexInput.h\
+					./objects/TriaVertexInput.cpp\
 					./objects/Sing.h\
 					./objects/Sing.cpp\
@@ -80,4 +81,5 @@
 					./objects/Input.h\
 					./objects/Input.cpp\
+					./objects/Einput.h\
 					./objects/ParameterInputs.h\
 					./objects/ParameterInputs.cpp\
@@ -272,4 +274,6 @@
 					./UpdateFromInputsx/UpdateFromInputsx.h\
 					./UpdateFromInputsx/UpdateFromInputsx.cpp\
+					./UpdateInputsx/UpdateInputsx.h\
+					./UpdateInputsx/UpdateInputsx.cpp\
 					./UpdateGeometryx/UpdateGeometryx.h\
 					./UpdateGeometryx/UpdateGeometryx.cpp\
@@ -437,5 +441,4 @@
 					./objects/BamgOpts.cpp\
 					./objects/Element.h\
-					./objects/Element.cpp\
 					./objects/ElementProperties.h\
 					./objects/ElementProperties.cpp\
@@ -473,4 +476,6 @@
 					./objects/Tria.h\
 					./objects/Tria.cpp\
+					./objects/TriaVertexInput.h\
+					./objects/TriaVertexInput.cpp\
 					./objects/Sing.h\
 					./objects/Sing.cpp\
@@ -487,4 +492,5 @@
 					./objects/Input.h\
 					./objects/Input.cpp\
+					./objects/Einput.h\
 					./objects/ParameterInputs.h\
 					./objects/ParameterInputs.cpp\
@@ -676,4 +682,6 @@
 					./UpdateFromInputsx/UpdateFromInputsx.h\
 					./UpdateFromInputsx/UpdateFromInputsx.cpp\
+					./UpdateInputsx/UpdateInputsx.h\
+					./UpdateInputsx/UpdateInputsx.cpp\
 					./UpdateGeometryx/UpdateGeometryx.h\
 					./UpdateGeometryx/UpdateGeometryx.cpp\
Index: /issm/trunk/src/c/UpdateInputsx/UpdateInputsx.cpp
===================================================================
--- /issm/trunk/src/c/UpdateInputsx/UpdateInputsx.cpp	(revision 3599)
+++ /issm/trunk/src/c/UpdateInputsx/UpdateInputsx.cpp	(revision 3599)
@@ -0,0 +1,40 @@
+/*!\file UpdateInputsx
+ * \brief: update datasets using  parameter inputs
+ */
+
+#include "./UpdateInputsx.h"
+#include "../shared/shared.h"
+#include "../include/macros.h"
+#include "../toolkits/toolkits.h"
+#include "../EnumDefinitions/EnumDefinitions.h"
+
+int UpdateInputsx( DataSet* elements,DataSet* nodes, DataSet* vertices, DataSet* loads, DataSet* materials, DataSet* parameters,Vec solution, int analysis_type, int sub_analysis_type){
+
+	int noerr=1;
+	int i;
+
+	int  found=0;
+	extern int num_procs;
+	extern int my_rank;
+	double* serial_solution=NULL;
+
+	/*First, get elements and loads configured: */
+	elements->Configure(elements,loads, nodes,vertices, materials,parameters);
+	loads->Configure(elements, loads, nodes,vertices, materials,parameters);
+	nodes->Configure(elements, loads, nodes,vertices, materials,parameters);
+	parameters->Configure(elements,loads, nodes,vertices, materials,parameters);
+
+	/*Serialize solution, so that elements can index into it on every CPU: */
+	VecToMPISerial(&serial_solution,solution);
+
+	/*Update elements, nodes, loads and materials from inputs: */
+	elements->UpdateInputs(serial_solution,analysis_type,sub_analysis_type);
+
+	elements->Echo();
+
+	/*Free ressources:*/
+	xfree((void**)&serial_solution);
+
+	return noerr;
+
+}
Index: /issm/trunk/src/c/UpdateInputsx/UpdateInputsx.h
===================================================================
--- /issm/trunk/src/c/UpdateInputsx/UpdateInputsx.h	(revision 3599)
+++ /issm/trunk/src/c/UpdateInputsx/UpdateInputsx.h	(revision 3599)
@@ -0,0 +1,15 @@
+/*!\file:  UpdateInputsx.h
+ * \brief header file for updating datasets from inputs
+ */ 
+
+#ifndef _UPDATEINPUTSXX_H
+#define _UPDATEINPUTSXX_H
+
+#include "../objects/objects.h"
+#include "../DataSet/DataSet.h"
+
+/* local prototypes: */
+int		UpdateInputsx( DataSet* elements,DataSet* nodes, DataSet* vertices,DataSet* loads, DataSet* materials,  DataSet* parameters,Vec solution, int analysis_type, int sub_analysis_type);
+
+#endif  /* _UPDATEINPUTSXX_H */
+
Index: /issm/trunk/src/c/issm.h
===================================================================
--- /issm/trunk/src/c/issm.h	(revision 3598)
+++ /issm/trunk/src/c/issm.h	(revision 3599)
@@ -40,4 +40,5 @@
 #include "./SystemMatricesx/SystemMatricesx.h"
 #include "./UpdateFromInputsx/UpdateFromInputsx.h"
+#include "./UpdateInputsx/UpdateInputsx.h"
 #include "./UpdateGeometryx/UpdateGeometryx.h"
 #include "./UpdateVertexPositionsx/UpdateVertexPositionsx.h"
Index: /issm/trunk/src/c/objects/Beam.cpp
===================================================================
--- /issm/trunk/src/c/objects/Beam.cpp	(revision 3598)
+++ /issm/trunk/src/c/objects/Beam.cpp	(revision 3599)
@@ -236,4 +236,9 @@
 		+properties.MarshallSize()
 		+sizeof(int); //sizeof(int) for enum type
+}
+/*}}}*/
+/*FUNCTION Beam::UpdateInputs {{{1*/
+void  Beam::UpdateInputs(double* solution, int analysis_type, int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Beam.h
===================================================================
--- /issm/trunk/src/c/objects/Beam.h	(revision 3598)
+++ /issm/trunk/src/c/objects/Beam.h	(revision 3599)
@@ -64,4 +64,5 @@
 		void  CreatePVector(Vec pg, void* inputs, int analysis_type,int sub_analysis_type);
 		void  UpdateFromInputs(void* inputs);
+		void  UpdateInputs(double* solution, int analysis_type, int sub_analysis_type);
 		void  GetDofList(int* doflist,int* pnumberofdofs);
 		void  GetDofList1(int* doflist);
Index: /issm/trunk/src/c/objects/Einput.h
===================================================================
--- /issm/trunk/src/c/objects/Einput.h	(revision 3599)
+++ /issm/trunk/src/c/objects/Einput.h	(revision 3599)
@@ -0,0 +1,20 @@
+/*!\file:  Einput.h
+ * \brief abstract class for Einput object
+ */ 
+
+
+#ifndef _EINPUT_H_
+#define _EINPUT_H_
+
+#include "./Object.h"
+
+class Einput: public Object{
+
+	public: 
+		
+		virtual        ~Einput(){};
+		virtual int    Enum()=0; //object Enum
+		virtual int    EnumType()=0; //type of input (vx,vy?)
+
+};
+#endif
Index: /issm/trunk/src/c/objects/Element.h
===================================================================
--- /issm/trunk/src/c/objects/Element.h	(revision 3598)
+++ /issm/trunk/src/c/objects/Element.h	(revision 3599)
@@ -20,5 +20,7 @@
 		virtual void   CreateKMatrix(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type)=0;
 		virtual void   CreatePVector(Vec pg, void* inputs, int analysis_type,int sub_analysis_type)=0;
+		virtual int    Enum()=0;
 		virtual void   UpdateFromInputs(void* inputs)=0;
+		virtual void   UpdateInputs(double* solution, int analysis_type, int sub_analysis_type)=0;
 		virtual void   GetNodes(void** nodes)=0;
 		virtual void*  GetMatPar()=0;
@@ -40,5 +42,4 @@
 
 		/*Implementation: */
-		int            Enum();
 
 };
Index: /issm/trunk/src/c/objects/Penta.cpp
===================================================================
--- /issm/trunk/src/c/objects/Penta.cpp	(revision 3598)
+++ /issm/trunk/src/c/objects/Penta.cpp	(revision 3599)
@@ -241,4 +241,5 @@
 	Hook* tria_hnumpar=NULL;
 	ElementProperties* tria_properties=NULL;
+	DataSet* tria_inputs=NULL;
 
 	indices[0]=g0;
@@ -251,6 +252,7 @@
 	tria_hnumpar=this->hnumpar.Spawn(&zero,1);
 	tria_properties=(ElementProperties*)this->properties.Spawn(indices,3);
-
-	tria=new Tria(this->id,tria_hnodes,tria_hmatice,tria_hmatpar,tria_hnumpar,tria_properties);
+	tria_inputs=(DataSet*)this->inputs->Spawn(indices,3);
+
+	tria=new Tria(this->id,tria_hnodes,tria_hmatice,tria_hmatpar,tria_hnumpar,tria_properties,tria_inputs);
 
 	delete tria_hnodes;
@@ -259,4 +261,5 @@
 	delete tria_hnumpar;
 	delete tria_properties;
+	delete tria_inputs;
 
 	return tria;
@@ -332,4 +335,9 @@
 	ISSMERROR("not supported yet!");
 
+}
+/*}}}*/
+/*FUNCTION Penta::UpdateInputs {{{1*/
+void  Penta::UpdateInputs(double* solution, int analysis_type, int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Penta.h
===================================================================
--- /issm/trunk/src/c/objects/Penta.h	(revision 3598)
+++ /issm/trunk/src/c/objects/Penta.h	(revision 3599)
@@ -37,4 +37,5 @@
 
 		ElementProperties properties;
+		DataSet* inputs;
 
 	public:
@@ -62,4 +63,5 @@
 		void  UpdateFromDakota(void* inputs);
 		void  UpdateFromInputs(void* inputs);
+		void  UpdateInputs(double* solution, int analysis_type, int sub_analysis_type);
 		void  SetClone(int* minranks);
 
Index: /issm/trunk/src/c/objects/Sing.cpp
===================================================================
--- /issm/trunk/src/c/objects/Sing.cpp	(revision 3598)
+++ /issm/trunk/src/c/objects/Sing.cpp	(revision 3599)
@@ -286,4 +286,9 @@
 	}
 
+}
+/*}}}*/
+/*FUNCTION Sing::UpdateInputs {{{1*/
+void  Sing::UpdateInputs(double* solution, int analysis_type, int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
 }
 /*}}}*/
Index: /issm/trunk/src/c/objects/Sing.h
===================================================================
--- /issm/trunk/src/c/objects/Sing.h	(revision 3598)
+++ /issm/trunk/src/c/objects/Sing.h	(revision 3599)
@@ -59,4 +59,5 @@
 		void  CreatePVector(Vec pg, void* inputs, int analysis_type,int sub_analysis_type);
 		void  UpdateFromInputs(void* inputs);
+		void  UpdateInputs(double* solution, int analysis_type, int sub_analysis_type);
 		void  GetDofList(int* doflist,int* pnumberofdofs);
 		void  GetDofList1(int* doflist);
Index: /issm/trunk/src/c/objects/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Tria.cpp	(revision 3598)
+++ /issm/trunk/src/c/objects/Tria.cpp	(revision 3599)
@@ -10,4 +10,5 @@
 
 #include "stdio.h"
+#include "./TriaVertexInput.h"
 #include "./Object.h"
 #include "./Hook.h"
@@ -21,13 +22,8 @@
 #include "../include/macros.h"
 
-/*For debugging purposes: */
-#define ELID 141 //element for which to print debug statements
-#define RANK 2 //rank of cpu for which to print debug statements.
-//#define _DEBUGELEMENTS_
-//#define _DEBUGGAUSS_
-
 /*Object constructors and destructor*/
 /*FUNCTION Tria::Tria(){{{1*/
 Tria::Tria(){
+	this->inputs=NULL;
 	return;
 }
@@ -44,10 +40,11 @@
 	/*all the initialization has been done by the initializer, just fill in the id: */
 	this->id=tria_id;
+	this->inputs=new DataSet();
 
 	return;
 }
 /*}}}*/
-/*FUNCTION Tria::Tria(int id, Hook* hnodes, Hook* hmatice, Hook* hmatpar, Hook* hnumpar, ElementProperties* properties) {{{1*/
-Tria::Tria(int tria_id,Hook* tria_hnodes, Hook* tria_hmatice, Hook* tria_hmatpar, Hook* tria_hnumpar, ElementProperties* tria_properties):
+/*FUNCTION Tria::Tria(int id, Hook* hnodes, Hook* hmatice, Hook* hmatpar, Hook* hnumpar, ElementProperties* properties,DataSet* tria_inputs) {{{1*/
+Tria::Tria(int tria_id,Hook* tria_hnodes, Hook* tria_hmatice, Hook* tria_hmatpar, Hook* tria_hnumpar, ElementProperties* tria_properties,DataSet* tria_inputs):
 	hnodes(tria_hnodes),
 	hmatice(tria_hmatice),
@@ -59,4 +56,10 @@
 	/*all the initialization has been done by the initializer, just fill in the id: */
 	this->id=tria_id;
+	if(tria_inputs){
+		this->inputs=tria_inputs->Copy();
+	}
+	else{
+		this->inputs=new DataSet();
+	}
 
 	return;
@@ -74,5 +77,6 @@
 	/*id: */
 	this->id=i+1;
-
+	this->inputs=new DataSet();
+	
 	/*hooks: */
 	//go recover node ids, needed to initialize the node hook.
@@ -103,4 +107,5 @@
 /*FUNCTION Tria::~Tria(){{{1*/
 Tria::~Tria(){
+	delete inputs;
 	return;
 }
@@ -136,5 +141,5 @@
 Object* Tria::copy() {
 
-	return new Tria(this->id,&this->hnodes,&this->hmatice,&this->hmatpar,&this->hnumpar,&this->properties);
+	return new Tria(this->id,&this->hnodes,&this->hmatice,&this->hmatpar,&this->hnumpar,&this->properties,this->inputs);
 
 }
@@ -160,7 +165,9 @@
 	hmatpar.Demarshall(&marshalled_dataset);
 	hnumpar.Demarshall(&marshalled_dataset);
-
+	
 	/*demarshall properties: */
 	properties.Demarshall(&marshalled_dataset);
+	
+	inputs=DataSetDemarshallRaw(&marshalled_dataset); 
 
 	/*return: */
@@ -180,4 +187,6 @@
 	hnumpar.DeepEcho();
 	properties.DeepEcho();
+	printf("Element inputs\n");
+	inputs->DeepEcho();
 
 	return;
@@ -195,4 +204,6 @@
 	hnumpar.Echo();
 	properties.Echo();
+	printf("Element inputs\n");
+	inputs->Echo();
 
 	return;
@@ -204,4 +215,6 @@
 	char* marshalled_dataset=NULL;
 	int   enum_type=0;
+	char* marshalled_inputs=NULL;
+	int   marshalled_inputs_size;
 
 	/*recover marshalled_dataset: */
@@ -225,4 +238,10 @@
 	/*Marshall properties: */
 	properties.Marshall(&marshalled_dataset);
+
+	/*Marshall inputs: */
+	marshalled_inputs_size=inputs->MarshallSize();
+	marshalled_inputs=inputs->Marshall();
+	memcpy(marshalled_dataset,marshalled_inputs,marshalled_inputs_size*sizeof(char));
+	marshalled_dataset+=marshalled_inputs_size;
 
 	*pmarshalled_dataset=marshalled_dataset;
@@ -239,7 +258,10 @@
 		+hnumpar.MarshallSize()
 		+properties.MarshallSize()
+		+inputs->MarshallSize()
 		+sizeof(int); //sizeof(int) for enum type
 }
 /*}}}*/
+
+/*Updates: */
 /*FUNCTION Tria::UpdateFromInputs {{{1*/
 void  Tria::UpdateFromInputs(void* vinputs){
@@ -357,5 +379,120 @@
 }
 /*}}}*/
-
+/*FUNCTION Tria::UpdateInputs {{{1*/
+void  Tria::UpdateInputs(double* solution, int analysis_type, int sub_analysis_type){
+
+	/*Just branch to the correct UpdateInputs generator, according to the type of analysis we are carrying out: */
+	if (analysis_type==ControlAnalysisEnum){
+		
+		UpdateInputsDiagnosticHoriz( solution,analysis_type,sub_analysis_type);
+	}
+	else if (analysis_type==DiagnosticAnalysisEnum){
+	
+		if (sub_analysis_type==HorizAnalysisEnum){
+
+			UpdateInputsDiagnosticHoriz( solution,analysis_type,sub_analysis_type);
+		}
+		else ISSMERROR("%s%i%s\n","sub_analysis: ",sub_analysis_type," not supported yet");
+
+	}
+	else if (analysis_type==SlopecomputeAnalysisEnum){
+
+		UpdateInputsSlopeCompute( solution,analysis_type,sub_analysis_type);
+	}
+	else if (analysis_type==PrognosticAnalysisEnum){
+
+		UpdateInputsPrognostic( solution,analysis_type,sub_analysis_type);
+	}
+	else if (analysis_type==Prognostic2AnalysisEnum){
+
+		UpdateInputsPrognostic2(solution,analysis_type,sub_analysis_type);
+	}
+	else if (analysis_type==BalancedthicknessAnalysisEnum){
+
+		UpdateInputsBalancedthickness( solution,analysis_type,sub_analysis_type);
+	}
+	else if (analysis_type==Balancedthickness2AnalysisEnum){
+
+		UpdateInputsBalancedthickness2( solution,analysis_type,sub_analysis_type);
+	}
+	else if (analysis_type==BalancedvelocitiesAnalysisEnum){
+
+		UpdateInputsBalancedvelocities( solution,analysis_type,sub_analysis_type);
+	}
+	else{
+
+		ISSMERROR("%s%i%s\n","analysis: ",analysis_type," not supported yet");
+	}
+}
+/*}}}*/
+/*FUNCTION Tria::UpdateInputsDiagnosticHoriz {{{1*/
+void  Tria::UpdateInputsDiagnosticHoriz(double* solution, int analysis_type, int sub_analysis_type){
+	
+	
+	int i;
+
+	const int    numvertices=3;
+	const int    numdofpervertex=2;
+	const int    numdof=numdofpervertex*numvertices;
+	
+	int          doflist[numdof];
+	double       values[numdof];
+	double       vx[numvertices];
+	double       vy[numvertices];
+
+	int          dummy;
+	
+	/*Get dof list: */
+	GetDofList(&doflist[0],&dummy);
+
+	/*Use the dof list to index into the solution vector: */
+	for(i=0;i<numdof;i++){
+		values[i]=solution[doflist[i]];
+	}
+
+	/*Ok, we have vx and vy in values, fill in vx and vy arrays: */
+	for(i=0;i<numvertices;i++){
+		vx[i]=values[i*numdofpervertex+0];
+		vy[i]=values[i*numdofpervertex+1];
+	}
+
+	/*Add vx and vy as inputs to the tria element: */
+	this->inputs->AddEinput(new TriaVertexInput(VxEnum,vx));
+	this->inputs->AddEinput(new TriaVertexInput(VyEnum,vy));
+}
+
+/*}}}*/
+/*FUNCTION Tria::UpdateInputsSlopeCompute {{{1*/
+void  Tria::UpdateInputsSlopeCompute(double* solution, int analysis_type, int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Tria::UpdateInputsPrognostic {{{1*/
+void  Tria::UpdateInputsPrognostic(double* solution, int analysis_type, int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Tria::UpdateInputsPrognostic2 {{{1*/
+void  Tria::UpdateInputsPrognostic2(double* solution, int analysis_type, int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Tria::UpdateInputsBalancedthickness {{{1*/
+void  Tria::UpdateInputsBalancedthickness(double* solution, int analysis_type, int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Tria::UpdateInputsBalancedthickness2 {{{1*/
+void  Tria::UpdateInputsBalancedthickness2(double* solution, int analysis_type, int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
+}
+/*}}}*/
+/*FUNCTION Tria::UpdateInputsBalancedvelocities {{{1*/
+void  Tria::UpdateInputsBalancedvelocities(double* solution, int analysis_type, int sub_analysis_type){
+	ISSMERROR(" not supported yet!");
+}
+/*}}}*/
+
+		
 /*Object functions*/
 /*FUNCTION Tria::ComputeBasalStress {{{1*/
@@ -513,10 +650,4 @@
 	  /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
 	  GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);
-
-#ifdef _ISSM_DEBUG_ 
-	for (i=0;i<num_gauss;i++){
-		printf("Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(gauss_weights+i));
-	}
-#endif
 
 	/* Start  looping on the number of gaussian points: */
@@ -777,44 +908,8 @@
 
 		}
-
-#ifdef _DEBUGELEMENTS_
-		if(my_rank==RANK && id==ELID){ 
-			printf("      B:\n");
-			for(i=0;i<3;i++){
-				for(j=0;j<numdof;j++){
-					printf("%g ",B[i][j]);
-				}
-				printf("\n");
-			}
-			printf("      Bprime:\n");
-			for(i=0;i<3;i++){
-				for(j=0;j<numdof;j++){
-					printf("%g ",Bprime[i][j]);
-				}
-				printf("\n");
-			}
-		}
-#endif
 	} // for (ig=0; ig<num_gauss; ig++)
 
 	/*Add Ke_gg to global matrix Kgg: */
 	MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES);
-
-#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("      Ke_gg erms:\n");
-		for( i=0; i<numdof; i++){
-			for (j=0;j<numdof;j++){
-				printf("%g ",Ke_gg[i][j]);
-			}
-			printf("\n");
-		}
-		printf("      Ke_gg row_indices:\n");
-		for( i=0; i<numdof; i++){
-			printf("%i ",doflist[i]);
-		}
-
-	}
-#endif
 
 cleanup_and_return: 
@@ -1117,22 +1212,4 @@
 		}
 
-#ifdef _DEBUGELEMENTS_
-		if(my_rank==RANK && id==ELID){ 
-			printf("      B:\n");
-			for(i=0;i<3;i++){
-				for(j=0;j<numdof;j++){
-					printf("%g ",B[i][j]);
-				}
-				printf("\n");
-			}
-			printf("      Bprime:\n");
-			for(i=0;i<3;i++){
-				for(j=0;j<numdof;j++){
-					printf("%g ",Bprime[i][j]);
-				}
-				printf("\n");
-			}
-		}
-#endif
 	} // for (ig=0; ig<num_gauss; ig++)
 
@@ -1140,20 +1217,4 @@
 	MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES);
 
-#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("      Ke_gg erms:\n");
-		for( i=0; i<numdof; i++){
-			for (j=0;j<numdof;j++){
-				printf("%g ",Ke_gg[i][j]);
-			}
-			printf("\n");
-		}
-		printf("      Ke_gg row_indices:\n");
-		for( i=0; i<numdof; i++){
-			printf("%i ",doflist[i]);
-		}
-
-	}
-#endif
 
 cleanup_and_return: 
@@ -1417,21 +1478,6 @@
 	DeleteFriction(&friction);
 
-	#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("   alpha2_list [%g %g %g ]\n",alpha2_list[0],alpha2_list[1],alpha2_list[2]);
-	}
-	#endif
-
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
 	GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);
-
-	#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("   gaussian points: \n");
-		for(i=0;i<num_gauss;i++){
-			printf("    %g %g %g : %g\n",first_gauss_area_coord[i],second_gauss_area_coord[i],third_gauss_area_coord[i],gauss_weights[i]);
-		}
-	}
-	#endif
 
 	/* Start  looping on the number of gaussian points: */
@@ -1905,22 +1951,4 @@
 		}
 
-#ifdef _DEBUGELEMENTS_
-		if(my_rank==RANK && id==ELID){ 
-			printf("      B:\n");
-			for(i=0;i<3;i++){
-				for(j=0;j<numdof;j++){
-					printf("%g ",B[i][j]);
-				}
-				printf("\n");
-			}
-			printf("      Bprime:\n");
-			for(i=0;i<3;i++){
-				for(j=0;j<numdof;j++){
-					printf("%g ",Bprime[i][j]);
-				}
-				printf("\n");
-			}
-		}
-#endif
 	} // for (ig=0; ig<num_gauss; ig++)
 
@@ -1928,20 +1956,4 @@
 	MatSetValues(Kgg,numdof,doflist,numdof,doflist,(const double*)Ke_gg,ADD_VALUES);
 
-#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("      Ke_gg erms:\n");
-		for( i=0; i<numdof; i++){
-			for (j=0;j<numdof;j++){
-				printf("%g ",Ke_gg[i][j]);
-			}
-			printf("\n");
-		}
-		printf("      Ke_gg row_indices:\n");
-		for( i=0; i<numdof; i++){
-			printf("%i ",doflist[i]);
-		}
-
-	}
-#endif
 
 cleanup_and_return: 
@@ -2851,29 +2863,6 @@
 
 
-	#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("gravity %g\n",matpar->GetG());
-		printf("rho_ice %g\n",matpar->GetRhoIce());
-		printf("thickness [%g,%g,%g]\n",h[0],h[1],h[2]);
-		printf("surface[%g,%g,%g]\n",s[0],s[1],s[2]);
-		printf("bed[%g,%g,%g]\n",b[0],b[1],b[2]);
-		printf("drag [%g,%g,%g]\n",k[0],k[1],k[2]);
-	}
-	#endif
-
-
 	/* Get gaussian points and weights: */
 	GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); /*We need higher order because our load is order 2*/
-
-	#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("   gaussian points: \n");
-		for(i=0;i<num_gauss;i++){
-			printf("    %g %g %g : %g\n",first_gauss_area_coord[i],second_gauss_area_coord[i],third_gauss_area_coord[i],gauss_weights[i]);
-		}
-	}
-	#endif
-
-
 
 	/* Start  looping on the number of gaussian points: */
@@ -2904,17 +2893,4 @@
 		/*Compute driving stress: */
 		driving_stress_baseline=matpar->GetRhoIce()*matpar->GetG()*thickness;
-
-
-	 	#ifdef _DEBUGELEMENTS_
-		if(my_rank==RANK && id==ELID){ 
-			printf("      gaussian %i\n",ig);
-			printf("      thickness %g\n",thickness);
-			printf("      slope(%g,%g)\n",slope[0],slope[1]);
-			printf("      Jdet %g\n",Jdet);
-			printf("      gaussweigth %g\n",gauss_weight);
-			printf("      l1l2l3 (%g,%g,%g)\n",l1l2l3[0],l1l2l3[1],l1l2l3[2]);
-			if(friction_type==1)printf("      plastic_stress(%g)\n",plastic_stress);
-		}
-		#endif
 
 		/*Build pe_g_gaussian vector: */
@@ -2938,18 +2914,4 @@
 
 	} //for (ig=0; ig<num_gauss; ig++)
-
-	#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("      pe_g->terms\n",ig);
-		for( i=0; i<pe_g->nrows; i++){
-			printf("%g ",*(pe_g->terms+i));
-		}
-		printf("\n");
-		printf("      pe_g->row_indices\n",ig);
-		for( i=0; i<pe_g->nrows; i++){
-			printf("%i ",*(pe_g->row_indices+i));
-		}
-	}
-	#endif
 
 	/*Add pe_g to global vector pg: */
@@ -3787,13 +3749,4 @@
 	GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2);
 
-#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("   gaussian points: \n");
-		for(i=0;i<num_gauss;i++){
-			printf("    %g %g %g : %g\n",first_gauss_area_coord[i],second_gauss_area_coord[i],third_gauss_area_coord[i],gauss_weights[i]);
-		}
-	}
-#endif
-
 	/* Start  looping on the number of gaussian points: */
 	for (ig=0; ig<num_gauss; ig++){
@@ -3806,7 +3759,4 @@
 		/* Get Jacobian determinant: */
 		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3);
-#ifdef _ISSM_DEBUG_ 
-		printf("Element id %i Jacobian determinant: %g\n",GetId(),Jdet);
-#endif
 
 		/* Get nodal functions value at gaussian point:*/
@@ -3934,10 +3884,4 @@
 	GetNodalFunctionsDerivatives(&dh1dh3[0][0],xyz_list, gauss_l1l2l3);
 
-	#ifdef _ISSM_DEBUG_ 
-	for (i=0;i<3;i++){
-		printf("Node %i  dh/dx=%lf dh/dy=%lf \n",i,dh1dh3[0][i],dh1dh3[1][i]);
-	}
-	#endif
-
 	/*Build B: */
 	for (i=0;i<numgrids;i++){
@@ -3974,10 +3918,4 @@
 	/*Get dh1dh2dh3 in actual coordinate system: */
 	GetNodalFunctions(&l1l2l3[0],gauss_l1l2l3);
-
-#ifdef _ISSM_DEBUG_ 
-	for (i=0;i<3;i++){
-		printf("Node %i  h=%lf \n",i,l1l2l3[i]);
-	}
-#endif
 
 	/*Build B_prog: */
@@ -4558,9 +4496,4 @@
 	/* Get gaussian points and weights (make this a statically initialized list of points? fstd): */
 	GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4);
-#ifdef _ISSM_DEBUG_ 
-	for (i=0;i<num_gauss;i++){
-		printf("Gauss coord %i: %lf %lf %lf Weight: %lf\n",i,*(first_gauss_area_coord+i),*(second_gauss_area_coord+i),*(third_gauss_area_coord+i),*(gauss_weights+i));
-	}
-#endif
 
 	/* Start  looping on the number of gaussian points: */
@@ -4592,7 +4525,4 @@
 		/* Get nodal functions value at gaussian point:*/
 		GetNodalFunctions(l1l2l3, gauss_l1l2l3);
-#ifdef _ISSM_DEBUG_
-		printf("viscositycomp %g thickness %g dvx [%g %g] dvy [%g %g]  dadjx [%g %g] dadjy[%g %g]\n",viscosity_complement,thickness,dvx[0],dvx[1],dvy[0],dvy[1],dadjx[0],dadjx[1],dadjy[0],dadjy[1]);
-#endif
 
 		/*Get nodal functions derivatives*/
@@ -4745,13 +4675,4 @@
 	GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4);
 
-	#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("   gaussian points: \n");
-		for(i=0;i<num_gauss;i++){
-			printf("    %g %g %g : %g\n",first_gauss_area_coord[i],second_gauss_area_coord[i],third_gauss_area_coord[i],gauss_weights[i]);
-		}
-	}
-	#endif
-	
 	/* Start  looping on the number of gaussian points: */
 	for (ig=0; ig<num_gauss; ig++){
@@ -4799,27 +4720,15 @@
 		GetParameterValue(&alpha_complement, &alpha_complement_list[0],gauss_l1l2l3);
 		GetParameterValue(&drag, &this->properties.k[0],gauss_l1l2l3);
-		#ifdef _ISSM_DEBUG_ 
-			printf("Drag complement: %20.20lf Drag: %20.20lf\n",alpha_complement,drag);
-		#endif
 
 		/*recover lambda and mu: */
 		GetParameterValue(&lambda, &adjx_list[0],gauss_l1l2l3);
 		GetParameterValue(&mu, &adjy_list[0],gauss_l1l2l3);
-		#ifdef _ISSM_DEBUG_ 
-			printf("Adjoint vector %20.20lf %20.20lf\n",lambda,mu);
-		#endif
 			
 		/*recover vx and vy: */
 		GetParameterValue(&vx, &vx_list[0],gauss_l1l2l3);
 		GetParameterValue(&vy, &vy_list[0],gauss_l1l2l3);
-		#ifdef _ISSM_DEBUG_ 
-			printf("Velocity vector %20.20lf %20.20lf\n",vx,vy);
-		#endif
 
 		/* Get Jacobian determinant: */
 		GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3);
-		#ifdef _ISSM_DEBUG_ 
-		printf("Element id %i Jacobian determinant: %lf\n",GetId(),Jdet);
-		#endif
 		
 		/* Get nodal functions value at gaussian point:*/
@@ -4979,13 +4888,4 @@
 	GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 4);
 
-#ifdef _DEBUGELEMENTS_
-	if(my_rank==RANK && id==ELID){ 
-		printf("   gaussian points: \n");
-		for(i=0;i<num_gauss;i++){
-			printf("    %g %g %g : %g\n",first_gauss_area_coord[i],second_gauss_area_coord[i],third_gauss_area_coord[i],gauss_weights[i]);
-		}
-	}
-#endif
-
 	/* Start  looping on the number of gaussian points: */
 	for (ig=0; ig<num_gauss; ig++){
@@ -5033,7 +4933,4 @@
 		GetParameterValue(&alpha_complement, &alpha_complement_list[0],gauss_l1l2l3);
 		GetParameterValue(&drag, &this->properties.k[0],gauss_l1l2l3);
-#ifdef _ISSM_DEBUG_ 
-		printf("Drag complement: %20.20lf Drag: %20.20lf\n",alpha_complement,drag);
-#endif
 
 		/*recover lambda mu and xi: */
@@ -5041,7 +4938,4 @@
 		GetParameterValue(&mu, &adjy_list[0],gauss_l1l2l3);
 		GetParameterValue(&xi, &adjz_list[0],gauss_l1l2l3);
-#ifdef _ISSM_DEBUG_ 
-		printf("Adjoint vector %20.20lf %20.20lf\n",lambda,mu);
-#endif
 
 		/*recover vx vy and vz: */
@@ -5049,6 +4943,4 @@
 		GetParameterValue(&vy, &vy_list[0],gauss_l1l2l3);
 		GetParameterValue(&vz, &vz_list[0],gauss_l1l2l3);
-#ifdef _ISSM_DEBUG_ 
-		printf("Velocity vector %20.20lf %20.20lf\n",vx,vy);
 
 		/*Get normal vecyor to the bed */
@@ -5058,11 +4950,7 @@
 		bed_normal[1]=-surface_normal[1];
 		bed_normal[2]=-surface_normal[2];
-#endif
 
 		/* Get Jacobian determinant: */
 		GetJacobianDeterminant3d(&Jdet, &xyz_list[0][0],gauss_l1l2l3);
-#ifdef _ISSM_DEBUG_ 
-		printf("Element id %i Jacobian determinant: %lf\n",GetId(),Jdet);
-#endif
 
 		/* Get nodal functions value at gaussian point:*/
Index: /issm/trunk/src/c/objects/Tria.h
===================================================================
--- /issm/trunk/src/c/objects/Tria.h	(revision 3598)
+++ /issm/trunk/src/c/objects/Tria.h	(revision 3599)
@@ -34,4 +34,5 @@
 
 		ElementProperties properties;
+		DataSet* inputs;
 	
 	public:
@@ -40,5 +41,5 @@
 		Tria();
 		Tria(int tria_id,int* tria_node_ids, int tria_matice_id, int tria_matpar_id, int tria_numpar_id, ElementProperties* tria_properties);
-		Tria(int tria_id,Hook* tria_hnodes, Hook* tria_hmatice, Hook* tria_hmatpar, Hook* tria_hnumpar, ElementProperties* tria_properties);
+		Tria(int tria_id,Hook* tria_hnodes, Hook* tria_hmatice, Hook* tria_hmatpar, Hook* tria_hnumpar, ElementProperties* tria_properties,DataSet* tria_inputs);
 		Tria(int i, IoModel* iomodel);
 		~Tria();
@@ -57,7 +58,5 @@
 		int   MyRank();
 		void  SetClone(int* minranks);
-		void  UpdateFromDakota(void* inputs);
-		void  UpdateFromInputs(void* inputs);
-	/*}}}*/
+		/*}}}*/
 		/*FUNCTION element numerical routines {{{1*/
 		void  CreateKMatrix(Mat Kgg,void* inputs,int analysis_type,int sub_analysis_type);
@@ -124,4 +123,17 @@
 		double GetArea(void);
 		double GetAreaCoordinate(double x, double y, int which_one);
+
+		/*updates:*/
+		void  UpdateFromDakota(void* inputs);
+		void  UpdateFromInputs(void* inputs);
+		void  UpdateInputs(double* solution, int analysis_type, int sub_analysis_type);
+		void  UpdateInputsDiagnosticHoriz( double* solution,int analysis_type,int sub_analysis_type);
+		void  UpdateInputsSlopeCompute( double* solution,int analysis_type,int sub_analysis_type);
+		void  UpdateInputsPrognostic( double* solution,int analysis_type,int sub_analysis_type);
+		void  UpdateInputsPrognostic2(double* solution,int analysis_type,int sub_analysis_type);
+		void  UpdateInputsBalancedthickness( double* solution,int analysis_type,int sub_analysis_type);
+		void  UpdateInputsBalancedthickness2( double* solution,int analysis_type,int sub_analysis_type);
+		void  UpdateInputsBalancedvelocities( double* solution,int analysis_type,int sub_analysis_type);
+
 		/*}}}*/
 
Index: /issm/trunk/src/c/objects/TriaVertexInput.cpp
===================================================================
--- /issm/trunk/src/c/objects/TriaVertexInput.cpp	(revision 3599)
+++ /issm/trunk/src/c/objects/TriaVertexInput.cpp	(revision 3599)
@@ -0,0 +1,141 @@
+/*!\file TriaVertexInput.c
+ * \brief: implementation of the TriaVertexInput object
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include "config.h"
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "stdio.h"
+#include "./TriaVertexInput.h"
+#include <string.h>
+#include "../EnumDefinitions/EnumDefinitions.h"
+#include "../shared/shared.h"
+#include "../DataSet/DataSet.h"
+#include "../include/typedefs.h"
+#include "../include/macros.h"
+
+/*Object constructors and destructor*/
+/*FUNCTION TriaVertexInput::TriaVertexInput(){{{1*/
+TriaVertexInput::TriaVertexInput(){
+	return;
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::TriaVertexInput(double* values){{{1*/
+TriaVertexInput::TriaVertexInput(int in_enum_type,double* in_values){
+
+	enum_type=in_enum_type;
+	values[0]=in_values[0];
+	values[1]=in_values[1];
+	values[2]=in_values[2];
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::~TriaVertexInput(){{{1*/
+TriaVertexInput::~TriaVertexInput(){
+	return;
+}
+/*}}}*/
+
+/*Object management*/
+/*FUNCTION TriaVertexInput::copy{{{1*/
+Object* TriaVertexInput::copy() {
+	
+	return new TriaVertexInput(this->enum_type,this->values);
+
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::DeepEcho{{{1*/
+void TriaVertexInput::DeepEcho(void){
+
+	printf("TriaVertexInput:\n");
+	printf("   enum: %i\n",this->enum_type);
+	printf("   %g|%g|%g\n",this->values[0],this->values[1],this->values[2]);
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::Demarshall{{{1*/
+void  TriaVertexInput::Demarshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   i;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*this time, no need to get enum type, the pointer directly points to the beginning of the 
+	 *object data (thanks to DataSet::Demarshall):*/
+	memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
+
+	/*return: */
+	*pmarshalled_dataset=marshalled_dataset;
+	return;
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::Echo {{{1*/
+void TriaVertexInput::Echo(void){
+	this->DeepEcho();
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::Enum{{{1*/
+int TriaVertexInput::Enum(void){
+
+	return TriaVertexInputEnum;
+
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::EnumType{{{1*/
+int TriaVertexInput::EnumType(void){
+
+	return this->enum_type;
+
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::GetId{{{1*/
+int    TriaVertexInput::GetId(void){ return -1; }
+/*}}}*/
+/*FUNCTION TriaVertexInput::GetName{{{1*/
+char* TriaVertexInput::GetName(void){
+	return "triavertexinput";
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::Marshall{{{1*/
+void  TriaVertexInput::Marshall(char** pmarshalled_dataset){
+
+	char* marshalled_dataset=NULL;
+	int   enum_type=0;
+
+	/*recover marshalled_dataset: */
+	marshalled_dataset=*pmarshalled_dataset;
+
+	/*get enum type of TriaVertexInput: */
+	enum_type=TriaVertexInputEnum;
+	
+	/*marshall enum: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	
+	/*marshall TriaVertexInput data: */
+	memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
+	memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
+
+	*pmarshalled_dataset=marshalled_dataset;
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::MarshallSize{{{1*/
+int   TriaVertexInput::MarshallSize(){
+	
+	return sizeof(values)+
+		sizeof(enum_type)+
+		+sizeof(int); //sizeof(int) for enum type
+}
+/*}}}*/
+/*FUNCTION TriaVertexInput::MyRank{{{1*/
+int    TriaVertexInput::MyRank(void){ 
+	extern int my_rank;
+	return my_rank; 
+}
+/*}}}*/
+
+/*Object functions*/
+
Index: /issm/trunk/src/c/objects/TriaVertexInput.h
===================================================================
--- /issm/trunk/src/c/objects/TriaVertexInput.h	(revision 3599)
+++ /issm/trunk/src/c/objects/TriaVertexInput.h	(revision 3599)
@@ -0,0 +1,42 @@
+/*! \file TriaVertexInput.h 
+ *  \brief: header file for triavertexinput object
+ */
+
+#include "./Einput.h"
+
+#ifndef _TRIAVERTEXINPUT_H_
+#define _TRIAVERTEXINPUT_H_
+
+class TriaVertexInput: public Einput{
+
+	private: 
+		/*just hold 3 values for 3 vertices: */
+		int    enum_type;
+		double values[3];
+
+	public:
+
+		/*constructors, destructors: {{{1*/
+		TriaVertexInput();
+		TriaVertexInput(int enum_type,double* values);
+		~TriaVertexInput();
+		/*}}}*/
+		/*object management: {{{1*/
+		void  DeepEcho();
+		void  Echo();
+		int   GetId(); 
+		void  Marshall(char** pmarshalled_dataset);
+		int   MarshallSize();
+		char* GetName();
+		void  Demarshall(char** pmarshalled_dataset);
+		int   Enum();
+		int   MyRank();
+		Object* copy();
+		int   EnumType();
+
+		/*}}}*/
+		/*numerics: {{{1*/
+		/*}}}*/
+
+};
+#endif  /* _TRIAVERTEXINPUT_H */
Index: /issm/trunk/src/m/enum/AirEnum.m
===================================================================
--- /issm/trunk/src/m/enum/AirEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/AirEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=AirEnum()
 
-macro=76;
+macro=77;
Index: /issm/trunk/src/m/enum/DofVecEnum.m
===================================================================
--- /issm/trunk/src/m/enum/DofVecEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/DofVecEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=DofVecEnum()
 
-macro=70;
+macro=71;
Index: /issm/trunk/src/m/enum/GeographyEnum.m
===================================================================
--- /issm/trunk/src/m/enum/GeographyEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/GeographyEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=GeographyEnum()
 
-macro=71;
+macro=72;
Index: /issm/trunk/src/m/enum/IceEnum.m
===================================================================
--- /issm/trunk/src/m/enum/IceEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/IceEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=IceEnum()
 
-macro=75;
+macro=76;
Index: /issm/trunk/src/m/enum/IceSheetEnum.m
===================================================================
--- /issm/trunk/src/m/enum/IceSheetEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/IceSheetEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=IceSheetEnum()
 
-macro=72;
+macro=73;
Index: /issm/trunk/src/m/enum/IceShelfEnum.m
===================================================================
--- /issm/trunk/src/m/enum/IceShelfEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/IceShelfEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=IceShelfEnum()
 
-macro=73;
+macro=74;
Index: /issm/trunk/src/m/enum/MelangeEnum.m
===================================================================
--- /issm/trunk/src/m/enum/MelangeEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/MelangeEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=MelangeEnum()
 
-macro=77;
+macro=78;
Index: /issm/trunk/src/m/enum/ParamEnum.m
===================================================================
--- /issm/trunk/src/m/enum/ParamEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/ParamEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=ParamEnum()
 
-macro=66;
+macro=67;
Index: /issm/trunk/src/m/enum/ResultEnum.m
===================================================================
--- /issm/trunk/src/m/enum/ResultEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/ResultEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=ResultEnum()
 
-macro=67;
+macro=68;
Index: /issm/trunk/src/m/enum/RgbEnum.m
===================================================================
--- /issm/trunk/src/m/enum/RgbEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/RgbEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=RgbEnum()
 
-macro=68;
+macro=69;
Index: /issm/trunk/src/m/enum/SpcEnum.m
===================================================================
--- /issm/trunk/src/m/enum/SpcEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/SpcEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=SpcEnum()
 
-macro=69;
+macro=70;
Index: /issm/trunk/src/m/enum/TriaVertexInputEnum.m
===================================================================
--- /issm/trunk/src/m/enum/TriaVertexInputEnum.m	(revision 3599)
+++ /issm/trunk/src/m/enum/TriaVertexInputEnum.m	(revision 3599)
@@ -0,0 +1,9 @@
+function macro=TriaVertexInputEnum()
+%TRIAVERTEXINPUTENUM - Enum of TriaVertexInput
+%
+%   file generated by src/c/EnumDefinitions/SynchronizeMatlabEnum
+%
+%   Usage:
+%      macro=TriaVertexInputEnum()
+
+macro=66;
Index: /issm/trunk/src/m/enum/VxEnum.m
===================================================================
--- /issm/trunk/src/m/enum/VxEnum.m	(revision 3599)
+++ /issm/trunk/src/m/enum/VxEnum.m	(revision 3599)
@@ -0,0 +1,9 @@
+function macro=VxEnum()
+%VXENUM - Enum of Vx
+%
+%   file generated by src/c/EnumDefinitions/SynchronizeMatlabEnum
+%
+%   Usage:
+%      macro=VxEnum()
+
+macro=79;
Index: /issm/trunk/src/m/enum/VyEnum.m
===================================================================
--- /issm/trunk/src/m/enum/VyEnum.m	(revision 3599)
+++ /issm/trunk/src/m/enum/VyEnum.m	(revision 3599)
@@ -0,0 +1,9 @@
+function macro=VyEnum()
+%VYENUM - Enum of Vy
+%
+%   file generated by src/c/EnumDefinitions/SynchronizeMatlabEnum
+%
+%   Usage:
+%      macro=VyEnum()
+
+macro=80;
Index: /issm/trunk/src/m/enum/WaterEnum.m
===================================================================
--- /issm/trunk/src/m/enum/WaterEnum.m	(revision 3598)
+++ /issm/trunk/src/m/enum/WaterEnum.m	(revision 3599)
@@ -7,3 +7,3 @@
 %      macro=WaterEnum()
 
-macro=74;
+macro=75;
Index: /issm/trunk/src/m/solutions/jpl/diagnostic_core_nonlinear.m
===================================================================
--- /issm/trunk/src/m/solutions/jpl/diagnostic_core_nonlinear.m	(revision 3598)
+++ /issm/trunk/src/m/solutions/jpl/diagnostic_core_nonlinear.m	(revision 3599)
@@ -50,7 +50,11 @@
 		%Solve	
 		[soln(count).u_f]=Solver(K_ff,p_f,[],m.parameters);
-		
+
 		%Merge back to g set
 		[soln(count).u_g]= Mergesolutionfromftog( soln(count).u_f, m.Gmn, m.ys, m.nodesets ); 
+
+		%Update elements with new solution
+		[m.elements]=UpdateInputs(m.elements,m.nodes,m.vertices,loads,m.materials,m.parameters,soln(count).u_g,analysis_type,sub_analysis_type);
+		error;
 		
 		%Deal with penalty loads
Index: /issm/trunk/src/mex/Makefile.am
===================================================================
--- /issm/trunk/src/mex/Makefile.am	(revision 3598)
+++ /issm/trunk/src/mex/Makefile.am	(revision 3599)
@@ -59,4 +59,5 @@
 				TriMeshRefine\
 				UpdateFromInputs\
+				UpdateInputs\
 				UpdateVertexPositions\
 				UpdateGeometry
@@ -247,4 +248,7 @@
 			  UpdateFromInputs/UpdateFromInputs.h
 
+UpdateInputs_SOURCES = UpdateInputs/UpdateInputs.cpp\
+			  UpdateInputs/UpdateInputs.h
+
 UpdateGeometry_SOURCES = UpdateGeometry/UpdateGeometry.cpp\
 			  UpdateGeometry/UpdateGeometry.h
Index: /issm/trunk/src/mex/UpdateInputs/UpdateInputs.cpp
===================================================================
--- /issm/trunk/src/mex/UpdateInputs/UpdateInputs.cpp	(revision 3599)
+++ /issm/trunk/src/mex/UpdateInputs/UpdateInputs.cpp	(revision 3599)
@@ -0,0 +1,64 @@
+/*\file UpdateInputs.c
+ *\brief: update elements properties using a solution vector
+ */
+
+#include "./UpdateInputs.h"
+
+void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
+
+	/*diverse: */
+	int   noerr=1;
+
+	/*input datasets: */
+	DataSet* elements=NULL;
+	DataSet* nodes=NULL;
+	DataSet* vertices=NULL;
+	DataSet* loads=NULL;
+	DataSet* materials=NULL;
+	DataSet* parameters=NULL;
+	Vec      solution=NULL;
+	int               analysis_type;
+	int               sub_analysis_type;
+
+	/*Boot module: */
+	MODULEBOOT();
+
+	/*checks on arguments on the matlab side: */
+	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&UpdateInputsUsage);
+	
+	/*Input datasets: */
+	FetchData(&elements,ELEMENTSIN);
+	FetchData(&nodes,NODESIN);
+	FetchData(&vertices,VERTICESIN);
+	FetchData(&loads,LOADSIN);
+	FetchData(&materials,MATERIALSIN);
+	FetchParams(&parameters,PARAMETERSIN);
+	FetchData(&solution,SOLUTION);
+	FetchData(&analysis_type,ANALYSIS);
+	FetchData(&sub_analysis_type,SUBANALYSIS);
+	
+	/*!Generate internal degree of freedom numbers: */
+	UpdateInputsx(elements,nodes,vertices,loads, materials,parameters,solution,analysis_type,sub_analysis_type);
+	
+	/*write output datasets: */
+	WriteData(ELEMENTS,elements);
+	
+	/*Free ressources: */
+	delete elements;
+	delete nodes;
+	delete vertices;
+	delete loads;
+	delete materials;
+	delete parameters;
+	VecFree(&solution);
+	
+	/*end module: */
+	MODULEEND();
+}
+
+void UpdateInputsUsage(void)
+{
+	_printf_("\n");
+	_printf_("   usage: [elements] = %s(elements,nodes,vertices,loads,materials,parameters,solution,analysis_type,sub_analysis_type);\n",__FUNCT__);
+	_printf_("\n");
+}
Index: /issm/trunk/src/mex/UpdateInputs/UpdateInputs.h
===================================================================
--- /issm/trunk/src/mex/UpdateInputs/UpdateInputs.h	(revision 3599)
+++ /issm/trunk/src/mex/UpdateInputs/UpdateInputs.h	(revision 3599)
@@ -0,0 +1,40 @@
+
+/*
+	UpdateInputs.h
+*/
+
+
+#ifndef _UPDATEINPUTS_H
+#define _UPDATEINPUTS_H
+
+/* local prototypes: */
+void UpdateInputsUsage(void);
+
+#include "../../c/issm.h"
+
+#undef __FUNCT__ 
+#define __FUNCT__  "UpdateInputs"
+
+/* serial input macros: */
+#define ELEMENTSIN (mxArray*)prhs[0]
+#define NODESIN (mxArray*)prhs[1]
+#define VERTICESIN (mxArray*)prhs[2]
+#define LOADSIN (mxArray*)prhs[3]
+#define MATERIALSIN (mxArray*)prhs[4]
+#define PARAMETERSIN (mxArray*)prhs[5]
+#define SOLUTION (mxArray*)prhs[6]
+#define ANALYSIS (mxArray*)prhs[7]
+#define SUBANALYSIS (mxArray*)prhs[8]
+
+/* serial output macros: */
+#define ELEMENTS (mxArray**)&plhs[0]
+
+/* serial arg counts: */
+#undef NLHS
+#define NLHS  1
+#undef NRHS
+#define NRHS  9
+
+
+#endif  /* _UPDATEINPUTS_H */
+
