Index: /issm/trunk-jpl/src/c/analyses/FreeSurfaceBaseAnalysis.cpp
===================================================================
--- /issm/trunk-jpl/src/c/analyses/FreeSurfaceBaseAnalysis.cpp	(revision 28154)
+++ /issm/trunk-jpl/src/c/analyses/FreeSurfaceBaseAnalysis.cpp	(revision 28155)
@@ -424,9 +424,9 @@
 	Gauss*      gauss     = NULL;
 	if(melt_style==SubelementMelt2Enum){
-		basalelement->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+		basalelement->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,MaskOceanLevelsetEnum,0);
 		gauss = basalelement->NewGauss(point1,fraction1,fraction2,3);
 	}
 	if(melt_style==IntrusionMeltEnum){
-		basalelement->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+		basalelement->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,DistanceToGroundinglineEnum,intrusiondist);
 		gauss = basalelement->NewGauss(point1,fraction1,fraction2,3);
 	}
Index: /issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp
===================================================================
--- /issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp	(revision 28154)
+++ /issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp	(revision 28155)
@@ -670,10 +670,10 @@
 	phi=element->GetGroundedPortion(xyz_list);
 	if(melt_style==SubelementMelt2Enum){
-		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,MaskOceanLevelsetEnum,0);
 	    gauss = element->NewGauss(point1,fraction1,fraction2,3);
 	}
 	else if(melt_style==IntrusionMeltEnum){
-	    element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
-       gauss = element->NewGauss(point1,fraction1,fraction2,3);
+		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,DistanceToGroundinglineEnum,intrusiondist);
+       	gauss = element->NewGauss(point1,fraction1,fraction2,3);
 	}
 	else{
@@ -804,9 +804,9 @@
    phi=element->GetGroundedPortion(xyz_list);
    if(melt_style==SubelementMelt2Enum){
-      element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+      element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,MaskOceanLevelsetEnum,0);
       gauss = element->NewGauss(point1,fraction1,fraction2,3);
    }
    else if(melt_style==IntrusionMeltEnum){
-	    element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+	    element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,DistanceToGroundinglineEnum,intrusiondist);
        gauss = element->NewGauss(point1,fraction1,fraction2,3);
 	}
@@ -1145,5 +1145,5 @@
 	phi=element->GetGroundedPortion(xyz_list);
 	if(melt_style==SubelementMelt2Enum){
-		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,MaskOceanLevelsetEnum,0);
 	   gauss = element->NewGauss(point1,fraction1,fraction2,3);
 	}
Index: /issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp
===================================================================
--- /issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp	(revision 28154)
+++ /issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp	(revision 28155)
@@ -1366,5 +1366,5 @@
 	if(friction_style==SubelementFriction2Enum){
 		gllevelset_input=element->GetInput(MaskOceanLevelsetEnum); _assert_(gllevelset_input);
-		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating, MaskOceanLevelsetEnum,0);
 	   gauss = element->NewGauss(point1,fraction1,fraction2,mainlyfloating,2);
 	}
@@ -1646,5 +1646,5 @@
 	int ig=-1;// needed for driving stress parameterization
 	if(partly_floating){
-		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating, MaskOceanLevelsetEnum,0);
 	   gauss=element->NewGauss(point1,fraction1,fraction2,3); //considering the entire element
 		gauss_subelem=element->NewGauss(fraction1,fraction2,3);//gauss on each subelement
@@ -2682,5 +2682,5 @@
 	if(friction_style==SubelementFriction2Enum){
 		gllevelset_input=element->GetInput(MaskOceanLevelsetEnum); _assert_(gllevelset_input);
-		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,MaskOceanLevelsetEnum,0);
 	   gauss = element->NewGauss(point1,fraction1,fraction2,mainlyfloating,2);
 	}
@@ -3310,5 +3310,5 @@
 	if(friction_style==SubelementFriction2Enum){
 		gllevelset_input=element->GetInput(MaskOceanLevelsetEnum); _assert_(gllevelset_input);
-		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating, MaskOceanLevelsetEnum,0);
 		gauss = element->NewGauss(point1,fraction1,fraction2,mainlyfloating,2);
 	}
