Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 17640)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 17641)
@@ -448,4 +448,86 @@
 int Penta::FiniteElement(void){
 	return this->element_type;
+}
+/*}}}*/
+/*FUNCTION Penta::FSContactMigration{{{*/
+void Penta::FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating){
+
+	if(!IsOnBase()) return;
+
+	/*Intermediaries*/
+	IssmDouble* xyz_list = NULL;
+	IssmDouble  pressure,water_pressure,sigma_nn,viscosity,bed,base;
+	IssmDouble  bed_normal[3];
+	IssmDouble  epsilon[6]; /* epsilon=[exx eyy ezz exy exz eyz];*/
+	IssmDouble  surface=0,value=0;
+	bool grounded;
+
+	/* Get node coordinates and dof list: */
+	GetVerticesCoordinates(&xyz_list);
+
+	/*Retrieve all inputs we will be needing: */
+	Input* pressure_input = inputs->GetInput(PressureEnum); _assert_(pressure_input);
+	Input* base_input     = inputs->GetInput(BaseEnum);     _assert_(base_input);
+	Input* bed_input      = inputs->GetInput(BedEnum);      _assert_(bed_input);
+	Input* vx_input       = inputs->GetInput(VxEnum);       _assert_(vx_input);
+	Input* vy_input       = inputs->GetInput(VyEnum);       _assert_(vy_input);
+	Input* vz_input       = inputs->GetInput(VzEnum);       _assert_(vz_input);
+
+	/*Create gauss point in the middle of the basal edge*/
+	Gauss* gauss=NewGaussBase(1);
+	gauss->GaussPoint(0);
+
+	if(!IsFloating()){ 
+		/*Check for basal force only if grounded and touching GL*/
+		if(this->inputs->Min(MaskGroundediceLevelsetEnum)==0.){
+			this->StrainRateFS(&epsilon[0],xyz_list,gauss,vx_input,vy_input,vz_input);
+			this->ViscosityFS(&viscosity,3,xyz_list,gauss,vx_input,vy_input,vz_input);
+			pressure_input->GetInputValue(&pressure, gauss);
+			base_input->GetInputValue(&base, gauss); _assert_(base<0.);
+
+			/*Compute Stress*/
+			IssmDouble sigma_xx=2.*viscosity*epsilon[0]-pressure;
+			IssmDouble sigma_yy=2.*viscosity*epsilon[1]-pressure;
+			IssmDouble sigma_zz=2.*viscosity*epsilon[2]-pressure;
+			IssmDouble sigma_xy=2.*viscosity*epsilon[3];
+			IssmDouble sigma_xz=2.*viscosity*epsilon[4];
+			IssmDouble sigma_yz=2.*viscosity*epsilon[5];
+
+			/*Get normal vector to the bed */
+			NormalBase(&bed_normal[0],xyz_list);
+
+			/*basalforce*/
+			sigma_nn = sigma_xx*bed_normal[0]*bed_normal[0] + sigma_yy*bed_normal[1]*bed_normal[1] + sigma_zz*bed_normal[2]*bed_normal[2] 
+			  + 2.*sigma_xy*bed_normal[0]*bed_normal[1] + 2.*sigma_xz*bed_normal[0]*bed_normal[2] + 2.*sigma_yz*bed_normal[1]*bed_normal[2];
+
+			/*Compute water pressure*/
+			IssmDouble rho_ice   = matpar->GetRhoIce();
+			IssmDouble rho_water = matpar->GetRhoWater();
+			IssmDouble gravity   = matpar->GetG();
+			water_pressure=gravity*rho_water*base;
+
+			/*Compare basal stress to water pressure and determine whether it should ground*/
+			if (sigma_nn<water_pressure) grounded=true;
+			else                         grounded=false;
+		}
+		else{
+			grounded=true;
+		}
+	}
+	else{
+		/*Check for basal elevation if floating*/
+		base_input->GetInputValue(&base, gauss);
+		bed_input->GetInputValue(&bed, gauss);
+		if (base<bed) grounded=true;
+		else          grounded=false;
+	}
+	for(int i=0;i<NUMVERTICES;i++){
+		if(grounded) vertexgrounded->SetValue(vertices[i]->Pid(),+1.,INS_VAL);
+		else         vertexfloating->SetValue(vertices[i]->Pid(),+1.,INS_VAL);
+	}
+
+	/*clean up*/
+	delete gauss;
+	xDelete<IssmDouble>(xyz_list);
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 17640)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 17641)
@@ -60,5 +60,5 @@
 		void   ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz);
 		int    FiniteElement(void);
