Index: /issm/trunk-jpl/src/c/classes/Inputs/BoolInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/BoolInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/BoolInput.h	(revision 20827)
@@ -66,6 +66,6 @@
 		IssmDouble Min(void){_error_("Min not implemented for booleans");};
 		IssmDouble MinAbs(void){_error_("Min not implemented for booleans");};
+		void Scale(IssmDouble scale_factor);
 		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
-		void Scale(IssmDouble scale_factor);
 		void SquareMin(IssmDouble* psquaremin, Parameters* parameters);
 		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
Index: /issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp	(revision 20827)
@@ -56,6 +56,19 @@
 
 /*Object virtual functions definitions:*/
-void ControlInput::Echo(void){/*{{{*/
-	this->DeepEcho();
+Object* ControlInput::copy() {/*{{{*/
+
+	ControlInput* output=NULL;
+
+	output = new ControlInput();
+	output->enum_type=this->enum_type;
+	output->control_id=this->control_id;
+
+	if(values)      output->values      = xDynamicCast<Input*>(this->values->copy());
+	if(savedvalues) output->savedvalues = xDynamicCast<Input*>(this->savedvalues->copy());
+	if(minvalues)   output->minvalues   = xDynamicCast<Input*>(this->minvalues->copy());
+	if(maxvalues)   output->maxvalues   = xDynamicCast<Input*>(this->maxvalues->copy());
+	if(gradient)    output->gradient    = xDynamicCast<Input*>(this->gradient->copy());
+
+	return output;
 }
 /*}}}*/
@@ -71,28 +84,9 @@
 }
 /*}}}*/
+void ControlInput::Echo(void){/*{{{*/
+	this->DeepEcho();
+}
+/*}}}*/
 int  ControlInput::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  ControlInput::ObjectEnum(void){/*{{{*/
-
-	return ControlInputEnum;
-
-}
-/*}}}*/
-Object* ControlInput::copy() {/*{{{*/
-
-	ControlInput* output=NULL;
-
-	output = new ControlInput();
-	output->enum_type=this->enum_type;
-	output->control_id=this->control_id;
-
-	if(values)      output->values      = xDynamicCast<Input*>(this->values->copy());
-	if(savedvalues) output->savedvalues = xDynamicCast<Input*>(this->savedvalues->copy());
-	if(minvalues)   output->minvalues   = xDynamicCast<Input*>(this->minvalues->copy());
-	if(maxvalues)   output->maxvalues   = xDynamicCast<Input*>(this->maxvalues->copy());
-	if(gradient)    output->gradient    = xDynamicCast<Input*>(this->gradient->copy());
-
-	return output;
-}
 /*}}}*/
 void ControlInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -130,4 +124,10 @@
 }
 /*}}}*/
+int  ControlInput::ObjectEnum(void){/*{{{*/
+
+	return ControlInputEnum;
+
+}
+/*}}}*/
 
 /*ControlInput management*/
@@ -143,4 +143,8 @@
 	values->AXPY(xinput,scalar);
 }/*}}}*/
+void ControlInput::Configure(Parameters* parameters){/*{{{*/
+	/*do nothing: */
+}
+/*}}}*/
 void ControlInput::Constrain(void){/*{{{*/
 
@@ -160,18 +164,75 @@
 	//gradient->Extrude();
 }/*}}}*/
-int  ControlInput::GetResultInterpolation(void){/*{{{*/
-
-	return values->GetResultInterpolation();
-
-}
-/*}}}*/
-int  ControlInput::GetResultNumberOfNodes(void){/*{{{*/
-
-	return values->GetResultNumberOfNodes();
-
-}
-/*}}}*/
 void ControlInput::GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist){/*{{{*/
 	if(gradient) gradient->GetVectorFromInputs(gradient_vec,doflist);
+}/*}}}*/
+void ControlInput::GetGradientValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
+	gradient->GetInputValue(pvalue,gauss);
+}/*}}}*/
+void ControlInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
+	values->GetInputAverage(pvalue);
+}/*}}}*/
+void ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
+	values->GetInputDerivativeValue(derivativevalues,xyz_list,gauss);
+}/*}}}*/
+void ControlInput::GetInputValue(bool* pvalue){/*{{{*/
+	values->GetInputValue(pvalue);
+}/*}}}*/
+void ControlInput::GetInputValue(int* pvalue){/*{{{*/
+	values->GetInputValue(pvalue);
+}/*}}}*/
+void ControlInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
+	values->GetInputValue(pvalue);
+}/*}}}*/
+void ControlInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
+	values->GetInputValue(pvalue,gauss);
+}/*}}}*/
+int  ControlInput::GetResultInterpolation(void){/*{{{*/
+
+	return values->GetResultInterpolation();
+
+}
+/*}}}*/
+int  ControlInput::GetResultNumberOfNodes(void){/*{{{*/
+
+	return values->GetResultNumberOfNodes();
+
+}
+/*}}}*/
+void ControlInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
+	values->GetVectorFromInputs(vector,doflist);
+}/*}}}*/
+void ControlInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist,const char* data){/*{{{*/
+	 if(strcmp(data,"value")==0){
+		 _assert_(values);
+		 values->GetVectorFromInputs(vector,doflist);
+	 }
+	 else if (strcmp(data,"lowerbound")==0){
+		 _assert_(minvalues);
+		 minvalues->GetVectorFromInputs(vector,doflist);
+	 }
+	 else if (strcmp(data,"upperbound")==0){
+		 _assert_(maxvalues);
+		 maxvalues->GetVectorFromInputs(vector,doflist);
+	 }
+	 else if (strcmp(data,"gradient")==0){
+		 _assert_(gradient);
+		 gradient->GetVectorFromInputs(vector,doflist);
+	 }
+	 else{
+		 _error_("Data " << data << " not supported yet");
+	 }
+}/*}}}*/
+IssmDouble ControlInput::Min(void){/*{{{*/
+
+	return values->Min();
+
+}
+/*}}}*/
+void ControlInput::SaveValue(void){/*{{{*/
+	if(!values) _error_("Values of " << EnumToStringx(this->enum_type) << " not found");
+
+	if(savedvalues) delete this->savedvalues;
+	this->savedvalues=xDynamicCast<Input*>(this->values->copy());
 }/*}}}*/
 void ControlInput::ScaleGradient(IssmDouble scaling_factor){/*{{{*/
@@ -207,66 +268,9 @@
 
 }/*}}}*/
+Input* ControlInput::SpawnSegInput(int index1,int index2){/*{{{*/
+	return values->SpawnSegInput(index1,index2);
+}/*}}}*/
 Input* ControlInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
 	return values->SpawnTriaInput(index1,index2,index3);
-}/*}}}*/
-Input* ControlInput::SpawnSegInput(int index1,int index2){/*{{{*/
-	return values->SpawnSegInput(index1,index2);
-}/*}}}*/
-void ControlInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
-	values->GetVectorFromInputs(vector,doflist);
-}/*}}}*/
-void ControlInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist,const char* data){/*{{{*/
-	 if(strcmp(data,"value")==0){
-		 _assert_(values);
-		 values->GetVectorFromInputs(vector,doflist);
-	 }
-	 else if (strcmp(data,"lowerbound")==0){
-		 _assert_(minvalues);
-		 minvalues->GetVectorFromInputs(vector,doflist);
-	 }
-	 else if (strcmp(data,"upperbound")==0){
-		 _assert_(maxvalues);
-		 maxvalues->GetVectorFromInputs(vector,doflist);
-	 }
-	 else if (strcmp(data,"gradient")==0){
-		 _assert_(gradient);
-		 gradient->GetVectorFromInputs(vector,doflist);
-	 }
-	 else{
-		 _error_("Data " << data << " not supported yet");
-	 }
-}/*}}}*/
-void ControlInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
-	values->GetInputAverage(pvalue);
-}/*}}}*/
-void ControlInput::GetInputValue(bool* pvalue){/*{{{*/
-	values->GetInputValue(pvalue);
-}/*}}}*/
-void ControlInput::GetInputValue(int* pvalue){/*{{{*/
-	values->GetInputValue(pvalue);
-}/*}}}*/
-void ControlInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
-	values->GetInputValue(pvalue);
-}/*}}}*/
-void ControlInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
-	values->GetInputValue(pvalue,gauss);
-}/*}}}*/
-void ControlInput::GetGradientValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
-	gradient->GetInputValue(pvalue,gauss);
-}/*}}}*/
-void ControlInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
-	values->GetInputDerivativeValue(derivativevalues,xyz_list,gauss);
-}/*}}}*/
-IssmDouble ControlInput::Min(void){/*{{{*/
-
-	return values->Min();
-
-}
-/*}}}*/
-void ControlInput::SaveValue(void){/*{{{*/
-	if(!values) _error_("Values of " << EnumToStringx(this->enum_type) << " not found");
-
-	if(savedvalues) delete this->savedvalues;
-	this->savedvalues=xDynamicCast<Input*>(this->values->copy());
 }/*}}}*/
 void ControlInput::UpdateValue(IssmDouble scalar){/*{{{*/
@@ -281,6 +285,2 @@
 	values->VerticallyIntegrate(thickness_input);
 }/*}}}*/
-void ControlInput::Configure(Parameters* parameters){/*{{{*/
-	/*do nothing: */
-}
-/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h	(revision 20827)
@@ -16,11 +16,11 @@
 
 	public:
+		int    control_id;
 		int    enum_type;
-		int    control_id;
+		Input* gradient;
+		Input* maxvalues;
+		Input* minvalues;
+		Input* savedvalues;
 		Input* values;
-		Input* savedvalues;
-		Input* minvalues;
-		Input* maxvalues;
-		Input* gradient;
 
 		/*ControlInput constructors, destructors: {{{*/
@@ -30,24 +30,35 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Object* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*ControlInput management: {{{*/
-		int    InstanceEnum();
-		Input* SpawnTriaInput(int index1,int index2,int index3);
-		Input* SpawnSegInput(int index1,int index2);
-		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
 		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
 		void Configure(Parameters* parameters);
+		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
+		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
+		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
+		int    InstanceEnum();
+		Input* SpawnSegInput(int index1,int index2);
+		Input* SpawnTriaInput(int index1,int index2,int index3);
 		/*}}}*/
 		/*numerics: {{{*/
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void Constrain(void);
+		void Constrain(IssmDouble min,IssmDouble max);
+		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
+		void ChangeEnum(int newenumtype){_error_("not implemented yet");};
+		void Extrude(int start);
+		void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist);
 		void GetGradientValue(IssmDouble* pvalue,Gauss* gauss);
-		void SetInput(Input* in_input);
+		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
+		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
+		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
 		void GetInputValue(bool* pvalue);
 		void GetInputValue(int* pvalue);
@@ -56,17 +67,9 @@
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
-		void GetInputAverage(IssmDouble* pvalue);
-		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
-		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
-		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
-		void ChangeEnum(int newenumtype){_error_("not implemented yet");};
-		void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
-		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
-		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
-		void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
-		void AXPY(Input* xinput,IssmDouble scalar);
-		void Constrain(void);
-		void Constrain(IssmDouble min,IssmDouble max);
+		int  GetResultArraySize(void){return 1;};
+		int  GetResultInterpolation(void);
+		int  GetResultNumberOfNodes(void);
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist,const char* data);
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 		IssmDouble InfinityNorm(void){_error_("not implemented yet");};
 		IssmDouble Max(void){_error_("not implemented yet");};
@@ -74,17 +77,14 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void){_error_("not implemented yet");};
-		void Extrude(int start);
+		void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
+		void SaveValue(void);
+		void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
+		void ScaleGradient(IssmDouble scale);
+		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
+		void SetGradient(Input* gradient_in);
+		void SetInput(Input* in_input);
+		void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
+		void UpdateValue(IssmDouble scalar);
 		void VerticallyIntegrate(Input* thickness_input);
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist,const char* data);
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
-		int  GetResultInterpolation(void);
-		int  GetResultNumberOfNodes(void);
-		int  GetResultArraySize(void){return 1;};
-		void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
-		void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist);
-		void ScaleGradient(IssmDouble scale);
-		void SetGradient(Input* gradient_in);
-		void UpdateValue(IssmDouble scalar);
-		void SaveValue(void);
 		/*}}}*/
 
Index: /issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.cpp	(revision 20827)
@@ -36,27 +36,4 @@
 
 /*Object virtual functions definitions:*/
-void DatasetInput::Echo(void){/*{{{*/
-	this->DeepEcho();
-}
-/*}}}*/
-void DatasetInput::DeepEcho(void){/*{{{*/
-
-	_printf_("DatasetInput:\n");
-	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
-	_printf_("   numids:"<< this->numids<< "\n");
-	_printf_("      ids: ");
-	for(int i=0;i<this->numids;i++) _printf_(this->ids[i]<<" ");
-	_printf_("\n");
-	_printf_("   inputs: \n"); inputs->Echo();
-}
-/*}}}*/
-int    DatasetInput::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int DatasetInput::ObjectEnum(void){/*{{{*/
-
-	return DatasetInputEnum;
-
-}
-/*}}}*/
 Object* DatasetInput::copy() {/*{{{*/
 
@@ -73,4 +50,21 @@
 }
 /*}}}*/
+void DatasetInput::DeepEcho(void){/*{{{*/
+
+	_printf_("DatasetInput:\n");
+	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+	_printf_("   numids:"<< this->numids<< "\n");
+	_printf_("      ids: ");
+	for(int i=0;i<this->numids;i++) _printf_(this->ids[i]<<" ");
+	_printf_("\n");
+	_printf_("   inputs: \n"); inputs->Echo();
+}
+/*}}}*/
+void DatasetInput::Echo(void){/*{{{*/
+	this->DeepEcho();
+}
+/*}}}*/
+int    DatasetInput::Id(void){ return -1; }/*{{{*/
+/*}}}*/
 void DatasetInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
 
@@ -85,19 +79,8 @@
 }
 /*}}}*/
-Input* DatasetInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
+int DatasetInput::ObjectEnum(void){/*{{{*/
 
-	/*output*/
-	DatasetInput* outinput=NULL;
+	return DatasetInputEnum;
 
-	/*Create new Datasetinput (copy of current input)*/
-	outinput=new DatasetInput();
-	outinput->enum_type=this->enum_type;
-	outinput->inputs=xDynamicCast<Inputs*>(this->inputs->SpawnTriaInputs(index1,index2,index3));
-	outinput->numids=this->numids;
-	outinput->ids=xNew<int>(this->numids);
-	xMemCpy(outinput->ids,this->ids,this->numids);
-
-	/*Assign output*/
-	return outinput;
 }
 /*}}}*/
@@ -111,4 +94,21 @@
 	outinput->enum_type=this->enum_type;
 	outinput->inputs=xDynamicCast<Inputs*>(this->inputs->SpawnSegInputs(index1,index2));
+	outinput->numids=this->numids;
+	outinput->ids=xNew<int>(this->numids);
+	xMemCpy(outinput->ids,this->ids,this->numids);
+
+	/*Assign output*/
+	return outinput;
+}
+/*}}}*/
+Input* DatasetInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
+
+	/*output*/
+	DatasetInput* outinput=NULL;
+
+	/*Create new Datasetinput (copy of current input)*/
+	outinput=new DatasetInput();
+	outinput->enum_type=this->enum_type;
+	outinput->inputs=xDynamicCast<Inputs*>(this->inputs->SpawnTriaInputs(index1,index2,index3));
 	outinput->numids=this->numids;
 	outinput->ids=xNew<int>(this->numids);
Index: /issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h	(revision 20827)
@@ -27,23 +27,34 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Object* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id();
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*DatasetInput management: {{{*/
 		void   AddInput(Input* input,int id);
+		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
+		void Configure(Parameters* parameters);
 		int    InstanceEnum();
-		Input* SpawnTriaInput(int index1,int index2,int index3);
-		Input* SpawnSegInput(int index1,int index2);
 		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
 		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
 		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
-		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
-		void Configure(Parameters* parameters);
+		Input* SpawnSegInput(int index1,int index2);
+		Input* SpawnTriaInput(int index1,int index2,int index3);
 		/*}}}*/
 		/*numerics: {{{*/
+		void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
+		void ChangeEnum(int newenumtype){_error_("not implemented yet");};
+		void Constrain(void){_error_("not implemented yet");};
+		void Constrain(IssmDouble min,IssmDouble max){_error_("not implemented yet");};
+		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
+		void Extrude(int start){_error_("not implemented yet");};
+		void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist){_error_("not implemented yet");};
+		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
+		void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
+		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
 		void GetInputValue(bool* pvalue){_error_("not implemented yet");};
 		void GetInputValue(int* pvalue){_error_("not implemented yet");};
@@ -52,17 +63,9 @@
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index);
-		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
-		void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
-		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
-		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
 		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
-		void ChangeEnum(int newenumtype){_error_("not implemented yet");};
-		void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
-		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
-		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
-		void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
-		void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
-		void Constrain(void){_error_("not implemented yet");};
-		void Constrain(IssmDouble min,IssmDouble max){_error_("not implemented yet");};
+		int GetResultArraySize(void){_error_("not implemented yet");};
+		int GetResultInterpolation(void){_error_("not implemented yet");};
+		int GetResultNumberOfNodes(void){_error_("not implemented yet");};
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
 		IssmDouble InfinityNorm(void){_error_("not implemented yet");};
 		IssmDouble Max(void){_error_("not implemented yet");};
@@ -70,16 +73,13 @@
 		IssmDouble Min(void){_error_("not implemented yet");};
 		IssmDouble MinAbs(void){_error_("not implemented yet");};
-		void Extrude(int start){_error_("not implemented yet");};
+		void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
+		void SaveValue(void){_error_("not implemented yet");};
+		void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
+		void ScaleGradient(IssmDouble scale){_error_("not implemented yet");};
+		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
+		void SetGradient(Input* gradient_in){_error_("not implemented yet");};
+		void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
+		void UpdateValue(IssmDouble scalar){_error_("not implemented yet");};
 		void VerticallyIntegrate(Input* thickness_input){_error_("not implemented yet");};
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
-		int GetResultInterpolation(void){_error_("not implemented yet");};
-		int GetResultNumberOfNodes(void){_error_("not implemented yet");};
-		int GetResultArraySize(void){_error_("not implemented yet");};
-		void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
-		void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist){_error_("not implemented yet");};
-		void ScaleGradient(IssmDouble scale){_error_("not implemented yet");};
-		void SetGradient(Input* gradient_in){_error_("not implemented yet");};
-		void UpdateValue(IssmDouble scalar){_error_("not implemented yet");};
-		void SaveValue(void){_error_("not implemented yet");};
 		/*}}}*/
 
Index: /issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.cpp	(revision 20827)
@@ -35,6 +35,8 @@
 
 /*Object virtual functions definitions:*/
-void DoubleArrayInput::Echo(void){/*{{{*/
-	this->DeepEcho();
+Object* DoubleArrayInput::copy() {/*{{{*/
+
+	return new DoubleArrayInput(this->enum_type,this->values,this->m);
+
 }
 /*}}}*/
@@ -46,17 +48,9 @@
 }
 /*}}}*/
-int DoubleArrayInput::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int DoubleArrayInput::ObjectEnum(void){/*{{{*/
-
-	return DoubleArrayInputEnum;
-
+void DoubleArrayInput::Echo(void){/*{{{*/
+	this->DeepEcho();
 }
 /*}}}*/
-Object* DoubleArrayInput::copy() {/*{{{*/
-
-	return new DoubleArrayInput(this->enum_type,this->values,this->m);
-
-}
+int DoubleArrayInput::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void DoubleArrayInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -69,6 +63,26 @@
 }
 /*}}}*/
+int DoubleArrayInput::ObjectEnum(void){/*{{{*/
+
+	return DoubleArrayInputEnum;
+
+}
+/*}}}*/
 
 /*DoubleArrayInput management*/
+void DoubleArrayInput::GetValues(IssmDouble** pvalues, int *pm){ /*{{{*/
+
+	/*output: */
+	IssmDouble*  outvalues= NULL;
+
+	outvalues=xNew<IssmDouble>(m);
+
+	xMemCpy<IssmDouble>(outvalues,values,m);
+
+	/*assign output pointers: */
+	*pm=m;
+	*pvalues=outvalues;
+}
+/*}}}*/
 int DoubleArrayInput::InstanceEnum(void){/*{{{*/
 
@@ -89,18 +103,4 @@
 }
 /*}}}*/
-void DoubleArrayInput::GetValues(IssmDouble** pvalues, int *pm){ /*{{{*/
-
-	/*output: */
-	IssmDouble*  outvalues= NULL;
-
-	outvalues=xNew<IssmDouble>(m);
-
-	xMemCpy<IssmDouble>(outvalues,values,m);
-
-	/*assign output pointers: */
-	*pm=m;
-	*pvalues=outvalues;
-}
-/*}}}*/
 
 /*Object functions*/
Index: /issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.h	(revision 20827)
@@ -24,26 +24,35 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Object* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*DoubleArrayInput management: {{{*/
-		int   InstanceEnum();
-		Input* SpawnTriaInput(int index1,int index2,int index3){_error_("not implemented yet");};
-		Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
-		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
+		void Configure(Parameters* parameters);
+		void GetValues(IssmDouble** pvalues,int* pm);
+		int  GetResultArraySize(void){return m;};
 		int  GetResultInterpolation(void){return P0ArrayEnum;};
 		int  GetResultNumberOfNodes(void){return 1;};
-		int  GetResultArraySize(void){return m;};
+		int   InstanceEnum();
+		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
+		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
+		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
 		void ResultToMatrix(IssmDouble* values,int ncols,int sid);
-		void Configure(Parameters* parameters);
-		void GetValues(IssmDouble** pvalues,int* pm);
+		Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
+		Input* SpawnTriaInput(int index1,int index2,int index3){_error_("not implemented yet");};
 		/*}}}*/
 		/*numerics: {{{*/
+		void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
+		void ChangeEnum(int newenumtype);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
+		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
+		void Extrude(int start){_error_("not supported yet");};
+		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
+		void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
+		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
 		void GetInputValue(bool* pvalue){_error_("not implemented yet");};
 		void GetInputValue(int* pvalue){_error_("not implemented yet");};
@@ -52,16 +61,6 @@
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
-		void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
-		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
-		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
 		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
-		void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
-		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
-		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
-		void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
-		void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
-		void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
-		void ChangeEnum(int newenumtype);
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
 		IssmDouble InfinityNorm(void){_error_("not implemented yet");};
 		IssmDouble Max(void){_error_("not implemented yet");};
@@ -69,7 +68,8 @@
 		IssmDouble Min(void){_error_("not implemented yet");};
 		IssmDouble MinAbs(void){_error_("not implemented yet");};
-		void Extrude(int start){_error_("not supported yet");};
+		void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
+		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
+		void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
 		void VerticallyIntegrate(Input* thickness_input){_error_("not implemented yet");};
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
 		/*}}}*/
 
Index: /issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.cpp	(revision 20827)
@@ -29,26 +29,20 @@
 
 /*Object virtual functions definitions:*/
+Object* DoubleInput::copy() {/*{{{*/
+
+	return new DoubleInput(this->enum_type,this->value);
+
+}
+/*}}}*/
+void DoubleInput::DeepEcho(void){/*{{{*/
+
+	_printf_(setw(15)<<"   DoubleInput "<<setw(25)<<left<<EnumToStringx(this->enum_type)<<" "<<this->value<<"\n");
+}
+/*}}}*/
 void DoubleInput::Echo(void){/*{{{*/
 	this->DeepEcho();
 }
 /*}}}*/
-void DoubleInput::DeepEcho(void){/*{{{*/
-
-	_printf_(setw(15)<<"   DoubleInput "<<setw(25)<<left<<EnumToStringx(this->enum_type)<<" "<<this->value<<"\n");
-}
-/*}}}*/
 int    DoubleInput::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int DoubleInput::ObjectEnum(void){/*{{{*/
-
-	return DoubleInputEnum;
-
-}
-/*}}}*/
-Object* DoubleInput::copy() {/*{{{*/
-
-	return new DoubleInput(this->enum_type,this->value);
-
-}
 /*}}}*/
 void DoubleInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -61,4 +55,10 @@
 }
 /*}}}*/
+int DoubleInput::ObjectEnum(void){/*{{{*/
+
+	return DoubleInputEnum;
+
+}
+/*}}}*/
 
 /*DoubleInput management*/
@@ -69,5 +69,5 @@
 }
 /*}}}*/
-Input* DoubleInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
+Input* DoubleInput::SpawnSegInput(int index1,int index2){/*{{{*/
 
 	/*output*/
@@ -83,5 +83,5 @@
 }
 /*}}}*/
-Input* DoubleInput::SpawnSegInput(int index1,int index2){/*{{{*/
+Input* DoubleInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
 
 	/*output*/
@@ -99,40 +99,4 @@
 
 /*Object functions*/
-void DoubleInput::GetInputValue(bool* pvalue){/*{{{*/
-	_error_("Double input of enum " << EnumToStringx(enum_type) << " cannot return a boolean");
-
-}
-/*}}}*/
-void DoubleInput::GetInputValue(int* pvalue){/*{{{*/
-	_error_("Double input of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");
-
-}
-/*}}}*/
-void DoubleInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
-
-	/*return value*/
-	*pvalue=value;
-}
-/*}}}*/
-void DoubleInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){*pvalue=this->value;}/*{{{*/
-/*}}}*/
-void DoubleInput::ChangeEnum(int newenumtype){/*{{{*/
-	this->enum_type=newenumtype;
-}
-/*}}}*/
-void DoubleInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
-
-	/*square min of a IssmDouble is the square of the IssmDouble itself: */
-	*psquaremin=pow(value,2);
-}
-/*}}}*/
-void DoubleInput::Scale(IssmDouble scale_factor){/*{{{*/
-	value=value*scale_factor;
-}
-/*}}}*/
-void DoubleInput::ConstrainMin(IssmDouble minimum){/*{{{*/
-	if (value<minimum) value=minimum;
-}
-/*}}}*/
 void DoubleInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
 
@@ -155,4 +119,12 @@
 }
 /*}}}*/
+void DoubleInput::ChangeEnum(int newenumtype){/*{{{*/
+	this->enum_type=newenumtype;
+}
+/*}}}*/
+void DoubleInput::Configure(Parameters* parameters){/*{{{*/
+	/*do nothing: */
+}
+/*}}}*/
 void DoubleInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
 
@@ -162,4 +134,36 @@
 }
 /*}}}*/
+void DoubleInput::ConstrainMin(IssmDouble minimum){/*{{{*/
+	if (value<minimum) value=minimum;
+}
+/*}}}*/
+void DoubleInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
+	*pvalue=value;
+}
+/*}}}*/
+void DoubleInput::GetInputValue(bool* pvalue){/*{{{*/
+	_error_("Double input of enum " << EnumToStringx(enum_type) << " cannot return a boolean");
+
+}
+/*}}}*/
+void DoubleInput::GetInputValue(int* pvalue){/*{{{*/
+	_error_("Double input of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return an integer");
+
+}
+/*}}}*/
+void DoubleInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
+
+	/*return value*/
+	*pvalue=value;
+}
+/*}}}*/
+void DoubleInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){*pvalue=this->value;}/*{{{*/
+/*}}}*/
+void DoubleInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
+
+	_error_("not supporte yet!");
+
+}
+/*}}}*/
 IssmDouble DoubleInput::Max(void){/*{{{*/
 	return this->value;
@@ -178,12 +182,71 @@
 }
 /*}}}*/
-void DoubleInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
-
-	_error_("not supporte yet!");
-
-}
-/*}}}*/
-void DoubleInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
-	*pvalue=value;
+Input* DoubleInput::PointwiseDivide(Input* inputB){/*{{{*/
+
+	/*Ouput*/
+	DoubleInput* outinput=NULL;
+
+	/*Intermediaries*/
+	IssmDouble       Bvalue;
+
+	/*Check that inputB is of the same type*/
+	inputB->GetInputAverage(&Bvalue);
+
+	/*Create new DoubleInput*/
+	outinput=new DoubleInput(this->enum_type,this->value/Bvalue);
+
+	/*Return output pointer*/
+	return outinput;
+
+}
+/*}}}*/
+Input* DoubleInput::PointwiseMax(Input* input){/*{{{*/
+
+	/*Ouput*/
+	DoubleInput* outinput=NULL;
+
+	/*Intermediaries*/
+	IssmDouble       max;
+
+	/*Check that inputB is of the same type*/
+	if (input->Max() > this->Max()) max=input->Max();
+	else max=this->Max();
+
+	/*Create new DoubleInput*/
+	outinput=new DoubleInput(this->enum_type,max);
+
+	/*Return output pointer*/
+	return outinput;
+
+}
+/*}}}*/
+Input* DoubleInput::PointwiseMin(Input* input){/*{{{*/
+
+	/*Ouput*/
+	DoubleInput* outinput=NULL;
+
+	/*Intermediaries*/
+	IssmDouble       min;
+
+	/*Check that inputB is of the same type*/
+	if (input->Min() < this->Min()) min=input->Min();
+	else min=this->Min();
+
+	/*Create new DoubleInput*/
+	outinput=new DoubleInput(this->enum_type,min);
+
+	/*Return output pointer*/
+	return outinput;
+
+}
+/*}}}*/
+void DoubleInput::Scale(IssmDouble scale_factor){/*{{{*/
+	value=value*scale_factor;
+}
+/*}}}*/
+void DoubleInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
+
+	/*square min of a IssmDouble is the square of the IssmDouble itself: */
+	*psquaremin=pow(value,2);
 }
 /*}}}*/
@@ -209,65 +272,2 @@
 }
 /*}}}*/
-Input* DoubleInput::PointwiseDivide(Input* inputB){/*{{{*/
-
-	/*Ouput*/
-	DoubleInput* outinput=NULL;
-
-	/*Intermediaries*/
-	IssmDouble       Bvalue;
-
-	/*Check that inputB is of the same type*/
-	inputB->GetInputAverage(&Bvalue);
-
-	/*Create new DoubleInput*/
-	outinput=new DoubleInput(this->enum_type,this->value/Bvalue);
-
-	/*Return output pointer*/
-	return outinput;
-
-}
-/*}}}*/
-Input* DoubleInput::PointwiseMin(Input* input){/*{{{*/
-
-	/*Ouput*/
-	DoubleInput* outinput=NULL;
-
-	/*Intermediaries*/
-	IssmDouble       min;
-
-	/*Check that inputB is of the same type*/
-	if (input->Min() < this->Min()) min=input->Min();
-	else min=this->Min();
-
-	/*Create new DoubleInput*/
-	outinput=new DoubleInput(this->enum_type,min);
-
-	/*Return output pointer*/
-	return outinput;
-
-}
-/*}}}*/
-Input* DoubleInput::PointwiseMax(Input* input){/*{{{*/
-
-	/*Ouput*/
-	DoubleInput* outinput=NULL;
-
-	/*Intermediaries*/
-	IssmDouble       max;
-
-	/*Check that inputB is of the same type*/
-	if (input->Max() > this->Max()) max=input->Max();
-	else max=this->Max();
-
-	/*Create new DoubleInput*/
-	outinput=new DoubleInput(this->enum_type,max);
-
-	/*Return output pointer*/
-	return outinput;
-
-}
-/*}}}*/
-void DoubleInput::Configure(Parameters* parameters){/*{{{*/
-	/*do nothing: */
-}
-/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.h	(revision 20827)
@@ -25,26 +25,35 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Object* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*DoubleInput management: {{{*/
-		int   InstanceEnum();
-		Input* SpawnTriaInput(int index1,int index2,int index3);
-		Input* SpawnSegInput(int index1,int index2);
-		Input* PointwiseDivide(Input* inputB);
-		Input* PointwiseMin(Input* inputB);
-		Input* PointwiseMax(Input* inputB);
+		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
+		void Configure(Parameters* parameters);
+		int  GetResultArraySize(void){return 1;};
 		int  GetResultInterpolation(void){return P0Enum;};
 		int  GetResultNumberOfNodes(void){return 1;};
-		int  GetResultArraySize(void){return 1;};
+		int   InstanceEnum();
+		Input* PointwiseDivide(Input* inputB);
+		Input* PointwiseMax(Input* inputB);
+		Input* PointwiseMin(Input* inputB);
 		void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
-		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
-		void Configure(Parameters* parameters);
+		Input* SpawnSegInput(int index1,int index2);
+		Input* SpawnTriaInput(int index1,int index2,int index3);
 		/*}}}*/
 		/*numerics: {{{*/
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void ChangeEnum(int newenumtype);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		void ConstrainMin(IssmDouble minimum);
+		void Extrude(int start){_error_("not supported yet");};
+		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
 		void GetInputValue(bool* pvalue);
 		void GetInputValue(int* pvalue);
@@ -53,16 +62,6 @@
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
-		void GetInputAverage(IssmDouble* pvalue);
-		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
-		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
 		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
-		void ChangeEnum(int newenumtype);
-		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
-		void ConstrainMin(IssmDouble minimum);
-		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
-		void Scale(IssmDouble scale_factor);
-		void AXPY(Input* xinput,IssmDouble scalar);
-		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 		IssmDouble InfinityNorm(void){_error_("not implemented yet");};
 		IssmDouble Max(void);
@@ -70,7 +69,8 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void);
-		void Extrude(int start){_error_("not supported yet");};
+		void Scale(IssmDouble scale_factor);
+		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
+		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
 		void VerticallyIntegrate(Input* thickness_input);
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 		/*}}}*/
 
Index: /issm/trunk-jpl/src/c/classes/Inputs/Input.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/Input.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/Input.h	(revision 20827)
@@ -25,5 +25,10 @@
 		virtual        ~Input(){};
 
-		virtual int  InstanceEnum()=0; 
+		virtual void ChangeEnum(int newenumtype)=0;
+		virtual void Configure(Parameters* parameters)=0;
+		virtual void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes)=0;
+		virtual void GetInputAverage(IssmDouble* pvalue)=0;
+		virtual void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list)=0;
+		virtual void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, Gauss* gauss)=0;
 		virtual void GetInputValue(bool* pvalue)=0;
 		virtual void GetInputValue(int* pvalue)=0;
@@ -32,37 +37,32 @@
 		virtual void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time)=0;
 		virtual void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int index)=0;
-		virtual void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, Gauss* gauss)=0;
-		virtual void GetInputAverage(IssmDouble* pvalue)=0;
-		virtual void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list)=0;
-		virtual void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes)=0;
 		virtual void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime)=0;
-		virtual void ChangeEnum(int newenumtype)=0;
-		virtual void Configure(Parameters* parameters)=0;
+		virtual int  InstanceEnum()=0; 
 
-		virtual void   SquareMin(IssmDouble* psquaremin,Parameters* parameters)=0;
-		virtual void   ConstrainMin(IssmDouble minimum)=0;
-		virtual IssmDouble InfinityNorm(void)=0;
-		virtual IssmDouble MaxAbs(void)=0;
-		virtual IssmDouble MinAbs(void)=0;
-		virtual IssmDouble Max(void)=0;
-		virtual IssmDouble Min(void)=0;
-		virtual void   Set(IssmDouble setvalue)=0;
-		virtual void   Scale(IssmDouble scale_factor)=0;
 		virtual void   AXPY(Input* xinput,IssmDouble scalar)=0;
 		virtual void   Constrain(IssmDouble cm_min, IssmDouble cm_max)=0;
-		virtual void   VerticallyIntegrate(Input* thickness_input)=0;
+		virtual void   ConstrainMin(IssmDouble minimum)=0;
 		virtual void   Extrude(int start)=0;
 		virtual void   GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist)=0;
+		virtual IssmDouble InfinityNorm(void)=0;
+		virtual IssmDouble Max(void)=0;
+		virtual IssmDouble MaxAbs(void)=0;
+		virtual IssmDouble Min(void)=0;
+		virtual IssmDouble MinAbs(void)=0;
+		virtual void   Scale(IssmDouble scale_factor)=0;
+		virtual void   Set(IssmDouble setvalue)=0;
+		virtual void   SquareMin(IssmDouble* psquaremin,Parameters* parameters)=0;
+		virtual void   VerticallyIntegrate(Input* thickness_input)=0;
 
-		virtual Input* SpawnTriaInput(int index1,int index2,int index3)=0;
-		virtual Input* SpawnSegInput(int index1,int index2)=0;
+		virtual int  GetResultArraySize(void)=0;
+		virtual int  GetResultInterpolation(void)=0;
+		virtual int  GetResultNumberOfNodes(void)=0;
 		virtual Input* PointwiseDivide(Input* inputB)=0;
 		virtual Input* PointwiseMax(Input* inputmax)=0;
 		virtual Input* PointwiseMin(Input* inputmin)=0;
-		virtual int  GetResultInterpolation(void)=0;
-		virtual int  GetResultNumberOfNodes(void)=0;
-		virtual int  GetResultArraySize(void)=0;
+		virtual Input* SpawnSegInput(int index1,int index2)=0;
+		virtual Input* SpawnTriaInput(int index1,int index2,int index3)=0;
+		virtual void ResultToMatrix(IssmDouble* values,int ncols,int sid){_error_("not supported yet");};
 		virtual void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");}; 
-		virtual void ResultToMatrix(IssmDouble* values,int ncols,int sid){_error_("not supported yet");};
 };
 #endif
Index: /issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp	(revision 20827)
@@ -29,5 +29,148 @@
 
 /*Object management*/
