Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 10320)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 10321)
@@ -285,5 +285,5 @@
 	double  bed_hydro;
 	double  rho_water,rho_ice,density;
-	double  h[3],s[3],b[3],ba[3];
+	double  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
 
 	/*vertices and material parameters: */
@@ -297,7 +297,7 @@
 
 	/*go through vertices, and update inputs, considering them to be TriaVertex type: */
-	for(i=0;i<3;i++){
+	for(i=0;i<NUMVERTICES;i++){
+		/*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */
 		if (nodes[i]->IsFloating()){
-			/*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */
 			if(b[i]<=ba[i]){ 
 				b[i]=ba[i];
@@ -305,6 +305,6 @@
 			}
 		}
+		/*Ice sheet: if hydrostatic bed above bathymetry, the ice sheet start to unground, elso do nothing */
 		else{
-			/*Ice sheet: if hydrostatic bed above bathymetry, the ice sheet start to unground, elso do nothing */
 			bed_hydro=-density*h[i];
 			if (bed_hydro>ba[i]){
@@ -315,5 +315,5 @@
 	}
 
-	/*Surface and bed are updated. Update inputs:*/
+	/*Update inputs*/
 	this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,&s[0]));
 	this->inputs->AddInput(new TriaVertexInput(BedEnum,&b[0]));
@@ -2241,6 +2241,4 @@
 	GetInputListOnVertices(&b[0],BedEnum);
 	GetInputListOnVertices(&ba[0],BathymetryEnum);
-
-	/*material parameters: */
 	rho_water=matpar->GetRhoWater();
 	rho_ice=matpar->GetRhoIce();
@@ -2249,35 +2247,25 @@
 	/*go through vertices, and update inputs, considering them to be TriaVertex type: */
 	for(i=0;i<NUMVERTICES;i++){
+		/*Ice shelf: if bed below bathymetry, impose it at the bathymetry and update surface, elso do nothing */
 		if (nodes[i]->IsFloating()){
-			/*This node is on the shelf. See if its bed is going under the bathymetry: */
-			if(b[i]<=ba[i]){ //<= because Neff being 0 when b=ba, drag will be 0 anyway.
-				/*The ice shelf is getting grounded, the thickness is the same, so just update the bed to stick to the bathymetry and elevate the surface accordingly: */
+			if(b[i]<=ba[i]){ 
 				b[i]=ba[i];
 				s[i]=b[i]+h[i];
 			}
-			else{
-				/*do nothing, we are still floating.*/
-			}
 		}
+		/*Ice sheet: if hydrostatic bed above bathymetry, the ice sheet starts to unground if it is connected to the ice shelf, elso do nothing */
 		else{
-			/*This node is on the sheet, near the grounding line. See if wants to unground. To 
-			 * do so, we compute the hydrostatic bed, and if it is > bathymetry, then we unground: */
 			bed_hydro=-density*h[i];
 			if (bed_hydro>ba[i]){
-
-				/*Now, are we connected to the grounding line, if so, go forward, otherwise, bail out: */
+				/*Unground only if the element is connected to the ice shelf*/
 				if(sheet_ungrounding[nodes[i]->Sid()]){
-					/*We are now floating, bed and surface are determined from hydrostatic equilibrium: */
 					s[i]=(1-density)*h[i];
 					b[i]=-density*h[i];
 				}
 			}
-			else{
-				/*do nothing, we are still grounded.*/
-			}
 		}
 	}
 
-	/*Surface and bed are updated. Update inputs:*/    
+	/*Update inputs*/    
 	this->inputs->AddInput(new TriaVertexInput(SurfaceEnum,&s[0]));
 	this->inputs->AddInput(new TriaVertexInput(BedEnum,&b[0]));
