Index: issm/trunk-jpl/src/c/classes/Elements/Element.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 28066)
+++ issm/trunk-jpl/src/c/classes/Elements/Element.cpp	(revision 28067)
@@ -5170,4 +5170,5 @@
 		this->SetElementInput(SmbAccumulatedRainEnum,0.0);
 		this->SetElementInput(SmbAccumulatedPrecipitationEnum,0.0);
+		this->SetElementInput(SmbMSurfEnum,0.0);
 
 		/*Flag the initialization:*/
@@ -5221,5 +5222,5 @@
 		Input *MassAdd_input       = this->GetInput(SmbMAddEnum);  _assert_(MassAdd_input);
 		Input *InitMass_input      = this->GetInput(SmbMInitnum);  _assert_(InitMass_input);
-		Input *sumMsurf_input         = this->GetInput(SmbMSurfEnum);  _assert_(sumMsurf_input);
+		Input *sumMsurf_input      = this->GetInput(SmbMSurfSumEnum);  _assert_(sumMsurf_input);
 
 		ULW_input->GetInputAverage(&meanULW);
@@ -5248,4 +5249,9 @@
 	}
 	/*}}}*/
+
+	// Get surface melt for albedo calculation
+	Input *Msurf_input         = this->GetInput(SmbMSurfEnum);  _assert_(Msurf_input);
+	Msurf_input->GetInputAverage(&Msurf);
+	Msurf=Msurf*dt*rho_ice;
 
 	// Get time forcing inputs
@@ -5432,6 +5438,7 @@
 	this->SetElementInput(SmbDzAddEnum,dz_add);
 	this->SetElementInput(SmbMInitnum,initMass);
+	this->SetElementInput(SmbMSurfEnum,Msurf/dt/rho_ice);
 	this->SetElementInput(SmbMAddEnum,sumMassAdd/dt);
-	this->SetElementInput(SmbMSurfEnum,sumMsurf/dt/rho_ice);
+	this->SetElementInput(SmbMSurfSumEnum,sumMsurf/dt/rho_ice);
 	this->SetElementInput(SmbWAddEnum,sumW/dt);
 	this->SetElementInput(SmbFACEnum,fac/1000.); // output in meters
Index: issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/Gembx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/Gembx.cpp	(revision 28066)
+++ issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/Gembx.cpp	(revision 28067)
@@ -897,8 +897,17 @@
 	// return the min integer factor that is < dt
 	max_fdt=f[0];
+	bool maxfound=false;
 	for(int i=0;i<45;i++){
-		if (f[i]<dt-Dtol)if(f[i]>=max_fdt-Dtol)max_fdt=f[i];
+		if (f[i]<dt-Dtol)if(f[i]>=max_fdt-Dtol){
+			max_fdt=f[i];
+			maxfound=true;
+		}
 	}
 	dt=max_fdt;
+	if (maxfound==false){
+		if(VerboseSmb() && sid==0 && IssmComm::GetRank()==0){
+			_printf0_(" WARNING: calculated timestep for thermal loop is < 1 second.\n");
+		}
+	}
 
 	// determine mean (harmonic mean) of K/dz for u, d, & p
@@ -1545,5 +1554,5 @@
 		if (T_air <= CtoK+Ttol){ // if snow
 
-			IssmDouble  z_snow = P/dSnow;               // depth of snow
+			IssmDouble z_snow = P/dSnow;               // depth of snow
 			IssmDouble dfall = gdnNew;
 			IssmDouble sfall = gspNew;
@@ -2395,5 +2404,5 @@
 
 			case 4: // Li and Zwally (2004)
-				c0 = (C/dIce) * (139.21 - 0.542*Tmean)*8.36*pow(CtoK - T[i],-2.061);
+				c0 = (C/dIce) * max(139.21 - 0.542*Tmean,1.0)*8.36*pow(max(CtoK - T[i],1.0),-2.061);
 				c1 = c0;
 				break;
@@ -2401,5 +2410,5 @@
 			case 5: // Helsen et al. (2008)
 				// common variable
-				c0 = (C/dIce) * (76.138 - 0.28965*Tmean)*8.36*pow(CtoK - T[i],-2.061);
+				c0 = (C/dIce) * max(76.138 - 0.28965*Tmean,1.0)*8.36*pow(max(CtoK - T[i],1.0),-2.061);
 				c1 = c0;
 				break;
Index: issm/trunk-jpl/src/c/shared/Enum/Enum.vim
===================================================================
--- issm/trunk-jpl/src/c/shared/Enum/Enum.vim	(revision 28066)
+++ issm/trunk-jpl/src/c/shared/Enum/Enum.vim	(revision 28067)
@@ -903,5 +903,7 @@
 syn keyword cConstant HydrologyNeumannfluxEnum
 syn keyword cConstant HydrologyReynoldsEnum
+syn keyword cConstant HydrologyRheologyBBaseEnum
 syn keyword cConstant HydrologySheetConductivityEnum
+syn keyword cConstant HydrologySheetDischargeEnum
 syn keyword cConstant HydrologySheetThicknessEnum
 syn keyword cConstant HydrologySheetThicknessOldEnum
@@ -1128,4 +1130,5 @@
 syn keyword cConstant SmbMonthlyairhumidityEnum
 syn keyword cConstant SmbMSurfEnum
+syn keyword cConstant SmbMSurfSumEnum
 syn keyword cConstant SmbNetLWEnum
 syn keyword cConstant SmbNetSWEnum
Index: issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
===================================================================
--- issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 28066)
+++ issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 28067)
@@ -1123,8 +1123,9 @@
 	SmbMonthlytemperaturesEnum,
 	SmbMonthlydsradiationEnum,
