[17085] | 1 | /*!\file SurfaceMassBalancex
|
---|
[23366] | 2 | * \brief: calculates SMB
|
---|
[17085] | 3 | */
|
---|
| 4 |
|
---|
[26479] | 5 | #include <config.h>
|
---|
[17085] | 6 | #include "./SurfaceMassBalancex.h"
|
---|
| 7 | #include "../../shared/shared.h"
|
---|
| 8 | #include "../../toolkits/toolkits.h"
|
---|
[23814] | 9 | #include "../modules.h"
|
---|
[25379] | 10 | #include "../../classes/Inputs/TransientInput.h"
|
---|
[26477] | 11 | #include "../../shared/Random/random.h"
|
---|
[17085] | 12 |
|
---|
[23814] | 13 | void SmbForcingx(FemModel* femmodel){/*{{{*/
|
---|
| 14 |
|
---|
| 15 | // void SmbForcingx(smb,ni){
|
---|
| 16 | // INPUT parameters: ni: working size of arrays
|
---|
| 17 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
| 18 |
|
---|
| 19 | }/*}}}*/
|
---|
[17085] | 20 | void SmbGradientsx(FemModel* femmodel){/*{{{*/
|
---|
| 21 |
|
---|
| 22 | // void SurfaceMassBalancex(hd,agd,ni){
|
---|
| 23 | // INPUT parameters: ni: working size of arrays
|
---|
| 24 | // INPUT: surface elevation (m): hd(NA)
|
---|
| 25 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
[18001] | 26 | int v;
|
---|
| 27 | IssmDouble rho_water; // density of fresh water
|
---|
| 28 | IssmDouble rho_ice; // density of ice
|
---|
[21469] | 29 | IssmDouble yts; // conversion factor year to second
|
---|
[17085] | 30 |
|
---|
[18001] | 31 | /*Loop over all the elements of this partition*/
|
---|
[25539] | 32 | for(Object* & object : femmodel->elements->objects){
|
---|
| 33 | Element* element=xDynamicCast<Element*>(object);
|
---|
[18001] | 34 |
|
---|
| 35 | /*Allocate all arrays*/
|
---|
| 36 | int numvertices = element->GetNumberOfVertices();
|
---|
| 37 | IssmDouble* Href = xNew<IssmDouble>(numvertices); // reference elevation from which deviations are used to calculate the SMB adjustment
|
---|
| 38 | IssmDouble* Smbref = xNew<IssmDouble>(numvertices); // reference SMB to which deviations are added
|
---|
| 39 | IssmDouble* b_pos = xNew<IssmDouble>(numvertices); // Hs-SMB relation parameter
|
---|
| 40 | IssmDouble* b_neg = xNew<IssmDouble>(numvertices); // Hs-SMB relation paremeter
|
---|
| 41 | IssmDouble* s = xNew<IssmDouble>(numvertices); // surface elevation (m)
|
---|
| 42 | IssmDouble* smb = xNew<IssmDouble>(numvertices);
|
---|
| 43 |
|
---|
| 44 | /*Recover SmbGradients*/
|
---|
[19527] | 45 | element->GetInputListOnVertices(Href,SmbHrefEnum);
|
---|
| 46 | element->GetInputListOnVertices(Smbref,SmbSmbrefEnum);
|
---|
| 47 | element->GetInputListOnVertices(b_pos,SmbBPosEnum);
|
---|
| 48 | element->GetInputListOnVertices(b_neg,SmbBNegEnum);
|
---|
[18001] | 49 |
|
---|
[18266] | 50 | /*Recover surface elevation at vertices: */
|
---|
[18001] | 51 | element->GetInputListOnVertices(s,SurfaceEnum);
|
---|
| 52 |
|
---|
| 53 | /*Get material parameters :*/
|
---|
[23644] | 54 | rho_ice=element->FindParam(MaterialsRhoIceEnum);
|
---|
| 55 | rho_water=element->FindParam(MaterialsRhoFreshwaterEnum);
|
---|
[18001] | 56 |
|
---|
[21469] | 57 | /* Get constants */
|
---|
| 58 | femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
|
---|
| 59 |
|
---|
[18001] | 60 | // loop over all vertices
|
---|
| 61 | for(v=0;v<numvertices;v++){
|
---|
| 62 | if(Smbref[v]>0){
|
---|
| 63 | smb[v]=Smbref[v]+b_pos[v]*(s[v]-Href[v]);
|
---|
| 64 | }
|
---|
| 65 | else{
|
---|
| 66 | smb[v]=Smbref[v]+b_neg[v]*(s[v]-Href[v]);
|
---|
| 67 | }
|
---|
[21469] | 68 |
|
---|
[18266] | 69 | smb[v]=smb[v]/1000*rho_water/rho_ice; // SMB in m/y ice
|
---|
[18001] | 70 | } //end of the loop over the vertices
|
---|
| 71 |
|
---|
| 72 | /*Add input to element and Free memory*/
|
---|
[25379] | 73 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
[18001] | 74 | xDelete<IssmDouble>(Href);
|
---|
| 75 | xDelete<IssmDouble>(Smbref);
|
---|
| 76 | xDelete<IssmDouble>(b_pos);
|
---|
| 77 | xDelete<IssmDouble>(b_neg);
|
---|
| 78 | xDelete<IssmDouble>(s);
|
---|
| 79 | xDelete<IssmDouble>(smb);
|
---|
[17085] | 80 | }
|
---|
| 81 |
|
---|
| 82 | }/*}}}*/
|
---|
[21469] | 83 | void SmbGradientsElax(FemModel* femmodel){/*{{{*/
|
---|
| 84 |
|
---|
| 85 | // void SurfaceMassBalancex(hd,agd,ni){
|
---|
| 86 | // INPUT parameters: ni: working size of arrays
|
---|
| 87 | // INPUT: surface elevation (m): hd(NA)
|
---|
| 88 | // OUTPUT: surface mass-balance (m/yr ice): agd(NA)
|
---|
| 89 | int v;
|
---|
| 90 |
|
---|
| 91 | /*Loop over all the elements of this partition*/
|
---|
[25539] | 92 | for(Object* & object : femmodel->elements->objects){
|
---|
| 93 | Element* element=xDynamicCast<Element*>(object);
|
---|
[21469] | 94 |
|
---|
| 95 | /*Allocate all arrays*/
|
---|
| 96 | int numvertices = element->GetNumberOfVertices();
|
---|
| 97 | IssmDouble* ela = xNew<IssmDouble>(numvertices); // Equilibrium Line Altitude (m a.s.l) to which deviations are used to calculate the SMB
|
---|
| 98 | IssmDouble* b_pos = xNew<IssmDouble>(numvertices); // SMB gradient above ELA (m ice eq. per m elevation change)
|
---|
| 99 | IssmDouble* b_neg = xNew<IssmDouble>(numvertices); // SMB gradient below ELA (m ice eq. per m elevation change)
|
---|
| 100 | IssmDouble* b_max = xNew<IssmDouble>(numvertices); // Upper cap on SMB rate (m/y ice eq.)
|
---|
| 101 | IssmDouble* b_min = xNew<IssmDouble>(numvertices); // Lower cap on SMB rate (m/y ice eq.)
|
---|
| 102 | IssmDouble* s = xNew<IssmDouble>(numvertices); // Surface elevation (m a.s.l.)
|
---|
| 103 | IssmDouble* smb = xNew<IssmDouble>(numvertices); // SMB (m/y ice eq.)
|
---|
| 104 |
|
---|
| 105 | /*Recover ELA, SMB gradients, and caps*/
|
---|
| 106 | element->GetInputListOnVertices(ela,SmbElaEnum);
|
---|
| 107 | element->GetInputListOnVertices(b_pos,SmbBPosEnum);
|
---|
| 108 | element->GetInputListOnVertices(b_neg,SmbBNegEnum);
|
---|
| 109 | element->GetInputListOnVertices(b_max,SmbBMaxEnum);
|
---|
| 110 | element->GetInputListOnVertices(b_min,SmbBMinEnum);
|
---|
| 111 |
|
---|
| 112 | /*Recover surface elevation at vertices: */
|
---|
| 113 | element->GetInputListOnVertices(s,SurfaceEnum);
|
---|
| 114 |
|
---|
| 115 | /*Loop over all vertices, calculate SMB*/
|
---|
| 116 | for(v=0;v<numvertices;v++){
|
---|
| 117 | // if surface is above the ELA
|
---|
[23366] | 118 | if(s[v]>ela[v]){
|
---|
[21469] | 119 | smb[v]=b_pos[v]*(s[v]-ela[v]);
|
---|
| 120 | }
|
---|
| 121 | // if surface is below or equal to the ELA
|
---|
| 122 | else{
|
---|
| 123 | smb[v]=b_neg[v]*(s[v]-ela[v]);
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | // if SMB is larger than upper cap, set SMB to upper cap
|
---|
| 127 | if(smb[v]>b_max[v]){
|
---|
| 128 | smb[v]=b_max[v];
|
---|
| 129 | }
|
---|
| 130 | // if SMB is smaller than lower cap, set SMB to lower cap
|
---|
| 131 | if(smb[v]<b_min[v]){
|
---|
| 132 | smb[v]=b_min[v];
|
---|
| 133 | }
|
---|
| 134 | } //end of the loop over the vertices
|
---|
| 135 |
|
---|
| 136 | /*Add input to element and Free memory*/
|
---|
[25379] | 137 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
[21469] | 138 | xDelete<IssmDouble>(ela);
|
---|
| 139 | xDelete<IssmDouble>(b_pos);
|
---|
| 140 | xDelete<IssmDouble>(b_neg);
|
---|
| 141 | xDelete<IssmDouble>(b_max);
|
---|
| 142 | xDelete<IssmDouble>(b_min);
|
---|
| 143 | xDelete<IssmDouble>(s);
|
---|
| 144 | xDelete<IssmDouble>(smb);
|
---|
| 145 |
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | }/*}}}*/
|
---|
[26477] | 149 | void SmbautoregressionInitx(FemModel* femmodel){/*{{{*/
|
---|
[26482] | 150 |
|
---|
[26477] | 151 | /*Initialization step of Smbautoregressionx*/
|
---|
[26482] | 152 | int M,N,Nphi,arorder,numbasins,my_rank;
|
---|
[26477] | 153 | IssmDouble starttime,tstep_ar,tinit_ar;
|
---|
[26482] | 154 | femmodel->parameters->FindParam(&numbasins,SmbNumBasinsEnum);
|
---|
| 155 | femmodel->parameters->FindParam(&arorder,SmbAutoregressiveOrderEnum);
|
---|
[26495] | 156 | IssmDouble* beta0 = NULL;
|
---|
| 157 | IssmDouble* beta1 = NULL;
|
---|
| 158 | IssmDouble* phi = NULL;
|
---|
[26477] | 159 | femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum);
|
---|
| 160 | femmodel->parameters->FindParam(&tstep_ar,SmbAutoregressionTimestepEnum);
|
---|
| 161 | femmodel->parameters->FindParam(&tinit_ar,SmbAutoregressionInitialTimeEnum);
|
---|
| 162 | femmodel->parameters->FindParam(&beta0,&M,SmbBeta0Enum); _assert_(M==numbasins);
|
---|
| 163 | femmodel->parameters->FindParam(&beta1,&M,SmbBeta1Enum); _assert_(M==numbasins);
|
---|
| 164 | femmodel->parameters->FindParam(&phi,&M,&Nphi,SmbPhiEnum); _assert_(M==numbasins); _assert_(Nphi==arorder);
|
---|
[26482] | 165 |
|
---|
[26751] | 166 | /*AR model spin-up with 0 noise to initialize SmbValuesAutoregressionEnum (688 = log(0.001)/log(0.99): decaying time of inluence of phi[0]=0.99 to 0.001 of beta_0*/
|
---|
| 167 | int nspin = 688;
|
---|
[26477] | 168 | for(Object* &object:femmodel->elements->objects){
|
---|
| 169 | Element* element = xDynamicCast<Element*>(object); //generate element object
|
---|
[26526] | 170 | element->AutoregressionInit(numbasins,arorder,nspin,starttime,tstep_ar,tinit_ar,beta0,beta1,phi,SMBautoregressionEnum);
|
---|
[26477] | 171 | }
|
---|
| 172 | /*Cleanup*/
|
---|
| 173 | xDelete<IssmDouble>(beta0);
|
---|
| 174 | xDelete<IssmDouble>(beta1);
|
---|
| 175 | xDelete<IssmDouble>(phi);
|
---|
| 176 | }/*}}}*/
|
---|
| 177 | void Smbautoregressionx(FemModel* femmodel){/*{{{*/
|
---|
[26483] | 178 |
|
---|
[26615] | 179 | /*Get time parameters*/
|
---|
| 180 | IssmDouble time,dt,starttime,tstep_ar;
|
---|
| 181 | femmodel->parameters->FindParam(&time,TimeEnum);
|
---|
| 182 | femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
|
---|
| 183 | femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum);
|
---|
[26477] | 184 | femmodel->parameters->FindParam(&tstep_ar,SmbAutoregressionTimestepEnum);
|
---|
[26482] | 185 |
|
---|
[26615] | 186 | /*Initialize module at first time step*/
|
---|
| 187 | if(time<=starttime+dt){SmbautoregressionInitx(femmodel);}
|
---|
| 188 | /*Determine if this is a time step for the AR model*/
|
---|
| 189 | bool isstepforar = false;
|
---|
[26479] | 190 |
|
---|
[26615] | 191 | #ifndef _HAVE_AD_
|
---|
[26482] | 192 | if((fmod(time,tstep_ar)<fmod((time-dt),tstep_ar)) || (time<=starttime+dt) || tstep_ar==dt) isstepforar = true;
|
---|
[26615] | 193 | #else
|
---|
| 194 | _error_("not implemented yet");
|
---|
| 195 | #endif
|
---|
[26479] | 196 |
|
---|
[26615] | 197 | /*Load parameters*/
|
---|
| 198 | bool isstochastic;
|
---|
| 199 | bool issmbstochastic = false;
|
---|
| 200 | int M,N,Nphi,arorder,numbasins,my_rank;
|
---|
| 201 | femmodel->parameters->FindParam(&numbasins,SmbNumBasinsEnum);
|
---|
| 202 | femmodel->parameters->FindParam(&arorder,SmbAutoregressiveOrderEnum);
|
---|
| 203 | IssmDouble tinit_ar;
|
---|
[26810] | 204 | IssmDouble* beta0 = NULL;
|
---|
| 205 | IssmDouble* beta1 = NULL;
|
---|
| 206 | IssmDouble* phi = NULL;
|
---|
| 207 | IssmDouble* lapseratepos = NULL;
|
---|
| 208 | IssmDouble* lapserateneg = NULL;
|
---|
| 209 | IssmDouble* refelevation = NULL;
|
---|
[26526] | 210 |
|
---|
[26615] | 211 | femmodel->parameters->FindParam(&tinit_ar,SmbAutoregressionInitialTimeEnum);
|
---|
[26810] | 212 | femmodel->parameters->FindParam(&beta0,&M,SmbBeta0Enum); _assert_(M==numbasins);
|
---|
| 213 | femmodel->parameters->FindParam(&beta1,&M,SmbBeta1Enum); _assert_(M==numbasins);
|
---|
| 214 | femmodel->parameters->FindParam(&phi,&M,&Nphi,SmbPhiEnum); _assert_(M==numbasins); _assert_(Nphi==arorder);
|
---|
| 215 | femmodel->parameters->FindParam(&lapseratepos,&M,SmbLapseRatePosEnum); _assert_(M==numbasins);
|
---|
| 216 | femmodel->parameters->FindParam(&lapserateneg,&M,SmbLapseRateNegEnum); _assert_(M==numbasins);
|
---|
| 217 | femmodel->parameters->FindParam(&refelevation,&M,SmbRefElevationEnum); _assert_(M==numbasins);
|
---|
[26481] | 218 |
|
---|
[26615] | 219 | femmodel->parameters->FindParam(&isstochastic,StochasticForcingIsStochasticForcingEnum);
|
---|
[26526] | 220 | if(isstochastic){
|
---|
[26615] | 221 | int numstochasticfields;
|
---|
[26526] | 222 | int* stochasticfields;
|
---|
| 223 | femmodel->parameters->FindParam(&numstochasticfields,StochasticForcingNumFieldsEnum);
|
---|
| 224 | femmodel->parameters->FindParam(&stochasticfields,&N,StochasticForcingFieldsEnum); _assert_(N==numstochasticfields);
|
---|
| 225 | for(int i=0;i<numstochasticfields;i++){
|
---|
[26615] | 226 | if(stochasticfields[i]==SMBautoregressionEnum) issmbstochastic = true;
|
---|
| 227 | }
|
---|
| 228 | xDelete<int>(stochasticfields);
|
---|
| 229 | }
|
---|
| 230 | /*Time elapsed with respect to AR model initial time*/
|
---|
| 231 | IssmDouble telapsed_ar = time-tinit_ar;
|
---|
[26481] | 232 |
|
---|
[26615] | 233 | /*Loop over each element to compute SMB at vertices*/
|
---|
| 234 | for(Object* &object:femmodel->elements->objects){
|
---|
| 235 | Element* element = xDynamicCast<Element*>(object);
|
---|
[26810] | 236 | /*Compute autoregression*/
|
---|
| 237 | element->Autoregression(isstepforar,arorder,telapsed_ar,beta0,beta1,phi,issmbstochastic,SMBautoregressionEnum);
|
---|
| 238 | /*Compute lapse rate adjustment*/
|
---|
| 239 | element->LapseRateBasinSMB(lapseratepos,lapserateneg,refelevation);
|
---|
| 240 | }
|
---|
[26481] | 241 |
|
---|
[26615] | 242 | /*Cleanup*/
|
---|
| 243 | xDelete<IssmDouble>(beta0);
|
---|
| 244 | xDelete<IssmDouble>(beta1);
|
---|
| 245 | xDelete<IssmDouble>(phi);
|
---|
[26810] | 246 | xDelete<IssmDouble>(lapseratepos);
|
---|
| 247 | xDelete<IssmDouble>(lapserateneg);
|
---|
| 248 | xDelete<IssmDouble>(refelevation);
|
---|
[26477] | 249 | }/*}}}*/
|
---|
[17085] | 250 | void Delta18oParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
| 251 |
|
---|
[25539] | 252 | for(Object* & object : femmodel->elements->objects){
|
---|
| 253 | Element* element=xDynamicCast<Element*>(object);
|
---|
[17085] | 254 | element->Delta18oParameterization();
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | }/*}}}*/
|
---|
[18968] | 258 | void MungsmtpParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
| 259 |
|
---|
[25539] | 260 | for(Object* & object : femmodel->elements->objects){
|
---|
| 261 | Element* element=xDynamicCast<Element*>(object);
|
---|
[18968] | 262 | element->MungsmtpParameterization();
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 | }/*}}}*/
|
---|
[19172] | 266 | void Delta18opdParameterizationx(FemModel* femmodel){/*{{{*/
|
---|
| 267 |
|
---|
[25539] | 268 | for(Object* & object : femmodel->elements->objects){
|
---|
| 269 | Element* element=xDynamicCast<Element*>(object);
|
---|
[19172] | 270 | element->Delta18opdParameterization();
|
---|
| 271 | }
|
---|
| 272 |
|
---|
| 273 | }/*}}}*/
|
---|
[17085] | 274 | void PositiveDegreeDayx(FemModel* femmodel){/*{{{*/
|
---|
| 275 |
|
---|
| 276 | // void PositiveDegreeDayx(hd,vTempsea,vPrec,agd,Tsurf,ni){
|
---|
| 277 | // note "v" prefix means 12 monthly means, ie time dimension
|
---|
| 278 | // INPUT parameters: ni: working size of arrays
|
---|
| 279 | // INPUT: surface elevation (m): hd(NA)
|
---|
| 280 | // monthly mean surface sealevel temperature (degrees C): vTempsea(NA
|
---|
[23366] | 281 | // ,NTIME)
|
---|
[17085] | 282 | // monthly mean precip rate (m/yr water equivalent): vPrec(NA,NTIME)
|
---|
| 283 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
| 284 | // mean annual surface temperature (degrees C): Tsurf(NA)
|
---|
| 285 |
|
---|
[25539] | 286 | int it, jj, itm;
|
---|
[17085] | 287 | IssmDouble DT = 0.02, sigfac, snormfac;
|
---|
[23366] | 288 | IssmDouble signorm = 5.5; // signorm : sigma of the temperature distribution for a normal day
|
---|
[17085] | 289 | IssmDouble siglim; // sigma limit for the integration which is equal to 2.5 sigmanorm
|
---|
| 290 | IssmDouble signormc = signorm - 0.5; // sigma of the temperature distribution for cloudy day
|
---|
| 291 | IssmDouble siglimc, siglim0, siglim0c;
|
---|
| 292 | IssmDouble tstep, tsint, tint, tstepc;
|
---|
| 293 | int NPDMAX = 1504, NPDCMAX = 1454;
|
---|
[23366] | 294 | //IssmDouble pdds[NPDMAX]={0};
|
---|
[17085] | 295 | //IssmDouble pds[NPDCMAX]={0};
|
---|
| 296 | IssmDouble pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
|
---|
| 297 | IssmDouble PDup, PDCUT = 2.0; // PDcut: rain/snow cutoff temperature (C)
|
---|
| 298 | IssmDouble tstar; // monthly mean surface temp
|
---|
| 299 |
|
---|
[18968] | 300 | bool ismungsm;
|
---|
[22448] | 301 | bool issetpddfac;
|
---|
[18968] | 302 |
|
---|
[17085] | 303 | IssmDouble *pdds = NULL;
|
---|
| 304 | IssmDouble *pds = NULL;
|
---|
| 305 | Element *element = NULL;
|
---|
| 306 |
|
---|
[23366] | 307 | pdds=xNew<IssmDouble>(NPDMAX+1);
|
---|
| 308 | pds=xNew<IssmDouble>(NPDCMAX+1);
|
---|
[17085] | 309 |
|
---|
[18968] | 310 | // Get ismungsm parameter
|
---|
[19527] | 311 | femmodel->parameters->FindParam(&ismungsm,SmbIsmungsmEnum);
|
---|
[18968] | 312 |
|
---|
[22448] | 313 | // Get issetpddfac parameter
|
---|
| 314 | femmodel->parameters->FindParam(&issetpddfac,SmbIssetpddfacEnum);
|
---|
| 315 |
|
---|
[17085] | 316 | /* initialize PDD (creation of a lookup table)*/
|
---|
| 317 | tstep = 0.1;
|
---|
| 318 | tsint = tstep*0.5;
|
---|
| 319 | sigfac = -1.0/(2.0*pow(signorm,2));
|
---|
| 320 | snormfac = 1.0/(signorm*sqrt(2.0*acos(-1.0)));
|
---|
| 321 | siglim = 2.5*signorm;
|
---|
| 322 | siglimc = 2.5*signormc;
|
---|
| 323 | siglim0 = siglim/DT + 0.5;
|
---|
| 324 | siglim0c = siglimc/DT + 0.5;
|
---|
| 325 | PDup = siglimc+PDCUT;
|
---|
| 326 |
|
---|
| 327 | itm = reCast<int,IssmDouble>((2*siglim/DT + 1.5));
|
---|
| 328 |
|
---|
| 329 | if(itm >= NPDMAX) _error_("increase NPDMAX in massBalance.cpp");
|
---|
[23366] | 330 | for(it = 0; it < itm; it++){
|
---|
[17085] | 331 | // tstar = REAL(it)*DT-siglim;
|
---|
| 332 | tstar = it*DT-siglim;
|
---|
| 333 | tint = tsint;
|
---|
| 334 | pddt = 0.;
|
---|
| 335 | for ( jj = 0; jj < 600; jj++){
|
---|
| 336 | if (tint > (tstar+siglim)){break;}
|
---|
| 337 | pddt = pddt + tint*exp(sigfac*(pow((tint-tstar),2)))*tstep;
|
---|
| 338 | tint = tint+tstep;
|
---|
| 339 | }
|
---|
| 340 | pdds[it] = pddt*snormfac;
|
---|
| 341 | }
|
---|
| 342 | pdds[itm+1] = siglim + DT;
|
---|
| 343 |
|
---|
| 344 | //*********compute PD(T) : snow/precip fraction. precipitation falling as snow
|
---|
| 345 | tstepc = 0.1;
|
---|
| 346 | tsint = PDCUT-tstepc*0.5;
|
---|
| 347 | signormc = signorm - 0.5;
|
---|
| 348 | sigfac = -1.0/(2.0*pow(signormc,2));
|
---|
| 349 | snormfac = 1.0/(signormc*sqrt(2.0*acos(-1.0)));
|
---|
| 350 | siglimc = 2.5*signormc ;
|
---|
| 351 | itm = reCast<int,IssmDouble>((PDCUT+2.*siglimc)/DT + 1.5);
|
---|
| 352 | if(itm >= NPDCMAX) _error_("increase NPDCMAX in p35com");
|
---|
| 353 | for(it = 0; it < itm; it++ ){
|
---|
| 354 | tstar = it*DT-siglimc;
|
---|
| 355 | // tstar = REAL(it)*DT-siglimc;
|
---|
| 356 | tint = tsint; // start against upper bound
|
---|
| 357 | pd = 0.;
|
---|
| 358 | for (jj = 0; jj < 600; jj++){
|
---|
| 359 | if (tint<(tstar-siglimc)) {break;}
|
---|
| 360 | pd = pd + exp(sigfac*(pow((tint-tstar),2)))*tstepc;
|
---|
| 361 | tint = tint-tstepc;
|
---|
| 362 | }
|
---|
| 363 | pds[it] = pd*snormfac; // gaussian integral lookup table for snow fraction
|
---|
| 364 | }
|
---|
| 365 | pds[itm+1] = 0.;
|
---|
| 366 | // *******END initialize PDD
|
---|
| 367 |
|
---|
[25539] | 368 | for(Object* & object : femmodel->elements->objects){
|
---|
| 369 | element=xDynamicCast<Element*>(object);
|
---|
[22448] | 370 | element->PositiveDegreeDay(pdds,pds,signorm,ismungsm,issetpddfac);
|
---|
[17085] | 371 | }
|
---|
| 372 | /*free ressouces: */
|
---|
| 373 | xDelete<IssmDouble>(pdds);
|
---|
| 374 | xDelete<IssmDouble>(pds);
|
---|
| 375 | }/*}}}*/
|
---|
[23317] | 376 | void PositiveDegreeDaySicopolisx(FemModel* femmodel){/*{{{*/
|
---|
[23366] | 377 |
|
---|
[23317] | 378 | bool isfirnwarming;
|
---|
[23328] | 379 | femmodel->parameters->FindParam(&isfirnwarming,SmbIsfirnwarmingEnum);
|
---|
[23366] | 380 |
|
---|
[25539] | 381 | for(Object* & object : femmodel->elements->objects){
|
---|
| 382 | Element* element=xDynamicCast<Element*>(object);
|
---|
[23317] | 383 | element->PositiveDegreeDaySicopolis(isfirnwarming);
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 | }/*}}}*/
|
---|
[17085] | 387 | void SmbHenningx(FemModel* femmodel){/*{{{*/
|
---|
| 388 |
|
---|
[17087] | 389 | /*Intermediaries*/
|
---|
[17403] | 390 | IssmDouble z_critical = 1675.;
|
---|
| 391 | IssmDouble dz = 0;
|
---|
| 392 | IssmDouble a = -15.86;
|
---|
| 393 | IssmDouble b = 0.00969;
|
---|
| 394 | IssmDouble c = -0.235;
|
---|
| 395 | IssmDouble f = 1.;
|
---|
| 396 | IssmDouble g = -0.0011;
|
---|
| 397 | IssmDouble h = -1.54e-5;
|
---|
| 398 | IssmDouble smb,smbref,anomaly,yts,z;
|
---|
[22249] | 399 |
|
---|
| 400 | /* Get constants */
|
---|
| 401 | femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);
|
---|
| 402 | /*iomodel->FindConstant(&yts,"md.constants.yts");*/
|
---|
| 403 | /*this->parameters->FindParam(&yts,ConstantsYtsEnum);*/
|
---|
| 404 | /*Mathieu original*/
|
---|
| 405 | /*IssmDouble smb,smbref,z;*/
|
---|
| 406 |
|
---|
[17087] | 407 | /*Loop over all the elements of this partition*/
|
---|
[25539] | 408 | for(Object* & object : femmodel->elements->objects){
|
---|
| 409 | Element* element=xDynamicCast<Element*>(object);
|
---|
[17087] | 410 |
|
---|
| 411 | /*Get reference SMB (uncorrected) and allocate all arrays*/
|
---|
| 412 | int numvertices = element->GetNumberOfVertices();
|
---|
| 413 | IssmDouble* surfacelist = xNew<IssmDouble>(numvertices);
|
---|
| 414 | IssmDouble* smblistref = xNew<IssmDouble>(numvertices);
|
---|
| 415 | IssmDouble* smblist = xNew<IssmDouble>(numvertices);
|
---|
| 416 | element->GetInputListOnVertices(surfacelist,SurfaceEnum);
|
---|
[19527] | 417 | element->GetInputListOnVertices(smblistref,SmbSmbrefEnum);
|
---|
[17087] | 418 |
|
---|
| 419 | /*Loop over all vertices of element and correct SMB as a function of altitude z*/
|
---|
| 420 | for(int v=0;v<numvertices;v++){
|
---|
| 421 |
|
---|
[17403] | 422 | /*Get vertex elevation, anoma smb*/
|
---|
[17087] | 423 | z = surfacelist[v];
|
---|
[17403] | 424 | anomaly = smblistref[v];
|
---|
[17087] | 425 |
|
---|
[22249] | 426 | /* Henning edited acc. to Riannes equations*/
|
---|
| 427 | /* Set SMB maximum elevation, if dz = 0 -> z_critical = 1675 */
|
---|
| 428 | z_critical = z_critical + dz;
|
---|
| 429 |
|
---|
| 430 | /* Calculate smb acc. to the surface elevation z */
|
---|
| 431 | if(z<z_critical){
|
---|
[17403] | 432 | smb = a + b*z + c;
|
---|
[17087] | 433 | }
|
---|
| 434 | else{
|
---|
[22249] | 435 | smb = (a + b*z)*(f + g*(z-z_critical) + h*(z-z_critical)*(z-z_critical)) + c;
|
---|
[17087] | 436 | }
|
---|
[22249] | 437 |
|
---|
[18584] | 438 | /* Compute smb including anomaly,
|
---|
| 439 | correct for number of seconds in a year [s/yr]*/
|
---|
| 440 | smb = smb/yts + anomaly;
|
---|
| 441 |
|
---|
[17087] | 442 | /*Update array accordingly*/
|
---|
| 443 | smblist[v] = smb;
|
---|
| 444 |
|
---|
| 445 | }
|
---|
| 446 |
|
---|
| 447 | /*Add input to element and Free memory*/
|
---|
[25379] | 448 | element->AddInput(SmbMassBalanceEnum,smblist,P1Enum);
|
---|
[17087] | 449 | xDelete<IssmDouble>(surfacelist);
|
---|
| 450 | xDelete<IssmDouble>(smblistref);
|
---|
| 451 | xDelete<IssmDouble>(smblist);
|
---|
[17085] | 452 | }
|
---|
| 453 |
|
---|
| 454 | }/*}}}*/
|
---|
[18001] | 455 | void SmbComponentsx(FemModel* femmodel){/*{{{*/
|
---|
| 456 |
|
---|
| 457 | // void SmbComponentsx(acc,evap,runoff,ni){
|
---|
| 458 | // INPUT parameters: ni: working size of arrays
|
---|
| 459 | // INPUT: surface accumulation (m/yr water equivalent): acc
|
---|
| 460 | // surface evaporation (m/yr water equivalent): evap
|
---|
| 461 | // surface runoff (m/yr water equivalent): runoff
|
---|
| 462 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
[23814] | 463 |
|
---|
[18001] | 464 | /*Loop over all the elements of this partition*/
|
---|
[25539] | 465 | for(Object* & object : femmodel->elements->objects){
|
---|
| 466 | Element* element=xDynamicCast<Element*>(object);
|
---|
[18001] | 467 |
|
---|
| 468 | /*Allocate all arrays*/
|
---|
| 469 | int numvertices = element->GetNumberOfVertices();
|
---|
[23366] | 470 | IssmDouble* acc = xNew<IssmDouble>(numvertices);
|
---|
[18001] | 471 | IssmDouble* evap = xNew<IssmDouble>(numvertices);
|
---|
[23366] | 472 | IssmDouble* runoff = xNew<IssmDouble>(numvertices);
|
---|
[18001] | 473 | IssmDouble* smb = xNew<IssmDouble>(numvertices);
|
---|
| 474 |
|
---|
| 475 | /*Recover Smb Components*/
|
---|
[26208] | 476 | element->GetInputListOnVertices(acc,SmbAccumulationEnum);
|
---|
| 477 | element->GetInputListOnVertices(evap,SmbEvaporationEnum);
|
---|
| 478 | element->GetInputListOnVertices(runoff,SmbRunoffEnum);
|
---|
[18001] | 479 |
|
---|
| 480 | // loop over all vertices
|
---|
[24335] | 481 | for(int v=0;v<numvertices;v++) smb[v]=acc[v]-evap[v]-runoff[v];
|
---|
[18001] | 482 |
|
---|
| 483 | /*Add input to element and Free memory*/
|
---|
[25379] | 484 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
[18001] | 485 | xDelete<IssmDouble>(acc);
|
---|
| 486 | xDelete<IssmDouble>(evap);
|
---|
| 487 | xDelete<IssmDouble>(runoff);
|
---|
| 488 | xDelete<IssmDouble>(smb);
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 | }/*}}}*/
|
---|
| 492 | void SmbMeltComponentsx(FemModel* femmodel){/*{{{*/
|
---|
| 493 |
|
---|
| 494 | // void SmbMeltComponentsx(acc,evap,melt,refreeze,ni){
|
---|
| 495 | // INPUT parameters: ni: working size of arrays
|
---|
| 496 | // INPUT: surface accumulation (m/yr water equivalent): acc
|
---|
| 497 | // surface evaporation (m/yr water equivalent): evap
|
---|
| 498 | // surface melt (m/yr water equivalent): melt
|
---|
| 499 | // refreeze of surface melt (m/yr water equivalent): refreeze
|
---|
| 500 | // OUTPUT: mass-balance (m/yr ice): agd(NA)
|
---|
[23814] | 501 |
|
---|
[18001] | 502 | /*Loop over all the elements of this partition*/
|
---|
[25539] | 503 | for(Object* & object : femmodel->elements->objects){
|
---|
| 504 | Element* element=xDynamicCast<Element*>(object);
|
---|
[18001] | 505 |
|
---|
| 506 | /*Allocate all arrays*/
|
---|
| 507 | int numvertices = element->GetNumberOfVertices();
|
---|
| 508 | IssmDouble* acc = xNew<IssmDouble>(numvertices);
|
---|
[23366] | 509 | IssmDouble* evap = xNew<IssmDouble>(numvertices);
|
---|
[18001] | 510 | IssmDouble* melt = xNew<IssmDouble>(numvertices);
|
---|
| 511 | IssmDouble* refreeze = xNew<IssmDouble>(numvertices);
|
---|
| 512 | IssmDouble* smb = xNew<IssmDouble>(numvertices);
|
---|
| 513 |
|
---|
| 514 | /*Recover Smb Components*/
|
---|
[26208] | 515 | element->GetInputListOnVertices(acc,SmbAccumulationEnum);
|
---|
| 516 | element->GetInputListOnVertices(evap,SmbEvaporationEnum);
|
---|
| 517 | element->GetInputListOnVertices(melt,SmbMeltEnum);
|
---|
| 518 | element->GetInputListOnVertices(refreeze,SmbRefreezeEnum);
|
---|
[18001] | 519 |
|
---|
| 520 | // loop over all vertices
|
---|
[24335] | 521 | for(int v=0;v<numvertices;v++) smb[v]=acc[v]-evap[v]-melt[v]+refreeze[v];
|
---|
[18001] | 522 |
|
---|
| 523 | /*Add input to element and Free memory*/
|
---|
[25379] | 524 | element->AddInput(SmbMassBalanceEnum,smb,P1Enum);
|
---|
[18001] | 525 | xDelete<IssmDouble>(acc);
|
---|
| 526 | xDelete<IssmDouble>(evap);
|
---|
| 527 | xDelete<IssmDouble>(melt);
|
---|
| 528 | xDelete<IssmDouble>(refreeze);
|
---|
| 529 | xDelete<IssmDouble>(smb);
|
---|
| 530 | }
|
---|
| 531 |
|
---|
| 532 | }/*}}}*/
|
---|
[23366] | 533 | void SmbGradientsComponentsx(FemModel* femmodel){/*{{{*/
|
---|
| 534 |
|
---|
[25539] | 535 | for(Object* & object : femmodel->elements->objects){
|
---|
| 536 | Element* element=xDynamicCast<Element*>(object);
|
---|
[23366] | 537 | element->SmbGradCompParameterization();
|
---|
| 538 | }
|
---|
| 539 |
|
---|
| 540 | }/*}}}*/
|
---|
[23540] | 541 | #ifdef _HAVE_SEMIC_
|
---|
| 542 | void SmbSemicx(FemModel* femmodel){/*{{{*/
|
---|
| 543 |
|
---|
[25539] | 544 | for(Object* & object : femmodel->elements->objects){
|
---|
| 545 | Element* element=xDynamicCast<Element*>(object);
|
---|
[23540] | 546 | element->SmbSemic();
|
---|
| 547 | }
|
---|
| 548 |
|
---|
| 549 | }/*}}}*/
|
---|
| 550 | #else
|
---|
| 551 | void SmbSemicx(FemModel* femmodel){_error_("SEMIC not installed");}
|
---|
| 552 | #endif //_HAVE_SEMIC_
|
---|