-void Inputs::GetInputValue(bool* pvalue,int enum_type){/*{{{*/
+int  Inputs::AddInput(Input* in_input){/*{{{*/
+
+	/*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;
+	Input* input=NULL;
+
+	/*In debugging mode, check that the input is not a NULL pointer*/
+	_assert_(in_input);
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		input=xDynamicCast<Input*>(*object);
+
+		if (input->InstanceEnum()==in_input->InstanceEnum()){
+			this->DeleteObject(input);
+			break;
+		}
+	}
+	this->AddObject(in_input);
+
+	return 1;
+}
+/*}}}*/
+void  Inputs::AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum){/*{{{*/
+
+	/*Find x and y inputs: */
+	Input* xinput=xDynamicCast<Input*>(this->GetInput(inputx_enum));
+	Input* yinput=xDynamicCast<Input*>(this->GetInput(inputy_enum));
+
+	/*some checks: */
+	if(!xinput) _error_("input " << EnumToStringx(inputx_enum) << " could not be found!");
+	if(!yinput) _error_("input " << EnumToStringx(inputy_enum) << " could not be found!");
+
+	/*Apply AXPY: */
+	yinput->AXPY(xinput,scalar);
+}
+/*}}}*/
+void  Inputs::ChangeEnum(int oldenumtype,int newenumtype){/*{{{*/
+
+	/*Go through dataset of inputs and look for input with 
+	 * same enum as input enum, once found, just change its name */
+	vector<Object*>::iterator object;
+	Input* input=NULL;
+
+	/*Delete existing input of newenumtype if it exists*/
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+		input=xDynamicCast<Input*>(*object);
+
+		if (input->InstanceEnum()==newenumtype){
+			this->DeleteObject(input);
+			break;
+		}
+	}
+
+	/*Change enum_type of input of oldenumtype*/
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		input=xDynamicCast<Input*>(*object);
+
+		if (input->InstanceEnum()==oldenumtype){
+			input->ChangeEnum(newenumtype);
+			break;
+		}
+	}
+}
+/*}}}*/
+void Inputs::Configure(Parameters* parameters){/*{{{*/
+
+	vector<Object*>::iterator object;
+	Input* input=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		input=xDynamicCast<Input*>(*object);
+		input->Configure(parameters);
+
+	}
+
+}
+/*}}}*/
+void  Inputs::ConstrainMin(int constrain_enum, IssmDouble minimum){/*{{{*/
+
+	/*Find x and y inputs: */
+	Input* constrain_input=xDynamicCast<Input*>(this->GetInput(constrain_enum));
+
+	/*some checks: */
+	if(!constrain_input) _error_("input " << EnumToStringx(constrain_enum) << " could not be found!");
+
+	/*Apply ContrainMin: */
+	constrain_input->ConstrainMin(minimum);
+}
+/*}}}*/
+int  Inputs::DeleteInput(int enum_type){/*{{{*/
+
+	vector<Object*>::iterator object;
+	Input* input=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		input=xDynamicCast<Input*>(*object);
+
+		if (input->InstanceEnum()==enum_type){
+			this->DeleteObject(input);
+			break;
+		}
+	}
+
+	return 1;
+
+}
+/*}}}*/
+void  Inputs::DuplicateInput(int original_enum,int new_enum){/*{{{*/
+
+	/*Make a copy of the original input: */
+	Input* original=xDynamicCast<Input*>(this->GetInput(original_enum));
+	if(!original)_error_("could not find input with enum: " << EnumToStringx(original_enum)); 
+	Input* copy=xDynamicCast<Input*>(original->copy());
+
+	/*Change copy enum to reinitialized_enum: */
+	copy->ChangeEnum(new_enum);
+
+	/*Add copy into inputs, it will wipe off the one already there: */
+	this->AddInput(xDynamicCast<Input*>(copy));
+}
+/*}}}*/
+Input* Inputs::GetInput(int enum_name){/*{{{*/
+
+	vector<Object*>::iterator object;
+	Input* input=NULL;
+
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		input=xDynamicCast<Input*>(*object);
+
+		if (input->InstanceEnum()==enum_name){
+			return input;
+		}
+	}
+	return NULL;
+}
+/*}}}*/
+void Inputs::GetInputAverage(IssmDouble* pvalue,int enum_type){/*{{{*/
 
 	vector<Object*>::iterator object;
@@ -52,9 +195,9 @@
 
 	/*Ok, we have an input if we made it here, request the input to return the value: */
-	input->GetInputValue(pvalue);
-
-}
-/*}}}*/
-void Inputs::GetInputValue(int* pvalue,int enum_type){/*{{{*/
+	input->GetInputAverage(pvalue);
+
+}
+/*}}}*/
+void Inputs::GetInputValue(bool* pvalue,int enum_type){/*{{{*/
 
 	vector<Object*>::iterator object;
@@ -83,5 +226,5 @@
 }
 /*}}}*/
-void Inputs::GetInputValue(IssmDouble* pvalue,int enum_type){/*{{{*/
+void Inputs::GetInputValue(int* pvalue,int enum_type){/*{{{*/
 
 	vector<Object*>::iterator object;
@@ -92,5 +235,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=xDynamicCast<Input*>(*object); 
+		input=xDynamicCast<Input*>(*object);
 		if (input->InstanceEnum()==enum_type){
 			found=true;
@@ -110,5 +253,5 @@
 }
 /*}}}*/
-void Inputs::GetInputAverage(IssmDouble* pvalue,int enum_type){/*{{{*/
+void Inputs::GetInputValue(IssmDouble* pvalue,int enum_type){/*{{{*/
 
 	vector<Object*>::iterator object;
@@ -119,5 +262,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=xDynamicCast<Input*>(*object);
+		input=xDynamicCast<Input*>(*object); 
 		if (input->InstanceEnum()==enum_type){
 			found=true;
@@ -133,72 +276,6 @@
 
 	/*Ok, we have an input if we made it here, request the input to return the value: */
-	input->GetInputAverage(pvalue);
-
-}
-/*}}}*/
-int  Inputs::AddInput(Input* in_input){/*{{{*/
-
-	/*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;
-	Input* input=NULL;
-
-	/*In debugging mode, check that the input is not a NULL pointer*/
-	_assert_(in_input);
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-
-		if (input->InstanceEnum()==in_input->InstanceEnum()){
-			this->DeleteObject(input);
-			break;
-		}
-	}
-	this->AddObject(in_input);
-
-	return 1;
-}
-/*}}}*/
-void  Inputs::ChangeEnum(int oldenumtype,int newenumtype){/*{{{*/
-
-	/*Go through dataset of inputs and look for input with 
-	 * same enum as input enum, once found, just change its name */
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-
-	/*Delete existing input of newenumtype if it exists*/
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		input=xDynamicCast<Input*>(*object);
-
-		if (input->InstanceEnum()==newenumtype){
-			this->DeleteObject(input);
-			break;
-		}
-	}
-
-	/*Change enum_type of input of oldenumtype*/
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-
-		if (input->InstanceEnum()==oldenumtype){
-			input->ChangeEnum(newenumtype);
-			break;
-		}
-	}
-}
-/*}}}*/
-void  Inputs::ConstrainMin(int constrain_enum, IssmDouble minimum){/*{{{*/
-
-	/*Find x and y inputs: */
-	Input* constrain_input=xDynamicCast<Input*>(this->GetInput(constrain_enum));
-
-	/*some checks: */
-	if(!constrain_input) _error_("input " << EnumToStringx(constrain_enum) << " could not be found!");
-
-	/*Apply ContrainMin: */
-	constrain_input->ConstrainMin(minimum);
+	input->GetInputValue(pvalue);
+
 }
 /*}}}*/
@@ -303,51 +380,27 @@
 }
 /*}}}*/
-Input* Inputs::GetInput(int enum_name){/*{{{*/
-
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-
-		if (input->InstanceEnum()==enum_name){
-			return input;
-		}
-	}
-	return NULL;
-}
-/*}}}*/
-int  Inputs::DeleteInput(int enum_type){/*{{{*/
-
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-
-		if (input->InstanceEnum()==enum_type){
-			this->DeleteObject(input);
-			break;
-		}
-	}
-
-	return 1;
-
-}
-/*}}}*/
-void  Inputs::DuplicateInput(int original_enum,int new_enum){/*{{{*/
-
-	/*Make a copy of the original input: */
-	Input* original=xDynamicCast<Input*>(this->GetInput(original_enum));
-	if(!original)_error_("could not find input with enum: " << EnumToStringx(original_enum)); 
-	Input* copy=xDynamicCast<Input*>(original->copy());
-
-	/*Change copy enum to reinitialized_enum: */
-	copy->ChangeEnum(new_enum);
-
-	/*Add copy into inputs, it will wipe off the one already there: */
-	this->AddInput(xDynamicCast<Input*>(copy));
+Inputs* Inputs::SpawnSegInputs(int index1,int index2){/*{{{*/
+
+	/*Intermediary*/
+	vector<Object*>::iterator object;
+	Input* inputin=NULL;
+	Input* inputout=NULL;
+
+	/*Output*/
+	Inputs* newinputs=new Inputs();
+
+	/*Go through inputs and call Spawn function*/
+	for ( object=objects.begin() ; object < objects.end(); object++ ){
+
+		/*Create new input*/
+		inputin=xDynamicCast<Input*>(*object);
+		inputout=inputin->SpawnSegInput(index1,index2);
+
+		/*Add input to new inputs*/
+		newinputs->AddObject(inputout);
+	}
+
+	/*Assign output pointer*/
+	return newinputs;
 }
 /*}}}*/
@@ -377,55 +430,2 @@
 }
 /*}}}*/
-Inputs* Inputs::SpawnSegInputs(int index1,int index2){/*{{{*/
-
-	/*Intermediary*/
-	vector<Object*>::iterator object;
-	Input* inputin=NULL;
-	Input* inputout=NULL;
-
-	/*Output*/
-	Inputs* newinputs=new Inputs();
-
-	/*Go through inputs and call Spawn function*/
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		/*Create new input*/
-		inputin=xDynamicCast<Input*>(*object);
-		inputout=inputin->SpawnSegInput(index1,index2);
-
-		/*Add input to new inputs*/
-		newinputs->AddObject(inputout);
-	}
-
-	/*Assign output pointer*/
-	return newinputs;
-}
-/*}}}*/
-void  Inputs::AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum){/*{{{*/
-
-	/*Find x and y inputs: */
-	Input* xinput=xDynamicCast<Input*>(this->GetInput(inputx_enum));
-	Input* yinput=xDynamicCast<Input*>(this->GetInput(inputy_enum));
-
-	/*some checks: */
-	if(!xinput) _error_("input " << EnumToStringx(inputx_enum) << " could not be found!");
-	if(!yinput) _error_("input " << EnumToStringx(inputy_enum) << " could not be found!");
-
-	/*Apply AXPY: */
-	yinput->AXPY(xinput,scalar);
-}
-/*}}}*/
-void Inputs::Configure(Parameters* parameters){/*{{{*/
-
-	vector<Object*>::iterator object;
-	Input* input=NULL;
-
-	for ( object=objects.begin() ; object < objects.end(); object++ ){
-
-		input=xDynamicCast<Input*>(*object);
-		input->Configure(parameters);
-
-	}
-
-}
-/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Inputs/Inputs.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/Inputs.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/Inputs.h	(revision 20827)
@@ -23,14 +23,16 @@
 		/*numerics*/
 		int         AddInput(Input* in_input);
+		void        AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum);
 		void        ChangeEnum(int enumtype,int new_enumtype);
+		void        Configure(Parameters* parameters);
 		void        ConstrainMin(int constrain_enum, IssmDouble minimum);
 		int         DeleteInput(int enum_type);
 		void        DuplicateInput(int original_enum,int new_enum);
 		Input*      GetInput(int enum_name);
-		Inputs*     SpawnTriaInputs(int position);//TO BE REMOVED (replaced by the other one)
-		Inputs*     SpawnTriaInputs(int index1,int index2,int index3);
-		Inputs*     SpawnSegInputs(int index1,int index2);
-		Inputs*     SpawnSegInputs(int position);
-		void        AXPY(int inputy_enum, IssmDouble scalar, int inputx_enum);
+		void        GetInputAverage(IssmDouble* pvalue, int enum_type);
+		void        GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
+		void        GetInputValue(bool* pvalue,int enum_type);
+		void        GetInputValue(int* pvalue,int enum_type);
+		void        GetInputValue(IssmDouble* pvalue,int enum_type);
 		IssmDouble  InfinityNorm(int enumtype);
 		IssmDouble  Max(int enumtype);
@@ -38,10 +40,8 @@
 		IssmDouble  Min(int enumtype);
 		IssmDouble  MinAbs(int enumtype);
-		void        GetInputAverage(IssmDouble* pvalue, int enum_type);
-		void        GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
-		void        GetInputValue(bool* pvalue,int enum_type);
-		void        GetInputValue(int* pvalue,int enum_type);
-		void        GetInputValue(IssmDouble* pvalue,int enum_type);
-		void        Configure(Parameters* parameters);
+		Inputs*     SpawnSegInputs(int index1,int index2);
+		Inputs*     SpawnSegInputs(int position);
+		Inputs*     SpawnTriaInputs(int position);//TO BE REMOVED (replaced by the other one)
+		Inputs*     SpawnTriaInputs(int index1,int index2,int index3);
 
 };
Index: /issm/trunk-jpl/src/c/classes/Inputs/IntInput.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/IntInput.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/IntInput.cpp	(revision 20827)
@@ -29,4 +29,10 @@
 
 /*Object virtual functions definitions:*/
+Object* IntInput::copy() {/*{{{*/
+
+	return new IntInput(this->enum_type,this->value);
+
+}
+/*}}}*/
 void IntInput::DeepEcho(void){/*{{{*/
 
@@ -36,16 +42,4 @@
 int  IntInput::Id(void){ return -1; }/*{{{*/
 /*}}}*/
-int  IntInput::ObjectEnum(void){/*{{{*/
-
-	return IntInputEnum;
-
-}
-/*}}}*/
-Object* IntInput::copy() {/*{{{*/
-
-	return new IntInput(this->enum_type,this->value);
-
-}
-/*}}}*/
 void IntInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
 
@@ -54,4 +48,10 @@
 	MARSHALLING(enum_type);
 	MARSHALLING(value);
+
+}
+/*}}}*/
+int  IntInput::ObjectEnum(void){/*{{{*/
+
+	return IntInputEnum;
 
 }
@@ -69,5 +69,5 @@
 }
 /*}}}*/
-Input* IntInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
+Input* IntInput::SpawnSegInput(int index1,int index2){/*{{{*/
 
 	/*output*/
@@ -82,5 +82,5 @@
 }
 /*}}}*/
-Input* IntInput::SpawnSegInput(int index1,int index2){/*{{{*/
+Input* IntInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
 
 	/*output*/
@@ -97,31 +97,4 @@
 
 /*Object functions*/
-void IntInput::GetInputValue(bool* pvalue){_error_("not supported yet!");}/*{{{*/
-/*}}}*/
-void IntInput::GetInputValue(int* pvalue){/*{{{*/
-	*pvalue=value;
-}
-/*}}}*/
-void IntInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
-	_error_("IntInput cannot return a IssmDouble in parallel");
-}
-/*}}}*/
-void IntInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){_error_("not supported yet!");}/*{{{*/
-/*}}}*/
-void IntInput::ChangeEnum(int newenumtype){/*{{{*/
-	this->enum_type=newenumtype;
-}
-/*}}}*/
-void IntInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
-
-	/*square min of an integer is the square of the integer itself: */
-	*psquaremin=pow((IssmDouble)value,2);
-}
-/*}}}*/
-void IntInput::Scale(IssmDouble scale_factor){/*{{{*/
-	IssmDouble dvalue=(IssmDouble)value*scale_factor;
-	value=reCast<int>(dvalue);
-}
-/*}}}*/
 void IntInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
 
@@ -146,4 +119,12 @@
 }
 /*}}}*/
+void IntInput::ChangeEnum(int newenumtype){/*{{{*/
+	this->enum_type=newenumtype;
+}
+/*}}}*/
+void IntInput::Configure(Parameters* parameters){/*{{{*/
+	/*do nothing: */
+}
+/*}}}*/
 void IntInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
 
@@ -153,4 +134,16 @@
 }
 /*}}}*/
+void IntInput::GetInputValue(bool* pvalue){_error_("not supported yet!");}/*{{{*/
+/*}}}*/
+void IntInput::GetInputValue(int* pvalue){/*{{{*/
+	*pvalue=value;
+}
+/*}}}*/
+void IntInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
+	_error_("IntInput cannot return a IssmDouble in parallel");
+}
+/*}}}*/
+void IntInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){_error_("not supported yet!");}/*{{{*/
+/*}}}*/
 void IntInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
 
@@ -159,6 +152,13 @@
 }
 /*}}}*/
-void IntInput::Configure(Parameters* parameters){/*{{{*/
-	/*do nothing: */
+void IntInput::Scale(IssmDouble scale_factor){/*{{{*/
+	IssmDouble dvalue=(IssmDouble)value*scale_factor;
+	value=reCast<int>(dvalue);
 }
 /*}}}*/
+void IntInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
+
+	/*square min of an integer is the square of the integer itself: */
+	*psquaremin=pow((IssmDouble)value,2);
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Inputs/IntInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/IntInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/IntInput.h	(revision 20827)
@@ -26,26 +26,35 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Object* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*IntInput management: {{{*/
-		int   InstanceEnum();
-		Input* SpawnTriaInput(int index1,int index2,int index3);
-		Input* SpawnSegInput(int index1,int index2);
-		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
-		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
+		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
+		void Configure(Parameters* parameters);
+		int  GetResultArraySize(void){return 1;};
 		int  GetResultInterpolation(void){return P0Enum;};
 		int  GetResultNumberOfNodes(void){return 1;};
-		int  GetResultArraySize(void){return 1;};
+		int   InstanceEnum();
+		Input* PointwiseDivide(Input* inputB){_error_("not implemented yet");};
+		Input* PointwiseMax(Input* inputB){_error_("not implemented yet");};
+		Input* PointwiseMin(Input* inputB){_error_("not implemented yet");};
 		void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
-		void AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
-		void Configure(Parameters* parameters);
+		Input* SpawnSegInput(int index1,int index2);
+		Input* SpawnTriaInput(int index1,int index2,int index3);
 		/*}}}*/
 		/*numerics: {{{*/
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void ChangeEnum(int newenumtype);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
+		void Extrude(int start){_error_("not supported yet");};
+		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
+		void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
+		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
 		void GetInputValue(bool* pvalue);
 		void GetInputValue(int* pvalue);
@@ -54,16 +63,6 @@
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss){_error_("not implemented yet");};
-		void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");};
-		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
-		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
 		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
-		void ChangeEnum(int newenumtype);
-		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
-		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
-		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
-		void Scale(IssmDouble scale_factor);
-		void AXPY(Input* xinput,IssmDouble scalar);
-		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 		IssmDouble InfinityNorm(void){_error_("InfinityNorm not implemented for integers");};
 		IssmDouble Max(void){_error_("Max not implemented for integers");};
@@ -71,7 +70,8 @@
 		IssmDouble Min(void){_error_("Min not implemented for integers");};
 		IssmDouble MinAbs(void){_error_("Min not implemented for integers");};
-		void Extrude(int start){_error_("not supported yet");};
+		void Scale(IssmDouble scale_factor);
+		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
+		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
 		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 		/*}}}*/
 
Index: /issm/trunk-jpl/src/c/classes/Inputs/PentaInput.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/PentaInput.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/PentaInput.cpp	(revision 20827)
@@ -42,6 +42,8 @@
 
 /*Object virtual functions definitions:*/
-void PentaInput::Echo(void){/*{{{*/
-	this->DeepEcho();
+Object* PentaInput::copy() {/*{{{*/
+
+	return new PentaInput(this->enum_type,this->values,this->interpolation_type);
+
 }
 /*}}}*/
@@ -53,17 +55,9 @@
 }
 /*}}}*/
+void PentaInput::Echo(void){/*{{{*/
+	this->DeepEcho();
+}
+/*}}}*/
 int  PentaInput::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  PentaInput::ObjectEnum(void){/*{{{*/
-
-	return PentaInputEnum;
-
-}
-/*}}}*/
-Object* PentaInput::copy() {/*{{{*/
-
-	return new PentaInput(this->enum_type,this->values,this->interpolation_type);
-
-}
 /*}}}*/
 void PentaInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -81,10 +75,48 @@
 }
 /*}}}*/
+int  PentaInput::ObjectEnum(void){/*{{{*/
+
+	return PentaInputEnum;
+
+}
+/*}}}*/
 
 /*PentaInput management*/
+int  PentaInput::GetResultInterpolation(void){/*{{{*/
+
+	if(this->interpolation_type==P0Enum){
+		return P0Enum;
+	}
+	return P1Enum;
+
+}
+/*}}}*/
+int  PentaInput::GetResultNumberOfNodes(void){/*{{{*/
+
+	return this->NumberofNodes(this->interpolation_type);;
+
+}
+/*}}}*/
 int PentaInput::InstanceEnum(void){/*{{{*/
 
 	return this->enum_type;
 
+}
+/*}}}*/
+void PentaInput::ResultToPatch(IssmDouble* values,int nodesperelement,int sid){/*{{{*/
+
+	int numnodes = this->NumberofNodes(this->interpolation_type);
+
+	/*Some checks*/
+	_assert_(values);
+	_assert_(numnodes==nodesperelement);
+
+	/*Fill in arrays*/
+	for(int i=0;i<numnodes;i++) values[sid*numnodes + i] = this->values[i];
+}
+/*}}}*/
+Input* PentaInput::SpawnSegInput(int index1,int index2){/*{{{*/
+
+	_error_("not supported");
 }
 /*}}}*/
@@ -119,38 +151,29 @@
 }
 /*}}}*/
-Input* PentaInput::SpawnSegInput(int index1,int index2){/*{{{*/
-
-	_error_("not supported");
-}
-/*}}}*/
-int  PentaInput::GetResultInterpolation(void){/*{{{*/
-
-	if(this->interpolation_type==P0Enum){
-		return P0Enum;
-	}
-	return P1Enum;
-
-}
-/*}}}*/
-int  PentaInput::GetResultNumberOfNodes(void){/*{{{*/
-
-	return this->NumberofNodes(this->interpolation_type);;
-
-}
-/*}}}*/
-void PentaInput::ResultToPatch(IssmDouble* values,int nodesperelement,int sid){/*{{{*/
-
-	int numnodes = this->NumberofNodes(this->interpolation_type);
-
-	/*Some checks*/
-	_assert_(values);
-	_assert_(numnodes==nodesperelement);
-
-	/*Fill in arrays*/
-	for(int i=0;i<numnodes;i++) values[sid*numnodes + i] = this->values[i];
-}
-/*}}}*/
 
 /*Object functions*/
+void PentaInput::ChangeEnum(int newenumtype){/*{{{*/
+	this->enum_type=newenumtype;
+}
+/*}}}*/
+void PentaInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
+
+	int        numnodes  = this->NumberofNodes(this->interpolation_type);
+	IssmDouble numnodesd = reCast<int,IssmDouble>(numnodes);
+	IssmDouble value     = 0.;
+
+	for(int i=0;i<numnodes;i++) value+=values[i];
+	value = value/numnodesd;
+
+	*pvalue=value;
+}
+/*}}}*/
+void PentaInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
+
+	/*Call PentaRef function*/
+	_assert_(gauss->Enum()==GaussPentaEnum);
+	PentaRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussPenta*)gauss,this->interpolation_type);
+}
+/*}}}*/
 void PentaInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
 
@@ -169,109 +192,6 @@
 }
 /*}}}*/
-void PentaInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
-
-	/*Call PentaRef function*/
-	_assert_(gauss->Enum()==GaussPentaEnum);
-	PentaRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussPenta*)gauss,this->interpolation_type);
-}
-/*}}}*/
-void PentaInput::ChangeEnum(int newenumtype){/*{{{*/
-	this->enum_type=newenumtype;
-}
-/*}}}*/
-void PentaInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
-
-	int        numnodes  = this->NumberofNodes(this->interpolation_type);
-	IssmDouble numnodesd = reCast<int,IssmDouble>(numnodes);
-	IssmDouble value     = 0.;
-
-	for(int i=0;i<numnodes;i++) value+=values[i];
-	value = value/numnodesd;
-
-	*pvalue=value;
-}
-/*}}}*/
 
 /*Intermediary*/
-void PentaInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
-
-	int        numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble squaremin;
-
-	/*Now, figure out minimum of valuescopy: */
-	squaremin=pow(this->values[0],2);
-	for(int i=1;i<numnodes;i++){
-		if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
-	}
-	/*Assign output pointers:*/
-	*psquaremin=squaremin;
-}
-/*}}}*/
-void PentaInput::ConstrainMin(IssmDouble minimum){/*{{{*/
-
-	int numnodes = this->NumberofNodes(this->interpolation_type);
-	for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
-}
-/*}}}*/
-IssmDouble PentaInput::InfinityNorm(void){/*{{{*/
-
-	/*Output*/
-	IssmDouble norm=0.;
-	int numnodes=this->NumberofNodes(this->interpolation_type);
-
-	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
-	return norm;
-}
-/*}}}*/
-IssmDouble PentaInput::Max(void){/*{{{*/
-
-	int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble max=values[0];
-
-	for(int i=1;i<numnodes;i++){
-		if(values[i]>max) max=values[i];
-	}
-	return max;
-}
-/*}}}*/
-IssmDouble PentaInput::MaxAbs(void){/*{{{*/
-
-	int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble max=fabs(values[0]);
-
-	for(int i=1;i<numnodes;i++){
-		if(fabs(values[i])>max) max=fabs(values[i]);
-	}
-	return max;
-}
-/*}}}*/
-IssmDouble PentaInput::Min(void){/*{{{*/
-
-	const int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble min=values[0];
-
-	for(int i=1;i<numnodes;i++){
-		if(values[i]<min) min=values[i];
-	}
-	return min;
-}
-/*}}}*/
-IssmDouble PentaInput::MinAbs(void){/*{{{*/
-
-	const int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble min=fabs(values[0]);
-
-	for(int i=1;i<numnodes;i++){
-		if(fabs(values[i])<min) min=fabs(values[i]);
-	}
-	return min;
-}
-/*}}}*/
-void PentaInput::Scale(IssmDouble scale_factor){/*{{{*/
-
-	const int numnodes=this->NumberofNodes(this->interpolation_type);
-	for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
-}
-/*}}}*/
 void PentaInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
 
@@ -295,4 +215,8 @@
 }
 /*}}}*/
+void PentaInput::Configure(Parameters* parameters){/*{{{*/
+	/*do nothing: */
+}
+/*}}}*/
 void PentaInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
 
@@ -303,4 +227,10 @@
 	if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
 
+}
+/*}}}*/
+void PentaInput::ConstrainMin(IssmDouble minimum){/*{{{*/
+
+	int numnodes = this->NumberofNodes(this->interpolation_type);
+	for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
 }
 /*}}}*/
@@ -319,4 +249,174 @@
 			_error_("not supported yet for type "<<EnumToStringx(this->interpolation_type));
 	}
+}
+/*}}}*/
+void PentaInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
+	const int numvertices=6;
+	vector->SetValues(numvertices,doflist,this->values,INS_VAL);
+} /*}}}*/
+IssmDouble PentaInput::InfinityNorm(void){/*{{{*/
+
+	/*Output*/
+	IssmDouble norm=0.;
+	int numnodes=this->NumberofNodes(this->interpolation_type);
+
+	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
+	return norm;
+}
+/*}}}*/
+IssmDouble PentaInput::Max(void){/*{{{*/
+
+	int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble max=values[0];
+
+	for(int i=1;i<numnodes;i++){
+		if(values[i]>max) max=values[i];
+	}
+	return max;
+}
+/*}}}*/
+IssmDouble PentaInput::MaxAbs(void){/*{{{*/
+
+	int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble max=fabs(values[0]);
+
+	for(int i=1;i<numnodes;i++){
+		if(fabs(values[i])>max) max=fabs(values[i]);
+	}
+	return max;
+}
+/*}}}*/
+IssmDouble PentaInput::Min(void){/*{{{*/
+
+	const int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble min=values[0];
+
+	for(int i=1;i<numnodes;i++){
+		if(values[i]<min) min=values[i];
+	}
+	return min;
+}
+/*}}}*/
+IssmDouble PentaInput::MinAbs(void){/*{{{*/
+
+	const int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble min=fabs(values[0]);
+
+	for(int i=1;i<numnodes;i++){
+		if(fabs(values[i])<min) min=fabs(values[i]);
+	}
+	return min;
+}
+/*}}}*/
+Input* PentaInput::PointwiseDivide(Input* inputB){/*{{{*/
+
+	/*Ouput*/
+	PentaInput* outinput=NULL;
+
+	/*Intermediaries*/
+	PentaInput *xinputB  = NULL;
+	const int   numnodes = this->NumberofNodes(this->interpolation_type);
+
+	/*Check that inputB is of the same type*/
+	if(inputB->ObjectEnum()!=PentaInputEnum)     _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(PentaInput*)inputB;
+	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
+
+	/*Allocate intermediary*/
+	IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes);
+
+	/*Create point wise sum*/
+	for(int i=0;i<numnodes;i++){
+		_assert_(xinputB->values[i]!=0);
+		AdotBvalues[i]=this->values[i]/xinputB->values[i];
+	}
+
+	/*Create new Penta vertex input (copy of current input)*/
+	outinput=new PentaInput(this->enum_type,AdotBvalues,this->interpolation_type);
+
+	/*Return output pointer*/
+	xDelete<IssmDouble>(AdotBvalues);
+	return outinput;
+
+}
+/*}}}*/
+Input* PentaInput::PointwiseMax(Input* inputB){/*{{{*/
+
+	/*Ouput*/
+	PentaInput* outinput=NULL;
+
+	/*Intermediaries*/
+	int         i;
+	PentaInput  *xinputB   = NULL;
+	const int   numnodes  = this->NumberofNodes(this->interpolation_type);
+	IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
+
+	/*Check that inputB is of the same type*/
+	if(inputB->ObjectEnum()!=PentaInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(PentaInput*)inputB;
+	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
+
+	/*Create point wise max*/
+	for(i=0;i<numnodes;i++){
+		if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
+		else maxvalues[i]=this->values[i];
+	}
+
+	/*Create new Penta vertex input (copy of current input)*/
+	outinput=new PentaInput(this->enum_type,&maxvalues[0],this->interpolation_type);
+
+	/*Return output pointer*/
+	xDelete<IssmDouble>(maxvalues);
+	return outinput;
+}
+/*}}}*/
+Input* PentaInput::PointwiseMin(Input* inputB){/*{{{*/
+
+	/*Ouput*/
+	PentaInput* outinput=NULL;
+
+	/*Intermediaries*/
+	int         i;
+	PentaInput  *xinputB   = NULL;
+	const int   numnodes  = this->NumberofNodes(this->interpolation_type);
+	IssmDouble *minvalues = xNew<IssmDouble>(numnodes);
+
+	/*Check that inputB is of the same type*/
+	if(inputB->ObjectEnum()!=PentaInputEnum)       _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(PentaInput*)inputB;
+	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
+
+	/*Create point wise min*/
+	for(i=0;i<numnodes;i++){
+		if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
+		else minvalues[i]=this->values[i];
+	}
+
+	/*Create new Penta vertex input (copy of current input)*/
+	outinput=new PentaInput(this->enum_type,&minvalues[0],this->interpolation_type);
+
+	/*Return output pointer*/
+	xDelete<IssmDouble>(minvalues);
+	return outinput;
+}
+/*}}}*/
+void PentaInput::Scale(IssmDouble scale_factor){/*{{{*/
+
+	const int numnodes=this->NumberofNodes(this->interpolation_type);
+	for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
+}
+/*}}}*/
+void PentaInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
+
+	int        numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble squaremin;
+
+	/*Now, figure out minimum of valuescopy: */
+	squaremin=pow(this->values[0],2);
+	for(int i=1;i<numnodes;i++){
+		if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
+	}
+	/*Assign output pointers:*/
+	*psquaremin=squaremin;
 }
 /*}}}*/
@@ -351,102 +451,2 @@
 }
 /*}}}*/
-Input* PentaInput::PointwiseDivide(Input* inputB){/*{{{*/
-
-	/*Ouput*/
-	PentaInput* outinput=NULL;
-
-	/*Intermediaries*/
-	PentaInput *xinputB  = NULL;
-	const int   numnodes = this->NumberofNodes(this->interpolation_type);
-
-	/*Check that inputB is of the same type*/
-	if(inputB->ObjectEnum()!=PentaInputEnum)     _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(PentaInput*)inputB;
-	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
-
-	/*Allocate intermediary*/
-	IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes);
-
-	/*Create point wise sum*/
-	for(int i=0;i<numnodes;i++){
-		_assert_(xinputB->values[i]!=0);
-		AdotBvalues[i]=this->values[i]/xinputB->values[i];
-	}
-
-	/*Create new Penta vertex input (copy of current input)*/
-	outinput=new PentaInput(this->enum_type,AdotBvalues,this->interpolation_type);
-
-	/*Return output pointer*/
-	xDelete<IssmDouble>(AdotBvalues);
-	return outinput;
-
-}
-/*}}}*/
-Input* PentaInput::PointwiseMin(Input* inputB){/*{{{*/
-
-	/*Ouput*/
-	PentaInput* outinput=NULL;
-
-	/*Intermediaries*/
-	int         i;
-	PentaInput  *xinputB   = NULL;
-	const int   numnodes  = this->NumberofNodes(this->interpolation_type);
-	IssmDouble *minvalues = xNew<IssmDouble>(numnodes);
-
-	/*Check that inputB is of the same type*/
-	if(inputB->ObjectEnum()!=PentaInputEnum)       _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(PentaInput*)inputB;
-	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
-
-	/*Create point wise min*/
-	for(i=0;i<numnodes;i++){
-		if(this->values[i] > xinputB->values[i]) minvalues[i]=xinputB->values[i];
-		else minvalues[i]=this->values[i];
-	}
-
-	/*Create new Penta vertex input (copy of current input)*/
-	outinput=new PentaInput(this->enum_type,&minvalues[0],this->interpolation_type);
-
-	/*Return output pointer*/
-	xDelete<IssmDouble>(minvalues);
-	return outinput;
-}
-/*}}}*/
-Input* PentaInput::PointwiseMax(Input* inputB){/*{{{*/
-
-	/*Ouput*/
-	PentaInput* outinput=NULL;
-
-	/*Intermediaries*/
-	int         i;
-	PentaInput  *xinputB   = NULL;
-	const int   numnodes  = this->NumberofNodes(this->interpolation_type);
-	IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
-
-	/*Check that inputB is of the same type*/
-	if(inputB->ObjectEnum()!=PentaInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(PentaInput*)inputB;
-	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
-
-	/*Create point wise max*/
-	for(i=0;i<numnodes;i++){
-		if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
-		else maxvalues[i]=this->values[i];
-	}
-
-	/*Create new Penta vertex input (copy of current input)*/
-	outinput=new PentaInput(this->enum_type,&maxvalues[0],this->interpolation_type);
-
-	/*Return output pointer*/
-	xDelete<IssmDouble>(maxvalues);
-	return outinput;
-}
-/*}}}*/
-void PentaInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
-	const int numvertices=6;
-	vector->SetValues(numvertices,doflist,this->values,INS_VAL);
-} /*}}}*/
-void PentaInput::Configure(Parameters* parameters){/*{{{*/
-	/*do nothing: */
-}
-/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Inputs/PentaInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/PentaInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/PentaInput.h	(revision 20827)
@@ -27,15 +27,13 @@
 
 		/*Object virtual functions definitions */
+		Object *copy();
+		void    DeepEcho();
 		void    Echo();
-		void    DeepEcho();
 		int     Id();
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int     ObjectEnum();
-		Object *copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 
 		/*PentaInput management*/
 		int   InstanceEnum();
-		Input* SpawnTriaInput(int index1,int index2,int index3);
-		Input* SpawnSegInput(int index1,int index2);
 		Input* PointwiseDivide(Input* inputB);
 		Input* PointwiseMin(Input* inputB);
@@ -48,4 +46,13 @@
 		void Configure(Parameters* parameters);
 		/*numerics*/
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void ChangeEnum(int newenumtype);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		void ConstrainMin(IssmDouble minimum);
+		void Extrude(int start);
+		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
 		void GetInputValue(bool* pvalue){_error_("not implemented yet");};
 		void GetInputValue(int* pvalue){_error_("not implemented yet");};
@@ -54,16 +61,6 @@
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
-		void GetInputAverage(IssmDouble* pvalue);
-		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
-		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
 		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
-		void ChangeEnum(int newenumtype);
-		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
-		void ConstrainMin(IssmDouble minimum);
-		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
-		void Scale(IssmDouble scale_factor);
-		void AXPY(Input* xinput,IssmDouble scalar);
-		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 		IssmDouble InfinityNorm(void);
 		IssmDouble Max(void);
@@ -71,7 +68,10 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void);
-		void Extrude(int start);
+		void Scale(IssmDouble scale_factor);
+		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
+		Input* SpawnTriaInput(int index1,int index2,int index3);
+		Input* SpawnSegInput(int index1,int index2);
+		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
 		void VerticallyIntegrate(Input* thickness_input);
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 
 };
Index: /issm/trunk-jpl/src/c/classes/Inputs/SegInput.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/SegInput.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/SegInput.cpp	(revision 20827)
@@ -34,6 +34,8 @@
 
 /*Object virtual functions definitions:*/
-void SegInput::Echo(void){/*{{{*/
-	this->DeepEcho();
+Object* SegInput::copy() {/*{{{*/
+
+	return new SegInput(this->enum_type,this->values,this->interpolation_type);
+
 }
 /*}}}*/
@@ -45,17 +47,9 @@
 }
 /*}}}*/
-int  SegInput::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  SegInput::ObjectEnum(void){/*{{{*/
-
-	return SegInputEnum;
-
+void SegInput::Echo(void){/*{{{*/
+	this->DeepEcho();
 }
 /*}}}*/
-Object* SegInput::copy() {/*{{{*/
-
-	return new SegInput(this->enum_type,this->values,this->interpolation_type);
-
-}
+int  SegInput::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void SegInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -73,4 +67,10 @@
 }
 /*}}}*/
+int  SegInput::ObjectEnum(void){/*{{{*/
+
+	return SegInputEnum;
+
+}
+/*}}}*/
 
 /*SegInput management*/
@@ -83,4 +83,8 @@
 
 /*Object functions*/
+void SegInput::Configure(Parameters* parameters){/*{{{*/
+	/*do nothing: */
+}
+/*}}}*/
 void SegInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
 
@@ -95,12 +99,4 @@
 }
 /*}}}*/
-void SegInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
-
-	/*Call SegRef function*/
-	_assert_(gauss->Enum()==GaussSegEnum);
-	SegRef::GetInputValue(pvalue,&values[0],(GaussSeg*)gauss,this->interpolation_type);
-
-}
-/*}}}*/
 void SegInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/
 
@@ -110,6 +106,10 @@
 }
 /*}}}*/
