Changeset 11994


Ignore:
Timestamp:
04/16/12 14:48:34 (13 years ago)
Author:
Mathieu Morlighem
Message:

merged trunk and trunk-jpl

Location:
issm/trunk-jpl
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl

  • issm/trunk-jpl/m4/issm_options.m4

    r11937 r11994  
    191191                        *darwin*)
    192192                                dnl mex -v gives all the flags for compilation of mex files
    193                                 dnl if matlab version is 7.10 or more, we must use mexmaci64 (64 bits)
     193                                dnl if matlab version is 7.9 or more, we must use mexmaci64 (64 bits)
    194194                                MEXLINK="-O -Wl,-flat_namespace -undefined suppress -arch i386 -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci/mexFunction.map"
    195195                                MEXLIB=" -L$MATLAB_ROOT/bin/maci/ -lmx -lmex -lmat -lstdc++ -largeArrayDims"
    196196                                if test $MATLAB_MAJOR -ge 7; then
    197                                          if test $MATLAB_MINOR -ge 10; then
     197                                         if test $MATLAB_MINOR -ge 9; then
    198198                                                  MEXLINK="-O -Wl,-flat_namespace -undefined suppress -bundle -Wl,-exported_symbols_list,$MATLAB_ROOT/extern/lib/maci64/mexFunction.map"
    199199                                                         MEXLIB=" -L$MATLAB_ROOT/bin/maci64/ -lmx -lmex -lmat -lstdc++"
  • issm/trunk-jpl/src/c/modules/PositiveDegreeDayx/PositiveDegreeDayx.cpp

    r11510 r11994  
    1111
    1212void PositiveDegreeDayx(Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters){
    13        
    14         Element* element = NULL;
    1513
    16         for(int i=0;i<elements->Size();i++){
    17                 element=(Element*)elements->GetObjectByOffset(i);
    18                 element->PositiveDegreeDay();
    19         }
     14// void PositiveDegreeDayx(hd,vTempsea,vPrec,agd,Tsurf,ni){
     15//    note "v" prefix means 12 monthly means, ie time dimension
     16//    INPUT parameters: ni: working size of arrays
     17//    INPUT: surface elevation (m): hd(NA)
     18//    monthly mean surface sealevel temperature (degrees C): vTempsea(NA
     19//    ,NTIME)
     20//    monthly mean precip rate (m/yr water equivalent): vPrec(NA,NTIME)
     21//    OUTPUT: mass-balance (m/yr ice): agd(NA)
     22//    mean annual surface temperature (degrees C): Tsurf(NA)
    2023
     24  int    i, it, jj, itm;
     25  double DT = 0.02, sigfac, snormfac;
     26  double signorm = 5.5;      // signorm : sigma of the temperature distribution for a normal day
     27  double siglim;       // sigma limit for the integration which is equal to 2.5 sigmanorm
     28  double signormc;     // sigma of the temperature distribution for cloudy day
     29  double siglimc=0, siglim0, siglim0c;
     30  double tstep, tsint, tint, tstepc;
     31  int    NPDMAX = 1504, NPDCMAX = 1454;
     32  //double pdds[NPDMAX]={0};
     33  //double pds[NPDCMAX]={0};
     34  double pddt, pd ; // pd : snow/precip fraction, precipitation falling as snow
     35  double PDup, PDCUT = 2.0;    // PDcut: rain/snow cutoff temperature (C)
     36  double tstar; // monthly mean surface temp
     37 
     38  double* pdds=NULL;
     39  double* pds=NULL;
     40  Element* element = NULL;
     41 
     42  pdds=(double*)xmalloc(NPDMAX*sizeof(double)+1);
     43  pds=(double*)xmalloc(NPDCMAX*sizeof(double)+1);
     44 
     45 
     46  // PDD constant
     47  siglim = 2.5*signorm;
     48 
     49  // initialize PDD (creation of a lookup table)
     50  tstep = 0.1;
     51  tsint = tstep*0.5;
     52  sigfac = -1.0/(2.0*pow(signorm,2));
     53  snormfac = 1.0/(signorm*sqrt(2.0*acos(-1.0)));
     54  siglim = 2.5*signorm;
     55  itm = (int)(2*siglim/DT + 1.5);
     56 
     57  if (itm >= NPDMAX){
     58    printf("increase NPDMAX in massBalance.cpp\n");
     59    exit (1);
     60      }
     61  for (it = 0; it < itm; it++){ 
     62    //    tstar = REAL(it)*DT-siglim;
     63    tstar = it*DT-siglim;
     64    tint = tsint;
     65    pddt = 0;
     66    for ( jj = 0; jj < 600; jj++){
     67      if (tint > (tstar+siglim)){break;}
     68      pddt = pddt + tint*exp(sigfac*(pow((tint-tstar),2)))*tstep;
     69      tint = tint+tstep;
     70    }
     71    pdds[it] = pddt*snormfac;
     72  }
     73  pdds[itm+1] = siglim + DT;
     74 
     75  //*********compute PD(T) : snow/precip fraction. precipitation falling as snow
     76  tstepc = 0.1;
     77  tsint = PDCUT-tstepc*0.5;
     78  signormc = signorm - 0.5;
     79  sigfac = -1.0/(2.0*pow(signormc,2));
     80  snormfac = 1.0/(signormc*sqrt(2.0*acos(-1.0)));
     81  siglimc = 2.5*signormc ;
     82  itm = (int)((PDCUT+2.*siglimc)/DT + 1.5);
     83  if (itm >= NPDCMAX){
     84    printf("'increase NPDCMAX in p35com'\n");
     85    exit (1);
     86      }
     87  for (it = 0; it < itm; it++ ){
     88    tstar = it*DT-siglimc;
     89    //    tstar = REAL(it)*DT-siglimc;
     90    tint = tsint;          // start against upper bound
     91    pd = 0;
     92    for (jj = 0; jj < 600; jj++){
     93      if (tint<(tstar-siglimc)) {break;}
     94      pd = pd + exp(sigfac*(pow((tint-tstar),2)))*tstepc;
     95      tint = tint-tstepc;
     96    }
     97    pds[it] = pd*snormfac;  // gaussian integral lookup table for snow fraction
     98  }
     99  pds[itm+1] = 0;
     100  //     *******END initialize PDD
     101 
     102  for(i=0;i<elements->Size();i++){
     103    element=(Element*)elements->GetObjectByOffset(i);
     104    element->PositiveDegreeDay(pdds,pds,signorm);
     105  }
     106  /*free ressouces: */
     107  xfree((void**)&pdds);
     108  xfree((void**)&pds);
     109 
    21110}
  • issm/trunk-jpl/src/c/objects/Elements/Element.h

    r11695 r11994  
    7171                virtual void   MigrateGroundingLine(double* old_floating_ice,double* sheet_ungrounding)=0;
    7272                virtual void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding)=0;
    73                 virtual void   PositiveDegreeDay(void)=0;
     73                virtual void   PositiveDegreeDay(double* pdds,double* pds,double signorm)=0;
    7474                virtual int    UpdatePotentialSheetUngrounding(double* potential_sheet_ungrounding,Vector* vec_nodes_on_iceshelf,double* nodes_on_iceshelf)=0;
    7575                virtual void   ResetCoordinateSystem()=0;
  • issm/trunk-jpl/src/c/objects/Elements/Penta.cpp

    r11695 r11994  
    24102410/*}}}*/
    24112411/*FUNCTION Penta::PositiveDegreeDay{{{1*/
    2412 void  Penta::PositiveDegreeDay(){
    2413 
    2414         _error_("Not implemented yet");
     2412void  Penta::PositiveDegreeDay(double* pdds,double* pds,double signorm){
     2413
     2414
     2415   int    i,iqj,imonth;
     2416   double agd[NUMVERTICES];  // surface and basal
     2417   double saccu[NUMVERTICES] = {0};     // yearly surface accumulation
     2418   double smelt[NUMVERTICES] = {0};     // yearly melt
     2419   double precrunoff[NUMVERTICES];      // yearly runoff
     2420   double prect; // total precipitation during 1 year taking into account des. ef.
     2421   double water; //water=rain + snowmelt
     2422   double runoff; //meltwater only, does not include rain
     2423   double sconv; //rhow_rain/rhoi / 12 months
     2424
     2425   double  rho_water,rho_ice,density;
     2426   double lapser=6.5/1000, sealev=0;    // lapse rate. degrees per meter.
     2427   double desfac = 0.5;                 //desert elevation factor
     2428   double s0p[NUMVERTICES]={0};         //should be set to elevation from precip source
     2429   double s0t[NUMVERTICES]={0};         //should be set to elevation from temperature source
     2430   double st;             // elevation between altitude of the temp record and current altitude
     2431   double sp;             // elevation between altitude of the prec record and current altitude
     2432
     2433
     2434   // PDD and PD constants and variables
     2435   double siglim;          // sigma limit for the integration which is equal to 2.5 sigmanorm
     2436   double siglimc=0, siglim0, siglim0c;
     2437   double PDup, pddsig, PDCUT = 2.0; // PDcut: rain/snow cutoff temperature (C)
     2438   double DT = 0.02;
     2439   double pddt, pd; // pd: snow/precip fraction, precipitation falling as snow
     2440   
     2441   double q, qmpt; // q is desert/elev. fact, hnpfac is huybrect fact, and pd is normal dist.
     2442   double qm[NUMVERTICES] = {0};        // snow part of the precipitation
     2443   double qmt[NUMVERTICES] = {0};       // precipitation without desertification effect adjustment
     2444   double qmp[NUMVERTICES] = {0};       // desertification taken into account
     2445   double pdd[NUMVERTICES] = {0};     
     2446   double frzndd[NUMVERTICES] = {0}; 
     2447
     2448   double tstar;                        // monthly mean surface temp
     2449   double Tsum[NUMVERTICES]= {0};       // average summer (JJA) temperature
     2450   double Tsurf[NUMVERTICES] = {0};     // average annual temperature   
     2451   
     2452   double h[NUMVERTICES],s[NUMVERTICES],ttmp[NUMVERTICES],prectmp[NUMVERTICES]; // ,b[NUMVERTICES]
     2453   double t[NUMVERTICES][12],prec[NUMVERTICES][12];
     2454   double deltm=1/12;
     2455   int    ismon[12]={12,1,2,3,4,5,6,7,8,9,10,11};
     2456
     2457   double snwm;  // snow that could have been melted in a year.
     2458   double snwmf; //  ablation factor for snow per positive degree day.
     2459   double smf;   //  ablation factor for ice per pdd (Braithwaite 1995 from tarasov 2002).
     2460
     2461   double dfrz=1.5, CovrLm=2009./3.35e+5, dCovrLm=dfrz*CovrLm; //m*J kg^-1 C^-1 /(J kg^-1)=m/C yr
     2462   double supice,supcap,diffndd;
     2463   double fsupT=0.5,  fsupndd=0.5;  // Tsurf mode factors for supice
     2464   double pddtj[NUMVERTICES], hmx2;
     2465
     2466   /*Recover info at the vertices: */
     2467   GetInputListOnVertices(&h[0],ThicknessEnum);
     2468   GetInputListOnVertices(&s[0],SurfaceEnum);
     2469   GetInputListOnVertices(&ttmp[0],ThermalSpctemperatureEnum);
     2470   GetInputListOnVertices(&prectmp[0],SurfaceforcingsPrecipitationEnum);
     2471
     2472   for(i=0;i<NUMVERTICES;i++) ttmp[i]=ttmp[i]-273.15; // convertion from Kelvin to celcius
     2473
     2474   for(i=0;i<NUMVERTICES;i++)
     2475     for(imonth=0;imonth<12;imonth++){
     2476       t[i][imonth]=ttmp[i];
     2477       prec[i][imonth]=prectmp[i];
     2478   }
     2479
     2480   /*Get material parameters :*/
     2481   rho_ice=matpar->GetRhoIce();
     2482   rho_water=matpar->GetRhoWater();
     2483   density=rho_ice/rho_water;
     2484   
     2485   sconv=(rho_water/rho_ice)/12.; //rhow_rain/rhoi / 12 months
     2486     
     2487     /*PDD constant*/
     2488   siglim = 2.5*signorm;
     2489   siglim0 =  siglim/DT + 0.5;
     2490   siglim0c =  siglimc/DT + 0.5;
     2491   PDup = siglimc+PDCUT;
     2492   
     2493   // seasonal loop
     2494   for (iqj = 0; iqj < 12; iqj++){
     2495     imonth =  ismon[iqj];
     2496     for (i = 0; i < NUMVERTICES; i++){
     2497       st=(s[i]-s0t[i])/1000;
     2498       tstar = t[i][imonth] - lapser *max(st,sealev);
     2499       Tsurf[i] = tstar*deltm+Tsurf[i];       
     2500       
     2501       /*********compute PD ****************/
     2502       if (tstar < PDup){
     2503         pd = 1;
     2504         if (tstar >= -siglimc){ pd = pds[int(tstar/DT + siglim0c)];}}
     2505       else {
     2506         pd = 0;}
     2507       
     2508       /******exp des/elev precip reduction*******/
     2509       sp=(s[i]-s0p[i])/1000; // deselev effect is wrt chng in topo
     2510       if (sp>0.0){q = exp(-desfac*sp);}
     2511       else {q = 1.0;}
     2512       
     2513       qmt[i]= qmt[i] + prec[i][imonth]*sconv;  //*sconv to convert in m of ice equivalent
     2514       qmpt= q*prec[i][imonth]*sconv;           
     2515       qmp[i]= qmp[i] + qmpt;
     2516       qm[i]= qm[i] + qmpt*pd;
     2517       
     2518       /*********compute PDD************/
     2519       // ndd(month)=-(tstar-pdd(month)) since ndd+pdd gives expectation of
     2520       // gaussian=T_m, so ndd=-(Tsurf-pdd)
     2521       if (iqj>6 &&  iqj<10){ Tsum[i]=Tsum[i]+tstar;}
     2522       if (tstar >= siglim) {pdd[i] = pdd[i] + tstar*deltm;}
     2523       else if (tstar> -siglim){
     2524         pddsig=pdds[int(tstar/DT + siglim0)];
     2525         pdd[i] = pdd[i] + pddsig*deltm;
     2526         frzndd[i] = frzndd[i] - (tstar-pddsig)*deltm;}
     2527       else{frzndd[i] = frzndd[i] - tstar*deltm; }
     2528     }
     2529   } // end of seasonal loop
     2530   
     2531   //******************************************************************
     2532   for(i=0;i<NUMVERTICES;i++){
     2533     saccu[i] = qm[i];
     2534     prect = qmp[i];     // total precipitation during 1 year taking into account des. ef.
     2535     Tsum[i]=Tsum[i]/3;
     2536     
     2537     /***** determine PDD factors *****/
     2538     if(Tsum[i]< -1.) {
     2539       snwmf=2.65*0.001;   //  ablation factor for snow per positive degree day.*0.001 to go from mm to m/ppd
     2540       smf=17.22*0.001;    //  ablation factor for ice per pdd (Braithwaite 1995 from tarasov 2002)
     2541     }
     2542     else if(Tsum[i]< 10){
     2543       snwmf = (0.15*Tsum[i] + 2.8)*0.001;
     2544       smf = (0.0067*pow((10.-Tsum[i]),3) + 8.3)*0.001;
     2545     }
     2546     else{
     2547       snwmf=4.3*0.001;
     2548       smf=8.3*0.001;
     2549     }
     2550     snwmf=0.95*snwmf;
     2551     smf=0.95*smf;
     2552     
     2553     /*****  compute PDD ablation and refreezing *****/
     2554     pddt = pdd[i] *365;
     2555     snwm = snwmf*pddt;       // snow that could have been melted in a year
     2556     hmx2 = min(h[i],dfrz);   // refreeze active layer max depth: dfrz
     2557     
     2558     if(snwm < saccu[i]) {
     2559       water=prect-saccu[i] + snwm; //water=rain + snowmelt
     2560       //     l 2.2= capillary factor
     2561       //     Should refreezing be controlled by frzndd or by mean annual Tsurf?
     2562       //     dCovrLm concept is of warming of active layer (thickness =d@=1-
     2563       //     >2m)
     2564       //     problem with water seepage into ice: should be sealed after
     2565       //     refreezing
     2566       //     so everything needs to be predicated on 1 year scale, except for
     2567       //     thermal
     2568       //     conductivity through ice
     2569       //     also, need to account that melt season has low accum, so what's
     2570       //     going to
     2571       //     hold the meltwater around for refreezing? And melt-time will have
     2572       //     low seasonal frzndd
     2573       
     2574       //      Superimposed ice :  Pfeffer et al. 1991, Tarasov 2002
     2575       
     2576       supice= min(hmx2*CovrLm*frzndd[i]+2.2*(saccu[i]-snwm), water); // superimposed ice
     2577       supcap=min(2.2*(saccu[i]-snwm),water);
     2578       runoff=snwm - supice;  //meltwater only, does not include rain
     2579     }
     2580     else {  //all snow melted
     2581       supice= min(hmx2*CovrLm*frzndd[i], prect );
     2582       runoff= saccu[i] + smf*(pddt-saccu[i]/snwmf) - supice;
     2583       supcap=0;
     2584     }
     2585     //     pdd melting doesn't cool Tsurf, so ndd refreeze shouldn't warm it
     2586     //     except pdd melt heat source is atmosphere, while refreeze is
     2587     //     ground/ice stored interim
     2588     //     assume pdd=ndd, then melt should equal refreeze and Tsurf should=0
     2589     //     assume ndd=2*pdd, then all supice is refrozen, but Tsurf should be
     2590     //     <0
     2591     //     assume ndd>pdd, little melt => little supice
     2592     //     bottom line: compare for Tsurf<0 : supice and no supice case,
     2593     //     expect Tsurf difference
     2594     //     except some of cooling flux comes from atmosphere//
     2595     //     1 dm supice should not raise Tsurf by 1/dCovrLm = 16.675C
     2596     //     does supice make sense when H< 0.1m? then d=thermoactive ice layer ////
     2597     //     < 0.1
     2598     
     2599     //     make more sense to just use residual pdd-ndd except that pdd
     2600     //     residual not clear yet
     2601     //     frzndd should not be used up by refreezing in snow, so stick in
     2602     //     supcap.
     2603     diffndd=0;
     2604     if (frzndd[i]>0) {
     2605       diffndd=fsupndd*min((supice-supcap)/dCovrLm ,frzndd[i]);
     2606       frzndd[i]=frzndd[i]-diffndd;
     2607     }
     2608     if(runoff<0){
     2609       saccu[i]= saccu[i] -runoff;
     2610       smelt[i] = 0;
     2611       precrunoff[i]=prect-saccu[i];
     2612       //here assume pdd residual is 0, =>
     2613       Tsurf[i]= max(Tsurf[i],-frzndd[i]);
     2614     }
     2615     else {
     2616       smelt[i] = runoff;
     2617       precrunoff[i]=prect-max(0.,supice)-saccu[i];}
     2618     //here really need pdd balance, try 0.5 fudge factor?
     2619     //at least runoff>0 => it's fairly warm, so Tsurf is !<<0,
     2620     //yet from site plots, can be ice free with Tsurf=-5.5C
     2621     if(Tsurf[i]<0) {
     2622       Tsurf[i]= min(Tsurf[i]+fsupT*diffndd , 0.);}
     2623     
     2624     agd[i] = -smelt[i]+saccu[i];
     2625     pddtj[i]=pddt;
     2626     
     2627     /*Update inputs*/   
     2628     this->inputs->AddInput(new PentaP1Input(SurfaceforcingsMassBalanceEnum,&agd[0])); ////////verifier le nom
     2629     // this->inputs->AddInput(new TriaVertexInput(ThermalSpcTemperatureEnum,&Tsurf[0]));
     2630     this->inputs->AddInput(new PentaP1Input(ThermalSpctemperatureEnum,&Tsurf[0]));
     2631     
     2632   }       //end of the for loop over the vertices
    24152633}
    24162634/*}}}*/
  • issm/trunk-jpl/src/c/objects/Elements/Penta.h

    r11695 r11994  
    112112                void   PatchFill(int* pcount, Patch* patch);
    113113                void   PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes);
    114                 void   PositiveDegreeDay(void);
     114                void   PositiveDegreeDay(double* pdds,double* pds,double signorm);
    115115                void   ProcessResultsUnits(void);
    116116                void   ResetCoordinateSystem(void);
  • issm/trunk-jpl/src/c/objects/Elements/Tria.cpp

    r11720 r11994  
    22352235/*}}}*/
    22362236/*FUNCTION Tria::PositiveDegreeDay{{{1*/
    2237 void  Tria::PositiveDegreeDay(){
    2238 
    2239         _error_("Not implemented yet");
     2237void  Tria::PositiveDegreeDay(double* pdds,double* pds,double signorm){
     2238
     2239   int    i,iqj,imonth;
     2240   double agd[NUMVERTICES];  // surface and basal
     2241   double saccu[NUMVERTICES] = {0};     // yearly surface accumulation
     2242   double smelt[NUMVERTICES] = {0};     // yearly melt
     2243   double precrunoff[NUMVERTICES];      // yearly runoff
     2244   double prect; // total precipitation during 1 year taking into account des. ef.
     2245   double water; //water=rain + snowmelt
     2246   double runoff; //meltwater only, does not include rain
     2247   double sconv; //rhow_rain/rhoi / 12 months
     2248
     2249   double  rho_water,rho_ice,density;
     2250   double lapser=6.5/1000, sealev=0;    // lapse rate. degrees per meter.
     2251   double desfac = 0.5;                 //desert elevation factor
     2252   double s0p[NUMVERTICES]={0};         //should be set to elevation from precip source
     2253   double s0t[NUMVERTICES]={0};         //should be set to elevation from temperature source
     2254   double st;             // elevation between altitude of the temp record and current altitude
     2255   double sp;             // elevation between altitude of the prec record and current altitude
     2256
     2257
     2258   // PDD and PD constants and variables
     2259   double siglim;          // sigma limit for the integration which is equal to 2.5 sigmanorm
     2260   double siglimc=0, siglim0, siglim0c;
     2261   double PDup, pddsig, PDCUT = 2.0; // PDcut: rain/snow cutoff temperature (C)
     2262   double DT = 0.02;
     2263   double pddt, pd; // pd: snow/precip fraction, precipitation falling as snow
     2264   
     2265   double q, qmpt; // q is desert/elev. fact, hnpfac is huybrect fact, and pd is normal dist.
     2266   double qm[NUMVERTICES] = {0};        // snow part of the precipitation
     2267   double qmt[NUMVERTICES] = {0};       // precipitation without desertification effect adjustment
     2268   double qmp[NUMVERTICES] = {0};       // desertification taken into account
     2269   double pdd[NUMVERTICES] = {0};     
     2270   double frzndd[NUMVERTICES] = {0}; 
     2271
     2272   double tstar;                        // monthly mean surface temp
     2273   double Tsum[NUMVERTICES]= {0};       // average summer (JJA) temperature
     2274   double Tsurf[NUMVERTICES] = {0};     // average annual temperature   
     2275   
     2276   double h[NUMVERTICES],s[NUMVERTICES],ttmp[NUMVERTICES],prectmp[NUMVERTICES]; // ,b[NUMVERTICES]
     2277   double t[NUMVERTICES][12],prec[NUMVERTICES][12];
     2278   double deltm=1/12;
     2279   int    ismon[12]={12,1,2,3,4,5,6,7,8,9,10,11};
     2280
     2281   double snwm;  // snow that could have been melted in a year.
     2282   double snwmf; //  ablation factor for snow per positive degree day.
     2283   double smf;   //  ablation factor for ice per pdd (Braithwaite 1995 from tarasov 2002).
     2284
     2285   double dfrz=1.5, CovrLm=2009./3.35e+5, dCovrLm=dfrz*CovrLm; //m*J kg^-1 C^-1 /(J kg^-1)=m/C yr
     2286   double supice,supcap,diffndd;
     2287   double fsupT=0.5,  fsupndd=0.5;  // Tsurf mode factors for supice
     2288   double pddtj[NUMVERTICES], hmx2;
     2289
     2290   /*Recover info at the vertices: */
     2291   GetInputListOnVertices(&h[0],ThicknessEnum);
     2292   GetInputListOnVertices(&s[0],SurfaceEnum);
     2293   GetInputListOnVertices(&ttmp[0],ThermalSpctemperatureEnum);
     2294   GetInputListOnVertices(&prectmp[0],SurfaceforcingsPrecipitationEnum);
     2295
     2296   for(i=0;i<NUMVERTICES;i++) ttmp[i]=ttmp[i]-273.15; // convertion from Kelvin to celcius
     2297
     2298   for(i=0;i<NUMVERTICES;i++)
     2299     for(imonth=0;imonth<12;imonth++){
     2300       t[i][imonth]=ttmp[i];
     2301       prec[i][imonth]=prectmp[i];
     2302   }
     2303
     2304   /*Get material parameters :*/
     2305   rho_ice=matpar->GetRhoIce();
     2306   rho_water=matpar->GetRhoWater();
     2307   density=rho_ice/rho_water;
     2308   
     2309   sconv=(rho_water/rho_ice)/12.; //rhow_rain/rhoi / 12 months
     2310     
     2311     /*PDD constant*/
     2312   siglim = 2.5*signorm;
     2313   siglim0 =  siglim/DT + 0.5;
     2314   siglim0c =  siglimc/DT + 0.5;
     2315   PDup = siglimc+PDCUT;
     2316   
     2317   // seasonal loop
     2318   for (iqj = 0; iqj < 12; iqj++){
     2319     imonth =  ismon[iqj];
     2320     for (i = 0; i < NUMVERTICES; i++){
     2321       st=(s[i]-s0t[i])/1000;
     2322       tstar = t[i][imonth] - lapser *max(st,sealev);
     2323       Tsurf[i] = tstar*deltm+Tsurf[i];       
     2324       
     2325       /*********compute PD ****************/
     2326       if (tstar < PDup){
     2327         pd = 1;
     2328         if (tstar >= -siglimc){ pd = pds[int(tstar/DT + siglim0c)];}}
     2329       else {
     2330         pd = 0;}
     2331       
     2332       /******exp des/elev precip reduction*******/
     2333       sp=(s[i]-s0p[i])/1000; // deselev effect is wrt chng in topo
     2334       if (sp>0.0){q = exp(-desfac*sp);}
     2335       else {q = 1.0;}
     2336       
     2337       qmt[i]= qmt[i] + prec[i][imonth]*sconv;  //*sconv to convert in m of ice equivalent
     2338       qmpt= q*prec[i][imonth]*sconv;           
     2339       qmp[i]= qmp[i] + qmpt;
     2340       qm[i]= qm[i] + qmpt*pd;
     2341       
     2342       /*********compute PDD************/
     2343       // ndd(month)=-(tstar-pdd(month)) since ndd+pdd gives expectation of
     2344       // gaussian=T_m, so ndd=-(Tsurf-pdd)
     2345       if (iqj>6 &&  iqj<10){ Tsum[i]=Tsum[i]+tstar;}
     2346       if (tstar >= siglim) {pdd[i] = pdd[i] + tstar*deltm;}
     2347       else if (tstar> -siglim){
     2348         pddsig=pdds[int(tstar/DT + siglim0)];
     2349         pdd[i] = pdd[i] + pddsig*deltm;
     2350         frzndd[i] = frzndd[i] - (tstar-pddsig)*deltm;}
     2351       else{frzndd[i] = frzndd[i] - tstar*deltm; }
     2352     }
     2353   } // end of seasonal loop
     2354   
     2355   //******************************************************************
     2356   for(i=0;i<NUMVERTICES;i++){
     2357     saccu[i] = qm[i];
     2358     prect = qmp[i];     // total precipitation during 1 year taking into account des. ef.
     2359     Tsum[i]=Tsum[i]/3;
     2360     
     2361     /***** determine PDD factors *****/
     2362     if(Tsum[i]< -1.) {
     2363       snwmf=2.65*0.001;   //  ablation factor for snow per positive degree day.*0.001 to go from mm to m/ppd
     2364       smf=17.22*0.001;    //  ablation factor for ice per pdd (Braithwaite 1995 from tarasov 2002)
     2365     }
     2366     else if(Tsum[i]< 10){
     2367       snwmf = (0.15*Tsum[i] + 2.8)*0.001;
     2368       smf = (0.0067*pow((10.-Tsum[i]),3) + 8.3)*0.001;
     2369     }
     2370     else{
     2371       snwmf=4.3*0.001;
     2372       smf=8.3*0.001;
     2373     }
     2374     snwmf=0.95*snwmf;
     2375     smf=0.95*smf;
     2376     
     2377     /*****  compute PDD ablation and refreezing *****/
     2378     pddt = pdd[i] *365;
     2379     snwm = snwmf*pddt;       // snow that could have been melted in a year
     2380     hmx2 = min(h[i],dfrz);   // refreeze active layer max depth: dfrz
     2381     
     2382     if(snwm < saccu[i]) {
     2383       water=prect-saccu[i] + snwm; //water=rain + snowmelt
     2384       //     l 2.2= capillary factor
     2385       //     Should refreezing be controlled by frzndd or by mean annual Tsurf?
     2386       //     dCovrLm concept is of warming of active layer (thickness =d@=1-
     2387       //     >2m)
     2388       //     problem with water seepage into ice: should be sealed after
     2389       //     refreezing
     2390       //     so everything needs to be predicated on 1 year scale, except for
     2391       //     thermal
     2392       //     conductivity through ice
     2393       //     also, need to account that melt season has low accum, so what's
     2394       //     going to
     2395       //     hold the meltwater around for refreezing? And melt-time will have
     2396       //     low seasonal frzndd
     2397       
     2398       //      Superimposed ice :  Pfeffer et al. 1991, Tarasov 2002
     2399       
     2400       supice= min(hmx2*CovrLm*frzndd[i]+2.2*(saccu[i]-snwm), water); // superimposed ice
     2401       supcap=min(2.2*(saccu[i]-snwm),water);
     2402       runoff=snwm - supice;  //meltwater only, does not include rain
     2403     }
     2404     else {  //all snow melted
     2405       supice= min(hmx2*CovrLm*frzndd[i], prect );
     2406       runoff= saccu[i] + smf*(pddt-saccu[i]/snwmf) - supice;
     2407       supcap=0;
     2408     }
     2409     //     pdd melting doesn't cool Tsurf, so ndd refreeze shouldn't warm it
     2410     //     except pdd melt heat source is atmosphere, while refreeze is
     2411     //     ground/ice stored interim
     2412     //     assume pdd=ndd, then melt should equal refreeze and Tsurf should=0
     2413     //     assume ndd=2*pdd, then all supice is refrozen, but Tsurf should be
     2414     //     <0
     2415     //     assume ndd>pdd, little melt => little supice
     2416     //     bottom line: compare for Tsurf<0 : supice and no supice case,
     2417     //     expect Tsurf difference
     2418     //     except some of cooling flux comes from atmosphere//
     2419     //     1 dm supice should not raise Tsurf by 1/dCovrLm = 16.675C
     2420     //     does supice make sense when H< 0.1m? then d=thermoactive ice layer ////
     2421     //     < 0.1
     2422     
     2423     //     make more sense to just use residual pdd-ndd except that pdd
     2424     //     residual not clear yet
     2425     //     frzndd should not be used up by refreezing in snow, so stick in
     2426     //     supcap.
     2427     diffndd=0;
     2428     if (frzndd[i]>0) {
     2429       diffndd=fsupndd*min((supice-supcap)/dCovrLm ,frzndd[i]);
     2430       frzndd[i]=frzndd[i]-diffndd;
     2431     }
     2432     if(runoff<0){
     2433       saccu[i]= saccu[i] -runoff;
     2434       smelt[i] = 0;
     2435       precrunoff[i]=prect-saccu[i];
     2436       //here assume pdd residual is 0, =>
     2437       Tsurf[i]= max(Tsurf[i],-frzndd[i]);
     2438     }
     2439     else {
     2440       smelt[i] = runoff;
     2441       precrunoff[i]=prect-max(0.,supice)-saccu[i];}
     2442     //here really need pdd balance, try 0.5 fudge factor?
     2443     //at least runoff>0 => it's fairly warm, so Tsurf is !<<0,
     2444     //yet from site plots, can be ice free with Tsurf=-5.5C
     2445     if(Tsurf[i]<0) {
     2446       Tsurf[i]= min(Tsurf[i]+fsupT*diffndd , 0.);}
     2447     
     2448     agd[i] = -smelt[i]+saccu[i];
     2449     pddtj[i]=pddt;
     2450     
     2451     /*Update inputs*/   
     2452     this->inputs->AddInput(new TriaP1Input(SurfaceforcingsMassBalanceEnum,&agd[0])); ////////verifier le nom
     2453     // this->inputs->AddInput(new TriaVertexInput(ThermalSpcTemperatureEnum,&Tsurf[0]));
     2454     this->inputs->AddInput(new TriaP1Input(ThermalSpctemperatureEnum,&Tsurf[0]));
     2455     
     2456   }       //end of the for loop over the vertices
    22402457}
    22412458/*}}}*/
  • issm/trunk-jpl/src/c/objects/Elements/Tria.h

    r11695 r11994  
    108108                int    NodalValue(double* pvalue, int index, int natureofdataenum,bool process_units);
    109109                void   PotentialSheetUngrounding(Vector* potential_sheet_ungrounding);
    110                 void   PositiveDegreeDay(void);
     110                void   PositiveDegreeDay(double* pdds,double* pds,double signorm);
    111111                void   RequestedOutput(int output_enum,int step,double time);
    112112                void   ListResultsInfo(int** results_enums,int** results_size,double** results_times,int** results_steps,int* num_results);
  • issm/trunk-jpl/src/m/classes/diagnostic.m

    r11924 r11994  
    130130                        fielddisplay(obj,'spcvy','y-axis velocity constraint (NaN means no constraint)');
    131131                        fielddisplay(obj,'spcvz','z-axis velocity constraint (NaN means no constraint)');
    132                         fielddisplay(obj,'icefront','segments on ice front list (last column 0-> Air, 1-> Water, 2->Ice');
     132                        fielddisplay(obj,'icefront','segments on ice front list (last column 0-> Air, 1-> Water, 2->Ice)');
    133133
    134134                        disp(sprintf('\n      %s','Rift options:'));
Note: See TracChangeset for help on using the changeset viewer.