source:
issm/oecreview/Archive/23185-23389/ISSM-23241-23242.diff@
23390
Last change on this file since 23390 was 23390, checked in by , 6 years ago | |
---|---|
File size: 28.5 KB |
-
../trunk-jpl/src/c/classes/ExternalResults/GenericExternalResult.h
621 621 } /*}}}*/ 622 622 623 623 /*Specific instantiations for IssmDouble*: */ 624 #if defined(_HAVE_AD OLC_) && !defined(_WRAPPERS_) //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization.624 #if defined(_HAVE_AD_) && !defined(_WRAPPERS_) //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization. 625 625 template <> inline GenericExternalResult<IssmDouble*>::~GenericExternalResult(){ /*{{{*/ 626 626 xDelete<char>(result_name); 627 627 xDelete<IssmDouble>(value); … … 708 708 template <> inline Object* GenericExternalResult<Vector<IssmPDouble>*>::copy(void){ /*{{{*/ 709 709 return new GenericExternalResult<Vector<IssmPDouble>*>(this->id,StringToEnumx(this->result_name),this->value,this->step,this->time); 710 710 } /*}}}*/ 711 #if defined(_HAVE_AD OLC_) && !defined(_WRAPPERS_) //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization.711 #if defined(_HAVE_AD_) && !defined(_WRAPPERS_) //We hook off this specific specialization when not running ADOLC, otherwise we get a redeclaration with the next specialization. 712 712 template <> inline void GenericExternalResult<Vector<IssmPDouble>*>::WriteData(FILE* fid,bool io_gather){ /*{{{*/ 713 713 714 714 char *name = NULL; -
../trunk-jpl/src/c/classes/FemModel.cpp
880 880 results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentMemEnum, solution_memory)); 881 881 results->AddObject(new GenericExternalResult<IssmDouble>(results->Size()+1, ProfilingCurrentFlopsEnum, solution_flops)); 882 882 883 #ifdef _HAVE_AD OLC_883 #ifdef _HAVE_AD_ 884 884 solution_time = profiler->TotalTime(ADCORE); 885 885 solution_flops = profiler->TotalFlops(ADCORE); 886 886 solution_memory = profiler->Memory(ADCORE); … … 1844 1844 parameters->FindParam(&isautodiff,AutodiffIsautodiffEnum); 1845 1845 1846 1846 if(isautodiff){ 1847 #ifdef _HAVE_AD OLC_1847 #ifdef _HAVE_AD_ 1848 1848 parameters->FindParam(&num_dependents,AutodiffNumDependentsEnum); 1849 1849 parameters->FindParam(&dependent_objects,AutodiffDependentObjectsEnum); 1850 1850 if(num_dependents){ -
../trunk-jpl/src/c/classes/Elements/Element.cpp
3132 3132 fac += dz[i]*(rho_ice - fmin(d[i],rho_ice)); 3133 3133 } 3134 3134 3135 #ifndef _HAVE_ADOLC_ //we want to avoid the round operation at all cost. Not differentiable. 3135 #if defined(_HAVE_AD_) 3136 /*we want to avoid the round operation at all cost. Not differentiable.*/ 3137 _error_("not implemented yet"); 3138 #else 3136 3139 dMass = sumMass + sumR + sumW - sumP - sumEC - initMass - sumMassAdd; 3137 3140 dMass = round(dMass * 100.0)/100.0; 3138 3141 -
../trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
52 52 AutodiffNumDependentsEnum, 53 53 AutodiffNumIndependentsEnum, 54 54 AutodiffObufsizeEnum, 55 AutodiffTapeAllocEnum, 55 56 AutodiffTbufsizeEnum, 56 57 AutodiffXpEnum, 57 58 BalancethicknessStabilizationEnum, -
../trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
60 60 case AutodiffNumDependentsEnum : return "AutodiffNumDependents"; 61 61 case AutodiffNumIndependentsEnum : return "AutodiffNumIndependents"; 62 62 case AutodiffObufsizeEnum : return "AutodiffObufsize"; 63 case AutodiffTapeAllocEnum : return "AutodiffTapeAlloc"; 63 64 case AutodiffTbufsizeEnum : return "AutodiffTbufsize"; 64 65 case AutodiffXpEnum : return "AutodiffXp"; 65 66 case BalancethicknessStabilizationEnum : return "BalancethicknessStabilization"; -
../trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
60 60 else if (strcmp(name,"AutodiffNumDependents")==0) return AutodiffNumDependentsEnum; 61 61 else if (strcmp(name,"AutodiffNumIndependents")==0) return AutodiffNumIndependentsEnum; 62 62 else if (strcmp(name,"AutodiffObufsize")==0) return AutodiffObufsizeEnum; 63 else if (strcmp(name,"AutodiffTapeAlloc")==0) return AutodiffTapeAllocEnum; 63 64 else if (strcmp(name,"AutodiffTbufsize")==0) return AutodiffTbufsizeEnum; 64 65 else if (strcmp(name,"AutodiffXp")==0) return AutodiffXpEnum; 65 66 else if (strcmp(name,"BalancethicknessStabilization")==0) return BalancethicknessStabilizationEnum; … … 135 136 else if (strcmp(name,"FrictionGamma")==0) return FrictionGammaEnum; 136 137 else if (strcmp(name,"FrictionLaw")==0) return FrictionLawEnum; 137 138 else if (strcmp(name,"FrictionPseudoplasticityExponent")==0) return FrictionPseudoplasticityExponentEnum; 138 else if (strcmp(name,"FrictionThresholdSpeed")==0) return FrictionThresholdSpeedEnum;139 139 else stage=2; 140 140 } 141 141 if(stage==2){ 142 if (strcmp(name,"FrictionDelta")==0) return FrictionDeltaEnum; 142 if (strcmp(name,"FrictionThresholdSpeed")==0) return FrictionThresholdSpeedEnum; 143 else if (strcmp(name,"FrictionDelta")==0) return FrictionDeltaEnum; 143 144 else if (strcmp(name,"FrictionVoidRatio")==0) return FrictionVoidRatioEnum; 144 145 else if (strcmp(name,"GiaCrossSectionShape")==0) return GiaCrossSectionShapeEnum; 145 146 else if (strcmp(name,"GroundinglineMigration")==0) return GroundinglineMigrationEnum; … … 258 259 else if (strcmp(name,"SealevelriseEquatorialMoi")==0) return SealevelriseEquatorialMoiEnum; 259 260 else if (strcmp(name,"SealevelriseFluidLove")==0) return SealevelriseFluidLoveEnum; 260 261 else if (strcmp(name,"SealevelriseGElastic")==0) return SealevelriseGElasticEnum; 261 else if (strcmp(name,"SealevelriseGeodetic")==0) return SealevelriseGeodeticEnum;262 262 else stage=3; 263 263 } 264 264 if(stage==3){ 265 if (strcmp(name,"SealevelriseGeodeticRunFrequency")==0) return SealevelriseGeodeticRunFrequencyEnum; 265 if (strcmp(name,"SealevelriseGeodetic")==0) return SealevelriseGeodeticEnum; 266 else if (strcmp(name,"SealevelriseGeodeticRunFrequency")==0) return SealevelriseGeodeticRunFrequencyEnum; 266 267 else if (strcmp(name,"SealevelriseHElastic")==0) return SealevelriseHElasticEnum; 267 268 else if (strcmp(name,"SealevelriseHoriz")==0) return SealevelriseHorizEnum; 268 269 else if (strcmp(name,"SealevelriseLoopIncrement")==0) return SealevelriseLoopIncrementEnum; … … 381 382 else if (strcmp(name,"TransientNumRequestedOutputs")==0) return TransientNumRequestedOutputsEnum; 382 383 else if (strcmp(name,"TransientRequestedOutputs")==0) return TransientRequestedOutputsEnum; 383 384 else if (strcmp(name,"Velocity")==0) return VelocityEnum; 384 else if (strcmp(name,"WorldComm")==0) return WorldCommEnum;385 385 else stage=4; 386 386 } 387 387 if(stage==4){ 388 if (strcmp(name,"ParametersEND")==0) return ParametersENDEnum; 388 if (strcmp(name,"WorldComm")==0) return WorldCommEnum; 389 else if (strcmp(name,"ParametersEND")==0) return ParametersENDEnum; 389 390 else if (strcmp(name,"InputsSTART")==0) return InputsSTARTEnum; 390 391 else if (strcmp(name,"Adjoint")==0) return AdjointEnum; 391 392 else if (strcmp(name,"Adjointx")==0) return AdjointxEnum; … … 504 505 else if (strcmp(name,"InversionVelObs")==0) return InversionVelObsEnum; 505 506 else if (strcmp(name,"InversionVxObs")==0) return InversionVxObsEnum; 506 507 else if (strcmp(name,"InversionVyObs")==0) return InversionVyObsEnum; 507 else if (strcmp(name,"LevelsetfunctionSlopeX")==0) return LevelsetfunctionSlopeXEnum;508 508 else stage=5; 509 509 } 510 510 if(stage==5){ 511 if (strcmp(name,"LevelsetfunctionSlopeY")==0) return LevelsetfunctionSlopeYEnum; 511 if (strcmp(name,"LevelsetfunctionSlopeX")==0) return LevelsetfunctionSlopeXEnum; 512 else if (strcmp(name,"LevelsetfunctionSlopeY")==0) return LevelsetfunctionSlopeYEnum; 512 513 else if (strcmp(name,"LoadingforceX")==0) return LoadingforceXEnum; 513 514 else if (strcmp(name,"LoadingforceY")==0) return LoadingforceYEnum; 514 515 else if (strcmp(name,"LoadingforceZ")==0) return LoadingforceZEnum; … … 627 628 else if (strcmp(name,"StrainRateperpendicular")==0) return StrainRateperpendicularEnum; 628 629 else if (strcmp(name,"StrainRatexx")==0) return StrainRatexxEnum; 629 630 else if (strcmp(name,"StrainRatexy")==0) return StrainRatexyEnum; 630 else if (strcmp(name,"StrainRatexz")==0) return StrainRatexzEnum;631 631 else stage=6; 632 632 } 633 633 if(stage==6){ 634 if (strcmp(name,"StrainRateyy")==0) return StrainRateyyEnum; 634 if (strcmp(name,"StrainRatexz")==0) return StrainRatexzEnum; 635 else if (strcmp(name,"StrainRateyy")==0) return StrainRateyyEnum; 635 636 else if (strcmp(name,"StrainRateyz")==0) return StrainRateyzEnum; 636 637 else if (strcmp(name,"StrainRatezz")==0) return StrainRatezzEnum; 637 638 else if (strcmp(name,"StressMaxPrincipal")==0) return StressMaxPrincipalEnum; … … 750 751 else if (strcmp(name,"DeviatoricStressErrorEstimator")==0) return DeviatoricStressErrorEstimatorEnum; 751 752 else if (strcmp(name,"Divergence")==0) return DivergenceEnum; 752 753 else if (strcmp(name,"Domain3Dsurface")==0) return Domain3DsurfaceEnum; 753 else if (strcmp(name,"DoubleArrayInput")==0) return DoubleArrayInputEnum;754 754 else stage=7; 755 755 } 756 756 if(stage==7){ 757 if (strcmp(name,"DoubleExternalResult")==0) return DoubleExternalResultEnum; 757 if (strcmp(name,"DoubleArrayInput")==0) return DoubleArrayInputEnum; 758 else if (strcmp(name,"DoubleExternalResult")==0) return DoubleExternalResultEnum; 758 759 else if (strcmp(name,"DoubleInput")==0) return DoubleInputEnum; 759 760 else if (strcmp(name,"DoubleMatArrayParam")==0) return DoubleMatArrayParamEnum; 760 761 else if (strcmp(name,"DoubleMatExternalResult")==0) return DoubleMatExternalResultEnum; … … 873 874 else if (strcmp(name,"LoveHi")==0) return LoveHiEnum; 874 875 else if (strcmp(name,"LoveHr")==0) return LoveHrEnum; 875 876 else if (strcmp(name,"LoveKernelsImag")==0) return LoveKernelsImagEnum; 876 else if (strcmp(name,"LoveKernelsReal")==0) return LoveKernelsRealEnum;877 877 else stage=8; 878 878 } 879 879 if(stage==8){ 880 if (strcmp(name,"LoveKi")==0) return LoveKiEnum; 880 if (strcmp(name,"LoveKernelsReal")==0) return LoveKernelsRealEnum; 881 else if (strcmp(name,"LoveKi")==0) return LoveKiEnum; 881 882 else if (strcmp(name,"LoveKr")==0) return LoveKrEnum; 882 883 else if (strcmp(name,"LoveLi")==0) return LoveLiEnum; 883 884 else if (strcmp(name,"LoveLr")==0) return LoveLrEnum; … … 996 997 else if (strcmp(name,"Outputdefinition45")==0) return Outputdefinition45Enum; 997 998 else if (strcmp(name,"Outputdefinition46")==0) return Outputdefinition46Enum; 998 999 else if (strcmp(name,"Outputdefinition47")==0) return Outputdefinition47Enum; 999 else if (strcmp(name,"Outputdefinition48")==0) return Outputdefinition48Enum;1000 1000 else stage=9; 1001 1001 } 1002 1002 if(stage==9){ 1003 if (strcmp(name,"Outputdefinition49")==0) return Outputdefinition49Enum; 1003 if (strcmp(name,"Outputdefinition48")==0) return Outputdefinition48Enum; 1004 else if (strcmp(name,"Outputdefinition49")==0) return Outputdefinition49Enum; 1004 1005 else if (strcmp(name,"Outputdefinition4")==0) return Outputdefinition4Enum; 1005 1006 else if (strcmp(name,"Outputdefinition50")==0) return Outputdefinition50Enum; 1006 1007 else if (strcmp(name,"Outputdefinition51")==0) return Outputdefinition51Enum; … … 1119 1120 else if (strcmp(name,"SMBgradientsela")==0) return SMBgradientselaEnum; 1120 1121 else if (strcmp(name,"SMBgradients")==0) return SMBgradientsEnum; 1121 1122 else if (strcmp(name,"SMBhenning")==0) return SMBhenningEnum; 1122 else if (strcmp(name,"SmbMAdd")==0) return SmbMAddEnum;1123 1123 else stage=10; 1124 1124 } 1125 1125 if(stage==10){ 1126 if (strcmp(name,"SMBmeltcomponents")==0) return SMBmeltcomponentsEnum; 1126 if (strcmp(name,"SmbMAdd")==0) return SmbMAddEnum; 1127 else if (strcmp(name,"SMBmeltcomponents")==0) return SMBmeltcomponentsEnum; 1127 1128 else if (strcmp(name,"SMBpdd")==0) return SMBpddEnum; 1128 1129 else if (strcmp(name,"SmbRlaps")==0) return SmbRlapsEnum; 1129 1130 else if (strcmp(name,"SmbRlapslgm")==0) return SmbRlapslgmEnum; -
../trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp
373 373 /*Now, deal with toolkits options, which need to be put into the parameters dataset: */ 374 374 ParseToolkitsOptionsx(parameters,toolkitsoptionsfid); 375 375 376 #ifdef _HAVE_AD OLC_376 #ifdef _HAVE_AD_ 377 377 if(VerboseMProcessor()) _printf0_(" starting autodiff parameters \n"); 378 378 CreateParametersAutodiff(parameters,iomodel); 379 379 if(VerboseMProcessor()) _printf0_(" ending autodiff parameters \n"); -
../trunk-jpl/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp
72 72 /*Free ressources: */ 73 73 xDelete<char>(options); 74 74 /*}}}*/ 75 #elif _HAVE_CODIPACK_ 76 //fprintf(stderr, "*** Codipack CreateParametersAutodiff()\n"); 77 /*initialize a placeholder to store solver pointers: {{{*/ 78 /*Solver pointers depend on what type of solver we are implementing: */ 79 options=OptionsFromAnalysis(parameters,DefaultAnalysisEnum); //options database is not filled in yet, use default. 80 ToolkitOptions::Init(options); 75 81 82 switch(IssmSolverTypeFromToolkitOptions()){ 83 case MumpsEnum:{ 84 #ifndef _HAVE_MUMPS_ 85 _error_("CoDiPack: requesting mumps solver without MUMPS being compiled in!"); 86 #endif 87 break; 88 } 89 case GslEnum: { 90 #ifndef _HAVE_GSL_ 91 _error_("CoDiPack: requesting GSL solver without GSL being compiled in!"); 92 #endif 93 break; 94 } 95 default: 96 _error_("solver type not supported yet!"); 97 } 98 /*Free ressources: */ 99 xDelete<char>(options); 100 #endif 101 #if defined(_HAVE_AD_) 102 76 103 if(isautodiff){ 104 #if _HAVE_ADOLC_ 77 105 /*Copy some parameters from IoModel to parameters dataset: {{{*/ 78 106 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.obufsize",AutodiffObufsizeEnum)); 79 107 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.cbufsize",AutodiffCbufsizeEnum)); … … 82 110 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.gcTriggerRatio",AutodiffGcTriggerRatioEnum)); 83 111 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.gcTriggerMaxSize",AutodiffGcTriggerMaxSizeEnum)); 84 112 /*}}}*/ 113 #endif 85 114 /*retrieve driver: {{{*/ 86 115 iomodel->FindConstant(&autodiff_driver,"md.autodiff.driver"); 87 116 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.driver",AutodiffDriverEnum)); 88 117 89 118 if(strcmp(autodiff_driver,"fos_forward")==0){ 119 #if _HAVE_CODIPACK_ 120 // FIXME codi support Foward Mode (scalar) 121 _error_("Foward Mode (scalar) not supported yet!"); 122 #endif 90 123 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.fos_forward_index",AutodiffFosForwardIndexEnum)); 91 124 } 92 125 else if(strcmp(autodiff_driver,"fos_reverse")==0){ … … 93 126 parameters->AddObject(iomodel->CopyConstantObject("md.autodiff.fos_reverse_index",AutodiffFosReverseIndexEnum)); 94 127 } 95 128 else if(strcmp(autodiff_driver,"fov_forward")==0){ 129 #if _HAVE_CODIPACK_ 130 // FIXME codi support Foward Mode (vector) 131 _error_("Foward Mode (vector) not supported yet!"); 132 #endif 96 133 /*Retrieve list of indices: */ 97 134 iomodel->FetchData(&indices,&num_indices,&dummy,"md.autodiff.fov_forward_indices"); 98 135 parameters->AddObject(new IntMatParam(AutodiffFovForwardIndicesEnum,indices,num_indices,1)); -
../trunk-jpl/src/c/modules/SurfaceMassBalancex/Gembx.cpp
61 61 //check to see if the top grid cell structure length (dzTop) goes evenly 62 62 //into specified top structure depth (zTop). Also make sure top grid cell 63 63 //structure length (dzTop) is greater than 5 cm 64 #ifndef _HAVE_AD OLC_ //avoid the round operation check!64 #ifndef _HAVE_AD_ //avoid the round operation check! 65 65 if (dgpTop != round(dgpTop)){ 66 66 _error_("top grid cell structure length does not go evenly into specified top structure depth, adjust dzTop or zTop"); 67 67 } … … 424 424 425 425 // spectral range: 426 426 // 0.3 - 0.8um 427 IssmDouble a0 = fmin(0.98, 1 - 1.58 *pow(gsz,0.5));427 IssmDouble a0 = min(0.98, 1 - 1.58 *pow(gsz,0.5)); 428 428 // 0.8 - 1.5um 429 IssmDouble a1 = fmax(0, 0.95 - 15.4 *pow(gsz,0.5));429 IssmDouble a1 = max(0, 0.95 - 15.4 *pow(gsz,0.5)); 430 430 // 1.5 - 2.8um 431 IssmDouble a2 = fmax(0.127, 0.88 + 346.3*gsz - 32.31*pow(gsz,0.5));431 IssmDouble a2 = max(0.127, 0.88 + 346.3*gsz - 32.31*pow(gsz,0.5)); 432 432 433 433 // broadband surface albedo 434 434 a[0] = sF[0]*a0 + sF[1]*a1 + sF[2]*a2; … … 666 666 // determine minimum acceptable delta t (diffusion number > 1/2) [s] 667 667 // NS: 2.16.18 divided dt by scaling factor, default set to 1/11 for stability 668 668 dt=1e12; 669 for(int i=0;i<m;i++)dt = fmin(dt,CI * pow(dz[i],2) * d[i] / (3 * K[i]) * thermo_scaling);669 for(int i=0;i<m;i++)dt = min(dt,CI * pow(dz[i],2) * d[i] / (3 * K[i]) * thermo_scaling); 670 670 671 671 // smallest possible even integer of 60 min where diffusion number > 1/2 672 672 // must go evenly into one hour or the data frequency if it is smaller … … 751 751 // calculated. The estimated enegy balance & melt are significanly 752 752 // less when Ts is taken as the mean of the x top grid cells. 753 753 Ts = (T[0] + T[1])/2.0; 754 Ts = fmin(CtoK,Ts); // don't allow Ts to exceed 273.15 K (0 degC)754 Ts = min(CtoK,Ts); // don't allow Ts to exceed 273.15 K (0 degC) 755 755 756 756 //TURBULENT HEAT FLUX 757 757 … … 766 766 // calculate Monin-Obukhov stability factors 'coefM' and 'coefH' 767 767 768 768 // do not allow Ri to exceed 0.19 769 Ri = fmin(Ri, 0.19);769 Ri = min(Ri, 0.19); 770 770 771 771 // calculate momentum 'coefM' stability factor 772 772 if (Ri > 0.0+Ttol){ … … 946 946 947 947 // spectral albedos: 948 948 // 0.3 - 0.8um 949 IssmDouble a0 = fmin(0.98, 1.0 - 1.58 *pow(gsz[0],0.5));949 IssmDouble a0 = min(0.98, 1.0 - 1.58 *pow(gsz[0],0.5)); 950 950 // 0.8 - 1.5um 951 IssmDouble a1 = fmax(0.0, 0.95 - 15.4 *pow(gsz[0],0.5));951 IssmDouble a1 = max(0.0, 0.95 - 15.4 *pow(gsz[0],0.5)); 952 952 // 1.5 - 2.8um 953 IssmDouble a2 = fmax(0.127, 0.88 + 346.3*gsz[0] - 32.31*pow(gsz[0],0.5));953 IssmDouble a2 = max(0.127, 0.88 + 346.3*gsz[0] - 32.31*pow(gsz[0],0.5)); 954 954 955 955 // separate net shortwave radiative flux into spectral ranges 956 956 IssmDouble swfS[3]; … … 1203 1203 1204 1204 mass_diff = mass - massinit - P; 1205 1205 1206 #ifndef _HAVE_AD OLC_ //avoid round operation. only check in forward mode.1206 #ifndef _HAVE_AD_ //avoid round operation. only check in forward mode. 1207 1207 mass_diff = round(mass_diff * 100.0)/100.0; 1208 1208 if (mass_diff > 0) _error_("mass not conserved in accumulation function"); 1209 1209 #endif … … 1322 1322 1323 1323 // calculate temperature excess above 0 deg C 1324 1324 exsT=xNewZeroInit<IssmDouble>(n); 1325 for(int i=0;i<n;i++) exsT[i]= fmax(0.0, T[i] - CtoK); // [K] to [degC]1325 for(int i=0;i<n;i++) exsT[i]= max(0.0, T[i] - CtoK); // [K] to [degC] 1326 1326 1327 1327 // new grid point center temperature, T [K] 1328 1328 // for(int i=0;i<n;i++) T[i]-=exsT[i]; 1329 for(int i=0;i<n;i++) T[i]= fmin(T[i],CtoK);1329 for(int i=0;i<n;i++) T[i]=min(T[i],CtoK); 1330 1330 1331 1331 // specify irreducible water content saturation [fraction] 1332 1332 const IssmDouble Swi = 0.07; // assumed constant after Colbeck, 1974 … … 1336 1336 if (cellsum(W,n) >0.0+Wtol){ 1337 1337 if(VerboseSmb() && sid==0 && IssmComm::GetRank()==0)_printf0_(" pore water refreeze\n"); 1338 1338 // calculate maximum freeze amount, maxF [kg] 1339 for(int i=0;i<n;i++) maxF[i] = fmax(0.0, -((T[i] - CtoK) * m[i] * CI) / LF);1339 for(int i=0;i<n;i++) maxF[i] = max(0.0, -((T[i] - CtoK) * m[i] * CI) / LF); 1340 1340 1341 1341 // freeze pore water and change snow/ice properties 1342 for(int i=0;i<n;i++) dW[i] = fmin(maxF[i], W[i]); // freeze mass [kg]1342 for(int i=0;i<n;i++) dW[i] = min(maxF[i], W[i]); // freeze mass [kg] 1343 1343 for(int i=0;i<n;i++) W[i] -= dW[i]; // pore water mass [kg] 1344 1344 for(int i=0;i<n;i++) m[i] += dW[i]; // new mass [kg] 1345 1345 for(int i=0;i<n;i++) d[i] = m[i] / dz[i]; // density [kg m-3] … … 1355 1355 exsW=xNew<IssmDouble>(n); 1356 1356 for(int i=0;i<n;i++){ 1357 1357 Wi= (dIce - d[i]) * Swi * (m[i] / d[i]); // irreducible water content [kg] 1358 exsW[i] = fmax(0.0, W[i] - Wi); // water "squeezed" from snow [kg]1358 exsW[i] = max(0.0, W[i] - Wi); // water "squeezed" from snow [kg] 1359 1359 } 1360 1360 1361 1361 //// MELT, PERCOLATION AND REFREEZE … … 1367 1367 // if so redistribute temperature to lower cells (temperature surplus) 1368 1368 // (maximum T of snow before entire grid cell melts is a constant 1369 1369 // LF/CI = 159.1342) 1370 surpT=xNew<IssmDouble>(n); for(int i=0;i<n;i++)surpT[i] = fmax(0.0, exsT[i]- LF/CI);1370 surpT=xNew<IssmDouble>(n); for(int i=0;i<n;i++)surpT[i] = max(0.0, exsT[i]- LF/CI); 1371 1371 1372 1372 if (cellsum(surpT,n) > 0.0 + Ttol ){ 1373 1373 // _printf_("T Surplus"); … … 1379 1379 // use surplus energy to increase the temperature of lower cell 1380 1380 T[i+1] = surpE[i]/m[i+1]/CI + T[i+1]; 1381 1381 1382 exsT[i+1] = fmax(0.0, T[i+1] - CtoK) + exsT[i+1];1383 T[i+1] = fmin(CtoK, T[i+1]);1382 exsT[i+1] = max(0.0, T[i+1] - CtoK) + exsT[i+1]; 1383 T[i+1] = min(CtoK, T[i+1]); 1384 1384 1385 surpT[i+1] = fmax(0.0, exsT[i+1] - LF/CI);1385 surpT[i+1] = max(0.0, exsT[i+1] - LF/CI); 1386 1386 surpE[i+1] = surpT[i+1] * CI * m[i+1]; 1387 1387 1388 1388 // adjust current cell properties (again 159.1342 is the max T) … … 1393 1393 } 1394 1394 1395 1395 // convert temperature excess to melt [kg] 1396 for(int i=0;i<n;i++) M[i] = fmin(exsT[i] * d[i] * dz[i] * CI / LF, m[i]); // melt1396 for(int i=0;i<n;i++) M[i] = min(exsT[i] * d[i] * dz[i] * CI / LF, m[i]); // melt 1397 1397 sumM = cellsum(M,n); // total melt [kg] 1398 1398 1399 1399 // calculate maximum refreeze amount, maxF [kg] 1400 for(int i=0;i<n;i++)maxF[i] = fmax(0.0, -((T[i] - CtoK) * d[i] * dz[i] * CI)/ LF);1400 for(int i=0;i<n;i++)maxF[i] = max(0.0, -((T[i] - CtoK) * d[i] * dz[i] * CI)/ LF); 1401 1401 1402 1402 // initialize refreeze, runoff, flxDn and dW vectors [kg] 1403 1403 IssmDouble* F = xNewZeroInit<IssmDouble>(n); … … 1434 1434 1435 1435 m[i] = m[i] - M[i]; // mass after melt 1436 1436 Wi = (dIce-d[i]) * Swi * (m[i]/d[i]); // irreducible water 1437 dW[i] = fmax(fmin(inM, Wi - W[i]),-1*W[i]); // change in pore water1438 R[i] = fmax(0.0, inM - dW[i]); // runoff1437 dW[i] = max(min(inM, Wi - W[i]),-1*W[i]); // change in pore water 1438 R[i] = max(0.0, inM - dW[i]); // runoff 1439 1439 F[i] = 0.0; 1440 1440 } 1441 1441 // check if no energy to refreeze meltwater … … 1446 1446 1447 1447 m[i] = m[i] - M[i]; // mass after melt 1448 1448 Wi = (dIce-d[i]) * Swi * (m[i]/d[i]); // irreducible water 1449 dW[i] = fmax(fmin(inM, Wi - W[i]),-1*W[i]); // change in pore water1450 flxDn[i+1] = fmax(0.0, inM - dW[i]); // meltwater out1449 dW[i] = max(min(inM, Wi - W[i]),-1*W[i]); // change in pore water 1450 flxDn[i+1] = max(0.0, inM - dW[i]); // meltwater out 1451 1451 R[i] = 0.0; 1452 1452 F[i] = 0.0; // no freeze 1453 1453 } … … 1459 1459 m[i] = m[i] - M[i]; 1460 1460 IssmDouble dz_0 = m[i]/d[i]; 1461 1461 IssmDouble dMax = (dIce - d[i])*dz_0; // d max = dIce 1462 IssmDouble F1 = fmin(fmin(inM,dMax),maxF[i]); // maximum refreeze1462 IssmDouble F1 = min(min(inM,dMax),maxF[i]); // maximum refreeze 1463 1463 m[i] = m[i] + F1; // mass after refreeze 1464 1464 d[i] = m[i]/dz_0; 1465 1465 1466 1466 //-----------------------pore water----------------------------- 1467 1467 Wi = (dIce-d[i])* Swi * dz_0; // irreducible water 1468 dW[i] = fmin(inM - F1, Wi-W[i]); // change in pore water1468 dW[i] = min(inM - F1, Wi-W[i]); // change in pore water 1469 1469 if (dW[i] < 0.0-Wtol && -1*dW[i]>W[i]-Wtol ){ 1470 1470 dW[i]= -1*W[i]; 1471 1471 } … … 1473 1473 1474 1474 if (dW[i] < 0.0-Wtol){ // excess pore water 1475 1475 dMax = (dIce - d[i])*dz_0; // maximum refreeze 1476 IssmDouble maxF2 = fmin(dMax, maxF[i]-F1); // maximum refreeze1477 F2 = fmin(-1*dW[i], maxF2); // pore water refreeze1476 IssmDouble maxF2 = min(dMax, maxF[i]-F1); // maximum refreeze 1477 F2 = min(-1*dW[i], maxF2); // pore water refreeze 1478 1478 m[i] = m[i] + F2; // mass after refreeze 1479 1479 d[i] = m[i]/dz_0; 1480 1480 dW[i] = dW[i] - F2; … … 1752 1752 for(int i=0;i<n;i++) if (W[i]<0.0-Wtol) _error_("negative pore water generated in melt equations\n"); 1753 1753 1754 1754 /*only in forward mode! avoid round in AD mode as it is not differentiable: */ 1755 #ifndef _HAVE_AD OLC_1755 #ifndef _HAVE_AD_ 1756 1756 dm = round((mSum0 - mSum1 + mAdd)*100.0)/100.0; 1757 1757 dE = round(sumE0 - sumE1 - sumER + addE); 1758 1758 if (dm !=0 || dE !=0) _error_("mass or energy are not conserved in melt equations\n" … … 1914 1914 H = exp((-60000.0/(Tmean * R)) + (42400.0/(Tmean * R))) * (C * 9.81); 1915 1915 c0arth = 0.07 * H; 1916 1916 c1arth = 0.03 * H; 1917 M0 = fmax(1.435 - (0.151 * log(C)),0.25);1918 M1 = fmax(2.366 - (0.293 * log(C)),0.25);1917 M0 = max(1.435 - (0.151 * log(C)),0.25); 1918 M1 = max(2.366 - (0.293 * log(C)),0.25); 1919 1919 c0 = M0*c0arth; 1920 1920 c1 = M1*c1arth; 1921 1921 break; … … 1925 1925 H = exp((-60000.0/(T[i] * R)) + (42400.0/(T[i] * R))) * (C * 9.81); 1926 1926 c0arth = 0.07 * H; 1927 1927 c1arth = 0.03 * H; 1928 M0 = fmax(1.042 - (0.0916 * log(C)),0.25);1929 M1 = fmax(1.734 - (0.2039 * log(C)),0.25);1928 M0 = max(1.042 - (0.0916 * log(C)),0.25); 1929 M1 = max(1.734 - (0.2039 * log(C)),0.25); 1930 1930 c0 = M0*c0arth; 1931 1931 c1 = M1*c1arth; 1932 1932 break; … … 2020 2020 // calculate Monin-Obukhov stability factors 'coef_M' and 'coef_H' 2021 2021 2022 2022 // do not allow Ri to exceed 0.19 2023 Ri = fmin(Ri, 0.19);2023 Ri = min(Ri, 0.19); 2024 2024 2025 2025 // calculate momentum 'coefM' stability factor 2026 2026 if (Ri > 0.0+Ttol){ -
../trunk-jpl/src/c/cores/controlvalidation_core.cpp
87 87 } 88 88 89 89 /*output*/ 90 #ifdef _HAVE_AD OLC_90 #ifdef _HAVE_AD_ 91 91 IssmPDouble* J_passive=xNew<IssmPDouble>(2*num); 92 92 for(int i=0;i<2*num;i++) J_passive[i]=reCast<IssmPDouble>(output[i]); 93 93 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,J_passive,num,2,0,0)); -
../trunk-jpl/src/c/cores/control_core.cpp
96 96 if(!dakota_analysis){ //do not save this if we are running the control core from a qmu run! 97 97 femmodel->OutputControlsx(&femmodel->results); 98 98 99 #ifdef _HAVE_AD OLC_99 #ifdef _HAVE_AD_ 100 100 IssmPDouble* J_passive=xNew<IssmPDouble>(nsteps); 101 101 for(int i=0;i<nsteps;i++) J_passive[i]=reCast<IssmPDouble>(J[i]); 102 102 femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,J_passive,nsteps,1,0,0));
Note:
See TracBrowser
for help on using the repository browser.