-        SmbMonthlydlradiationEnum,
-        SmbMonthlywindspeedEnum,
-        SmbMonthlyairhumidityEnum,
+	SmbMonthlydlradiationEnum,
+	SmbMonthlywindspeedEnum,
+	SmbMonthlyairhumidityEnum,
 	SmbMSurfEnum,
+	SmbMSurfSumEnum,
 	SmbNetLWEnum,
 	SmbNetSWEnum,
@@ -1136,7 +1137,7 @@
 	SmbPrecipitationsAnomalyEnum,
 	SmbDsradiationAnomalyEnum,
-        SmbDlradiationAnomalyEnum,
-        SmbWindspeedAnomalyEnum,
-        SmbAirhumidityAnomalyEnum,
+	SmbDlradiationAnomalyEnum,
+	SmbWindspeedAnomalyEnum,
+	SmbAirhumidityAnomalyEnum,
 	SmbPrecipitationsLgmEnum,
 	SmbPrecipitationsPresentdayEnum,
@@ -1159,6 +1160,6 @@
 	SmbSzaValueEnum,
 	SmbSummerMeltEnum,
-        SmbSummerAlbedoEnum,
-        SmbSnowheightEnum,
+	SmbSummerAlbedoEnum,
+	SmbSnowheightEnum,
 	SmbTEnum,
 	SmbTaEnum,
Index: issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
===================================================================
--- issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 28066)
+++ issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 28067)
@@ -905,5 +905,7 @@
 		case HydrologyNeumannfluxEnum : return "HydrologyNeumannflux";
 		case HydrologyReynoldsEnum : return "HydrologyReynolds";
+		case HydrologyRheologyBBaseEnum : return "HydrologyRheologyBBase";
 		case HydrologySheetConductivityEnum : return "HydrologySheetConductivity";
+		case HydrologySheetDischargeEnum : return "HydrologySheetDischarge";
 		case HydrologySheetThicknessEnum : return "HydrologySheetThickness";
 		case HydrologySheetThicknessOldEnum : return "HydrologySheetThicknessOld";
@@ -1130,4 +1132,5 @@
 		case SmbMonthlyairhumidityEnum : return "SmbMonthlyairhumidity";
 		case SmbMSurfEnum : return "SmbMSurf";
+		case SmbMSurfSumEnum : return "SmbMSurfSum";
 		case SmbNetLWEnum : return "SmbNetLW";
 		case SmbNetSWEnum : return "SmbNetSW";
Index: issm/trunk-jpl/src/c/shared/Enum/Enumjl.vim
===================================================================
--- issm/trunk-jpl/src/c/shared/Enum/Enumjl.vim	(revision 28066)
+++ issm/trunk-jpl/src/c/shared/Enum/Enumjl.vim	(revision 28067)
@@ -896,5 +896,7 @@
 syn keyword juliaConstC HydrologyNeumannfluxEnum
 syn keyword juliaConstC HydrologyReynoldsEnum
+syn keyword juliaConstC HydrologyRheologyBBaseEnum
 syn keyword juliaConstC HydrologySheetConductivityEnum
+syn keyword juliaConstC HydrologySheetDischargeEnum
 syn keyword juliaConstC HydrologySheetThicknessEnum
 syn keyword juliaConstC HydrologySheetThicknessOldEnum
@@ -1121,4 +1123,5 @@
 syn keyword juliaConstC SmbMonthlyairhumidityEnum
 syn keyword juliaConstC SmbMSurfEnum
+syn keyword juliaConstC SmbMSurfSumEnum
 syn keyword juliaConstC SmbNetLWEnum
 syn keyword juliaConstC SmbNetSWEnum
Index: issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
===================================================================
--- issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 28066)
+++ issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 28067)
@@ -926,5 +926,7 @@
 	      else if (strcmp(name,"HydrologyNeumannflux")==0) return HydrologyNeumannfluxEnum;
 	      else if (strcmp(name,"HydrologyReynolds")==0) return HydrologyReynoldsEnum;