@@ -5029,5 +5029,5 @@
 		if(domaintype==Domain2DverticalEnum) _error_("Subelement Friction 2 not implemented yet for Flowline");
 		gllevelset_input=element->GetInput(MaskOceanLevelsetEnum); _assert_(gllevelset_input);
-		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating, MaskOceanLevelsetEnum,0);
 		//gauss = element->NewGauss(point1,fraction1,fraction2,mainlyfloating,2);
 		gauss=element->NewGaussBase(3);
@@ -5267,5 +5267,5 @@
 		if(domaintype==Domain2DverticalEnum) _error_("Subelement Friction 2 not implemented yet for Flowline");
 		gllevelset_input=element->GetInput(MaskOceanLevelsetEnum); _assert_(gllevelset_input);
-		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+		element->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating, MaskOceanLevelsetEnum,0);
 		gauss=element->NewGaussBase(3);
 	}
Index: /issm/trunk-jpl/src/c/classes/Elements/Element.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 28154)
+++ /issm/trunk-jpl/src/c/classes/Elements/Element.h	(revision 28155)
@@ -273,5 +273,5 @@
 		virtual int        GetElementType(void)=0;
 		virtual IssmDouble GetHorizontalSurfaceArea(void){_error_("not implemented");};
-		virtual void       GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating)=0;
+		virtual void       GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating,int distance_enum, IssmDouble intrusion_distance)=0;
 		virtual IssmDouble GetGroundedPortion(IssmDouble* xyz_list)=0;
 		virtual void        GetFractionGeometry(IssmDouble* weights, IssmDouble* pphi, int* ppoint1,IssmDouble* pfraction1,IssmDouble* pfraction2, bool* ptrapezeisnegative, IssmDouble* gl)=0;
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 28154)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 28155)
@@ -1434,9 +1434,9 @@
 }
 /*}}}*/
-void       Penta::GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating){/*{{{*/
+void       Penta::GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating, int distance_enum, IssmDouble intrusion_distance){/*{{{*/
 	/*Computeportion of the element that is grounded*/
 
 	bool               floating=true;
-	int                point;
+	int                point, i;
 	const IssmPDouble  epsilon= 1.e-15;
 	IssmDouble         gl[NUMVERTICES];
@@ -1444,5 +1444,10 @@
 
 	/*Recover parameters and values*/
-	Element::GetInputListOnVertices(&gl[0],MaskOceanLevelsetEnum);
+	Element::GetInputListOnVertices(&gl[0],distance_enum);
+
+	/*Determine where to apply sub-element melt using intrusion distance*/
+	for (i; i<NUMVERTICES; i++){
+		gl[i] -= intrusion_distance;
+	}
 
 	/*Be sure that values are not zero*/
@@ -4249,5 +4254,5 @@
 	::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
 
-	this->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+	this->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,MaskOceanLevelsetEnum,0);
 	/* Start  looping on the number of gaussian points: */
 	gauss = this->NewGauss(point1,fraction1,fraction2,1-mainlyfloating,3);
@@ -4292,5 +4297,5 @@
 	::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
 
-	this->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+	this->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,MaskOceanLevelsetEnum,0);
 	/* Start  looping on the number of gaussian points: */
 	gauss = this->NewGauss(point1,fraction1,fraction2,mainlyfloating,3);
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 28154)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.h	(revision 28155)
@@ -86,5 +86,5 @@
 		Penta*         GetBasalPenta(void);
 		int            GetElementType(void);
-		void           GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating);
+		void           GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating, int distance_enum, IssmDouble intrusion_distance);
 		IssmDouble     GetGroundedPortion(IssmDouble* xyz_list);
 		void           GetFractionGeometry(IssmDouble* weights, IssmDouble* pphi, int* ppoint1,IssmDouble* pfraction1,IssmDouble* pfraction2, bool* ptrapezeisnegative, IssmDouble* gl){_error_("not implemented yet");};
