Changeset 24683
- Timestamp:
- 04/01/20 18:53:08 (5 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Element.cpp
r24652 r24683 562 562 this->parameters->FindParam(&isPrecipScaled,SmbIsprecipscaledEnum); 563 563 564 564 /*Recover present day temperature and precipitation*/ 565 565 DatasetInput2 *dinput3 = NULL; 566 566 DatasetInput2 *dinput4 = NULL; … … 3588 3588 } 3589 3589 /*}}}*/ 3590 void Element::SmbGemb( ){/*{{{*/3590 void Element::SmbGemb(IssmDouble timeinputs, int count){/*{{{*/ 3591 3591 3592 3592 /*only compute SMB at the surface: */ … … 3605 3605 IssmDouble C=0.0; 3606 3606 IssmDouble Tz,Vz=0.0; 3607 IssmDouble time,dt,starttime,finaltime;3608 IssmDouble timeclim=0.0;3609 IssmDouble t,smb_dt;3610 3607 IssmDouble yts; 3611 3608 IssmDouble Ta=0.0; … … 3618 3615 IssmDouble teValue=1.0; 3619 3616 IssmDouble aValue=0.0; 3617 IssmDouble dt,time,smb_dt; 3620 3618 int aIdx=0; 3621 3619 int denIdx=0; … … 3627 3625 IssmDouble dayEC=0.0; 3628 3626 IssmDouble initMass=0.0; 3629 IssmDouble sumR=0.0; 3630 IssmDouble sumM=0.0; 3631 IssmDouble sumEC=0.0; 3632 IssmDouble sumP=0.0; 3633 IssmDouble sumW=0.0; 3634 IssmDouble sumMassAdd=0.0; 3635 IssmDouble sumdz_add=0.0; 3627 IssmDouble sumR=0.0; 3628 IssmDouble sumM=0.0; 3629 IssmDouble sumEC=0.0; 3630 IssmDouble sumP=0.0; 3631 IssmDouble sumW=0.0; 3632 IssmDouble sumMassAdd=0.0; 3636 3633 IssmDouble fac=0.0; 3637 3634 IssmDouble sumMass=0.0; … … 3642 3639 IssmDouble thermo_scaling=1.0; 3643 3640 IssmDouble adThresh=1023.0; 3644 int offsetend=-1;3645 IssmDouble time0, timeend, delta;3646 3641 /*}}}*/ 3647 3642 /*Output variables:{{{ */ … … 3676 3671 IssmDouble* Tini = NULL; 3677 3672 int m=0; 3678 int count=0;3679 3673 /*}}}*/ 3680 3674 … … 3687 3681 parameters->FindParam(&dt,TimesteppingTimeStepEnum); /*transient core time step*/ 3688 3682 parameters->FindParam(&yts,ConstantsYtsEnum); 3689 parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum);3690 parameters->FindParam(&starttime,TimesteppingStartTimeEnum);3691 3683 parameters->FindParam(&smb_dt,SmbDtEnum); /*time period for the smb solution, usually smaller than the glaciological dt*/ 3692 3684 parameters->FindParam(&aIdx,SmbAIdxEnum); … … 3698 3690 parameters->FindParam(&t0dry,SmbT0dryEnum); 3699 3691 parameters->FindParam(&K,SmbKEnum); 3700 parameters->FindParam(&isclimatology,SmbIsclimatologyEnum);3701 3692 parameters->FindParam(&isgraingrowth,SmbIsgraingrowthEnum); 3702 3693 parameters->FindParam(&isalbedo,SmbIsalbedoEnum); … … 3723 3714 Input2 *Tz_input = this->GetInput2(SmbTzEnum); _assert_(Tz_input); 3724 3715 Input2 *Vz_input = this->GetInput2(SmbVzEnum); _assert_(Vz_input); 3725 Input2 *teValue_input = this->GetInput2(SmbTeValueEnum); _assert_(teValue_input);3726 Input2 *aValue_input = this->GetInput2(SmbAValueEnum); _assert_(aValue_input);3727 3716 Input2 *EC_input = NULL; 3728 3717 … … 3742 3731 Tz_input->GetInputValue(&Tz,gauss); 3743 3732 Vz_input->GetInputValue(&Vz,gauss); 3744 teValue_input->GetInputValue(&teValue,gauss);3745 aValue_input->GetInputValue(&aValue,gauss);3746 3733 /*}}}*/ 3747 3734 … … 3763 3750 EC_input->GetInputAverage(&EC); 3764 3751 3765 /*Retri ve the correct value of m (without the zeroes at the end)*/3752 /*Retrieve the correct value of m (without the zeroes at the end)*/ 3766 3753 this->GetInput2Value(&m,SmbSizeiniEnum); 3767 3754 … … 3816 3803 this->inputs2->GetArray(SmbAEnum,this->lid,&a,&m); 3817 3804 this->inputs2->GetArray(SmbTEnum,this->lid,&T,&m); 3818 EC_input = this->GetInput2(SmbEC Enum); _assert_(EC_input);3805 EC_input = this->GetInput2(SmbECDtEnum); _assert_(EC_input); 3819 3806 EC_input->GetInputAverage(&EC); 3820 EC=EC*dt*rho_ice;3821 3807 3822 3808 //fixed lower temperature bounday condition - T is fixed … … 3830 3816 // initialize cumulative variables 3831 3817 sumR = 0; sumM = 0; sumEC = 0; sumP = 0; sumMassAdd = 0; 3832 sumdz_add=0;3833 3818 3834 3819 //before starting loop, realize that the transient core runs this smb_core at time = time +deltaT. 3835 //go back to time - deltaT: 3836 time-=dt; 3837 3838 timeclim=time; 3839 if (isclimatology){ 3840 //If this is a climatology, we need to repeat the forcing after the final time 3841 TransientInput2* Ta_input_tr = this->inputs2->GetTransientInput(SmbTaEnum); _assert_(Ta_input_tr); 3842 offsetend = Ta_input_tr->GetTimeInputOffset(finaltime); 3843 time0 = Ta_input_tr->GetTimeByOffset(-1); 3844 timeend = Ta_input_tr->GetTimeByOffset(offsetend); 3845 if (time>time0 & timeend>time0){ 3846 delta=(time-time0) - (timeend-time0)*(reCast<int,IssmDouble>((time-time0)/(timeend-time0))); 3847 timeclim=time0+delta; 3848 } 3849 } 3850 3851 /*Start loop: */ 3852 count=1; 3853 for (t=time;t<time+dt;t=t+smb_dt){ 3854 3855 if(VerboseSmb() && this->Sid()==0 && IssmComm::GetRank()==0)_printf0_("Time: t=" << setprecision(8) << t/365.0/24.0/3600.0 << " yr/" << (time+dt)/365.0/24.0/3600.0 << " yr" << setprecision(3) << " Step: " << count << "\n"); 3856 3857 Input2 *Ta_input = this->GetInput2(SmbTaEnum,t-time+timeclim); _assert_(Ta_input); 3858 Input2 *V_input = this->GetInput2(SmbVEnum,t-time+timeclim); _assert_(V_input); 3859 Input2 *Dlwr_input= this->GetInput2(SmbDlwrfEnum,t-time+timeclim); _assert_(Dlwr_input); 3860 Input2 *Dswr_input= this->GetInput2(SmbDswrfEnum,t-time+timeclim); _assert_(Dswr_input); 3861 Input2 *P_input = this->GetInput2(SmbPEnum,t-time+timeclim); _assert_(P_input); 3862 Input2 *eAir_input= this->GetInput2(SmbEAirEnum,t-time+timeclim); _assert_(eAir_input); 3863 Input2 *pAir_input= this->GetInput2(SmbPAirEnum,t-time+timeclim); _assert_(pAir_input); 3864 3865 /*extract daily data:{{{*/ 3866 Ta_input->GetInputValue(&Ta,gauss);//screen level air temperature [K] 3867 V_input->GetInputValue(&V,gauss); //wind speed [m s-1] 3868 Dlwr_input->GetInputValue(&dlw,gauss); //downward longwave radiation flux [W m-2] 3869 Dswr_input->GetInputValue(&dsw,gauss); //downward shortwave radiation flux [W m-2] 3870 P_input->GetInputValue(&P,gauss); //precipitation [kg m-2] 3871 eAir_input->GetInputValue(&eAir,gauss); //screen level vapor pressure [Pa] 3872 pAir_input->GetInputValue(&pAir,gauss); // screen level air pressure [Pa] 3873 teValue_input->GetInputValue(&teValue,gauss); // Emissivity [0-1] 3874 aValue_input->GetInputValue(&aValue,gauss); // Albedo [0 1] 3875 //_printf_("Time: " << t << " Ta: " << Ta << " V: " << V << " dlw: " << dlw << " dsw: " << dsw << " P: " << P << " eAir: " << eAir << " pAir: " << pAir << "\n"); 3876 /*}}}*/ 3877 3878 /*Snow grain metamorphism:*/ 3879 if(isgraingrowth)grainGrowth(&re, &gdn, &gsp, T, dz, d, W, smb_dt, m, aIdx,this->Sid()); 3880 3881 /*Snow, firn and ice albedo:*/ 3882 if(isalbedo)albedo(&a,aIdx,re,d,cldFrac,aIce,aSnow,aValue,adThresh,T,W,P,EC,t0wet,t0dry,K,smb_dt,rho_ice,m,this->Sid()); 3883 3884 /*Distribution of absorbed short wave radation with depth:*/ 3885 if(isshortwave)shortwave(&swf, swIdx, aIdx, dsw, a[0], d, dz, re,rho_ice,m,this->Sid()); 3886 3887 /*Calculate net shortwave [W m-2]*/ 3888 netSW = netSW + cellsum(swf,m)*smb_dt/dt; 3889 3890 /*Thermal profile computation:*/ 3891 if(isthermal)thermo(&EC, &T, &ulw, dz, d, swf, dlw, Ta, V, eAir, pAir, teValue, W[0], smb_dt, m, Vz, Tz, thermo_scaling,rho_ice,this->Sid()); 3892 3893 /*Change in thickness of top cell due to evaporation/condensation assuming same density as top cell. 3894 * need to fix this in case all or more of cell evaporates */ 3895 dz[0] = dz[0] + EC / d[0]; 3896 3897 /*Add snow/rain to top grid cell adjusting cell depth, temperature and density*/ 3898 if(isaccumulation)accumulation(&T, &dz, &d, &W, &a, &re, &gdn, &gsp, &m, aIdx, dsnowIdx, Tmean, Ta, P, dzMin, aSnow, C, V, Vmean, rho_ice,this->Sid()); 3899 3900 /*Calculate water production, M [kg m-2] resulting from snow/ice temperature exceeding 273.15 deg K 3901 * (> 0 deg C), runoff R [kg m-2] and resulting changes in density and determine wet compaction [m]*/ 3902 if(ismelt)melt(&M, &R, &mAdd, &dz_add, &T, &d, &dz, &W, &a, &re, &gdn, &gsp, &m, dzMin, zMax, zMin, zTop,rho_ice,this->Sid()); 3903 3904 /*Allow non-melt densification and determine compaction [m]*/ 3905 if(isdensification)densification(&d,&dz, T, re, denIdx, C, smb_dt, Tmean,rho_ice,m,this->Sid()); 3906 3907 /*Calculate upward longwave radiation flux [W m-2] not used in energy balance. Calculated for every 3908 * sub-time step in thermo equations*/ 3909 //ulw = 5.67E-8 * pow(T[0],4.0) * teValue; // + deltatest here 3910 3911 /*Calculate net longwave [W m-2]*/ 3912 meanULW = meanULW + ulw*smb_dt/dt; 3913 netLW = netLW + (dlw - ulw)*smb_dt/dt; 3914 3915 /*Calculate turbulent heat fluxes [W m-2]*/ 3916 if(isturbulentflux)turbulentFlux(&shf, &lhf, &dayEC, Ta, T[0], V, eAir, pAir, d[0], W[0], Vz, Tz,rho_ice,this->Sid()); 3917 3918 /*Verbose some results in debug mode: {{{*/ 3919 if(VerboseSmb() && 0){ 3920 _printf_("smb log: count[" << count << "] m[" << m << "] " 3921 << setprecision(16) << "T[" << cellsum(T,m) << "] " 3922 << "d[" << cellsum(d,m) << "] " 3923 << "dz[" << cellsum(dz,m) << "] " 3924 << "a[" << cellsum(a,m) << "] " 3925 << "W[" << cellsum(W,m) << "] " 3926 << "re[" << cellsum(re,m) << "] " 3927 << "gdn[" << cellsum(gdn,m) << "] " 3928 << "gsp[" << cellsum(gsp,m) << "] " 3929 << "swf[" << netSW << "] " 3930 << "lwf[" << netLW << "] " 3931 << "a[" << a << "] " 3932 << "te[" << teValue << "] " 3933 << "\n"); 3934 } /*}}}*/ 3935 3936 meanLHF = meanLHF + lhf*smb_dt/dt; 3937 meanSHF = meanSHF + shf*smb_dt/dt; 3938 3939 /*Sum component mass changes [kg m-2]*/ 3940 sumMassAdd = mAdd + sumMassAdd; 3941 sumM = M + sumM; 3942 sumR = R + sumR; 3943 sumW = cellsum(W,m); 3944 sumP = P + sumP; 3945 sumEC = sumEC + EC; // evap (-)/cond(+) 3946 3947 /*Calculate total system mass:*/ 3948 sumMass=0; 3949 fac=0; 3950 for(int i=0;i<m;i++){ 3951 sumMass += dz[i]*d[i]; 3952 fac += dz[i]*(rho_ice - fmin(d[i],rho_ice)); 3953 } 3954 3955 #if defined(_HAVE_AD_) 3956 /*we want to avoid the round operation at all cost. Not differentiable.*/ 3957 _error_("not implemented yet"); 3958 #else 3959 dMass = sumMass + sumR + sumW - sumP - sumEC - initMass - sumMassAdd; 3960 dMass = round(dMass * 100.0)/100.0; 3961 3962 /*Check mass conservation:*/ 3963 if (dMass != 0.0) _printf_("total system mass not conserved in MB function \n"); 3964 #endif 3965 3966 /*Check bottom grid cell T is unchanged:*/ 3967 if(VerboseSmb() && this->Sid()==0 && IssmComm::GetRank()==0){ 3968 if (T[m-1]!=T_bottom) _printf_("T(end)~=T_bottom" << "\n"); 3969 } 3970 3971 /*Free ressources: */ 3972 xDelete<IssmDouble>(swf); 3973 3974 /*increase counter:*/ 3975 count++; 3976 } //for (t=time;t<time+dt;t=t+smb_dt) 3820 //go back to time - deltaT: 3821 time-=dt; 3822 3823 if(VerboseSmb() && this->Sid()==0 && IssmComm::GetRank()==0)_printf0_("Time: t=" << setprecision(8) << timeinputs/365.0/24.0/3600.0 << " yr/" << (time+dt)/365.0/24.0/3600.0 << " yr" << setprecision(3) << " Step: " << count << "\n"); 3824 3825 /*Get daily accumulated inputs {{{*/ 3826 if (count>1){ 3827 Input2 *sumEC_input = this->GetInput2(SmbECEnum); _assert_(sumEC_input); 3828 Input2 *sumM_input = this->GetInput2(SmbMeltEnum); _assert_(sumM_input); 3829 Input2 *sumR_input = this->GetInput2(SmbRunoffEnum); _assert_(sumR_input); 3830 Input2 *sumP_input = this->GetInput2(SmbPrecipitationEnum); _assert_(sumP_input); 3831 Input2 *ULW_input = this->GetInput2(SmbMeanULWEnum); _assert_(ULW_input); 3832 Input2 *LW_input = this->GetInput2(SmbNetLWEnum); _assert_(LW_input); 3833 Input2 *SW_input = this->GetInput2(SmbNetSWEnum); _assert_(SW_input); 3834 Input2 *LHF_input = this->GetInput2(SmbMeanLHFEnum); _assert_(LHF_input); 3835 Input2 *SHF_input = this->GetInput2(SmbMeanSHFEnum); _assert_(SHF_input); 3836 Input2 *DzAdd_input = this->GetInput2(SmbDzAddEnum); _assert_(DzAdd_input); 3837 Input2 *MassAdd_input = this->GetInput2(SmbMAddEnum); _assert_(MassAdd_input); 3838 Input2 *InitMass_input = this->GetInput2(SmbMInitnum); _assert_(InitMass_input); 3839 3840 ULW_input->GetInputAverage(&meanULW); 3841 LW_input->GetInputAverage(&netLW); 3842 SW_input->GetInputAverage(&netSW); 3843 LHF_input->GetInputAverage(&meanLHF); 3844 SHF_input->GetInputAverage(&meanSHF); 3845 DzAdd_input->GetInputAverage(&dz_add); 3846 MassAdd_input->GetInputAverage(&sumMassAdd); 3847 sumMassAdd=sumMassAdd*dt; 3848 InitMass_input->GetInputAverage(&initMass); 3849 sumEC_input->GetInputAverage(&sumEC); 3850 sumEC=sumEC*dt*rho_ice; 3851 sumM_input->GetInputAverage(&sumM); 3852 sumM=sumM*dt*rho_ice; 3853 sumR_input->GetInputAverage(&sumR); 3854 sumR=sumR*dt*rho_ice; 3855 sumP_input->GetInputAverage(&sumP); 3856 sumP=sumP*dt*rho_ice; 3857 } 3858 /*}}}*/ 3859 3860 // Get time forcing inputs 3861 Input2 *Ta_input = this->GetInput2(SmbTaEnum,timeinputs); _assert_(Ta_input); 3862 Input2 *V_input = this->GetInput2(SmbVEnum,timeinputs); _assert_(V_input); 3863 Input2 *Dlwr_input= this->GetInput2(SmbDlwrfEnum,timeinputs); _assert_(Dlwr_input); 3864 Input2 *Dswr_input= this->GetInput2(SmbDswrfEnum,timeinputs); _assert_(Dswr_input); 3865 Input2 *P_input = this->GetInput2(SmbPEnum,timeinputs); _assert_(P_input); 3866 Input2 *eAir_input= this->GetInput2(SmbEAirEnum,timeinputs); _assert_(eAir_input); 3867 Input2 *pAir_input= this->GetInput2(SmbPAirEnum,timeinputs); _assert_(pAir_input); 3868 Input2 *teValue_input= this->GetInput2(SmbTeValueEnum,timeinputs); _assert_(teValue_input); 3869 Input2 *aValue_input= this->GetInput2(SmbAValueEnum,timeinputs); _assert_(aValue_input); 3870 3871 /*extract daily data:{{{*/ 3872 Ta_input->GetInputValue(&Ta,gauss);//screen level air temperature [K] 3873 V_input->GetInputValue(&V,gauss); //wind speed [m s-1] 3874 Dlwr_input->GetInputValue(&dlw,gauss); //downward longwave radiation flux [W m-2] 3875 Dswr_input->GetInputValue(&dsw,gauss); //downward shortwave radiation flux [W m-2] 3876 P_input->GetInputValue(&P,gauss); //precipitation [kg m-2] 3877 eAir_input->GetInputValue(&eAir,gauss); //screen level vapor pressure [Pa] 3878 pAir_input->GetInputValue(&pAir,gauss); // screen level air pressure [Pa] 3879 teValue_input->GetInputValue(&teValue,gauss); // Emissivity [0-1] 3880 aValue_input->GetInputValue(&aValue,gauss); // Albedo [0 1] 3881 //_printf_("Time: " << t << " Ta: " << Ta << " V: " << V << " dlw: " << dlw << " dsw: " << dsw << " P: " << P << " eAir: " << eAir << " pAir: " << pAir << "\n"); 3882 /*}}}*/ 3883 3884 /*Snow grain metamorphism:*/ 3885 if(isgraingrowth)grainGrowth(&re, &gdn, &gsp, T, dz, d, W, smb_dt, m, aIdx,this->Sid()); 3886 3887 /*Snow, firn and ice albedo:*/ 3888 if(isalbedo)albedo(&a,aIdx,re,d,cldFrac,aIce,aSnow,aValue,adThresh,T,W,P,EC,t0wet,t0dry,K,smb_dt,rho_ice,m,this->Sid()); 3889 3890 /*Distribution of absorbed short wave radation with depth:*/ 3891 if(isshortwave)shortwave(&swf, swIdx, aIdx, dsw, a[0], d, dz, re,rho_ice,m,this->Sid()); 3892 3893 /*Calculate net shortwave [W m-2]*/ 3894 netSW = netSW + cellsum(swf,m)*smb_dt/dt; 3895 3896 /*Thermal profile computation:*/ 3897 if(isthermal)thermo(&EC, &T, &ulw, dz, d, swf, dlw, Ta, V, eAir, pAir, teValue, W[0], smb_dt, m, Vz, Tz, thermo_scaling,rho_ice,this->Sid()); 3898 3899 /*Change in thickness of top cell due to evaporation/condensation assuming same density as top cell. 3900 * need to fix this in case all or more of cell evaporates */ 3901 dz[0] = dz[0] + EC / d[0]; 3902 3903 /*Add snow/rain to top grid cell adjusting cell depth, temperature and density*/ 3904 if(isaccumulation)accumulation(&T, &dz, &d, &W, &a, &re, &gdn, &gsp, &m, aIdx, dsnowIdx, Tmean, Ta, P, dzMin, aSnow, C, V, Vmean, rho_ice,this->Sid()); 3905 3906 /*Calculate water production, M [kg m-2] resulting from snow/ice temperature exceeding 273.15 deg K 3907 * (> 0 deg C), runoff R [kg m-2] and resulting changes in density and determine wet compaction [m]*/ 3908 if(ismelt)melt(&M, &R, &mAdd, &dz_add, &T, &d, &dz, &W, &a, &re, &gdn, &gsp, &m, dzMin, zMax, zMin, zTop,rho_ice,this->Sid()); 3909 3910 /*Allow non-melt densification and determine compaction [m]*/ 3911 if(isdensification)densification(&d,&dz, T, re, denIdx, C, smb_dt, Tmean,rho_ice,m,this->Sid()); 3912 3913 /*Calculate upward longwave radiation flux [W m-2] not used in energy balance. Calculated for every 3914 * sub-time step in thermo equations*/ 3915 //ulw = 5.67E-8 * pow(T[0],4.0) * teValue; // + deltatest here 3916 3917 /*Calculate net longwave [W m-2]*/ 3918 meanULW = meanULW + ulw*smb_dt/dt; 3919 netLW = netLW + (dlw - ulw)*smb_dt/dt; 3920 3921 /*Calculate turbulent heat fluxes [W m-2]*/ 3922 if(isturbulentflux)turbulentFlux(&shf, &lhf, &dayEC, Ta, T[0], V, eAir, pAir, d[0], W[0], Vz, Tz,rho_ice,this->Sid()); 3923 3924 /*Verbose some results in debug mode: {{{*/ 3925 if(VerboseSmb() && 0){ 3926 _printf_("smb log: count[" << count << "] m[" << m << "] " 3927 << setprecision(16) << "T[" << cellsum(T,m) << "] " 3928 << "d[" << cellsum(d,m) << "] " 3929 << "dz[" << cellsum(dz,m) << "] " 3930 << "a[" << cellsum(a,m) << "] " 3931 << "W[" << cellsum(W,m) << "] " 3932 << "re[" << cellsum(re,m) << "] " 3933 << "gdn[" << cellsum(gdn,m) << "] " 3934 << "gsp[" << cellsum(gsp,m) << "] " 3935 << "swf[" << netSW << "] " 3936 << "lwf[" << netLW << "] " 3937 << "a[" << a << "] " 3938 << "te[" << teValue << "] " 3939 << "\n"); 3940 } /*}}}*/ 3941 3942 meanLHF = meanLHF + lhf*smb_dt/dt; 3943 meanSHF = meanSHF + shf*smb_dt/dt; 3944 3945 /*Sum component mass changes [kg m-2]*/ 3946 sumMassAdd = mAdd + sumMassAdd; 3947 sumM = M + sumM; 3948 sumR = R + sumR; 3949 sumW = cellsum(W,m); 3950 sumP = P + sumP; 3951 sumEC = sumEC + EC; // evap (-)/cond(+) 3952 3953 /*Calculate total system mass:*/ 3954 sumMass=0; 3955 fac=0; 3956 for(int i=0;i<m;i++){ 3957 sumMass += dz[i]*d[i]; 3958 fac += dz[i]*(rho_ice - fmin(d[i],rho_ice)); 3959 } 3960 3961 #if defined(_HAVE_AD_) 3962 /*we want to avoid the round operation at all cost. Not differentiable.*/ 3963 _error_("not implemented yet"); 3964 #else 3965 dMass = sumMass + sumR + sumW - sumP - sumEC - initMass - sumMassAdd; 3966 dMass = round(dMass * 100.0)/100.0; 3967 3968 /*Check mass conservation:*/ 3969 if (dMass != 0.0){ 3970 _printf_("total system mass not conserved in MB function \n"); 3971 } 3972 #endif 3973 3974 /*Check bottom grid cell T is unchanged:*/ 3975 if(VerboseSmb() && this->Sid()==0 && IssmComm::GetRank()==0){ 3976 if (T[m-1]!=T_bottom) _printf_("T(end)~=T_bottom" << "\n"); 3977 } 3977 3978 3978 3979 /*Save generated inputs: */ … … 3995 3996 this->SetElementInput(SmbMeanLHFEnum,meanLHF); 3996 3997 this->SetElementInput(SmbMeanSHFEnum,meanSHF); 3997 this->SetElementInput(SmbDzAddEnum,sumdz_add); 3998 this->SetElementInput(SmbDzAddEnum,dz_add); 3999 this->SetElementInput(SmbMInitnum,initMass); 3998 4000 this->SetElementInput(SmbMAddEnum,sumMassAdd/dt); 4001 this->SetElementInput(SmbWAddEnum,sumW/dt); 3999 4002 this->SetElementInput(SmbFACEnum,fac/1000.); // output in meters 4003 this->SetElementInput(SmbECDtEnum,EC); 4000 4004 4001 4005 /*Free allocations:{{{*/ … … 4016 4020 if(aini) xDelete<IssmDouble>(aini); 4017 4021 if(Tini) xDelete<IssmDouble>(Tini); 4022 if(swf) xDelete<IssmDouble>(swf); 4018 4023 4019 4024 delete gauss; -
issm/trunk-jpl/src/c/classes/Elements/Element.h
r24565 r24683 172 172 void SmbSemic(); 173 173 int Sid(); 174 void SmbGemb( );174 void SmbGemb(IssmDouble timeinputs, int count); 175 175 void StrainRateESA(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input2* vx_input,Input2* vy_input); 176 176 void StrainRateFS(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input2* vx_input,Input2* vy_input,Input2* vz_input); -
issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/Gembx.cpp
r24509 r24683 6 6 #include "../../shared/shared.h" 7 7 #include "../../toolkits/toolkits.h" 8 #include "../modules.h" 9 #include "../../classes/Inputs2/TransientInput2.h" 8 10 9 11 const double Pi = 3.141592653589793; … … 32 34 void Gembx(FemModel* femmodel){ /*{{{*/ 33 35 34 for(int i=0;i<femmodel->elements->Size();i++){ 35 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 36 element->SmbGemb(); 36 int count=0; 37 IssmDouble time,dt,finaltime,starttime; 38 IssmDouble timeclim=0.0; 39 IssmDouble t,smb_dt; 40 IssmDouble delta; 41 bool isclimatology=false; 42 43 femmodel->parameters->FindParam(&time,TimeEnum); /*transient core time at which we run the smb core*/ 44 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); /*transient core time step*/ 45 femmodel->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum); 46 femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum); 47 femmodel->parameters->FindParam(&smb_dt,SmbDtEnum); /*time period for the smb solution, usually smaller than the glaciological dt*/ 48 femmodel->parameters->FindParam(&isclimatology,SmbIsclimatologyEnum); 49 50 //before starting loop, realize that the transient core runs this smb_core at time = time +deltaT. 51 //go back to time - deltaT: 52 time-=dt; 53 54 IssmDouble timeinputs = time; 55 56 /*Start loop: */ 57 count=1; 58 for (t=time;t<time+dt;t=t+smb_dt){ 59 60 for(int i=0;i<femmodel->elements->Size();i++){ 61 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 62 63 timeclim=time; 64 if (isclimatology){ 65 //If this is a climatology, we need to repeat the forcing after the final time 66 TransientInput2* Ta_input_tr = element->inputs2->GetTransientInput(SmbTaEnum); _assert_(Ta_input_tr); 67 68 /*Get temperature climatology value*/ 69 int offsetend = Ta_input_tr->GetTimeInputOffset(finaltime); 70 IssmDouble time0 = Ta_input_tr->GetTimeByOffset(-1); 71 IssmDouble timeend = Ta_input_tr->GetTimeByOffset(offsetend); 72 if (time>time0 & timeend>time0){ 73 delta=(time-time0) - (timeend-time0)*(reCast<int,IssmDouble>((time-time0)/(timeend-time0))); 74 timeclim=time0+delta; 75 } 76 } 77 timeinputs = t-time+timeclim; 78 element->SmbGemb(timeinputs,count); 79 } 80 count=count+1; 37 81 } 38 82 … … 1045 1089 // SWs and SWss coefficients need to be better constranted. Greuell 1046 1090 // and Konzelmann 1994 used SWs = 0.36 and SWss = 0.64 as this the 1047 // the //of SW radiation with wavelengths > and < 800 nm1091 // the % of SW radiation with wavelengths > and < 800 nm 1048 1092 // respectively. This, however, may not account for the fact that 1049 1093 // the albedo of wavelengths > 800 nm has a much lower albedo. … … 2107 2151 2108 2152 // calculate the Bulk Richardson Number (Ri) 2109 Ri = (2.0*9.81* (Vz - z0) * (Ta - Ts)) / ((Ta + Ts)* pow(V,2 ));2110 2111 // calculate Monin-Obukhov stability factors 'coef _M' and 'coef_H'2153 Ri = (2.0*9.81* (Vz - z0) * (Ta - Ts)) / ((Ta + Ts)* pow(V,2.0)); 2154 2155 // calculate Monin-Obukhov stability factors 'coefM' and 'coefH' 2112 2156 2113 2157 // do not allow Ri to exceed 0.19 -
issm/trunk-jpl/src/c/shared/Enum/Enum.vim
r24626 r24683 149 149 syn keyword cConstant FrictionCouplingEnum 150 150 syn keyword cConstant FrictionDeltaEnum 151 syn keyword cConstant FrictionEffectivePressureLimitEnum 151 152 syn keyword cConstant FrictionFEnum 152 153 syn keyword cConstant FrictionGammaEnum … … 717 718 syn keyword cConstant SmbEAirEnum 718 719 syn keyword cConstant SmbECEnum 720 syn keyword cConstant SmbECDtEnum 719 721 syn keyword cConstant SmbECiniEnum 720 722 syn keyword cConstant SmbElaEnum … … 774 776 syn keyword cConstant SmbVzEnum 775 777 syn keyword cConstant SmbWEnum 778 syn keyword cConstant SmbWAddEnum 776 779 syn keyword cConstant SmbWiniEnum 777 780 syn keyword cConstant SmbZMaxEnum … … 1335 1338 syn keyword cType Cfsurfacesquare 1336 1339 syn keyword cType Channel 1337 syn keyword cType classes1338 1340 syn keyword cType Constraint 1339 1341 syn keyword cType Constraints … … 1342 1344 syn keyword cType ControlInput2 1343 1345 syn keyword cType Covertree 1346 syn keyword cType DataSetParam 1344 1347 syn keyword cType DatasetInput2 1345 syn keyword cType DataSetParam1346 1348 syn keyword cType Definition 1347 1349 syn keyword cType DependentObject … … 1355 1357 syn keyword cType ElementInput2 1356 1358 syn keyword cType ElementMatrix 1359 syn keyword cType ElementVector 1357 1360 syn keyword cType Elements 1358 syn keyword cType ElementVector1359 1361 syn keyword cType ExponentialVariogram 1360 1362 syn keyword cType ExternalResult … … 1363 1365 syn keyword cType Friction 1364 1366 syn keyword cType Gauss 1365 syn keyword cType GaussianVariogram1366 syn keyword cType gaussobjects1367 1367 syn keyword cType GaussPenta 1368 1368 syn keyword cType GaussSeg 1369 1369 syn keyword cType GaussTetra 1370 1370 syn keyword cType GaussTria 1371 syn keyword cType GaussianVariogram 1371 1372 syn keyword cType GenericExternalResult 1372 1373 syn keyword cType GenericOption … … 1383 1384 syn keyword cType IssmDirectApplicInterface 1384 1385 syn keyword cType IssmParallelDirectApplicInterface 1385 syn keyword cType krigingobjects1386 1386 syn keyword cType Load 1387 1387 syn keyword cType Loads … … 1394 1394 syn keyword cType Matice 1395 1395 syn keyword cType Matlitho 1396 syn keyword cType matrixobjects1397 1396 syn keyword cType MatrixParam 1398 1397 syn keyword cType Misfit … … 1407 1406 syn keyword cType Observations 1408 1407 syn keyword cType Option 1408 syn keyword cType OptionUtilities 1409 1409 syn keyword cType Options 1410 syn keyword cType OptionUtilities1411 1410 syn keyword cType Param 1412 1411 syn keyword cType Parameters … … 1422 1421 syn keyword cType Regionaloutput 1423 1422 syn keyword cType Results 1423 syn keyword cType RiftStruct 1424 1424 syn keyword cType Riftfront 1425 syn keyword cType RiftStruct1426 1425 syn keyword cType Seg 1427 1426 syn keyword cType SegInput2 1427 syn keyword cType SegRef 1428 1428 syn keyword cType Segment 1429 syn keyword cType SegRef1430 1429 syn keyword cType SpcDynamic 1431 1430 syn keyword cType SpcStatic … … 1446 1445 syn keyword cType Vertex 1447 1446 syn keyword cType Vertices 1447 syn keyword cType classes 1448 syn keyword cType gaussobjects 1449 syn keyword cType krigingobjects 1450 syn keyword cType matrixobjects 1448 1451 syn keyword cType AdjointBalancethickness2Analysis 1449 1452 syn keyword cType AdjointBalancethicknessAnalysis … … 1464 1467 syn keyword cType FreeSurfaceBaseAnalysis 1465 1468 syn keyword cType FreeSurfaceTopAnalysis 1469 syn keyword cType GLheightadvectionAnalysis 1466 1470 syn keyword cType GiaIvinsAnalysis 1467 syn keyword cType GLheightadvectionAnalysis1468 1471 syn keyword cType HydrologyDCEfficientAnalysis 1469 1472 syn keyword cType HydrologyDCInefficientAnalysis -
issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
r24666 r24683 715 715 SmbEAirEnum, 716 716 SmbECEnum, 717 SmbECDtEnum, 717 718 SmbECiniEnum, 718 719 SmbElaEnum, … … 734 735 SmbMeanULWEnum, 735 736 SmbMeltEnum, 737 SmbMInitnum, 736 738 SmbMonthlytemperaturesEnum, 737 739 SmbNetLWEnum, … … 772 774 SmbVzEnum, 773 775 SmbWEnum, 776 SmbWAddEnum, 774 777 SmbWiniEnum, 775 778 SmbZMaxEnum, -
issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
r24666 r24683 720 720 case SmbEAirEnum : return "SmbEAir"; 721 721 case SmbECEnum : return "SmbEC"; 722 case SmbECDtEnum : return "SmbECDt"; 722 723 case SmbECiniEnum : return "SmbECini"; 723 724 case SmbElaEnum : return "SmbEla"; … … 777 778 case SmbVzEnum : return "SmbVz"; 778 779 case SmbWEnum : return "SmbW"; 780 case SmbWAddEnum : return "SmbWAdd"; 779 781 case SmbWiniEnum : return "SmbWini"; 780 782 case SmbZMaxEnum : return "SmbZMax"; -
issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
r24666 r24683 735 735 else if (strcmp(name,"SmbEAir")==0) return SmbEAirEnum; 736 736 else if (strcmp(name,"SmbEC")==0) return SmbECEnum; 737 else if (strcmp(name,"SmbECDt")==0) return SmbECDtEnum; 737 738 else if (strcmp(name,"SmbECini")==0) return SmbECiniEnum; 738 739 else if (strcmp(name,"SmbEla")==0) return SmbElaEnum; … … 751 752 else if (strcmp(name,"SmbMassBalanceTransient")==0) return SmbMassBalanceTransientEnum; 752 753 else if (strcmp(name,"SmbMeanLHF")==0) return SmbMeanLHFEnum; 753 else if (strcmp(name,"SmbMeanSHF")==0) return SmbMeanSHFEnum;754 754 else stage=7; 755 755 } 756 756 if(stage==7){ 757 if (strcmp(name,"SmbMeanULW")==0) return SmbMeanULWEnum; 757 if (strcmp(name,"SmbMeanSHF")==0) return SmbMeanSHFEnum; 758 else if (strcmp(name,"SmbMeanULW")==0) return SmbMeanULWEnum; 758 759 else if (strcmp(name,"SmbMelt")==0) return SmbMeltEnum; 759 760 else if (strcmp(name,"SmbMonthlytemperatures")==0) return SmbMonthlytemperaturesEnum; … … 795 796 else if (strcmp(name,"SmbVz")==0) return SmbVzEnum; 796 797 else if (strcmp(name,"SmbW")==0) return SmbWEnum; 798 else if (strcmp(name,"SmbWAdd")==0) return SmbWAddEnum; 797 799 else if (strcmp(name,"SmbWini")==0) return SmbWiniEnum; 798 800 else if (strcmp(name,"SmbZMax")==0) return SmbZMaxEnum; … … 873 875 else if (strcmp(name,"Outputdefinition17")==0) return Outputdefinition17Enum; 874 876 else if (strcmp(name,"Outputdefinition18")==0) return Outputdefinition18Enum; 875 else if (strcmp(name,"Outputdefinition19")==0) return Outputdefinition19Enum;876 else if (strcmp(name,"Outputdefinition20")==0) return Outputdefinition20Enum;877 877 else stage=8; 878 878 } 879 879 if(stage==8){ 880 if (strcmp(name,"Outputdefinition21")==0) return Outputdefinition21Enum; 880 if (strcmp(name,"Outputdefinition19")==0) return Outputdefinition19Enum; 881 else if (strcmp(name,"Outputdefinition20")==0) return Outputdefinition20Enum; 882 else if (strcmp(name,"Outputdefinition21")==0) return Outputdefinition21Enum; 881 883 else if (strcmp(name,"Outputdefinition22")==0) return Outputdefinition22Enum; 882 884 else if (strcmp(name,"Outputdefinition23")==0) return Outputdefinition23Enum; … … 996 998 else if (strcmp(name,"BoolInput2")==0) return BoolInput2Enum; 997 999 else if (strcmp(name,"IntInput2")==0) return IntInput2Enum; 998 else if (strcmp(name,"BoolParam")==0) return BoolParamEnum;999 else if (strcmp(name,"Boundary")==0) return BoundaryEnum;1000 1000 else stage=9; 1001 1001 } 1002 1002 if(stage==9){ 1003 if (strcmp(name,"BuddJacka")==0) return BuddJackaEnum; 1003 if (strcmp(name,"BoolParam")==0) return BoolParamEnum; 1004 else if (strcmp(name,"Boundary")==0) return BoundaryEnum; 1005 else if (strcmp(name,"BuddJacka")==0) return BuddJackaEnum; 1004 1006 else if (strcmp(name,"CalvingDev2")==0) return CalvingDev2Enum; 1005 1007 else if (strcmp(name,"CalvingHab")==0) return CalvingHabEnum; … … 1119 1121 else if (strcmp(name,"IcefrontMassFlux")==0) return IcefrontMassFluxEnum; 1120 1122 else if (strcmp(name,"IcefrontMassFluxLevelset")==0) return IcefrontMassFluxLevelsetEnum; 1121 else if (strcmp(name,"Incremental")==0) return IncrementalEnum;1122 else if (strcmp(name,"Indexed")==0) return IndexedEnum;1123 1123 else stage=10; 1124 1124 } 1125 1125 if(stage==10){ 1126 if (strcmp(name,"IntExternalResult")==0) return IntExternalResultEnum; 1126 if (strcmp(name,"Incremental")==0) return IncrementalEnum; 1127 else if (strcmp(name,"Indexed")==0) return IndexedEnum; 1128 else if (strcmp(name,"IntExternalResult")==0) return IntExternalResultEnum; 1127 1129 else if (strcmp(name,"IntInput")==0) return IntInputEnum; 1128 1130 else if (strcmp(name,"ElementInput2")==0) return ElementInput2Enum; … … 1242 1244 else if (strcmp(name,"Regionaloutput")==0) return RegionaloutputEnum; 1243 1245 else if (strcmp(name,"Regular")==0) return RegularEnum; 1244 else if (strcmp(name,"RecoveryAnalysis")==0) return RecoveryAnalysisEnum;1245 else if (strcmp(name,"Riftfront")==0) return RiftfrontEnum;1246 1246 else stage=11; 1247 1247 } 1248 1248 if(stage==11){ 1249 if (strcmp(name,"SIAApproximation")==0) return SIAApproximationEnum; 1249 if (strcmp(name,"RecoveryAnalysis")==0) return RecoveryAnalysisEnum; 1250 else if (strcmp(name,"Riftfront")==0) return RiftfrontEnum; 1251 else if (strcmp(name,"SIAApproximation")==0) return SIAApproximationEnum; 1250 1252 else if (strcmp(name,"SMBcomponents")==0) return SMBcomponentsEnum; 1251 1253 else if (strcmp(name,"SMBd18opdd")==0) return SMBd18opddEnum;
Note:
See TracChangeset
for help on using the changeset viewer.