Index: /issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp
===================================================================
--- /issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp	(revision 24096)
+++ /issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp	(revision 24097)
@@ -808,24 +808,13 @@
 	if(!element->IsOnBase()) return;
 
-	/*Get basal element*/
-	int domaintype; element->FindParam(&domaintype,DomainTypeEnum);
-   Element* basalelement=element;
-	if(domaintype!=Domain2DhorizontalEnum) basalelement = element->SpawnBasalElement();
-
-	/*Fetch number of nodes and dof for this finite element*/
-	int numnodes    = basalelement->GetNumberOfNodes();
-   int numvertices = basalelement->GetNumberOfVertices();
-
-   /*Keep old thickness for later*/
-	IssmDouble* oldthickness = xNew<IssmDouble>(numvertices);
-   basalelement->GetInputListOnNodes(&oldthickness[0],ThicknessEnum);
-
 	/*Fetch dof list and allocate solution vector*/
 	int *doflist = NULL;
 	element->GetDofListLocal(&doflist,NoneApproximationEnum,GsetEnum);
+
+	int numnodes = element->GetNumberOfNodes();
 	IssmDouble* newthickness = xNew<IssmDouble>(numnodes);
 
 	/*Use the dof list to index into the solution vector: */
-   IssmDouble minthickness = basalelement->FindParam(MasstransportMinThicknessEnum);
+   IssmDouble minthickness = element->FindParam(MasstransportMinThicknessEnum);
 	for(int i=0;i<numnodes;i++){
 		newthickness[i]=solution[doflist[i]];
@@ -835,13 +824,21 @@
       if(newthickness[i]<minthickness) newthickness[i]=minthickness;
 	}
-
 	element->AddBasalInput(ThicknessEnum,newthickness,element->GetElementType());
-
-	/*Free ressources:*/
+	xDelete<int>(doflist);
 	xDelete<IssmDouble>(newthickness);
-	xDelete<int>(doflist);
+
+	/*Update bed and surface accordingly*/
+
+	/*Get basal element*/
+	int domaintype; element->FindParam(&domaintype,DomainTypeEnum);
+   Element* basalelement=element;
+	if(domaintype!=Domain2DhorizontalEnum) basalelement = element->SpawnBasalElement();
+
+	/*Fetch number of nodes and dof for this finite element*/
+   int numvertices = basalelement->GetNumberOfVertices();
 
 	/*Now, we need to do some "processing"*/
    newthickness  = xNew<IssmDouble>(numvertices);
+	IssmDouble* oldthickness      = xNew<IssmDouble>(numvertices);
 	IssmDouble* cumdeltathickness = xNew<IssmDouble>(numvertices);
 	IssmDouble* deltathickness    = xNew<IssmDouble>(numvertices);
@@ -856,4 +853,5 @@
 	/*Get previous base, thickness, surfac and current sealevel and bed:*/
    basalelement->GetInputListOnVertices(&newthickness[0],ThicknessEnum);
+	basalelement->GetInputListOnVertices(&oldthickness[0],ThicknessOldEnum);
 	basalelement->GetInputListOnVertices(&oldbase[0],BaseEnum);
 	basalelement->GetInputListOnVertices(&oldsurface[0],SurfaceEnum);
@@ -869,6 +867,6 @@
 	/*What is the delta thickness forcing the sea-level rise core: cumulated over time, hence the +=:*/
 	for(int i=0;i<numvertices;i++){
-		cumdeltathickness[i]+=newthickness[i]-oldthickness[i];
-		deltathickness[i]=newthickness[i]-oldthickness[i];
+		cumdeltathickness[i] += newthickness[i]-oldthickness[i];
+		deltathickness[i]     = newthickness[i]-oldthickness[i];
 	}
 
@@ -880,6 +878,5 @@
 
 	for(int i=0;i<numvertices;i++) {
-		if (phi[i]>0.){ //this is an ice sheet: just add thickness to base.
-			/*Update! actually, the bed has moved too!:*/
+		if (phi[i]>0.){ //this is grounded ice: just add thickness to base.
 			if(isgroundingline){
 				newsurface[i] = bed[i]+newthickness[i]; //surface = bed + newthickness
@@ -888,5 +885,5 @@
 			else{
 				 newsurface[i] = oldbase[i]+newthickness[i]; //surface = oldbase + newthickness
-				 newbase[i]     = oldbase[i];                 //same base: do nothing
+				 newbase[i]    = oldbase[i];                 //same base: do nothing
 			}
 		}
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 24096)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 24097)
@@ -1808,5 +1808,5 @@
 	/*Fetch dof list and allocate solution vector*/
 	GetDofListLocal(&doflist,NoneApproximationEnum,GsetEnum);
-	IssmDouble* values    = xNew<IssmDouble>(numnodes);
+	IssmDouble* values = xNew<IssmDouble>(numnodes);
 
 	/*Use the dof list to index into the solution vector: */
Index: /issm/trunk-jpl/src/c/cores/masstransport_core.cpp
===================================================================
--- /issm/trunk-jpl/src/c/cores/masstransport_core.cpp	(revision 24096)
+++ /issm/trunk-jpl/src/c/cores/masstransport_core.cpp	(revision 24097)
@@ -61,4 +61,5 @@
 		}
 		femmodel->SetCurrentConfiguration(MasstransportAnalysisEnum);
