Index: /issm/trunk-jpl/src/c/analyses/LevelsetAnalysis.cpp
===================================================================
--- /issm/trunk-jpl/src/c/analyses/LevelsetAnalysis.cpp	(revision 22420)
+++ /issm/trunk-jpl/src/c/analyses/LevelsetAnalysis.cpp	(revision 22421)
@@ -423,12 +423,17 @@
 				if(groundedice-calvinghaf<=-haf_eps){
 					// ice floats freely below calvinghaf: calve freely
+					// undercutting has no effect:
+					meltingrate=0.;
 				}
 				else if(groundedice-calvinghaf>=haf_eps){ 
 					// ice is well above calvinghaf -> no calving back, i.e. limit calving rate to ice velocity
 					calvingrate=min(calvingrate,vel);
+					// ice is almost grounded: frontal undercutting has maximum effect (do nothing).
 				}
 				else{ // ice is close to calvinghaf: smooth transition between limitation and free calving.
-					heaviside=(groundedice-calvinghaf+haf_eps)/(2.*haf_eps) + sin(PI*(groundedice-calvinghaf)/haf_eps)/(2.*PI);
+					//heaviside: 0 for floating, 1 for grounded
+					heaviside=(groundedice-calvinghaf+haf_eps)/(2.*haf_eps) + sin(PI*(groundedice-calvinghaf)/haf_eps)/(2.*PI); 
 					calvingrate=heaviside*(min(calvingrate,vel)-calvingrate)+calvingrate;
+					meltingrate=heaviside*meltingrate+0.;
 				}
 
