Changeset 22628
- Timestamp:
- 03/26/18 11:06:37 (7 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r22625 r22628 2777 2777 } 2778 2778 /*}}}*/ 2779 void Tria::PicoUpdateBoxid(int* pmax_boxid_basin){/*{{{*/2779 void Tria::PicoUpdateBoxid(int* max_boxid_basin_list){/*{{{*/ 2780 2780 2781 2781 if(!this->IsIceInElement() || !this->IsFloating()) return; 2782 2782 2783 int i,boxid,basin_id,boxid_max;2784 IssmDouble dist_gl,dist_cf ,rel_dist_gl,lowbound,highbound;2783 int basin_id; 2784 IssmDouble dist_gl,dist_cf; 2785 2785 2786 2786 inputs->GetInputValue(&basin_id,BasalforcingsPicoBasinIdEnum); 2787 boxid_max=pmax_boxid_basin[basin_id];2787 IssmDouble boxid_max=reCast<IssmDouble>(max_boxid_basin_list[basin_id]); 2788 2788 2789 2789 Input* dist_gl_input=inputs->GetInput(DistanceToGroundinglineEnum); _assert_(dist_gl_input); 2790 Input* dist_cf_input=inputs->GetInput(DistanceToCalvingfrontEnum); _assert_(dist_cf_input);2790 Input* dist_cf_input=inputs->GetInput(DistanceToCalvingfrontEnum); _assert_(dist_cf_input); 2791 2791 2792 2792 /*Get dist_gl and dist_cf at center of element*/ … … 2794 2794 dist_gl_input->GetInputValue(&dist_gl,gauss); 2795 2795 dist_cf_input->GetInputValue(&dist_cf,gauss); 2796 delete gauss; 2796 2797 2797 2798 /*Ensure values are positive for floating ice*/ 2798 if(dist_gl<0){dist_gl=dist_gl*(-1);}2799 if(dist_cf<0){dist_cf=dist_cf*(-1);}2799 dist_gl = fabs(dist_gl); 2800 dist_cf = fabs(dist_cf); 2800 2801 2801 2802 /*Compute relative distance to grounding line*/ 2802 rel_dist_gl=dist_gl/(dist_gl+dist_cf);2803 IssmDouble rel_dist_gl=dist_gl/(dist_gl+dist_cf); 2803 2804 2804 2805 /*Assign box numbers based on rel_dist_gl*/ 2805 boxid=-1;2806 for( i=0;i<boxid_max;i++){2807 lowbound = 1-sqrt((boxid_max-i-0.0)/boxid_max);2808 highbound = 1-sqrt((boxid_max-i-1.0)/boxid_max);2806 int boxid = -1; 2807 for(IssmDouble i=0.;i<boxid_max;i++){ 2808 IssmDouble lowbound = 1. -sqrt((boxid_max-i )/boxid_max); 2809 IssmDouble highbound = 1. -sqrt((boxid_max-i-1.)/boxid_max); 2809 2810 if(rel_dist_gl>=lowbound && rel_dist_gl<=highbound){ 2810 2811 boxid=i; … … 2815 2816 2816 2817 this->inputs->AddInput(new IntInput(BasalforcingsPicoBoxIdEnum, boxid)); 2817 2818 /*Cleanup & return: */ 2819 delete gauss; 2820 } 2821 /*}}}*/ 2818 }/*}}}*/ 2822 2819 void Tria::PicoUpdateFirstBox(){/*{{{*/ 2823 2820 … … 2829 2826 2830 2827 int basinid, maxbox, num_basins, numnodes, M; 2831 IssmDouble time, rhoi, rhow, earth_grav, rho_star, nu, latentheat, c_p_ocean, lambda, a, b, c; 2832 IssmDouble alpha, Beta, gamma_T, overturning_coeff; 2833 IssmDouble thickness, toc_farocean, soc_farocean, area_box1; 2834 IssmDouble pressure, T_star, g1, s1, p_coeff, q_coeff; 2835 IssmDouble* boxareas=NULL; 2836 IssmDouble* t_farocean=NULL; 2837 IssmDouble* s_farocean=NULL; 2828 IssmDouble time, gamma_T, overturning_coeff,thickness; 2829 IssmDouble pressure, T_star,p_coeff, q_coeff,toc_farocean,soc_farocean; 2830 IssmDouble* boxareas = NULL; 2838 2831 2839 2832 /*Get variables*/ 2840 rhoi= this->GetMaterialParameter(MaterialsRhoIceEnum);2841 rhow= this->GetMaterialParameter(MaterialsRhoSeawaterEnum);2842 earth_grav= this->GetMaterialParameter(ConstantsGEnum);2843 rho_star= 1033.; // kg/m^32844 nu= rhoi/rhow;2845 latentheat= this->GetMaterialParameter(MaterialsLatentheatEnum);2846 c_p_ocean= this->GetMaterialParameter(MaterialsMixedLayerCapacityEnum);2847 lambda= latentheat/c_p_ocean;2848 a= -0.0572; // K/psu2849 b= 0.0788 + this->GetMaterialParameter(MaterialsMeltingpointEnum); //K2850 c= 7.77e-4;2851 alpha= 7.5e-5; // 1/K2852 Beta= 7.7e-4; // K2833 IssmDouble rhoi = this->GetMaterialParameter(MaterialsRhoIceEnum); 2834 IssmDouble rhow = this->GetMaterialParameter(MaterialsRhoSeawaterEnum); 2835 IssmDouble earth_grav = this->GetMaterialParameter(ConstantsGEnum); 2836 IssmDouble rho_star = 1033.; // kg/m^3 2837 IssmDouble nu = rhoi/rhow; 2838 IssmDouble latentheat = this->GetMaterialParameter(MaterialsLatentheatEnum); 2839 IssmDouble c_p_ocean = this->GetMaterialParameter(MaterialsMixedLayerCapacityEnum); 2840 IssmDouble lambda = latentheat/c_p_ocean; 2841 IssmDouble a = -0.0572; // K/psu 2842 IssmDouble b = 0.0788 + this->GetMaterialParameter(MaterialsMeltingpointEnum); //K 2843 IssmDouble c = 7.77e-4; 2844 IssmDouble alpha = 7.5e-5; // 1/K 2845 IssmDouble Beta = 7.7e-4; // K 2853 2846 2854 2847 /* Get parameters and inputs */ … … 2857 2850 this->parameters->FindParam(&gamma_T,BasalforcingsPicoGammaTEnum); 2858 2851 this->parameters->FindParam(&overturning_coeff,BasalforcingsPicoOverturningCoeffEnum); 2859 this->parameters->FindParam(&t _farocean, &num_basins, time, BasalforcingsPicoFarOceantemperatureEnum);2860 this->parameters->FindParam(&s _farocean, &num_basins, time, BasalforcingsPicoFarOceansalinityEnum);2852 this->parameters->FindParam(&toc_farocean, basinid, time, BasalforcingsPicoFarOceantemperatureEnum); 2853 this->parameters->FindParam(&soc_farocean, basinid, time, BasalforcingsPicoFarOceansalinityEnum); 2861 2854 this->parameters->FindParam(&maxbox,BasalforcingsPicoMaxboxcountEnum); 2862 M = num_basins*maxbox;2863 2855 this->parameters->FindParam(&boxareas,&M,BasalforcingsPicoBoxAreaEnum); 2864 2856 this->inputs->GetInputValue(&basinid,BasalforcingsPicoBasinIdEnum); 2865 2866 2857 Input* thickness_input=this->GetInput(ThicknessEnum); _assert_(thickness_input); 2867 2868 toc_farocean = t_farocean[basinid]; 2869 soc_farocean = s_farocean[basinid]; 2870 area_box1 = boxareas[basinid*maxbox+boxid]; 2871 g1 = area_box1*gamma_T; 2872 s1 = soc_farocean/(nu*lambda); 2873 2858 IssmDouble area_box1 = boxareas[basinid*maxbox+boxid]; 2859 IssmDouble g1 = area_box1*gamma_T; 2860 IssmDouble s1 = soc_farocean/(nu*lambda); 2861 2862 /*Define new inputs*/ 2874 2863 IssmDouble basalmeltrates_shelf[NUMVERTICES]; 2875 2864 IssmDouble potential_pressure_melting_point[NUMVERTICES]; … … 2880 2869 /* Start looping on the number of nodes and calculate ocean vars */ 2881 2870 Gauss* gauss=this->NewGauss(); 2882 for 2871 for(int i=0;i<NUMVERTICES;i++){ 2883 2872 gauss->GaussVertex(i); 2884 2873 thickness_input->GetInputValue(&thickness,gauss); 2885 2874 pressure = (rhoi*earth_grav*1e-4)*thickness; 2886 T_star = a*soc_farocean+b-c*pressure-toc_farocean;2887 p_coeff = g1/(overturning_coeff*rho_star*(Beta*s1-alpha));2888 q_coeff = T_star*(g1/(overturning_coeff*rho_star*(Beta*s1-alpha)));2875 T_star = a*soc_farocean+b-c*pressure-toc_farocean; 2876 p_coeff = g1/(overturning_coeff*rho_star*(Beta*s1-alpha)); 2877 q_coeff = T_star*(g1/(overturning_coeff*rho_star*(Beta*s1-alpha))); 2889 2878 2890 2879 /* To avoid negatives under the square root */ 2891 if 2892 q_coeff = (0.25*pow(p_coeff,2));2880 if((0.25*pow(p_coeff,2)-q_coeff)<0){ 2881 q_coeff = 0.25*p_coeff*p_coeff; 2893 2882 } 2894 2883 … … 2907 2896 /*Cleanup and return */ 2908 2897 delete gauss; 2909 xDelete<IssmDouble>(t_farocean);2910 xDelete<IssmDouble>(s_farocean);2911 2898 xDelete<IssmDouble>(boxareas); 2912 2899 } … … 2920 2907 if(loopboxid!=boxid) return; 2921 2908 2922 int basinid, maxbox, num_basins, numnodes,M; 2923 IssmDouble rhoi, rhow, earth_grav, rho_star, nu, latentheat, c_p_ocean, lambda, a, b, c; 2924 IssmDouble alpha, Beta, gamma_T, overturning_coeff; 2925 IssmDouble thickness, toc_farocean, soc_farocean, area_boxi; 2926 IssmDouble mean_toc,mean_soc,mean_overturning; 2927 IssmDouble pressure, T_star, g1, g2, p_coeff, q_coeff; 2928 IssmDouble* toc_weighted_avg=NULL; 2929 IssmDouble* soc_weighted_avg=NULL; 2930 IssmDouble* overturning_weighted_avg=NULL; 2931 IssmDouble* boxareas=NULL; 2909 int basinid, maxbox, num_basins, numnodes,M; 2910 IssmDouble gamma_T, overturning_coeff; 2911 IssmDouble thickness, toc_farocean, soc_farocean; 2912 IssmDouble pressure, T_star,p_coeff, q_coeff; 2913 IssmDouble* toc_weighted_avg = NULL; 2914 IssmDouble* soc_weighted_avg = NULL; 2915 IssmDouble* overturning_weighted_avg = NULL; 2916 IssmDouble* boxareas = NULL; 2932 2917 2933 2918 /*Get variables*/ 2934 rhoi= this->GetMaterialParameter(MaterialsRhoIceEnum);2935 rhow= this->GetMaterialParameter(MaterialsRhoSeawaterEnum);2936 earth_grav= this->GetMaterialParameter(ConstantsGEnum);2937 rho_star= 1033.; // kg/m^32938 nu= rhoi/rhow;2939 latentheat= this->GetMaterialParameter(MaterialsLatentheatEnum);2940 c_p_ocean= this->GetMaterialParameter(MaterialsMixedLayerCapacityEnum);2941 lambda= latentheat/c_p_ocean;2942 a= -0.0572; // K/psu2943 b= 0.0788 + this->GetMaterialParameter(MaterialsMeltingpointEnum); //K2944 c= 7.77e-4;2945 alpha= 7.5e-5; // 1/K2946 Beta= 7.7e-4; // K2919 IssmDouble rhoi = this->GetMaterialParameter(MaterialsRhoIceEnum); 2920 IssmDouble rhow = this->GetMaterialParameter(MaterialsRhoSeawaterEnum); 2921 IssmDouble earth_grav = this->GetMaterialParameter(ConstantsGEnum); 2922 IssmDouble rho_star = 1033.; // kg/m^3 2923 IssmDouble nu = rhoi/rhow; 2924 IssmDouble latentheat = this->GetMaterialParameter(MaterialsLatentheatEnum); 2925 IssmDouble c_p_ocean = this->GetMaterialParameter(MaterialsMixedLayerCapacityEnum); 2926 IssmDouble lambda = latentheat/c_p_ocean; 2927 IssmDouble a = -0.0572; // K/psu 2928 IssmDouble b = 0.0788 + this->GetMaterialParameter(MaterialsMeltingpointEnum); //K 2929 IssmDouble c = 7.77e-4; 2930 IssmDouble alpha = 7.5e-5; // 1/K 2931 IssmDouble Beta = 7.7e-4; // K 2947 2932 2948 2933 /* Get parameters and inputs */ … … 2954 2939 this->parameters->FindParam(&soc_weighted_avg,&num_basins,BasalforcingsPicoAverageSalinityEnum); 2955 2940 this->parameters->FindParam(&overturning_weighted_avg,&num_basins,BasalforcingsPicoAverageOverturningEnum); 2956 M=num_basins*maxbox;2957 2941 this->parameters->FindParam(&boxareas,&M,BasalforcingsPicoBoxAreaEnum); 2958 2942 this->inputs->GetInputValue(&basinid,BasalforcingsPicoBasinIdEnum); 2959 2960 2943 Input* thickness_input=this->GetInput(ThicknessEnum); _assert_(thickness_input); 2961 2944 2962 area_boxi = boxareas[basinid*maxbox+boxid]; 2963 mean_toc = toc_weighted_avg[basinid]; 2964 mean_soc = soc_weighted_avg[basinid]; 2965 mean_overturning = overturning_weighted_avg[basinid]; 2966 g1 = area_boxi*gamma_T; 2967 g2 = g2/(nu*lambda); 2945 _assert_(basinid<=num_basins); 2946 IssmDouble area_boxi = boxareas[basinid*maxbox+boxid]; 2947 IssmDouble mean_toc = toc_weighted_avg[basinid]; 2948 IssmDouble mean_soc = soc_weighted_avg[basinid]; 2949 IssmDouble mean_overturning = overturning_weighted_avg[basinid]; 2950 IssmDouble g1 = area_boxi*gamma_T; 2951 IssmDouble g2 = g2/(nu*lambda); 2968 2952 2969 2953 IssmDouble basalmeltrates_shelf[NUMVERTICES]; … … 2974 2958 /* Start looping on the number of nodes and calculate ocean vars */ 2975 2959 Gauss* gauss=this->NewGauss(); 2976 for 2960 for(int i=0;i<NUMVERTICES;i++){ 2977 2961 gauss->GaussVertex(i); 2978 2962 thickness_input->GetInputValue(&thickness,gauss); 2979 pressure = (rhoi*earth_grav*1 e-4)*thickness;2980 T_star = a*mean_soc+b-c*pressure-mean_toc;2981 Tocs[i] = mean_toc+T_star*(g1/(mean_overturning+g1-g2*a*mean_soc));2982 Socs[i] = mean_soc-mean_soc*((mean_toc-Tocs[i])/(nu*lambda));2963 pressure = (rhoi*earth_grav*1.e-4)*thickness; 2964 T_star = a*mean_soc+b-c*pressure-mean_toc; 2965 Tocs[i] = mean_toc+T_star*(g1/(mean_overturning+g1-g2*a*mean_soc)); 2966 Socs[i] = mean_soc-mean_soc*((mean_toc-Tocs[i])/(nu*lambda)); 2983 2967 potential_pressure_melting_point[i] = a*Socs[i]+b-c*pressure; 2984 2968 basalmeltrates_shelf[i] = (-gamma_T/(nu*lambda))*(potential_pressure_melting_point[i]-Tocs[i]); -
issm/trunk-jpl/src/c/classes/Params/BoolParam.h
r22625 r22628 45 45 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 46 46 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 47 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}48 47 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 49 48 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/DataSetParam.h
r22625 r22628 46 46 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 47 47 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 48 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}49 48 void GetParameterValue(FILE** pfile){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a file pointer");} 50 49 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} -
issm/trunk-jpl/src/c/classes/Params/DoubleMatArrayParam.h
r22625 r22628 48 48 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a IssmDouble");} 49 49 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 50 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}51 50 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a string");} 52 51 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << "cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/DoubleMatParam.h
r22625 r22628 48 48 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 49 49 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 50 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}51 50 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 52 51 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/DoubleParam.h
r22625 r22628 46 46 void GetParameterValue(IssmDouble* pIssmDouble){*pIssmDouble=value;} 47 47 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 48 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}49 48 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 50 49 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.cpp
r20827 r22628 77 77 78 78 /*DoubleVecParam virtual functions definitions: */ 79 void DoubleVecParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM){/*{{{*/ 80 IssmDouble* output=NULL; 81 int M; 79 void DoubleVecParam::GetParameterValue(IssmDouble** poutput,int* pM){/*{{{*/ 82 80 83 M=this->M; 84 output=xNew<IssmDouble>(M); 81 IssmDouble* output=xNew<IssmDouble>(M); 85 82 xMemCpy<IssmDouble>(output,values,M); 86 83 87 84 /*Assign output pointers:*/ 88 85 if(pM) *pM=M; 89 *p IssmDoublearray=output;86 *poutput=output; 90 87 } 91 88 /*}}}*/ 92 void DoubleVecParam::GetParameterValue(IssmDouble** pIssmDoublearray,int* pM,int* pN){/*{{{*/ 93 IssmDouble* output=NULL; 94 int M; 95 int N; 89 void DoubleVecParam::GetParameterValue(IssmDouble** poutput,int* pM,int* pN){/*{{{*/ 96 90 97 N=1; 98 M=this->M; 99 output=xNew<IssmDouble>(M); 91 IssmDouble* output=xNew<IssmDouble>(this->M); 100 92 xMemCpy<IssmDouble>(output,values,M); 101 93 102 94 /*Assign output pointers:*/ 103 if(pM) *pM= M;104 if(pN) *pN= N;105 *p IssmDoublearray=output;95 if(pM) *pM=this->M; 96 if(pN) *pN=1; 97 *poutput=output; 106 98 } 107 99 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Params/DoubleVecParam.h
r22625 r22628 46 46 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 47 47 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 48 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}49 48 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 50 49 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/FileParam.h
r22625 r22628 45 45 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 46 46 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 47 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}48 47 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 49 48 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/GenericParam.h
r22625 r22628 71 71 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a IssmDouble");} 72 72 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a IssmDouble for a given time");} 73 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a IssmDoubleArray for a given time");}74 73 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a string");} 75 74 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(myEnumVal) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/IntMatParam.h
r22625 r22628 47 47 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 48 48 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 49 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}50 49 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 51 50 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/IntParam.h
r22625 r22628 46 46 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 47 47 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 48 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}49 48 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 50 49 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/IntVecParam.h
r22625 r22628 47 47 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 48 48 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 49 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}50 49 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 51 50 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/MatrixParam.h
r22625 r22628 46 46 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 47 47 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 48 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}49 48 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 50 49 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/Param.h
r22625 r22628 34 34 virtual void GetParameterValue(IssmDouble* pIssmDouble)=0; 35 35 virtual void GetParameterValue(IssmDouble* pdouble,IssmDouble time)=0; 36 virtual void GetParameterValue(IssmDouble* * pIssmDoublearray,int* pM, IssmDouble time)=0;36 virtual void GetParameterValue(IssmDouble* pdouble,int row, IssmDouble time){_error_("not implemented yet");}; 37 37 virtual void GetParameterValue(char** pstring)=0; 38 38 virtual void GetParameterValue(char*** pstringarray,int* pM)=0; -
issm/trunk-jpl/src/c/classes/Params/Parameters.cpp
r22625 r22628 300 300 } 301 301 /*}}}*/ 302 void Parameters::FindParam(IssmDouble* * pIssmDoublearray, int* pM,IssmDouble time, int param_enum){ _assert_(this);/*{{{*/303 304 _assert_(param_enum>ParametersSTARTEnum); 305 _assert_(param_enum<ParametersENDEnum); 306 307 int index = param_enum - ParametersSTARTEnum -1; 308 if(!this->params[index]) _error_("Parameter " << EnumToStringx(param_enum) <<" not set"); 309 this->params[index]->GetParameterValue(p IssmDoublearray, pM,time);302 void Parameters::FindParam(IssmDouble* pscalar,int row,IssmDouble time, int param_enum){ _assert_(this);/*{{{*/ 303 304 _assert_(param_enum>ParametersSTARTEnum); 305 _assert_(param_enum<ParametersENDEnum); 306 307 int index = param_enum - ParametersSTARTEnum -1; 308 if(!this->params[index]) _error_("Parameter " << EnumToStringx(param_enum) <<" not set"); 309 this->params[index]->GetParameterValue(pscalar,row,time); 310 310 } 311 311 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Params/Parameters.h
r22625 r22628 40 40 void FindParam(IssmDouble* pscalar, int enum_type); 41 41 void FindParam(IssmDouble* pscalar, int enum_type,IssmDouble time); 42 void FindParam(IssmDouble** pIssmDoublearray, int* pM, IssmDouble time,int enum_type);42 void FindParam(IssmDouble* pscalar, int row,IssmDouble time,int enum_type); 43 43 void FindParam(char** pstring,int enum_type); 44 44 void FindParam(char*** pstringarray,int* pM,int enum_type); -
issm/trunk-jpl/src/c/classes/Params/StringArrayParam.h
r22625 r22628 46 46 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 47 47 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 48 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}49 48 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 50 49 void GetParameterValue(char*** pstringarray,int* pM); -
issm/trunk-jpl/src/c/classes/Params/StringParam.h
r22625 r22628 46 46 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 47 47 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 48 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}49 48 void GetParameterValue(char** pstring); 50 49 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/TransientArrayParam.cpp
r22625 r22628 25 25 26 26 enum_type=in_enum_type; 27 N=in_N; //Number of time steps28 M=in_M; //Number of rows27 M=in_M; //Number of time steps 28 N=in_N; //Number of rows 29 29 interpolation=interpolation_on; 30 30 31 values=xNew<IssmDouble>( N*M);32 xMemCpy<IssmDouble>(values,in_values, N*M);31 values=xNew<IssmDouble>(M*N); 32 xMemCpy<IssmDouble>(values,in_values,M*N); 33 33 34 timesteps=xNew<IssmDouble>( N);35 xMemCpy<IssmDouble>(timesteps,in_time, N);34 timesteps=xNew<IssmDouble>(M); 35 xMemCpy<IssmDouble>(timesteps,in_time,M); 36 36 } 37 37 /*}}}*/ … … 39 39 xDelete<IssmDouble>(values); 40 40 xDelete<IssmDouble>(timesteps); 41 } 42 /*}}}*/ 41 }/*}}}*/ 43 42 44 43 /*Object virtual functions definitions:*/ 45 44 Param* TransientArrayParam::copy() {/*{{{*/ 46 45 47 return new TransientArrayParam(this->enum_type,this->values,this->timesteps,this->interpolation,this-> N,this->M);46 return new TransientArrayParam(this->enum_type,this->values,this->timesteps,this->interpolation,this->M,this->N); 48 47 49 48 } … … 68 67 _printf_("TransientArrayParam:\n"); 69 68 _printf_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")\n"); 70 _printf_(" size: " << this-> N << " by " << this->M<< "\n");69 _printf_(" size: " << this->M << " by " << this->N << "\n"); 71 70 72 71 } … … 83 82 MARSHALLING(N); 84 83 if(marshall_direction==MARSHALLING_BACKWARD){ 85 values =xNew<IssmDouble>(N*M);86 timesteps =xNew<IssmDouble>(N*M);84 values = xNew<IssmDouble>(M*N); 85 timesteps = xNew<IssmDouble>(N); 87 86 } 88 MARSHALLING_ARRAY(values,IssmDouble, N*M);89 MARSHALLING_ARRAY(timesteps,IssmDouble,N *M);87 MARSHALLING_ARRAY(values,IssmDouble,M*N); 88 MARSHALLING_ARRAY(timesteps,IssmDouble,N); 90 89 91 90 }/*}}}*/ … … 94 93 return TransientArrayParamEnum; 95 94 96 } 97 /*}}}*/ 95 }/*}}}*/ 98 96 99 97 /*TransientArrayParam virtual functions definitions: */ 100 void TransientArrayParam::GetParameterValue(IssmDouble* pdouble, IssmDouble time, int row){/*{{{*/98 void TransientArrayParam::GetParameterValue(IssmDouble* pdouble,int row,IssmDouble time){/*{{{*/ 101 99 102 100 IssmDouble output; 103 bool found;101 bool found; 104 102 105 103 /*Ok, we have the time, go through the timesteps, and figure out which interval we … … 142 140 } 143 141 /*}}}*/ 144 void TransientArrayParam::GetParameterValue(IssmDouble** pIssmDoubleArray, int* pM, IssmDouble time){/*{{{*/145 146 IssmDouble* output=NULL;147 bool found;148 int M=*pM;149 150 output=xNew<IssmDouble>(M);151 152 /*Ok, we have the time, go through the timesteps, and figure out which interval we153 *fall within. Then interpolate the values on this interval: */154 if(time<this->timesteps[0]){155 /*get values for the first time: */156 for(int k=0; k<M;k++){157 output[k]=this->values[k*this->N];158 found=true;159 }160 }161 else if(time>this->timesteps[this->N-1]){162 /*get values for the last time: */163 for(int k=0; k<M;k++){164 output[k]=this->values[(k+1)*this->N-1];165 found=true;166 }167 }168 else{169 /*Find which interval we fall within: */170 for(int i=0;i<this->N;i++){171 if(time==this->timesteps[i]){172 /*We are right on one step time: */173 for(int k=0; k<M;k++){174 output[k]=this->values[k*this->N+i];175 }176 found=true;177 break; //we are done with the time interpolation.178 }179 else{180 if(this->timesteps[i]<time && time<this->timesteps[i+1]){181 /*ok, we have the interval ]i:i+1[. Interpolate linearly for now: */182 IssmDouble deltat=this->timesteps[i+1]-this->timesteps[i];183 IssmDouble alpha=(time-this->timesteps[i])/deltat;184 for(int k=0; k<M;k++){185 if(interpolation==true) output[k]=(1.0-alpha)*this->values[k*this->N+i] + alpha*this->values[k*this->N+i+1];186 else output[k]=this->values[k*this->N+i];187 }188 found=true;189 break;190 }191 else continue; //keep looking on the next interval192 }193 }194 }195 if(!found)_error_("did not find time interval on which to interpolate values");196 *pIssmDoubleArray=output;197 198 }/*}}}*/ -
issm/trunk-jpl/src/c/classes/Params/TransientArrayParam.h
r22625 r22628 48 48 void GetParameterValue(int** pintarray,int* pM,int* pN){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a array of integers");} 49 49 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a IssmDouble");} 50 void GetParameterValue(IssmDouble* pdouble,IssmDouble time,int row); 51 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time); 50 void GetParameterValue(IssmDouble* pdouble,int row,IssmDouble time); 52 51 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Parameter " <<EnumToStringx(enum_type) << " needs row to be specified");} 53 52 void GetParameterValue(char** pstring){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a string");} -
issm/trunk-jpl/src/c/classes/Params/TransientParam.h
r22625 r22628 48 48 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a IssmDouble");} 49 49 void GetParameterValue(IssmDouble* pdouble,IssmDouble time); 50 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}51 50 void GetParameterValue(char** pstring){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a string");} 52 51 void GetParameterValue(char*** pstringarray,int* pM){_error_("Parameter " <<EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/classes/Params/VectorParam.h
r22625 r22628 46 46 void GetParameterValue(IssmDouble* pIssmDouble){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble");} 47 47 void GetParameterValue(IssmDouble* pdouble,IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDouble for a given time");} 48 void GetParameterValue(IssmDouble** pIssmDoublearray,int* pM, IssmDouble time){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a IssmDoubleArray for a given time");}49 48 void GetParameterValue(char** pstring){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string");} 50 49 void GetParameterValue(char*** pstringarray,int* pM){_error_("Param "<< EnumToStringx(enum_type) << " cannot return a string array");} -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp
r22625 r22628 209 209 parameters->AddObject(iomodel->CopyConstantObject("md.basalforcings.overturning_coeff",BasalforcingsPicoOverturningCoeffEnum)); 210 210 parameters->AddObject(iomodel->CopyConstantObject("md.basalforcings.gamma_T",BasalforcingsPicoGammaTEnum)); 211 iomodel->FetchData(&transparam,& N,&M,"md.basalforcings.farocean_temperature");212 parameters->AddObject(new TransientArrayParam(BasalforcingsPicoFarOceantemperatureEnum, &transparam[0],&transparam[M*(N-1)],interp,M,N));211 iomodel->FetchData(&transparam,&M,&N,"md.basalforcings.farocean_temperature"); 212 parameters->AddObject(new TransientArrayParam(BasalforcingsPicoFarOceantemperatureEnum,transparam,&transparam[N*(M-1)],interp,M,N)); 213 213 xDelete<IssmDouble>(transparam); 214 iomodel->FetchData(&transparam,& N,&M,"md.basalforcings.farocean_salinity");215 parameters->AddObject(new TransientArrayParam(BasalforcingsPicoFarOceansalinityEnum, &transparam[0],&transparam[M*(N-1)],interp,M,N));214 iomodel->FetchData(&transparam,&M,&N,"md.basalforcings.farocean_salinity"); 215 parameters->AddObject(new TransientArrayParam(BasalforcingsPicoFarOceansalinityEnum,transparam,&transparam[N*(M-1)],interp,M,N)); 216 216 xDelete<IssmDouble>(transparam); 217 217 break;
Note:
See TracChangeset
for help on using the changeset viewer.