Index: issm/trunk-jpl/src/c/analyses/Balancethickness2Analysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/Balancethickness2Analysis.cpp	(revision 18446)
+++ issm/trunk-jpl/src/c/analyses/Balancethickness2Analysis.cpp	(revision 18450)
@@ -202,5 +202,5 @@
 	/*Intermediaries */
 	int         Hinterpolation;
-	IssmDouble  vx,vy,vbar,nu,normdphi,dphi[2];
+	IssmDouble  vx,vy,vbar,nu,normdphi,dphi[2],H;
 	IssmDouble* xyz_list = NULL;
 	int       * doflist  = NULL;
@@ -233,4 +233,5 @@
 	Input* vy_input        = element->GetInput(BalancethicknessVyObsEnum); _assert_(vy_input);
 	Input* nu_input        = element->GetInput(BalancethicknessNuEnum);    _assert_(nu_input);
+	Input* thickness_input = element->GetInput(BalancethicknessThicknessObsEnum);             _assert_(thickness_input);
 
 	switch(element->GetElementType()){
@@ -246,4 +247,5 @@
 		vy_input->GetInputValue(&vy,gauss);
 		nu_input->GetInputValue(&nu,gauss);
+		thickness_input->GetInputValue(&H,gauss);
 		potential_input->GetInputDerivativeValue(&dphi[0],xyz_list,gauss);
 
@@ -253,6 +255,6 @@
 
 		thickness_list[iv] = normdphi/vbar;
-		vx_list[iv]        = -1./thickness_list[iv] * dphi[0];
-		vy_list[iv]        = -1./thickness_list[iv] * dphi[1];
+		vx_list[iv]        = -1./H * dphi[0];
+		vy_list[iv]        = -1./H * dphi[1];
 	}
 	element->AddInput(ThicknessEnum,thickness_list,Hinterpolation);
Index: issm/trunk-jpl/src/c/classes/Elements/Element.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 18450)
@@ -220,5 +220,5 @@
 
 		virtual void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finite_element)=0;
-		virtual void   InputExtrude(int input_enum)=0;
+		virtual void   InputExtrude(int input_enum,int start)=0;
 		virtual void   InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solution,int inputenum)=0;
 		virtual void   InputUpdateFromSolutionOneDof(IssmDouble* solution,int inputenum)=0;
Index: issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 18450)
@@ -447,6 +447,6 @@
 	this->inputs->AddInput(NewPrecipitationInput);
 
-	this->InputExtrude(SurfaceforcingsMonthlytemperaturesEnum);
-	this->InputExtrude(SurfaceforcingsPrecipitationEnum);
+	this->InputExtrude(SurfaceforcingsMonthlytemperaturesEnum,-1);
+	this->InputExtrude(SurfaceforcingsPrecipitationEnum,-1);
 
 	/*clean-up*/
@@ -1191,22 +1191,27 @@
 }
 /*}}}*/