-void SegInput::Configure(Parameters* parameters){/*{{{*/
-	/*do nothing: */
+void SegInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
+
+	/*Call SegRef function*/
+	_assert_(gauss->Enum()==GaussSegEnum);
+	SegRef::GetInputValue(pvalue,&values[0],(GaussSeg*)gauss,this->interpolation_type);
+
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Inputs/SegInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/SegInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/SegInput.h	(revision 20827)
@@ -27,26 +27,35 @@
 
 		/*Object virtual functions definitions*/
+		Object *copy();
+		void    DeepEcho();
 		void    Echo();
-		void    DeepEcho();
 		int     Id();
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int     ObjectEnum();
-		Object *copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 
 		/*SegInput management:*/
-		int    InstanceEnum();
-		Input* SpawnTriaInput(int index1,int index2,int index3){_error_("not supported yet");};
-		Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
-		Input* PointwiseDivide(Input* inputB){_error_("not supported yet");};
-		Input* PointwiseMin(Input* inputB){_error_("not supported yet");};
-		Input* PointwiseMax(Input* inputB){_error_("not supported yet");};
+		void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
+		void   Configure(Parameters* parameters);
+		int  GetResultArraySize(void){_error_("not implemented");};
 		int  GetResultInterpolation(void){_error_("not implemented");};
 		int  GetResultNumberOfNodes(void){_error_("not implemented");};
-		int  GetResultArraySize(void){_error_("not implemented");};
+		int    InstanceEnum();
+		Input* PointwiseDivide(Input* inputB){_error_("not supported yet");};
+		Input* PointwiseMax(Input* inputB){_error_("not supported yet");};
+		Input* PointwiseMin(Input* inputB){_error_("not supported yet");};
 		void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
-		void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
-		void   Configure(Parameters* parameters);
+		Input* SpawnSegInput(int index1,int index2){_error_("not implemented yet");};
+		Input* SpawnTriaInput(int index1,int index2,int index3){_error_("not supported yet");};
 
 		/*numerics*/
+		void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
+		void ChangeEnum(int newenumtype){_error_("not implemented yet");};
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
+		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
+		void Extrude(int start){_error_("not supported yet");};
+		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
 		void GetInputValue(bool* pvalue){_error_("not implemented yet");}
 		void GetInputValue(int* pvalue){_error_("not implemented yet");}
@@ -55,16 +64,6 @@
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
-		void GetInputAverage(IssmDouble* pvalue);
-		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
-		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};
 		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};
-		void ChangeEnum(int newenumtype){_error_("not implemented yet");};
-		void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
-		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
-		void Set(IssmDouble setvalue){_error_("not implemented yet");};
-		void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
-		void AXPY(Input* xinput,IssmDouble scalar){_error_("not implemented yet");};
-		void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
 		IssmDouble InfinityNorm(void){_error_("not implemented yet");};
 		IssmDouble Max(void){_error_("not implemented yet");};
@@ -72,7 +71,8 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void){_error_("not implemented yet");};
-		void Extrude(int start){_error_("not supported yet");};
+		void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
+		void Set(IssmDouble setvalue){_error_("not implemented yet");};
+		void SquareMin(IssmDouble* psquaremin,Parameters* parameters){_error_("not implemented yet");};
 		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");};
 
 };
Index: /issm/trunk-jpl/src/c/classes/Inputs/TetraInput.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/TetraInput.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/TetraInput.cpp	(revision 20827)
@@ -42,6 +42,8 @@
 
 /*Object virtual functions definitions:*/
-void TetraInput::Echo(void){/*{{{*/
-	this->DeepEcho();
+Object* TetraInput::copy() {/*{{{*/
+
+	return new TetraInput(this->enum_type,this->values,this->interpolation_type);
+
 }
 /*}}}*/
@@ -53,17 +55,9 @@
 }
 /*}}}*/
+void TetraInput::Echo(void){/*{{{*/
+	this->DeepEcho();
+}
+/*}}}*/
 int  TetraInput::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  TetraInput::ObjectEnum(void){/*{{{*/
-
-	return TetraInputEnum;
-
-}
-/*}}}*/
-Object* TetraInput::copy() {/*{{{*/
-
-	return new TetraInput(this->enum_type,this->values,this->interpolation_type);
-
-}
 /*}}}*/
 void TetraInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -81,4 +75,10 @@
 }
 /*}}}*/
+int  TetraInput::ObjectEnum(void){/*{{{*/
+
+	return TetraInputEnum;
+
+}
+/*}}}*/
 
 /*TetraInput management*/
@@ -118,33 +118,6 @@
 
 /*Object functions*/
-void TetraInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
-
-	/*Call TetraRef function*/
-	_assert_(gauss->Enum()==GaussTetraEnum);
-	TetraRef::GetInputValue(pvalue,&values[0],(GaussTetra*)gauss,this->interpolation_type);
-
-}
-/*}}}*/
-void TetraInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
-
-	/*Call TetraRef function*/
-	_assert_(gauss->Enum()==GaussTetraEnum);
-	TetraRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussTetra*)gauss,this->interpolation_type);
-}
-/*}}}*/
 void TetraInput::ChangeEnum(int newenumtype){/*{{{*/
 	this->enum_type=newenumtype;
-}
-/*}}}*/
-void TetraInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
-
-	int        numnodes  = this->NumberofNodes(this->interpolation_type);
-	IssmDouble numnodesd = reCast<int,IssmDouble>(numnodes);
-	IssmDouble value     = 0.;
-
-	for(int i=0;i<numnodes;i++) value+=values[i];
-	value = value/numnodesd;
-
-	*pvalue=value;
 }
 /*}}}*/
@@ -168,4 +141,23 @@
 }
 /*}}}*/
+void TetraInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
+
+	int        numnodes  = this->NumberofNodes(this->interpolation_type);
+	IssmDouble numnodesd = reCast<int,IssmDouble>(numnodes);
+	IssmDouble value     = 0.;
+
+	for(int i=0;i<numnodes;i++) value+=values[i];
+	value = value/numnodesd;
+
+	*pvalue=value;
+}
+/*}}}*/
+void TetraInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
+
+	/*Call TetraRef function*/
+	_assert_(gauss->Enum()==GaussTetraEnum);
+	TetraRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussTetra*)gauss,this->interpolation_type);
+}
+/*}}}*/
 void TetraInput::GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/
 
@@ -185,4 +177,12 @@
 	*ptimes=times;
 	*pnumtimes=numtimes;
+}
+/*}}}*/
+void TetraInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
+
+	/*Call TetraRef function*/
+	_assert_(gauss->Enum()==GaussTetraEnum);
+	TetraRef::GetInputValue(pvalue,&values[0],(GaussTetra*)gauss,this->interpolation_type);
+
 }
 /*}}}*/
@@ -219,90 +219,4 @@
 
 /*Intermediary*/
-void TetraInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
-
-	int        numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble squaremin;
-
-	/*Now, figure out minimum of valuescopy: */
-	squaremin=pow(this->values[0],2);
-	for(int i=1;i<numnodes;i++){
-		if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
-	}
-	/*Assign output pointers:*/
-	*psquaremin=squaremin;
-}
-/*}}}*/
-void TetraInput::ConstrainMin(IssmDouble minimum){/*{{{*/
-
-	int numnodes = this->NumberofNodes(this->interpolation_type);
-	for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
-}
-/*}}}*/
-IssmDouble TetraInput::InfinityNorm(void){/*{{{*/
-
-	/*Output*/
-	IssmDouble norm=0.;
-	int numnodes=this->NumberofNodes(this->interpolation_type);
-
-	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
-	return norm;
-}
-/*}}}*/
-IssmDouble TetraInput::Max(void){/*{{{*/
-
-	int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble max=values[0];
-
-	for(int i=1;i<numnodes;i++){
-		if(values[i]>max) max=values[i];
-	}
-	return max;
-}
-/*}}}*/
-IssmDouble TetraInput::MaxAbs(void){/*{{{*/
-
-	int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble max=fabs(values[0]);
-
-	for(int i=1;i<numnodes;i++){
-		if(fabs(values[i])>max) max=fabs(values[i]);
-	}
-	return max;
-}
-/*}}}*/
-IssmDouble TetraInput::Min(void){/*{{{*/
-
-	const int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble min=values[0];
-
-	for(int i=1;i<numnodes;i++){
-		if(values[i]<min) min=values[i];
-	}
-	return min;
-}
-/*}}}*/
-IssmDouble TetraInput::MinAbs(void){/*{{{*/
-
-	const int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble min=fabs(values[0]);
-
-	for(int i=1;i<numnodes;i++){
-		if(fabs(values[i])<min) min=fabs(values[i]);
-	}
-	return min;
-}
-/*}}}*/
-void TetraInput::Scale(IssmDouble scale_factor){/*{{{*/
-
-	const int numnodes=this->NumberofNodes(this->interpolation_type);
-	for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
-}
-/*}}}*/
-void TetraInput::Set(IssmDouble setvalue){/*{{{*/
-
-	const int numnodes=this->NumberofNodes(this->interpolation_type);
-	for(int i=0;i<numnodes;i++)values[i]=setvalue;
-}
-/*}}}*/
 void TetraInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
 
@@ -320,4 +234,8 @@
 }
 /*}}}*/
+void TetraInput::Configure(Parameters* parameters){/*{{{*/
+	/*do nothing: */
+}
+/*}}}*/
 void TetraInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
 
@@ -328,4 +246,10 @@
 	if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
 
+}
+/*}}}*/
+void TetraInput::ConstrainMin(IssmDouble minimum){/*{{{*/
+
+	int numnodes = this->NumberofNodes(this->interpolation_type);
+	for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
 }
 /*}}}*/
@@ -334,4 +258,121 @@
 	vector->SetValues(numvertices,doflist,this->values,INS_VAL);
 } /*}}}*/
+IssmDouble TetraInput::InfinityNorm(void){/*{{{*/
+
+	/*Output*/
+	IssmDouble norm=0.;
+	int numnodes=this->NumberofNodes(this->interpolation_type);
+
+	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
+	return norm;
+}
+/*}}}*/
+IssmDouble TetraInput::MinAbs(void){/*{{{*/
+
+	const int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble min=fabs(values[0]);
+
+	for(int i=1;i<numnodes;i++){
+		if(fabs(values[i])<min) min=fabs(values[i]);
+	}
+	return min;
+}
+/*}}}*/
+IssmDouble TetraInput::Max(void){/*{{{*/
+
+	int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble max=values[0];
+
+	for(int i=1;i<numnodes;i++){
+		if(values[i]>max) max=values[i];
+	}
+	return max;
+}
+/*}}}*/
+IssmDouble TetraInput::MaxAbs(void){/*{{{*/
+
+	int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble max=fabs(values[0]);
+
+	for(int i=1;i<numnodes;i++){
+		if(fabs(values[i])>max) max=fabs(values[i]);
+	}
+	return max;
+}
+/*}}}*/
+IssmDouble TetraInput::Min(void){/*{{{*/
+
+	const int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble min=values[0];
+
+	for(int i=1;i<numnodes;i++){
+		if(values[i]<min) min=values[i];
+	}
+	return min;
+}
+/*}}}*/
+Input* TetraInput::PointwiseDivide(Input* inputB){/*{{{*/
+
+	/*Ouput*/
+	TetraInput* outinput=NULL;
+
+	/*Intermediaries*/
+	TetraInput *xinputB  = NULL;
+	const int   numnodes = this->NumberofNodes(this->interpolation_type);
+
+	/*Check that inputB is of the same type*/
+	if(inputB->ObjectEnum()!=TetraInputEnum)     _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(TetraInput*)inputB;
+	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
+
+	/*Allocate intermediary*/
+	IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes);
+
+	/*Create point wise division*/
+	for(int i=0;i<numnodes;i++){
+		_assert_(xinputB->values[i]!=0);
+		AdotBvalues[i]=this->values[i]/xinputB->values[i];
+	}
+
+	/*Create new Tetra vertex input (copy of current input)*/
+	outinput=new TetraInput(this->enum_type,AdotBvalues,this->interpolation_type);
+
+	/*Return output pointer*/
+	xDelete<IssmDouble>(AdotBvalues);
+	return outinput;
+
+}
+/*}}}*/
+Input* TetraInput::PointwiseMax(Input* inputB){/*{{{*/
+
+	/*Ouput*/
+	TetraInput* outinput=NULL;
+
+	/*Intermediaries*/
+	int         i;
+	TetraInput  *xinputB   = NULL;
+	const int   numnodes  = this->NumberofNodes(this->interpolation_type);
+	IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
+
+	/*Check that inputB is of the same type*/
+	if(inputB->ObjectEnum()!=TetraInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(TetraInput*)inputB;
+	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
+
+	/*Create point wise max*/
+	for(i=0;i<numnodes;i++){
+		if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
+		else maxvalues[i]=this->values[i];
+	}
+
+	/*Create new Tetra vertex input (copy of current input)*/
+	outinput=new TetraInput(this->enum_type,&maxvalues[0],this->interpolation_type);
+
+	/*Return output pointer*/
+	xDelete<IssmDouble>(maxvalues);
+	return outinput;
+
+}
+/*}}}*/
 Input* TetraInput::PointwiseMin(Input* inputB){/*{{{*/
 
@@ -365,69 +406,28 @@
 }
 /*}}}*/
-Input* TetraInput::PointwiseMax(Input* inputB){/*{{{*/
-
-	/*Ouput*/
-	TetraInput* outinput=NULL;
-
-	/*Intermediaries*/
-	int         i;
-	TetraInput  *xinputB   = NULL;
-	const int   numnodes  = this->NumberofNodes(this->interpolation_type);
-	IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
-
-	/*Check that inputB is of the same type*/
-	if(inputB->ObjectEnum()!=TetraInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(TetraInput*)inputB;
-	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
-
-	/*Create point wise max*/
-	for(i=0;i<numnodes;i++){
-		if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
-		else maxvalues[i]=this->values[i];
-	}
-
-	/*Create new Tetra vertex input (copy of current input)*/
-	outinput=new TetraInput(this->enum_type,&maxvalues[0],this->interpolation_type);
-
-	/*Return output pointer*/
-	xDelete<IssmDouble>(maxvalues);
-	return outinput;
-
-}
-/*}}}*/
-Input* TetraInput::PointwiseDivide(Input* inputB){/*{{{*/
-
-	/*Ouput*/
-	TetraInput* outinput=NULL;
-
-	/*Intermediaries*/
-	TetraInput *xinputB  = NULL;
-	const int   numnodes = this->NumberofNodes(this->interpolation_type);
-
-	/*Check that inputB is of the same type*/
-	if(inputB->ObjectEnum()!=TetraInputEnum)     _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(TetraInput*)inputB;
-	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
-
-	/*Allocate intermediary*/
-	IssmDouble* AdotBvalues=xNew<IssmDouble>(numnodes);
-
-	/*Create point wise division*/
-	for(int i=0;i<numnodes;i++){
-		_assert_(xinputB->values[i]!=0);
-		AdotBvalues[i]=this->values[i]/xinputB->values[i];
-	}
-
-	/*Create new Tetra vertex input (copy of current input)*/
-	outinput=new TetraInput(this->enum_type,AdotBvalues,this->interpolation_type);
-
-	/*Return output pointer*/
-	xDelete<IssmDouble>(AdotBvalues);
-	return outinput;
-
-}
-/*}}}*/
-void TetraInput::Configure(Parameters* parameters){/*{{{*/
-	/*do nothing: */
-}
-/*}}}*/
+void TetraInput::Scale(IssmDouble scale_factor){/*{{{*/
+
+	const int numnodes=this->NumberofNodes(this->interpolation_type);
+	for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
+}
+/*}}}*/
+void TetraInput::Set(IssmDouble setvalue){/*{{{*/
+
+	const int numnodes=this->NumberofNodes(this->interpolation_type);
+	for(int i=0;i<numnodes;i++)values[i]=setvalue;
+}
+/*}}}*/
+void TetraInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
+
+	int        numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble squaremin;
+
+	/*Now, figure out minimum of valuescopy: */
+	squaremin=pow(this->values[0],2);
+	for(int i=1;i<numnodes;i++){
+		if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
+	}
+	/*Assign output pointers:*/
+	*psquaremin=squaremin;
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Inputs/TetraInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/TetraInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/TetraInput.h	(revision 20827)
@@ -27,26 +27,35 @@
 
 		/*Object virtual functions definitions*/
+		Object *copy();
+		void    DeepEcho();
 		void    Echo();
-		void    DeepEcho();
 		int     Id();
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int     ObjectEnum();
-		Object *copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 
 		/*TetraInput management:*/
-		int    InstanceEnum();
-		Input* SpawnTriaInput(int index1,int index2,int index3);
-		Input* SpawnSegInput(int index1,int index2){_error_("not supported yet");};
-		Input* PointwiseDivide(Input* inputB);
-		Input* PointwiseMin(Input* inputB);
-		Input* PointwiseMax(Input* inputB);
+		void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
+		void   Configure(Parameters* parameters);
+		int    GetResultArraySize(void){return 1;};
 		int    GetResultInterpolation(void);
 		int    GetResultNumberOfNodes(void);
-		int    GetResultArraySize(void){return 1;};
+		int    InstanceEnum();
+		Input* PointwiseDivide(Input* inputB);
+		Input* PointwiseMax(Input* inputB);
+		Input* PointwiseMin(Input* inputB);
 		void   ResultToPatch(IssmDouble* values,int nodesperelement,int sid);
-		void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
-		void   Configure(Parameters* parameters);
+		Input* SpawnSegInput(int index1,int index2){_error_("not supported yet");};
+		Input* SpawnTriaInput(int index1,int index2,int index3);
 
 		/*numerics*/
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void ChangeEnum(int newenumtype);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		void ConstrainMin(IssmDouble minimum);
+		void Extrude(int start){_error_("not supported yet");};
+		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
 		void GetInputValue(bool* pvalue){_error_("not implemented yet");}
 		void GetInputValue(int* pvalue){_error_("not implemented yet");}
@@ -55,16 +64,6 @@
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
-		void GetInputAverage(IssmDouble* pvalue);
-		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
-		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
 		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);
-		void ChangeEnum(int newenumtype);
-		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
-		void ConstrainMin(IssmDouble minimum);
-		void Set(IssmDouble setvalue);
-		void Scale(IssmDouble scale_factor);
-		void AXPY(Input* xinput,IssmDouble scalar);
-		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 		IssmDouble InfinityNorm(void);
 		IssmDouble Max(void);
@@ -72,7 +71,8 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void);
-		void Extrude(int start){_error_("not supported yet");};
+		void Scale(IssmDouble scale_factor);
+		void Set(IssmDouble setvalue);
+		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
 		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 
 };
Index: /issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp	(revision 20827)
@@ -62,6 +62,18 @@
 
 /*Object virtual functions definitions:*/
-void TransientInput::Echo(void){/*{{{*/
-	this->DeepEcho();
+Object* TransientInput::copy() {/*{{{*/
+
+	TransientInput* output=NULL;
+
+	output = new TransientInput();
+	output->enum_type=this->enum_type;
+	output->numtimesteps=this->numtimesteps;
+	output->timesteps=xNew<IssmDouble>(this->numtimesteps);
+	xMemCpy(output->timesteps,this->timesteps,this->numtimesteps);
+	output->inputs=static_cast<Inputs*>(this->inputs->Copy());
+	output->parameters=this->parameters;
+
+	return (Object*)output;
+
 }
 /*}}}*/
@@ -80,27 +92,9 @@
 }
 /*}}}*/
+void TransientInput::Echo(void){/*{{{*/
+	this->DeepEcho();
+}
+/*}}}*/
 int  TransientInput::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  TransientInput::ObjectEnum(void){/*{{{*/
-
-	return TransientInputEnum;
-
-}
-/*}}}*/
-Object* TransientInput::copy() {/*{{{*/
-
-	TransientInput* output=NULL;
-
-	output = new TransientInput();
-	output->enum_type=this->enum_type;
-	output->numtimesteps=this->numtimesteps;
-	output->timesteps=xNew<IssmDouble>(this->numtimesteps);
-	xMemCpy(output->timesteps,this->timesteps,this->numtimesteps);
-	output->inputs=static_cast<Inputs*>(this->inputs->Copy());
-	output->parameters=this->parameters;
-
-	return (Object*)output;
-
-}
 /*}}}*/
 void TransientInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -116,4 +110,10 @@
 }
 /*}}}*/
+int  TransientInput::ObjectEnum(void){/*{{{*/
+
+	return TransientInputEnum;
+
+}
+/*}}}*/
 
 /*TransientInput management*/
@@ -121,4 +121,23 @@
 
 	return this->enum_type;
+
+}
+/*}}}*/
+Input* TransientInput::SpawnSegInput(int index1,int index2){/*{{{*/
+
+	/*output*/
+	TransientInput* outinput=NULL;
+
+	/*Create new Transientinput (copy of current input)*/
+	outinput=new TransientInput();
+	outinput->enum_type=this->enum_type;
+	outinput->numtimesteps=this->numtimesteps;
+	outinput->timesteps=xNew<IssmDouble>(this->numtimesteps);
+	xMemCpy(outinput->timesteps,this->timesteps,this->numtimesteps);
+	outinput->inputs=(Inputs*)this->inputs->SpawnSegInputs(index1,index2);
+	outinput->parameters=this->parameters;
+
+	/*Assign output*/
+	return outinput;
 
 }
@@ -143,86 +162,8 @@
 }
 /*}}}*/
-Input* TransientInput::SpawnSegInput(int index1,int index2){/*{{{*/
-
-	/*output*/
-	TransientInput* outinput=NULL;
-
-	/*Create new Transientinput (copy of current input)*/
-	outinput=new TransientInput();
-	outinput->enum_type=this->enum_type;
-	outinput->numtimesteps=this->numtimesteps;
-	outinput->timesteps=xNew<IssmDouble>(this->numtimesteps);
-	xMemCpy(outinput->timesteps,this->timesteps,this->numtimesteps);
-	outinput->inputs=(Inputs*)this->inputs->SpawnSegInputs(index1,index2);
-	outinput->parameters=this->parameters;
-
-	/*Assign output*/
-	return outinput;
-
-}
-/*}}}*/
 
 /*Object functions*/
-void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
-	IssmDouble time;
-
-	/*First, recover current time from parameters: */
-	this->parameters->FindParam(&time,TimeEnum);
-
-	/*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	input->GetInputValue(pvalue,gauss);
-
-	delete input;
-}
-/*}}}*/
-void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){/*{{{*/
-
-	/*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	input->GetInputValue(pvalue,gauss);
-
-	delete input;
-}
-/*}}}*/
-void TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
-
-	IssmDouble time;
-
-	/*First, recover current time from parameters: */
-	parameters->FindParam(&time,TimeEnum);
-
-	/*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	input->GetInputDerivativeValue(p,xyz_list,gauss);
-
-	delete input;
-}
-/*}}}*/
 void TransientInput::ChangeEnum(int newenumtype){/*{{{*/
 	this->enum_type=newenumtype;
-}
-/*}}}*/
-void TransientInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
-
-	IssmDouble time;
-
-	/*First, recover current time from parameters: */
-	parameters->FindParam(&time,TimeEnum);
-
-	/*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	input->GetInputAverage(pvalue);
-
-	delete input;
-
 }
 /*}}}*/
@@ -246,4 +187,63 @@
 	*ptimes=times;
 	*pnumtimes=numtimesteps;
+}
+/*}}}*/
+void TransientInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/
+
+	IssmDouble time;
+
+	/*First, recover current time from parameters: */
+	parameters->FindParam(&time,TimeEnum);
+
+	/*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	input->GetInputAverage(pvalue);
+
+	delete input;
+
+}
+/*}}}*/
+void TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
+
+	IssmDouble time;
+
+	/*First, recover current time from parameters: */
+	parameters->FindParam(&time,TimeEnum);
+
+	/*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	input->GetInputDerivativeValue(p,xyz_list,gauss);
+
+	delete input;
+}
+/*}}}*/
+void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
+	IssmDouble time;
+
+	/*First, recover current time from parameters: */
+	this->parameters->FindParam(&time,TimeEnum);
+
+	/*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	input->GetInputValue(pvalue,gauss);
+
+	delete input;
+}
+/*}}}*/
+void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){/*{{{*/
+
+	/*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	input->GetInputValue(pvalue,gauss);
+
+	delete input;
 }
 /*}}}*/
@@ -327,37 +327,6 @@
 }
 /*}}}*/
-int  TransientInput::GetResultInterpolation(void){/*{{{*/
-
-	IssmDouble time;
-	int        output;
-
-	parameters->FindParam(&time,TimeEnum);
-	Input* input=GetTimeInput(time);
-	output = input->GetResultInterpolation();
-
-	/*Clean up and return*/
-	delete input;
-	return output;
-
-}
-/*}}}*/
-int  TransientInput::GetResultNumberOfNodes(void){/*{{{*/
-
-	IssmDouble time;
-	int        output;
-
-	parameters->FindParam(&time,TimeEnum);
-	Input* input=GetTimeInput(time);
-	output = input->GetResultNumberOfNodes();
-
-	/*Clean up and return*/
-	delete input;
-	return output;
-
-}
-/*}}}*/
-int  TransientInput::GetResultArraySize(void){/*{{{*/
-
-	return 1;
+void TransientInput::Configure(Parameters* parameters){/*{{{*/
+	this->parameters=parameters;
 }
 /*}}}*/
@@ -369,134 +338,39 @@
 }
 /*}}}*/
-void TransientInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
-
-	IssmDouble time;
-
-	/*First, recover current time from parameters: */
-	parameters->FindParam(&time,TimeEnum);
-
-   /*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	input->SquareMin(psquaremin,parameters);
-
-	delete input;
-
-}
-/*}}}*/
-IssmDouble TransientInput::InfinityNorm(void){/*{{{*/
-
-	IssmDouble time;
-	IssmDouble infnorm;
-
-	/*First, recover current time from parameters: */
-	parameters->FindParam(&time,TimeEnum);
-
-   /*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	infnorm=input->InfinityNorm();
-
-	/*Clean-up and return*/
-	delete input;
-	return infnorm;
-}
-/*}}}*/
-IssmDouble TransientInput::Max(void){/*{{{*/
-
-	IssmDouble time;
-	IssmDouble max;
-
-	/*First, recover current time from parameters: */
-	parameters->FindParam(&time,TimeEnum);
-
-   /*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	max=input->Max();
-
-	delete input;
-
-	return max;
-}
-/*}}}*/
-IssmDouble TransientInput::MaxAbs(void){/*{{{*/
-
-	IssmDouble time;
-	IssmDouble maxabs;
-
-	/*First, recover current time from parameters: */
-	parameters->FindParam(&time,TimeEnum);
-
-	/*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	maxabs=input->MaxAbs();
-
-	/*Clean-up and return*/
-	delete input;
-	return maxabs;
-
-}
-/*}}}*/
-IssmDouble TransientInput::Min(void){/*{{{*/
-
-	IssmDouble time;
-	IssmDouble min;
-
-	/*First, recover current time from parameters: */
-	parameters->FindParam(&time,TimeEnum);
-
-   /*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	min=input->Min();
-
-	/*Clean-up and return*/
-	delete input;
-	return min;
-
-}
-/*}}}*/
-IssmDouble TransientInput::MinAbs(void){/*{{{*/
-
-	IssmDouble time;
-	IssmDouble minabs;
-
-	/*First, recover current time from parameters: */
-	parameters->FindParam(&time,TimeEnum);
-
-	/*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	minabs=input->MinAbs();
-
-	/*Clean-up and return*/
-	delete input;
-	return minabs;
-}
-/*}}}*/
-void TransientInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
-
-	IssmDouble time;
-
-	/*First, recover current time from parameters: */
-	parameters->FindParam(&time,TimeEnum);
-
-	/*Retrieve interpolated values for this time step: */
-	Input* input=GetTimeInput(time);
-
-	/*Call input function*/
-	input->GetVectorFromInputs(vector,doflist);
-
-	delete input;
-
-} /*}}}*/
+int  TransientInput::GetResultArraySize(void){/*{{{*/
+
+	return 1;
+}
+/*}}}*/
+int  TransientInput::GetResultInterpolation(void){/*{{{*/
+
+	IssmDouble time;
+	int        output;
+
+	parameters->FindParam(&time,TimeEnum);
+	Input* input=GetTimeInput(time);
+	output = input->GetResultInterpolation();
+
+	/*Clean up and return*/
+	delete input;
+	return output;
+
+}
+/*}}}*/
+int  TransientInput::GetResultNumberOfNodes(void){/*{{{*/
+
+	IssmDouble time;
+	int        output;
+
+	parameters->FindParam(&time,TimeEnum);
+	Input* input=GetTimeInput(time);
+	output = input->GetResultNumberOfNodes();
+
+	/*Clean up and return*/
+	delete input;
+	return output;
+
+}
+/*}}}*/
 Input* TransientInput::GetTimeInput(IssmDouble intime){/*{{{*/
 
@@ -548,6 +422,132 @@
 }
 /*}}}*/
-void TransientInput::Configure(Parameters* parameters){/*{{{*/
-	this->parameters=parameters;
-}
-/*}}}*/
+void TransientInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
+
+	IssmDouble time;
+
+	/*First, recover current time from parameters: */
+	parameters->FindParam(&time,TimeEnum);
+
+	/*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	input->GetVectorFromInputs(vector,doflist);
+
+	delete input;
+
+} /*}}}*/
+IssmDouble TransientInput::InfinityNorm(void){/*{{{*/
+
+	IssmDouble time;
+	IssmDouble infnorm;
+
+	/*First, recover current time from parameters: */
+	parameters->FindParam(&time,TimeEnum);
+
+   /*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	infnorm=input->InfinityNorm();
+
+	/*Clean-up and return*/
+	delete input;
+	return infnorm;
+}
+/*}}}*/
+IssmDouble TransientInput::Max(void){/*{{{*/
+
+	IssmDouble time;
+	IssmDouble max;
+
+	/*First, recover current time from parameters: */
+	parameters->FindParam(&time,TimeEnum);
+
+   /*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	max=input->Max();
+
+	delete input;
+
+	return max;
+}
+/*}}}*/
+IssmDouble TransientInput::MaxAbs(void){/*{{{*/
+
+	IssmDouble time;
+	IssmDouble maxabs;
+
+	/*First, recover current time from parameters: */
+	parameters->FindParam(&time,TimeEnum);
+
+	/*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	maxabs=input->MaxAbs();
+
+	/*Clean-up and return*/
+	delete input;
+	return maxabs;
+
+}
+/*}}}*/
+IssmDouble TransientInput::Min(void){/*{{{*/
+
+	IssmDouble time;
+	IssmDouble min;
+
+	/*First, recover current time from parameters: */
+	parameters->FindParam(&time,TimeEnum);
+
+   /*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	min=input->Min();
+
+	/*Clean-up and return*/
+	delete input;
+	return min;
+
+}
+/*}}}*/
+IssmDouble TransientInput::MinAbs(void){/*{{{*/
+
+	IssmDouble time;
+	IssmDouble minabs;
+
+	/*First, recover current time from parameters: */
+	parameters->FindParam(&time,TimeEnum);
+
+	/*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	minabs=input->MinAbs();
+
+	/*Clean-up and return*/
+	delete input;
+	return minabs;
+}
+/*}}}*/
+void TransientInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
+
+	IssmDouble time;
+
+	/*First, recover current time from parameters: */
+	parameters->FindParam(&time,TimeEnum);
+
+   /*Retrieve interpolated values for this time step: */
+	Input* input=GetTimeInput(time);
+
+	/*Call input function*/
+	input->SquareMin(psquaremin,parameters);
+
+	delete input;
+
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h	(revision 20827)
@@ -32,25 +32,34 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{*/
+		Object* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id();
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*TransientInput management: {{{*/
-		int    InstanceEnum();
-		Input* SpawnTriaInput(int index1,int index2,int index3);
-		Input* SpawnSegInput(int index1,int index2);
-		Input* PointwiseDivide(Input* input_in){_error_("not implemented yet");};
-		Input* PointwiseMin(Input* input_in){_error_("not implemented yet");};
-		Input* PointwiseMax(Input* input_in){_error_("not implemented yet");};
+		void Configure(Parameters* parameters);
+		int  GetResultArraySize(void);
 		int  GetResultInterpolation(void);
 		int  GetResultNumberOfNodes(void);
-		int  GetResultArraySize(void);
+		int    InstanceEnum();
+		Input* PointwiseDivide(Input* input_in){_error_("not implemented yet");};
+		Input* PointwiseMax(Input* input_in){_error_("not implemented yet");};
+		Input* PointwiseMin(Input* input_in){_error_("not implemented yet");};
 		void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");};
-		void Configure(Parameters* parameters);
+		Input* SpawnSegInput(int index1,int index2);
+		Input* SpawnTriaInput(int index1,int index2,int index3);
 		/*}}}*/
 		/*numerics: {{{*/
+		void AXPY(Input* xforcing,IssmDouble scalar){_error_("not implemented yet");};
+		void ChangeEnum(int newenumtype);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
+		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
+		void Extrude(int start);
+		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
 		void GetInputValue(bool* pvalue){_error_("not implemented yet");};
 		void GetInputValue(int* pvalue){_error_("not implemented yet");};
@@ -59,16 +68,8 @@
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time);
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
-		void GetInputAverage(IssmDouble* pvalue);
-		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");};
-		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
 		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);
-		void ChangeEnum(int newenumtype);
-		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
-		void ConstrainMin(IssmDouble minimum){_error_("not implemented yet");};
-		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
-		void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
-		void AXPY(Input* xforcing,IssmDouble scalar){_error_("not implemented yet");};
-		void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("not implemented yet");};
+		Input* GetTimeInput(IssmDouble time);
+		void GetTimeValues(IssmDouble* values,IssmDouble time){_error_("not implemented yet");};
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 		IssmDouble InfinityNorm(void);
 		IssmDouble Max(void);
@@ -76,9 +77,8 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void);
-		void Extrude(int start);
+		void Scale(IssmDouble scale_factor){_error_("not implemented yet");};
+		void Set(IssmDouble setvalue){_error_("Set not implemented yet");};
+		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
 		void VerticallyIntegrate(Input* thickness_forcing){_error_("not supported yet");};
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
-		void GetTimeValues(IssmDouble* values,IssmDouble time){_error_("not implemented yet");};
-		Input* GetTimeInput(IssmDouble time);
 		/*}}}*/
 
Index: /issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp	(revision 20827)
@@ -41,6 +41,8 @@
 
 /*Object virtual functions definitions:*/
-void TriaInput::Echo(void){/*{{{*/
-	this->DeepEcho();
+Object* TriaInput::copy() {/*{{{*/
+
+	return new TriaInput(this->enum_type,this->values,this->interpolation_type);
+
 }
 /*}}}*/
@@ -52,17 +54,9 @@
 }
 /*}}}*/
+void TriaInput::Echo(void){/*{{{*/
+	this->DeepEcho();
+}
+/*}}}*/
 int  TriaInput::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  TriaInput::ObjectEnum(void){/*{{{*/
-
-	return TriaInputEnum;
-
-}
-/*}}}*/
-Object* TriaInput::copy() {/*{{{*/
-
-	return new TriaInput(this->enum_type,this->values,this->interpolation_type);
-
-}
 /*}}}*/
 void TriaInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -80,4 +74,10 @@
 }
 /*}}}*/
+int  TriaInput::ObjectEnum(void){/*{{{*/
+
+	return TriaInputEnum;
+
+}
+/*}}}*/
 
 /*TriaInput management*/
@@ -88,15 +88,35 @@
 }
 /*}}}*/
-Input* TriaInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
-
-	/*output*/
-	TriaInput* outinput=NULL;
-
-	/*Create new Tria input (copy of current input)*/
-	outinput=new TriaInput(this->enum_type,&this->values[0],this->interpolation_type);
-
-	/*Assign output*/
-	return outinput;
-
+int  TriaInput::GetResultArraySize(void){/*{{{*/
+
+	return 1;
+
+}
+/*}}}*/
+int  TriaInput::GetResultInterpolation(void){/*{{{*/
+
+	if(this->interpolation_type==P0Enum){
+		return P0Enum;
+	}
+	return P1Enum;
+
+}
+/*}}}*/
+int  TriaInput::GetResultNumberOfNodes(void){/*{{{*/
+
+	return this->NumberofNodes(this->interpolation_type);
+
+}
+/*}}}*/
+void TriaInput::ResultToPatch(IssmDouble* values,int nodesperelement,int sid){/*{{{*/
+
+	int numnodes = this->NumberofNodes(this->interpolation_type);
+
+	/*Some checks*/
+	_assert_(values);
+	_assert_(numnodes==nodesperelement);
+
+	/*Fill in arrays*/
+	for(int i=0;i<numnodes;i++) values[sid*numnodes + i] = this->values[i];
 }
 /*}}}*/
@@ -126,56 +146,40 @@
 }
 /*}}}*/
-int  TriaInput::GetResultInterpolation(void){/*{{{*/
-
-	if(this->interpolation_type==P0Enum){
-		return P0Enum;
-	}
-	return P1Enum;
-
-}
-/*}}}*/
-int  TriaInput::GetResultNumberOfNodes(void){/*{{{*/
-
-	return this->NumberofNodes(this->interpolation_type);
-
-}
-/*}}}*/
-int  TriaInput::GetResultArraySize(void){/*{{{*/
-
-	return 1;
-
-}
-/*}}}*/
-void TriaInput::ResultToPatch(IssmDouble* values,int nodesperelement,int sid){/*{{{*/
-
-	int numnodes = this->NumberofNodes(this->interpolation_type);
-
-	/*Some checks*/
-	_assert_(values);
-	_assert_(numnodes==nodesperelement);
-
-	/*Fill in arrays*/
-	for(int i=0;i<numnodes;i++) values[sid*numnodes + i] = this->values[i];
+Input* TriaInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
+
+	/*output*/
+	TriaInput* outinput=NULL;
+
+	/*Create new Tria input (copy of current input)*/
+	outinput=new TriaInput(this->enum_type,&this->values[0],this->interpolation_type);
+
+	/*Assign output*/
+	return outinput;
+
 }
 /*}}}*/
 
 /*Object functions*/
-void TriaInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
-
-	/*Call TriaRef function*/
-	_assert_(gauss->Enum()==GaussTriaEnum);
-	TriaRef::GetInputValue(pvalue,&values[0],(GaussTria*)gauss,this->interpolation_type);
-
-}
-/*}}}*/
-void TriaInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
-
-	/*Call TriaRef function*/
-	_assert_(gauss->Enum()==GaussTriaEnum);
-	TriaRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussTria*)gauss,this->interpolation_type);
-}
-/*}}}*/
 void TriaInput::ChangeEnum(int newenumtype){/*{{{*/
 	this->enum_type=newenumtype;
+}
+/*}}}*/
+void TriaInput::GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/
+
+	IssmDouble* outvalues=NULL;
+	IssmDouble* times=NULL;
+	int         numtimes;
+
+	/*this is not a transient forcing, so we only have 1 value, steady state: */
+	numtimes=1;
+	outvalues=xNew<IssmDouble>(1);
+	times=xNew<IssmDouble>(1);
+
+	this->GetInputAverage(&outvalues[0]);
+	times[0]=0.; /*we don't have a time*/
+
+	*pvalues=outvalues;
+	*ptimes=times;
+	*pnumtimes=numtimes;
 }
 /*}}}*/
