Index: /issm/trunk/src/c/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 10319)
+++ /issm/trunk/src/c/objects/Elements/Tria.cpp	(revision 10320)
@@ -286,5 +286,4 @@
 	double  rho_water,rho_ice,density;
 	double  h[3],s[3],b[3],ba[3];
-	double *values         = NULL;
 
 	/*vertices and material parameters: */
@@ -2178,14 +2177,17 @@
 void  Tria::ShelfSync(void){
 
-	int     i,swap;
+	int     i;
+	bool    elementonshelf = false;
 	double  bed_hydro,gl_melting_rate;
 	double  yts,rho_water,rho_ice,density;
 	double  melting[NUMVERTICES];
 	double  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
-	bool    elementonshelf = false;
 
 	/*recover parameters: */
 	parameters->FindParam(&yts,ConstantsYtsEnum);
 	parameters->FindParam(&gl_melting_rate,GroundinglineMeltingRateEnum);
+	rho_water=matpar->GetRhoWater();
+	rho_ice=matpar->GetRhoIce();
+	density=rho_ice/rho_water;
 
 	/*Recover info at the vertices: */
@@ -2194,9 +2196,4 @@
 	GetInputListOnVertices(&b[0],BedEnum);
 	GetInputListOnVertices(&ba[0],BathymetryEnum);
-
-	/*material parameters: */
-	rho_water=matpar->GetRhoWater();
-	rho_ice=matpar->GetRhoIce();
-	density=rho_ice/rho_water;
 
 	/*go through vertices, and update inputs, considering them to be TriaVertex type: */
@@ -2212,7 +2209,5 @@
 	}
 
-	/*Now, update  shelf status of element. An element can only be on shelf if all its nodes are on shelf: */
-	swap=0;
-	elementonshelf=false;
+	/*If at least one vertex is now floating, the element is an iceshelf*/
 	for(i=0;i<NUMVERTICES;i++){
 		if(nodes[i]->IsFloating()){
@@ -2221,12 +2216,13 @@
 		}
 	}
-	if(!this->IsFloating() && elementonshelf==true)swap=1;
-    this->inputs->AddInput(new BoolInput(MaskElementonfloatingiceEnum,elementonshelf));
 	
-    /*If this element just  became ungrounded, set its basal melting rate at 50 m/yr:*/
-	if(swap){
+   /*Add basal melting rate if element just ungrounded*/
+	if(!this->IsFloating() && elementonshelf==true){
 		for(i=0;i<NUMVERTICES;i++)melting[i]=gl_melting_rate/yts;
 		this->inputs->AddInput(new TriaVertexInput(BasalforcingsMeltingRateEnum,&melting[0]));
-	}
+	} 
+
+	/*Update inputs*/
+   this->inputs->AddInput(new BoolInput(MaskElementonfloatingiceEnum,elementonshelf));
 }
 /*}}}*/
@@ -2234,10 +2230,9 @@
 void  Tria::SoftMigration(double* sheet_ungrounding){
 
-	double *values         = NULL;
-	double  h[3],s[3],b[3],ba[3];
+	int     i;
+	bool    elementonshelf = false;
 	double  bed_hydro;
 	double  rho_water,rho_ice,density;
-	int     i;
-	bool    elementonshelf = false;
+	double  h[NUMVERTICES],s[NUMVERTICES],b[NUMVERTICES],ba[NUMVERTICES];
 
 	/*Recover info at the vertices: */
@@ -2253,5 +2248,5 @@
 	
 	/*go through vertices, and update inputs, considering them to be TriaVertex type: */
-	for(i=0;i<3;i++){
+	for(i=0;i<NUMVERTICES;i++){
 		if (nodes[i]->IsFloating()){
 			/*This node is on the shelf. See if its bed is going under the bathymetry: */
