Changeset 19274
- Timestamp:
- 04/08/15 19:15:23 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Element.cpp
r19264 r19274 513 513 514 514 int i; 515 IssmDouble monthlytemperatures[numvertices][12],monthlyprec[numvertices][12]; 516 IssmDouble TemperaturesPresentday[numvertices][12],TemperaturesLgm[numvertices][12]; 517 IssmDouble PrecipitationsPresentday[numvertices][12]; 518 IssmDouble tmp[numvertices]; 515 IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices); 516 IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices); 517 IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(12*numvertices); 518 IssmDouble* TemperaturesLgm=xNew<IssmDouble>(12*numvertices); 519 IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(12*numvertices); 520 IssmDouble* tmp=xNew<IssmDouble>(numvertices); 519 521 IssmDouble Delta18oPresent,Delta18oLgm,Delta18oTime; 520 522 IssmDouble Delta18oSurfacePresent,Delta18oSurfaceLgm,Delta18oSurfaceTime; … … 536 538 for(int iv=0;iv<numvertices;iv++){ 537 539 gauss->GaussVertex(iv); 538 input->GetInputValue(&TemperaturesPresentday[iv ][month],gauss,month/12.*yts);539 input2->GetInputValue(&TemperaturesLgm[iv ][month],gauss,month/12.*yts);540 input3->GetInputValue(&PrecipitationsPresentday[iv ][month],gauss,month/12.*yts);541 542 PrecipitationsPresentday[iv ][month]=PrecipitationsPresentday[iv][month]*yts;540 input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,month/12.*yts); 541 input2->GetInputValue(&TemperaturesLgm[iv*12+month],gauss,month/12.*yts); 542 input3->GetInputValue(&PrecipitationsPresentday[iv*12+month],gauss,month/12.*yts); 543 544 PrecipitationsPresentday[iv*12+month]=PrecipitationsPresentday[iv*12+month]*yts; 543 545 } 544 546 } … … 556 558 ComputeDelta18oTemperaturePrecipitation(Delta18oSurfacePresent, Delta18oSurfaceLgm, Delta18oSurfaceTime, 557 559 Delta18oPresent, Delta18oLgm, Delta18oTime, 558 &PrecipitationsPresentday[iv ][0],559 &TemperaturesLgm[iv ][0], &TemperaturesPresentday[iv][0],560 &monthlytemperatures[iv ][0], &monthlyprec[iv][0]);560 &PrecipitationsPresentday[iv*12], 561 &TemperaturesLgm[iv*12], &TemperaturesPresentday[iv*12], 562 &monthlytemperatures[iv*12], &monthlyprec[iv*12]); 561 563 } 562 564 … … 565 567 TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum); 566 568 for (int imonth=0;imonth<12;imonth++) { 567 for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i ][imonth];569 for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth]; 568 570 switch(this->ObjectEnum()){ 569 571 case TriaEnum: NewTemperatureInput->AddTimeInput(new TriaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 572 574 default: _error_("Not implemented yet"); 573 575 } 574 for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i ][imonth]/yts;576 for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts; 575 577 switch(this->ObjectEnum()){ 576 578 case TriaEnum: NewPrecipitationInput->AddTimeInput(new TriaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 607 609 608 610 int i; 609 IssmDouble monthlytemperatures[numvertices][12],monthlyprec[numvertices][12]; 610 IssmDouble TemperaturesPresentday[numvertices][12],TemperaturesLgm[numvertices][12]; 611 IssmDouble PrecipitationsPresentday[numvertices][12],PrecipitationsLgm[numvertices][12]; 612 IssmDouble tmp[numvertices]; 611 IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices); 612 IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices); 613 IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(12*numvertices); 614 IssmDouble* TemperaturesLgm=xNew<IssmDouble>(12*numvertices); 615 IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(12*numvertices); 616 IssmDouble* PrecipitationsLgm=xNew<IssmDouble>(12*numvertices); 617 IssmDouble* tmp=xNew<IssmDouble>(numvertices); 613 618 IssmDouble TdiffTime,PfacTime; 614 619 IssmDouble time,yts,time_yr; … … 627 632 for(int iv=0;iv<numvertices;iv++) { 628 633 gauss->GaussVertex(iv); 629 input->GetInputValue(&TemperaturesPresentday[iv ][month],gauss,month/12.*yts);630 input2->GetInputValue(&TemperaturesLgm[iv ][month],gauss,month/12.*yts);631 input3->GetInputValue(&PrecipitationsPresentday[iv ][month],gauss,month/12.*yts);632 input4->GetInputValue(&PrecipitationsLgm[iv ][month],gauss,month/12.*yts);633 634 PrecipitationsPresentday[iv ][month]=PrecipitationsPresentday[iv][month]*yts;635 PrecipitationsLgm[iv ][month]=PrecipitationsLgm[iv][month]*yts;634 input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,month/12.*yts); 635 input2->GetInputValue(&TemperaturesLgm[iv*12+month],gauss,month/12.*yts); 636 input3->GetInputValue(&PrecipitationsPresentday[iv*12+month],gauss,month/12.*yts); 637 input4->GetInputValue(&PrecipitationsLgm[iv*12+month],gauss,month/12.*yts); 638 639 PrecipitationsPresentday[iv*12+month]=PrecipitationsPresentday[iv*12+month]*yts; 640 PrecipitationsLgm[iv*12+month]=PrecipitationsLgm[iv*12+month]*yts; 636 641 } 637 642 } … … 644 649 for(int iv=0;iv<numvertices;iv++){ 645 650 ComputeMungsmTemperaturePrecipitation(TdiffTime,PfacTime, 646 &PrecipitationsLgm[iv ][0],&PrecipitationsPresentday[iv][0],647 &TemperaturesLgm[iv ][0], &TemperaturesPresentday[iv][0],648 &monthlytemperatures[iv ][0], &monthlyprec[iv][0]);651 &PrecipitationsLgm[iv*12],&PrecipitationsPresentday[iv*12], 652 &TemperaturesLgm[iv*12], &TemperaturesPresentday[iv*12], 653 &monthlytemperatures[iv*12], &monthlyprec[iv*12]); 649 654 } 650 655 … … 653 658 TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum); 654 659 for (int imonth=0;imonth<12;imonth++) { 655 for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i ][imonth];660 for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth]; 656 661 switch(this->ObjectEnum()){ 657 662 case TriaEnum: NewTemperatureInput->AddTimeInput(new TriaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 660 665 default: _error_("Not implemented yet"); 661 666 } 662 for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i ][imonth]/yts;667 for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts; 663 668 switch(this->ObjectEnum()){ 664 669 case TriaEnum: NewPrecipitationInput->AddTimeInput(new TriaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 695 700 696 701 int i; 697 IssmDouble monthlytemperatures[numvertices][12],monthlyprec[numvertices][12]; 698 IssmDouble TemperaturesPresentday[numvertices][12]; 699 IssmDouble PrecipitationsPresentday[numvertices][12]; 700 IssmDouble tmp[numvertices]; 702 IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices); 703 IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices); 704 IssmDouble* TemperaturesPresentday=xNew<IssmDouble>(12*numvertices); 705 IssmDouble* PrecipitationsPresentday=xNew<IssmDouble>(12*numvertices); 706 IssmDouble* tmp=xNew<IssmDouble>(numvertices); 701 707 IssmDouble Delta18oTime; 702 708 IssmDouble dpermil; … … 717 723 for(int iv=0;iv<numvertices;iv++) { 718 724 gauss->GaussVertex(iv); 719 input->GetInputValue(&TemperaturesPresentday[iv ][month],gauss,month/12.*yts);720 input2->GetInputValue(&PrecipitationsPresentday[iv ][month],gauss,month/12.*yts);721 722 PrecipitationsPresentday[iv ][month]=PrecipitationsPresentday[iv][month]*yts;725 input->GetInputValue(&TemperaturesPresentday[iv*12+month],gauss,month/12.*yts); 726 input2->GetInputValue(&PrecipitationsPresentday[iv*12+month],gauss,month/12.*yts); 727 728 PrecipitationsPresentday[iv*12+month]=PrecipitationsPresentday[iv*12+month]*yts; 723 729 } 724 730 } … … 730 736 for(int iv=0;iv<numvertices;iv++){ 731 737 ComputeD18OTemperaturePrecipitationFromPD(Delta18oTime,dpermil, 732 &PrecipitationsPresentday[iv ][0], &TemperaturesPresentday[iv][0],733 &monthlytemperatures[iv ][0], &monthlyprec[iv][0]);738 &PrecipitationsPresentday[iv*12], &TemperaturesPresentday[iv*12], 739 &monthlytemperatures[iv*12], &monthlyprec[iv*12]); 734 740 } 735 741 … … 738 744 TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum); 739 745 for (int imonth=0;imonth<12;imonth++) { 740 for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i ][imonth];746 for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth]; 741 747 switch(this->ObjectEnum()){ 742 748 case TriaEnum: NewTemperatureInput->AddTimeInput(new TriaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 745 751 default: _error_("Not implemented yet"); 746 752 } 747 for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i ][imonth]/yts;753 for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts; 748 754 switch(this->ObjectEnum()){ 749 755 case TriaEnum: NewPrecipitationInput->AddTimeInput(new TriaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum),time_yr+imonth/12.*yts); break; … … 1657 1663 1658 1664 int i; 1659 IssmDouble agd[numvertices]; // surface mass balance 1660 IssmDouble monthlytemperatures[numvertices][12],monthlyprec[numvertices][12]; 1661 IssmDouble yearlytemperatures[numvertices]; memset(yearlytemperatures, 0., numvertices*sizeof(IssmDouble)); 1662 IssmDouble tmp[numvertices]; 1663 IssmDouble h[numvertices],s[numvertices]; 1665 IssmDouble* agd=xNew<IssmDouble>(numvertices); // surface mass balance 1666 IssmDouble* monthlytemperatures=xNew<IssmDouble>(12*numvertices); 1667 IssmDouble* monthlyprec=xNew<IssmDouble>(12*numvertices); 1668 IssmDouble* yearlytemperatures=xNew<IssmDouble>(numvertices); memset(yearlytemperatures, 0., numvertices*sizeof(IssmDouble)); 1669 IssmDouble* tmp=xNew<IssmDouble>(numvertices); 1670 IssmDouble* h=xNew<IssmDouble>(numvertices); 1671 IssmDouble* s=xNew<IssmDouble>(numvertices); 1664 1672 IssmDouble rho_water,rho_ice,desfac,s0p,s0t,rlaps,rlapslgm; 1665 1673 IssmDouble PfacTime,TdiffTime,sealevTime; … … 1690 1698 for(int iv=0;iv<numvertices;iv++) { 1691 1699 gauss->GaussVertex(iv); 1692 input->GetInputValue(&monthlytemperatures[iv ][month],gauss,time_yr+month/12.*yts);1693 yearlytemperatures[iv]=yearlytemperatures[iv]+monthlytemperatures[iv ][month]*mavg; // Has to be in Kelvin1694 monthlytemperatures[iv ][month]=monthlytemperatures[iv][month]-273.15; // conversion from Kelvin to celcius for PDD module1695 input2->GetInputValue(&monthlyprec[iv ][month],gauss,time_yr+month/12.*yts);1696 monthlyprec[iv ][month]=monthlyprec[iv][month]*yts;1700 input->GetInputValue(&monthlytemperatures[iv*12+month],gauss,time_yr+month/12.*yts); 1701 yearlytemperatures[iv]=yearlytemperatures[iv]+monthlytemperatures[iv*12+month]*mavg; // Has to be in Kelvin 1702 monthlytemperatures[iv*12+month]=monthlytemperatures[iv*12+month]-273.15; // conversion from Kelvin to celcius for PDD module 1703 input2->GetInputValue(&monthlyprec[iv*12+month],gauss,time_yr+month/12.*yts); 1704 monthlyprec[iv*12+month]=monthlyprec[iv*12+month]*yts; 1697 1705 } 1698 1706 } … … 1716 1724 /*measure the surface mass balance*/ 1717 1725 for (int iv = 0; iv<numvertices; iv++){ 1718 agd[iv]=PddSurfaceMassBalance(&monthlytemperatures[iv ][0], &monthlyprec[iv][0],1726 agd[iv]=PddSurfaceMassBalance(&monthlytemperatures[iv*12], &monthlyprec[iv*12], 1719 1727 pdds, pds, signorm, yts, h[iv], s[iv], 1720 1728 desfac, s0t, s0p,rlaps,rlapslgm,TdiffTime,sealevTime, … … 1726 1734 // TransientInput* NewPrecipitationInput = new TransientInput(SurfaceforcingsPrecipitationEnum); 1727 1735 // for (int imonth=0;imonth<12;imonth++) { 1728 // for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i ][imonth];1736 // for(i=0;i<numvertices;i++) tmp[i]=monthlytemperatures[i*12+imonth]; 1729 1737 // TriaInput* newmonthinput1 = new TriaInput(SurfaceforcingsMonthlytemperaturesEnum,&tmp[0],P1Enum); 1730 1738 // NewTemperatureInput->AddTimeInput(newmonthinput1,time+imonth/12.*yts); 1731 1739 // 1732 // for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i ][imonth];1740 // for(i=0;i<numvertices;i++) tmp[i]=monthlyprec[i*12+imonth]/yts; 1733 1741 // TriaInput* newmonthinput2 = new TriaInput(SurfaceforcingsPrecipitationEnum,&tmp[0],P1Enum); 1734 1742 // NewPrecipitationInput->AddTimeInput(newmonthinput2,time+imonth/12.*yts);
Note:
See TracChangeset
for help on using the changeset viewer.