@@ -212,5 +216,12 @@
 }
 /*}}}*/
-void TriaInput::GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/
+void TriaInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/
+
+	/*Call TriaRef function*/
+	_assert_(gauss->Enum()==GaussTriaEnum);
+	TriaRef::GetInputDerivativeValue(p,&values[0],xyz_list,(GaussTria*)gauss,this->interpolation_type);
+}
+/*}}}*/
+void TriaInput::GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/
 
 	IssmDouble* outvalues=NULL;
@@ -224,5 +235,5 @@
 
 	this->GetInputAverage(&outvalues[0]);
-	times[0]=0.; /*we don't have a time*/
+	times[0]=currenttime; /*we don't have a time*/
 
 	*pvalues=outvalues;
@@ -231,111 +242,14 @@
 }
 /*}}}*/
-void TriaInput::GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/
-
-	IssmDouble* outvalues=NULL;
-	IssmDouble* times=NULL;
-	int         numtimes;
-
-	/*this is not a transient forcing, so we only have 1 value, steady state: */
-	numtimes=1;
-	outvalues=xNew<IssmDouble>(1);
-	times=xNew<IssmDouble>(1);
-
-	this->GetInputAverage(&outvalues[0]);
-	times[0]=currenttime; /*we don't have a time*/
-
-	*pvalues=outvalues;
-	*ptimes=times;
-	*pnumtimes=numtimes;
+void TriaInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/
+
+	/*Call TriaRef function*/
+	_assert_(gauss->Enum()==GaussTriaEnum);
+	TriaRef::GetInputValue(pvalue,&values[0],(GaussTria*)gauss,this->interpolation_type);
+
 }
 /*}}}*/
 
 /*Intermediary*/
-void TriaInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
-
-	int        numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble squaremin;
-
-	/*Now, figure out minimum of valuescopy: */
-	squaremin=pow(this->values[0],2);
-	for(int i=1;i<numnodes;i++){
-		if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
-	}
-	/*Assign output pointers:*/
-	*psquaremin=squaremin;
-}
-/*}}}*/
-void TriaInput::ConstrainMin(IssmDouble minimum){/*{{{*/
-
-	int numnodes = this->NumberofNodes(this->interpolation_type);
-	for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
-}
-/*}}}*/
-IssmDouble TriaInput::InfinityNorm(void){/*{{{*/
-
-	/*Output*/
-	IssmDouble norm=0.;
-	int numnodes=this->NumberofNodes(this->interpolation_type);
-
-	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
-	return norm;
-}
-/*}}}*/
-IssmDouble TriaInput::Max(void){/*{{{*/
-
-	int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble max=values[0];
-
-	for(int i=1;i<numnodes;i++){
-		if(values[i]>max) max=values[i];
-	}
-	return max;
-}
-/*}}}*/
-IssmDouble TriaInput::MaxAbs(void){/*{{{*/
-
-	int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble max=fabs(values[0]);
-
-	for(int i=1;i<numnodes;i++){
-		if(fabs(values[i])>max) max=fabs(values[i]);
-	}
-	return max;
-}
-/*}}}*/
-IssmDouble TriaInput::Min(void){/*{{{*/
-
-	const int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble min=values[0];
-
-	for(int i=1;i<numnodes;i++){
-		if(values[i]<min) min=values[i];
-	}
-	return min;
-}
-/*}}}*/
-IssmDouble TriaInput::MinAbs(void){/*{{{*/
-
-	const int  numnodes=this->NumberofNodes(this->interpolation_type);
-	IssmDouble min=fabs(values[0]);
-
-	for(int i=1;i<numnodes;i++){
-		if(fabs(values[i])<min) min=fabs(values[i]);
-	}
-	return min;
-}
-/*}}}*/
-void TriaInput::Scale(IssmDouble scale_factor){/*{{{*/
-
-	const int numnodes=this->NumberofNodes(this->interpolation_type);
-	for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
-}
-/*}}}*/
-void TriaInput::Set(IssmDouble setvalue){/*{{{*/
-
-	const int numnodes=this->NumberofNodes(this->interpolation_type);
-	for(int i=0;i<numnodes;i++)values[i]=setvalue;
-}
-/*}}}*/
 void TriaInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
 
@@ -353,4 +267,8 @@
 }
 /*}}}*/
+void TriaInput::Configure(Parameters* parameters){/*{{{*/
+	/*do nothing: */
+}
+/*}}}*/
 void TriaInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
 
@@ -361,4 +279,10 @@
 	if(!xIsNan<IssmDouble>(cm_max)) for(i=0;i<numnodes;i++)if (this->values[i]>cm_max)this->values[i]=cm_max;
 
+}
+/*}}}*/
+void TriaInput::ConstrainMin(IssmDouble minimum){/*{{{*/
+
+	int numnodes = this->NumberofNodes(this->interpolation_type);
+	for(int i=0;i<numnodes;i++) if (values[i]<minimum) values[i]=minimum;
 }
 /*}}}*/
@@ -367,4 +291,89 @@
 	vector->SetValues(numvertices,doflist,this->values,INS_VAL);
 } /*}}}*/
+IssmDouble TriaInput::InfinityNorm(void){/*{{{*/
+
+	/*Output*/
+	IssmDouble norm=0.;
+	int numnodes=this->NumberofNodes(this->interpolation_type);
+
+	for(int i=0;i<numnodes;i++) if(fabs(values[i])>norm) norm=fabs(values[i]);
+	return norm;
+}
+/*}}}*/
+IssmDouble TriaInput::Max(void){/*{{{*/
+
+	int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble max=values[0];
+
+	for(int i=1;i<numnodes;i++){
+		if(values[i]>max) max=values[i];
+	}
+	return max;
+}
+/*}}}*/
+IssmDouble TriaInput::MaxAbs(void){/*{{{*/
+
+	int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble max=fabs(values[0]);
+
+	for(int i=1;i<numnodes;i++){
+		if(fabs(values[i])>max) max=fabs(values[i]);
+	}
+	return max;
+}
+/*}}}*/
+IssmDouble TriaInput::Min(void){/*{{{*/
+
+	const int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble min=values[0];
+
+	for(int i=1;i<numnodes;i++){
+		if(values[i]<min) min=values[i];
+	}
+	return min;
+}
+/*}}}*/
+IssmDouble TriaInput::MinAbs(void){/*{{{*/
+
+	const int  numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble min=fabs(values[0]);
+
+	for(int i=1;i<numnodes;i++){
+		if(fabs(values[i])<min) min=fabs(values[i]);
+	}
+	return min;
+}
+/*}}}*/
+Input* TriaInput::PointwiseMax(Input* inputB){/*{{{*/
+
+	/*Ouput*/
+	TriaInput* outinput=NULL;
+
+	/*Intermediaries*/
+	int         i;
+	TriaInput  *xinputB   = NULL;
+	const int   numnodes  = this->NumberofNodes(this->interpolation_type);
+	IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
+
+	/*Check that inputB is of the same type*/
+	if(inputB->ObjectEnum()!=TriaInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
+	xinputB=(TriaInput*)inputB;
+	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
+
+	/*Create point wise max*/
+	for(i=0;i<numnodes;i++){
+		if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
+		else maxvalues[i]=this->values[i];
+	}
+
+	/*Create new Tria vertex input (copy of current input)*/
+	outinput=new TriaInput(this->enum_type,&maxvalues[0],this->interpolation_type);
+
+	/*Return output pointer*/
+	xDelete<IssmDouble>(maxvalues);
+	return outinput;
+
+}
+/*}}}*/
 Input* TriaInput::PointwiseMin(Input* inputB){/*{{{*/
 
@@ -398,35 +407,4 @@
 }
 /*}}}*/
-Input* TriaInput::PointwiseMax(Input* inputB){/*{{{*/
-
-	/*Ouput*/
-	TriaInput* outinput=NULL;
-
-	/*Intermediaries*/
-	int         i;
-	TriaInput  *xinputB   = NULL;
-	const int   numnodes  = this->NumberofNodes(this->interpolation_type);
-	IssmDouble *maxvalues = xNew<IssmDouble>(numnodes);
-
-	/*Check that inputB is of the same type*/
-	if(inputB->ObjectEnum()!=TriaInputEnum) _error_("Operation not permitted because inputB is of type " << EnumToStringx(inputB->ObjectEnum()));
-	xinputB=(TriaInput*)inputB;
-	if(xinputB->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because inputB is of type " << EnumToStringx(xinputB->interpolation_type));
-
-	/*Create point wise max*/
-	for(i=0;i<numnodes;i++){
-		if(this->values[i] < xinputB->values[i]) maxvalues[i]=xinputB->values[i];
-		else maxvalues[i]=this->values[i];
-	}
-
-	/*Create new Tria vertex input (copy of current input)*/
-	outinput=new TriaInput(this->enum_type,&maxvalues[0],this->interpolation_type);
-
-	/*Return output pointer*/
-	xDelete<IssmDouble>(maxvalues);
-	return outinput;
-
-}
-/*}}}*/
 Input* TriaInput::PointwiseDivide(Input* inputB){/*{{{*/
 
@@ -461,6 +439,28 @@
 }
 /*}}}*/
-void TriaInput::Configure(Parameters* parameters){/*{{{*/
-	/*do nothing: */
-}
-/*}}}*/
+void TriaInput::Scale(IssmDouble scale_factor){/*{{{*/
+
+	const int numnodes=this->NumberofNodes(this->interpolation_type);
+	for(int i=0;i<numnodes;i++)values[i]=values[i]*scale_factor;
+}
+/*}}}*/
+void TriaInput::Set(IssmDouble setvalue){/*{{{*/
+
+	const int numnodes=this->NumberofNodes(this->interpolation_type);
+	for(int i=0;i<numnodes;i++)values[i]=setvalue;
+}
+/*}}}*/
+void TriaInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
+
+	int        numnodes=this->NumberofNodes(this->interpolation_type);
+	IssmDouble squaremin;
+
+	/*Now, figure out minimum of valuescopy: */
+	squaremin=pow(this->values[0],2);
+	for(int i=1;i<numnodes;i++){
+		if(pow(this->values[i],2)<squaremin)squaremin=pow(this->values[i],2);
+	}
+	/*Assign output pointers:*/
+	*psquaremin=squaremin;
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h	(revision 20827)
@@ -27,26 +27,35 @@
 
 		/*Object virtual functions definitions*/
+		Object *copy();
+		void    DeepEcho();
 		void    Echo();
-		void    DeepEcho();
 		int     Id();
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int     ObjectEnum();
-		Object *copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 
 		/*TriaInput management:*/
-		int    InstanceEnum();
-		Input* SpawnTriaInput(int index1,int index2,int index3);
-		Input* SpawnSegInput(int index1,int index2);
-		Input* PointwiseDivide(Input* inputB);
-		Input* PointwiseMin(Input* inputB);
-		Input* PointwiseMax(Input* inputB);
+		void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
+		void   Configure(Parameters* parameters);
+		int    GetResultArraySize(void);
 		int    GetResultInterpolation(void);
 		int    GetResultNumberOfNodes(void);
-		int    GetResultArraySize(void);
+		int    InstanceEnum();
+		Input* PointwiseDivide(Input* inputB);
+		Input* PointwiseMax(Input* inputB);
+		Input* PointwiseMin(Input* inputB);
 		void   ResultToPatch(IssmDouble* values,int nodesperelement,int sid);
-		void   AddTimeValues(IssmDouble* values,int step,IssmDouble time){_error_("not supported yet");};
-		void   Configure(Parameters* parameters);
+		Input* SpawnSegInput(int index1,int index2);
+		Input* SpawnTriaInput(int index1,int index2,int index3);
 
 		/*numerics*/
+		void AXPY(Input* xinput,IssmDouble scalar);
+		void ChangeEnum(int newenumtype);
+		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		void ConstrainMin(IssmDouble minimum);
+		void Extrude(int start){_error_("not supported yet");};
+		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
+		void GetInputAverage(IssmDouble* pvalue);
+		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list);
+		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
 		void GetInputValue(bool* pvalue){_error_("not implemented yet");}
 		void GetInputValue(int* pvalue){_error_("not implemented yet");}
@@ -55,16 +64,6 @@
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");};
 		void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int index){_error_("not implemented yet");};
-		void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss);
-		void GetInputAverage(IssmDouble* pvalue);
-		void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list);
-		void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);
 		void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);
-		void ChangeEnum(int newenumtype);
-		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
-		void ConstrainMin(IssmDouble minimum);
-		void Set(IssmDouble setvalue);
-		void Scale(IssmDouble scale_factor);
-		void AXPY(Input* xinput,IssmDouble scalar);
-		void Constrain(IssmDouble cm_min, IssmDouble cm_max);
+		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 		IssmDouble InfinityNorm(void);
 		IssmDouble Max(void);
@@ -72,7 +71,8 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void);
-		void Extrude(int start){_error_("not supported yet");};
+		void Scale(IssmDouble scale_factor);
+		void Set(IssmDouble setvalue);
+		void SquareMin(IssmDouble* psquaremin,Parameters* parameters);
 		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
-		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
 
 };
Index: /issm/trunk-jpl/src/c/classes/Loads/Friction.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Friction.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Friction.cpp	(revision 20827)
@@ -57,67 +57,4 @@
 
 }/*}}}*/
-void Friction::GetAlphaViscousComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/
-
-	/* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p. 
-	 * FrictionGetAlphaComplement is used in control methods on drag, and it computes: 
-	 * alpha_complement= Neff ^r * vel ^s*/
-
-	/*diverse: */
-	IssmDouble  r,s;
-	IssmDouble  vx,vy,vz,vmag;
-	IssmDouble  drag_p,drag_q;
-	IssmDouble  Neff;
-	IssmDouble  drag_coefficient;
-	IssmDouble  bed,thickness,sealevel;
-	IssmDouble  alpha_complement;
-
-	/*Recover parameters: */
-	element->GetInputValue(&drag_p,FrictionPEnum);
-	element->GetInputValue(&drag_q,FrictionQEnum);
-	element->GetInputValue(&thickness, gauss,ThicknessEnum);
-	element->GetInputValue(&bed, gauss,BaseEnum);
-	element->GetInputValue(&sealevel, gauss,SealevelEnum);
-	element->GetInputValue(&drag_coefficient, gauss,FrictionCoefficientEnum);
-	IssmDouble rho_water   = element->GetMaterialParameter(MaterialsRhoSeawaterEnum);
-	IssmDouble rho_ice     = element->GetMaterialParameter(MaterialsRhoIceEnum);
-	IssmDouble gravity     = element->GetMaterialParameter(ConstantsGEnum);
-
-	//compute r and q coefficients: */
-	r=drag_q/drag_p;
-	s=1./drag_p;
-
-	//From bed and thickness, compute effective pressure when drag is viscous:
-	Neff=gravity*(rho_ice*thickness+rho_water*(bed-sealevel));
-	if(Neff<0)Neff=0;
-
-	//We need the velocity magnitude to evaluate the basal stress:
-	switch(dim){
-		case 1:
-			element->GetInputValue(&vx,gauss,VxEnum);
-			vmag=sqrt(vx*vx);
-			break;
-		case 2:
-			element->GetInputValue(&vx,gauss,VxEnum);
-			element->GetInputValue(&vy,gauss,VyEnum);
-			vmag=sqrt(vx*vx+vy*vy);
-			break;
-		case 3:
-			element->GetInputValue(&vx,gauss,VxEnum);
-			element->GetInputValue(&vy,gauss,VyEnum);
-			element->GetInputValue(&vz,gauss,VzEnum);
-			vmag=sqrt(vx*vx+vy*vy+vz*vz);
-			break;
-		default:
-			_error_("not supported");
-	}
-
-	/*Check to prevent dividing by zero if vmag==0*/
-	if(vmag==0. && (s-1.)<0.) alpha_complement=0.;
-	else alpha_complement=pow(Neff,r)*pow(vmag,(s-1));_assert_(!xIsNan<IssmDouble>(alpha_complement));
-
-	/*Assign output pointers:*/
-	*palpha_complement=alpha_complement;
-}
-/*}}}*/
 void Friction::GetAlphaHydroComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/
 
@@ -220,4 +157,67 @@
 	*palpha_complement=alpha_complement;
 }/*}}}*/
+void Friction::GetAlphaViscousComplement(IssmDouble* palpha_complement, Gauss* gauss){/*{{{*/
+
+	/* FrictionGetAlpha2 computes alpha2= drag^2 * Neff ^r * vel ^s, with Neff=rho_ice*g*thickness+rho_ice*g*bed, r=q/p and s=1/p. 
+	 * FrictionGetAlphaComplement is used in control methods on drag, and it computes: 
+	 * alpha_complement= Neff ^r * vel ^s*/
+
+	/*diverse: */
+	IssmDouble  r,s;
+	IssmDouble  vx,vy,vz,vmag;
+	IssmDouble  drag_p,drag_q;
+	IssmDouble  Neff;
+	IssmDouble  drag_coefficient;
+	IssmDouble  bed,thickness,sealevel;
+	IssmDouble  alpha_complement;
+
+	/*Recover parameters: */
+	element->GetInputValue(&drag_p,FrictionPEnum);
+	element->GetInputValue(&drag_q,FrictionQEnum);
+	element->GetInputValue(&thickness, gauss,ThicknessEnum);
+	element->GetInputValue(&bed, gauss,BaseEnum);
+	element->GetInputValue(&sealevel, gauss,SealevelEnum);
+	element->GetInputValue(&drag_coefficient, gauss,FrictionCoefficientEnum);
+	IssmDouble rho_water   = element->GetMaterialParameter(MaterialsRhoSeawaterEnum);
+	IssmDouble rho_ice     = element->GetMaterialParameter(MaterialsRhoIceEnum);
+	IssmDouble gravity     = element->GetMaterialParameter(ConstantsGEnum);
+
+	//compute r and q coefficients: */
+	r=drag_q/drag_p;
+	s=1./drag_p;
+
+	//From bed and thickness, compute effective pressure when drag is viscous:
+	Neff=gravity*(rho_ice*thickness+rho_water*(bed-sealevel));
+	if(Neff<0)Neff=0;
+
+	//We need the velocity magnitude to evaluate the basal stress:
+	switch(dim){
+		case 1:
+			element->GetInputValue(&vx,gauss,VxEnum);
+			vmag=sqrt(vx*vx);
+			break;
+		case 2:
+			element->GetInputValue(&vx,gauss,VxEnum);
+			element->GetInputValue(&vy,gauss,VyEnum);
+			vmag=sqrt(vx*vx+vy*vy);
+			break;
+		case 3:
+			element->GetInputValue(&vx,gauss,VxEnum);
+			element->GetInputValue(&vy,gauss,VyEnum);
+			element->GetInputValue(&vz,gauss,VzEnum);
+			vmag=sqrt(vx*vx+vy*vy+vz*vz);
+			break;
+		default:
+			_error_("not supported");
+	}
+
+	/*Check to prevent dividing by zero if vmag==0*/
+	if(vmag==0. && (s-1.)<0.) alpha_complement=0.;
+	else alpha_complement=pow(Neff,r)*pow(vmag,(s-1));_assert_(!xIsNan<IssmDouble>(alpha_complement));
+
+	/*Assign output pointers:*/
+	*palpha_complement=alpha_complement;
+}
+/*}}}*/
 void Friction::GetAlpha2(IssmDouble* palpha2, Gauss* gauss){/*{{{*/
 
@@ -402,4 +402,38 @@
 	*palpha2=alpha2;
 }/*}}}*/
+void Friction::GetAlpha2Sommers(IssmDouble* palpha2, Gauss* gauss){/*{{{*/
+
+	/* FrictionGetAlpha2 computes alpha2= drag^2 * Neff, with Neff=rho_ice*g*thickness+rho_ice*g*(head-bed)*/
+
+	/*diverse: */
+	IssmDouble  pressure_ice,pressure_water;
+	IssmDouble  Neff;
+	IssmDouble  drag_coefficient;
+	IssmDouble  bed,thickness,head,sealevel;
+	IssmDouble  alpha2;
+
+	/*Recover parameters: */
+	element->GetInputValue(&thickness, gauss,ThicknessEnum);
+	element->GetInputValue(&bed, gauss,BaseEnum);
+	element->GetInputValue(&head, gauss,HydrologyHeadEnum);
+	element->GetInputValue(&sealevel, gauss,SealevelEnum);
+	element->GetInputValue(&drag_coefficient, gauss,FrictionCoefficientEnum);
+	IssmDouble rho_water   = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum);
+	IssmDouble rho_ice     = element->GetMaterialParameter(MaterialsRhoIceEnum);
+	IssmDouble gravity     = element->GetMaterialParameter(ConstantsGEnum);
+
+	//From bed and thickness, compute effective pressure when drag is viscous:
+	pressure_ice   = rho_ice*gravity*thickness;
+	pressure_water = rho_water*gravity*(head-bed+sealevel);
+	Neff=pressure_ice-pressure_water;
+	if(Neff<0.) Neff=0.;
+
+	alpha2=drag_coefficient*drag_coefficient*Neff;
+	_assert_(!xIsNan<IssmDouble>(alpha2));
+
+	/*Assign output pointers:*/
+	*palpha2=alpha2;
+}
+/*}}}*/
 void Friction::GetAlpha2Temp(IssmDouble* palpha2, Gauss* gauss){/*{{{*/
 	/*Here, we want to parameterize the friction as a function of temperature
@@ -624,36 +658,2 @@
 	*palpha2=alpha2;
 }/*}}}*/
-void Friction::GetAlpha2Sommers(IssmDouble* palpha2, Gauss* gauss){/*{{{*/
-
-	/* FrictionGetAlpha2 computes alpha2= drag^2 * Neff, with Neff=rho_ice*g*thickness+rho_ice*g*(head-bed)*/
-
-	/*diverse: */
-	IssmDouble  pressure_ice,pressure_water;
-	IssmDouble  Neff;
-	IssmDouble  drag_coefficient;
-	IssmDouble  bed,thickness,head,sealevel;
-	IssmDouble  alpha2;
-
-	/*Recover parameters: */
-	element->GetInputValue(&thickness, gauss,ThicknessEnum);
-	element->GetInputValue(&bed, gauss,BaseEnum);
-	element->GetInputValue(&head, gauss,HydrologyHeadEnum);
-	element->GetInputValue(&sealevel, gauss,SealevelEnum);
-	element->GetInputValue(&drag_coefficient, gauss,FrictionCoefficientEnum);
-	IssmDouble rho_water   = element->GetMaterialParameter(MaterialsRhoFreshwaterEnum);
-	IssmDouble rho_ice     = element->GetMaterialParameter(MaterialsRhoIceEnum);
-	IssmDouble gravity     = element->GetMaterialParameter(ConstantsGEnum);
-
-	//From bed and thickness, compute effective pressure when drag is viscous:
-	pressure_ice   = rho_ice*gravity*thickness;
-	pressure_water = rho_water*gravity*(head-bed+sealevel);
-	Neff=pressure_ice-pressure_water;
-	if(Neff<0.) Neff=0.;
-
-	alpha2=drag_coefficient*drag_coefficient*Neff;
-	_assert_(!xIsNan<IssmDouble>(alpha2));
-
-	/*Assign output pointers:*/
-	*palpha2=alpha2;
-}
-/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Friction.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Friction.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Friction.h	(revision 20827)
@@ -30,10 +30,11 @@
 		void  Echo(void);
 		void  GetAlphaComplement(IssmDouble* alpha_complement,Gauss* gauss);
-		void  GetAlphaViscousComplement(IssmDouble* alpha_complement,Gauss* gauss);
 		void  GetAlphaHydroComplement(IssmDouble* alpha_complement,Gauss* gauss);
 		void  GetAlphaTempComplement(IssmDouble* alpha_complement,Gauss* gauss);
+		void  GetAlphaViscousComplement(IssmDouble* alpha_complement,Gauss* gauss);
 		void  GetAlpha2(IssmDouble* palpha2,Gauss* gauss);
 		void  GetAlpha2Coulomb(IssmDouble* palpha2,Gauss* gauss);
 		void  GetAlpha2Hydro(IssmDouble* palpha2,Gauss* gauss);
+		void  GetAlpha2Sommers(IssmDouble* palpha2,Gauss* gauss);
 		void  GetAlpha2Temp(IssmDouble* palpha2,Gauss* gauss);
 		void  GetAlpha2Viscous(IssmDouble* palpha2,Gauss* gauss);
@@ -41,5 +42,4 @@
 		void  GetAlpha2Weertman(IssmDouble* palpha2,Gauss* gauss);
 		void  GetAlpha2WeertmanTemp(IssmDouble* palpha2,Gauss* gauss);
-		void  GetAlpha2Sommers(IssmDouble* palpha2,Gauss* gauss);
 };
 
Index: /issm/trunk-jpl/src/c/classes/Loads/Moulin.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Moulin.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Moulin.cpp	(revision 20827)
@@ -97,29 +97,4 @@
 }
 /*}}}*/
-void    Moulin::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
-
-	_assert_(this);
-
-	/*ok, marshall operations: */
-	MARSHALLING_ENUM(MoulinEnum);
-	MARSHALLING(id);
-	MARSHALLING(analysis_type);
-
-	if(marshall_direction==MARSHALLING_BACKWARD){
-		this->hnode      = new Hook();
-		this->helement   = new Hook();
-		this->hmatpar    = new Hook();
-	}
-
-	this->hnode->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-	this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-	this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-
-	/*corresponding fields*/
-	node   =(Node*)this->hnode->delivers();
-	matpar =(Matpar*)this->hmatpar->delivers();
-	element=(Element*)this->helement->delivers();
-}
-/*}}}*/
 void    Moulin::DeepEcho(void){/*{{{*/
 
@@ -139,4 +114,29 @@
 /*}}}*/
 int     Moulin::Id(void){ return id; }/*{{{*/
+/*}}}*/
+void    Moulin::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
+
+	_assert_(this);
+
+	/*ok, marshall operations: */
+	MARSHALLING_ENUM(MoulinEnum);
+	MARSHALLING(id);
+	MARSHALLING(analysis_type);
+
+	if(marshall_direction==MARSHALLING_BACKWARD){
+		this->hnode      = new Hook();
+		this->helement   = new Hook();
+		this->hmatpar    = new Hook();
+	}
+
+	this->hnode->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+	this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+	this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+
+	/*corresponding fields*/
+	node   =(Node*)this->hnode->delivers();
+	matpar =(Matpar*)this->hmatpar->delivers();
+	element=(Element*)this->helement->delivers();
+}
 /*}}}*/
 int     Moulin::ObjectEnum(void){/*{{{*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Moulin.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Moulin.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Moulin.h	(revision 20827)
@@ -46,36 +46,36 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Object* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Update virtual functions resolution: {{{*/
-		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
-		void  InputUpdateFromMatrixDakota(IssmDouble* matrix ,int nrows, int ncols, int name, int type);
-		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromConstant(IssmDouble constant, int name);
 		void  InputUpdateFromConstant(int constant, int name);
 		void  InputUpdateFromConstant(bool constant, int name);
 		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix ,int nrows, int ncols, int name, int type);
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		/*}}}*/
 		/*Load virtual functions definitions: {{{*/
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
-		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
-		void  ResetHooks();
+		void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
 		void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
 		void  CreatePVector(Vector<IssmDouble>* pf);
-		void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
 		void  GetNodesSidList(int* sidlist);
 		void  GetNodesLidList(int* lidlist);
 		int   GetNumberOfNodes(void);
+		bool  InAnalysis(int analysis_type);
 		bool  IsPenalty(void);
 		void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");};
 		void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
 		void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
+		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum);
-		bool  InAnalysis(int analysis_type);
+		void  ResetHooks();
 		/*}}}*/
 
Index: /issm/trunk-jpl/src/c/classes/Loads/Neumannflux.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Neumannflux.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Neumannflux.cpp	(revision 20827)
@@ -99,30 +99,4 @@
 
 	return neumannflux;
-}
-/*}}}*/
-void    Neumannflux::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
-
-	_assert_(this);
-
-	/*ok, marshall operations: */
-	MARSHALLING_ENUM(NeumannfluxEnum);
-	MARSHALLING(id);
-	MARSHALLING(analysis_type);
-
-	if(marshall_direction==MARSHALLING_BACKWARD){
-		this->hnodes      = new Hook();
-		this->hvertices   = new Hook();
-		this->helement    = new Hook();
-	}
-
-	this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-	this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-	this->hvertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-
-	/*corresponding fields*/
-	nodes    =(Node**)this->hnodes->deliverp();
-	vertices =(Vertex**)this->hvertices->deliverp();
-	element  =(Element*)this->helement->delivers();
-
 }
 /*}}}*/
@@ -154,4 +128,30 @@
 int     Neumannflux::Id(void){/*{{{*/
 	return id;
+}
+/*}}}*/
+void    Neumannflux::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
+
+	_assert_(this);
+
+	/*ok, marshall operations: */
+	MARSHALLING_ENUM(NeumannfluxEnum);
+	MARSHALLING(id);
+	MARSHALLING(analysis_type);
+
+	if(marshall_direction==MARSHALLING_BACKWARD){
+		this->hnodes      = new Hook();
+		this->hvertices   = new Hook();
+		this->helement    = new Hook();
+	}
+
+	this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+	this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+	this->hvertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+
+	/*corresponding fields*/
+	nodes    =(Node**)this->hnodes->deliverp();
+	vertices =(Vertex**)this->hvertices->deliverp();
+	element  =(Element*)this->helement->delivers();
+
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Neumannflux.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Neumannflux.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Neumannflux.h	(revision 20827)
@@ -43,6 +43,6 @@
 		void    Echo();
 		int     Id();
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int     ObjectEnum();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Update virtual functions resolution: {{{*/
@@ -69,6 +69,6 @@
 		void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
 		void ResetHooks();
+		void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum);
-		void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		/*}}}*/
 		/*Neumannflux management:{{{*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Numericalflux.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Numericalflux.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Numericalflux.cpp	(revision 20827)
@@ -156,31 +156,4 @@
 
 	return numericalflux;
-}
-/*}}}*/
-void    Numericalflux::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
-
-	_assert_(this);
-
-	/*ok, marshall operations: */
-	MARSHALLING_ENUM(NumericalfluxEnum);
-	MARSHALLING(id);
-	MARSHALLING(analysis_type);
-	MARSHALLING(flux_type);
-
-	if(marshall_direction==MARSHALLING_BACKWARD){
-		this->hnodes      = new Hook();
-		this->hvertices   = new Hook();
-		this->helement    = new Hook();
-	}
-
-	this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-	this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-	this->hvertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-
-	/*corresponding fields*/
-	nodes    =(Node**)this->hnodes->deliverp();
-	vertices =(Vertex**)this->hvertices->deliverp();
-	element  =(Element*)this->helement->delivers();
-
 }
 /*}}}*/
@@ -214,4 +187,31 @@
 int     Numericalflux::Id(void){/*{{{*/
 	return id;
+}
+/*}}}*/
+void    Numericalflux::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
+
+	_assert_(this);
+
+	/*ok, marshall operations: */
+	MARSHALLING_ENUM(NumericalfluxEnum);
+	MARSHALLING(id);
+	MARSHALLING(analysis_type);
+	MARSHALLING(flux_type);
+
+	if(marshall_direction==MARSHALLING_BACKWARD){
+		this->hnodes      = new Hook();
+		this->hvertices   = new Hook();
+		this->helement    = new Hook();
+	}
+
+	this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+	this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+	this->hvertices->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+
+	/*corresponding fields*/
+	nodes    =(Node**)this->hnodes->deliverp();
+	vertices =(Vertex**)this->hvertices->deliverp();
+	element  =(Element*)this->helement->delivers();
+
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Numericalflux.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Numericalflux.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Numericalflux.h	(revision 20827)
@@ -44,6 +44,6 @@
 		void    Echo();
 		int     Id();
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int     ObjectEnum();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Update virtual functions resolution: {{{*/
@@ -70,6 +70,6 @@
 		void PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
 		void ResetHooks();
+		void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum);
-		void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		/*}}}*/
 		/*Numericalflux management:{{{*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Pengrid.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Pengrid.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Pengrid.cpp	(revision 20827)
@@ -109,33 +109,4 @@
 
 	return pengrid;
-
-}
-/*}}}*/
-void    Pengrid::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
-
-	_assert_(this);
-
-	/*ok, marshall operations: */
-	MARSHALLING_ENUM(PengridEnum);
-	MARSHALLING(id);
-	MARSHALLING(analysis_type);
-
-	if(marshall_direction==MARSHALLING_BACKWARD){
-		this->hnode      = new Hook();
-		this->helement   = new Hook();
-		this->hmatpar    = new Hook();
-	}
-
-	this->hnode->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-	this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-	this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-
-	/*corresponding fields*/
-	node   =(Node*)this->hnode->delivers();
-	matpar =(Matpar*)this->hmatpar->delivers();
-	element=(Element*)this->helement->delivers();
-
-	MARSHALLING(active);
-	MARSHALLING(zigzag_counter);
 
 }
@@ -160,4 +131,33 @@
 /*}}}*/
 int     Pengrid::Id(void){ return id; }/*{{{*/
+/*}}}*/
+void    Pengrid::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
+
+	_assert_(this);
+
+	/*ok, marshall operations: */
+	MARSHALLING_ENUM(PengridEnum);
+	MARSHALLING(id);
+	MARSHALLING(analysis_type);
+
+	if(marshall_direction==MARSHALLING_BACKWARD){
+		this->hnode      = new Hook();
+		this->helement   = new Hook();
+		this->hmatpar    = new Hook();
+	}
+
+	this->hnode->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+	this->helement->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+	this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+
+	/*corresponding fields*/
+	node   =(Node*)this->hnode->delivers();
+	matpar =(Matpar*)this->hmatpar->delivers();
+	element=(Element*)this->helement->delivers();
+
+	MARSHALLING(active);
+	MARSHALLING(zigzag_counter);
+
+}
 /*}}}*/
 int     Pengrid::ObjectEnum(void){/*{{{*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Pengrid.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Pengrid.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Pengrid.h	(revision 20827)
@@ -50,48 +50,48 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Object* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Update virtual functions resolution: {{{*/
-		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
-		void  InputUpdateFromMatrixDakota(IssmDouble* matrix ,int nrows, int ncols, int name, int type);
-		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromConstant(IssmDouble constant, int name);
 		void  InputUpdateFromConstant(int constant, int name);
 		void  InputUpdateFromConstant(bool constant, int name);
 		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix ,int nrows, int ncols, int name, int type);
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		/*}}}*/
 		/*Load virtual functions definitions: {{{*/
 		void  Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
-		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
-		void  ResetHooks();
+		void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
 		void  CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
 		void  CreatePVector(Vector<IssmDouble>* pf);
-		void  CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("Not implemented yet");};
+		void  GetNodesLidList(int* lidlist);
 		void  GetNodesSidList(int* sidlist);
-		void  GetNodesLidList(int* lidlist);
 		int   GetNumberOfNodes(void);
+		bool  InAnalysis(int analysis_type);
 		bool  IsPenalty(void);
 		void  PenaltyCreateJacobianMatrix(Matrix<IssmDouble>* Jff,IssmDouble kmax){_error_("Not implemented yet");};
 		void  PenaltyCreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* kfs, IssmDouble kmax);
 		void  PenaltyCreatePVector(Vector<IssmDouble>* pf, IssmDouble kmax);
+		void  ResetHooks();
+		void  SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void  SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum);
-		bool  InAnalysis(int analysis_type);
 		/*}}}*/
 		/*Pengrid management {{{*/
+		void				ConstraintActivate(int* punstable);
+		void           ConstraintActivateHydrologyDCInefficient(int* punstable);
+		void           ConstraintActivateThermal(int* punstable);
+		ElementVector* CreatePVectorHydrologyDCInefficient(void);
+		ElementMatrix* PenaltyCreateKMatrixHydrologyDCInefficient(IssmDouble kmax);
+		ElementMatrix* PenaltyCreateKMatrixMelting(IssmDouble kmax);
 		ElementMatrix* PenaltyCreateKMatrixThermal(IssmDouble kmax);
-		ElementMatrix* PenaltyCreateKMatrixMelting(IssmDouble kmax);
+		ElementVector* PenaltyCreatePVectorHydrologyDCInefficient(IssmDouble kmax);
+		ElementVector* PenaltyCreatePVectorMelting(IssmDouble kmax);
 		ElementVector* PenaltyCreatePVectorThermal(IssmDouble kmax);
-		ElementVector* PenaltyCreatePVectorMelting(IssmDouble kmax);
-		void           ConstraintActivateThermal(int* punstable);
-		ElementMatrix* PenaltyCreateKMatrixHydrologyDCInefficient(IssmDouble kmax);
-		ElementVector* PenaltyCreatePVectorHydrologyDCInefficient(IssmDouble kmax);
-		void           ConstraintActivateHydrologyDCInefficient(int* punstable);
-		void  ConstraintActivate(int* punstable);
-		ElementVector* CreatePVectorHydrologyDCInefficient(void);
 		void  ResetConstraint(void);
 		/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Penpair.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Penpair.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Penpair.cpp	(revision 20827)
@@ -66,4 +66,26 @@
 }
 /*}}}*/
+void    Penpair::DeepEcho(void){/*{{{*/
+
+	_printf_("Penpair:\n");
+	_printf_("   id: " << id << "\n");
+	_printf_("   analysis_type: " << EnumToStringx(analysis_type) << "\n");
+	hnodes->DeepEcho();
+
+	return;
+}		
+/*}}}*/
+void    Penpair::Echo(void){/*{{{*/
+
+	_printf_("Penpair:\n");
+	_printf_("   id: " << id << "\n");
+	_printf_("   analysis_type: " << EnumToStringx(analysis_type) << "\n");
+	hnodes->Echo();
+
+	return;
+}
+/*}}}*/
+int     Penpair::Id(void){ return id; }/*{{{*/
+/*}}}*/
 void    Penpair::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
 
@@ -85,26 +107,4 @@
 }
 /*}}}*/
-void    Penpair::DeepEcho(void){/*{{{*/
-
-	_printf_("Penpair:\n");
-	_printf_("   id: " << id << "\n");
-	_printf_("   analysis_type: " << EnumToStringx(analysis_type) << "\n");
-	hnodes->DeepEcho();
-
-	return;
-}		
-/*}}}*/
-void    Penpair::Echo(void){/*{{{*/
-
-	_printf_("Penpair:\n");
-	_printf_("   id: " << id << "\n");
-	_printf_("   analysis_type: " << EnumToStringx(analysis_type) << "\n");
-	hnodes->Echo();
-
-	return;
-}
-/*}}}*/
-int     Penpair::Id(void){ return id; }/*{{{*/
-/*}}}*/
 int     Penpair::ObjectEnum(void){/*{{{*/
 
@@ -146,4 +146,12 @@
 }
 /*}}}*/