Index: /issm/trunk-jpl/src/c/classes/Elements/Seg.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 28154)
+++ /issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 28155)
@@ -62,5 +62,5 @@
 		Element*    GetBasalElement(void){_error_("not implemented yet");};
 		int         GetElementType(void){_error_("not implemented yet");};
-		void        GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating){_error_("not implemented yet");};
+		void        GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating, int distance_enum, IssmDouble intrusion_distance){_error_("not implemented yet");};
 		IssmDouble  GetGroundedPortion(IssmDouble* xyz_list);
 		void        GetFractionGeometry(IssmDouble* weights, IssmDouble* pphi, int* ppoint1,IssmDouble* pfraction1,IssmDouble* pfraction2, bool* ptrapezeisnegative, IssmDouble* gl){_error_("not implemented yet");};
Index: /issm/trunk-jpl/src/c/classes/Elements/Tetra.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 28154)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tetra.h	(revision 28155)
@@ -67,5 +67,5 @@
 		Element*    GetBasalElement(void){_error_("not implemented yet");};
 		int         GetElementType(void);
-		void        GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating){_error_("not implemented yet");};
+		void        GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating, int distance_enum, IssmDouble intrusion_distance){_error_("not implemented yet");};
 		IssmDouble  GetGroundedPortion(IssmDouble* xyz_list){_error_("not implemented yet");};
 		void        GetFractionGeometry(IssmDouble* weights, IssmDouble* pphi, int* ppoint1,IssmDouble* pfraction1,IssmDouble* pfraction2, bool* ptrapezeisnegative, IssmDouble* gl){_error_("not implemented yet");};
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 28154)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 28155)
@@ -2053,9 +2053,9 @@
 }
 /*}}}*/
-void       Tria::GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* pmainlyfloating){/*{{{*/
-	/*Computeportion of the element that is grounded*/
+void       Tria::GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* pmainlyfloating, int distance_enum, IssmDouble intrusion_distance){/*{{{*/
+	/*Compute portion of the element that is grounded*/
 
 	bool               floating=true;
-	int                point;
+	int                point, i;
 	const IssmPDouble  epsilon= 1.e-15;
 	IssmDouble         gl[NUMVERTICES];
@@ -2063,5 +2063,10 @@
 
 	/*Recover parameters and values*/
-	Element::GetInputListOnVertices(&gl[0],MaskOceanLevelsetEnum);
+	Element::GetInputListOnVertices(&gl[0],distance_enum);
+	
+	/*Determine where to apply sub-element melt using intrusion distance*/
+	for (i; i<NUMVERTICES; i++){
+		gl[i] -= intrusion_distance;
+	}
 
 	/*Be sure that values are not zero*/
@@ -5761,5 +5766,5 @@
 	::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
 
-	this->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+	this->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,MaskOceanLevelsetEnum,0);
 	/* Start  looping on the number of gaussian points: */
 	gauss = this->NewGauss(point1,fraction1,fraction2,1-mainlyfloating,3);
@@ -5804,5 +5809,5 @@
 	::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES);
 
-	this->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating);
+	this->GetGroundedPart(&point1,&fraction1,&fraction2,&mainlyfloating,MaskOceanLevelsetEnum,0);
 	/* Start  looping on the number of gaussian points: */
 	gauss = this->NewGauss(point1,fraction1,fraction2,mainlyfloating,2);
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 28154)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 28155)
@@ -89,5 +89,5 @@
 		Element*    GetBasalElement(void){_error_("not implemented yet");};
 		void        GetLevelsetPositivePart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlynegative,IssmDouble* levelsetvalues);
-		void        GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating);
+		void        GetGroundedPart(int* point1,IssmDouble* fraction1, IssmDouble* fraction2,bool* mainlyfloating, int distance_enum, IssmDouble intrusion_distance);
 		IssmDouble  GetGroundedPortion(IssmDouble* xyz_list);
 		void        GetFractionGeometry(IssmDouble* weights, IssmDouble* pphi, int* ppoint1,IssmDouble* pfraction1,IssmDouble* pfraction2, bool* ptrapezeisnegative, IssmDouble* gl);
