Changeset 27240


Ignore:
Timestamp:
08/26/22 12:16:57 (3 years ago)
Author:
schlegel
Message:

CHG: more GEMB cleanup of ints to floats

Location:
issm/trunk-jpl
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/Gembx.cpp

    r27238 r27240  
    160160        T = T - CtoK;
    161161        // convert dT from degC/m to degC/cm
    162         dT = dT/100;
     162        dT = dT/100.0;
    163163
    164164        // temperature coefficient F
     
    410410
    411411         // determine new grain size (mm)
    412                         gsz[i] = 1e-1*(gdn[i]/.99+(1-1*gdn[i]/.99)*(gsp[i]/.99*3+(1-gsp[i]/.99)*4));
     412                        gsz[i] = max(1e-1*(gdn[i]/.99+(1.0-1.0*gdn[i]/.99)*(gsp[i]/.99*3.0+(1.0-gsp[i]/.99)*4.0)),Gdntol*2.0);
    413413
    414414                }
     
    756756        IssmDouble zT=0.0;
    757757        IssmDouble zQ=0.0;
    758         IssmDouble zratio=1;
     758        IssmDouble zratio=1.0;
    759759        IssmDouble dt=0.0;
    760760        IssmDouble max_fdt=0.0;
     
    815815
    816816        //zT and zQ are percentage of z0 (Foken 2008)
    817         zratio=10;
     817        zratio=10.0;
    818818        zT=z0/zratio;
    819819        zQ=z0/zratio;
     
    886886        // NS: 2.16.18 divided dt by scaling factor, default set to 1/11 for stability
    887887        dt=1e12;
    888         for(int i=0;i<m;i++) dt = min(dt,CI * pow(dz[i],2) * d[i]  / (3 * K[i]) * thermo_scaling);
     888        for(int i=0;i<m;i++) dt = min(dt,CI * pow(dz[i],2) * d[i]  / (3. * K[i]) * thermo_scaling);
    889889
    890890        // smallest possible even integer of 60 min where diffusion number > 1/2
     
    977977
    978978                // calculate the Bulk Richardson Number (Ri)
    979                 Ri = pow(100000/pAir,0.286)*(2.0*9.81*(Ta - Ts)) / (Tz*(Ta + Ts)* pow(V/(Vz),2.0));
     979                Ri = pow(100000./pAir,0.286)*(2.0*9.81*(Ta - Ts)) / (Tz*(Ta + Ts)* pow(V/(Vz),2.0));
    980980
    981981                IssmDouble PhiM;
     
    993993                        }
    994994                        else {
    995                                 coefM =pow (1.0-18*Ri,-0.25);
     995                                coefM =pow (1.0-18.0*Ri,-0.25);
    996996                        }
    997997
     
    10131013                                // if stable
    10141014                                //coefM = pow(1.0-5.0*Ri,2.0); //Fitzpatrick et al., 2017, from Brock et al., 2010
    1015                                 coefM=1+5.3*min((Ri/(1-5*Ri)),0.5);
    1016                                 coefH=1+8*min((Ri/(1-5*Ri)),0.5);
     1015                                coefM=1.0+5.3*min((Ri/(1.0-5.0*Ri)),0.5);
     1016                                coefH=1.0+8.0*min((Ri/(1.0-5.0*Ri)),0.5);
    10171017                        }
    10181018                        else {
    10191019                                //coefM =pow(1.0-16.0*max(Ri,-1.0),0.75); //Fitzpatrick et al., 2017, from Brock et al., 2010
    1020                                 coefM=pow(1-19*max(Ri/1.5,-2.0),-0.25);
    1021                                 coefH=0.95*pow(1-11.6*max(Ri/1.5,-2.0),-0.5);
     1020                                coefM=pow(1.0-19.0*max(Ri/1.5,-2.0),-0.25);
     1021                                coefH=0.95*pow(1.0-11.6*max(Ri/1.5,-2.0),-0.5);
    10221022                        }
    10231023
     
    10321032         if (Ri > 0.0+Ttol){
    10331033            // if stable
    1034             coefM=1+15*Ri*pow(1+Ri,1/2);
    1035             coefH=1;
     1034            coefM=1.0+15.0*Ri*pow(1.0+Ri,1./2.);
     1035            coefH=1.0;
    10361036         }
    10371037         else {
    1038             coefM=pow(1-15*Ri/(1+75*pow(0.4/log(Tz/zT),2)*pow(Tz/zT*fabs(Ri),1/2)),-1);
    1039             coefH=1;
     1038            coefM=pow(1.0-15.0*Ri/(1.0+75.0*pow(0.4/log(Tz/zT),2)*pow(Tz/zT*fabs(Ri),1./2.)),-1);
     1039            coefH=1.0;
    10401040         }
    10411041
     
    10461046      else {
    10471047         IssmDouble a1=1.0;
    1048          IssmDouble b1=2/3;
     1048         IssmDouble b1=2.0/3.0;
    10491049         IssmDouble c1=5.0;
    10501050         IssmDouble d1=0.35;
    1051          IssmDouble PhiMz;
    1052          IssmDouble PhiHz;
     1051         IssmDouble PhiMz=0.0;
     1052         IssmDouble PhiHz=0.0;
    10531053         IssmDouble PhiMz0=0.0;
    10541054         IssmDouble PhiHzT=0.0;
    10551055         IssmDouble PhiHzQ=0.0;
    1056          IssmDouble zL;
    1057          IssmDouble zLT;
    1058          IssmDouble zLM;
     1056         IssmDouble zL=0.0;
     1057         IssmDouble zLT=0.0;
     1058         IssmDouble zLM=0.0;
    10591059
    10601060         if (Ri > 0.0+Ttol){
     
    10621062
    10631063            if(Ri < 0.2-Ttol){
    1064                zL = Ri/(1-5*Ri);
     1064               zL = Ri/(1.0-5.0*Ri);
    10651065            }
    10661066            else{
     
    10681068            }
    10691069            //zL = min(zL, 0.5); //Sjoblom, 2014
    1070             zLM=max(zL/Vz*z0,1e-3);
    1071             zLT=max(zL/Tz*zT,1e-3);
     1070            zLM=max(zL/Vz*z0,1.e-3);
     1071            zLT=max(zL/Tz*zT,1.e-3);
    10721072
    10731073            //Ding et al. 2020, from Beljaars and Holtslag (1991)
    1074             PhiMz=-1*(a1*zL + b1*(zL-c1/d1)*exp(-1*d1*zL) + b1*c1/d1);
    1075             PhiHz=-1*(pow(1+2*a1*zL/3,1.5) + b1*(zL-c1/d1)*exp(-1*d1*zL) + b1*c1/d1 - 1);
    1076             PhiMz0=-1*(a1*zLM + b1*(zLM-c1/d1)*exp(-1*d1*zLM) + b1*c1/d1);
    1077             PhiHzT=-1*(pow(1+2*a1*zLT/3,1.5) + b1*(zLT-c1/d1)*exp(-1*d1*zLT) + b1*c1/d1 - 1);
     1074            PhiMz=-1.*(a1*zL + b1*(zL-c1/d1)*exp(-1.*d1*zL) + b1*c1/d1);
     1075            PhiHz=-1.*(pow(1.+2.*a1*zL/3.,1.5) + b1*(zL-c1/d1)*exp(-1.*d1*zL) + b1*c1/d1 - 1.0);
     1076            PhiMz0=-1.*(a1*zLM + b1*(zLM-c1/d1)*exp(-1.*d1*zLM) + b1*c1/d1);
     1077            PhiHzT=-1.*(pow(1.+2.*a1*zLT/3.,1.5) + b1*(zLT-c1/d1)*exp(-1.*d1*zLT) + b1*c1/d1 - 1.0);
    10781078
    10791079            PhiHzQ=PhiHzT;
     
    10911091
    10921092            if (true){ //Sjoblom, 2014
    1093                xm=pow(1.0-19*zL,-0.25);
    1094                PhiMz=2*log((1+xm)/2.0) + log((1+pow(xm,2))/2.0) - 2*atan(xm) + Pi/2;
     1093               xm=pow(1.0-19.0*zL,-0.25);
     1094               PhiMz=2.0*log((1.+xm)/2.0) + log((1.+pow(xm,2))/2.0) - 2.*atan(xm) + Pi/2.;
    10951095
    10961096               xh=0.95*pow(1.0-11.6*zL,-0.5);
    1097                PhiHz=2*log((1+pow(xh,2))/2.0);
     1097               PhiHz=2.0*log((1.0+pow(xh,2))/2.0);
    10981098            }
    10991099            else{ //Ding et al., 2020
     
    11011101               xmM=pow(1.0-16*zLM,0.25);
    11021102               xmT=pow(1.0-16*zLT,0.25);
    1103                PhiMz=2*log((1+xm)/2.0) + log((1+pow(xm,2))/2.0) - 2*atan(xm) + Pi/2;
    1104                PhiMz0=2*log((1+xmM)/2.0) + log((1+pow(xmM,2))/2.0) - 2*atan(xmM) + Pi/2;
    1105 
    1106                PhiHz=2*log((1+pow(xm,2))/2.0);
    1107                PhiHzT=2*log((1+pow(xmT,2))/2.0);
     1103               PhiMz=2.0*log((1.+xm)/2.0) + log((1.+pow(xm,2))/2.0) - 2.0*atan(xm) + Pi/2.0;
     1104               PhiMz0=2.0*log((1.+xmM)/2.0) + log((1.+pow(xmM,2))/2.0) - 2.0*atan(xmM) + Pi/2.0;
     1105
     1106               PhiHz=2.0*log((1.+pow(xm,2))/2.0);
     1107               PhiHzT=2.0*log((1.+pow(xmT,2))/2.0);
    11081108
    11091109               PhiHzQ=PhiHzT;
     
    11211121      //// Sensible Heat
    11221122      // calculate the sensible heat flux [W m-2](Patterson, 1998)
    1123       shf = dAir * C * CA * (Ta - Ts) * pow(100000/pAir,0.286);
     1123      shf = dAir * C * CA * (Ta - Ts) * pow(100000./pAir,0.286);
    11241124
    11251125      // adjust using Monin-Obukhov stability theory
     
    11471147
    11481148      // Latent heat flux [W m-2]
    1149       lhf = C * L * (eAir - eS) / (461.9*(Ta+Ts)/2);
     1149      lhf = C * L * (eAir - eS) / (461.9*(Ta+Ts)/2.0);
    11501150
    11511151      // adjust using Monin-Obukhov stability theory (if lhf '+' then there is energy and mass gained at the surface,
     
    15211521                        gdnNew = min(max(1.29 - 0.17*V,0.20),1.0);
    15221522                        gspNew = min(max(0.08*V + 0.38,0.5),0.9);
    1523                         reNew=max(1e-1*(gdnNew/.99+(1-1*gdnNew/.99)*(gspNew/.99*3+(1-gspNew/.99)*4))/2,Gdntol);
     1523                        reNew=max(1e-1*(gdnNew/.99+(1.0-1.0*gdnNew/.99)*(gspNew/.99*3.0+(1.0-gspNew/.99)*4.0))/2.0,Gdntol);
    15241524                        break;
    15251525
     
    15791579                                gdn[0] = dfall;
    15801580                                gsp[0] = sfall;
    1581                                 re[0] = max(1e-1*(gdn[0]/.99+(1-1*gdn[0]/.99)*(gsp[0]/.99*3+(1-gsp[0]/.99)*4))/2,Gdntol);
     1581                                re[0] = max(1e-1*(gdn[0]/.99+(1.0-1.0*gdn[0]/.99)*(gsp[0]/.99*3.0+(1.0-gsp[0]/.99)*4.0))/2.0,Gdntol);
    15821582                        }
    15831583                }
  • issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.h

    r27237 r27240  
    3434void albedo(IssmDouble** a, IssmDouble** adiff, int aIdx, IssmDouble* re, IssmDouble* dz, IssmDouble* d, IssmDouble cldFrac, IssmDouble aIce, IssmDouble aSnow, IssmDouble aValue, IssmDouble adThresh, IssmDouble* T, IssmDouble* W, IssmDouble P, IssmDouble EC, IssmDouble Msurf, IssmDouble clabSnow, IssmDouble clabIce, IssmDouble SZA, IssmDouble COT, IssmDouble t0wet, IssmDouble t0dry, IssmDouble K, IssmDouble dt, IssmDouble dIce, int m, int sid);
    3535void shortwave(IssmDouble** pswf, int swIdx, int aIdx, IssmDouble dsw, IssmDouble dswdiff, IssmDouble as, IssmDouble asdiff, IssmDouble* d, IssmDouble* dz, IssmDouble* re, IssmDouble dIce, int m, int sid);
    36 void thermo(IssmDouble* pshf, IssmDouble* plhf, IssmDouble* pEC, IssmDouble** T, IssmDouble* pulwrf, IssmDouble* re, IssmDouble* dz, IssmDouble* d, IssmDouble* swf, IssmDouble dlw, IssmDouble Ta, IssmDouble V, IssmDouble eAir, IssmDouble pAir, int tcIdx, int eIdx, IssmDouble teValue, IssmDouble dulwrfValue, IssmDouble teThresh, IssmDouble Ws, IssmDouble dt0, IssmDouble dzMin, int m, IssmDouble Vz, IssmDouble Tz, IssmDouble thermo_scaling, IssmDouble dIce, int sid, bool isconstrainsurfaceT, bool isdeltaLWup);
     36void thermo(IssmDouble* pshf, IssmDouble* plhf, IssmDouble* pEC, IssmDouble** pT, IssmDouble* pulwrf, IssmDouble* re, IssmDouble* dz, IssmDouble* d, IssmDouble* swf, IssmDouble dlw, IssmDouble Ta, IssmDouble V, IssmDouble eAir, IssmDouble pAir, int tcIdx, int eIdx, IssmDouble teValue, IssmDouble dulwrfValue, IssmDouble teThresh, IssmDouble Ws, IssmDouble dt0, IssmDouble dzMin, int m, IssmDouble Vz, IssmDouble Tz, IssmDouble thermo_scaling, IssmDouble dIce, int sid, bool isconstrainsurfaceT, bool isdeltaLWup);
    3737void accumulation(IssmDouble** pT, IssmDouble** pdz, IssmDouble** pd, IssmDouble** pW, IssmDouble** pa, IssmDouble** padiff, IssmDouble** pre, IssmDouble** pgdn, IssmDouble** pgsp, IssmDouble* pRa, int* pm, int aIdx, int dsnowIdx, IssmDouble Tmean, IssmDouble Ta, IssmDouble P, IssmDouble dzMin, IssmDouble aSnow, IssmDouble C, IssmDouble V, IssmDouble Vmean, IssmDouble dIce, int sid);
    3838void melt(IssmDouble* pM, IssmDouble* pMs, IssmDouble* pR, IssmDouble* pF, IssmDouble* pmAdd, IssmDouble* pdz_add, IssmDouble** pT, IssmDouble** pd, IssmDouble** pdz, IssmDouble** pW, IssmDouble** pa, IssmDouble** padiff, IssmDouble** pre, IssmDouble** pgdn, IssmDouble** pgsp, int* pn, IssmDouble Ra, IssmDouble dzMin, IssmDouble zMax, IssmDouble zMin, IssmDouble zTop, IssmDouble zY, IssmDouble dIce, int sid);
Note: See TracChangeset for help on using the changeset viewer.