+void  Penpair::GetNodesLidList(int* lidlist){/*{{{*/
+
+	_assert_(lidlist);
+	_assert_(nodes);
+
+	for(int i=0;i<NUMVERTICES;i++) lidlist[i]=nodes[i]->Lid();
+}
+/*}}}*/
 void  Penpair::GetNodesSidList(int* sidlist){/*{{{*/
 
@@ -152,12 +160,4 @@
 
 	for(int i=0;i<NUMVERTICES;i++) sidlist[i]=nodes[i]->Sid();
-}
-/*}}}*/
-void  Penpair::GetNodesLidList(int* lidlist){/*{{{*/
-
-	_assert_(lidlist);
-	_assert_(nodes);
-
-	for(int i=0;i<NUMVERTICES;i++) lidlist[i]=nodes[i]->Lid();
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Penpair.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Penpair.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Penpair.h	(revision 20827)
@@ -35,6 +35,6 @@
 		void     Echo();
 		int      Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int      ObjectEnum();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Update virtual functions resolution: {{{*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Riftfront.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Riftfront.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Riftfront.cpp	(revision 20827)
@@ -150,47 +150,4 @@
 
 	return riftfront;
-
-}
-/*}}}*/
-void    Riftfront::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
-
-	_assert_(this);
-
-	/*ok, marshall operations: */
-	MARSHALLING_ENUM(RiftfrontEnum);
-	MARSHALLING(id);
-	MARSHALLING(analysis_type);
-	MARSHALLING(type);
-	MARSHALLING(fill);
-	MARSHALLING(friction);
-	MARSHALLING(fractionincrement);
-	MARSHALLING(shelf);
-
-	if(marshall_direction==MARSHALLING_BACKWARD){
-		this->hnodes      = new Hook();
-		this->hmatpar     = new Hook();
-		this->helements   = new Hook();
-	}
-
-	this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-	this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-	this->helements->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
-
-	/*corresponding fields*/
-	nodes     =(Node**)this->hnodes->deliverp();
-	matpar    =(Matpar*)this->hmatpar->delivers();
-	elements  =(Element**)this->helements->deliverp();
-
-	MARSHALLING(penalty_lock);
-	MARSHALLING(active);
-	MARSHALLING(frozen);
-	MARSHALLING(state);
-	MARSHALLING(counter);
-	MARSHALLING(prestable);
-	MARSHALLING(material_converged);
-	MARSHALLING(normal[0]);
-	MARSHALLING(normal[1]);
-	MARSHALLING(length);
-	MARSHALLING(fraction);
 
 }
@@ -235,4 +192,47 @@
 /*}}}*/
 int     Riftfront::Id(void){ return id; }/*{{{*/
+/*}}}*/
+void    Riftfront::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
+
+	_assert_(this);
+
+	/*ok, marshall operations: */
+	MARSHALLING_ENUM(RiftfrontEnum);
+	MARSHALLING(id);
+	MARSHALLING(analysis_type);
+	MARSHALLING(type);
+	MARSHALLING(fill);
+	MARSHALLING(friction);
+	MARSHALLING(fractionincrement);
+	MARSHALLING(shelf);
+
+	if(marshall_direction==MARSHALLING_BACKWARD){
+		this->hnodes      = new Hook();
+		this->hmatpar     = new Hook();
+		this->helements   = new Hook();
+	}
+
+	this->hnodes->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+	this->hmatpar->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+	this->helements->Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
+
+	/*corresponding fields*/
+	nodes     =(Node**)this->hnodes->deliverp();
+	matpar    =(Matpar*)this->hmatpar->delivers();
+	elements  =(Element**)this->helements->deliverp();
+
+	MARSHALLING(penalty_lock);
+	MARSHALLING(active);
+	MARSHALLING(frozen);
+	MARSHALLING(state);
+	MARSHALLING(counter);
+	MARSHALLING(prestable);
+	MARSHALLING(material_converged);
+	MARSHALLING(normal[0]);
+	MARSHALLING(normal[1]);
+	MARSHALLING(length);
+	MARSHALLING(fraction);
+
+}
 /*}}}*/
 int     Riftfront::ObjectEnum(void){/*{{{*/
Index: /issm/trunk-jpl/src/c/classes/Loads/Riftfront.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Loads/Riftfront.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Loads/Riftfront.h	(revision 20827)
@@ -61,6 +61,6 @@
 		void     Echo();
 		int      Id(); 
+		void		Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int      ObjectEnum();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Update virtual functions resolution: {{{*/
Index: /issm/trunk-jpl/src/c/classes/Materials/Material.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Materials/Material.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Materials/Material.h	(revision 20827)
@@ -25,6 +25,6 @@
 
 		/*Numerics*/
+		virtual void       Configure(Elements* elements)=0;
 		virtual Material*  copy2(Element* element)=0;
-		virtual void       Configure(Elements* elements)=0;
 		virtual IssmDouble GetA()=0;
 		virtual IssmDouble GetAbar()=0;
Index: /issm/trunk-jpl/src/c/classes/Materials/Matestar.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Materials/Matestar.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Materials/Matestar.cpp	(revision 20827)
@@ -106,10 +106,4 @@
 int       Matestar::Id(void){ return mid; }/*{{{*/
 /*}}}*/
-int       Matestar::ObjectEnum(void){/*{{{*/
-
-	return MatestarEnum;
-
-}
-/*}}}*/
 void      Matestar::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
 
@@ -123,4 +117,10 @@
 }
 /*}}}*/
+int       Matestar::ObjectEnum(void){/*{{{*/
+
+	return MatestarEnum;
+
+}
+/*}}}*/
 
 /*Matestar management*/
@@ -133,8 +133,4 @@
 }
 /*}}}*/
-void  Matestar::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
-
-}
-/*}}}*/
 IssmDouble Matestar::GetA(){/*{{{*/
 	_error_("not implemented yet");
@@ -154,19 +150,14 @@
 }
 /*}}}*/
+IssmDouble Matestar::GetD(){/*{{{*/
+	_error_("not implemented yet");
+}
+/*}}}*/
+IssmDouble Matestar::GetDbar(){/*{{{*/
+
+	_error_("not implemented yet");
+}
+/*}}}*/
 IssmDouble Matestar::GetN(){/*{{{*/
-	_error_("not implemented yet");
-}
-/*}}}*/
-IssmDouble Matestar::GetD(){/*{{{*/
-	_error_("not implemented yet");
-}
-/*}}}*/
-IssmDouble Matestar::GetDbar(){/*{{{*/
-
-	_error_("not implemented yet");
-}
-/*}}}*/
-bool Matestar::IsDamage(){/*{{{*/
-
 	_error_("not implemented yet");
 }
@@ -221,4 +212,57 @@
 }
 /*}}}*/
+void  Matestar::GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/
+	_error_("not implemented yet");
+}
+/*}}}*/
+void  Matestar::GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
+	_error_("not implemented yet");
+}
+/*}}}*/
+void  Matestar::GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
+	_error_("not implemented yet");
+}
+/*}}}*/
+void  Matestar::GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
+	_error_("not implemented yet");
+}
+/*}}}*/
+IssmDouble Matestar::GetViscosityGeneral(IssmDouble ko,IssmDouble Ec, IssmDouble Es,IssmDouble vx,IssmDouble vy,IssmDouble vz,IssmDouble* dvx,IssmDouble* dvy,IssmDouble* dvz){/*{{{*/
+
+	/*Intermediaries*/
+	IssmDouble viscosity;
+	IssmDouble E,lambdas;
+	IssmDouble epso,epsprime_norm;
+	IssmDouble vmag,dvmag[3];
+
+	/*Calculate velocity magnitude and its derivative*/
+	vmag = sqrt(vx*vx+vy*vy+vz*vz);
+	if(vmag<1e-12){
+		dvmag[0]=0;
+		dvmag[1]=0;
+		dvmag[2]=0;
+	}
+	else{
+		dvmag[0]=1./(2*sqrt(vmag))*(2*vx*dvx[0]+2*vy*dvy[0]+2*vz*dvz[0]);
+		dvmag[1]=1./(2*sqrt(vmag))*(2*vx*dvx[1]+2*vy*dvy[1]+2*vz*dvz[1]);
+		dvmag[2]=1./(2*sqrt(vmag))*(2*vx*dvx[2]+2*vy*dvy[2]+2*vz*dvz[2]);
+	}
+
+	EstarStrainrateQuantities(&epso,&epsprime_norm,vx,vy,vz,vmag,dvx,dvy,dvz,&dvmag[0]);
+	lambdas=EstarLambdaS(epso,epsprime_norm);
+
+	/*Get total enhancement factor E(lambdas)*/
+	E = Ec + (Es-Ec)*lambdas*lambdas;
+
+	/*Compute viscosity*/
+	_assert_(E>0.); 
+	_assert_(ko>0.); 
+	_assert_(epso>0.); 
+	viscosity = 1./(2*pow(ko*E*epso*epso,1./3.));
+
+	/*Assign output pointer*/
+	return viscosity;
+}
+/*}}}*/
 void  Matestar::GetViscosity_B(IssmDouble* pdmudB,IssmDouble eps_eff){/*{{{*/
 	_error_("not implemented yet");
@@ -229,30 +273,18 @@
 }
 /*}}}*/
-void  Matestar::GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){/*{{{*/
-	_error_("not implemented yet");
-}
-/*}}}*/
-void  Matestar::GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
-	_error_("not implemented yet");
-}
-/*}}}*/
-void  Matestar::GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* epsilon){/*{{{*/
-	_error_("not implemented yet");
-}
-/*}}}*/
-void  Matestar::GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
-	_error_("not implemented yet");
-}
-/*}}}*/
 void  Matestar::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
 	_error_("not implemented yet");
 }
 /*}}}*/
-void  Matestar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
-
-}
-/*}}}*/
-void  Matestar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
-
+void  Matestar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
+	/*Nothing updated yet*/
+}
+/*}}}*/
+void  Matestar::InputUpdateFromConstant(int constant, int name){/*{{{*/
+	/*Nothing updated yet*/
+}
+/*}}}*/
+void  Matestar::InputUpdateFromConstant(bool constant, int name){/*{{{*/
+	/*Nothing updated yet*/
 }
 /*}}}*/
@@ -261,14 +293,28 @@
 }
 /*}}}*/
-void  Matestar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
-	/*Nothing updated yet*/
-}
-/*}}}*/
-void  Matestar::InputUpdateFromConstant(int constant, int name){/*{{{*/
-	/*Nothing updated yet*/
-}
-/*}}}*/
-void  Matestar::InputUpdateFromConstant(bool constant, int name){/*{{{*/
-	/*Nothing updated yet*/
+void  Matestar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
+
+}
+/*}}}*/
+void  Matestar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
+
+}
+/*}}}*/
+bool Matestar::IsDamage(){/*{{{*/
+
+	_error_("not implemented yet");
+}
+/*}}}*/
+void  Matestar::ResetHooks(){/*{{{*/
+
+	this->element=NULL;
+
+	/*Get Element type*/
+	this->helement->reset();
+
+}
+/*}}}*/
+void  Matestar::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
+
 }
 /*}}}*/
@@ -394,48 +440,2 @@
 	_error_("not implemented yet");
 }/*}}}*/
-void  Matestar::ResetHooks(){/*{{{*/
-
-	this->element=NULL;
-
-	/*Get Element type*/
-	this->helement->reset();
-
-}
-/*}}}*/
-IssmDouble Matestar::GetViscosityGeneral(IssmDouble ko,IssmDouble Ec, IssmDouble Es,IssmDouble vx,IssmDouble vy,IssmDouble vz,IssmDouble* dvx,IssmDouble* dvy,IssmDouble* dvz){/*{{{*/
-
-	/*Intermediaries*/
-	IssmDouble viscosity;
-	IssmDouble E,lambdas;
-	IssmDouble epso,epsprime_norm;
-	IssmDouble vmag,dvmag[3];
-
-	/*Calculate velocity magnitude and its derivative*/
-	vmag = sqrt(vx*vx+vy*vy+vz*vz);
-	if(vmag<1e-12){
-		dvmag[0]=0;
-		dvmag[1]=0;
-		dvmag[2]=0;
-	}
-	else{
-		dvmag[0]=1./(2*sqrt(vmag))*(2*vx*dvx[0]+2*vy*dvy[0]+2*vz*dvz[0]);
-		dvmag[1]=1./(2*sqrt(vmag))*(2*vx*dvx[1]+2*vy*dvy[1]+2*vz*dvz[1]);
-		dvmag[2]=1./(2*sqrt(vmag))*(2*vx*dvx[2]+2*vy*dvy[2]+2*vz*dvz[2]);
-	}
-
-	EstarStrainrateQuantities(&epso,&epsprime_norm,vx,vy,vz,vmag,dvx,dvy,dvz,&dvmag[0]);
-	lambdas=EstarLambdaS(epso,epsprime_norm);
-
-	/*Get total enhancement factor E(lambdas)*/
-	E = Ec + (Es-Ec)*lambdas*lambdas;
-
-	/*Compute viscosity*/
-	_assert_(E>0.); 
-	_assert_(ko>0.); 
-	_assert_(epso>0.); 
-	viscosity = 1./(2*pow(ko*E*epso*epso,1./3.));
-
-	/*Assign output pointer*/
-	return viscosity;
-}
-/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Materials/Matestar.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Materials/Matestar.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Materials/Matestar.h	(revision 20827)
@@ -36,31 +36,30 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Object* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Update virtual funictions definitions: {{{*/
-		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
-		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
-		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromConstant(IssmDouble constant, int name);
 		void  InputUpdateFromConstant(int constant, int name);
 		void  InputUpdateFromConstant(bool constant, int name);
 		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented");};
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		/*}}}*/
 		/*Material virtual functions resolution: {{{*/
 		void   Configure(Elements* elements);
 		Material*  copy2(Element* element);
-		void       SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void       GetViscosity(IssmDouble* pviscosity, IssmDouble eps_eff);
-		void       GetViscosity_B(IssmDouble* pviscosity, IssmDouble eps_eff);
-		void       GetViscosity_D(IssmDouble* pviscosity, IssmDouble eps_eff);
 		void       GetViscosityBar(IssmDouble* pviscosity, IssmDouble eps_eff);
 		void       GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon);
 		void       GetViscosityDComplement(IssmDouble*, IssmDouble*);
 		void       GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
+		void       GetViscosity_B(IssmDouble* pviscosity, IssmDouble eps_eff);
+		void       GetViscosity_D(IssmDouble* pviscosity, IssmDouble eps_eff);
 		void       GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
 		IssmDouble GetA();
@@ -73,4 +72,5 @@
 		bool       IsDamage();
 		void       ResetHooks();
+		void       SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 
 		void       ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input);
Index: /issm/trunk-jpl/src/c/classes/Materials/Matice.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Materials/Matice.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Materials/Matice.cpp	(revision 20827)
@@ -117,10 +117,4 @@
 int       Matice::Id(void){ return mid; }/*{{{*/
 /*}}}*/
-int       Matice::ObjectEnum(void){/*{{{*/
-
-	return MaticeEnum;
-
-}
-/*}}}*/
 void      Matice::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
 
@@ -135,4 +129,10 @@
 }
 /*}}}*/
+int       Matice::ObjectEnum(void){/*{{{*/
+
+	return MaticeEnum;
+
+}
+/*}}}*/
 
 /*Matice management*/
@@ -145,8 +145,4 @@
 }
 /*}}}*/
-void  Matice::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
-
-}
-/*}}}*/
 IssmDouble Matice::GetA(){/*{{{*/
 	/*
@@ -191,13 +187,4 @@
 	element->inputs->GetInputAverage(&Bbar,MaterialsRheologyBbarEnum);
 	return Bbar;
-}
-/*}}}*/
-IssmDouble Matice::GetN(){/*{{{*/
-
-	/*Output*/
-	IssmDouble n;
-
-	element->inputs->GetInputAverage(&n,MaterialsRheologyNEnum);
-	return n;
 }
 /*}}}*/
@@ -218,4 +205,13 @@
 	if(this->isdamaged)element->inputs->GetInputAverage(&Dbar,DamageDbarEnum);
 	return Dbar;
+}
+/*}}}*/
+IssmDouble Matice::GetN(){/*{{{*/
+
+	/*Output*/
+	IssmDouble n;
+
+	element->inputs->GetInputAverage(&n,MaterialsRheologyNEnum);
+	return n;
 }
 /*}}}*/
@@ -275,58 +271,4 @@
 	/*Return: */
 	*pviscosity=viscosity;
-}
-/*}}}*/
-void  Matice::GetViscosity_B(IssmDouble* pdmudB,IssmDouble eps_eff){/*{{{*/
-
-	/*output: */
-	IssmDouble dmudB;
-
-	/*Intermediary: */
-	IssmDouble D=0.,n;
-
-	/*Get B and n*/
-	n=GetN(); _assert_(n>0.);
-	if(this->isdamaged){
-		D=GetD();
-		_assert_(D>=0. && D<1.);
-	}
-
-	if(n==1.){
-		/*Linear Viscous behavior (Newtonian fluid) dmudB=B/2: */
-		dmudB=(1.-D)/2.;
-	}
-	else{
-		if(eps_eff==0.) dmudB = 0.;
-		else            dmudB = (1.-D)/(2.*pow(eps_eff,(n-1.)/n));
-	}
-
-	/*Return: */
-	*pdmudB=dmudB;
-}
-/*}}}*/
-void  Matice::GetViscosity_D(IssmDouble* pdmudD,IssmDouble eps_eff){/*{{{*/
-
-	/*output: */
-	IssmDouble dmudD;
-
-	/*Intermediary: */
-	IssmDouble n,B;
-
-	/*Get B and n*/
-	n=GetN(); _assert_(n>0.);
-	B=GetBbar();
-	_assert_(this->isdamaged);
-
-	if(n==1.){
-		/*Linear Viscous behavior (Newtonian fluid) dmudB=B/2: */
-		dmudD=-B/2.;
-	}
-	else{
-		if(eps_eff==0.) dmudD = 0.;
-		else            dmudD = -B/(2.*pow(eps_eff,(n-1.)/n));
-	}
-
-	/*Return: */
-	*pdmudD=dmudD;
 }
 /*}}}*/
@@ -527,4 +469,58 @@
 }
 /*}}}*/
+void  Matice::GetViscosity_B(IssmDouble* pdmudB,IssmDouble eps_eff){/*{{{*/
+
+	/*output: */
+	IssmDouble dmudB;
+
+	/*Intermediary: */
+	IssmDouble D=0.,n;
+
+	/*Get B and n*/
+	n=GetN(); _assert_(n>0.);
+	if(this->isdamaged){
+		D=GetD();
+		_assert_(D>=0. && D<1.);
+	}
+
+	if(n==1.){
+		/*Linear Viscous behavior (Newtonian fluid) dmudB=B/2: */
+		dmudB=(1.-D)/2.;
+	}
+	else{
+		if(eps_eff==0.) dmudB = 0.;
+		else            dmudB = (1.-D)/(2.*pow(eps_eff,(n-1.)/n));
+	}
+
+	/*Return: */
+	*pdmudB=dmudB;
+}
+/*}}}*/
+void  Matice::GetViscosity_D(IssmDouble* pdmudD,IssmDouble eps_eff){/*{{{*/
+
+	/*output: */
+	IssmDouble dmudD;
+
+	/*Intermediary: */
+	IssmDouble n,B;
+
+	/*Get B and n*/
+	n=GetN(); _assert_(n>0.);
+	B=GetBbar();
+	_assert_(this->isdamaged);
+
+	if(n==1.){
+		/*Linear Viscous behavior (Newtonian fluid) dmudB=B/2: */
+		dmudD=-B/2.;
+	}
+	else{
+		if(eps_eff==0.) dmudD = 0.;
+		else            dmudD = -B/(2.*pow(eps_eff,(n-1.)/n));
+	}
+
+	/*Return: */
+	*pdmudD=dmudD;
+}
+/*}}}*/
 void  Matice::GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* epsilon){/*{{{*/
 
@@ -555,10 +551,14 @@
 }
 /*}}}*/
-void  Matice::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
-
-}
-/*}}}*/
-void  Matice::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
-
+void  Matice::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
+	/*Nothing updated yet*/
+}
+/*}}}*/
+void  Matice::InputUpdateFromConstant(int constant, int name){/*{{{*/
+	/*Nothing updated yet*/
+}
+/*}}}*/
+void  Matice::InputUpdateFromConstant(bool constant, int name){/*{{{*/
+	/*Nothing updated yet*/
 }
 /*}}}*/
@@ -567,14 +567,23 @@
 }
 /*}}}*/
-void  Matice::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
-	/*Nothing updated yet*/
-}
-/*}}}*/
-void  Matice::InputUpdateFromConstant(int constant, int name){/*{{{*/
-	/*Nothing updated yet*/
-}
-/*}}}*/
-void  Matice::InputUpdateFromConstant(bool constant, int name){/*{{{*/
-	/*Nothing updated yet*/
+void  Matice::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
+
+}
+/*}}}*/
+void  Matice::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
+
+}
+/*}}}*/
+void  Matice::ResetHooks(){/*{{{*/
+
+	this->element=NULL;
+
+	/*Get Element type*/
+	this->helement->reset();
+
+}
+/*}}}*/
+void  Matice::SetCurrentConfiguration(Elements* elementsin,Loads* loadsin,Nodes* nodesin,Vertices* verticesin,Materials* materialsin,Parameters* parametersin){/*{{{*/
+
 }
 /*}}}*/
@@ -737,11 +746,2 @@
 	this->GetViscosity2dDerivativeEpsSquare(pmu_prime,epsilon);
 }/*}}}*/
-void  Matice::ResetHooks(){/*{{{*/
-
-	this->element=NULL;
-
-	/*Get Element type*/
-	this->helement->reset();
-
-}
-/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Materials/Matice.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Materials/Matice.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Materials/Matice.h	(revision 20827)
@@ -37,31 +37,30 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Object* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Update virtual funictions definitions: {{{*/
-		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
-		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
-		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void  InputUpdateFromConstant(IssmDouble constant, int name);
 		void  InputUpdateFromConstant(int constant, int name);
 		void  InputUpdateFromConstant(bool constant, int name);
 		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented");};
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrow, int ncols, int name, int type);
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type);
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		/*}}}*/
 		/*Material virtual functions resolution: {{{*/
 		void   Configure(Elements* elements);
 		Material*  copy2(Element* element);
-		void       SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 		void       GetViscosity(IssmDouble* pviscosity, IssmDouble eps_eff);
-		void       GetViscosity_B(IssmDouble* pviscosity, IssmDouble eps_eff);
-		void       GetViscosity_D(IssmDouble* pviscosity, IssmDouble eps_eff);
 		void       GetViscosityBar(IssmDouble* pviscosity, IssmDouble eps_eff);
 		void       GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon);
 		void       GetViscosityDComplement(IssmDouble*, IssmDouble*);
 		void       GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
+		void       GetViscosity_B(IssmDouble* pviscosity, IssmDouble eps_eff);
+		void       GetViscosity_D(IssmDouble* pviscosity, IssmDouble eps_eff);
 		void       GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon);
 		IssmDouble GetA();
@@ -74,4 +73,5 @@
 		bool       IsDamage();
 		void       ResetHooks();
+		void       SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
 
 		void       ViscosityFS(IssmDouble* pviscosity,int dim,IssmDouble* xyz_list,Gauss* gauss,Input* vx_input,Input* vy_input,Input* vz_input);
Index: /issm/trunk-jpl/src/c/classes/Materials/Matpar.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Materials/Matpar.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Materials/Matpar.cpp	(revision 20827)
@@ -179,4 +179,60 @@
 
 /*Object virtual functions definitions:*/
+Object* Matpar::copy() {/*{{{*/
+
+	/*Output*/
+	Matpar* matpar;
+
+	/*Initialize output*/
+	matpar=new Matpar(*this);
+
+	/*copy fields: */
+	matpar->mid=this->mid;
+	matpar->rho_ice=this->rho_ice;
+	matpar->rho_water=this->rho_water;
+	matpar->rho_freshwater=this->rho_freshwater;
+	matpar->mu_water=this->mu_water;
+	matpar->heatcapacity=this->heatcapacity;
+	matpar->thermalconductivity=this->thermalconductivity;
+	matpar->temperateiceconductivity=this->temperateiceconductivity;
+	matpar->latentheat=this->latentheat;
+	matpar->beta=this->beta;
+	matpar->meltingpoint=this->meltingpoint;
+	matpar->referencetemperature=this->referencetemperature;
+	matpar->mixed_layer_capacity=this->mixed_layer_capacity;
+	matpar->thermal_exchange_velocity=this->thermal_exchange_velocity;
+	matpar->g=this->g;
+	matpar->desfac=this->desfac;
+	matpar->rlaps=this->rlaps;
+	matpar->rlapslgm=this->rlapslgm;
+	matpar->dpermil=this->dpermil;
+
+	matpar->sediment_compressibility=this->sediment_compressibility;
+	matpar->sediment_porosity=this->sediment_porosity;
+	matpar->sediment_thickness=this->sediment_thickness;
+	matpar->water_compressibility=this->water_compressibility;
+
+	matpar->epl_compressibility=this->epl_compressibility;
+	matpar->epl_porosity=this->epl_porosity;
+	matpar->epl_init_thickness=this->epl_init_thickness;
+	matpar->epl_colapse_thickness=this->epl_colapse_thickness;
+	matpar->epl_max_thickness=this->epl_max_thickness;
+	matpar->epl_conductivity=this->epl_conductivity;
+
+	matpar->lithosphere_shear_modulus=this->lithosphere_shear_modulus;
+	matpar->lithosphere_density=this->lithosphere_density;
+	matpar->mantle_shear_modulus=this->mantle_shear_modulus;
+	matpar->mantle_density=this->mantle_density;
+	
+	matpar->earth_density=this->earth_density;
+
+	return matpar;
+}
+/*}}}*/
+void Matpar::DeepEcho(void){/*{{{*/
+
+	this->Echo();
+}		
+/*}}}*/
 void Matpar::Echo(void){/*{{{*/
 
@@ -204,67 +260,5 @@
 }
 /*}}}*/
-void Matpar::DeepEcho(void){/*{{{*/
-
-	this->Echo();
-}		
-/*}}}*/
 int  Matpar::Id(void){ return mid; }/*{{{*/
-/*}}}*/
-int  Matpar::ObjectEnum(void){/*{{{*/
-
-	return MatparEnum;
-
-}
-/*}}}*/
-Object* Matpar::copy() {/*{{{*/
-
-	/*Output*/
-	Matpar* matpar;
-
-	/*Initialize output*/
-	matpar=new Matpar(*this);
-
-	/*copy fields: */
-	matpar->mid=this->mid;
-	matpar->rho_ice=this->rho_ice;
-	matpar->rho_water=this->rho_water;
-	matpar->rho_freshwater=this->rho_freshwater;
-	matpar->mu_water=this->mu_water;
-	matpar->heatcapacity=this->heatcapacity;
-	matpar->thermalconductivity=this->thermalconductivity;
-	matpar->temperateiceconductivity=this->temperateiceconductivity;
-	matpar->latentheat=this->latentheat;
-	matpar->beta=this->beta;
-	matpar->meltingpoint=this->meltingpoint;
-	matpar->referencetemperature=this->referencetemperature;
-	matpar->mixed_layer_capacity=this->mixed_layer_capacity;
-	matpar->thermal_exchange_velocity=this->thermal_exchange_velocity;
-	matpar->g=this->g;
-	matpar->desfac=this->desfac;
-	matpar->rlaps=this->rlaps;
-	matpar->rlapslgm=this->rlapslgm;
-	matpar->dpermil=this->dpermil;
-
-	matpar->sediment_compressibility=this->sediment_compressibility;
-	matpar->sediment_porosity=this->sediment_porosity;
-	matpar->sediment_thickness=this->sediment_thickness;
-	matpar->water_compressibility=this->water_compressibility;
-
-	matpar->epl_compressibility=this->epl_compressibility;
-	matpar->epl_porosity=this->epl_porosity;
-	matpar->epl_init_thickness=this->epl_init_thickness;
-	matpar->epl_colapse_thickness=this->epl_colapse_thickness;
-	matpar->epl_max_thickness=this->epl_max_thickness;
-	matpar->epl_conductivity=this->epl_conductivity;
-
-	matpar->lithosphere_shear_modulus=this->lithosphere_shear_modulus;
-	matpar->lithosphere_density=this->lithosphere_density;
-	matpar->mantle_shear_modulus=this->mantle_shear_modulus;
-	matpar->mantle_density=this->mantle_density;
-	
-	matpar->earth_density=this->earth_density;
-
-	return matpar;
-}
 /*}}}*/
 void Matpar::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -328,18 +322,12 @@
 }
 /*}}}*/
+int  Matpar::ObjectEnum(void){/*{{{*/
+
+	return MatparEnum;
+
+}
+/*}}}*/
 
 /*Update virtual functions definitions:*/
-void   Matpar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
-	/*Nothing updated yet*/
-}
-/*}}}*/
-void   Matpar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
-	/*Nothing updated yet*/
-}
-/*}}}*/
-void  Matpar::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){/*{{{*/
-	/*Nothing updated yet*/
-}
-/*}}}*/
 void   Matpar::InputUpdateFromConstant(IssmDouble constant, int name){/*{{{*/
 
@@ -410,4 +398,16 @@
 /*}}}*/
 void   Matpar::InputUpdateFromConstant(bool constant, int name){/*{{{*/
+	/*Nothing updated yet*/
+}
+/*}}}*/
+void  Matpar::InputUpdateFromMatrixDakota(IssmDouble* matrix, int nrows, int ncols,int name, int type){/*{{{*/
+	/*Nothing updated yet*/
+}
+/*}}}*/
+void   Matpar::InputUpdateFromVector(IssmDouble* vector, int name, int type){/*{{{*/
+	/*Nothing updated yet*/
+}
+/*}}}*/
+void   Matpar::InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){/*{{{*/
 	/*Nothing updated yet*/
 }
Index: /issm/trunk-jpl/src/c/classes/Materials/Matpar.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Materials/Matpar.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Materials/Matpar.h	(revision 20827)
@@ -79,19 +79,19 @@
 
 		/*Object virtual functions definitions:{{{ */
+		Object *copy();
+		void    DeepEcho();
 		void    Echo();
-		void    DeepEcho();
 		int     Id();
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int     ObjectEnum();
-		Object *copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Update virtual functions resolution: {{{*/
-		void   InputUpdateFromVector(IssmDouble* vector, int name, int type);
-		void   InputUpdateFromMatrixDakota(IssmDouble* matrix,int nrows,int ncols, int name, int type);
-		void   InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		void   InputUpdateFromConstant(IssmDouble constant, int name);
 		void   InputUpdateFromConstant(int constant, int name);
 		void   InputUpdateFromConstant(bool constant, int name);
 		void   InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented");};
+		void   InputUpdateFromMatrixDakota(IssmDouble* matrix,int nrows,int ncols, int name, int type);
+		void   InputUpdateFromVector(IssmDouble* vector, int name, int type);
+		void   InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type);
 		/*}}}*/
 		/*Material virtual functions resolution: {{{*/
@@ -99,10 +99,10 @@
 		void       Configure(Elements* elements);
 		void       GetViscosity(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
-		void       GetViscosity_B(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
-		void       GetViscosity_D(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
 		void       GetViscosityBar(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
 		void       GetViscosityComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon){_error_("not supported");};
 		void       GetViscosityDComplement(IssmDouble* pviscosity_complement, IssmDouble* pepsilon){_error_("not supported");};
 		void       GetViscosityDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon){_error_("not supported");};
+		void       GetViscosity_B(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
+		void       GetViscosity_D(IssmDouble* pviscosity,IssmDouble eps_eff){_error_("not supported");};
 		void       GetViscosity2dDerivativeEpsSquare(IssmDouble* pmu_prime, IssmDouble* pepsilon){_error_("not supported");};
 		IssmDouble GetA(){_error_("not supported");};
@@ -110,7 +110,7 @@
 		IssmDouble GetB(){_error_("not supported");};
 		IssmDouble GetBbar(){_error_("not supported");};
-		IssmDouble GetN(){_error_("not supported");};
 		IssmDouble GetD(){_error_("not supported");};
 		IssmDouble GetDbar(){_error_("not supported");};
+		IssmDouble GetN(){_error_("not supported");};
 		bool       IsDamage(){_error_("not supported");};
 		void       ResetHooks();
Index: /issm/trunk-jpl/src/c/classes/Options/GenericOption.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Options/GenericOption.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Options/GenericOption.h	(revision 20827)
@@ -48,9 +48,7 @@
 
 		/*Object virtual functions definitions:*/
-		void Echo(){ /*{{{*/
-
-			this->DeepEcho();
-
-		} /*}}}*/
+		Object* copy(){/*{{{*/
+			_error_("Not implemented yet");
+		};/*}}}*/
 		void DeepEcho(){ /*{{{*/
 
@@ -74,4 +72,9 @@
 			_printf_(indent << "         value: " << value << "\n");;
 		} /*}}}*/
+		void Echo(){ /*{{{*/
+
+			this->DeepEcho();
+
+		} /*}}}*/
 		int  Id(){/*{{{*/
 			_error_("Not implemented yet");
@@ -80,23 +83,20 @@
 			return GenericOptionEnum;
 		};/*}}}*/
-		Object* copy(){/*{{{*/
-			_error_("Not implemented yet");
-		};/*}}}*/
 
 		/*GenericOption functions: */
+		void  Get(OptionType* pvalue){/*{{{*/
+			*pvalue=value; 
+		};/*}}}*/
 		char* Name(){/*{{{*/
 			return name;
+		};/*}}}*/
+		int   NDims(){/*{{{*/
+			return ndims;
 		};/*}}}*/
 		int   NumEl(){/*{{{*/
 			return numel;
 		};/*}}}*/
-		int   NDims(){/*{{{*/
-			return ndims;
-		};/*}}}*/
 		int*  Size(){/*{{{*/
 			return size;
-		};/*}}}*/
-		void  Get(OptionType* pvalue){/*{{{*/
-			*pvalue=value; 
 		};/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Options/Option.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Options/Option.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Options/Option.h	(revision 20827)
@@ -20,17 +20,17 @@
 
 		/*Object virtual functions definitions*/
-		virtual void  Echo()= 0;
+		Object       *copy(){_error_("Not implemented yet"); };
 		virtual void  DeepEcho()= 0;
 		virtual void  DeepEcho(char  *indent)=0;
+		virtual void  Echo()= 0;
 		int           Id(){_error_("Not implemented yet"); };
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 		int           ObjectEnum(){return OptionEnum;              };
-		Object       *copy(){_error_("Not implemented yet"); };
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 
 
 		/*virtual functions: */
 		virtual char* Name()=0;
+		virtual int   NDims()=0;
 		virtual int   NumEl()=0;
-		virtual int   NDims()=0;
 		virtual int*  Size()=0;
 
Index: /issm/trunk-jpl/src/c/classes/Options/OptionUtilities.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Options/OptionUtilities.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Options/OptionUtilities.cpp	(revision 20827)
@@ -51,4 +51,22 @@
 	return(index);
 }/*}}}*/
+int IndexFromRowWiseDims(int* dims, int* size, int ndims) {/*{{{*/
+
+	int   i;
+	int   index=0;
+
+	/*check for any dimension too large  */
+	for (i=0; i<ndims; i++){
+		if (dims[i] >= size[i]) _error_("Dimension " << i << " of " << dims[i] << " exceeds size of " << size[i] << ".");
+	}
+
+	/*calculate the index  */
+	for (i=0; i<ndims; i++) {
+		index*=size[i];
+		index+=dims[i];
+	}
+
+	return(index);
+}/*}}}*/
 int RowWiseDimsFromIndex(int* dims, int index, int* size, int ndims) {/*{{{*/
 
@@ -69,22 +87,4 @@
 	return(0);
 }/*}}}*/
-int IndexFromRowWiseDims(int* dims, int* size, int ndims) {/*{{{*/
-
-	int   i;
-	int   index=0;
-
-	/*check for any dimension too large  */
-	for (i=0; i<ndims; i++){
-		if (dims[i] >= size[i]) _error_("Dimension " << i << " of " << dims[i] << " exceeds size of " << size[i] << ".");
-	}
-
-	/*calculate the index  */
-	for (i=0; i<ndims; i++) {
-		index*=size[i];
-		index+=dims[i];
-	}
-
-	return(index);
-}/*}}}*/
 int StringFromDims(char* cstr, int* dims, int ndims) {/*{{{*/
 
Index: /issm/trunk-jpl/src/c/classes/Options/OptionUtilities.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Options/OptionUtilities.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Options/OptionUtilities.h	(revision 20827)
@@ -15,6 +15,6 @@
 int ColumnWiseDimsFromIndex(int* dims, int index, int* size, int ndims);
 int IndexFromColumnWiseDims(int* dims, int* size, int ndims);
+int IndexFromRowWiseDims(int* dims, int* size, int ndims);
 int RowWiseDimsFromIndex(int* dims, int index, int* size, int ndims);
-int IndexFromRowWiseDims(int* dims, int* size, int ndims);
 int StringFromDims(char* cstr, int* dims, int ndims);
 int StringFromSize(char* cstr, int* size, int ndims);
Index: /issm/trunk-jpl/src/c/classes/Params/BoolParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/BoolParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/BoolParam.cpp	(revision 20827)
@@ -32,6 +32,8 @@
 
 /*Object virtual functions definitions:*/
-void BoolParam::Echo(void){/*{{{*/
-	this->DeepEcho();
+Param* BoolParam::copy() {/*{{{*/
+
+	return new BoolParam(this->enum_type,this->value);
+
 }
 /*}}}*/
@@ -40,17 +42,9 @@
 }
 /*}}}*/
-int    BoolParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int BoolParam::ObjectEnum(void){/*{{{*/
-
-	return BoolParamEnum;
-
+void BoolParam::Echo(void){/*{{{*/
+	this->DeepEcho();
 }
 /*}}}*/
-Param* BoolParam::copy() {/*{{{*/
-
-	return new BoolParam(this->enum_type,this->value);
-
-}
+int    BoolParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void BoolParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -63,3 +57,9 @@
 }
 /*}}}*/
+int BoolParam::ObjectEnum(void){/*{{{*/
+
+	return BoolParamEnum;
+
+}
+/*}}}*/
 		
Index: /issm/trunk-jpl/src/c/classes/Params/BoolParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/BoolParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/BoolParam.h	(revision 20827)
@@ -31,13 +31,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){*pbool=value;}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
@@ -55,5 +54,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){this->value=boolean;}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an int");}
@@ -69,5 +70,4 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/DataSetParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/DataSetParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/DataSetParam.cpp	(revision 20827)
@@ -33,6 +33,8 @@
 
 /*Object virtual functions definitions:*/
-void DataSetParam::Echo(void){/*{{{*/
-	this->DeepEcho();
+Param* DataSetParam::copy() {/*{{{*/
+
+	return new DataSetParam(this->enum_type,this->value);
+
 }
 /*}}}*/
@@ -44,17 +46,9 @@
 }
 /*}}}*/
-int    DataSetParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int DataSetParam::ObjectEnum(void){/*{{{*/
-
-	return DataSetParamEnum;
-
+void DataSetParam::Echo(void){/*{{{*/
+	this->DeepEcho();
 }
 /*}}}*/
-Param* DataSetParam::copy() {/*{{{*/
-
-	return new DataSetParam(this->enum_type,this->value);
-
-}
+int    DataSetParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void DataSetParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -68,4 +62,10 @@
 }
 /*}}}*/
+int DataSetParam::ObjectEnum(void){/*{{{*/
+
+	return DataSetParamEnum;
+
+}
+/*}}}*/
 
 /*DataSetParam virtual functions definitions: */
Index: /issm/trunk-jpl/src/c/classes/Params/DataSetParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/DataSetParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/DataSetParam.h	(revision 20827)
@@ -32,13 +32,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){  _error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");}
@@ -56,5 +55,7 @@
 		void  GetParameterValue(Matrix<IssmDouble>** pmat){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a Mat");}
 		void  GetParameterValue(DataSet** pdataset);
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
@@ -71,5 +72,4 @@
 		void  SetValue(DataSet* dataset){_error_("DataSet param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a DataSet yet");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("DataSet param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.cpp	(revision 20827)
@@ -76,4 +76,33 @@
 
 /*Object virtual functions definitions:*/
+Param* DoubleMatArrayParam::copy() {/*{{{*/
+
+	return new DoubleMatArrayParam(this->enum_type,this->array, this->M, this->mdim_array,this->ndim_array);
+
+}
+/*}}}*/
+void DoubleMatArrayParam::DeepEcho(void){/*{{{*/
+
+	int i,j,k;
+	int m,n;
+	IssmDouble* matrix=NULL;
+
+	_printf_("DoubleMatArrayParam:\n");
+	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+	_printf_("   array size: " << this->M << "\n");
+	for(i=0;i<M;i++){
+		_printf_("   array " << i << " (" << mdim_array[i] << "x" << ndim_array[i] << "):\n");
+		matrix=array[i];
+		m=mdim_array[i];
+		n=ndim_array[i];
+
+		for(j=0;j<m;j++){
+			_printf_("   ");
+			for(k=0;k<n;k++)_printf_(*(matrix+n*j+k) << " ");
+			_printf_("\n");
+		}
+	}
+}
+/*}}}*/
 void DoubleMatArrayParam::Echo(void){/*{{{*/
 
@@ -85,40 +114,5 @@
 }
 /*}}}*/
-void DoubleMatArrayParam::DeepEcho(void){/*{{{*/
-
-	int i,j,k;
-	int m,n;
-	IssmDouble* matrix=NULL;
-
-	_printf_("DoubleMatArrayParam:\n");
-	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
-	_printf_("   array size: " << this->M << "\n");
-	for(i=0;i<M;i++){
-		_printf_("   array " << i << " (" << mdim_array[i] << "x" << ndim_array[i] << "):\n");
-		matrix=array[i];
-		m=mdim_array[i];
-		n=ndim_array[i];
-
-		for(j=0;j<m;j++){
-			_printf_("   ");
-			for(k=0;k<n;k++)_printf_(*(matrix+n*j+k) << " ");
-			_printf_("\n");
-		}
-	}
-}
-/*}}}*/
 int    DoubleMatArrayParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int DoubleMatArrayParam::ObjectEnum(void){/*{{{*/
-
-	return DoubleMatArrayParamEnum;
-
-}
-/*}}}*/
-Param* DoubleMatArrayParam::copy() {/*{{{*/
-
-	return new DoubleMatArrayParam(this->enum_type,this->array, this->M, this->mdim_array,this->ndim_array);
-
-}
 /*}}}*/
 void DoubleMatArrayParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -144,4 +138,10 @@
 }
 /*}}}*/
+int DoubleMatArrayParam::ObjectEnum(void){/*{{{*/
+
+	return DoubleMatArrayParamEnum;
+
+}
+/*}}}*/
 
 /*DoubleMatArrayParam virtual functions definitions: */
Index: /issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.h	(revision 20827)
@@ -34,13 +34,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << "cannot return an integer");}
@@ -58,5 +57,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << "cannot hold an integer");}
@@ -72,5 +73,4 @@
 		void  SetValue(FILE* fid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array);
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/DoubleParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/DoubleParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/DoubleParam.cpp	(revision 20827)
@@ -29,6 +29,8 @@
 
 /*Object virtual functions definitions:*/
-void DoubleParam::Echo(void){/*{{{*/
-	this->DeepEcho();
+Param* DoubleParam::copy() {/*{{{*/
+
+	return new DoubleParam(this->enum_type,this->value);
+
 }
 /*}}}*/
@@ -38,17 +40,9 @@
 }
 /*}}}*/
-int  DoubleParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  DoubleParam::ObjectEnum(void){/*{{{*/
-
-	return DoubleParamEnum;
-
+void DoubleParam::Echo(void){/*{{{*/
+	this->DeepEcho();
 }
 /*}}}*/
-Param* DoubleParam::copy() {/*{{{*/
-
-	return new DoubleParam(this->enum_type,this->value);
-
-}
+int  DoubleParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void DoubleParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -58,4 +52,10 @@
 	MARSHALLING(enum_type);
 	MARSHALLING(value);
+
+}
+/*}}}*/
+int  DoubleParam::ObjectEnum(void){/*{{{*/
+
+	return DoubleParamEnum;
 
 }
Index: /issm/trunk-jpl/src/c/classes/Params/DoubleParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/DoubleParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/DoubleParam.h	(revision 20827)
@@ -32,13 +32,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool);
 		void  GetParameterValue(int* pinteger);
