function Q_f=freezing_temp(SWR_in,cc,T_a,U,V,h_alt,RH)
     rho_w=1000;
     rho_i=rho_w;
     del_t=86400;
     sigma=5.67*10^(-8);
     J=1.907*10^(-5);
     Lf=3.34*10^5;
     Cw=4186;
     Ki=2.24;
 		     u=sqrt(U^2+V^2);
		     rb=(9.8*(T_a-273.16)*10)/(T_a*(u^2));
		     if rb<0
			     Ct=(0.0013)*(1-(2*20*rb)/(1+50.986*sqrt(abs(rb))));
		     else
			     Ct=(0.0013)*(1+20*rb)^(-2);
		     end
		     P=101325*exp(-8000/h_alt);
		     rho_a=(P*0.02896)/(8.31*T_a);
		     e_s=611*exp((2494/0.461)*((1/273.16)-(1/T_a)));
		     e=0.01*RH*e_s;
		     LWR_in=((0.23+0.484*(e/T_a)^(1/8))*(1-cc^4)+0.952*cc^4)*sigma*(T_a^4);
		     e_s_s=611*exp((2494/0.461)*((1/273.16)-(1/273.16)));
		     e_surf=e_s_s*RH*0.01;
		     H=rho_a*(1000)*Ct*u*(T_a-273.16);
		     LE=rho_a*(2.501*10^6)*Ct*u*(0.622/P)*(e-e_surf);
		     if u==0
			     H=0;
			     LE=0;
             end
		     Q_f=SWR_in+LWR_in-sigma*(273.16)^4+H+LE;    
end