+		InputDuplicatex(femmodel,ThicknessEnum,ThicknessOldEnum);
 		if(stabilization==4){
 			solutionsequence_fct(femmodel);
Index: /issm/trunk-jpl/src/c/shared/Enum/Enum.vim
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/Enum.vim	(revision 24096)
+++ /issm/trunk-jpl/src/c/shared/Enum/Enum.vim	(revision 24097)
@@ -781,4 +781,5 @@
 syn keyword cConstant ThicknessAlongGradientEnum
 syn keyword cConstant ThicknessEnum
+syn keyword cConstant ThicknessOldEnum
 syn keyword cConstant ThicknessPositiveEnum
 syn keyword cConstant VelEnum
@@ -1281,4 +1282,5 @@
 syn keyword cType Cfsurfacesquare
 syn keyword cType Channel
+syn keyword cType classes
 syn keyword cType Constraint
 syn keyword cType Constraints
@@ -1287,6 +1289,6 @@
 syn keyword cType ControlInput
 syn keyword cType Covertree
+syn keyword cType DatasetInput
 syn keyword cType DataSetParam
-syn keyword cType DatasetInput
 syn keyword cType Definition
 syn keyword cType DependentObject
@@ -1301,6 +1303,6 @@
 syn keyword cType ElementHook
 syn keyword cType ElementMatrix
+syn keyword cType Elements
 syn keyword cType ElementVector
-syn keyword cType Elements
 syn keyword cType ExponentialVariogram
 syn keyword cType ExternalResult
@@ -1309,9 +1311,10 @@
 syn keyword cType Friction
 syn keyword cType Gauss
+syn keyword cType GaussianVariogram
+syn keyword cType gaussobjects
 syn keyword cType GaussPenta
 syn keyword cType GaussSeg
 syn keyword cType GaussTetra
 syn keyword cType GaussTria
-syn keyword cType GaussianVariogram
 syn keyword cType GenericExternalResult
 syn keyword cType GenericOption
@@ -1321,4 +1324,5 @@
 syn keyword cType Input
 syn keyword cType Inputs
+syn keyword cType IntArrayInput
 syn keyword cType IntInput
 syn keyword cType IntMatParam
@@ -1328,4 +1332,5 @@
 syn keyword cType IssmDirectApplicInterface
 syn keyword cType IssmParallelDirectApplicInterface
+syn keyword cType krigingobjects
 syn keyword cType Load
 syn keyword cType Loads
@@ -1338,4 +1343,5 @@
 syn keyword cType Matice
 syn keyword cType Matlitho
+syn keyword cType matrixobjects
 syn keyword cType MatrixParam
 syn keyword cType Misfit
@@ -1350,6 +1356,6 @@
 syn keyword cType Observations
 syn keyword cType Option
+syn keyword cType Options
 syn keyword cType OptionUtilities
-syn keyword cType Options
 syn keyword cType Param
 syn keyword cType Parameters
@@ -1364,10 +1370,10 @@
 syn keyword cType Regionaloutput
 syn keyword cType Results
+syn keyword cType Riftfront
 syn keyword cType RiftStruct
-syn keyword cType Riftfront
 syn keyword cType Seg
 syn keyword cType SegInput
+syn keyword cType Segment
 syn keyword cType SegRef
-syn keyword cType Segment
 syn keyword cType SpcDynamic
 syn keyword cType SpcStatic
@@ -1389,8 +1395,4 @@
 syn keyword cType Vertex
 syn keyword cType Vertices
-syn keyword cType classes
-syn keyword cType gaussobjects
-syn keyword cType krigingobjects
-syn keyword cType matrixobjects
 syn keyword cType AdjointBalancethickness2Analysis
 syn keyword cType AdjointBalancethicknessAnalysis
@@ -1411,6 +1413,6 @@
 syn keyword cType FreeSurfaceBaseAnalysis
 syn keyword cType FreeSurfaceTopAnalysis
+syn keyword cType GiaIvinsAnalysis
 syn keyword cType GLheightadvectionAnalysis
-syn keyword cType GiaIvinsAnalysis
 syn keyword cType HydrologyDCEfficientAnalysis
 syn keyword cType HydrologyDCInefficientAnalysis
Index: /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 24096)
+++ /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 24097)
@@ -777,4 +777,5 @@
 	ThicknessAlongGradientEnum,
 	ThicknessEnum,