@@ -56,5 +55,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){this->value=(IssmDouble)boolean;}
 		void  SetValue(int integer){this->value=(IssmDouble)integer;}
@@ -70,5 +71,4 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.cpp	(revision 20827)
@@ -39,7 +39,7 @@
 
 /*Object virtual functions definitions:*/
-void DoubleVecParam::Echo(void){/*{{{*/
+Param* DoubleVecParam::copy() {/*{{{*/
 
-	_printf_(setw(22)<<"   DoubleVecParam "<<setw(35)<<left<<EnumToStringx(this->enum_type)<<" size: "<<this->M<<"\n");
+	return new DoubleVecParam(this->enum_type,this->values,this->M);
 
 }
@@ -51,17 +51,11 @@
 }
 /*}}}*/
-int    DoubleVecParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int DoubleVecParam::ObjectEnum(void){/*{{{*/
+void DoubleVecParam::Echo(void){/*{{{*/
 
-	return DoubleVecParamEnum;
+	_printf_(setw(22)<<"   DoubleVecParam "<<setw(35)<<left<<EnumToStringx(this->enum_type)<<" size: "<<this->M<<"\n");
 
 }
 /*}}}*/
-Param* DoubleVecParam::copy() {/*{{{*/
-
-	return new DoubleVecParam(this->enum_type,this->values,this->M);
-
-}
+int    DoubleVecParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void DoubleVecParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -72,4 +66,10 @@
 	MARSHALLING(M);
 	MARSHALLING_DYNAMIC(values,IssmDouble,M);
+
+}
+/*}}}*/
+int DoubleVecParam::ObjectEnum(void){/*{{{*/
+
+	return DoubleVecParamEnum;
 
 }
Index: /issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.h	(revision 20827)
@@ -32,13 +32,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param virtual functions definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
@@ -56,5 +55,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
@@ -70,5 +71,4 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 		/*DoubleVecParam specific routines:{{{*/
Index: /issm/trunk-jpl/src/c/classes/Params/FileParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/FileParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/FileParam.cpp	(revision 20827)
@@ -32,6 +32,8 @@
 
 /*Object virtual functions definitions:*/
-void FileParam::Echo(void){/*{{{*/
-	this->DeepEcho();
+Param* FileParam::copy() {/*{{{*/
+
+	return new FileParam(this->enum_type,this->value);
+
 }
 /*}}}*/
@@ -41,17 +43,9 @@
 }
 /*}}}*/
-int  FileParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  FileParam::ObjectEnum(void){/*{{{*/
-
-	return FileParamEnum;
-
+void FileParam::Echo(void){/*{{{*/
+	this->DeepEcho();
 }
 /*}}}*/
-Param* FileParam::copy() {/*{{{*/
-
-	return new FileParam(this->enum_type,this->value);
-
-}
+int  FileParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void FileParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -65,2 +59,8 @@
 }
 /*}}}*/
+int  FileParam::ObjectEnum(void){/*{{{*/
+
+	return FileParamEnum;
+
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Params/FileParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/FileParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/FileParam.h	(revision 20827)
@@ -31,13 +31,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){  _error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");}
@@ -55,5 +54,7 @@
 		void  GetParameterValue(FILE** pfid){*pfid=value;};
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a string");}
@@ -69,5 +70,4 @@
 		void  SetValue(FILE* fid){_error_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("File param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/GenericParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/GenericParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/GenericParam.h	(revision 20827)
@@ -39,4 +39,5 @@
                 // unfortunately,  having to implement such a printer method implies
                 // that any structured P must provide the friend << operator
+                Param* copy() { return new GenericParam<P>(*this); };
                 void  DeepEcho() {
                   _printf_("GenericParam:\n");
@@ -46,5 +47,4 @@
                 void  Echo() {DeepEcho();};
                 int   Id(){ return -1; };
-                int   ObjectEnum() {return GenericParamEnum;};
 
                 // the "copy"  has to implement the base class abstract function
@@ -52,15 +52,15 @@
                 // it does not clarify  ownership of the newed up instance...
                 // use the default copy constructor instead
-                Param* copy() { return new GenericParam<P>(*this); };
 					 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){
 						 _printf_("   WARNING: parameter "<<EnumToStringx(this->myEnumVal)<<" is a GenericParam and cannot be marshalled\n");
 						 /*Nothing for now*/
 					 }
+                int   ObjectEnum() {return GenericParamEnum;};
 
                 /*}}}*/
                 /*Param vritual function definitions: {{{*/
-                int   InstanceEnum(){return myEnumVal;}
                 P& GetParameterValue() { return myP;}
                 const P& GetParameterValue()const { return myP;};
+                int   InstanceEnum(){return myEnumVal;}
 
                 // none of these apply ...
@@ -81,4 +81,5 @@
 				void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a DataSet");}
 
+					 void  SetEnum(int enum_in){this->myEnumVal = enum_in;};
                 void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a bool");}
                 void  SetValue(int integer){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an integer");}
@@ -94,5 +95,4 @@
                 void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold a FILE");}
                 void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot hold an array of matrices");}
-					 void  SetEnum(int enum_in){this->myEnumVal = enum_in;};
 
                 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Params/IntMatParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/IntMatParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/IntMatParam.cpp	(revision 20827)
@@ -37,9 +37,7 @@
 
 /*Object virtual functions definitions:*/
-void IntMatParam::Echo(void){/*{{{*/
+Param* IntMatParam::copy() {/*{{{*/
 
-	_printf_("IntMatParam:\n");
-	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
-	_printf_("   matrix size: " << this->M << "x" << this->N << "\n");
+	return new IntMatParam(this->enum_type,this->value,this->M,this->N);
 
 }
@@ -59,17 +57,13 @@
 }
 /*}}}*/
-int  IntMatParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  IntMatParam::ObjectEnum(void){/*{{{*/
+void IntMatParam::Echo(void){/*{{{*/
 
-	return IntMatParamEnum;
+	_printf_("IntMatParam:\n");
+	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+	_printf_("   matrix size: " << this->M << "x" << this->N << "\n");
 
 }
 /*}}}*/
-Param* IntMatParam::copy() {/*{{{*/
-
-	return new IntMatParam(this->enum_type,this->value,this->M,this->N);
-
-}
+int  IntMatParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void IntMatParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -81,4 +75,10 @@
 	MARSHALLING(N);
 	MARSHALLING_DYNAMIC(value,int,M*N);
+}
+/*}}}*/
+int  IntMatParam::ObjectEnum(void){/*{{{*/
+
+	return IntMatParamEnum;
+
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Params/IntMatParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/IntMatParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/IntMatParam.h	(revision 20827)
@@ -33,13 +33,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
@@ -57,5 +56,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
@@ -71,5 +72,4 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/IntParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/IntParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/IntParam.cpp	(revision 20827)
@@ -32,6 +32,8 @@
 
 /*Object virtual functions definitions:*/
-void IntParam::Echo(void){/*{{{*/
-	this->DeepEcho();
+Param* IntParam::copy() {/*{{{*/
+
+	return new IntParam(this->enum_type,this->value);
+
 }
 /*}}}*/
@@ -41,17 +43,9 @@
 }
 /*}}}*/
-int  IntParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  IntParam::ObjectEnum(void){/*{{{*/
-
-	return IntParamEnum;
-
+void IntParam::Echo(void){/*{{{*/
+	this->DeepEcho();
 }
 /*}}}*/
-Param* IntParam::copy() {/*{{{*/
-
-	return new IntParam(this->enum_type,this->value);
-
-}
+int  IntParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void IntParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -64,3 +58,9 @@
 }
 /*}}}*/
+int  IntParam::ObjectEnum(void){/*{{{*/
 
+	return IntParamEnum;
+
+}
+/*}}}*/
+
Index: /issm/trunk-jpl/src/c/classes/Params/IntParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/IntParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/IntParam.h	(revision 20827)
@@ -32,13 +32,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){*pinteger=value;}
@@ -56,5 +55,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a bool");}
 		void  SetValue(int integer){this->value=integer;}
@@ -70,5 +71,4 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/IntVecParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/IntVecParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/IntVecParam.cpp	(revision 20827)
@@ -51,9 +51,7 @@
 
 /*Object virtual functions definitions:*/
-void IntVecParam::Echo(void){/*{{{*/
+Param* IntVecParam::copy() {/*{{{*/
 
-	_printf_("IntVecParam:\n");
-	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
-	_printf_("   vector size: " << this->M << "\n");
+	return new IntVecParam(this->enum_type,this->values,this->M);
 
 }
@@ -71,17 +69,13 @@
 }
 /*}}}*/
-int  IntVecParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  IntVecParam::ObjectEnum(void){/*{{{*/
+void IntVecParam::Echo(void){/*{{{*/
 
-	return IntVecParamEnum;
+	_printf_("IntVecParam:\n");
+	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+	_printf_("   vector size: " << this->M << "\n");
 
 }
 /*}}}*/
-Param* IntVecParam::copy() {/*{{{*/
-
-	return new IntVecParam(this->enum_type,this->values,this->M);
-
-}
+int  IntVecParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void IntVecParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -95,4 +89,10 @@
 	}
 	else values=NULL;
+
+}
+/*}}}*/
+int  IntVecParam::ObjectEnum(void){/*{{{*/
+
+	return IntVecParamEnum;
 
 }
Index: /issm/trunk-jpl/src/c/classes/Params/IntVecParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/IntVecParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/IntVecParam.h	(revision 20827)
@@ -33,13 +33,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param virtual functions definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
@@ -57,5 +56,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
@@ -71,5 +72,4 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/MatrixParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/MatrixParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/MatrixParam.cpp	(revision 20827)
@@ -36,8 +36,7 @@
 
 /*Object virtual functions definitions:*/
-void MatrixParam::Echo(void){/*{{{*/
+Param* MatrixParam::copy() {/*{{{*/
 
-	_printf_("MatrixParam:\n");
-	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+	return new MatrixParam(this->enum_type,this->value);
 
 }
@@ -50,4 +49,11 @@
 }
 /*}}}*/
+void MatrixParam::Echo(void){/*{{{*/
+
+	_printf_("MatrixParam:\n");
+	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+
+}
+/*}}}*/
 int  MatrixParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
@@ -55,10 +61,4 @@
 
 	return MatrixParamEnum;
-
-}
-/*}}}*/
-Param* MatrixParam::copy() {/*{{{*/
-
-	return new MatrixParam(this->enum_type,this->value);
 
 }
Index: /issm/trunk-jpl/src/c/classes/Params/MatrixParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/MatrixParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/MatrixParam.h	(revision 20827)
@@ -32,13 +32,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
@@ -56,5 +55,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
@@ -70,5 +71,4 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/Param.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/Param.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/Param.h	(revision 20827)
@@ -25,9 +25,6 @@
 
 		/*Virtual functions:*/
+		virtual Param* copy()=0;
 		virtual void  Echo()=0;
-		virtual int   ObjectEnum()=0;
-		virtual Param* copy()=0;
-		virtual void Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction)=0;
-		virtual int   InstanceEnum()=0;
 		virtual void  GetParameterValue(bool* pbool)=0;
 		virtual void  GetParameterValue(int* pinteger)=0;
@@ -45,5 +42,9 @@
 		virtual void  GetParameterValue(FILE** pfid)=0;
 		virtual void  GetParameterValue(DataSet** pdataset)=0;
+		virtual int   InstanceEnum()=0;
+		virtual void Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction)=0;
+		virtual int   ObjectEnum()=0;
 
+		virtual void  SetEnum(int enum_in)=0;
 		virtual void  SetValue(bool boolean)=0;
 		virtual void  SetValue(int integer)=0;
@@ -59,5 +60,4 @@
 		virtual void  SetValue(FILE* fid)=0;
 		virtual void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array)=0;
-		virtual void  SetEnum(int enum_in)=0;
 };
 #endif
Index: /issm/trunk-jpl/src/c/classes/Params/Parameters.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/Parameters.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/Parameters.cpp	(revision 20827)
@@ -89,4 +89,12 @@
 }
 /*}}}*/
+void Parameters::DeepEcho(void){/*{{{*/
+	_error_("not implemented yet");
+}
+/*}}}*/
+void Parameters::Echo(void){/*{{{*/
+	_error_("not implemented yet");
+}
+/*}}}*/
 void Parameters::Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction){/*{{{*/
 
@@ -209,12 +217,4 @@
 		}
 	}
-}
-/*}}}*/
-void Parameters::Echo(void){/*{{{*/
-	_error_("not implemented yet");
-}
-/*}}}*/
-void Parameters::DeepEcho(void){/*{{{*/
-	_error_("not implemented yet");
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Params/Parameters.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/Parameters.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/Parameters.h	(revision 20827)
@@ -28,10 +28,10 @@
 
 		/*numerics*/
-		bool  Exist(int enum_type);
 		void  AddObject(Param* newparam);
 		Parameters* Copy(void);
+		void  DeepEcho();
+		void  Echo();
+		bool  Exist(int enum_type);
 		void  Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction);
-		void  Echo();
-		void  DeepEcho();
 
 		void  FindParam(bool* pinteger,int enum_type);
Index: /issm/trunk-jpl/src/c/classes/Params/StringArrayParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/StringArrayParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/StringArrayParam.cpp	(revision 20827)
@@ -56,6 +56,8 @@
 
 /*Object virtual functions definitions:*/
-void StringArrayParam::Echo(void){/*{{{*/
-	this->DeepEcho();
+Param* StringArrayParam::copy() {/*{{{*/
+
+	return new StringArrayParam(this->enum_type,this->value,this->numstrings);
+
 }
 /*}}}*/
@@ -67,17 +69,9 @@
 }
 /*}}}*/
-int    StringArrayParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int StringArrayParam::ObjectEnum(void){/*{{{*/
-
-	return StringArrayParamEnum;
-
+void StringArrayParam::Echo(void){/*{{{*/
+	this->DeepEcho();
 }
 /*}}}*/
-Param* StringArrayParam::copy() {/*{{{*/
-
-	return new StringArrayParam(this->enum_type,this->value,this->numstrings);
-
-}
+int    StringArrayParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void StringArrayParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -104,4 +98,10 @@
 	//cleanup sizes array
 	if(sizes) xDelete<int>(sizes);
+
+}
+/*}}}*/
+int StringArrayParam::ObjectEnum(void){/*{{{*/
+
+	return StringArrayParamEnum;
 
 }
Index: /issm/trunk-jpl/src/c/classes/Params/StringArrayParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/StringArrayParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/StringArrayParam.h	(revision 20827)
@@ -32,13 +32,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
@@ -56,5 +55,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
@@ -70,5 +71,4 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/StringParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/StringParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/StringParam.cpp	(revision 20827)
@@ -34,6 +34,8 @@
 
 /*Object virtual functions definitions:*/
-void StringParam::Echo(void){/*{{{*/
-	this->DeepEcho();
+Param* StringParam::copy() {/*{{{*/
+
+	return new StringParam(this->enum_type,this->value);
+
 }
 /*}}}*/
@@ -42,17 +44,9 @@
 }
 /*}}}*/
-int    StringParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int StringParam::ObjectEnum(void){/*{{{*/
-
-	return StringParamEnum;
-
+void StringParam::Echo(void){/*{{{*/
+	this->DeepEcho();
 }
 /*}}}*/
-Param* StringParam::copy() {/*{{{*/
-
-	return new StringParam(this->enum_type,this->value);
-
-}
+int    StringParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void StringParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -66,4 +60,10 @@
 	MARSHALLING(size);
 	MARSHALLING_DYNAMIC(value,char,size);
+
+}
+/*}}}*/
+int StringParam::ObjectEnum(void){/*{{{*/
+
+	return StringParamEnum;
 
 }
Index: /issm/trunk-jpl/src/c/classes/Params/StringParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/StringParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/StringParam.h	(revision 20827)
@@ -32,13 +32,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
@@ -56,5 +55,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Bool param of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an integer");}
@@ -70,5 +71,4 @@
 		void  SetValue(FILE* fid){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/TransientParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/TransientParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/TransientParam.cpp	(revision 20827)
@@ -42,9 +42,7 @@
 
 /*Object virtual functions definitions:*/
-void TransientParam::Echo(void){/*{{{*/
+Param* TransientParam::copy() {/*{{{*/
 
-	_printf_("TransientParam:\n");
-	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
-	_printf_("   size: " << this->N << "\n");
+	return new TransientParam(this->enum_type,this->values,this->timesteps,this->interpolation,this->N);
 
 }
@@ -60,17 +58,13 @@
 }
 /*}}}*/
-int  TransientParam::Id(void){ return -1; }/*{{{*/
-/*}}}*/
-int  TransientParam::ObjectEnum(void){/*{{{*/
+void TransientParam::Echo(void){/*{{{*/
 
-	return TransientParamEnum;
+	_printf_("TransientParam:\n");
+	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+	_printf_("   size: " << this->N << "\n");
 
 }
 /*}}}*/
-Param* TransientParam::copy() {/*{{{*/
-
-	return new TransientParam(this->enum_type,this->values,this->timesteps,this->interpolation,this->N);
-
-}
+int  TransientParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
 void TransientParam::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
@@ -87,4 +81,10 @@
 	MARSHALLING_ARRAY(values,IssmDouble,N);
 	MARSHALLING_ARRAY(timesteps,IssmDouble,N);
+
+}
+/*}}}*/
+int  TransientParam::ObjectEnum(void){/*{{{*/
+
+	return TransientParamEnum;
 
 }
Index: /issm/trunk-jpl/src/c/classes/Params/TransientParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/TransientParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/TransientParam.h	(revision 20827)
@@ -34,13 +34,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction);
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return an integer");}
@@ -58,5 +57,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold an integer");}
@@ -72,5 +73,4 @@
 		void  SetValue(FILE* fid){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/Params/VectorParam.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/VectorParam.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/VectorParam.cpp	(revision 20827)
@@ -38,8 +38,7 @@
 
 /*Object virtual functions definitions:*/
-void VectorParam::Echo(void){/*{{{*/
+Param* VectorParam::copy() {/*{{{*/
 
-	_printf_("VectorParam:\n");
-	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+	return new VectorParam(this->enum_type,this->value);
 
 }
@@ -52,4 +51,11 @@
 }
 /*}}}*/
+void VectorParam::Echo(void){/*{{{*/
+
+	_printf_("VectorParam:\n");
+	_printf_("   enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n");
+
+}
+/*}}}*/
 int    VectorParam::Id(void){ return -1; }/*{{{*/
 /*}}}*/
@@ -57,10 +63,4 @@
 
 	return VectorParamEnum;
-
-}
-/*}}}*/
-Param* VectorParam::copy() {/*{{{*/
-
-	return new VectorParam(this->enum_type,this->value);
 
 }
Index: /issm/trunk-jpl/src/c/classes/Params/VectorParam.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Params/VectorParam.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/Params/VectorParam.h	(revision 20827)
@@ -32,13 +32,12 @@
 		/*}}}*/
 		/*Object virtual functions definitions:{{{ */
+		Param* copy();
+		void  DeepEcho();
 		void  Echo();
-		void  DeepEcho();
 		int   Id(); 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 		int   ObjectEnum();
-		Param* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 		/*}}}*/
 		/*Param vritual function definitions: {{{*/
-		int   InstanceEnum(){return enum_type;}
 		void  GetParameterValue(bool* pbool){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a bool");}
 		void  GetParameterValue(int* pinteger){_error_("Param "<< EnumToStringx(enum_type) << " cannot return an integer");}
@@ -56,5 +55,7 @@
 		void  GetParameterValue(FILE** pfid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot return a FILE");}
 		void  GetParameterValue(DataSet** pdataset){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a DataSet");}
+		int   InstanceEnum(){return enum_type;}
 
+		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		void  SetValue(bool boolean){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a boolean");}
 		void  SetValue(int integer){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold an integer");}
@@ -70,5 +71,4 @@
 		void  SetValue(FILE* fid){_error_("Vector of enum " << enum_type << " (" << EnumToStringx(enum_type) << ") cannot hold a FILE");}
 		void  SetValue(IssmDouble** array, int M, int* mdim_array, int* ndim_array){_error_("Param "<< EnumToStringx(enum_type) << " cannot hold an array of matrices");}
-		void  SetEnum(int enum_in){this->enum_type = enum_in;};
 		/*}}}*/
 };
Index: /issm/trunk-jpl/src/c/classes/gauss/Gauss.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/gauss/Gauss.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/gauss/Gauss.h	(revision 20827)
@@ -13,10 +13,10 @@
 		virtual        ~Gauss(){};
 		virtual int  begin(void)=0;
+		virtual void Echo(void)=0;
 		virtual int  end(void)=0;
-		virtual void Echo(void)=0;
 		virtual int  Enum(void)=0;
+		virtual void GaussNode(int finitelement,int iv)=0;
 		virtual void GaussPoint(int ig)=0;
 		virtual void GaussVertex(int iv)=0;
-		virtual void GaussNode(int finitelement,int iv)=0;
 		virtual void SynchronizeGaussBase(Gauss* gauss)=0;
 
Index: /issm/trunk-jpl/src/c/classes/gauss/GaussPenta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/gauss/GaussPenta.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/gauss/GaussPenta.cpp	(revision 20827)
@@ -443,4 +443,18 @@
 
 /*Methods*/
+int GaussPenta::begin(void){/*{{{*/
+
+	/*Check that this has been initialized*/
+	_assert_(numgauss>0);
+	_assert_(weights);
+	_assert_(coords1);
+	_assert_(coords2);
+	_assert_(coords3);
+	_assert_(coords4);
+
+	/*return first gauss index*/
+	return 0;
+}
+/*}}}*/
 void GaussPenta::Echo(void){/*{{{*/
 
@@ -487,6 +501,37 @@
 }
 /*}}}*/
+int GaussPenta::end(void){/*{{{*/
+
+	/*Check that this has been initialized*/
+	_assert_(numgauss>0);
+	_assert_(weights);
+	_assert_(coords1);
+	_assert_(coords2);
+	_assert_(coords3);
+	_assert_(coords4);
+
+	/*return last gauss index +1*/
+	return numgauss;
+}
+/*}}}*/
 int GaussPenta::Enum(void){/*{{{*/
 	return GaussPentaEnum;
+}
+/*}}}*/
+void GaussPenta::GaussFaceTria(int index1, int index2, int index3, int order){/*{{{*/
+
+	/*in debugging mode: check that the default constructor has been called*/
+	_assert_(numgauss==-1);
+
+	/*Basal Tria*/
+	if(index1==0 && index2==1 && index3==2){
+		GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order);
+		coords4=xNew<IssmDouble>(numgauss);
+		for(int i=0;i<numgauss;i++) coords4[i]=-1.0;
+	}
+	else{
+		_error_("Tria not supported yet");
+	}
+
 }
 /*}}}*/
@@ -502,40 +547,4 @@
 	 coord3=coords3[ig];
 	 coord4=coords4[ig];
-
-}
-/*}}}*/
-void GaussPenta::GaussVertex(int iv){/*{{{*/
-
-	/*in debugging mode: check that the default constructor has been called*/
-	_assert_(numgauss==-1);
-
-	/*update static arrays*/
-	switch(iv){
-		case 0: coord1=1.; coord2=0.; coord3=0.; coord4= -1.; break;
-		case 1: coord1=0.; coord2=1.; coord3=0.; coord4= -1.; break;
-		case 2: coord1=0.; coord2=0.; coord3=1.; coord4= -1.; break;
-		case 3: coord1=1.; coord2=0.; coord3=0.; coord4= +1.; break;
-		case 4: coord1=0.; coord2=1.; coord3=0.; coord4= +1.; break;
-		case 5: coord1=0.; coord2=0.; coord3=1.; coord4= +1.; break;
-		default: _error_("vertex index should be in [0 5]");
-
-	}
-
-}
-/*}}}*/
-void GaussPenta::GaussFaceTria(int index1, int index2, int index3, int order){/*{{{*/
-
-	/*in debugging mode: check that the default constructor has been called*/
-	_assert_(numgauss==-1);
-
-	/*Basal Tria*/
-	if(index1==0 && index2==1 && index3==2){
-		GaussLegendreTria(&numgauss,&coords1,&coords2,&coords3,&weights,order);
-		coords4=xNew<IssmDouble>(numgauss);
-		for(int i=0;i<numgauss;i++) coords4[i]=-1.0;
-	}
-	else{
-		_error_("Tria not supported yet");
-	}
 
 }
@@ -720,30 +729,21 @@
 }
 /*}}}*/
-int GaussPenta::begin(void){/*{{{*/
-
-	/*Check that this has been initialized*/
-	_assert_(numgauss>0);
-	_assert_(weights);
-	_assert_(coords1);
-	_assert_(coords2);
-	_assert_(coords3);
-	_assert_(coords4);
-
-	/*return first gauss index*/
-	return 0;
-}
-/*}}}*/
-int GaussPenta::end(void){/*{{{*/
-
-	/*Check that this has been initialized*/
-	_assert_(numgauss>0);
-	_assert_(weights);
-	_assert_(coords1);
-	_assert_(coords2);
-	_assert_(coords3);
-	_assert_(coords4);
-
-	/*return last gauss index +1*/
-	return numgauss;
+void GaussPenta::GaussVertex(int iv){/*{{{*/
+
+	/*in debugging mode: check that the default constructor has been called*/
+	_assert_(numgauss==-1);
+
+	/*update static arrays*/
+	switch(iv){
+		case 0: coord1=1.; coord2=0.; coord3=0.; coord4= -1.; break;
+		case 1: coord1=0.; coord2=1.; coord3=0.; coord4= -1.; break;
+		case 2: coord1=0.; coord2=0.; coord3=1.; coord4= -1.; break;
+		case 3: coord1=1.; coord2=0.; coord3=0.; coord4= +1.; break;
+		case 4: coord1=0.; coord2=1.; coord3=0.; coord4= +1.; break;
+		case 5: coord1=0.; coord2=0.; coord3=1.; coord4= +1.; break;
+		default: _error_("vertex index should be in [0 5]");
+
+	}
+
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/gauss/GaussPenta.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/gauss/GaussPenta.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/gauss/GaussPenta.h	(revision 20827)
@@ -41,11 +41,11 @@
 		/*Methods*/
 		int  begin(void);
+		void Echo(void);
 		int  end(void);
-		void Echo(void);
 		int  Enum(void);
+		void GaussFaceTria(int index1, int index2, int index3, int order);
+		void GaussNode(int finitelement,int iv);
 		void GaussPoint(int ig);
 		void GaussVertex(int iv);
-		void GaussNode(int finitelement,int iv);
-		void GaussFaceTria(int index1, int index2, int index3, int order);
 		void SynchronizeGaussBase(Gauss* gauss);
 };
Index: /issm/trunk-jpl/src/c/classes/gauss/GaussSeg.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/gauss/GaussSeg.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/gauss/GaussSeg.cpp	(revision 20827)
@@ -74,4 +74,15 @@
 
 /*Methods*/
+int GaussSeg::begin(void){/*{{{*/
+
+	/*Check that this has been initialized*/
+	_assert_(numgauss>0);
+	_assert_(weights);
+	_assert_(coords1);
+
+	/*return first gauss index*/
+	return 0;
+}
+/*}}}*/
 void GaussSeg::Echo(void){/*{{{*/
 
@@ -95,4 +106,15 @@
 }
 /*}}}*/
+int GaussSeg::end(void){/*{{{*/
+
+	/*Check that this has been initialized*/
+	_assert_(numgauss>0);
+	_assert_(weights);
+	_assert_(coords1);
+
+	/*return last gauss index +1*/
+	return numgauss;
+}
+/*}}}*/
 int GaussSeg::Enum(void){/*{{{*/
 	return GaussSegEnum;
@@ -107,17 +129,4 @@
 	 weight=weights[ig];
 	 coord1=coords1[ig];
-}
-/*}}}*/
-void GaussSeg::GaussVertex(int iv){/*{{{*/
-
-	/*in debugging mode: check that the default constructor has been called*/
-	_assert_(numgauss==-1);
-
-	/*update static arrays*/
-	switch(iv){
-		case 0: coord1=-1.; break;
-		case 1: coord1=+1.; break;
-		default: _error_("vertex index should be in [0 1]");
-	}
 }
 /*}}}*/
@@ -141,24 +150,15 @@
 }
 /*}}}*/
-int GaussSeg::begin(void){/*{{{*/
+void GaussSeg::GaussVertex(int iv){/*{{{*/
 
-	/*Check that this has been initialized*/
-	_assert_(numgauss>0);
-	_assert_(weights);
-	_assert_(coords1);
+	/*in debugging mode: check that the default constructor has been called*/
+	_assert_(numgauss==-1);
 
-	/*return first gauss index*/
-	return 0;
-}
-/*}}}*/
-int GaussSeg::end(void){/*{{{*/
-
-	/*Check that this has been initialized*/
-	_assert_(numgauss>0);
-	_assert_(weights);
-	_assert_(coords1);
-
-	/*return last gauss index +1*/
-	return numgauss;
+	/*update static arrays*/
+	switch(iv){
+		case 0: coord1=-1.; break;
+		case 1: coord1=+1.; break;
+		default: _error_("vertex index should be in [0 1]");
+	}
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/gauss/GaussSeg.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/gauss/GaussSeg.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/gauss/GaussSeg.h	(revision 20827)
@@ -30,10 +30,10 @@
 		/*Methods*/
 		int  begin(void);
+		void Echo(void);
 		int  end(void);
-		void Echo(void);
 		int  Enum(void);
 		void GaussPoint(int ig);
+		void GaussNode(int finitelement,int iv);
 		void GaussVertex(int iv);
-		void GaussNode(int finitelement,int iv);
 		void SynchronizeGaussBase(Gauss* gauss);
 };
Index: /issm/trunk-jpl/src/c/classes/gauss/GaussTetra.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/gauss/GaussTetra.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/gauss/GaussTetra.cpp	(revision 20827)
@@ -94,4 +94,18 @@
 
 /*Methods*/
+int GaussTetra::begin(void){/*{{{*/
+
+	/*Check that this has been initialized*/
+	_assert_(numgauss>0);
+	_assert_(weights);
+	_assert_(coords1);
+	_assert_(coords2);
+	_assert_(coords3);
+	_assert_(coords4);
+
+	/*return first gauss index*/
+	return 0;
+}
+/*}}}*/
 void GaussTetra::Echo(void){/*{{{*/
 
@@ -136,4 +150,18 @@
 	_printf_("   coord4 = " << coord4 << "\n");
 
+}
+/*}}}*/
+int GaussTetra::end(void){/*{{{*/
+
+	/*Check that this has been initialized*/
+	_assert_(numgauss>0);
+	_assert_(weights);
+	_assert_(coords1);
+	_assert_(coords2);
+	_assert_(coords3);
+	_assert_(coords4);
+
+	/*return last gauss index +1*/
+	return numgauss;
 }
 /*}}}*/
@@ -153,21 +181,4 @@
 	 coord3=coords3[ig];
 	 coord4=coords4[ig];
-
-}
-/*}}}*/
-void GaussTetra::GaussVertex(int iv){/*{{{*/
-
-	/*in debugging mode: check that the default constructor has been called*/
-	_assert_(numgauss==-1);
-
-	/*update static arrays*/
-	switch(iv){
-		case 0: coord1=1.; coord2=0.; coord3=0.; coord4=0.; break;
-		case 1: coord1=0.; coord2=1.; coord3=0.; coord4=0.; break;
-		case 2: coord1=0.; coord2=0.; coord3=1.; coord4=0.; break;
-		case 3: coord1=0.; coord2=0.; coord3=0.; coord4=1.; break;
-		default: _error_("vertex index should be in [0 3]");
-
-	}
 
 }
@@ -220,30 +231,19 @@
 }
 /*}}}*/
