source:
issm/oecreview/Archive/24307-24683/ISSM-24682-24683.diff
Last change on this file was 24684, checked in by , 5 years ago | |
---|---|
File size: 35.6 KB |
-
../trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
714 714 SmbDziniEnum, 715 715 SmbEAirEnum, 716 716 SmbECEnum, 717 SmbECDtEnum, 717 718 SmbECiniEnum, 718 719 SmbElaEnum, 719 720 SmbEvaporationEnum, … … 733 734 SmbMeanSHFEnum, 734 735 SmbMeanULWEnum, 735 736 SmbMeltEnum, 737 SmbMInitnum, 736 738 SmbMonthlytemperaturesEnum, 737 739 SmbNetLWEnum, 738 740 SmbNetSWEnum, … … 771 773 SmbVmeanEnum, 772 774 SmbVzEnum, 773 775 SmbWEnum, 776 SmbWAddEnum, 774 777 SmbWiniEnum, 775 778 SmbZMaxEnum, 776 779 SmbZMinEnum, -
../trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
719 719 case SmbDziniEnum : return "SmbDzini"; 720 720 case SmbEAirEnum : return "SmbEAir"; 721 721 case SmbECEnum : return "SmbEC"; 722 case SmbECDtEnum : return "SmbECDt"; 722 723 case SmbECiniEnum : return "SmbECini"; 723 724 case SmbElaEnum : return "SmbEla"; 724 725 case SmbEvaporationEnum : return "SmbEvaporation"; … … 776 777 case SmbVmeanEnum : return "SmbVmean"; 777 778 case SmbVzEnum : return "SmbVz"; 778 779 case SmbWEnum : return "SmbW"; 780 case SmbWAddEnum : return "SmbWAdd"; 779 781 case SmbWiniEnum : return "SmbWini"; 780 782 case SmbZMaxEnum : return "SmbZMax"; 781 783 case SmbZMinEnum : return "SmbZMin"; -
../trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
734 734 else if (strcmp(name,"SmbDzini")==0) return SmbDziniEnum; 735 735 else if (strcmp(name,"SmbEAir")==0) return SmbEAirEnum; 736 736 else if (strcmp(name,"SmbEC")==0) return SmbECEnum; 737 else if (strcmp(name,"SmbECDt")==0) return SmbECDtEnum; 737 738 else if (strcmp(name,"SmbECini")==0) return SmbECiniEnum; 738 739 else if (strcmp(name,"SmbEla")==0) return SmbElaEnum; 739 740 else if (strcmp(name,"SmbEvaporation")==0) return SmbEvaporationEnum; … … 750 751 else if (strcmp(name,"SmbMassBalanceSubstep")==0) return SmbMassBalanceSubstepEnum; 751 752 else if (strcmp(name,"SmbMassBalanceTransient")==0) return SmbMassBalanceTransientEnum; 752 753 else if (strcmp(name,"SmbMeanLHF")==0) return SmbMeanLHFEnum; 753 else if (strcmp(name,"SmbMeanSHF")==0) return SmbMeanSHFEnum;754 754 else stage=7; 755 755 } 756 756 if(stage==7){ 757 if (strcmp(name,"SmbMeanULW")==0) return SmbMeanULWEnum; 757 if (strcmp(name,"SmbMeanSHF")==0) return SmbMeanSHFEnum; 758 else if (strcmp(name,"SmbMeanULW")==0) return SmbMeanULWEnum; 758 759 else if (strcmp(name,"SmbMelt")==0) return SmbMeltEnum; 759 760 else if (strcmp(name,"SmbMonthlytemperatures")==0) return SmbMonthlytemperaturesEnum; 760 761 else if (strcmp(name,"SmbNetLW")==0) return SmbNetLWEnum; … … 794 795 else if (strcmp(name,"SmbVmean")==0) return SmbVmeanEnum; 795 796 else if (strcmp(name,"SmbVz")==0) return SmbVzEnum; 796 797 else if (strcmp(name,"SmbW")==0) return SmbWEnum; 798 else if (strcmp(name,"SmbWAdd")==0) return SmbWAddEnum; 797 799 else if (strcmp(name,"SmbWini")==0) return SmbWiniEnum; 798 800 else if (strcmp(name,"SmbZMax")==0) return SmbZMaxEnum; 799 801 else if (strcmp(name,"SmbZMin")==0) return SmbZMinEnum; … … 872 874 else if (strcmp(name,"Outputdefinition16")==0) return Outputdefinition16Enum; 873 875 else if (strcmp(name,"Outputdefinition17")==0) return Outputdefinition17Enum; 874 876 else if (strcmp(name,"Outputdefinition18")==0) return Outputdefinition18Enum; 875 else if (strcmp(name,"Outputdefinition19")==0) return Outputdefinition19Enum;876 else if (strcmp(name,"Outputdefinition20")==0) return Outputdefinition20Enum;877 877 else stage=8; 878 878 } 879 879 if(stage==8){ 880 if (strcmp(name,"Outputdefinition21")==0) return Outputdefinition21Enum; 880 if (strcmp(name,"Outputdefinition19")==0) return Outputdefinition19Enum; 881 else if (strcmp(name,"Outputdefinition20")==0) return Outputdefinition20Enum; 882 else if (strcmp(name,"Outputdefinition21")==0) return Outputdefinition21Enum; 881 883 else if (strcmp(name,"Outputdefinition22")==0) return Outputdefinition22Enum; 882 884 else if (strcmp(name,"Outputdefinition23")==0) return Outputdefinition23Enum; 883 885 else if (strcmp(name,"Outputdefinition24")==0) return Outputdefinition24Enum; … … 995 997 else if (strcmp(name,"BoolInput")==0) return BoolInputEnum; 996 998 else if (strcmp(name,"BoolInput2")==0) return BoolInput2Enum; 997 999 else if (strcmp(name,"IntInput2")==0) return IntInput2Enum; 998 else if (strcmp(name,"BoolParam")==0) return BoolParamEnum;999 else if (strcmp(name,"Boundary")==0) return BoundaryEnum;1000 1000 else stage=9; 1001 1001 } 1002 1002 if(stage==9){ 1003 if (strcmp(name,"BuddJacka")==0) return BuddJackaEnum; 1003 if (strcmp(name,"BoolParam")==0) return BoolParamEnum; 1004 else if (strcmp(name,"Boundary")==0) return BoundaryEnum; 1005 else if (strcmp(name,"BuddJacka")==0) return BuddJackaEnum; 1004 1006 else if (strcmp(name,"CalvingDev2")==0) return CalvingDev2Enum; 1005 1007 else if (strcmp(name,"CalvingHab")==0) return CalvingHabEnum; 1006 1008 else if (strcmp(name,"CalvingLevermann")==0) return CalvingLevermannEnum; … … 1118 1120 else if (strcmp(name,"IceVolumeScaled")==0) return IceVolumeScaledEnum; 1119 1121 else if (strcmp(name,"IcefrontMassFlux")==0) return IcefrontMassFluxEnum; 1120 1122 else if (strcmp(name,"IcefrontMassFluxLevelset")==0) return IcefrontMassFluxLevelsetEnum; 1121 else if (strcmp(name,"Incremental")==0) return IncrementalEnum;1122 else if (strcmp(name,"Indexed")==0) return IndexedEnum;1123 1123 else stage=10; 1124 1124 } 1125 1125 if(stage==10){ 1126 if (strcmp(name,"IntExternalResult")==0) return IntExternalResultEnum; 1126 if (strcmp(name,"Incremental")==0) return IncrementalEnum; 1127 else if (strcmp(name,"Indexed")==0) return IndexedEnum; 1128 else if (strcmp(name,"IntExternalResult")==0) return IntExternalResultEnum; 1127 1129 else if (strcmp(name,"IntInput")==0) return IntInputEnum; 1128 1130 else if (strcmp(name,"ElementInput2")==0) return ElementInput2Enum; 1129 1131 else if (strcmp(name,"SegInput2")==0) return SegInput2Enum; … … 1241 1243 else if (strcmp(name,"ProfilingSolutionTime")==0) return ProfilingSolutionTimeEnum; 1242 1244 else if (strcmp(name,"Regionaloutput")==0) return RegionaloutputEnum; 1243 1245 else if (strcmp(name,"Regular")==0) return RegularEnum; 1244 else if (strcmp(name,"RecoveryAnalysis")==0) return RecoveryAnalysisEnum;1245 else if (strcmp(name,"Riftfront")==0) return RiftfrontEnum;1246 1246 else stage=11; 1247 1247 } 1248 1248 if(stage==11){ 1249 if (strcmp(name,"SIAApproximation")==0) return SIAApproximationEnum; 1249 if (strcmp(name,"RecoveryAnalysis")==0) return RecoveryAnalysisEnum; 1250 else if (strcmp(name,"Riftfront")==0) return RiftfrontEnum; 1251 else if (strcmp(name,"SIAApproximation")==0) return SIAApproximationEnum; 1250 1252 else if (strcmp(name,"SMBcomponents")==0) return SMBcomponentsEnum; 1251 1253 else if (strcmp(name,"SMBd18opdd")==0) return SMBd18opddEnum; 1252 1254 else if (strcmp(name,"SMBforcing")==0) return SMBforcingEnum; -
../trunk-jpl/src/c/shared/Enum/Enum.vim
148 148 syn keyword cConstant FlowequationIsSSAEnum 149 149 syn keyword cConstant FrictionCouplingEnum 150 150 syn keyword cConstant FrictionDeltaEnum 151 syn keyword cConstant FrictionEffectivePressureLimitEnum 151 152 syn keyword cConstant FrictionFEnum 152 153 syn keyword cConstant FrictionGammaEnum 153 154 syn keyword cConstant FrictionLawEnum … … 716 717 syn keyword cConstant SmbDziniEnum 717 718 syn keyword cConstant SmbEAirEnum 718 719 syn keyword cConstant SmbECEnum 720 syn keyword cConstant SmbECDtEnum 719 721 syn keyword cConstant SmbECiniEnum 720 722 syn keyword cConstant SmbElaEnum 721 723 syn keyword cConstant SmbEvaporationEnum … … 773 775 syn keyword cConstant SmbVmeanEnum 774 776 syn keyword cConstant SmbVzEnum 775 777 syn keyword cConstant SmbWEnum 778 syn keyword cConstant SmbWAddEnum 776 779 syn keyword cConstant SmbWiniEnum 777 780 syn keyword cConstant SmbZMaxEnum 778 781 syn keyword cConstant SmbZMinEnum … … 1334 1337 syn keyword cType Cfsurfacelogvel 1335 1338 syn keyword cType Cfsurfacesquare 1336 1339 syn keyword cType Channel 1337 syn keyword cType classes1338 1340 syn keyword cType Constraint 1339 1341 syn keyword cType Constraints 1340 1342 syn keyword cType Contour … … 1341 1343 syn keyword cType Contours 1342 1344 syn keyword cType ControlInput2 1343 1345 syn keyword cType Covertree 1346 syn keyword cType DataSetParam 1344 1347 syn keyword cType DatasetInput2 1345 syn keyword cType DataSetParam1346 1348 syn keyword cType Definition 1347 1349 syn keyword cType DependentObject 1348 1350 syn keyword cType DoubleMatArrayParam … … 1354 1356 syn keyword cType ElementHook 1355 1357 syn keyword cType ElementInput2 1356 1358 syn keyword cType ElementMatrix 1359 syn keyword cType ElementVector 1357 1360 syn keyword cType Elements 1358 syn keyword cType ElementVector1359 1361 syn keyword cType ExponentialVariogram 1360 1362 syn keyword cType ExternalResult 1361 1363 syn keyword cType FemModel … … 1362 1364 syn keyword cType FileParam 1363 1365 syn keyword cType Friction 1364 1366 syn keyword cType Gauss 1365 syn keyword cType GaussianVariogram1366 syn keyword cType gaussobjects1367 1367 syn keyword cType GaussPenta 1368 1368 syn keyword cType GaussSeg 1369 1369 syn keyword cType GaussTetra 1370 1370 syn keyword cType GaussTria 1371 syn keyword cType GaussianVariogram 1371 1372 syn keyword cType GenericExternalResult 1372 1373 syn keyword cType GenericOption 1373 1374 syn keyword cType GenericParam … … 1382 1383 syn keyword cType IoModel 1383 1384 syn keyword cType IssmDirectApplicInterface 1384 1385 syn keyword cType IssmParallelDirectApplicInterface 1385 syn keyword cType krigingobjects1386 1386 syn keyword cType Load 1387 1387 syn keyword cType Loads 1388 1388 syn keyword cType Masscon … … 1393 1393 syn keyword cType Matestar 1394 1394 syn keyword cType Matice 1395 1395 syn keyword cType Matlitho 1396 syn keyword cType matrixobjects1397 1396 syn keyword cType MatrixParam 1398 1397 syn keyword cType Misfit 1399 1398 syn keyword cType Moulin … … 1406 1405 syn keyword cType Observation 1407 1406 syn keyword cType Observations 1408 1407 syn keyword cType Option 1408 syn keyword cType OptionUtilities 1409 1409 syn keyword cType Options 1410 syn keyword cType OptionUtilities1411 1410 syn keyword cType Param 1412 1411 syn keyword cType Parameters 1413 1412 syn keyword cType Pengrid … … 1421 1420 syn keyword cType Radar 1422 1421 syn keyword cType Regionaloutput 1423 1422 syn keyword cType Results 1423 syn keyword cType RiftStruct 1424 1424 syn keyword cType Riftfront 1425 syn keyword cType RiftStruct1426 1425 syn keyword cType Seg 1427 1426 syn keyword cType SegInput2 1427 syn keyword cType SegRef 1428 1428 syn keyword cType Segment 1429 syn keyword cType SegRef1430 1429 syn keyword cType SpcDynamic 1431 1430 syn keyword cType SpcStatic 1432 1431 syn keyword cType SpcTransient … … 1445 1444 syn keyword cType VectorParam 1446 1445 syn keyword cType Vertex 1447 1446 syn keyword cType Vertices 1447 syn keyword cType classes 1448 syn keyword cType gaussobjects 1449 syn keyword cType krigingobjects 1450 syn keyword cType matrixobjects 1448 1451 syn keyword cType AdjointBalancethickness2Analysis 1449 1452 syn keyword cType AdjointBalancethicknessAnalysis 1450 1453 syn keyword cType AdjointHorizAnalysis … … 1463 1466 syn keyword cType ExtrudeFromTopAnalysis 1464 1467 syn keyword cType FreeSurfaceBaseAnalysis 1465 1468 syn keyword cType FreeSurfaceTopAnalysis 1469 syn keyword cType GLheightadvectionAnalysis 1466 1470 syn keyword cType GiaIvinsAnalysis 1467 syn keyword cType GLheightadvectionAnalysis1468 1471 syn keyword cType HydrologyDCEfficientAnalysis 1469 1472 syn keyword cType HydrologyDCInefficientAnalysis 1470 1473 syn keyword cType HydrologyGlaDSAnalysis -
../trunk-jpl/src/c/modules/SurfaceMassBalancex/Gembx.cpp
5 5 #include "./SurfaceMassBalancex.h" 6 6 #include "../../shared/shared.h" 7 7 #include "../../toolkits/toolkits.h" 8 #include "../modules.h" 9 #include "../../classes/Inputs2/TransientInput2.h" 8 10 9 11 const double Pi = 3.141592653589793; 10 12 const double CtoK = 273.15; // Kelvin to Celcius conversion/ice melt. point T in K … … 31 33 32 34 void Gembx(FemModel* femmodel){ /*{{{*/ 33 35 34 for(int i=0;i<femmodel->elements->Size();i++){ 35 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 36 element->SmbGemb(); 36 int count=0; 37 IssmDouble time,dt,finaltime,starttime; 38 IssmDouble timeclim=0.0; 39 IssmDouble t,smb_dt; 40 IssmDouble delta; 41 bool isclimatology=false; 42 43 femmodel->parameters->FindParam(&time,TimeEnum); /*transient core time at which we run the smb core*/ 44 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); /*transient core time step*/ 45 femmodel->parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum); 46 femmodel->parameters->FindParam(&starttime,TimesteppingStartTimeEnum); 47 femmodel->parameters->FindParam(&smb_dt,SmbDtEnum); /*time period for the smb solution, usually smaller than the glaciological dt*/ 48 femmodel->parameters->FindParam(&isclimatology,SmbIsclimatologyEnum); 49 50 //before starting loop, realize that the transient core runs this smb_core at time = time +deltaT. 51 //go back to time - deltaT: 52 time-=dt; 53 54 IssmDouble timeinputs = time; 55 56 /*Start loop: */ 57 count=1; 58 for (t=time;t<time+dt;t=t+smb_dt){ 59 60 for(int i=0;i<femmodel->elements->Size();i++){ 61 Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 62 63 timeclim=time; 64 if (isclimatology){ 65 //If this is a climatology, we need to repeat the forcing after the final time 66 TransientInput2* Ta_input_tr = element->inputs2->GetTransientInput(SmbTaEnum); _assert_(Ta_input_tr); 67 68 /*Get temperature climatology value*/ 69 int offsetend = Ta_input_tr->GetTimeInputOffset(finaltime); 70 IssmDouble time0 = Ta_input_tr->GetTimeByOffset(-1); 71 IssmDouble timeend = Ta_input_tr->GetTimeByOffset(offsetend); 72 if (time>time0 & timeend>time0){ 73 delta=(time-time0) - (timeend-time0)*(reCast<int,IssmDouble>((time-time0)/(timeend-time0))); 74 timeclim=time0+delta; 75 } 76 } 77 timeinputs = t-time+timeclim; 78 element->SmbGemb(timeinputs,count); 79 } 80 count=count+1; 37 81 } 38 82 39 83 } /*}}}*/ … … 1044 1088 1045 1089 // SWs and SWss coefficients need to be better constranted. Greuell 1046 1090 // and Konzelmann 1994 used SWs = 0.36 and SWss = 0.64 as this the 1047 // the //of SW radiation with wavelengths > and < 800 nm1091 // the % of SW radiation with wavelengths > and < 800 nm 1048 1092 // respectively. This, however, may not account for the fact that 1049 1093 // the albedo of wavelengths > 800 nm has a much lower albedo. 1050 1094 … … 2106 2150 if(V< 0.01-Dtol)V=0.01; 2107 2151 2108 2152 // calculate the Bulk Richardson Number (Ri) 2109 Ri = (2.0*9.81* (Vz - z0) * (Ta - Ts)) / ((Ta + Ts)* pow(V,2 ));2153 Ri = (2.0*9.81* (Vz - z0) * (Ta - Ts)) / ((Ta + Ts)* pow(V,2.0)); 2110 2154 2111 // calculate Monin-Obukhov stability factors 'coef _M' and 'coef_H'2155 // calculate Monin-Obukhov stability factors 'coefM' and 'coefH' 2112 2156 2113 2157 // do not allow Ri to exceed 0.19 2114 2158 Ri = min(Ri, 0.19); -
../trunk-jpl/src/c/classes/Elements/Element.h
171 171 void SetIntInput(Inputs2* inputs2,int enum_in,int value); 172 172 void SmbSemic(); 173 173 int Sid(); 174 void SmbGemb( );174 void SmbGemb(IssmDouble timeinputs, int count); 175 175 void StrainRateESA(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input2* vx_input,Input2* vy_input); 176 176 void StrainRateFS(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input2* vx_input,Input2* vy_input,Input2* vz_input); 177 177 void StrainRateHO(IssmDouble* epsilon,IssmDouble* xyz_list,Gauss* gauss,Input2* vx_input,Input2* vy_input); -
../trunk-jpl/src/c/classes/Elements/Element.cpp
561 561 this->parameters->FindParam(&isTemperatureScaled,SmbIstemperaturescaledEnum); 562 562 this->parameters->FindParam(&isPrecipScaled,SmbIsprecipscaledEnum); 563 563 564 564 /*Recover present day temperature and precipitation*/ 565 565 DatasetInput2 *dinput3 = NULL; 566 566 DatasetInput2 *dinput4 = NULL; 567 567 int offset_t,offset_p,N; … … 3587 3587 3588 3588 } 3589 3589 /*}}}*/ 3590 void Element::SmbGemb( ){/*{{{*/3590 void Element::SmbGemb(IssmDouble timeinputs, int count){/*{{{*/ 3591 3591 3592 3592 /*only compute SMB at the surface: */ 3593 3593 if (!IsOnSurface()) return; … … 3604 3604 IssmDouble Vmean=0.0; 3605 3605 IssmDouble C=0.0; 3606 3606 IssmDouble Tz,Vz=0.0; 3607 IssmDouble time,dt,starttime,finaltime;3608 IssmDouble timeclim=0.0;3609 IssmDouble t,smb_dt;3610 3607 IssmDouble yts; 3611 3608 IssmDouble Ta=0.0; 3612 3609 IssmDouble V=0.0; … … 3617 3614 IssmDouble pAir=0.0; 3618 3615 IssmDouble teValue=1.0; 3619 3616 IssmDouble aValue=0.0; 3617 IssmDouble dt,time,smb_dt; 3620 3618 int aIdx=0; 3621 3619 int denIdx=0; 3622 3620 int dsnowIdx=0; … … 3626 3624 IssmDouble shf=0.0; 3627 3625 IssmDouble dayEC=0.0; 3628 3626 IssmDouble initMass=0.0; 3629 IssmDouble sumR=0.0; 3630 IssmDouble sumM=0.0; 3631 IssmDouble sumEC=0.0; 3632 IssmDouble sumP=0.0; 3633 IssmDouble sumW=0.0; 3634 IssmDouble sumMassAdd=0.0; 3635 IssmDouble sumdz_add=0.0; 3627 IssmDouble sumR=0.0; 3628 IssmDouble sumM=0.0; 3629 IssmDouble sumEC=0.0; 3630 IssmDouble sumP=0.0; 3631 IssmDouble sumW=0.0; 3632 IssmDouble sumMassAdd=0.0; 3636 3633 IssmDouble fac=0.0; 3637 3634 IssmDouble sumMass=0.0; 3638 3635 IssmDouble dMass=0.0; … … 3641 3638 IssmDouble init_scaling=0.0; 3642 3639 IssmDouble thermo_scaling=1.0; 3643 3640 IssmDouble adThresh=1023.0; 3644 int offsetend=-1;3645 IssmDouble time0, timeend, delta;3646 3641 /*}}}*/ 3647 3642 /*Output variables:{{{ */ 3648 3643 IssmDouble* dz=NULL; … … 3675 3670 IssmDouble* aini = NULL; 3676 3671 IssmDouble* Tini = NULL; 3677 3672 int m=0; 3678 int count=0;3679 3673 /*}}}*/ 3680 3674 3681 3675 /*Retrieve material properties and parameters:{{{ */ … … 3686 3680 parameters->FindParam(&time,TimeEnum); /*transient core time at which we run the smb core*/ 3687 3681 parameters->FindParam(&dt,TimesteppingTimeStepEnum); /*transient core time step*/ 3688 3682 parameters->FindParam(&yts,ConstantsYtsEnum); 3689 parameters->FindParam(&finaltime,TimesteppingFinalTimeEnum);3690 parameters->FindParam(&starttime,TimesteppingStartTimeEnum);3691 3683 parameters->FindParam(&smb_dt,SmbDtEnum); /*time period for the smb solution, usually smaller than the glaciological dt*/ 3692 3684 parameters->FindParam(&aIdx,SmbAIdxEnum); 3693 3685 parameters->FindParam(&denIdx,SmbDenIdxEnum); … … 3697 3689 parameters->FindParam(&t0wet,SmbT0wetEnum); 3698 3690 parameters->FindParam(&t0dry,SmbT0dryEnum); 3699 3691 parameters->FindParam(&K,SmbKEnum); 3700 parameters->FindParam(&isclimatology,SmbIsclimatologyEnum);3701 3692 parameters->FindParam(&isgraingrowth,SmbIsgraingrowthEnum); 3702 3693 parameters->FindParam(&isalbedo,SmbIsalbedoEnum); 3703 3694 parameters->FindParam(&isshortwave,SmbIsshortwaveEnum); … … 3722 3713 Input2 *C_input = this->GetInput2(SmbCEnum); _assert_(C_input); 3723 3714 Input2 *Tz_input = this->GetInput2(SmbTzEnum); _assert_(Tz_input); 3724 3715 Input2 *Vz_input = this->GetInput2(SmbVzEnum); _assert_(Vz_input); 3725 Input2 *teValue_input = this->GetInput2(SmbTeValueEnum); _assert_(teValue_input);3726 Input2 *aValue_input = this->GetInput2(SmbAValueEnum); _assert_(aValue_input);3727 3716 Input2 *EC_input = NULL; 3728 3717 3729 3718 /*Retrieve input values:*/ … … 3741 3730 C_input->GetInputValue(&C,gauss); 3742 3731 Tz_input->GetInputValue(&Tz,gauss); 3743 3732 Vz_input->GetInputValue(&Vz,gauss); 3744 teValue_input->GetInputValue(&teValue,gauss);3745 aValue_input->GetInputValue(&aValue,gauss);3746 3733 /*}}}*/ 3747 3734 3748 3735 /*First, check that the initial structures have been setup in GEMB. If not, initialize profile variables: layer thickness dz, * density d, temperature T, etc. {{{*/ … … 3762 3749 EC_input = this->GetInput2(SmbECiniEnum); _assert_(EC_input); 3763 3750 EC_input->GetInputAverage(&EC); 3764 3751 3765 /*Retri ve the correct value of m (without the zeroes at the end)*/3752 /*Retrieve the correct value of m (without the zeroes at the end)*/ 3766 3753 this->GetInput2Value(&m,SmbSizeiniEnum); 3767 3754 3768 3755 if(m==2){ //Snow properties are initialized with default values. Vertical grid has to be initialized too … … 3815 3802 this->inputs2->GetArray(SmbWEnum,this->lid,&W,&m); 3816 3803 this->inputs2->GetArray(SmbAEnum,this->lid,&a,&m); 3817 3804 this->inputs2->GetArray(SmbTEnum,this->lid,&T,&m); 3818 EC_input = this->GetInput2(SmbEC Enum); _assert_(EC_input);3805 EC_input = this->GetInput2(SmbECDtEnum); _assert_(EC_input); 3819 3806 EC_input->GetInputAverage(&EC); 3820 EC=EC*dt*rho_ice;3821 3807 3822 3808 //fixed lower temperature bounday condition - T is fixed 3823 3809 _assert_(m>0); … … 3829 3815 3830 3816 // initialize cumulative variables 3831 3817 sumR = 0; sumM = 0; sumEC = 0; sumP = 0; sumMassAdd = 0; 3832 sumdz_add=0;3833 3818 3834 3819 //before starting loop, realize that the transient core runs this smb_core at time = time +deltaT. 3835 3836 3820 //go back to time - deltaT: 3821 time-=dt; 3837 3822 3838 timeclim=time; 3839 if (isclimatology){ 3840 //If this is a climatology, we need to repeat the forcing after the final time 3841 TransientInput2* Ta_input_tr = this->inputs2->GetTransientInput(SmbTaEnum); _assert_(Ta_input_tr); 3842 offsetend = Ta_input_tr->GetTimeInputOffset(finaltime); 3843 time0 = Ta_input_tr->GetTimeByOffset(-1); 3844 timeend = Ta_input_tr->GetTimeByOffset(offsetend); 3845 if (time>time0 & timeend>time0){ 3846 delta=(time-time0) - (timeend-time0)*(reCast<int,IssmDouble>((time-time0)/(timeend-time0))); 3847 timeclim=time0+delta; 3848 } 3849 } 3823 if(VerboseSmb() && this->Sid()==0 && IssmComm::GetRank()==0)_printf0_("Time: t=" << setprecision(8) << timeinputs/365.0/24.0/3600.0 << " yr/" << (time+dt)/365.0/24.0/3600.0 << " yr" << setprecision(3) << " Step: " << count << "\n"); 3850 3824 3851 /*Start loop: */ 3852 count=1; 3853 for (t=time;t<time+dt;t=t+smb_dt){ 3825 /*Get daily accumulated inputs {{{*/ 3826 if (count>1){ 3827 Input2 *sumEC_input = this->GetInput2(SmbECEnum); _assert_(sumEC_input); 3828 Input2 *sumM_input = this->GetInput2(SmbMeltEnum); _assert_(sumM_input); 3829 Input2 *sumR_input = this->GetInput2(SmbRunoffEnum); _assert_(sumR_input); 3830 Input2 *sumP_input = this->GetInput2(SmbPrecipitationEnum); _assert_(sumP_input); 3831 Input2 *ULW_input = this->GetInput2(SmbMeanULWEnum); _assert_(ULW_input); 3832 Input2 *LW_input = this->GetInput2(SmbNetLWEnum); _assert_(LW_input); 3833 Input2 *SW_input = this->GetInput2(SmbNetSWEnum); _assert_(SW_input); 3834 Input2 *LHF_input = this->GetInput2(SmbMeanLHFEnum); _assert_(LHF_input); 3835 Input2 *SHF_input = this->GetInput2(SmbMeanSHFEnum); _assert_(SHF_input); 3836 Input2 *DzAdd_input = this->GetInput2(SmbDzAddEnum); _assert_(DzAdd_input); 3837 Input2 *MassAdd_input = this->GetInput2(SmbMAddEnum); _assert_(MassAdd_input); 3838 Input2 *InitMass_input = this->GetInput2(SmbMInitnum); _assert_(InitMass_input); 3854 3839 3855 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" << setprecision(3) << " Step: " << count << "\n"); 3840 ULW_input->GetInputAverage(&meanULW); 3841 LW_input->GetInputAverage(&netLW); 3842 SW_input->GetInputAverage(&netSW); 3843 LHF_input->GetInputAverage(&meanLHF); 3844 SHF_input->GetInputAverage(&meanSHF); 3845 DzAdd_input->GetInputAverage(&dz_add); 3846 MassAdd_input->GetInputAverage(&sumMassAdd); 3847 sumMassAdd=sumMassAdd*dt; 3848 InitMass_input->GetInputAverage(&initMass); 3849 sumEC_input->GetInputAverage(&sumEC); 3850 sumEC=sumEC*dt*rho_ice; 3851 sumM_input->GetInputAverage(&sumM); 3852 sumM=sumM*dt*rho_ice; 3853 sumR_input->GetInputAverage(&sumR); 3854 sumR=sumR*dt*rho_ice; 3855 sumP_input->GetInputAverage(&sumP); 3856 sumP=sumP*dt*rho_ice; 3857 } 3858 /*}}}*/ 3856 3859 3857 Input2 *Ta_input = this->GetInput2(SmbTaEnum,t-time+timeclim); _assert_(Ta_input); 3858 Input2 *V_input = this->GetInput2(SmbVEnum,t-time+timeclim); _assert_(V_input); 3859 Input2 *Dlwr_input= this->GetInput2(SmbDlwrfEnum,t-time+timeclim); _assert_(Dlwr_input); 3860 Input2 *Dswr_input= this->GetInput2(SmbDswrfEnum,t-time+timeclim); _assert_(Dswr_input); 3861 Input2 *P_input = this->GetInput2(SmbPEnum,t-time+timeclim); _assert_(P_input); 3862 Input2 *eAir_input= this->GetInput2(SmbEAirEnum,t-time+timeclim); _assert_(eAir_input); 3863 Input2 *pAir_input= this->GetInput2(SmbPAirEnum,t-time+timeclim); _assert_(pAir_input); 3860 // Get time forcing inputs 3861 Input2 *Ta_input = this->GetInput2(SmbTaEnum,timeinputs); _assert_(Ta_input); 3862 Input2 *V_input = this->GetInput2(SmbVEnum,timeinputs); _assert_(V_input); 3863 Input2 *Dlwr_input= this->GetInput2(SmbDlwrfEnum,timeinputs); _assert_(Dlwr_input); 3864 Input2 *Dswr_input= this->GetInput2(SmbDswrfEnum,timeinputs); _assert_(Dswr_input); 3865 Input2 *P_input = this->GetInput2(SmbPEnum,timeinputs); _assert_(P_input); 3866 Input2 *eAir_input= this->GetInput2(SmbEAirEnum,timeinputs); _assert_(eAir_input); 3867 Input2 *pAir_input= this->GetInput2(SmbPAirEnum,timeinputs); _assert_(pAir_input); 3868 Input2 *teValue_input= this->GetInput2(SmbTeValueEnum,timeinputs); _assert_(teValue_input); 3869 Input2 *aValue_input= this->GetInput2(SmbAValueEnum,timeinputs); _assert_(aValue_input); 3864 3870 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3871 /*extract daily data:{{{*/ 3872 Ta_input->GetInputValue(&Ta,gauss);//screen level air temperature [K] 3873 V_input->GetInputValue(&V,gauss); //wind speed [m s-1] 3874 Dlwr_input->GetInputValue(&dlw,gauss); //downward longwave radiation flux [W m-2] 3875 Dswr_input->GetInputValue(&dsw,gauss); //downward shortwave radiation flux [W m-2] 3876 P_input->GetInputValue(&P,gauss); //precipitation [kg m-2] 3877 eAir_input->GetInputValue(&eAir,gauss); //screen level vapor pressure [Pa] 3878 pAir_input->GetInputValue(&pAir,gauss); // screen level air pressure [Pa] 3879 teValue_input->GetInputValue(&teValue,gauss); // Emissivity [0-1] 3880 aValue_input->GetInputValue(&aValue,gauss); // Albedo [0 1] 3881 //_printf_("Time: " << t << " Ta: " << Ta << " V: " << V << " dlw: " << dlw << " dsw: " << dsw << " P: " << P << " eAir: " << eAir << " pAir: " << pAir << "\n"); 3882 /*}}}*/ 3877 3883 3878 3879 3884 /*Snow grain metamorphism:*/ 3885 if(isgraingrowth)grainGrowth(&re, &gdn, &gsp, T, dz, d, W, smb_dt, m, aIdx,this->Sid()); 3880 3886 3881 3882 3887 /*Snow, firn and ice albedo:*/ 3888 if(isalbedo)albedo(&a,aIdx,re,d,cldFrac,aIce,aSnow,aValue,adThresh,T,W,P,EC,t0wet,t0dry,K,smb_dt,rho_ice,m,this->Sid()); 3883 3889 3884 3885 3890 /*Distribution of absorbed short wave radation with depth:*/ 3891 if(isshortwave)shortwave(&swf, swIdx, aIdx, dsw, a[0], d, dz, re,rho_ice,m,this->Sid()); 3886 3892 3887 3888 3893 /*Calculate net shortwave [W m-2]*/ 3894 netSW = netSW + cellsum(swf,m)*smb_dt/dt; 3889 3895 3890 3891 3896 /*Thermal profile computation:*/ 3897 if(isthermal)thermo(&EC, &T, &ulw, dz, d, swf, dlw, Ta, V, eAir, pAir, teValue, W[0], smb_dt, m, Vz, Tz, thermo_scaling,rho_ice,this->Sid()); 3892 3898 3893 3894 3895 3899 /*Change in thickness of top cell due to evaporation/condensation assuming same density as top cell. 3900 * need to fix this in case all or more of cell evaporates */ 3901 dz[0] = dz[0] + EC / d[0]; 3896 3902 3897 3898 3903 /*Add snow/rain to top grid cell adjusting cell depth, temperature and density*/ 3904 if(isaccumulation)accumulation(&T, &dz, &d, &W, &a, &re, &gdn, &gsp, &m, aIdx, dsnowIdx, Tmean, Ta, P, dzMin, aSnow, C, V, Vmean, rho_ice,this->Sid()); 3899 3905 3900 3901 3902 3906 /*Calculate water production, M [kg m-2] resulting from snow/ice temperature exceeding 273.15 deg K 3907 * (> 0 deg C), runoff R [kg m-2] and resulting changes in density and determine wet compaction [m]*/ 3908 if(ismelt)melt(&M, &R, &mAdd, &dz_add, &T, &d, &dz, &W, &a, &re, &gdn, &gsp, &m, dzMin, zMax, zMin, zTop,rho_ice,this->Sid()); 3903 3909 3904 3905 3910 /*Allow non-melt densification and determine compaction [m]*/ 3911 if(isdensification)densification(&d,&dz, T, re, denIdx, C, smb_dt, Tmean,rho_ice,m,this->Sid()); 3906 3912 3907 3908 3909 3913 /*Calculate upward longwave radiation flux [W m-2] not used in energy balance. Calculated for every 3914 * sub-time step in thermo equations*/ 3915 //ulw = 5.67E-8 * pow(T[0],4.0) * teValue; // + deltatest here 3910 3916 3911 3912 3913 3917 /*Calculate net longwave [W m-2]*/ 3918 meanULW = meanULW + ulw*smb_dt/dt; 3919 netLW = netLW + (dlw - ulw)*smb_dt/dt; 3914 3920 3915 3916 3921 /*Calculate turbulent heat fluxes [W m-2]*/ 3922 if(isturbulentflux)turbulentFlux(&shf, &lhf, &dayEC, Ta, T[0], V, eAir, pAir, d[0], W[0], Vz, Tz,rho_ice,this->Sid()); 3917 3923 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3924 /*Verbose some results in debug mode: {{{*/ 3925 if(VerboseSmb() && 0){ 3926 _printf_("smb log: count[" << count << "] m[" << m << "] " 3927 << setprecision(16) << "T[" << cellsum(T,m) << "] " 3928 << "d[" << cellsum(d,m) << "] " 3929 << "dz[" << cellsum(dz,m) << "] " 3930 << "a[" << cellsum(a,m) << "] " 3931 << "W[" << cellsum(W,m) << "] " 3932 << "re[" << cellsum(re,m) << "] " 3933 << "gdn[" << cellsum(gdn,m) << "] " 3934 << "gsp[" << cellsum(gsp,m) << "] " 3935 << "swf[" << netSW << "] " 3936 << "lwf[" << netLW << "] " 3937 << "a[" << a << "] " 3938 << "te[" << teValue << "] " 3939 << "\n"); 3940 } /*}}}*/ 3935 3941 3936 3937 3942 meanLHF = meanLHF + lhf*smb_dt/dt; 3943 meanSHF = meanSHF + shf*smb_dt/dt; 3938 3944 3939 3940 3941 3942 3943 3944 3945 3945 /*Sum component mass changes [kg m-2]*/ 3946 sumMassAdd = mAdd + sumMassAdd; 3947 sumM = M + sumM; 3948 sumR = R + sumR; 3949 sumW = cellsum(W,m); 3950 sumP = P + sumP; 3951 sumEC = sumEC + EC; // evap (-)/cond(+) 3946 3952 3947 3948 3949 3950 3951 3952 3953 3953 /*Calculate total system mass:*/ 3954 sumMass=0; 3955 fac=0; 3956 for(int i=0;i<m;i++){ 3957 sumMass += dz[i]*d[i]; 3958 fac += dz[i]*(rho_ice - fmin(d[i],rho_ice)); 3959 } 3954 3960 3955 3956 3957 3958 3959 3960 3961 #if defined(_HAVE_AD_) 3962 /*we want to avoid the round operation at all cost. Not differentiable.*/ 3963 _error_("not implemented yet"); 3964 #else 3965 dMass = sumMass + sumR + sumW - sumP - sumEC - initMass - sumMassAdd; 3966 dMass = round(dMass * 100.0)/100.0; 3961 3967 3962 /*Check mass conservation:*/ 3963 if (dMass != 0.0) _printf_("total system mass not conserved in MB function \n"); 3964 #endif 3968 /*Check mass conservation:*/ 3969 if (dMass != 0.0){ 3970 _printf_("total system mass not conserved in MB function \n"); 3971 } 3972 #endif 3965 3973 3966 3967 3968 3969 3974 /*Check bottom grid cell T is unchanged:*/ 3975 if(VerboseSmb() && this->Sid()==0 && IssmComm::GetRank()==0){ 3976 if (T[m-1]!=T_bottom) _printf_("T(end)~=T_bottom" << "\n"); 3977 } 3970 3978 3971 /*Free ressources: */3972 xDelete<IssmDouble>(swf);3973 3974 /*increase counter:*/3975 count++;3976 } //for (t=time;t<time+dt;t=t+smb_dt)3977 3978 3979 /*Save generated inputs: */ 3979 3980 this->inputs2->SetArrayInput(SmbDzEnum,this->lid,dz,m); 3980 3981 this->inputs2->SetArrayInput(SmbDEnum,this->lid,d,m); … … 3994 3995 this->SetElementInput(SmbNetSWEnum,netSW); 3995 3996 this->SetElementInput(SmbMeanLHFEnum,meanLHF); 3996 3997 this->SetElementInput(SmbMeanSHFEnum,meanSHF); 3997 this->SetElementInput(SmbDzAddEnum,sumdz_add); 3998 this->SetElementInput(SmbDzAddEnum,dz_add); 3999 this->SetElementInput(SmbMInitnum,initMass); 3998 4000 this->SetElementInput(SmbMAddEnum,sumMassAdd/dt); 4001 this->SetElementInput(SmbWAddEnum,sumW/dt); 3999 4002 this->SetElementInput(SmbFACEnum,fac/1000.); // output in meters 4003 this->SetElementInput(SmbECDtEnum,EC); 4000 4004 4001 4005 /*Free allocations:{{{*/ 4002 4006 if(dz) xDelete<IssmDouble>(dz); … … 4015 4019 if(Wini) xDelete<IssmDouble>(Wini); 4016 4020 if(aini) xDelete<IssmDouble>(aini); 4017 4021 if(Tini) xDelete<IssmDouble>(Tini); 4022 if(swf) xDelete<IssmDouble>(swf); 4018 4023 4019 4024 delete gauss; 4020 4025 /*}}}*/
Note:
See TracBrowser
for help on using the repository browser.