-void       Penta::InputExtrude(int enum_type){/*{{{*/
-
-	/*Are we on the base, not on the surface?:*/
-	if(!IsOnBase()) return;
+void       Penta::InputExtrude(int enum_type,int start){/*{{{*/
+
+	_assert_(start==-1 || start==+1);
+
+	/*Are we on the the boundary we want to be?*/
+	if(start==-1 && !IsOnBase())    return;
+	if(start==+1 && !IsOnSurface()) return;
 
 	/*Step1: Get and Extrude original input: */
 	Input* base_input=(Input*)this->inputs->GetInput(enum_type);
 	if(!base_input) _error_("could not find input with enum " << EnumToStringx(enum_type));
-	base_input->Extrude();
+	base_input->Extrude(start);
 
 	/*Stop if there is only one layer of element*/
-	if(this->IsOnSurface()) return;
+	if(start==-1 && this->IsOnSurface()) return;
+	if(start==+1 && this->IsOnBase())    return;
 
 	/*Step 2: this input has been extruded for this element, now follow the upper element*/
 	Penta* penta=this;
 	for(;;){
-		/* get upper Penta*/
-		penta=penta->GetUpperPenta();
+		/*get upper/lower Penta*/
+		if(start==-1) penta=penta->GetUpperPenta();
+		else          penta=penta->GetLowerPenta();
 		_assert_(penta->Id()!=this->id);
 
@@ -1215,6 +1220,7 @@
 		penta->inputs->AddInput((Input*)copy);
 
-		/*Stop if we have reached the surface*/
-		if(penta->IsOnSurface()) break;
+		/*Stop if we have reached the surface/base*/
+		if(start==-1 && penta->IsOnSurface()) break;
+		if(start==+1 && penta->IsOnBase())    break;
 	}
 }
@@ -1785,5 +1791,5 @@
    this->inputs->AddInput(new PentaInput(SurfaceforcingsMassBalanceEnum,&agd[0],P1Enum));
    //this->inputs->AddInput(new PentaVertexInput(ThermalSpcTemperatureEnum,&Tsurf[0]));
-   this->InputExtrude(SurfaceforcingsMassBalanceEnum);
+   this->InputExtrude(SurfaceforcingsMassBalanceEnum,-1);
 
 	/*clean-up*/
@@ -2860,8 +2866,8 @@
 
 		if(control_type[i]==MaterialsRheologyBbarEnum){
-			this->InputExtrude(MaterialsRheologyBEnum);
+			this->InputExtrude(MaterialsRheologyBEnum,-1);
 		}
 		else if(control_type[i]==DamageDbarEnum){
-			this->InputExtrude(DamageDEnum);
+			this->InputExtrude(DamageDEnum,-1);
 		}
 	}
@@ -2930,8 +2936,8 @@
 
 	if(control_init==MaterialsRheologyBbarEnum){
-		this->InputExtrude(control_enum);
+		this->InputExtrude(control_enum,-1);
 	}
 	if(control_init==DamageDbarEnum){
-		this->InputExtrude(control_enum);
+		this->InputExtrude(control_enum,-1);
 	}
 }
@@ -3171,5 +3177,5 @@
 	}
 	this->inputs->AddInput(new PentaInput(MaskGroundediceLevelsetEnum,&phi[0],P1Enum));
-	this->InputExtrude(MaskGroundediceLevelsetEnum);
+	this->InputExtrude(MaskGroundediceLevelsetEnum,-1);
 
 	/*Update inputs*/
@@ -3178,6 +3184,6 @@
 
 	/*Extrude inputs*/
-	this->InputExtrude(SurfaceEnum);
-	this->InputExtrude(BaseEnum);
+	this->InputExtrude(SurfaceEnum,-1);
+	this->InputExtrude(BaseEnum,-1);
 }
 /*}}}*/
Index: issm/trunk-jpl/src/c/classes/Elements/Penta.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 18450)
@@ -144,5 +144,5 @@
 		void           GetInputValue(IssmDouble* pvalue,Node* node,int enumtype);
 		Node*          GetNode(int node_number);
-		void	         InputExtrude(int enum_type);
+		void	         InputExtrude(int enum_type,int start);
 		void           InputUpdateFromSolutionOneDof(IssmDouble* solutiong,int enum_type);
 		void           InputUpdateFromSolutionOneDofCollapsed(IssmDouble* solutiong,int enum_type);
Index: issm/trunk-jpl/src/c/classes/Elements/Seg.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 18450)
@@ -130,5 +130,5 @@
 		void        GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type){_error_("not implemented yet");};
 		void        InputDepthAverageAtBase(int enum_type,int average_enum_type){_error_("not implemented yet");};
-		void        InputExtrude(int enum_type){_error_("not implemented"); /*For penta only*/};
+		void        InputExtrude(int enum_type,int start){_error_("not implemented"); /*For penta only*/};
 		void        InputScale(int enum_type,IssmDouble scale_factor){_error_("not implemented yet");};
 		void        MaterialUpdateFromTemperature(void){_error_("not implemented yet");};
Index: issm/trunk-jpl/src/c/classes/Elements/Tetra.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 18450)
@@ -134,5 +134,5 @@
 		void        GetSolutionFromInputsOneDof(Vector<IssmDouble>* solution,int enum_type){_error_("not implemented yet");};
 		void        InputDepthAverageAtBase(int enum_type,int average_enum_type){_error_("not implemented yet");};