-int GaussTetra::begin(void){/*{{{*/
-
-	/*Check that this has been initialized*/
-	_assert_(numgauss>0);
-	_assert_(weights);
-	_assert_(coords1);
-	_assert_(coords2);
-	_assert_(coords3);
-	_assert_(coords4);
-
-	/*return first gauss index*/
-	return 0;
-}
-/*}}}*/
-int GaussTetra::end(void){/*{{{*/
-
-	/*Check that this has been initialized*/
-	_assert_(numgauss>0);
-	_assert_(weights);
-	_assert_(coords1);
-	_assert_(coords2);
-	_assert_(coords3);
-	_assert_(coords4);
-
-	/*return last gauss index +1*/
-	return numgauss;
+void GaussTetra::GaussVertex(int iv){/*{{{*/
+
+	/*in debugging mode: check that the default constructor has been called*/
+	_assert_(numgauss==-1);
+
+	/*update static arrays*/
+	switch(iv){
+		case 0: coord1=1.; coord2=0.; coord3=0.; coord4=0.; break;
+		case 1: coord1=0.; coord2=1.; coord3=0.; coord4=0.; break;
+		case 2: coord1=0.; coord2=0.; coord3=1.; coord4=0.; break;
+		case 3: coord1=0.; coord2=0.; coord3=0.; coord4=1.; break;
+		default: _error_("vertex index should be in [0 3]");
+
+	}
+
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/gauss/GaussTetra.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/gauss/GaussTetra.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/gauss/GaussTetra.h	(revision 20827)
@@ -36,10 +36,10 @@
 		/*Methods*/
 		int  begin(void);
+		void Echo(void);
 		int  end(void);
-		void Echo(void);
 		int  Enum(void);
 		void GaussPoint(int ig);
+		void GaussNode(int finitelement,int iv);
 		void GaussVertex(int iv);
-		void GaussNode(int finitelement,int iv);
 		void SynchronizeGaussBase(Gauss* gauss);
 };
Index: /issm/trunk-jpl/src/c/classes/gauss/GaussTria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/gauss/GaussTria.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/gauss/GaussTria.cpp	(revision 20827)
@@ -297,4 +297,17 @@
 
 /*Methods*/
+int GaussTria::begin(void){/*{{{*/
+
+	/*Check that this has been initialized*/
+	_assert_(numgauss>0);
+	_assert_(weights);
+	_assert_(coords1);
+	_assert_(coords2);
+	_assert_(coords3);
+
+	/*return first gauss index*/
+	return 0;
+}
+/*}}}*/
 void GaussTria::Echo(void){/*{{{*/
 
@@ -334,4 +347,17 @@
 }
 /*}}}*/
+int GaussTria::end(void){/*{{{*/
+
+	/*Check that this has been initialized*/
+	_assert_(numgauss>0);
+	_assert_(weights);
+	_assert_(coords1);
+	_assert_(coords2);
+	_assert_(coords3);
+
+	/*return last gauss index +1*/
+	return numgauss;
+}
+/*}}}*/
 int GaussTria::Enum(void){/*{{{*/
 	return GaussTriaEnum;
@@ -368,4 +394,30 @@
 }
 /*}}}*/
+void GaussTria::GaussFromCoords(IssmDouble x,IssmDouble y,IssmDouble* xyz_list){/*{{{*/
+
+	/*Intermediaries*/
+	IssmDouble    area = 0;
+	IssmDouble    x1,y1,x2,y2,x3,y3;
+
+	/*in debugging mode: check that the default constructor has been called*/
+	_assert_(numgauss==-1);
+
+	x1=*(xyz_list+3*0+0); y1=*(xyz_list+3*0+1);
+	x2=*(xyz_list+3*1+0); y2=*(xyz_list+3*1+1);
+	x3=*(xyz_list+3*2+0); y3=*(xyz_list+3*2+1);
+
+	area=(x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1)/2;
+
+	/*Get first area coordinate = det(x-x3  x2-x3 ; y-y3   y2-y3)/area*/
+	coord1=((x-x3)*(y2-y3)-(x2-x3)*(y-y3))/area;
+
+	/*Get second area coordinate = det(x1-x3  x-x3 ; y1-y3   y-y3)/area*/
+	coord2=((x1-x3)*(y-y3)-(x-x3)*(y1-y3))/area;
+
+	/*Get third  area coordinate 1-area1-area2: */
+	coord3=1-coord1-coord2;
+
+}
+/*}}}*/
 void GaussTria::GaussPoint(int ig){/*{{{*/
 
@@ -378,45 +430,4 @@
 	 coord2=coords2[ig];
 	 coord3=coords3[ig];
-
-}
-/*}}}*/
-void GaussTria::GaussFromCoords(IssmDouble x,IssmDouble y,IssmDouble* xyz_list){/*{{{*/
-
-	/*Intermediaries*/
-	IssmDouble    area = 0;
-	IssmDouble    x1,y1,x2,y2,x3,y3;
-
-	/*in debugging mode: check that the default constructor has been called*/
-	_assert_(numgauss==-1);
-
-	x1=*(xyz_list+3*0+0); y1=*(xyz_list+3*0+1);
-	x2=*(xyz_list+3*1+0); y2=*(xyz_list+3*1+1);
-	x3=*(xyz_list+3*2+0); y3=*(xyz_list+3*2+1);
-
-	area=(x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1)/2;
-
-	/*Get first area coordinate = det(x-x3  x2-x3 ; y-y3   y2-y3)/area*/
-	coord1=((x-x3)*(y2-y3)-(x2-x3)*(y-y3))/area;
-
-	/*Get second area coordinate = det(x1-x3  x-x3 ; y1-y3   y-y3)/area*/
-	coord2=((x1-x3)*(y-y3)-(x-x3)*(y1-y3))/area;
-
-	/*Get third  area coordinate 1-area1-area2: */
-	coord3=1-coord1-coord2;
-
-}
-/*}}}*/
-void GaussTria::GaussVertex(int iv){/*{{{*/
-
-	/*in debugging mode: check that the default constructor has been called*/
-	_assert_(numgauss==-1);
-
-	/*update static arrays*/
-	switch(iv){
-		case 0: coord1=1.; coord2=0.; coord3=0.; break;
-		case 1: coord1=0.; coord2=1.; coord3=0.; break;
-		case 2: coord1=0.; coord2=0.; coord3=1.; break;
-		default: _error_("vertex index should be in [0 2]");
-	}
 
 }
@@ -480,28 +491,17 @@
 }
 /*}}}*/
-int GaussTria::begin(void){/*{{{*/
-
-	/*Check that this has been initialized*/
-	_assert_(numgauss>0);
-	_assert_(weights);
-	_assert_(coords1);
-	_assert_(coords2);
-	_assert_(coords3);
-
-	/*return first gauss index*/
-	return 0;
-}
-/*}}}*/
-int GaussTria::end(void){/*{{{*/
-
-	/*Check that this has been initialized*/
-	_assert_(numgauss>0);
-	_assert_(weights);
-	_assert_(coords1);
-	_assert_(coords2);
-	_assert_(coords3);
-
-	/*return last gauss index +1*/
-	return numgauss;
+void GaussTria::GaussVertex(int iv){/*{{{*/
+
+	/*in debugging mode: check that the default constructor has been called*/
+	_assert_(numgauss==-1);
+
+	/*update static arrays*/
+	switch(iv){
+		case 0: coord1=1.; coord2=0.; coord3=0.; break;
+		case 1: coord1=0.; coord2=1.; coord3=0.; break;
+		case 2: coord1=0.; coord2=0.; coord3=1.; break;
+		default: _error_("vertex index should be in [0 2]");
+	}
+
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/gauss/GaussTria.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/gauss/GaussTria.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/gauss/GaussTria.h	(revision 20827)
@@ -36,12 +36,12 @@
 		/*Methods*/
 		int  begin(void);
+		void Echo(void);
 		int  end(void);
-		void Echo(void);
 		int  Enum(void);
+		void GaussEdgeCenter(int index1,int index2);
 		void GaussFromCoords(IssmDouble x1,IssmDouble y1,IssmDouble* xyz_list);
 		void GaussPoint(int ig);
+		void GaussNode(int finitelement,int iv);
 		void GaussVertex(int iv);
-		void GaussNode(int finitelement,int iv);
-		void GaussEdgeCenter(int index1,int index2);
 		void SynchronizeGaussBase(Gauss* gauss);
 };
Index: /issm/trunk-jpl/src/c/classes/kriging/Covertree.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/Covertree.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/Covertree.cpp	(revision 20827)
@@ -31,4 +31,79 @@
 
 	/*Methods*/
+std::pair<double, Covertree::CoverTreeNode*>		Covertree::distance(const Observation& p, const std::vector<CoverTreeNode*>& Q){/*{{{*/
+	double minDist = 1.e+50;
+	CoverTreeNode* minNode;
+	std::vector<CoverTreeNode*>::const_iterator it;
+	for(it=Q.begin();it!=Q.end();++it) {
+		double dist = p.distance((*it)->getObservation());
+		if(dist < minDist) {
+			minDist = dist;
+			minNode = *it;
+		}
+	}
+	return std::make_pair(minDist,minNode);  
+}/*}}}*/
+int Covertree::get_numberofobs(){/*{{{*/
+	return _numNodes;
+}/*}}}*/
+void   Covertree::insert(const Observation& newObservation){/*{{{*/
+	if(_root==NULL) {
+		_root = new CoverTreeNode(newObservation);
+		_numNodes=1;
+		return;
+	}
+	//TODO: this is pretty inefficient, there may be a better way
+	//to check if the node already exists...
+	CoverTreeNode* n = kNearestNodes(newObservation,1)[0];
+	if(newObservation.distance(n->getObservation())==0.0) {
+		n->addObservation(newObservation);
+	} else {
+		//insert_rec acts under the assumption that there are no nodes with
+		//distance 0 to newObservation in the cover tree (the previous lines check it)
+		insert_rec(newObservation,
+					std::vector<distNodePair>
+					(1,std::make_pair(_root->distance(newObservation),_root)),
+					_maxLevel);
+	}
+}/*}}}*/
+bool		Covertree::insert_rec(const Observation& p, const std::vector<distNodePair>& Qi, const int& level){/*{{{*/
+	std::vector<std::pair<double, CoverTreeNode*> > Qj;
+	double sep = pow(base,level);
+	double minDist = 1.e+50;
+	std::pair<double,CoverTreeNode*> minQiDist(1.e+50,NULL);
+	std::vector<std::pair<double, CoverTreeNode*> >::const_iterator it;
+	for(it=Qi.begin(); it!=Qi.end(); ++it) {
+		if(it->first<minQiDist.first) minQiDist = *it;
+		if(it->first<minDist) minDist=it->first;
+		if(it->first<=sep) Qj.push_back(*it);
+		std::vector<CoverTreeNode*> children = it->second->getChildren(level);
+		std::vector<CoverTreeNode*>::const_iterator it2;
+		for(it2=children.begin();it2!=children.end();++it2) {
+			double d = p.distance((*it2)->getObservation());
+			if(d<minDist) minDist = d;
+			if(d<=sep) {
+				Qj.push_back(std::make_pair(d,*it2));
+			}
+		}
+	}
+	//std::cout << "level: " << level << ", sep: " << sep << ", dist: " << minQDist.first << "\n";
+	if(minDist > sep) {
+		return true;
+	} else {
+		bool found = insert_rec(p,Qj,level-1);
+		//distNodePair minQiDist = distance(p,Qi);
+		if(found && minQiDist.first <= sep) {
+			if(level-1<_minLevel) _minLevel=level-1;
+			minQiDist.second->addChild(level,
+						new CoverTreeNode(p));
+			//std::cout << "parent is ";
+			//minQiDist.second->getObservation().print();
+			_numNodes++;
+			return false;
+		} else {
+			return found;
+		}
+	}
+}/*}}}*/
 std::vector<Covertree::CoverTreeNode*> Covertree::kNearestNodes(const Observation& p, const unsigned int& k) const{/*{{{*/
 	if(_root==NULL) return std::vector<CoverTreeNode*>();
@@ -78,41 +153,79 @@
 	return kNN;
 }/*}}}*/
-bool   Covertree::insert_rec(const Observation& p, const std::vector<distNodePair>& Qi, const int& level){/*{{{*/
-	std::vector<std::pair<double, CoverTreeNode*> > Qj;
-	double sep = pow(base,level);
-	double minDist = 1.e+50;
-	std::pair<double,CoverTreeNode*> minQiDist(1.e+50,NULL);
-	std::vector<std::pair<double, CoverTreeNode*> >::const_iterator it;
-	for(it=Qi.begin(); it!=Qi.end(); ++it) {
-		if(it->first<minQiDist.first) minQiDist = *it;
-		if(it->first<minDist) minDist=it->first;
-		if(it->first<=sep) Qj.push_back(*it);
-		std::vector<CoverTreeNode*> children = it->second->getChildren(level);
-		std::vector<CoverTreeNode*>::const_iterator it2;
-		for(it2=children.begin();it2!=children.end();++it2) {
-			double d = p.distance((*it2)->getObservation());
-			if(d<minDist) minDist = d;
-			if(d<=sep) {
-				Qj.push_back(std::make_pair(d,*it2));
-			}
-		}
-	}
-	//std::cout << "level: " << level << ", sep: " << sep << ", dist: " << minQDist.first << "\n";
-	if(minDist > sep) {
-		return true;
-	} else {
-		bool found = insert_rec(p,Qj,level-1);
-		//distNodePair minQiDist = distance(p,Qi);
-		if(found && minQiDist.first <= sep) {
-			if(level-1<_minLevel) _minLevel=level-1;
-			minQiDist.second->addChild(level,
-						new CoverTreeNode(p));
-			//std::cout << "parent is ";
-			//minQiDist.second->getObservation().print();
-			_numNodes++;
-			return false;
+std::vector<Observation> Covertree::kNearestNeighbors(const Observation& p, const unsigned int& k) const{/*{{{*/
+	if(_root==NULL) return std::vector<Observation>();
+	std::vector<CoverTreeNode*> v = kNearestNodes(p, k);
+	std::vector<Observation> kNN;
+	std::vector<CoverTreeNode*>::const_iterator it;
+	for(it=v.begin();it!=v.end();++it) {
+		const std::vector<Observation>& p = (*it)->getObservations();
+		kNN.insert(kNN.end(),p.begin(),p.end());
+		if(kNN.size() >= k) break;
+	}
+	return kNN;
+}/*}}}*/
+void   Covertree::print() const{/*{{{*/
+	int d = _maxLevel-_minLevel+1;
+	std::vector<CoverTreeNode*> Q;
+	Q.push_back(_root);
+	for(int i=0;i<d;i++) {
+		std::cout << "LEVEL " << _maxLevel-i << "\n";
+		std::vector<CoverTreeNode*>::const_iterator it;
+		for(it=Q.begin();it!=Q.end();++it) {
+			(*it)->getObservation().print();
+			std::vector<CoverTreeNode*>
+			  children = (*it)->getChildren(_maxLevel-i);
+			std::vector<CoverTreeNode*>::const_iterator it2;
+			for(it2=children.begin();it2!=children.end();++it2) {
+				std::cout << "  ";
+				(*it2)->getObservation().print();
+			}
+		}
+		std::vector<CoverTreeNode*> newQ;
+		for(it=Q.begin();it!=Q.end();++it) {
+			std::vector<CoverTreeNode*>
+			  children = (*it)->getChildren(_maxLevel-i);
+			newQ.insert(newQ.end(),children.begin(),children.end());
+		}
+		Q.insert(Q.end(),newQ.begin(),newQ.end());
+		std::cout << "\n\n";
+	}
+}/*}}}*/
+void   Covertree::remove(const Observation& p){/*{{{*/
+	//Most of this function's code is for the special case of removing the root
+	if(_root==NULL) return;
+	bool removingRoot=_root->hasObservation(p);
+	if(removingRoot && !_root->isSingle()) {
+		_root->removeObservation(p);
+		return;
+	}
+	CoverTreeNode* newRoot=NULL;
+	if(removingRoot) {
+		if(_numNodes==1) {
+			//removing the last node...
+			delete _root;
+			_numNodes--;
+			_root=NULL;
+			return;
 		} else {
-			return found;
-		}
+			for(int i=_maxLevel;i>_minLevel;i--) {
+				if(!(_root->getChildren(i).empty())) {
+					newRoot = _root->getChildren(i).back();
+					_root->removeChild(i,newRoot);
+					break;
+				}
+			}
+		}
+	}
+	std::map<int, std::vector<distNodePair> > coverSets;
+	coverSets[_maxLevel].push_back(std::make_pair(_root->distance(p),_root));
+	if(removingRoot)
+	 coverSets[_maxLevel].push_back(std::make_pair(newRoot->distance(p),newRoot));
+	bool multi = false;
+	remove_rec(p,coverSets,_maxLevel,multi);
+	if(removingRoot) {
+		delete _root;
+		_numNodes--;
+		_root=newRoot;
 	}
 }/*}}}*/
@@ -219,123 +332,25 @@
 	}
 }/*}}}*/
-int Covertree::get_numberofobs(){/*{{{*/
-	return _numNodes;
-}/*}}}*/
-std::pair<double, Covertree::CoverTreeNode*> Covertree::distance(const Observation& p, const std::vector<CoverTreeNode*>& Q){/*{{{*/
-	double minDist = 1.e+50;
-	CoverTreeNode* minNode;
-	std::vector<CoverTreeNode*>::const_iterator it;
-	for(it=Q.begin();it!=Q.end();++it) {
-		double dist = p.distance((*it)->getObservation());
-		if(dist < minDist) {
-			minDist = dist;
-			minNode = *it;
-		}
-	}
-	return std::make_pair(minDist,minNode);  
-}/*}}}*/
-void   Covertree::insert(const Observation& newObservation){/*{{{*/
-	if(_root==NULL) {
-		_root = new CoverTreeNode(newObservation);
-		_numNodes=1;
-		return;
-	}
-	//TODO: this is pretty inefficient, there may be a better way
-	//to check if the node already exists...
-	CoverTreeNode* n = kNearestNodes(newObservation,1)[0];
-	if(newObservation.distance(n->getObservation())==0.0) {
-		n->addObservation(newObservation);
-	} else {
-		//insert_rec acts under the assumption that there are no nodes with
-		//distance 0 to newObservation in the cover tree (the previous lines check it)
-		insert_rec(newObservation,
-					std::vector<distNodePair>
-					(1,std::make_pair(_root->distance(newObservation),_root)),
-					_maxLevel);
-	}
-}/*}}}*/
-void   Covertree::remove(const Observation& p){/*{{{*/
-	//Most of this function's code is for the special case of removing the root
-	if(_root==NULL) return;
-	bool removingRoot=_root->hasObservation(p);
-	if(removingRoot && !_root->isSingle()) {
-		_root->removeObservation(p);
-		return;
-	}
-	CoverTreeNode* newRoot=NULL;
-	if(removingRoot) {
-		if(_numNodes==1) {
-			//removing the last node...
-			delete _root;
-			_numNodes--;
-			_root=NULL;
-			return;
-		} else {
-			for(int i=_maxLevel;i>_minLevel;i--) {
-				if(!(_root->getChildren(i).empty())) {
-					newRoot = _root->getChildren(i).back();
-					_root->removeChild(i,newRoot);
-					break;
-				}
-			}
-		}
-	}
-	std::map<int, std::vector<distNodePair> > coverSets;
-	coverSets[_maxLevel].push_back(std::make_pair(_root->distance(p),_root));
-	if(removingRoot)
-	 coverSets[_maxLevel].push_back(std::make_pair(newRoot->distance(p),newRoot));
-	bool multi = false;
-	remove_rec(p,coverSets,_maxLevel,multi);
-	if(removingRoot) {
-		delete _root;
-		_numNodes--;
-		_root=newRoot;
-	}
-}/*}}}*/
-std::vector<Observation> Covertree::kNearestNeighbors(const Observation& p, const unsigned int& k) const{/*{{{*/
-	if(_root==NULL) return std::vector<Observation>();
-	std::vector<CoverTreeNode*> v = kNearestNodes(p, k);
-	std::vector<Observation> kNN;
-	std::vector<CoverTreeNode*>::const_iterator it;
-	for(it=v.begin();it!=v.end();++it) {
-		const std::vector<Observation>& p = (*it)->getObservations();
-		kNN.insert(kNN.end(),p.begin(),p.end());
-		if(kNN.size() >= k) break;
-	}
-	return kNN;
-}/*}}}*/
-void   Covertree::print() const{/*{{{*/
-	int d = _maxLevel-_minLevel+1;
-	std::vector<CoverTreeNode*> Q;
-	Q.push_back(_root);
-	for(int i=0;i<d;i++) {
-		std::cout << "LEVEL " << _maxLevel-i << "\n";
-		std::vector<CoverTreeNode*>::const_iterator it;
-		for(it=Q.begin();it!=Q.end();++it) {
-			(*it)->getObservation().print();
-			std::vector<CoverTreeNode*>
-			  children = (*it)->getChildren(_maxLevel-i);
-			std::vector<CoverTreeNode*>::const_iterator it2;
-			for(it2=children.begin();it2!=children.end();++it2) {
-				std::cout << "  ";
-				(*it2)->getObservation().print();
-			}
-		}
-		std::vector<CoverTreeNode*> newQ;
-		for(it=Q.begin();it!=Q.end();++it) {
-			std::vector<CoverTreeNode*>
-			  children = (*it)->getChildren(_maxLevel-i);
-			newQ.insert(newQ.end(),children.begin(),children.end());
-		}
-		Q.insert(Q.end(),newQ.begin(),newQ.end());
-		std::cout << "\n\n";
-	}
-}/*}}}*/
 
-Covertree::CoverTreeNode* Covertree::getRoot() const{/*{{{*/
-	return _root;
+void   Covertree::CoverTreeNode::addChild(int level, CoverTreeNode* p){/*{{{*/
+	_childMap[level].push_back(p);
+}/*}}}*/
+void   Covertree::CoverTreeNode::addObservation(const Observation& p){/*{{{*/
+	if(find(_observations.begin(), _observations.end(), p) == _observations.end())
+	 _observations.push_back(p);
 }/*}}}*/
 Covertree::CoverTreeNode::CoverTreeNode(const Observation& p) {/*{{{*/
 	_observations.push_back(p);
+}/*}}}*/
+double Covertree::CoverTreeNode::distance(const CoverTreeNode& p) const{/*{{{*/
+	return _observations[0].distance(p.getObservation());
+}/*}}}*/
+std::vector<Covertree::CoverTreeNode*> Covertree::CoverTreeNode::getAllChildren() const{/*{{{*/
+	std::vector<CoverTreeNode*> children;
+	std::map<int,std::vector<CoverTreeNode*> >::const_iterator it;
+	for(it=_childMap.begin();it!=_childMap.end();++it) {
+		children.insert(children.end(), it->second.begin(), it->second.end());
+	}
+	return children;
 }/*}}}*/
 std::vector<Covertree::CoverTreeNode*> Covertree::CoverTreeNode::getChildren(int level) const{/*{{{*/
@@ -347,46 +362,15 @@
 	return std::vector<CoverTreeNode*>();
 }/*}}}*/
-void   Covertree::CoverTreeNode::addChild(int level, CoverTreeNode* p){/*{{{*/
-	_childMap[level].push_back(p);
-}/*}}}*/
-void   Covertree::CoverTreeNode::removeChild(int level, CoverTreeNode* p){/*{{{*/
-	std::vector<CoverTreeNode*>& v = _childMap[level];
-	for(unsigned int i=0;i<v.size();i++) {
-		if(v[i]==p) {
-			v[i]=v.back();
-			v.pop_back();
-			break;
-		}
-	}
-}/*}}}*/
-void   Covertree::CoverTreeNode::addObservation(const Observation& p){/*{{{*/
-	if(find(_observations.begin(), _observations.end(), p) == _observations.end())
-	 _observations.push_back(p);
-}/*}}}*/
-void   Covertree::CoverTreeNode::removeObservation(const Observation& p){/*{{{*/
-	std::vector<Observation>::iterator it =
-	  find(_observations.begin(), _observations.end(), p);
-	if(it != _observations.end())
-	 _observations.erase(it);
-}/*}}}*/
-double Covertree::CoverTreeNode::distance(const CoverTreeNode& p) const{/*{{{*/
-	return _observations[0].distance(p.getObservation());
+const Observation& Covertree::CoverTreeNode::getObservation() const{/*{{{*/
+	return _observations[0]; 
+}/*}}}*/
+Covertree::CoverTreeNode* Covertree::getRoot() const{/*{{{*/
+	return _root;
+}/*}}}*/
+bool   Covertree::CoverTreeNode::hasObservation(const Observation& p) const{/*{{{*/
+	return find(_observations.begin(), _observations.end(), p) != _observations.end();
 }/*}}}*/
 bool   Covertree::CoverTreeNode::isSingle() const{/*{{{*/
 	return _observations.size() == 1;
-}/*}}}*/
-bool   Covertree::CoverTreeNode::hasObservation(const Observation& p) const{/*{{{*/
-	return find(_observations.begin(), _observations.end(), p) != _observations.end();
-}/*}}}*/
-const Observation& Covertree::CoverTreeNode::getObservation() const{/*{{{*/
-	return _observations[0]; 
-}/*}}}*/
-std::vector<Covertree::CoverTreeNode*> Covertree::CoverTreeNode::getAllChildren() const{/*{{{*/
-	std::vector<CoverTreeNode*> children;
-	std::map<int,std::vector<CoverTreeNode*> >::const_iterator it;
-	for(it=_childMap.begin();it!=_childMap.end();++it) {
-		children.insert(children.end(), it->second.begin(), it->second.end());
-	}
-	return children;
 }/*}}}*/
 bool   Covertree::isValidTree() const {/*{{{*/
@@ -429,2 +413,18 @@
 	return true;
 }/*}}}*/
+void   Covertree::CoverTreeNode::removeChild(int level, CoverTreeNode* p){/*{{{*/
+	std::vector<CoverTreeNode*>& v = _childMap[level];
+	for(unsigned int i=0;i<v.size();i++) {
+		if(v[i]==p) {
+			v[i]=v.back();
+			v.pop_back();
+			break;
+		}
+	}
+}/*}}}*/
+void   Covertree::CoverTreeNode::removeObservation(const Observation& p){/*{{{*/
+	std::vector<Observation>::iterator it =
+	  find(_observations.begin(), _observations.end(), p);
+	if(it != _observations.end())
+	 _observations.erase(it);
+}/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/kriging/Covertree.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/Covertree.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/Covertree.h	(revision 20827)
@@ -25,14 +25,14 @@
 			 * has itself as a child in a cover tree.
 			 */
-			std::vector<CoverTreeNode*> getChildren(int level) const;
 			void addChild(int level, CoverTreeNode* p);
-			void removeChild(int level, CoverTreeNode* p);
 			void addObservation(const Observation& o);
-			void removeObservation(const Observation& o);
-			const std::vector<Observation>& getObservations() { return _observations; }
 			double distance(const CoverTreeNode& p) const;
 			bool   isSingle() const;
 			bool   hasObservation(const Observation& o) const;
+			std::vector<CoverTreeNode*> getChildren(int level) const;
 			const Observation& getObservation() const;
+			const std::vector<Observation>& getObservations() { return _observations; }
+			void removeChild(int level, CoverTreeNode* p);
+			void removeObservation(const Observation& o);
 
 			/**
@@ -51,5 +51,7 @@
 	int            _minLevel;   //A level beneath which there are no more new nodes.
 
-	std::vector<CoverTreeNode*> kNearestNodes(const Observation& o, const unsigned int& k) const;
+	/* Finds the node in Q with the minimum distance to p. Returns a pair
+	 * consisting of this node and the distance.  */
+	distNodePair distance(const Observation& p,const std::vector<CoverTreeNode*>& Q);
 	/**
 	 * Recursive implementation of the insert algorithm (see paper).
@@ -57,9 +59,5 @@
 	bool insert_rec(const Observation& p, const std::vector<distNodePair>& Qi,const int& level);
 
-	/* Finds the node in Q with the minimum distance to p. Returns a pair
-	 * consisting of this node and the distance.  */
-	distNodePair distance(const Observation& p,const std::vector<CoverTreeNode*>& Q);
-
-
+	std::vector<CoverTreeNode*> kNearestNodes(const Observation& o, const unsigned int& k) const;
 	void remove_rec(const Observation& p, std::map<int,std::vector<distNodePair> >& coverSets, int level, bool& multi);
 
@@ -80,4 +78,13 @@
 
 	/**
+	 * Insert newPoint into the cover tree. If newPoint is already present,
+	 * (that is, newPoint==p for some p already in the tree), then the tree
+	 * is unchanged. If p.distance(newPoint)==0.0 but newPoint!=p, then
+	 * newPoint WILL be inserted and both points may be returned in k-nearest-
+	 * neighbor searches.
+	 */
+	void insert(const Observation& newObservation);
+
+	/**
 	 * Just for testing/debugging. Returns true iff the cover tree satisfies the
 	 * the covering tree invariants (every node in level i is greater than base^i
@@ -88,12 +95,4 @@
 	bool isValidTree() const;
 
-	/**
-	 * Insert newPoint into the cover tree. If newPoint is already present,
-	 * (that is, newPoint==p for some p already in the tree), then the tree
-	 * is unchanged. If p.distance(newPoint)==0.0 but newPoint!=p, then
-	 * newPoint WILL be inserted and both points may be returned in k-nearest-
-	 * neighbor searches.
-	 */
-	void insert(const Observation& newObservation);
 
 	/**
Index: /issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.cpp	(revision 20827)
@@ -42,4 +42,8 @@
 
 /*Object virtual functions definitions:*/
+Object* ExponentialVariogram::copy(void){/*{{{*/
+	   return new ExponentialVariogram(*this);
+}
+/*}}}*/
 void ExponentialVariogram::Echo(void){/*{{{*/
 	_printf_("ExponentialVariogram\n");
@@ -47,8 +51,4 @@
 	_printf_("   sill  : " << this->sill << "\n");
 	_printf_("   range : " << this->range << "\n");
-}
-/*}}}*/
-Object* ExponentialVariogram::copy(void){/*{{{*/
-	   return new ExponentialVariogram(*this);
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.h	(revision 20827)
@@ -22,15 +22,15 @@
 
 		/*Object virtual functions definitions*/
+		Object* copy();
+		void  DeepEcho(){_error_("Not implemented yet");};
 		void  Echo();
-		void  DeepEcho(){_error_("Not implemented yet");};
 		int   Id(){_error_("Not implemented yet");}; 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 		int   ObjectEnum(){_error_("Not implemented yet");};
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 
 
 		/*Variogram functions*/
+		double Covariance(double deltax,double deltay);
 		double SemiVariogram(double deltax,double deltay);
-		double Covariance(double deltax,double deltay);
 };
 #endif  /* _EXPONENTIALVARIOGRAM_H */
Index: /issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.cpp	(revision 20827)
@@ -42,4 +42,8 @@
 
 /*Object virtual functions definitions:*/
+Object* GaussianVariogram::copy(void){/*{{{*/
+	   return new GaussianVariogram(*this);
+}
+/*}}}*/
 void GaussianVariogram::Echo(void){/*{{{*/
 	_printf_("GaussianVariogram\n");
@@ -47,8 +51,4 @@
 	_printf_("   sill  : " << this->sill << "\n");
 	_printf_("   range : " << this->range << "\n");
-}
-/*}}}*/
-Object* GaussianVariogram::copy(void){/*{{{*/
-	   return new GaussianVariogram(*this);
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.h	(revision 20827)
@@ -23,14 +23,14 @@
 
 		/*Object virtual functions definitions*/
+		Object* copy();
+		void  DeepEcho(){_error_("Not implemented yet");};
 		void  Echo();
-		void  DeepEcho(){_error_("Not implemented yet");};
 		int   Id(){_error_("Not implemented yet");}; 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 		int   ObjectEnum(){_error_("Not implemented yet");};
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 
 		/*Variogram functions*/
+		double Covariance(double deltax,double deltay);
 		double SemiVariogram(double deltax,double deltay);
-		double Covariance(double deltax,double deltay);
 };
 #endif  /* _GAUSSIANVARIOGRAM_H */
Index: /issm/trunk-jpl/src/c/classes/kriging/Observation.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/Observation.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/Observation.cpp	(revision 20827)
@@ -41,4 +41,14 @@
 
 /*Object virtual functions definitions:*/
+Object* Observation::copy(void){/*{{{*/
+
+	Observation* observation = new Observation(this->x,this->y,this->xi,this->yi,this->index,this->value);
+
+	observation->weight = this->weight;
+
+	return (Object*) observation;
+
+}
+/*}}}*/
 void Observation::Echo(void){/*{{{*/
 
@@ -53,14 +63,4 @@
 }
 /*}}}*/
-Object* Observation::copy(void){/*{{{*/
-
-	Observation* observation = new Observation(this->x,this->y,this->xi,this->yi,this->index,this->value);
-
-	observation->weight = this->weight;
-
-	return (Object*) observation;
-
-}
-/*}}}*/
 
 /*Observations functions*/
@@ -73,4 +73,11 @@
 
 /*Covertree*/
+bool Observation::operator==(const Observation& ob) const{/*{{{*/
+	return (ob.x == this->x && ob.y == this->y && ob.value == this->value);
+}/*}}}*/
+double Observation::distance(const Observation& ob) const{/*{{{*/
+	return std::sqrt( (std::pow( (ob.x - this->x), 2 ) + std::pow((ob.y - this->y), 2) ));
+}
+/*}}}*/
 void Observation::print(void) const{/*{{{*/
 
@@ -81,17 +88,7 @@
 }
 /*}}}*/
-double Observation::distance(const Observation& ob) const
-{
-	return std::sqrt( (std::pow( (ob.x - this->x), 2 ) + std::pow((ob.y - this->y), 2) ));
-}
-
-bool Observation::operator==(const Observation& ob) const
-{
-	return (ob.x == this->x && ob.y == this->y && ob.value == this->value);
-}
-
-void Observation::WriteXYObs(const Observation& ob, double* px, double* py, double* pobs){
+void Observation::WriteXYObs(const Observation& ob, double* px, double* py, double* pobs){/*{{{*/
     *px   = ob.x;
     *py   = ob.y;
     *pobs = ob.value;
-}
+}/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/kriging/Observation.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/Observation.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/Observation.h	(revision 20827)
@@ -24,15 +24,13 @@
 
 		/*Object virtual functions definitions*/
-		double  distance(const Observation& ob) const;
-
-		void    Echo();
-		void    print() const;
-		void    DeepEcho()  {_error_("Not implemented yet"); };
-		int     Id()        {_error_("Not implemented yet"); };
-		int     ObjectEnum(){_error_("Not implemented yet"); };
 		bool operator==(const Observation& ob) const;
 		Object *copy();
+		void    DeepEcho()  {_error_("Not implemented yet"); };
+		double  distance(const Observation& ob) const;
+		void    Echo();
+		int     Id()        {_error_("Not implemented yet"); };
+		void    print() const;
 		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!");};
-
+		int     ObjectEnum(){_error_("Not implemented yet"); };
 
 		/*Management*/
Index: /issm/trunk-jpl/src/c/classes/kriging/Observations.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/Observations.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/Observations.cpp	(revision 20827)
@@ -77,79 +77,4 @@
 
 /*Initialize data structures*/
-void Observations::InitQuadtree(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){/*{{{*/
-
-	/*Intermediaries*/
-	int          i,maxdepth,level,counter,index;
-	int          xi,yi;
-	IssmPDouble  xmin,xmax,ymin,ymax;
-	IssmPDouble  offset,minlength,minspacing,mintrimming,maxtrimming;
-	Observation *observation = NULL;
-
-	/*Checks*/
-	_assert_(n);
-
-	/*Get extrema*/
-	xmin=x[0]; ymin=y[0];
-	xmax=x[0]; ymax=y[0];
-	for(i=1;i<n;i++){
-		xmin=min(xmin,x[i]); ymin=min(ymin,y[i]);
-		xmax=max(xmax,x[i]); ymax=max(ymax,y[i]);
-	}
-	offset=0.05*(xmax-xmin); xmin-=offset; xmax+=offset;
-	offset=0.05*(ymax-ymin); ymin-=offset; ymax+=offset;
-
-	/*Get trimming limits*/
-	options->Get(&mintrimming,"mintrimming",-1.e+21);
-	options->Get(&maxtrimming,"maxtrimming",+1.e+21);
-	options->Get(&minspacing,"minspacing",0.01);
-	if(minspacing<=0) _error_("minspacing must > 0");
-
-	/*Get Minimum box size*/
-	if(options->GetOption("boxlength")){
-		options->Get(&minlength,"boxlength");
-		if(minlength<=0)_error_("boxlength should be a positive number");
-		maxdepth=reCast<int,IssmPDouble>(log(max(xmax-xmin,ymax-ymin)/minlength +1)/log(2.0));
-	}
-	else{
-		maxdepth = 30;
-		minlength=max(xmax-xmin,ymax-ymin)/IssmPDouble((1L<<maxdepth)-1);
-	}
-
-	/*Initialize Quadtree*/
-	_printf0_("Generating quadtree with a maximum box size " << minlength << " (depth=" << maxdepth << ")... ");
-	this->quadtree = new Quadtree(xmin,xmax,ymin,ymax,maxdepth);
-
-	/*Add observations one by one*/
-	counter = 0;
-	for(i=0;i<n;i++){
-
-		/*First check limits*/
-		if(observations_list[i]>maxtrimming) continue;
-		if(observations_list[i]<mintrimming) continue;
-
-		/*Second, check that this observation is not too close from another one*/
-		this->quadtree->ClosestObs(&index,x[i],y[i]);
-		if(index>=0){
-			observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
-			if(pow(observation->x-x[i],2)+pow(observation->y-y[i],2) < minspacing) continue;
-		}
-
-		this->quadtree->IntergerCoordinates(&xi,&yi,x[i],y[i]);
-		this->quadtree->QuadtreeDepth2(&level,xi,yi);
-		if((int)level <= maxdepth){
-			observation = new Observation(x[i],y[i],xi,yi,counter++,observations_list[i]);
-			this->quadtree->Add(observation);
-			this->AddObject(observation);
-		}
-		else{
-			/*We need to average with the current observations*/
-			this->quadtree->AddAndAverage(x[i],y[i],observations_list[i]);
-		}
-	}
-	_printf0_("done\n");
-	_printf0_("Initial number of observations: " << n << "\n");
-	_printf0_("  Final number of observations: " << this->quadtree->NbObs << "\n");
-}
-/*}}}*/
 void Observations::InitCovertree(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){/*{{{*/
 
@@ -208,4 +133,79 @@
 }
 /*}}}*/
+void Observations::InitQuadtree(IssmPDouble* observations_list,IssmPDouble* x,IssmPDouble* y,int n,Options* options){/*{{{*/
+
+	/*Intermediaries*/
+	int          i,maxdepth,level,counter,index;
+	int          xi,yi;
+	IssmPDouble  xmin,xmax,ymin,ymax;
+	IssmPDouble  offset,minlength,minspacing,mintrimming,maxtrimming;
+	Observation *observation = NULL;
+
+	/*Checks*/
+	_assert_(n);
+
+	/*Get extrema*/
+	xmin=x[0]; ymin=y[0];
+	xmax=x[0]; ymax=y[0];
+	for(i=1;i<n;i++){
+		xmin=min(xmin,x[i]); ymin=min(ymin,y[i]);
+		xmax=max(xmax,x[i]); ymax=max(ymax,y[i]);
+	}
+	offset=0.05*(xmax-xmin); xmin-=offset; xmax+=offset;
+	offset=0.05*(ymax-ymin); ymin-=offset; ymax+=offset;
+
+	/*Get trimming limits*/
+	options->Get(&mintrimming,"mintrimming",-1.e+21);
+	options->Get(&maxtrimming,"maxtrimming",+1.e+21);
+	options->Get(&minspacing,"minspacing",0.01);
+	if(minspacing<=0) _error_("minspacing must > 0");
+
+	/*Get Minimum box size*/
+	if(options->GetOption("boxlength")){
+		options->Get(&minlength,"boxlength");
+		if(minlength<=0)_error_("boxlength should be a positive number");
+		maxdepth=reCast<int,IssmPDouble>(log(max(xmax-xmin,ymax-ymin)/minlength +1)/log(2.0));
+	}
+	else{
+		maxdepth = 30;
+		minlength=max(xmax-xmin,ymax-ymin)/IssmPDouble((1L<<maxdepth)-1);
+	}
+
+	/*Initialize Quadtree*/
+	_printf0_("Generating quadtree with a maximum box size " << minlength << " (depth=" << maxdepth << ")... ");
+	this->quadtree = new Quadtree(xmin,xmax,ymin,ymax,maxdepth);
+
+	/*Add observations one by one*/
+	counter = 0;
+	for(i=0;i<n;i++){
+
+		/*First check limits*/
+		if(observations_list[i]>maxtrimming) continue;
+		if(observations_list[i]<mintrimming) continue;
+
+		/*Second, check that this observation is not too close from another one*/
+		this->quadtree->ClosestObs(&index,x[i],y[i]);
+		if(index>=0){
+			observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
+			if(pow(observation->x-x[i],2)+pow(observation->y-y[i],2) < minspacing) continue;
+		}
+
+		this->quadtree->IntergerCoordinates(&xi,&yi,x[i],y[i]);
+		this->quadtree->QuadtreeDepth2(&level,xi,yi);
+		if((int)level <= maxdepth){
+			observation = new Observation(x[i],y[i],xi,yi,counter++,observations_list[i]);
+			this->quadtree->Add(observation);
+			this->AddObject(observation);
+		}
+		else{
+			/*We need to average with the current observations*/
+			this->quadtree->AddAndAverage(x[i],y[i],observations_list[i]);
+		}
+	}
+	_printf0_("done\n");
+	_printf0_("Initial number of observations: " << n << "\n");
+	_printf0_("  Final number of observations: " << this->quadtree->NbObs << "\n");
+}
+/*}}}*/
 
 /*Methods*/
@@ -222,55 +222,4 @@
 			_error_("Tree type "<<this->treetype<<" not supported yet (1: quadtree, 2: covertree)");
 	}
-
-}/*}}}*/
-void Observations::ClosestObservationQuadtree(IssmPDouble *px,IssmPDouble *py,IssmPDouble *pobs,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius){/*{{{*/
-
-	/*Output and Intermediaries*/
-	int          nobs,i,index;
-	IssmPDouble  hmin,h2,hmin2;
-	int         *indices      = NULL;
-	Observation *observation  = NULL;
-
-	/*If radius is not provided or is 0, return all observations*/
-	if(radius==0) radius=this->quadtree->root->length;
-
-	/*First, find closest point in Quadtree (fast but might not be the true closest obs)*/
-	this->quadtree->ClosestObs(&index,x_interp,y_interp);
-	if(index>=0){
-		observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
-		hmin = sqrt((observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp));
-		if(hmin<radius) radius=hmin;
-	}
-
-	/*Find all observations that are in radius*/
-	this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,radius);
-	for (i=0;i<nobs;i++){
-		observation=xDynamicCast<Observation*>(this->GetObjectByOffset(indices[i]));
-		h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
-		if(i==0){
-			hmin2 = h2;
-			index = indices[i];
-		}
-		else{
-			if(h2<hmin2){
-				hmin2 = h2;
-				index = indices[i];
-			}
-		}
-	}  
-
-	/*Assign output pointer*/
-	if(nobs || hmin==radius){
-		observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
-		*px   = observation->x;
-		*py   = observation->y;
-		*pobs = observation->value;
-	}
-	else{
-		*px   = UNDEF;
-		*py   = UNDEF;
-		*pobs = UNDEF;
-	}
-	xDelete<int>(indices);
 
 }/*}}}*/
