6 #include "../Numerics/numerics.h"
7 #include "../Exceptions/exceptions.h"
18 IssmDouble frac_solid, snowfall, rainfall, runoff;
35 sconv=(rho_water/rho_ice);
38 beta1=beta1*(0.001*365)*sconv;
39 beta2=beta2*(0.001*365)*sconv;
47 for(imonth=0;imonth<12;imonth++){
53 rlaps=-6.309e-03+(-5.426e-03-(-6.309e-03))*sin((imonth+1-4)*
PI/6.0)*1000.0;
54 monthlytemperatures[imonth]=monthlytemperatures[imonth]-rlaps*st;
55 tstar=monthlytemperatures[imonth]+t_ampl[0];
60 q=exp(desfac*(
max(s,2000.0)-2000.0));
62 q=exp(desfac*(
max(s,2000.0)-s0p));
64 precip_star=q*monthlyprec[imonth]*sconv*p_ampl[0]*yts;
65 precip=precip+precip_star*inv_twelve;
74 #if !defined(_HAVE_ADOLC_)
75 pdd=pdd+(s_stat*inv_sqrt2pi*exp(-0.5*pow(tstar*inv_s_stat,2))
76 +0.5*tstar*erfc(-tstar*inv_s_stat*inv_sqrt2))*inv_twelve;
78 _error_(
"Cannot differentiate erfc, talk to ADOLC folks (http://functions.wolfram.com/GammaBetaErf/Erfc/20/01/)");
96 else if(tstar<=temp_snow)
99 frac_solid=coeff1+tstar*(coeff2
100 +tstar*(coeff3+tstar*(coeff4+tstar*(coeff5+tstar*coeff6))));
103 snowfall=snowfall+precip_star*frac_solid*inv_twelve;
107 rainfall=precip-snowfall;
108 if(snowfall<0.0) snowfall=0.0;
109 if(rainfall<0.0) rainfall=0.0;
111 if(rainfall<=(Pmax*snowfall)){
112 if((rainfall+beta1*pdd)<=(Pmax*snowfall)) {
113 smelt_star = rainfall+beta1*pdd;
118 smelt_star = Pmax*snowfall;
119 smelt = beta2*(pdd-(smelt_star-rainfall)/beta1);
124 smelt_star = Pmax*snowfall;
126 runoff = smelt+rainfall-Pmax*snowfall;
134 melt_star[0]=smelt_star/yts;
135 B=(saccu-runoff)/yts;