-		void        InputExtrude(int enum_type){_error_("not implemented"); /*For penta only*/};
+		void        InputExtrude(int enum_type,int start){_error_("not implemented"); /*For penta only*/};
 		void        InputScale(int enum_type,IssmDouble scale_factor){_error_("not implemented yet");};
 		void        MaterialUpdateFromTemperature(void){_error_("not implemented yet");};
Index: issm/trunk-jpl/src/c/classes/Elements/Tria.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 18450)
@@ -86,5 +86,5 @@
 		void        GetVerticesCoordinatesTop(IssmDouble** pxyz_list);
 		void        InputDepthAverageAtBase(int enum_type,int average_enum_type);
-		void        InputExtrude(int enum_type){_error_("not implemented"); /*For penta only*/};
+		void        InputExtrude(int enum_type,int start){_error_("not implemented"); /*For penta only*/};
 		void        InputScale(int enum_type,IssmDouble scale_factor);
 		void        MaterialUpdateFromTemperature(void){_error_("not implemented yet");};
Index: issm/trunk-jpl/src/c/classes/Inputs/BoolInput.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/BoolInput.cpp	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/BoolInput.cpp	(revision 18450)
@@ -133,5 +133,5 @@
 }
 /*}}}*/
-void BoolInput::Extrude(void){/*{{{*/
+void BoolInput::Extrude(int start){/*{{{*/
 
 	/*do nothing*/
Index: issm/trunk-jpl/src/c/classes/Inputs/BoolInput.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/BoolInput.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/BoolInput.h	(revision 18450)
@@ -64,5 +64,5 @@
 		void AXPY(Input* xinput,IssmDouble scalar);
 		void Constrain(IssmDouble cm_min, IssmDouble cm_max){_error_("Constrain not implemented for booleans");};
-		void Extrude(void);
+		void Extrude(int start);
 		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
 		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
Index: issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp	(revision 18450)
@@ -121,7 +121,7 @@
 	   values->Constrain(min,max);
 }/*}}}*/
-void ControlInput::Extrude(void){/*{{{*/
-	values->Extrude();
-	savedvalues->Extrude();
+void ControlInput::Extrude(int start){/*{{{*/
+	values->Extrude(start);
+	savedvalues->Extrude(start);
 	//gradient->Extrude();
 }/*}}}*/
Index: issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h	(revision 18450)
@@ -72,5 +72,5 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void){_error_("not implemented yet");};
-		void Extrude(void);
+		void Extrude(int start);
 		void VerticallyIntegrate(Input* thickness_input);
 		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist,const char* data);
Index: issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h	(revision 18450)
@@ -68,5 +68,5 @@
 		IssmDouble Min(void){_error_("not implemented yet");};
 		IssmDouble MinAbs(void){_error_("not implemented yet");};
-		void Extrude(void){_error_("not implemented yet");};
+		void Extrude(int start){_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.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.h	(revision 18450)
@@ -67,5 +67,5 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void);
-		void Extrude(void){_error_("not supported yet");};
+		void Extrude(int start){_error_("not supported yet");};
 		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 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/Input.h	(revision 18450)
@@ -51,5 +51,5 @@
 		virtual void   Constrain(IssmDouble cm_min, IssmDouble cm_max)=0;
 		virtual void   VerticallyIntegrate(Input* thickness_input)=0;
-		virtual void   Extrude()=0;
+		virtual void   Extrude(int start)=0;
 		virtual void   GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist)=0;
 
Index: issm/trunk-jpl/src/c/classes/Inputs/IntInput.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/IntInput.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/IntInput.h	(revision 18450)
@@ -68,5 +68,5 @@
 		IssmDouble Min(void){_error_("Min not implemented for integers");};
 		IssmDouble MinAbs(void){_error_("Min not implemented for integers");};
-		void Extrude(void){_error_("not supported yet");};
+		void Extrude(int start){_error_("not supported yet");};
 		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 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/PentaInput.cpp	(revision 18450)
@@ -291,9 +291,14 @@
 }
 /*}}}*/