-		void   FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating){_error_("not implemented yet");};
+		void   FSContactMigration(Vector<IssmDouble>* vertexgrounded,Vector<IssmDouble>* vertexfloating);
 		void   SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters);
 		void   Delta18oParameterization(void);
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 17640)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 17641)
@@ -1344,31 +1344,31 @@
 
 	if(!IsFloating()){ 
-
+		/*Check for basal force only if grounded and touching GL*/
 		if(this->inputs->Min(MaskGroundediceLevelsetEnum)==0.){
-		this->StrainRateSSA(&epsilon[0],xyz_list,gauss,vx_input,vy_input);
-		this->ViscosityFS(&viscosity,2,xyz_list,gauss,vx_input,vy_input,NULL);
-		pressure_input->GetInputValue(&pressure, gauss);
-		base_input->GetInputValue(&base, gauss); _assert_(base<0.);
-
-		/*Compute Stress*/
-		IssmDouble sigma_xx=2.*viscosity*epsilon[0]-pressure;
-		IssmDouble sigma_yy=2.*viscosity*epsilon[1]-pressure;
-		IssmDouble sigma_xy=2.*viscosity*epsilon[2];
-
-		/*Get normal vector to the bed */
-		NormalBase(&bed_normal[0],xyz_list);
-
-		/*basalforce*/
-		sigma_nn = sigma_xx*bed_normal[0]*bed_normal[0] + sigma_yy*bed_normal[1]*bed_normal[1] + 2.*sigma_xy*bed_normal[0]*bed_normal[1];
-
-		/*Compute water pressure*/
-		IssmDouble rho_ice   = matpar->GetRhoIce();
-		IssmDouble rho_water = matpar->GetRhoWater();
-		IssmDouble gravity   = matpar->GetG();
-		water_pressure=gravity*rho_water*base;
-
-		/*Compare basal stress to water pressure and determine whether it should ground*/
-		if (sigma_nn<water_pressure) grounded=true;
-		else                         grounded=false;
+			this->StrainRateSSA(&epsilon[0],xyz_list,gauss,vx_input,vy_input);
+			this->ViscosityFS(&viscosity,2,xyz_list,gauss,vx_input,vy_input,NULL);
+			pressure_input->GetInputValue(&pressure, gauss);
+			base_input->GetInputValue(&base, gauss); _assert_(base<0.);
+
+			/*Compute Stress*/
+			IssmDouble sigma_xx=2.*viscosity*epsilon[0]-pressure;
+			IssmDouble sigma_yy=2.*viscosity*epsilon[1]-pressure;
+			IssmDouble sigma_xy=2.*viscosity*epsilon[2];
+
+			/*Get normal vector to the bed */
+			NormalBase(&bed_normal[0],xyz_list);
+
+			/*basalforce*/
+			sigma_nn = sigma_xx*bed_normal[0]*bed_normal[0] + sigma_yy*bed_normal[1]*bed_normal[1] + 2.*sigma_xy*bed_normal[0]*bed_normal[1];
+
+			/*Compute water pressure*/
+			IssmDouble rho_ice   = matpar->GetRhoIce();
+			IssmDouble rho_water = matpar->GetRhoWater();
+			IssmDouble gravity   = matpar->GetG();
+			water_pressure=gravity*rho_water*base;
+
+			/*Compare basal stress to water pressure and determine whether it should ground*/
+			if (sigma_nn<water_pressure) grounded=true;
+			else                         grounded=false;
 		}
 		else{
@@ -1377,4 +1377,5 @@
 	}
 	else{
+		/*Check for basal elevation if floating*/
 		base_input->GetInputValue(&base, gauss);
 		bed_input->GetInputValue(&bed, gauss);
Index: /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 17640)
+++ /issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 17641)
@@ -94,5 +94,5 @@
 		}
 		else{
-			_error_("not supported");
+			_error_("not supported (vertexfloating="<<serial_vertexfloating[i]<<" vertexgrounded="<<serial_vertexgrounded[i]<<")");
 		}
 	}
