Changeset 12752


Ignore:
Timestamp:
07/26/12 10:28:31 (13 years ago)
Author:
Mathieu Morlighem
Message:

Fixed some leaks

Location:
issm/trunk-jpl/src/c/objects/Elements
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/objects/Elements/Penta.cpp

    r12750 r12752  
    688688void  Penta::Delta18oParameterization(void){
    689689
    690         IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
     690        IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
    691691        IssmDouble Delta18oTemperaturesPresentday[NUMVERTICES][12],Delta18oTemperaturesLgm[NUMVERTICES][12];
    692692        IssmDouble PrecipitationsPresentday[NUMVERTICES][12];
    693693        IssmDouble Delta18oPresent,Delta18oLgm,Delta18oTime;
    694694        IssmDouble Delta18oSurfacePresent,Delta18oSurfaceLgm,Delta18oSurfaceTime;
    695         IssmDouble time,yts,finaltime;
    696         this->parameters->FindParam(&time,TimeEnum);
    697         this->parameters->FindParam(&yts,ConstantsYtsEnum);
    698         this->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum);
    699 
    700         /*Recover present day temperature and precipitation*/
    701         Input*     input=inputs->GetInput(SurfaceforcingsDelta18oTemperaturesPresentdayEnum); _assert_(input);
    702         Input*     input2=inputs->GetInput(SurfaceforcingsDelta18oTemperaturesLgmEnum); _assert_(input2);
    703         Input*     input3=inputs->GetInput(SurfaceforcingsPrecipitationsPresentdayEnum); _assert_(input3);
    704         GaussPenta* gauss=new GaussPenta();
    705         for(int month=0;month<12;month++) {
    706           for(int iv=0;iv<NUMVERTICES;iv++) {
    707                 gauss->GaussVertex(iv);
    708                 input->GetInputValue(&Delta18oTemperaturesPresentday[iv][month],gauss,month/12.*yts);
    709                 input2->GetInputValue(&Delta18oTemperaturesLgm[iv][month],gauss,month/12.*yts);
    710                 input3->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts);
    711                 monthlyprec[iv][month]=monthlyprec[iv][month]*yts; // convertion to m/yr
    712           }
    713         }
    714        
    715         /*Recover delta18o and Delta18oSurface at present day, lgm and at time t*/
     695        IssmDouble time,yts,finaltime;
     696        this->parameters->FindParam(&time,TimeEnum);
     697        this->parameters->FindParam(&yts,ConstantsYtsEnum);
     698        this->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum);
     699
     700        /*Recover present day temperature and precipitation*/
     701        Input*     input=inputs->GetInput(SurfaceforcingsDelta18oTemperaturesPresentdayEnum); _assert_(input);
     702        Input*     input2=inputs->GetInput(SurfaceforcingsDelta18oTemperaturesLgmEnum); _assert_(input2);
     703        Input*     input3=inputs->GetInput(SurfaceforcingsPrecipitationsPresentdayEnum); _assert_(input3);
     704        GaussPenta* gauss=new GaussPenta();
     705        for(int month=0;month<12;month++) {
     706                for(int iv=0;iv<NUMVERTICES;iv++) {
     707                        gauss->GaussVertex(iv);
     708                        input->GetInputValue(&Delta18oTemperaturesPresentday[iv][month],gauss,month/12.*yts);
     709                        input2->GetInputValue(&Delta18oTemperaturesLgm[iv][month],gauss,month/12.*yts);
     710                        input3->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts);
     711                        monthlyprec[iv][month]=monthlyprec[iv][month]*yts; // convertion to m/yr
     712                }
     713        }
     714
     715        /*Recover delta18o and Delta18oSurface at present day, lgm and at time t*/
    716716        this->parameters->FindParam(&Delta18oPresent,SurfaceforcingsDelta18oEnum,finaltime*yts);
    717717        this->parameters->FindParam(&Delta18oLgm,SurfaceforcingsDelta18oEnum,(finaltime-21000)*yts);
     
    721721        this->parameters->FindParam(&Delta18oSurfaceTime,SurfaceforcingsDelta18oSurfaceEnum,time*yts);
    722722
    723         /*Compute the temperature and precipitation*/
    724         for(int iv=0;iv<NUMVERTICES;iv++){
    725           ComputeDelta18oTemperaturePrecipitation(Delta18oSurfacePresent, Delta18oSurfaceLgm, Delta18oSurfaceTime,
    726                                               Delta18oPresent, Delta18oLgm, Delta18oTime,
    727                                               &PrecipitationsPresentday[iv][0],
    728                                               &Delta18oTemperaturesLgm[iv][0], &Delta18oTemperaturesPresentday[iv][0],
    729                                               &monthlytemperatures[iv][0], &monthlyprec[iv][0]);
    730         }
    731  
    732         /*Update inputs*/
     723        /*Compute the temperature and precipitation*/
     724        for(int iv=0;iv<NUMVERTICES;iv++){
     725                ComputeDelta18oTemperaturePrecipitation(Delta18oSurfacePresent, Delta18oSurfaceLgm, Delta18oSurfaceTime,
     726                                        Delta18oPresent, Delta18oLgm, Delta18oTime,
     727                                        &PrecipitationsPresentday[iv][0],
     728                                        &Delta18oTemperaturesLgm[iv][0], &Delta18oTemperaturesPresentday[iv][0],
     729                                        &monthlytemperatures[iv][0], &monthlyprec[iv][0]);
     730        }
     731
     732        /*Update inputs*/
    733733        TransientInput* NewTemperatureInput = new TransientInput(SurfaceforcingsMonthlytemperaturesEnum);
    734734        TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum);
    735735        for (int imonth=0;imonth<12;imonth++) {
    736                 for(int iv=0;iv<NUMVERTICES;iv++) {
    737                         PentaP1Input* newmonthinput1 = new PentaP1Input(SurfaceforcingsMonthlytemperaturesEnum,&monthlytemperatures[iv][imonth]);
    738                         NewTemperatureInput->AddTimeInput(newmonthinput1,imonth/12.*yts);
    739                         PentaP1Input* newmonthinput2 = new PentaP1Input(SurfaceforcingsPrecipitationEnum,&monthlyprec[iv][imonth]);
    740                         NewPrecipitationInput->AddTimeInput(newmonthinput2,imonth/12.*yts);
     736                for(int iv=0;iv<NUMVERTICES;iv++) {
     737                        PentaP1Input* newmonthinput1 = new PentaP1Input(SurfaceforcingsMonthlytemperaturesEnum,&monthlytemperatures[iv][imonth]);
     738                        NewTemperatureInput->AddTimeInput(newmonthinput1,imonth/12.*yts);
     739                        PentaP1Input* newmonthinput2 = new PentaP1Input(SurfaceforcingsPrecipitationEnum,&monthlyprec[iv][imonth]);
     740                        NewPrecipitationInput->AddTimeInput(newmonthinput2,imonth/12.*yts);
    741741                }
    742742        }
    743743        this->inputs->AddInput(NewTemperatureInput);
    744744        this->inputs->AddInput(NewPrecipitationInput);
     745
     746        /*clean-up*/
     747        delete gauss;
    745748}
    746749/*}}}*/
     
    22612264        }
    22622265
     2266        delete gauss;
    22632267        if(found)*pvalue=value;
    22642268        return found;
     
    23582362   //this->inputs->AddInput(new PentaVertexInput(ThermalSpcTemperatureEnum,&Tsurf[0]));
    23592363   this->InputExtrude(SurfaceforcingsMassBalanceEnum,ElementEnum);
     2364
     2365        /*clean-up*/
     2366        delete gauss;
    23602367}
    23612368/*}}}*/
  • issm/trunk-jpl/src/c/objects/Elements/Tria.cpp

    r12750 r12752  
    911911void  Tria::Delta18oParameterization(void){
    912912
    913         IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
     913        IssmDouble monthlytemperatures[NUMVERTICES][12],monthlyprec[NUMVERTICES][12];
    914914        IssmDouble Delta18oTemperaturesPresentday[NUMVERTICES][12],Delta18oTemperaturesLgm[NUMVERTICES][12];
    915915        IssmDouble PrecipitationsPresentday[NUMVERTICES][12];
    916916        IssmDouble Delta18oPresent,Delta18oLgm,Delta18oTime;
    917917        IssmDouble Delta18oSurfacePresent,Delta18oSurfaceLgm,Delta18oSurfaceTime;
    918         IssmDouble time,yts,finaltime;
    919         this->parameters->FindParam(&time,TimeEnum);
    920         this->parameters->FindParam(&yts,ConstantsYtsEnum);
    921         this->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum);
    922 
    923         /*Recover present day temperature and precipitation*/
    924         Input*     input=inputs->GetInput(SurfaceforcingsDelta18oTemperaturesPresentdayEnum); _assert_(input);
    925         Input*     input2=inputs->GetInput(SurfaceforcingsDelta18oTemperaturesLgmEnum); _assert_(input2);
    926         Input*     input3=inputs->GetInput(SurfaceforcingsPrecipitationsPresentdayEnum); _assert_(input3);
    927         GaussTria* gauss=new GaussTria();
    928         for(int month=0;month<12;month++) {
    929                 for(int iv=0;iv<NUMVERTICES;iv++) {
    930                         gauss->GaussVertex(iv);
    931                         input->GetInputValue(&Delta18oTemperaturesPresentday[iv][month],gauss,month/12.*yts);
    932                         input2->GetInputValue(&Delta18oTemperaturesLgm[iv][month],gauss,month/12.*yts);
    933                         input3->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts);
    934                         monthlyprec[iv][month]=monthlyprec[iv][month]*yts; // convertion to m/yr
    935                 }
    936         }
    937 
    938         /*Recover delta18o and Delta18oSurface at present day, lgm and at time t*/
     918        IssmDouble time,yts,finaltime;
     919        this->parameters->FindParam(&time,TimeEnum);
     920        this->parameters->FindParam(&yts,ConstantsYtsEnum);
     921        this->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum);
     922
     923        /*Recover present day temperature and precipitation*/
     924        Input*     input=inputs->GetInput(SurfaceforcingsDelta18oTemperaturesPresentdayEnum); _assert_(input);
     925        Input*     input2=inputs->GetInput(SurfaceforcingsDelta18oTemperaturesLgmEnum); _assert_(input2);
     926        Input*     input3=inputs->GetInput(SurfaceforcingsPrecipitationsPresentdayEnum); _assert_(input3);
     927        GaussTria* gauss=new GaussTria();
     928        for(int month=0;month<12;month++) {
     929                for(int iv=0;iv<NUMVERTICES;iv++) {
     930                        gauss->GaussVertex(iv);
     931                        input->GetInputValue(&Delta18oTemperaturesPresentday[iv][month],gauss,month/12.*yts);
     932                        input2->GetInputValue(&Delta18oTemperaturesLgm[iv][month],gauss,month/12.*yts);
     933                        input3->GetInputValue(&PrecipitationsPresentday[iv][month],gauss,month/12.*yts);
     934                        monthlyprec[iv][month]=monthlyprec[iv][month]*yts; // convertion to m/yr
     935                }
     936        }
     937
     938        /*Recover delta18o and Delta18oSurface at present day, lgm and at time t*/
    939939        this->parameters->FindParam(&Delta18oPresent,SurfaceforcingsDelta18oEnum,finaltime*yts);
    940940        this->parameters->FindParam(&Delta18oLgm,SurfaceforcingsDelta18oEnum,(finaltime-21000)*yts);
     
    943943        this->parameters->FindParam(&Delta18oSurfaceLgm,SurfaceforcingsDelta18oSurfaceEnum,(finaltime-21000)*yts);
    944944        this->parameters->FindParam(&Delta18oSurfaceTime,SurfaceforcingsDelta18oSurfaceEnum,time*yts);
    945    
    946         /*Compute the temperature and precipitation*/
    947         for(int iv=0;iv<NUMVERTICES;iv++){
    948           ComputeDelta18oTemperaturePrecipitation(Delta18oSurfacePresent, Delta18oSurfaceLgm, Delta18oSurfaceTime,
    949                                               Delta18oPresent, Delta18oLgm, Delta18oTime,
    950                                               &PrecipitationsPresentday[iv][0],
    951                                               &Delta18oTemperaturesLgm[iv][0], &Delta18oTemperaturesPresentday[iv][0],
    952                                               &monthlytemperatures[iv][0], &monthlyprec[iv][0]);
    953         }
    954  
    955         /*Update inputs*/
     945
     946        /*Compute the temperature and precipitation*/
     947        for(int iv=0;iv<NUMVERTICES;iv++){
     948                ComputeDelta18oTemperaturePrecipitation(Delta18oSurfacePresent, Delta18oSurfaceLgm, Delta18oSurfaceTime,
     949                                        Delta18oPresent, Delta18oLgm, Delta18oTime,
     950                                        &PrecipitationsPresentday[iv][0],
     951                                        &Delta18oTemperaturesLgm[iv][0], &Delta18oTemperaturesPresentday[iv][0],
     952                                        &monthlytemperatures[iv][0], &monthlyprec[iv][0]);
     953        }
     954
     955        /*Update inputs*/
    956956        TransientInput* NewTemperatureInput = new TransientInput(SurfaceforcingsMonthlytemperaturesEnum);
    957957        TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum);
    958958        for (int imonth=0;imonth<12;imonth++) {
    959                 for(int iv=0;iv<NUMVERTICES;iv++) {
    960                         TriaP1Input* newmonthinput1 = new TriaP1Input(SurfaceforcingsMonthlytemperaturesEnum,&monthlytemperatures[iv][imonth]);
    961                         NewTemperatureInput->AddTimeInput(newmonthinput1,imonth/12.*yts);
    962                         TriaP1Input* newmonthinput2 = new TriaP1Input(SurfaceforcingsPrecipitationEnum,&monthlyprec[iv][imonth]);
    963                         NewPrecipitationInput->AddTimeInput(newmonthinput2,imonth/12.*yts);
     959                for(int iv=0;iv<NUMVERTICES;iv++) {
     960                        TriaP1Input* newmonthinput1 = new TriaP1Input(SurfaceforcingsMonthlytemperaturesEnum,&monthlytemperatures[iv][imonth]);
     961                        NewTemperatureInput->AddTimeInput(newmonthinput1,imonth/12.*yts);
     962                        TriaP1Input* newmonthinput2 = new TriaP1Input(SurfaceforcingsPrecipitationEnum,&monthlyprec[iv][imonth]);
     963                        NewPrecipitationInput->AddTimeInput(newmonthinput2,imonth/12.*yts);
    964964                }
    965965        }
    966966        this->inputs->AddInput(NewTemperatureInput);
    967967        this->inputs->AddInput(NewPrecipitationInput);
     968
     969        /*clean-up*/
     970        delete gauss;
    968971}
    969972/*}}}*/
     
    20392042int    Tria::NodalValue(IssmDouble* pvalue, int index, int natureofdataenum,bool process_units){
    20402043
    2041         int i;
    2042         int found=0;
    2043         IssmDouble value;
    2044         Input* data=NULL;
    2045         GaussTria *gauss                            = NULL;
     2044        int         found = 0;
     2045        IssmDouble  value;
     2046        Input      *data  = NULL;
     2047        GaussTria  *gauss = NULL;
    20462048
    20472049        /*First, serarch the input: */
     
    20502052        /*figure out if we have the vertex id: */
    20512053        found=0;
    2052         for(i=0;i<NUMVERTICES;i++){
     2054        for(int i=0;i<NUMVERTICES;i++){
    20532055                if(index==nodes[i]->GetVertexId()){
    20542056                        /*Do we have natureofdataenum in our inputs? :*/
     
    20622064                }
    20632065        }
     2066
     2067        /*clean-up*/
     2068        delete gauss;
    20642069
    20652070        if(found)*pvalue=value;
     
    21882193   this->inputs->AddInput(new TriaP1Input(SurfaceforcingsMassBalanceEnum,&agd[0]));
    21892194   // this->inputs->AddInput(new TriaVertexInput(ThermalSpcTemperatureEnum,&Tsurf[0]));
     2195
     2196        /*clean-up*/
     2197        delete gauss;
    21902198}
    21912199/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.