@@ -297,4 +246,55 @@
 	*pobs = UNDEF;
 }/*}}}*/
+void Observations::ClosestObservationQuadtree(IssmPDouble *px,IssmPDouble *py,IssmPDouble *pobs,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius){/*{{{*/
+
+	/*Output and Intermediaries*/
+	int          nobs,i,index;
+	IssmPDouble  hmin,h2,hmin2;
+	int         *indices      = NULL;
+	Observation *observation  = NULL;
+
+	/*If radius is not provided or is 0, return all observations*/
+	if(radius==0) radius=this->quadtree->root->length;
+
+	/*First, find closest point in Quadtree (fast but might not be the true closest obs)*/
+	this->quadtree->ClosestObs(&index,x_interp,y_interp);
+	if(index>=0){
+		observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
+		hmin = sqrt((observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp));
+		if(hmin<radius) radius=hmin;
+	}
+
+	/*Find all observations that are in radius*/
+	this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,radius);
+	for (i=0;i<nobs;i++){
+		observation=xDynamicCast<Observation*>(this->GetObjectByOffset(indices[i]));
+		h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
+		if(i==0){
+			hmin2 = h2;
+			index = indices[i];
+		}
+		else{
+			if(h2<hmin2){
+				hmin2 = h2;
+				index = indices[i];
+			}
+		}
+	}  
+
+	/*Assign output pointer*/
+	if(nobs || hmin==radius){
+		observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
+		*px   = observation->x;
+		*py   = observation->y;
+		*pobs = observation->value;
+	}
+	else{
+		*px   = UNDEF;
+		*py   = UNDEF;
+		*pobs = UNDEF;
+	}
+	xDelete<int>(indices);
+
+}/*}}}*/
 void Observations::Distances(IssmPDouble* distances,IssmPDouble *x,IssmPDouble *y,int n,IssmPDouble radius){/*{{{*/
 
@@ -350,4 +350,47 @@
 			_error_("Tree type "<<this->treetype<<" not supported yet (1: quadtree, 2: covertree)");
 	}
+}/*}}}*/
+void Observations::ObservationListCovertree(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double radius,int maxdata){/*{{{*/
+
+	double *x            = NULL;
+	double *y            = NULL;
+	double *obs          = NULL;
+	Observation observation=Observation(x_interp,y_interp,0.);
+	std::vector<Observation> kNN;
+
+	kNN=(this->covertree->kNearestNeighbors(observation, maxdata));
+	//cout << "kNN's size: " << kNN.size() << " (maxdata = " <<maxdata<<")"<<endl;
+
+	//kNN is sort from closest to farthest neighbor
+	//searches for the first neighbor that is out of radius
+	//deletes and resizes the kNN vector
+	vector<Observation>::iterator it;
+	if(radius>0.){
+		for (it = kNN.begin(); it != kNN.end(); ++it) {
+			//(*it).print();
+			//cout << "\n" << (*it).distance(observation) << endl;
+			if ((*it).distance(observation) > radius) {
+				break;
+			}
+		}
+		kNN.erase(it, kNN.end());
+	}
+
+	/*Allocate vectors*/
+	x   = new double[kNN.size()];
+	y   = new double[kNN.size()];
+	obs = new double[kNN.size()];
+
+	/*Loop over all observations and fill in x, y and obs*/
+	int i = 0;
+	for(it = kNN.begin(); it != kNN.end(); ++it) {
+		(*it).WriteXYObs((*it), &x[i], &y[i], &obs[i]);
+		i++;
+	}
+
+	*px=x;
+	*py=y;
+	*pobs=obs;
+	*pnobs = kNN.size();
 }/*}}}*/
 void Observations::ObservationListQuadtree(IssmPDouble **px,IssmPDouble **py,IssmPDouble **pobs,int* pnobs,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius,int maxdata){/*{{{*/
@@ -433,47 +476,4 @@
 	*pnobs=nobs;
 }/*}}}*/
-void Observations::ObservationListCovertree(double **px,double **py,double **pobs,int* pnobs,double x_interp,double y_interp,double radius,int maxdata){/*{{{*/
-
-	double *x            = NULL;
-	double *y            = NULL;
-	double *obs          = NULL;
-	Observation observation=Observation(x_interp,y_interp,0.);
-	std::vector<Observation> kNN;
-
-	kNN=(this->covertree->kNearestNeighbors(observation, maxdata));
-	//cout << "kNN's size: " << kNN.size() << " (maxdata = " <<maxdata<<")"<<endl;
-
-	//kNN is sort from closest to farthest neighbor
-	//searches for the first neighbor that is out of radius
-	//deletes and resizes the kNN vector
-	vector<Observation>::iterator it;
-	if(radius>0.){
-		for (it = kNN.begin(); it != kNN.end(); ++it) {
-			//(*it).print();
-			//cout << "\n" << (*it).distance(observation) << endl;
-			if ((*it).distance(observation) > radius) {
-				break;
-			}
-		}
-		kNN.erase(it, kNN.end());
-	}
-
-	/*Allocate vectors*/
-	x   = new double[kNN.size()];
-	y   = new double[kNN.size()];
-	obs = new double[kNN.size()];
-
-	/*Loop over all observations and fill in x, y and obs*/
-	int i = 0;
-	for(it = kNN.begin(); it != kNN.end(); ++it) {
-		(*it).WriteXYObs((*it), &x[i], &y[i], &obs[i]);
-		i++;
-	}
-
-	*px=x;
-	*py=y;
-	*pobs=obs;
-	*pnobs = kNN.size();
-}/*}}}*/
 void Observations::InterpolationIDW(IssmPDouble *pprediction,IssmPDouble x_interp,IssmPDouble y_interp,IssmPDouble radius,int mindata,int maxdata,IssmPDouble power){/*{{{*/
 
Index: /issm/trunk-jpl/src/c/classes/kriging/Observations.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/Observations.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/Observations.h	(revision 20827)
@@ -29,11 +29,11 @@
 
 		/*Initialize data structures*/
+		void InitCovertree(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options);
 		void InitQuadtree(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options);
-		void InitCovertree(IssmDouble* observations_list,IssmDouble* x,IssmDouble* y,int n,Options* options);
 
 		/*Methods*/
 		void ClosestObservation(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
+		void ClosestObservationCovertree(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
 		void ClosestObservationQuadtree(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
-		void ClosestObservationCovertree(IssmDouble *px,IssmDouble *py,IssmDouble *pobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius);
 		void Distances(IssmPDouble* distances,IssmPDouble *x,IssmPDouble *y,int n,IssmPDouble radius);
 		void InterpolationIDW(IssmDouble *pprediction,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int mindata,int maxdata,IssmDouble power);
@@ -43,6 +43,6 @@
 		void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs);
 		void ObservationList(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata);
+		void ObservationListCovertree(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata);
 		void ObservationListQuadtree(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata);
-		void ObservationListCovertree(IssmDouble **px,IssmDouble **py,IssmDouble **pobs,int* pnobs,IssmDouble x_interp,IssmDouble y_interp,IssmDouble radius,int maxdata);
 		void QuadtreeColoring(IssmDouble* A,IssmDouble *x,IssmDouble *y,int n);
 		void Variomap(IssmDouble* gamma,IssmDouble *x,int n);
Index: /issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.cpp	(revision 20827)
@@ -43,4 +43,8 @@
 
 /*Object virtual functions definitions:*/
+Object* PowerVariogram::copy(void){/*{{{*/
+	   return new PowerVariogram(*this);
+}
+/*}}}*/
 void PowerVariogram::Echo(void){/*{{{*/
 	_printf_("PowerVariogram\n");
@@ -48,8 +52,4 @@
 	_printf_("   slope : " << this->slope << "\n");
 	_printf_("   power : " << this->power << "\n");
-}
-/*}}}*/
-Object* PowerVariogram::copy(void){/*{{{*/
-	   return new PowerVariogram(*this);
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.h	(revision 20827)
@@ -22,15 +22,15 @@
 
 		/*Object virtual functions definitions*/
+		Object* copy();
+		void  DeepEcho(){_error_("Not implemented yet");};
 		void  Echo();
-		void  DeepEcho(){_error_("Not implemented yet");};
 		int   Id(){_error_("Not implemented yet");}; 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 		int   ObjectEnum(){_error_("Not implemented yet");};
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 
 
 		/*Variogram functions*/
+		double Covariance(double deltax,double deltay);
 		double SemiVariogram(double deltax,double deltay);
-		double Covariance(double deltax,double deltay);
 };
 #endif  /* _POWERVARIOGRAM_H */
Index: /issm/trunk-jpl/src/c/classes/kriging/Quadtree.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/Quadtree.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/Quadtree.cpp	(revision 20827)
@@ -282,13 +282,4 @@
 	*pindex=index;
 }/*}}}*/
-void  Quadtree::Echo(void){/*{{{*/
-
-	_printf_("Quadtree:\n");
-	_printf_("   MaxDepth      = " << this->MaxDepth << "\n");
-	_printf_("   NbQuadtreeBox = " << this->NbQuadtreeBox << "\n");
-	_printf_("   NbObs         = " << this->NbObs << "\n");
-	_printf_("   root          = " << this->root << "\n");
-
-}/*}}}*/
 void  Quadtree::DeepEcho(void){/*{{{*/
 
@@ -299,4 +290,13 @@
 	_printf_("   root          = " << this->root << "\n");
 	boxcontainer->Echo();
+
+}/*}}}*/
+void  Quadtree::Echo(void){/*{{{*/
+
+	_printf_("Quadtree:\n");
+	_printf_("   MaxDepth      = " << this->MaxDepth << "\n");
+	_printf_("   NbQuadtreeBox = " << this->NbQuadtreeBox << "\n");
+	_printf_("   NbObs         = " << this->NbObs << "\n");
+	_printf_("   root          = " << this->root << "\n");
 
 }/*}}}*/
@@ -391,4 +391,21 @@
 	return newbox;
 }/*}}}*/
+void Quadtree::RangeSearch(int **pindices,int *pnobs,double x,double y,double range){/*{{{*/
+
+	/*Intermediaries*/
+	int  nobs;
+	int *indices = NULL;
+
+	/*Allocate indices (maximum by default*/
+	if(this->NbObs) indices = xNew<int>(this->NbObs);
+	nobs = 0;
+
+	if(this->root) this->root->RangeSearch(indices,&nobs,x,y,range);
+
+	/*Clean-up and return*/
+	*pnobs=nobs;
+	*pindices=indices;
+
+}/*}}}*/
 void Quadtree::QuadtreeDepth(int* A,int xi,int yi){/*{{{*/
 
@@ -470,23 +487,22 @@
 	*A=level;
 }/*}}}*/
-void Quadtree::RangeSearch(int **pindices,int *pnobs,double x,double y,double range){/*{{{*/
-
-	/*Intermediaries*/
-	int  nobs;
-	int *indices = NULL;
-
-	/*Allocate indices (maximum by default*/
-	if(this->NbObs) indices = xNew<int>(this->NbObs);
-	nobs = 0;
-
-	if(this->root) this->root->RangeSearch(indices,&nobs,x,y,range);
-
-	/*Clean-up and return*/
-	*pnobs=nobs;
-	*pindices=indices;
-
-}/*}}}*/
 
 /*QuadtreeBox methos*/
+Object* Quadtree::QuadtreeBox::copy(void){/*{{{*/
+
+	   QuadtreeBox* qtreebox = new QuadtreeBox(*this);
+
+		for (int i=0; i<4; ++i){
+			if(this->box[i]) qtreebox->box[i] = reinterpret_cast<QuadtreeBox*>(this->box[i]->copy());
+			else qtreebox->box[i] = NULL;
+		}
+		for (int i=0; i<4; ++i){
+			if(this->obs[i]) qtreebox->obs[i] = reinterpret_cast<Observation*>(this->obs[i]->copy());
+			else qtreebox->obs[i] = NULL;
+		}
+
+		return (Object*) qtreebox;
+}
+/*}}}*/
 void  Quadtree::QuadtreeBox::Echo(void){/*{{{*/
 
@@ -498,20 +514,4 @@
 
 }/*}}}*/
-Object* Quadtree::QuadtreeBox::copy(void){/*{{{*/
-
-	   QuadtreeBox* qtreebox = new QuadtreeBox(*this);
-
-		for (int i=0; i<4; ++i){
-			if(this->box[i]) qtreebox->box[i] = reinterpret_cast<QuadtreeBox*>(this->box[i]->copy());
-			else qtreebox->box[i] = NULL;
-		}
-		for (int i=0; i<4; ++i){
-			if(this->obs[i]) qtreebox->obs[i] = reinterpret_cast<Observation*>(this->obs[i]->copy());
-			else qtreebox->obs[i] = NULL;
-		}
-
-		return (Object*) qtreebox;
-}
-/*}}}*/
 int Quadtree::QuadtreeBox::IsWithinRange(double x,double y,double range){/*{{{*/
 
Index: /issm/trunk-jpl/src/c/classes/kriging/Quadtree.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/Quadtree.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/Quadtree.h	(revision 20827)
@@ -26,10 +26,10 @@
 
 				/*Object functions (Needed because the Quadtree uses a Container*/
+				Object *copy();
+				void    DeepEcho()  {_error_("not implemented yet"); };
 				void    Echo();
-				void    DeepEcho()  {_error_("not implemented yet"); };
 				int     Id()        {_error_("not implemented yet"); };
+				void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!");};
 				int     ObjectEnum(){_error_("not implemented yet"); };
-				Object *copy();
-				void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!");};
 
 
Index: /issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.cpp	(revision 20827)
@@ -42,4 +42,8 @@
 
 /*Object virtual functions definitions:*/
+Object* SphericalVariogram::copy(void){/*{{{*/
+	return new SphericalVariogram(*this);
+}
+/*}}}*/
 void SphericalVariogram::Echo(void){/*{{{*/
 	_printf_("SphericalVariogram\n");
@@ -47,8 +51,4 @@
 	_printf_("   sill  : " << this->sill << "\n");
 	_printf_("   range : " << this->range << "\n");
-}
-/*}}}*/
-Object* SphericalVariogram::copy(void){/*{{{*/
-	return new SphericalVariogram(*this);
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.h	(revision 20827)
@@ -22,15 +22,15 @@
 
 		/*Object virtual functions definitions*/
+		Object* copy();
+		void  DeepEcho(){_error_("Not implemented yet");};
 		void  Echo();
-		void  DeepEcho(){_error_("Not implemented yet");};
 		int   Id(){_error_("Not implemented yet");}; 
+		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 		int   ObjectEnum(){_error_("Not implemented yet");};
-		Object* copy();
-		void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ _error_("not implemented yet!"); };
 
 
 		/*Variogram functions*/
+		double Covariance(double deltax,double deltay);
 		double SemiVariogram(double deltax,double deltay);
-		double Covariance(double deltax,double deltay);
 };
 #endif  /* _SPHERICALVARIOGRAM_H */
Index: /issm/trunk-jpl/src/c/classes/kriging/Variogram.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/kriging/Variogram.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/kriging/Variogram.h	(revision 20827)
@@ -12,6 +12,6 @@
 	public: 
 		virtual ~Variogram(){};
+		virtual double Covariance(double deltax,double deltay)=0;
 		virtual double SemiVariogram(double deltax,double deltay)=0;
-		virtual double Covariance(double deltax,double deltay)=0;
 
 };
Index: /issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.cpp	(revision 20827)
@@ -236,4 +236,37 @@
 
 /*ElementMatrix specific routines: */
+void ElementMatrix::AddDiagonalToGlobal(Vector<IssmDouble>* pf){/*{{{*/
+
+	IssmDouble* localvalues=NULL;
+
+	/*Check that pf is not NULL*/
+	_assert_(pf); 
+
+	/*In debugging mode, check consistency (no NaN, and values not too big)*/
+	this->CheckConsistency();
+
+	if(this->dofsymmetrical){
+		/*only use row dofs to add values into global matrices: */
+
+		if(this->row_fsize){
+			/*first, retrieve values that are in the f-set from the g-set values matrix: */
+			localvalues=xNew<IssmDouble>(this->row_fsize);
+			for(int i=0;i<this->row_fsize;i++){
+				localvalues[i] = this->values[this->ncols*this->row_flocaldoflist[i]+ this->row_flocaldoflist[i]];
+			}
+
+			/*add local values into global  matrix, using the fglobaldoflist: */
+			pf->SetValues(this->row_fsize,this->row_fglobaldoflist,localvalues,ADD_VAL);
+
+			/*Free ressources:*/
+			xDelete<IssmDouble>(localvalues);
+		}
+	}
+	else{
+		_error_("non dofsymmetrical matrix AddToGlobal routine not support yet!");
+	}
+
+}
+/*}}}*/
 void ElementMatrix::AddToGlobal(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs){/*{{{*/
 
@@ -322,37 +355,4 @@
 		}
 
-	}
-	else{
-		_error_("non dofsymmetrical matrix AddToGlobal routine not support yet!");
-	}
-
-}
-/*}}}*/
-void ElementMatrix::AddDiagonalToGlobal(Vector<IssmDouble>* pf){/*{{{*/
-
-	IssmDouble* localvalues=NULL;
-
-	/*Check that pf is not NULL*/
-	_assert_(pf); 
-
-	/*In debugging mode, check consistency (no NaN, and values not too big)*/
-	this->CheckConsistency();
-
-	if(this->dofsymmetrical){
-		/*only use row dofs to add values into global matrices: */
-
-		if(this->row_fsize){
-			/*first, retrieve values that are in the f-set from the g-set values matrix: */
-			localvalues=xNew<IssmDouble>(this->row_fsize);
-			for(int i=0;i<this->row_fsize;i++){
-				localvalues[i] = this->values[this->ncols*this->row_flocaldoflist[i]+ this->row_flocaldoflist[i]];
-			}
-
-			/*add local values into global  matrix, using the fglobaldoflist: */
-			pf->SetValues(this->row_fsize,this->row_fglobaldoflist,localvalues,ADD_VAL);
-
-			/*Free ressources:*/
-			xDelete<IssmDouble>(localvalues);
-		}
 	}
 	else{
@@ -373,4 +373,113 @@
 	}
 	#endif
+}
+/*}}}*/
+void ElementMatrix::Echo(void){/*{{{*/
+
+	int i,j;
+	_printf_("Element Matrix echo:\n");
+	_printf_("   nrows: " << this->nrows << "\n");
+	_printf_("   ncols: " << this->ncols << "\n");
+	_printf_("   dofsymmetrical: " << (dofsymmetrical?"true":"false") << "\n");
+
+	_printf_("   values:\n");
+	for(i=0;i<nrows;i++){
+		_printf_(setw(4) << right << i << ": ");
+		for(j=0;j<ncols;j++) _printf_( " " << setw(11) << setprecision (5) << right << values[i*ncols+j]);
+		_printf_("\n");
+	}
+
+	_printf_("   gglobaldoflist (" << gglobaldoflist << "): ");
+	if(gglobaldoflist) for(i=0;i<nrows;i++) _printf_(" " << gglobaldoflist[i]); _printf_("\n");
+
+	_printf_("   row_fsize: " << row_fsize << "\n");
+	_printf_("   row_flocaldoflist  (" << row_flocaldoflist << "): ");
+	if(row_flocaldoflist) for(i=0;i<row_fsize;i++) _printf_(" " << row_flocaldoflist[i] ); _printf_(" \n");
+	_printf_("   row_fglobaldoflist  (" << row_fglobaldoflist << "): ");
+	if(row_fglobaldoflist) for(i=0;i<row_fsize;i++)_printf_(" " << row_fglobaldoflist[i]); _printf_(" \n");
+
+	_printf_("   row_ssize: " << row_ssize << "\n");
+	_printf_("   row_slocaldoflist  (" << row_slocaldoflist << "): ");
+	if(row_slocaldoflist) for(i=0;i<row_ssize;i++) _printf_(" " << row_slocaldoflist[i] ); _printf_(" \n");
+	_printf_("   row_sglobaldoflist  (" << row_sglobaldoflist << "): ");
+	if(row_sglobaldoflist) for(i=0;i<row_ssize;i++)_printf_(" " << row_sglobaldoflist[i]); _printf_(" \n");
+
+	if(!dofsymmetrical){
+		_printf_("   col_fsize: " << col_fsize << "\n");
+		_printf_("   col_flocaldoflist  (" << col_flocaldoflist << "): ");
+		if(col_flocaldoflist) for(i=0;i<col_fsize;i++) _printf_(" " << col_flocaldoflist[i] ); _printf_(" \n");
+		_printf_("   col_fglobaldoflist  (" << col_fglobaldoflist << "): ");
+		if(col_fglobaldoflist) for(i=0;i<col_fsize;i++)_printf_(" " << col_fglobaldoflist[i]); _printf_(" \n");
+
+		_printf_("   col_ssize: " << col_ssize << "\n");
+		_printf_("   col_slocaldoflist  (" << col_slocaldoflist << "): ");
+		if(col_slocaldoflist) for(i=0;i<col_ssize;i++) _printf_(" " << col_slocaldoflist[i] ); _printf_(" \n");
+		_printf_("   col_sglobaldoflist  (" << col_sglobaldoflist << "): ");
+		if(col_sglobaldoflist) for(i=0;i<col_ssize;i++)_printf_(" " << col_sglobaldoflist[i]); _printf_(" \n");
+	}
+}
+/*}}}*/
+void ElementMatrix::Init(ElementMatrix* Ke){/*{{{*/
+
+	_assert_(Ke);
+	_assert_(this);
+
+	this->nrows =Ke->nrows;
+	this->ncols =Ke->ncols;
+	this->dofsymmetrical=Ke->dofsymmetrical;
+
+	this->values=xNew<IssmDouble>(this->nrows*this->ncols);
+	xMemCpy<IssmDouble>(this->values,Ke->values,this->nrows*this->ncols);
+
+	this->gglobaldoflist=xNew<int>(this->nrows);
+	xMemCpy<int>(this->gglobaldoflist,Ke->gglobaldoflist,this->nrows);
+
+	this->row_fsize=Ke->row_fsize;
+	if(this->row_fsize){
+		this->row_flocaldoflist=xNew<int>(this->row_fsize);
+		xMemCpy<int>(this->row_flocaldoflist,Ke->row_flocaldoflist,this->row_fsize);
+		this->row_fglobaldoflist=xNew<int>(this->row_fsize);
+		xMemCpy<int>(this->row_fglobaldoflist,Ke->row_fglobaldoflist,this->row_fsize);
+	}
+	else{
+		this->row_flocaldoflist=NULL;
+		this->row_fglobaldoflist=NULL;
+	}
+
+	this->row_ssize=Ke->row_ssize;
+	if(this->row_ssize){
+		this->row_slocaldoflist=xNew<int>(this->row_ssize);
+		xMemCpy<int>(this->row_slocaldoflist,Ke->row_slocaldoflist,this->row_ssize);
+		this->row_sglobaldoflist=xNew<int>(this->row_ssize);
+		xMemCpy<int>(this->row_sglobaldoflist,Ke->row_sglobaldoflist,this->row_ssize);
+	}
+	else{
+		this->row_slocaldoflist=NULL;
+		this->row_sglobaldoflist=NULL;
+	}
+
+	this->col_fsize=Ke->col_fsize;
+	if(this->col_fsize){
+		this->col_flocaldoflist=xNew<int>(this->col_fsize);
+		xMemCpy<int>(this->col_flocaldoflist,Ke->col_flocaldoflist,this->col_fsize);
+		this->col_fglobaldoflist=xNew<int>(this->col_fsize);
+		xMemCpy<int>(this->col_fglobaldoflist,Ke->col_fglobaldoflist,this->col_fsize);
+	}
+	else{
+		this->col_flocaldoflist=NULL;
+		this->col_fglobaldoflist=NULL;
+	}
+
+	this->col_ssize=Ke->col_ssize;
+	if(this->col_ssize){
+		this->col_slocaldoflist=xNew<int>(this->col_ssize);
+		xMemCpy<int>(this->col_slocaldoflist,Ke->col_slocaldoflist,this->col_ssize);
+		this->col_sglobaldoflist=xNew<int>(this->col_ssize);
+		xMemCpy<int>(this->col_sglobaldoflist,Ke->col_sglobaldoflist,this->col_ssize);
+	}
+	else{
+		this->col_slocaldoflist=NULL;
+		this->col_sglobaldoflist=NULL;
+	}
 }
 /*}}}*/
@@ -516,111 +625,2 @@
 }
 /*}}}*/
-void ElementMatrix::Echo(void){/*{{{*/
-
-	int i,j;
-	_printf_("Element Matrix echo:\n");
-	_printf_("   nrows: " << this->nrows << "\n");
-	_printf_("   ncols: " << this->ncols << "\n");
-	_printf_("   dofsymmetrical: " << (dofsymmetrical?"true":"false") << "\n");
-
-	_printf_("   values:\n");
-	for(i=0;i<nrows;i++){
-		_printf_(setw(4) << right << i << ": ");
-		for(j=0;j<ncols;j++) _printf_( " " << setw(11) << setprecision (5) << right << values[i*ncols+j]);
-		_printf_("\n");
-	}
-
-	_printf_("   gglobaldoflist (" << gglobaldoflist << "): ");
-	if(gglobaldoflist) for(i=0;i<nrows;i++) _printf_(" " << gglobaldoflist[i]); _printf_("\n");
-
-	_printf_("   row_fsize: " << row_fsize << "\n");
-	_printf_("   row_flocaldoflist  (" << row_flocaldoflist << "): ");
-	if(row_flocaldoflist) for(i=0;i<row_fsize;i++) _printf_(" " << row_flocaldoflist[i] ); _printf_(" \n");
-	_printf_("   row_fglobaldoflist  (" << row_fglobaldoflist << "): ");
-	if(row_fglobaldoflist) for(i=0;i<row_fsize;i++)_printf_(" " << row_fglobaldoflist[i]); _printf_(" \n");
-
-	_printf_("   row_ssize: " << row_ssize << "\n");
-	_printf_("   row_slocaldoflist  (" << row_slocaldoflist << "): ");
-	if(row_slocaldoflist) for(i=0;i<row_ssize;i++) _printf_(" " << row_slocaldoflist[i] ); _printf_(" \n");
-	_printf_("   row_sglobaldoflist  (" << row_sglobaldoflist << "): ");
-	if(row_sglobaldoflist) for(i=0;i<row_ssize;i++)_printf_(" " << row_sglobaldoflist[i]); _printf_(" \n");
-
-	if(!dofsymmetrical){
-		_printf_("   col_fsize: " << col_fsize << "\n");
-		_printf_("   col_flocaldoflist  (" << col_flocaldoflist << "): ");
-		if(col_flocaldoflist) for(i=0;i<col_fsize;i++) _printf_(" " << col_flocaldoflist[i] ); _printf_(" \n");
-		_printf_("   col_fglobaldoflist  (" << col_fglobaldoflist << "): ");
-		if(col_fglobaldoflist) for(i=0;i<col_fsize;i++)_printf_(" " << col_fglobaldoflist[i]); _printf_(" \n");
-
-		_printf_("   col_ssize: " << col_ssize << "\n");
-		_printf_("   col_slocaldoflist  (" << col_slocaldoflist << "): ");
-		if(col_slocaldoflist) for(i=0;i<col_ssize;i++) _printf_(" " << col_slocaldoflist[i] ); _printf_(" \n");
-		_printf_("   col_sglobaldoflist  (" << col_sglobaldoflist << "): ");
-		if(col_sglobaldoflist) for(i=0;i<col_ssize;i++)_printf_(" " << col_sglobaldoflist[i]); _printf_(" \n");
-	}
-}
-/*}}}*/
-void ElementMatrix::Init(ElementMatrix* Ke){/*{{{*/
-
-	_assert_(Ke);
-	_assert_(this);
-
-	this->nrows =Ke->nrows;
-	this->ncols =Ke->ncols;
-	this->dofsymmetrical=Ke->dofsymmetrical;
-
-	this->values=xNew<IssmDouble>(this->nrows*this->ncols);
-	xMemCpy<IssmDouble>(this->values,Ke->values,this->nrows*this->ncols);
-
-	this->gglobaldoflist=xNew<int>(this->nrows);
-	xMemCpy<int>(this->gglobaldoflist,Ke->gglobaldoflist,this->nrows);
-
-	this->row_fsize=Ke->row_fsize;
-	if(this->row_fsize){
-		this->row_flocaldoflist=xNew<int>(this->row_fsize);
-		xMemCpy<int>(this->row_flocaldoflist,Ke->row_flocaldoflist,this->row_fsize);
-		this->row_fglobaldoflist=xNew<int>(this->row_fsize);
-		xMemCpy<int>(this->row_fglobaldoflist,Ke->row_fglobaldoflist,this->row_fsize);
-	}
-	else{
-		this->row_flocaldoflist=NULL;
-		this->row_fglobaldoflist=NULL;
-	}
-
-	this->row_ssize=Ke->row_ssize;
-	if(this->row_ssize){
-		this->row_slocaldoflist=xNew<int>(this->row_ssize);
-		xMemCpy<int>(this->row_slocaldoflist,Ke->row_slocaldoflist,this->row_ssize);
-		this->row_sglobaldoflist=xNew<int>(this->row_ssize);
-		xMemCpy<int>(this->row_sglobaldoflist,Ke->row_sglobaldoflist,this->row_ssize);
-	}
-	else{
-		this->row_slocaldoflist=NULL;
-		this->row_sglobaldoflist=NULL;
-	}
-
-	this->col_fsize=Ke->col_fsize;
-	if(this->col_fsize){
-		this->col_flocaldoflist=xNew<int>(this->col_fsize);
-		xMemCpy<int>(this->col_flocaldoflist,Ke->col_flocaldoflist,this->col_fsize);
-		this->col_fglobaldoflist=xNew<int>(this->col_fsize);
-		xMemCpy<int>(this->col_fglobaldoflist,Ke->col_fglobaldoflist,this->col_fsize);
-	}
-	else{
-		this->col_flocaldoflist=NULL;
-		this->col_fglobaldoflist=NULL;
-	}
-
-	this->col_ssize=Ke->col_ssize;
-	if(this->col_ssize){
-		this->col_slocaldoflist=xNew<int>(this->col_ssize);
-		xMemCpy<int>(this->col_slocaldoflist,Ke->col_slocaldoflist,this->col_ssize);
-		this->col_sglobaldoflist=xNew<int>(this->col_ssize);
-		xMemCpy<int>(this->col_sglobaldoflist,Ke->col_sglobaldoflist,this->col_ssize);
-	}
-	else{
-		this->col_slocaldoflist=NULL;
-		this->col_sglobaldoflist=NULL;
-	}
-}
-/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/matrix/ElementMatrix.h	(revision 20827)
@@ -58,13 +58,13 @@
 
 		/*ElementMatrix specific routines*/
+		void AddDiagonalToGlobal(Vector<IssmDouble>* pf);
 		void AddToGlobal(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
 		void AddToGlobal(Matrix<IssmDouble>* Jff);
-		void AddDiagonalToGlobal(Vector<IssmDouble>* pf);
+		void CheckConsistency(void);
 		void Echo(void);
-		void CheckConsistency(void);
+		void Init(ElementMatrix* Ke);
+		void Lump(void);
 		void StaticCondensation(int numindices,int* indices);
-		void Lump(void);
 		void Transpose(void);
-		void Init(ElementMatrix* Ke);
 };
 #endif //#ifndef _ELEMENT_MATRIX_H_
Index: /issm/trunk-jpl/src/c/classes/matrix/ElementVector.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/matrix/ElementVector.cpp	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/matrix/ElementVector.cpp	(revision 20827)
@@ -176,24 +176,4 @@
 }
 /*}}}*/
-void ElementVector::InsertIntoGlobal(Vector<IssmDouble>* pf){/*{{{*/
-
-	int i;
-	IssmDouble* localvalues=NULL;
-
-	if(this->fsize){
-		/*first, retrieve values that are in the f-set from the g-set values vector: */
-		localvalues=xNew<IssmDouble>(this->fsize);
-		for(i=0;i<this->fsize;i++){
-			localvalues[i]=this->values[this->flocaldoflist[i]];
-		}
-		/*add local values into global  vector, using the fglobaldoflist: */
-		pf->SetValues(this->fsize,this->fglobaldoflist,localvalues,INS_VAL);
-
-		/*Free ressources:*/
-		xDelete<IssmDouble>(localvalues);
-	}
-
-}
-/*}}}*/
 void ElementVector::CheckConsistency(void){/*{{{*/
 	/*Check element matrix values, only in debugging mode*/
@@ -254,4 +234,24 @@
 		this->fglobaldoflist=NULL;
 	}
+}
+/*}}}*/
+void ElementVector::InsertIntoGlobal(Vector<IssmDouble>* pf){/*{{{*/
+
+	int i;
+	IssmDouble* localvalues=NULL;
+
+	if(this->fsize){
+		/*first, retrieve values that are in the f-set from the g-set values vector: */
+		localvalues=xNew<IssmDouble>(this->fsize);
+		for(i=0;i<this->fsize;i++){
+			localvalues[i]=this->values[this->flocaldoflist[i]];
+		}
+		/*add local values into global  vector, using the fglobaldoflist: */
+		pf->SetValues(this->fsize,this->fglobaldoflist,localvalues,INS_VAL);
+
+		/*Free ressources:*/
+		xDelete<IssmDouble>(localvalues);
+	}
+
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/matrix/ElementVector.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/matrix/ElementVector.h	(revision 20826)
+++ /issm/trunk-jpl/src/c/classes/matrix/ElementVector.h	(revision 20827)
@@ -41,8 +41,8 @@
 		/*ElementVector specific routines*/
 		void AddToGlobal(Vector<IssmDouble>* pf);
+		void CheckConsistency(void);
+		void Echo(void);
+		void Init(ElementVector* pe);
 		void InsertIntoGlobal(Vector<IssmDouble>* pf);
-		void Echo(void);
-		void CheckConsistency(void);
-		void Init(ElementVector* pe);
 		void SetValue(IssmDouble scalar);
 		void StaticCondensation(ElementMatrix* Ke,int numindices,int* indices);
