Changeset 19567
- Timestamp:
- 09/19/15 14:55:36 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Element.cpp
r19554 r19567 2137 2137 int swIdx=0; 2138 2138 IssmDouble cldFrac,t0wet, t0dry, K; 2139 IssmDouble comp1,comp2;2140 2139 IssmDouble ulw; 2141 2140 IssmDouble netSW; … … 2146 2145 IssmDouble sumMass,dMass; 2147 2146 bool isgraingrowth,isalbedo,isshortwave,isthermal,isaccumulation,ismelt,isdensification,isturbulentflux; 2147 IssmDouble init_scaling=1.0; 2148 2148 /*}}}*/ 2149 2149 /*Output variables:{{{ */ … … 2163 2163 IssmDouble mAdd; 2164 2164 int m; 2165 IssmDouble SmbMassBalance=0; 2165 2166 /*}}}*/ 2166 2167 2167 2168 /*only compute SMB at the surface: */ 2168 2169 if (!IsOnSurface()) return; 2170 2169 2171 2170 2172 /*Retrieve material properties and parameters:{{{ */ … … 2190 2192 parameters->FindParam(&isdensification,SmbIsdensificationEnum); 2191 2193 parameters->FindParam(&isturbulentflux,SmbIsturbulentfluxEnum); 2194 parameters->FindParam(&init_scaling,SmbInitDensityScalingEnum); 2192 2195 /*}}}*/ 2193 2196 /*Retrieve inputs: {{{*/ … … 2225 2228 Vz_input->GetInputValue(&Vz,gauss); 2226 2229 /*}}}*/ 2230 2227 2231 /*First, check that the initial structures have been setup in GEMB. If not, initialize profile variables: layer thickness dz, * density d, temperature T, etc. {{{*/ 2228 if(!isinitialized_input){ 2229 2230 /*Initialize grid:*/2232 if(!isinitialized_input){ 2233 2234 if(VerboseSmb() && this->Sid()==0)_printf0_("smb core: Initializing grid\n"); 2231 2235 GembgridInitialize(&dz, &m, zTop, dzTop, zMax, zY); 2232 2236 //if(this->Sid()==1) for(int i=0;i<m;i++)_printf_("z[" << i << "]=" << … … 2234 2238 2235 2239 /*initialize profile variables:*/ 2236 d = xNewZeroInit<IssmDouble>(m); for(int i=0;i<m;i++)d[i]=rho_ice ; //ice density2240 d = xNewZeroInit<IssmDouble>(m); for(int i=0;i<m;i++)d[i]=rho_ice*init_scaling; //ice density scaled by a factor 2237 2241 re = xNewZeroInit<IssmDouble>(m); for(int i=0;i<m;i++)re[i]=2.5; //set grain size to old snow [mm] 2238 2242 gdn = xNewZeroInit<IssmDouble>(m); for(int i=0;i<m;i++)gdn[i]=0; //set grain dentricity to old snow … … 2242 2246 a = xNewZeroInit<IssmDouble>(m); for(int i=0;i<m;i++)a[i]=aSnow; //set albedo equal to fresh snow [fraction] 2243 2247 T = xNewZeroInit<IssmDouble>(m); for(int i=0;i<m;i++)T[i]=Tmean; //set initial grid cell temperature to the annual mean temperature [K] 2248 swf = xNewZeroInit<IssmDouble>(m); 2244 2249 2245 2250 //fixed lower temperatuer bounday condition - T is fixed … … 2251 2256 else{ 2252 2257 /*Recover inputs: */ 2253 DoubleArrayInput* dz_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbDzEnum)); 2254 DoubleArrayInput* d_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbDEnum)); 2255 DoubleArrayInput* re_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbReEnum)); 2256 DoubleArrayInput* gdn_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbGdnEnum)); 2257 DoubleArrayInput* gsp_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbGspEnum)); 2258 DoubleInput* EC_input= dynamic_cast<DoubleInput*>(this->GetInput(SmbECEnum)); 2259 DoubleArrayInput* W_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbWEnum)); 2260 DoubleArrayInput* a_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbAEnum)); 2261 DoubleArrayInput* T_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbTEnum)); 2258 DoubleArrayInput* dz_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbDzEnum)); _assert_(dz_input); 2259 DoubleArrayInput* d_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbDEnum));_assert_(d_input); 2260 DoubleArrayInput* re_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbReEnum));_assert_(re_input); 2261 DoubleArrayInput* gdn_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbGdnEnum));_assert_(gdn_input); 2262 DoubleArrayInput* gsp_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbGspEnum));_assert_(gsp_input); 2263 DoubleInput* EC_input= dynamic_cast<DoubleInput*>(this->GetInput(SmbECEnum));_assert_(EC_input); 2264 DoubleArrayInput* W_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbWEnum));_assert_(W_input); 2265 DoubleArrayInput* a_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbAEnum));_assert_(a_input); 2266 DoubleArrayInput* T_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbTEnum));_assert_(T_input); 2267 DoubleArrayInput* swf_input= dynamic_cast<DoubleArrayInput*>(this->GetInput(SmbSwfEnum));_assert_(swf_input); 2262 2268 2263 2269 /*Recover arrays: */ … … 2271 2277 a_input->GetValues(&a,&m); 2272 2278 T_input->GetValues(&T,&m); 2279 swf_input->GetValues(&swf,&m); 2273 2280 2274 2281 } /*}}}*/ … … 2280 2287 sumR = 0; sumM = 0; sumEC = 0; sumP = 0; sumMassAdd = 0; 2281 2288 2289 //before starting loop, realize that the transient core runs this smb_core at time = time +deltaT. 2290 //go back to time - deltaT: 2291 time-=dt; 2292 2282 2293 /*Start loop: */ 2283 2294 for (t=time;t<=time+dt;t=t+smb_dt){ 2295 2296 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" << "\n"); 2284 2297 2285 2298 /*extract daily data:{{{*/ … … 2295 2308 2296 2309 /*Snow grain metamorphism:*/ 2297 if(isgraingrowth)grainGrowth(re, gdn, gsp, T, dz, d, W, smb_dt, m, aIdx );2310 if(isgraingrowth)grainGrowth(re, gdn, gsp, T, dz, d, W, smb_dt, m, aIdx,this->Sid()); 2298 2311 2299 2312 /*Snow, firn and ice albedo:*/ 2300 if(isalbedo)albedo(a,aIdx,re,d,cldFrac,aIce, aSnow,T,W,P,EC,t0wet,t0dry,K,smb_dt,m );2313 if(isalbedo)albedo(a,aIdx,re,d,cldFrac,aIce, aSnow,T,W,P,EC,t0wet,t0dry,K,smb_dt,m,this->Sid()); 2301 2314 2315 2302 2316 /*Distribution of absorbed short wave radation with depth:*/ 2303 if(isshortwave)shortwave( &swf, swIdx, aIdx, dsw, a[0], d, dz, re,m);2317 if(isshortwave)shortwave(swf, swIdx, aIdx, dsw, a[0], d, dz, re,m,this->Sid()); 2304 2318 2305 2319 /*Thermal profile computation:*/ 2306 if(isthermal)thermo(&EC, T, dz, d, swf, dlw, Ta, V, eAir, pAir, W[0], smb_dt, Vz, Tz,m);2320 if(isthermal)thermo(&EC, T, dz, d, swf, dlw, Ta, V, eAir, pAir, W[0], smb_dt, m, Vz, Tz,this->Sid()); 2307 2321 2308 2322 /*Change in thickness of top cell due to evaporation/condensation assuming same density as top cell. … … 2311 2325 2312 2326 /*Add snow/rain to top grid cell adjusting cell depth, temperature and density*/ 2313 if(isaccumulation)accumulation(&T, &dz, &d, &W, &a, &re, &gdn, &gsp, &m, Ta, P, dzMin, aSnow );2327 if(isaccumulation)accumulation(&T, &dz, &d, &W, &a, &re, &gdn, &gsp, &m, Ta, P, dzMin, aSnow,this->Sid()); 2314 2328 2315 2329 /*Calculate water production, M [kg m-2] resulting from snow/ice temperature exceeding 273.15 deg K 2316 2330 * (> 0 deg C), runoff R [kg m-2] and resulting changes in density and determine wet compaction [m]*/ 2317 comp2 = cellsum(dz,m); 2318 if(ismelt)melt(&M, &R, &mAdd, &T, &d, &dz, &W, &a, &re, &gdn, &gsp, &m, dzMin, zMax, zMin); 2319 comp2 = (comp2 - cellsum(dz,m)); 2331 if(ismelt)melt(&M, &R, &mAdd, &T, &d, &dz, &W, &a, &re, &gdn, &gsp, &m, dzMin, zMax, zMin,this->Sid()); 2320 2332 2321 2333 /*Allow non-melt densification and determine compaction [m]*/ 2322 comp1 = cellsum(dz,m); 2323 if(isdensification)densification(d,dz, T, re, denIdx, C, smb_dt, Tmean,m); 2324 comp1 = (comp1 - cellsum(dz,m)); 2334 if(isdensification)densification(d,dz, T, re, denIdx, C, smb_dt, Tmean,rho_ice,m,this->Sid()); 2325 2335 2326 2336 /*Calculate upward longwave radiation flux [W m-2] not used in energy balance. Calculated for every … … 2333 2343 2334 2344 /*Calculate turbulent heat fluxes [W m-2]*/ 2335 if(isturbulentflux)turbulentFlux(&shf, &lhf, &dayEC, Ta, T[0], V, eAir, pAir, d[0], W[0], Vz, Tz );2345 if(isturbulentflux)turbulentFlux(&shf, &lhf, &dayEC, Ta, T[0], V, eAir, pAir, d[0], W[0], Vz, Tz,this->Sid()); 2336 2346 2337 2347 /*Sum component mass changes [kg m-2]*/ … … 2347 2357 dMass = sumMass + sumR + sumW - sumP - sumEC - initMass - sumMassAdd; 2348 2358 dMass = round(dMass * 100.0)/100.0; 2349 2359 2350 2360 /*Check mass conservation:*/ 2351 if (dMass != 0.0) _error_("total system mass not conserved in MB function");2361 if(!VerboseSmb())if (dMass != 0.0) _printf_("total system mass not conserved in MB function"); 2352 2362 2353 2363 /*Check bottom grid cell T is unchanged:*/ 2354 if (T[m-1]!=T_bottom) _printf_("T(end)~=T_bottom"); 2355 } 2364 if(!VerboseSmb())if (T[m-1]!=T_bottom) _printf_("T(end)~=T_bottom" << "\n"); 2365 2366 SmbMassBalance += sumP + sumEC - sumR; //increment SMB for the entire time span of ice-flow dynamics. 2367 2368 2369 } //for (t=time;t<=time+dt;t=t+smb_dt) 2356 2370 2357 2371 /*Save generated inputs: */ … … 2361 2375 this->AddInput(new DoubleArrayInput(SmbGdnEnum,gdn,m)); 2362 2376 this->AddInput(new DoubleArrayInput(SmbGspEnum,gsp,m)); 2377 this->AddInput(new DoubleArrayInput(SmbTEnum,T,m)); 2363 2378 this->AddInput(new DoubleInput(SmbECEnum,EC)); 2364 2379 this->AddInput(new DoubleArrayInput(SmbWEnum,W,m)); 2365 2380 this->AddInput(new DoubleArrayInput(SmbAEnum,a,m)); 2366 this->AddInput(new DoubleArrayInput(SmbTEnum,T,m)); 2381 this->AddInput(new DoubleArrayInput(SmbSwfEnum,swf,m)); 2382 this->AddInput(new DoubleInput(SmbMassBalanceEnum,time)); 2383 2367 2384 2368 2385 /*Free allocations:{{{*/
Note:
See TracChangeset
for help on using the changeset viewer.