+	ThicknessOldEnum,
 	ThicknessPositiveEnum,
 	VelEnum,
Index: /issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 24096)
+++ /issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 24097)
@@ -783,4 +783,5 @@
 		case ThicknessAlongGradientEnum : return "ThicknessAlongGradient";
 		case ThicknessEnum : return "Thickness";
+		case ThicknessOldEnum : return "ThicknessOld";
 		case ThicknessPositiveEnum : return "ThicknessPositive";
 		case VelEnum : return "Vel";
Index: /issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 24096)
+++ /issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 24097)
@@ -801,4 +801,5 @@
 	      else if (strcmp(name,"ThicknessAlongGradient")==0) return ThicknessAlongGradientEnum;
 	      else if (strcmp(name,"Thickness")==0) return ThicknessEnum;
+	      else if (strcmp(name,"ThicknessOld")==0) return ThicknessOldEnum;
 	      else if (strcmp(name,"ThicknessPositive")==0) return ThicknessPositiveEnum;
 	      else if (strcmp(name,"Vel")==0) return VelEnum;
@@ -874,9 +875,9 @@
 	      else if (strcmp(name,"Outputdefinition55")==0) return Outputdefinition55Enum;
 	      else if (strcmp(name,"Outputdefinition56")==0) return Outputdefinition56Enum;
-	      else if (strcmp(name,"Outputdefinition57")==0) return Outputdefinition57Enum;
          else stage=8;
    }
    if(stage==8){
-	      if (strcmp(name,"Outputdefinition58")==0) return Outputdefinition58Enum;
+	      if (strcmp(name,"Outputdefinition57")==0) return Outputdefinition57Enum;
+	      else if (strcmp(name,"Outputdefinition58")==0) return Outputdefinition58Enum;
 	      else if (strcmp(name,"Outputdefinition59")==0) return Outputdefinition59Enum;
 	      else if (strcmp(name,"Outputdefinition5")==0) return Outputdefinition5Enum;
@@ -997,9 +998,9 @@
 	      else if (strcmp(name,"DoubleInput")==0) return DoubleInputEnum;
 	      else if (strcmp(name,"DoubleMatArrayParam")==0) return DoubleMatArrayParamEnum;
-	      else if (strcmp(name,"DoubleMatExternalResult")==0) return DoubleMatExternalResultEnum;
          else stage=9;
    }
    if(stage==9){
-	      if (strcmp(name,"DoubleMatParam")==0) return DoubleMatParamEnum;
+	      if (strcmp(name,"DoubleMatExternalResult")==0) return DoubleMatExternalResultEnum;
+	      else if (strcmp(name,"DoubleMatParam")==0) return DoubleMatParamEnum;
 	      else if (strcmp(name,"DoubleParam")==0) return DoubleParamEnum;
 	      else if (strcmp(name,"DoubleVecParam")==0) return DoubleVecParamEnum;
@@ -1120,9 +1121,9 @@
 	      else if (strcmp(name,"Matestar")==0) return MatestarEnum;
 	      else if (strcmp(name,"Matice")==0) return MaticeEnum;
-	      else if (strcmp(name,"Matlitho")==0) return MatlithoEnum;
          else stage=10;
    }
    if(stage==10){
-	      if (strcmp(name,"MatrixParam")==0) return MatrixParamEnum;
+	      if (strcmp(name,"Matlitho")==0) return MatlithoEnum;
+	      else if (strcmp(name,"MatrixParam")==0) return MatrixParamEnum;
 	      else if (strcmp(name,"MaxAbsVx")==0) return MaxAbsVxEnum;
 	      else if (strcmp(name,"MaxAbsVy")==0) return MaxAbsVyEnum;
@@ -1243,9 +1244,9 @@
 	      else if (strcmp(name,"StringExternalResult")==0) return StringExternalResultEnum;
 	      else if (strcmp(name,"StringParam")==0) return StringParamEnum;
-	      else if (strcmp(name,"SubelementFriction1")==0) return SubelementFriction1Enum;
          else stage=11;
    }
    if(stage==11){
-	      if (strcmp(name,"SubelementFriction2")==0) return SubelementFriction2Enum;
+	      if (strcmp(name,"SubelementFriction1")==0) return SubelementFriction1Enum;
+	      else if (strcmp(name,"SubelementFriction2")==0) return SubelementFriction2Enum;
 	      else if (strcmp(name,"SubelementMelt1")==0) return SubelementMelt1Enum;
 	      else if (strcmp(name,"SubelementMelt2")==0) return SubelementMelt2Enum;