-void PentaInput::Extrude(void){/*{{{*/
+void PentaInput::Extrude(int start){/*{{{*/
 
 	switch(this->interpolation_type){
 		case P1Enum:
-			for(int i=0;i<3;i++) this->values[3+i]=this->values[i];
+			if(start==-1){
+				for(int i=0;i<3;i++) this->values[3+i]=this->values[i];
+			}
+			else{
+				for(int i=3;i<6;i++) this->values[i]  =this->values[3+i];
+			}
 			break;
 		default:
Index: issm/trunk-jpl/src/c/classes/Inputs/PentaInput.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/PentaInput.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/PentaInput.h	(revision 18450)
@@ -68,5 +68,5 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void);
-		void Extrude(void);
+		void Extrude(int start);
 		void VerticallyIntegrate(Input* thickness_input);
 		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
Index: issm/trunk-jpl/src/c/classes/Inputs/SegInput.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/SegInput.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/SegInput.h	(revision 18450)
@@ -69,5 +69,5 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void){_error_("not implemented yet");};
-		void Extrude(void){_error_("not supported yet");};
+		void Extrude(int start){_error_("not supported 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.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/TetraInput.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/TetraInput.h	(revision 18450)
@@ -69,5 +69,5 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void);
-		void Extrude(void){_error_("not supported yet");};
+		void Extrude(int start){_error_("not supported yet");};
 		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 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp	(revision 18450)
@@ -345,8 +345,8 @@
 }
 /*}}}*/
-void TransientInput::Extrude(void){/*{{{*/
+void TransientInput::Extrude(int start){/*{{{*/
 
 	for(int i=0;i<this->numtimesteps;i++){
-		((Input*)this->inputs->GetObjectByOffset(i))->Extrude();
+		((Input*)this->inputs->GetObjectByOffset(i))->Extrude(start);
 	}
 }
Index: issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h	(revision 18450)
@@ -73,5 +73,5 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void);
-		void Extrude(void);
+		void Extrude(int start);
 		void VerticallyIntegrate(Input* thickness_forcing){_error_("not supported yet");};
 		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
Index: issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h	(revision 18446)
+++ issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h	(revision 18450)
@@ -69,5 +69,5 @@
 		IssmDouble Min(void);
 		IssmDouble MinAbs(void);
-		void Extrude(void){_error_("not supported yet");};
+		void Extrude(int start){_error_("not supported yet");};
 		void VerticallyIntegrate(Input* thickness_input){_error_("not supported yet");};
 		void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist);
Index: issm/trunk-jpl/src/c/cores/extrudefrombase_core.cpp
===================================================================
--- issm/trunk-jpl/src/c/cores/extrudefrombase_core.cpp	(revision 18446)
+++ issm/trunk-jpl/src/c/cores/extrudefrombase_core.cpp	(revision 18450)
@@ -27,5 +27,5 @@
 	if(elementtype==PentaEnum){
 		int inputenum; femmodel->parameters->FindParam(&inputenum,InputToExtrudeEnum);
-		InputExtrudex(femmodel,inputenum);
+		InputExtrudex(femmodel,inputenum,-1);
 	}
 	else{
Index: issm/trunk-jpl/src/c/modules/InputExtrudex/InputExtrudex.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputExtrudex/InputExtrudex.cpp	(revision 18446)
+++ issm/trunk-jpl/src/c/modules/InputExtrudex/InputExtrudex.cpp	(revision 18450)
@@ -8,8 +8,8 @@
 #include "../../toolkits/toolkits.h"
 
-void InputExtrudex(FemModel* femmodel,int input_enum){
+void InputExtrudex(FemModel* femmodel,int input_enum,int start){
 	for(int i=0;i<femmodel->elements->Size();i++){
 		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
-		element->InputExtrude(input_enum);
+		element->InputExtrude(input_enum,start);
 	}
 }
Index: issm/trunk-jpl/src/c/modules/InputExtrudex/InputExtrudex.h
===================================================================
--- issm/trunk-jpl/src/c/modules/InputExtrudex/InputExtrudex.h	(revision 18446)
+++ issm/trunk-jpl/src/c/modules/InputExtrudex/InputExtrudex.h	(revision 18450)
@@ -9,5 +9,5 @@
 
 /* local prototypes: */
-void InputExtrudex(FemModel* femmodel,int input_enum);
+void InputExtrudex(FemModel* femmodel,int input_enum,int start);
 
 #endif  /* _INPUTDUPLICATEX_H */
