699 dAir = 0.029 * pAir /(
R * Ta);
712 if (ds < dIce-
Dtol && fabs(Ws) <
Wtol) z0 = 0.00012;
713 else if (ds >= dIce-
Dtol) z0 = 0.0032;
717 if(V<0.01-
Dtol)V=0.01;
721 An = pow(0.4,2) / (log(Tz/z0)*log(Vz/z0));
728 K= xNewZeroInit<IssmDouble>(m);
731 for(
int i=0;i<m;i++)
if(d[i]<dIce-
Dtol) K[i] = 0.138 - 1.01E-3 * d[i] + 3.233E-6 * (pow(d[i],2));
734 for(
int i=0;i<m;i++)
if(d[i]>=dIce-
Dtol) K[i] = 9.828 * exp(-5.7E-3*T[i]);
755 KU = xNew<IssmDouble>(m);
756 KD = xNew<IssmDouble>(m);
757 KP = xNew<IssmDouble>(m);
761 for(
int i=1;i<m;i++) KU[i]= K[i-1];
762 for(
int i=0;i<m-1;i++) KD[i] = K[i+1];
763 for(
int i=0;i<m;i++) KP[i] = K[i];
766 dzU = xNew<IssmDouble>(m);
767 dzD = xNew<IssmDouble>(m);
771 for(
int i=1;i<m;i++) dzU[i]= dz[i-1];
772 for(
int i=0;i<m-1;i++) dzD[i] = dz[i+1];
777 for(
int i=0;i<m;i++)dt =
min(dt,
CI * pow(dz[i],2) * d[i] / (3 * K[i]) * thermo_scaling);
783 int f[45] = {1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 25, 30, 36, 40, 45, 48, 50, 60,
784 72, 75, 80, 90, 100, 120, 144, 150, 180, 200, 225, 240, 300, 360, 400, 450, 600, 720, 900, 1200, 1800, 3600};
788 for(
int i=0;i<45;i++){
789 if (f[i]<dt-
Dtol)
if(f[i]>=max_fdt-
Dtol)max_fdt=f[i];
794 Au = xNew<IssmDouble>(m);
795 Ad = xNew<IssmDouble>(m);
796 Ap = xNew<IssmDouble>(m);
797 for(
int i=0;i<m;i++){
798 Au[i] = pow((dzU[i]/2.0/KP[i] + dz[i]/2.0/KU[i]),-1.0);
799 Ad[i] = pow((dzD[i]/2.0/KP[i] + dz[i]/2.0/KD[i]),-1.0);
800 Ap[i] = (d[i]*dz[i]*
CI)/dt;
804 Nu = xNew<IssmDouble>(m);
805 Nd = xNew<IssmDouble>(m);
806 Np = xNew<IssmDouble>(m);
807 for(
int i=0;i<m;i++){
808 Nu[i] = Au[i] / Ap[i];
809 Nd[i] = Ad[i] / Ap[i];
810 Np[i]= 1.0 - Nu[i] - Nd[i];
827 sw = xNew<IssmDouble>(m);
828 for(
int i=0;i<m;i++) sw[i]= swf[i] * dt;
831 dT_sw = xNew<IssmDouble>(m);
832 for(
int i=0;i<m;i++) dT_sw[i]= sw[i] / (
CI * d[i] * dz[i]);
845 T0 = xNewZeroInit<IssmDouble>(m+2);
846 Tu=xNew<IssmDouble>(m);
847 Td=xNew<IssmDouble>(m);
861 if(m>1) Ts = (T[0] + T[1])/2.0;
873 Ri = (2.0*9.81* (Vz - z0) * (Ta - Ts)) / ((Ta + Ts)* pow(V,2.0));
883 coefM = 1.0/(1.0-5.2*Ri);
886 coefM =pow (1.0-18*Ri,-0.25);
890 if (Ri <= -0.03+
Ttol) coefH = coefM/1.3;
895 shf = C *
CA * (Ta - Ts);
898 shf = shf / (coefM * coefH);
907 eS = 611.21 * exp(17.502 * (Ts -
CtoK) / (240.97 + Ts -
CtoK));
913 eS = exp(9.550426 - 5723.265/Ts + 3.53068 * log(Ts) - 0.00728332 * Ts);
917 lhf = C * L * (eAir - eS) * 0.622 / pAir;
921 lhf = lhf / (coefM * coefH);
924 EC_day = lhf *
dts / L;
927 turb = (shf + lhf)* dt;
928 dT_turb = turb / TCs;
931 ulw = - (
SB * pow(Ts,4.0)* teValue) * dt;
932 ulwrf = ulwrf - ulw/dt0;
939 if(!isconstrainsurfaceT)
for(
int j=0;j<m;j++) T[j] = T[j] + dT_sw[j];
940 if(!isconstrainsurfaceT) T[0] = T[0] + dT_dlw + dT_ulw + dT_turb;
943 for(
int j=0;j<m;j++) T0[1+j]=T[j];
944 for(
int j=0;j<m;j++) Tu[j] = T0[j];
945 for(
int j=0;j<m;j++) Td[j] = T0[2+j];
946 for(
int j=0;j<m;j++) T[j] = (Np[j] * T[j]) + (Nu[j] * Tu[j]) + (Nd[j] * Td[j]);
949 if(!isconstrainsurfaceT) EC = EC + (EC_day/
dts)*dt;
967 xDelete<IssmDouble>(K);
968 xDelete<IssmDouble>(KU);
969 xDelete<IssmDouble>(KD);
970 xDelete<IssmDouble>(KP);
971 xDelete<IssmDouble>(Au);
972 xDelete<IssmDouble>(Ad);
973 xDelete<IssmDouble>(Ap);
974 xDelete<IssmDouble>(Nu);
975 xDelete<IssmDouble>(Nd);
976 xDelete<IssmDouble>(Np);
977 xDelete<IssmDouble>(dzU);
978 xDelete<IssmDouble>(dzD);
979 xDelete<IssmDouble>(sw);
980 xDelete<IssmDouble>(dT_sw);
981 xDelete<IssmDouble>(T0);
982 xDelete<IssmDouble>(Tu);
983 xDelete<IssmDouble>(Td);