+	      else if (strcmp(name,"HydrologyRheologyBBase")==0) return HydrologyRheologyBBaseEnum;
 	      else if (strcmp(name,"HydrologySheetConductivity")==0) return HydrologySheetConductivityEnum;
+	      else if (strcmp(name,"HydrologySheetDischarge")==0) return HydrologySheetDischargeEnum;
 	      else if (strcmp(name,"HydrologySheetThickness")==0) return HydrologySheetThicknessEnum;
 	      else if (strcmp(name,"HydrologySheetThicknessOld")==0) return HydrologySheetThicknessOldEnum;
@@ -996,10 +998,10 @@
 	      else if (strcmp(name,"SampleOld")==0) return SampleOldEnum;
 	      else if (strcmp(name,"SampleNoise")==0) return SampleNoiseEnum;
-	      else if (strcmp(name,"SamplingBeta")==0) return SamplingBetaEnum;
-	      else if (strcmp(name,"SamplingKappa")==0) return SamplingKappaEnum;
          else stage=9;
    }
    if(stage==9){
-	      if (strcmp(name,"SamplingPhi")==0) return SamplingPhiEnum;
+	      if (strcmp(name,"SamplingBeta")==0) return SamplingBetaEnum;
+	      else if (strcmp(name,"SamplingKappa")==0) return SamplingKappaEnum;
+	      else if (strcmp(name,"SamplingPhi")==0) return SamplingPhiEnum;
 	      else if (strcmp(name,"SamplingTau")==0) return SamplingTauEnum;
 	      else if (strcmp(name,"Sealevel")==0) return SealevelEnum;
@@ -1119,10 +1121,10 @@
 	      else if (strcmp(name,"SmbDzMin")==0) return SmbDzMinEnum;
 	      else if (strcmp(name,"SmbDzTop")==0) return SmbDzTopEnum;
-	      else if (strcmp(name,"SmbDzini")==0) return SmbDziniEnum;
-	      else if (strcmp(name,"SmbEAir")==0) return SmbEAirEnum;
          else stage=10;
    }
    if(stage==10){
-	      if (strcmp(name,"SmbEC")==0) return SmbECEnum;
+	      if (strcmp(name,"SmbDzini")==0) return SmbDziniEnum;
+	      else if (strcmp(name,"SmbEAir")==0) return SmbEAirEnum;
+	      else if (strcmp(name,"SmbEC")==0) return SmbECEnum;
 	      else if (strcmp(name,"SmbECDt")==0) return SmbECDtEnum;
 	      else if (strcmp(name,"SmbECini")==0) return SmbECiniEnum;
@@ -1157,4 +1159,5 @@
 	      else if (strcmp(name,"SmbMonthlyairhumidity")==0) return SmbMonthlyairhumidityEnum;
 	      else if (strcmp(name,"SmbMSurf")==0) return SmbMSurfEnum;
+	      else if (strcmp(name,"SmbMSurfSum")==0) return SmbMSurfSumEnum;
 	      else if (strcmp(name,"SmbNetLW")==0) return SmbNetLWEnum;
 	      else if (strcmp(name,"SmbNetSW")==0) return SmbNetSWEnum;
@@ -1241,11 +1244,11 @@
 	      else if (strcmp(name,"SurfaceAbsVelMisfit")==0) return SurfaceAbsVelMisfitEnum;
 	      else if (strcmp(name,"Area")==0) return AreaEnum;
-	      else if (strcmp(name,"SealevelArea")==0) return SealevelAreaEnum;
-	      else if (strcmp(name,"SurfaceArea")==0) return SurfaceAreaEnum;
-	      else if (strcmp(name,"SurfaceAverageVelMisfit")==0) return SurfaceAverageVelMisfitEnum;
          else stage=11;
    }
    if(stage==11){
-	      if (strcmp(name,"SurfaceCrevasse")==0) return SurfaceCrevasseEnum;
+	      if (strcmp(name,"SealevelArea")==0) return SealevelAreaEnum;
+	      else if (strcmp(name,"SurfaceArea")==0) return SurfaceAreaEnum;
+	      else if (strcmp(name,"SurfaceAverageVelMisfit")==0) return SurfaceAverageVelMisfitEnum;
+	      else if (strcmp(name,"SurfaceCrevasse")==0) return SurfaceCrevasseEnum;
 	      else if (strcmp(name,"Surface")==0) return SurfaceEnum;
 	      else if (strcmp(name,"SurfaceOld")==0) return SurfaceOldEnum;
@@ -1364,11 +1367,11 @@
 	      else if (strcmp(name,"Outputdefinition55")==0) return Outputdefinition55Enum;
 	      else if (strcmp(name,"Outputdefinition56")==0) return Outputdefinition56Enum;
-	      else if (strcmp(name,"Outputdefinition57")==0) return Outputdefinition57Enum;
-	      else if (strcmp(name,"Outputdefinition58")==0) return Outputdefinition58Enum;
-	      else if (strcmp(name,"Outputdefinition59")==0) return Outputdefinition59Enum;
          else stage=12;
    }
    if(stage==12){
-	      if (strcmp(name,"Outputdefinition5")==0) return Outputdefinition5Enum;
+	      if (strcmp(name,"Outputdefinition57")==0) return Outputdefinition57Enum;
+	      else if (strcmp(name,"Outputdefinition58")==0) return Outputdefinition58Enum;
+	      else if (strcmp(name,"Outputdefinition59")==0) return Outputdefinition59Enum;
+	      else if (strcmp(name,"Outputdefinition5")==0) return Outputdefinition5Enum;
 	      else if (strcmp(name,"Outputdefinition60")==0) return Outputdefinition60Enum;
 	      else if (strcmp(name,"Outputdefinition61")==0) return Outputdefinition61Enum;
@@ -1487,11 +1490,11 @@
 	      else if (strcmp(name,"DamageEvolutionAnalysis")==0) return DamageEvolutionAnalysisEnum;
 	      else if (strcmp(name,"DamageEvolutionSolution")==0) return DamageEvolutionSolutionEnum;
-	      else if (strcmp(name,"DataSet")==0) return DataSetEnum;
-	      else if (strcmp(name,"DataSetParam")==0) return DataSetParamEnum;
-	      else if (strcmp(name,"DatasetInput")==0) return DatasetInputEnum;
          else stage=13;
    }
    if(stage==13){
-	      if (strcmp(name,"DebrisAnalysis")==0) return DebrisAnalysisEnum;
+	      if (strcmp(name,"DataSet")==0) return DataSetEnum;
+	      else if (strcmp(name,"DataSetParam")==0) return DataSetParamEnum;
+	      else if (strcmp(name,"DatasetInput")==0) return DatasetInputEnum;
+	      else if (strcmp(name,"DebrisAnalysis")==0) return DebrisAnalysisEnum;
 	      else if (strcmp(name,"DebrisSolution")==0) return DebrisSolutionEnum;
 	      else if (strcmp(name,"DefaultAnalysis")==0) return DefaultAnalysisEnum;
@@ -1610,11 +1613,11 @@
 	      else if (strcmp(name,"LinearFloatingMeltRate")==0) return LinearFloatingMeltRateEnum;
 	      else if (strcmp(name,"LinearFloatingMeltRatearma")==0) return LinearFloatingMeltRatearmaEnum;
-	      else if (strcmp(name,"LliboutryDuval")==0) return LliboutryDuvalEnum;
-	      else if (strcmp(name,"Loads")==0) return LoadsEnum;
-	      else if (strcmp(name,"LoveAnalysis")==0) return LoveAnalysisEnum;
          else stage=14;
    }
    if(stage==14){
-	      if (strcmp(name,"LoveHf")==0) return LoveHfEnum;
+	      if (strcmp(name,"LliboutryDuval")==0) return LliboutryDuvalEnum;
+	      else if (strcmp(name,"Loads")==0) return LoadsEnum;
+	      else if (strcmp(name,"LoveAnalysis")==0) return LoveAnalysisEnum;
+	      else if (strcmp(name,"LoveHf")==0) return LoveHfEnum;
 	      else if (strcmp(name,"LoveHt")==0) return LoveHtEnum;
 	      else if (strcmp(name,"LoveKernelsImag")==0) return LoveKernelsImagEnum;
@@ -1733,11 +1736,11 @@
 	      else if (strcmp(name,"SMBgradientsela")==0) return SMBgradientselaEnum;
 	      else if (strcmp(name,"SMBhenning")==0) return SMBhenningEnum;
-	      else if (strcmp(name,"SMBmeltcomponents")==0) return SMBmeltcomponentsEnum;
-	      else if (strcmp(name,"SMBpdd")==0) return SMBpddEnum;
-	      else if (strcmp(name,"SMBpddSicopolis")==0) return SMBpddSicopolisEnum;
          else stage=15;
    }
    if(stage==15){
-	      if (strcmp(name,"SMBsemic")==0) return SMBsemicEnum;
+	      if (strcmp(name,"SMBmeltcomponents")==0) return SMBmeltcomponentsEnum;
+	      else if (strcmp(name,"SMBpdd")==0) return SMBpddEnum;
+	      else if (strcmp(name,"SMBpddSicopolis")==0) return SMBpddSicopolisEnum;
+	      else if (strcmp(name,"SMBsemic")==0) return SMBsemicEnum;
 	      else if (strcmp(name,"SSAApproximation")==0) return SSAApproximationEnum;
 	      else if (strcmp(name,"SSAFSApproximation")==0) return SSAFSApproximationEnum;
