├── BEPS-SIF ├── DB.h ├── aerodynamic_conductance.c ├── beps.h ├── beps401b_glb.c ├── beps401b_glb_hr.c ├── calc_temp_leaf.c ├── evaporation_canopy.c ├── evaporation_soil.c ├── init_soil.c ├── inter_prg.c ├── lai_calc.c ├── makefile ├── meteo_pack.c ├── netRadiation.c ├── photosyn_gs.c ├── plant_respir.c ├── plant_respir_l.c ├── rainfall.c ├── read_all_lai.c ├── read_input2.c ├── read_yrdata_c.c ├── readcoef_l.c ├── readcontrolf_b.c ├── readlonlat.c ├── readparam_l.c ├── s_coszs.c ├── sensible_heat.c ├── snowpack.c ├── soil.h ├── soil_thermal_regime.c ├── soil_water_stress.c ├── soilresp.c ├── surface_temp.c ├── transpiration.c ├── updatesoilmoisture.c └── vcmax_jmax_mod.c └── README.md /BEPS-SIF/DB.h: -------------------------------------------------------------------------------- 1 | 2 | #define PI180 0.017453292 // pi divided by 180, radians per degree 3 | #define PI9 2.864788976 4 | #define PI2 6.283185307 // 2 time pi 5 | 6 | struct meteorology { 7 | 8 | double ustar; // friction velocity, m s-1 9 | double ustarnew; // updated friction velocity with new H, m s-1 10 | double rhova_g; // absolute humidity, g m-3 11 | double rhova_kg; // absolute humidity, kg m-3 12 | double sensible_heat_flux; // sensible heat flux, W M-2 13 | double H_old; // old sensible heat flux, W m-2 14 | double air_density; // air density, kg m-3 15 | double T_Kelvin; // absolute air temperature, K 16 | double press_kpa; // station pressure, kPa 17 | double press_bars; // station pressure, bars 18 | double press_Pa; // pressure, Pa 19 | double pstat273; // gas constant computations 20 | double air_density_mole; // air density, mole m-3 21 | double relative_humidity; // relative humidity, ea/es(T) 22 | double vpd; // vapor pressure deficit 23 | double ir_in; // infrared flux density 24 | } met; 25 | 26 | // structure for plant and physical factors 27 | 28 | struct factors { 29 | double latent; // latent heat of vaporization, J kg-1 30 | double latent18; // latent heat of vaporization times molecular mass of vapor, 18 g mol-1 31 | double heatcoef; // factor for sensible heat flux density 32 | double a_filt; // filter coefficients 33 | double b_filt; // filter coefficients 34 | double co2; // CO2 factor, ma/mc * rhoa (mole m-3) 35 | 36 | } fact; 37 | 38 | struct boundary_layer_resistances{ 39 | 40 | double vapor; // resistance for water vapor, s/m 41 | double heat; // resistance for heat, s/m 42 | double co2; // resistance for CO2, s/m 43 | } bound_layer_res; 44 | 45 | void TBOLTZdouble(); 46 | double TEMP_FUNC(); 47 | double TBOLTZ(); 48 | void photosynthesis(); 49 | double SFC_VPD(); 50 | double ES(); 51 | double LAMBDA(); 52 | double SIF_y(); 53 | 54 | 55 | 56 | 57 | #define rugc 8.314 // J mole-1 K-1 58 | //#define vcopt 73.0 // carboxylation rate at optimal temperature, umol m-2 s-1 59 | //#define jmopt 170.0 // electron transport rate at optimal temperature, umol m-2 s-1 60 | #define rd25 0.34 // dark respiration at 25 C, rd25= 0.34 umol m-2 s-1 61 | #define pi4 12.5663706 62 | // Universal gas constant 63 | 64 | #define rgc1000 8314 // gas constant times 1000. 65 | 66 | // Consts for Photosynthesis model and kinetic equations. 67 | // for Vcmax and Jmax. Taken from Harley and Baldocchi (1995, PCE) 68 | #define hkin 200000.0 // enthalpy term, J mol-1 69 | #define skin 710.0 // entropy term, J K-1 mol-1 70 | #define ejm 55000.0 // activation energy for electron transport, J mol-1 71 | #define evc 55000.0 // activation energy for carboxylation, J mol-1 72 | 73 | // Enzyme constants & partial pressure of O2 and CO2 74 | // Michaelis-Menten K values. From survey of literature. 75 | 76 | #define kc25 274.6 // kinetic coef for CO2 at 25 C, microbars 77 | #define ko25 419.8 // kinetic coef for O2 at 25C, millibars 78 | #define o2 210.0 // oxygen concentration mmol mol-1 79 | 80 | 81 | // tau is computed on the basis of the Specificity factor (102.33) 82 | // times Kco2/Kh2o (28.38) to convert for value in solution 83 | // to that based in air/ 84 | // The old value was 2321.1. 85 | 86 | // New value for Quercus robor from Balaguer et al. 1996 87 | // Similar number from Dreyer et al. 2001, Tree Physiol, tau= 2710 88 | 89 | #define tau25 2904.12 // tau coefficient 90 | // Arrhenius constants 91 | // Eact for Michaelis-Menten const. for KC, KO and dark respiration 92 | // These values are from Harley 93 | #define ekc 80500.0 // Activation energy for K of CO2; J mol-1 94 | #define eko 14500.0 // Activation energy for K of O2, J mol-1 95 | #define erd 38000.0 // activation energy for dark respiration, eg Q10=2 96 | #define ektau -29000.0 // J mol-1 (Jordan and Ogren, 1984) 97 | #define tk_25 298.16 // absolute temperature at 25 C 98 | #define toptvc 301.0 // optimum temperature for maximum carboxylation 99 | #define toptjm 301.0 // optimum temperature for maximum electron transport 100 | #define eabole 45162 // activation energy for bole respiration for Q10 = 2.02 101 | 102 | 103 | // Constants for leaf energy balance 104 | 105 | #define sigma 5.67e-08 // Stefan-Boltzmann constant W M-2 K-4 106 | #define cp 1005. // Specific heat of air, J KG-1 K-1 107 | #define mass_air 29.0 // Molecular weight of air, g mole-1 108 | #define mass_CO2 44.0 // molecular weight of CO2, g mole-1 109 | #define dldt -2370.0 // Derivative of the latent heat of vaporization 110 | 111 | #define ep 0.98 // emissivity of leaves 112 | #define epm1 0.02 // 1- ep 113 | #define epsoil 0.98 // Emissivity of soil 114 | #define epsigma 5.5566e-8 // ep*sigma 115 | #define epsigma2 11.1132e-8 // 2*ep*sigma 116 | #define epsigma4 22.2264e-8 // 4.0 * ep * sigma 117 | #define epsigma6 33.3396e-8 // 6.0 * ep * sigma 118 | #define epsigma8 44.448e-8 // 8.0 * ep * sigma 119 | #define epsigma12 66.6792e-8 // 12.0 * ep * sigma 120 | #define betfact 1.5 // multiplication factor for aerodynamic 121 | // sheltering, based on work by Grace and Wilson 122 | // constants for the polynomial equation for saturation vapor pressure-T function, es=f(t) 123 | #define a1en 617.4 124 | #define a2en 42.22 125 | #define a3en 1.675 126 | #define a4en 0.01408 127 | #define a5en 0.0005818 128 | 129 | 130 | 131 | // Minimum stomatal resistance, s m-1. 132 | #define rsm 145.0 133 | #define brs 60.0 // curvature coeffient for light response 134 | 135 | // leaf quantum yield, electrons 136 | #define qalpha 0.22 137 | #define qalpha2 0.0484 // qalpha squared, qalpha2 = pow(qalpha, 2.0); 138 | 139 | // Leaf dimension. geometric mean of length and width (m) 140 | #define lleaf 0.1 // leaf length, m 141 | 142 | 143 | // Diffusivity values for 273 K and 1013 mb (STP) using values from Massman (1998) Atmos Environment 144 | // These values are for diffusion in air. When used these values must be adjusted for 145 | // temperature and pressure 146 | // nu, Molecular viscosity 147 | 148 | 149 | #define nuvisc 13.27 // mm2 s-1 150 | #define nnu 0.00001327 // m2 s-1 151 | 152 | // Diffusivity of CO2 153 | 154 | #define dc 13.81 // mm2 s-1 155 | #define ddc 0.00001381 // m2 s-1 156 | 157 | // Diffusivity of heat 158 | 159 | #define dh 18.69; // mm2 s-1 160 | #define ddh 0.00001869 // m2 s-1 161 | 162 | 163 | // Diffusivity of water vapor 164 | 165 | #define dv 21.78 // mm2 s-1 166 | #define ddv 0.00002178 // m2 s-1 167 | 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /BEPS-SIF/aerodynamic_conductance.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | aerodynamic_conductance.c 3 | 4 | Calculation of aerodynamic resistance/conductance. 5 | 6 | Written by: J. Liu. and W. Ju, Modified by G. Mo 7 | Last update: May 2015 8 | *************************************************************************/ 9 | 10 | #include"beps.h" 11 | 12 | void aerodynamic_conductance(double canopy_height_o,double canopy_height_u,double zz, double clumping,double temp_air,double wind_sp,double SH_o_p,double lai_o,double lai_u, 13 | double *rm,double *ra_u,double *ra_g,double *G_o_a,double *G_o_b,double *G_u_a,double *G_u_b) 14 | 15 | { 16 | double kh_o; 17 | double lw=0.3; // leaf charcteristic width =0.3 for BS 18 | double sigma=5; // shelter factor =5 for BS 19 | double rb_o,rb_u; 20 | double k=0.4; // von Karman's constant 21 | double beta=0.5; // Bowen's ratio 22 | double cp=1010; // specific heat of air (J/kg/K) 23 | double density_air=1.225; // density of air at 15 C (kg/m3) 24 | double gg=9.8; // gravitational acceleration (m/s2) 25 | double n=5.0; 26 | 27 | double nu_lower; // viscosity (cm2/s) 28 | double uf; 29 | double psi; 30 | double d; // displacement height (m) 31 | double z0; // roughness length (m) 32 | double ustar; // friction velocity (m/s) 33 | double L; 34 | double Le; 35 | 36 | double uh; // wind speed at height h 37 | double ud; // wind speed at height d 38 | double gamma; 39 | double Re; // Reynold's number 40 | double Nu; // Nusselt number 41 | double alfac; 42 | double alfaw; 43 | 44 | double ram; 45 | double un_d,un_t,kh_u; 46 | 47 | nu_lower=(13.3+temp_air*0.07)/1000000; 48 | alfac=0.15; /* for CO2 */ 49 | //alfaw=0.25; /* for H2O */ 50 | alfaw=(18.9+temp_air*0.07)/1000000; 51 | 52 | if(wind_sp==0) 53 | { 54 | uh=0; 55 | uf=0; 56 | psi=6; 57 | *G_o_a=1/200.0; 58 | *G_o_b=1/200.0; 59 | *G_u_a=1/200.0; 60 | *G_u_b=1/200.0; 61 | *ra_g =300; 62 | } 63 | else 64 | { 65 | d=0.8*canopy_height_o; 66 | z0=0.08*canopy_height_o; 67 | 68 | ustar=wind_sp*k/log((zz-d)/z0); 69 | L= - (k*gg*SH_o_p)/(density_air*cp*(temp_air+273.3)*pow(ustar,3)); 70 | L=max(-2.0,L); 71 | 72 | ram= 1/(k*ustar)*(log((zz-d)/z0)+(n*(zz-d)*L)); 73 | ram=max(2,ram); 74 | ram=min(100,ram); 75 | 76 | if(L>0) psi=1+5*(zz-d)*L; 77 | else psi=pow((1-16*(zz-d)*L),-0.5); 78 | psi=min(10.0,psi); 79 | 80 | /********* Leaf boundary layer resistance ******************/ 81 | /* Wind speed at tree top */ 82 | uh=1.1*ustar/k; 83 | Le=lai_o*clumping; 84 | gamma=(0.167+0.179*uh)*pow(Le, 1.0/3.0); 85 | 86 | /* Wind speed at d, taking as the mean wind speed inside a stand */ 87 | ud=uh*exp(-gamma*(1-d/canopy_height_o)); 88 | 89 | /* Reynold's number */ 90 | //Re=(ud*lw/sigma)/nu_lower; 91 | Re=(ud*0.1)/nu_lower; 92 | 93 | /* Nusselt number */ 94 | Nu=1.0*pow(Re,0.5); 95 | 96 | /* leaf boundary resistance */ 97 | rb_o=min(40,0.5*0.1/(alfaw*Nu)); 98 | 99 | 100 | uf=ustar; 101 | *rm=ram; 102 | *G_o_a=1/ram; 103 | *G_o_b=1/rb_o; 104 | 105 | kh_o=0.41*ustar*(canopy_height_o-canopy_height_o*0.8)/psi; 106 | gamma=0.1+pow(lai_o, 0.75); 107 | 108 | // wind speed at the zero displancement of canopy 109 | un_d=uh*exp(-gamma*(1-canopy_height_u*0.8/canopy_height_o)); 110 | // wind speed at the zero displancement of canopy 111 | un_t=uh*exp(-gamma*(1-canopy_height_u/canopy_height_o)); 112 | 113 | /* Reynold's number */ 114 | //Re=(ud*lw/sigma)/nu_lower; 115 | Re=(un_d*0.1)/nu_lower; 116 | 117 | /* Nusselt number */ 118 | Nu=1.0*pow(Re,0.5); 119 | 120 | /* leaf boundary resistance */ 121 | rb_u =0.5*0.1/(alfaw*Nu); 122 | rb_u =min(40,rb_u); 123 | *G_u_b=1.0/rb_u; 124 | 125 | *ra_u=canopy_height_o/(gamma* kh_o)*(exp(gamma*(1-canopy_height_u/canopy_height_o))-1); 126 | *G_u_a=1/(ram+*ra_u); 127 | 128 | gamma=4.0; 129 | kh_u=kh_o*exp(-gamma*(1-canopy_height_u/canopy_height_o)); 130 | 131 | *ra_g=canopy_height_o/(gamma* kh_o)* 132 | (exp(gamma*(1-0/canopy_height_o))-exp(gamma*(1-canopy_height_u/canopy_height_o))); 133 | *ra_g=*ra_g+*ra_u+ram; 134 | *ra_g=max(120,*ra_g); 135 | 136 | } 137 | return; 138 | } 139 | 140 | -------------------------------------------------------------------------------- /BEPS-SIF/beps.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | program: beps.h 3 | Description: Header file for defining constants and global variables 4 | ---------- for BEPS program 5 | 6 | *************************************************************************** 7 | CCRS (EMS/Applications Division) 8 | Wrintten by: J. Liu 9 | Modified by: G. Mo 10 | Last update: June 2015 11 | *****************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | /* Define Constants */ 20 | #define NOERROR 0 21 | #define ERROR 1 22 | #define PI 3.1415926 23 | #define zero 0.0000000001 24 | 25 | //#define max(a,b) (a>b)?a:b // used for UNIX 26 | //#define min(a,b) (a(b))?(a):(b) // LHE. the orginal one can lead to disorder. 28 | #define min(a,b) ((a)<(b))?(a):(b) // LHE 29 | 30 | 31 | #define l_sta 105 // start line 32 | #define l_end 105 // end line 33 | #define p_sta 101 // start pix 34 | #define p_end 101 // end pix 35 | 36 | #define RTIMES 24 /*24 */ 37 | #define step 3600 /*3600 in sec */ 38 | #define kstep 371.14 /* 10 times per hour, 360 sec. per time */ 39 | #define kloop 10 /* 10 times per hour, 360 sec. per time */ 40 | #define layer 5 41 | #define depth_f 6 42 | #define CO2_air 369.54 //atmopsheric CO2 concentration 43 | #define rho_a 1.292 // densoty of air at 0C 44 | 45 | 46 | void readconf(); 47 | void mid_prg(); 48 | void readinput1(); 49 | void readinput2(); 50 | void readlai_d(); 51 | void readlonlat(); 52 | void readlai_all(); 53 | void inter_prg(); 54 | void s_coszs(); 55 | void aerodynamic_conductance(); 56 | void plantresp(); 57 | void Vcmax_Jmax(); 58 | void netRadiation (); 59 | void soilresp(); 60 | void readparam(); 61 | void lai2(); 62 | void readcoef(); 63 | void photosynthesis(); 64 | void Leaf_Temperatures(); 65 | double Leaf_Temperature(); 66 | 67 | void sensible_heat(); 68 | void transpiration(); 69 | void evaporation_canopy(); 70 | void evaporation_soil(); 71 | void rainfall_stage1(); 72 | void rainfall_stage2(); 73 | void rainfall_stage3(); 74 | 75 | void meteo_pack(); 76 | void surface_temperature(); 77 | void snowpack_stage1(); 78 | void snowpack_stage2(); 79 | void snowpack_stage3(); 80 | 81 | /* Declare structures */ 82 | struct climatedata 83 | { 84 | double Srad; 85 | double LR; 86 | double temp; 87 | double rh; 88 | double rain; 89 | double wind; 90 | double dr_o; 91 | double df_o; 92 | double dr_u; 93 | double df_u; 94 | // float st_c; 95 | }; 96 | 97 | struct results 98 | { 99 | double gpp_o_sunlit; 100 | double gpp_u_sunlit; 101 | double gpp_o_shaded; 102 | double gpp_u_shaded; 103 | double plant_resp; 104 | double npp_o; 105 | double npp_u; 106 | double GPP; 107 | double NPP; 108 | double NEP; 109 | double soil_resp; 110 | double Net_Rad; 111 | double SH; 112 | double LH; 113 | double Trans; 114 | double Evap; 115 | double SIF; 116 | }; 117 | 118 | 119 | /* Declare global variables */ 120 | short lc_no; 121 | int yr,bgn_day,end_day; 122 | int npixels,nlines; 123 | 124 | char lc_fn[255]; /* Land cover file */ 125 | char lai_fn[255]; /* Leaf area index file */ 126 | char lai_fp[255]; /* Leaf area index file prefix */ 127 | char stxt_fn[255]; /* soil texture file */ 128 | char ci_fn[255]; /* clumping index file */ 129 | char st_fn[255]; /* intial values of soil temp */ 130 | char sw_fn[255]; /* intial values of soil water */ 131 | char sdp_fn[255]; /* intial values of snow depth*/ 132 | 133 | char r_fn[255]; /* meteo.data files */ 134 | char t_fn[255]; 135 | char h_fn[255]; 136 | char p_fn[255]; 137 | char wd_fn[255]; 138 | 139 | char lon_fn[255]; 140 | char lat_fn[255]; 141 | 142 | char laiy_fn[255],nppy_fn[255]; 143 | char ccd_fn[255],cssd_fn[255],csmd_fn[255],cfsd_fn[255],cfmd_fn[255],csm_fn[255],cm_fn[255],cs_fn[255],cp_fn[255]; 144 | 145 | char fp4outp1[255]; /* output file1 prefix */ 146 | char fp4outp2[255]; /* output file2 prefix */ 147 | char fp4outp3[255]; /* output file3 prefix */ 148 | 149 | -------------------------------------------------------------------------------- /BEPS-SIF/beps401b_glb.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | Program: beps401b_glb.c (main program for global simulation) 3 | version 4.01b: for simulation of NPP, NEP and respirations 4 | *************************************************************************/ 5 | 6 | #include "beps.h" 7 | #include "soil.h" 8 | 9 | int main(argc,argv) 10 | int argc; 11 | char *argv[]; 12 | { 13 | int pix,line; 14 | int jday,rstep; 15 | char argv1[20]; 16 | short rv,tv,hv,pv,wv,laiv; 17 | 18 | int i,j,p,ptr,ptr2; 19 | int lc,stxt; 20 | float lon,lat; 21 | float **lc0,**lai0,**ci0,**lon0,**lat0; 22 | float **st0,**sw0,**sdp0,**stxt0; 23 | float **Ccd0,**Cssd0,**Csmd0,**Cfsd0,**Cfmd0,**Csm0,**Cm0,**Cs0,**Cp0,**laiy0,**nppy0; 24 | 25 | double ci,lai,laiy,nppy; 26 | 27 | double tem,hum,st,sw,snowdepth; 28 | double Ccd[5],Cssd[5],Csmd[5],Cfsd[5],Cfmd[5],Csm[5],Cm[5],Cs[5],Cp[5]; 29 | 30 | double parameter[50]; 31 | double coef[100]; 32 | double es,esd; 33 | double CosZs; 34 | 35 | struct climatedata *meteo; 36 | struct results *mid_res; 37 | struct Soil *soilp; 38 | 39 | double var_o[42],var_n[42]; 40 | double v2last[40]; 41 | float outp[10]; 42 | float **ann1,**ann2,**ann3; 43 | double total[10]; 44 | 45 | char outp1fn[80],outp2fn[80],outp3fn[80]; 46 | 47 | FILE *outp1_p,*outp2_p,*outp3_p; 48 | FILE *inR_p,*inT_p,*inH_p,*inP_p,*wind_p,*laif_p; 49 | 50 | /** Reading control file **/ 51 | readconf(argv[1]); 52 | 53 | printf("running with %s ...\n",argv[1]); 54 | 55 | meteo=(struct climatedata*)malloc(366*sizeof(struct climatedata)); 56 | mid_res=(struct results*)malloc(366*sizeof(struct results)); 57 | soilp = (struct Soil*)malloc(sizeof(struct Soil)); 58 | 59 | 60 | lc0 = (float **) malloc((nlines*2)*sizeof(float*)); 61 | for (j=0;j<=nlines+1;j++) 62 | lc0[j] = (float *) malloc((npixels+1)*sizeof(float)); 63 | ci0 = (float **) malloc((nlines*2)*sizeof(float*)); 64 | for (j=0;j<=nlines+1;j++) 65 | ci0[j] = (float *) malloc((npixels+1)*sizeof(float)); 66 | lon0 = (float **) malloc(nlines*2*sizeof(float*)); 67 | for (j=0;j<=nlines;j++) 68 | lon0[j] = (float *) malloc(npixels*sizeof(float)); 69 | lat0 = (float **) malloc(nlines*2*sizeof(float*)); 70 | for (j=0;j<=nlines;j++) 71 | lat0[j] = (float *) malloc(npixels*sizeof(float)); 72 | stxt0 = (float **) malloc((nlines*2)*sizeof(float*)); 73 | for (j=0;j<=nlines+1;j++) 74 | stxt0[j] = (float *) malloc((npixels+1)*sizeof(float)); 75 | st0 = (float **) malloc((nlines*2)*sizeof(float*)); 76 | for (j=0;j<=nlines+1;j++) 77 | st0[j] = (float *) malloc((npixels+1)*sizeof(float)); 78 | sw0 = (float **) malloc((nlines*2)*sizeof(float*)); 79 | for (j=0;j<=nlines+1;j++) 80 | sw0[j] = (float *) malloc((npixels+1)*sizeof(float)); 81 | sdp0 = (float **) malloc((nlines*2)*sizeof(float*)); 82 | for (j=0;j<=nlines+1;j++) 83 | sdp0[j] = (float *) malloc((npixels+1)*sizeof(float)); 84 | 85 | nppy0 = (float **) malloc(361*sizeof(float)); 86 | for (j=0;j<=181;j++) 87 | nppy0[j] = (float *) malloc(361*sizeof(float)); 88 | laiy0 = (float **) malloc(361*sizeof(float)); 89 | for (j=0;j<=181;j++) 90 | laiy0[j] = (float *) malloc(361*sizeof(float)); 91 | 92 | Ccd0 = (float **) malloc(361*sizeof(float)); 93 | for (j=0;j<=181;j++) 94 | Ccd0[j] = (float *) malloc(361*sizeof(float)); 95 | Cssd0 = (float **) malloc(361*sizeof(float)); 96 | for (j=0;j<=181;j++) 97 | Cssd0[j] = (float *) malloc(361*sizeof(float)); 98 | Csmd0 = (float **) malloc(361*sizeof(float)); 99 | for (j=0;j<=181;j++) 100 | Csmd0[j] = (float *) malloc(361*sizeof(float)); 101 | Cfsd0 = (float **) malloc(361*sizeof(float)); 102 | for (j=0;j<=181;j++) 103 | Cfsd0[j] = (float *) malloc(361*sizeof(float)); 104 | Cfmd0 = (float **) malloc(361*sizeof(float)); 105 | for (j=0;j<=181;j++) 106 | Cfmd0[j] = (float *) malloc(361*sizeof(float)); 107 | Csm0 = (float **) malloc(361*sizeof(float)); 108 | for (j=0;j<=181;j++) 109 | Csm0[j] = (float *) malloc(361*sizeof(float)); 110 | Cm0 = (float **) malloc(361*sizeof(float)); 111 | for (j=0;j<=181;j++) 112 | Cm0[j] = (float *) malloc(361*sizeof(float)); 113 | Cs0 = (float **) malloc(361*sizeof(float)); 114 | for (j=0;j<=181;j++) 115 | Cs0[j] = (float *) malloc(361*sizeof(float)); 116 | Cp0 = (float **) malloc(361*sizeof(float)); 117 | for (j=0;j<=181;j++) 118 | Cp0[j] = (float *) malloc(361*sizeof(float)); 119 | lai0 = (float **) malloc(760*sizeof(float)); 120 | for (j=0;j<=375;j++) 121 | lai0[j] = (float *) malloc(73000*sizeof(float)); 122 | 123 | ann1 = (float **) malloc((nlines*2)*sizeof(float*)); 124 | for (j=0;j<=nlines+1;j++) 125 | ann1[j] = (float *) malloc((npixels+1)*sizeof(float)); 126 | ann2 = (float **) malloc((nlines*2)*sizeof(float*)); 127 | for (j=0;j<=nlines+1;j++) 128 | ann2[j] = (float *) malloc((npixels+1)*sizeof(float)); 129 | ann3 = (float **) malloc((nlines*2)*sizeof(float*)); 130 | for (j=0;j<=nlines+1;j++) 131 | ann3[j] = (float *) malloc((npixels+1)*sizeof(float)); 132 | 133 | 134 | 135 | 136 | /***** Reading input data set 1 *****/ 137 | readinput1(lc0,ci0,stxt0,st0,sw0,sdp0); 138 | 139 | /***** Reading long. lat. values *****/ 140 | readlonlat(lon0,lat0); 141 | 142 | /***** Reading input dataset2 for calulation of respirations *****/ 143 | readinput2(laiy0,nppy0,Ccd0,Cssd0,Csmd0,Cfsd0,Cfmd0,Csm0,Cm0,Cs0,Cp0); 144 | 145 | /***** Read lai data */ 146 | readlai_all(lai0); 147 | 148 | /* open climate data files */ 149 | if ((inR_p=fopen(r_fn, "rb")) == NULL) 150 | { 151 | printf("\n Unable to open r file, exitting ...\n",r_fn); 152 | exit(0); 153 | } 154 | if ((inT_p=fopen(t_fn, "rb")) == NULL) 155 | { 156 | printf("\n Unable to open file <%s>, exitting ...\n",t_fn); 157 | exit(0); 158 | } 159 | if ((inH_p=fopen(h_fn, "rb")) == NULL) 160 | { 161 | printf("\n Unable to open file <%s>, exitting ...\n",h_fn); 162 | exit(0); 163 | } 164 | if ((inP_p=fopen(p_fn, "rb")) == NULL) 165 | { 166 | printf("\n Unable to open file <%s>, exitting ...\n",p_fn); 167 | exit(0); 168 | } 169 | if ((wind_p=fopen(wd_fn, "rb")) == NULL) 170 | { 171 | printf("\n Unable to open file <%s>, exitting ...\n",wd_fn); 172 | exit(0); 173 | } 174 | 175 | 176 | /* Open hourly output file */ 177 | /*sprintf(outp1fn,"%s_%dhr.bin",fp4outp1,yr); 178 | printf("output file name: %s",outp1fn); 179 | sprintf(outp2fn,"%s_%dhr.bin",fp4outp2,yr); 180 | sprintf(outp3fn,"%s_%dhr.bin",fp4outp3,yr); 181 | 182 | if ((outp1_p=fopen(outp1fn, "wb")) == NULL) 183 | { printf("\n Unable to open output1, exitting...\n"); 184 | exit(0); 185 | } 186 | if ((outp2_p=fopen(outp2fn, "wb")) == NULL) 187 | { printf("\n Unable to open output2, exitting ...\n"); 188 | exit(0); 189 | } 190 | if ((outp3_p=fopen(outp3fn, "wb")) == NULL) 191 | { printf("\n Unable to open output3, exitting ...\n"); 192 | exit(0); 193 | } 194 | */ 195 | 196 | 197 | 198 | for (line=0; line Srad = rv*0.1; 359 | meteo->temp = tv*0.1; 360 | meteo->rain = pv*0.0001; 361 | meteo->wind = wv*0.1; 362 | meteo->LR = -200.0; // -200.0 means no measured longwave radiation, the value will be calculated later 363 | 364 | tem = tv*0.1; 365 | hum = hv*0.1; 366 | 367 | /* vapour pressure in mbar */ 368 | //es =0.46*hum*(tem+273.16)/100; 369 | //esd = 6.1078 * exp((17.269*tem)/(237.3 + tem)); 370 | /* Calculating Relative humidity */ 371 | //if (es/esd>=1) meteo->rh = 100; 372 | //else meteo->rh = 100*es/esd; 373 | 374 | meteo->rh = hum; // when reading in relative humidity 375 | 376 | if (lc<=0 || sw<=0 || stxt<=0 || ci<=0.5) // pix without enough data 377 | { 378 | outp[1] = 0; 379 | outp[2] = 0; 380 | outp[3] = 0; 381 | } 382 | else // starting simulation 383 | { 384 | if(jday==bgn_day && rstep==0) // for 1st time step, to initialize var. 385 | { 386 | Init_Soil_Parameters(lc, stxt, parameter[27], soilp); 387 | soilp->r_drainage = parameter[26]; 388 | Init_Soil_Status(soilp, st, tem, sw, snowdepth); 389 | 390 | for (i=0;i<=40;i++) var_o[i] = 0; 391 | for (i=3;i<=8;i++) var_o[i] = tem; 392 | 393 | for(i=9;i<=14;i++) var_o[i] = soilp->temp_soil_p[i-9]; 394 | for(i=21;i<=26;i++) var_o[i] = soilp->thetam_prev[i-21]; 395 | for(i=27;i<=32;i++) var_o[i] = soilp->ice_ratio[i-27]; 396 | } 397 | else // for other time step 398 | for (i=0;i<=40;i++) var_o[i] = v2last[i]; 399 | 400 | /* --- Calculating cos_solar zenith angle Z --- */ 401 | s_coszs(jday,rstep,lat,lon,&CosZs); 402 | 403 | /* --- Running simulation modules --- */ 404 | 405 | inter_prg(jday,rstep,lai,ci,parameter,meteo,CosZs,var_o,var_n,soilp,mid_res); 406 | 407 | for (i=0;i<=40;i++) v2last[i]=var_n[i]; 408 | 409 | 410 | /* --- plant respiration /NPP module --- */ 411 | 412 | plantresp(lc,mid_res,laiy,lai,tem,soilp->temp_soil_c[1],CosZs); 413 | 414 | /* --- soil respiration module --- */ 415 | 416 | soilresp(Ccd,Cssd,Csmd,Cfsd,Cfmd,Csm,Cm,Cs,Cp,nppy,coef,stxt,soilp,mid_res); 417 | 418 | 419 | outp[1] = (float)(mid_res->GPP); 420 | //outp[2]=(float)(mid_res->gpp_o_sunlit+mid_res->gpp_u_sunlit)*12*step*0.000001; 421 | //outp[3]=(float)(mid_res->gpp_o_shaded+mid_res->gpp_u_shaded)*12*step*0.000001; 422 | outp[2] = (float)(mid_res->NPP); 423 | outp[3] = (float)(mid_res->NEP); 424 | 425 | } // end of simulation if lc<0 else 426 | 427 | 428 | /* --- Writing outputs of this time step --- */ 429 | 430 | //fwrite(&outp[1],sizeof(float),1,outp1_p); 431 | //fwrite(&outp[2],sizeof(float),1,outp2_p); 432 | //fwrite(&outp[3],sizeof(float),1,outp3_p); 433 | 434 | total[1]=total[1]+outp[1]; 435 | total[2]=total[2]+outp[2]; 436 | total[3]=total[3]+outp[3]; 437 | 438 | } /* end of rstep - hourly cycle */ 439 | } /* end of for day loop */ 440 | 441 | ann1[line][pix]=total[1]; 442 | ann2[line][pix]=total[2]; 443 | ann3[line][pix]=total[3]; 444 | 445 | } /* end of line/pix loop */ 446 | } 447 | 448 | //fclose(outp1_p); 449 | //fclose(outp2_p); 450 | //fclose(outp3_p); 451 | 452 | 453 | /* --- Writing annual outputs to files (optional) --- */ 454 | 455 | sprintf(outp1fn,"%s_%dann.bin",fp4outp1,yr); 456 | sprintf(outp2fn,"%s_%dann.bin",fp4outp2,yr); 457 | sprintf(outp3fn,"%s_%dann.bin",fp4outp3,yr); 458 | 459 | if ((outp1_p=fopen(outp1fn, "wb")) == NULL) 460 | { printf("\n Unable to open ann. output1, exitting...\n"); 461 | exit(0); 462 | } 463 | if ((outp2_p=fopen(outp2fn, "wb")) == NULL) 464 | { printf("\n Unable to open ann. output2, exitting ...\n"); 465 | exit(0); 466 | } 467 | if ((outp3_p=fopen(outp3fn, "wb")) == NULL) 468 | { printf("\n Unable to open ann. output3, exitting ...\n"); 469 | exit(0); 470 | } 471 | 472 | 473 | for (line=0; line, exitting ...\n",t_fn); 157 | exit(0); 158 | } 159 | if ((inH_p=fopen(h_fn, "rb")) == NULL) 160 | { 161 | printf("\n Unable to open file <%s>, exitting ...\n",h_fn); 162 | exit(0); 163 | } 164 | if ((inP_p=fopen(p_fn, "rb")) == NULL) 165 | { 166 | printf("\n Unable to open file <%s>, exitting ...\n",p_fn); 167 | exit(0); 168 | } 169 | if ((wind_p=fopen(wd_fn, "rb")) == NULL) 170 | { 171 | printf("\n Unable to open file <%s>, exitting ...\n",wd_fn); 172 | exit(0); 173 | } 174 | 175 | 176 | /* Open hourly output file */ 177 | sprintf(outp1fn,"%s_%dhr.bin",fp4outp1,yr); 178 | printf("output file name: %s",outp1fn); 179 | sprintf(outp2fn,"%s_%dhr.bin",fp4outp2,yr); 180 | sprintf(outp3fn,"%s_%dhr.bin",fp4outp3,yr); 181 | 182 | if ((outp1_p=fopen(outp1fn, "wb")) == NULL) 183 | { printf("\n Unable to open output1, exitting...\n"); 184 | exit(0); 185 | } 186 | if ((outp2_p=fopen(outp2fn, "wb")) == NULL) 187 | { printf("\n Unable to open output2, exitting ...\n"); 188 | exit(0); 189 | } 190 | if ((outp3_p=fopen(outp3fn, "wb")) == NULL) 191 | { printf("\n Unable to open output3, exitting ...\n"); 192 | exit(0); 193 | } 194 | 195 | 196 | 197 | 198 | for (line=0; line Srad = rv*0.1; 341 | meteo->temp = tv*0.1; 342 | meteo->rain = pv*0.0001; 343 | meteo->wind = wv*0.1; 344 | meteo->LR = -200.0; // -200.0 means no measured longwave radiation, the value will be calculated later 345 | 346 | tem = tv*0.1; 347 | hum = hv*0.1; 348 | 349 | /* vapour pressure in mbar */ 350 | //es =0.46*hum*(tem+273.16)/100; 351 | //esd = 6.1078 * exp((17.269*tem)/(237.3 + tem)); 352 | /* Calculating Relative humidity */ 353 | //if (es/esd>=1) meteo->rh = 100; 354 | //else meteo->rh = 100*es/esd; 355 | 356 | meteo->rh = hum; // when reading in relative humidity 357 | 358 | if (lc<=0 || sw<=0 || stxt<=0 || ci<=0.5) // pix without enough data 359 | { 360 | outp[1] = 0; 361 | outp[2] = 0; 362 | outp[3] = 0; 363 | } 364 | else // starting simulation 365 | { 366 | if(jday==bgn_day && rstep==0) // for 1st time step, to initialize var. 367 | { 368 | Init_Soil_Parameters(lc, stxt, parameter[27], soilp); 369 | soilp->r_drainage = parameter[26]; 370 | Init_Soil_Status(soilp, st, tem, sw, snowdepth); 371 | 372 | for (i=0;i<=40;i++) var_o[i] = 0; 373 | for (i=3;i<=8;i++) var_o[i] = tem; 374 | 375 | for(i=9;i<=14;i++) var_o[i] = soilp->temp_soil_p[i-9]; 376 | for(i=21;i<=26;i++) var_o[i] = soilp->thetam_prev[i-21]; 377 | for(i=27;i<=32;i++) var_o[i] = soilp->ice_ratio[i-27]; 378 | } 379 | else // for other time step 380 | for (i=0;i<=40;i++) var_o[i] = v2last[i]; 381 | 382 | /* --- Calculating cos_solar zenith angle Z --- */ 383 | s_coszs(jday,rstep,lat,lon,&CosZs); 384 | 385 | /* --- Running simulation modules --- */ 386 | 387 | inter_prg(jday,rstep,lai,ci,parameter,meteo,CosZs,var_o,var_n,soilp,mid_res); 388 | 389 | for (i=0;i<=40;i++) v2last[i]=var_n[i]; 390 | 391 | 392 | /* --- plant respiration /NPP module --- */ 393 | 394 | plantresp(lc,mid_res,laiy,lai,tem,soilp->temp_soil_c[1],CosZs); 395 | 396 | /* --- soil respiration module --- */ 397 | 398 | soilresp(Ccd,Cssd,Csmd,Cfsd,Cfmd,Csm,Cm,Cs,Cp,nppy,coef,stxt,soilp,mid_res); 399 | 400 | 401 | outp[1] = (float)(mid_res->GPP); 402 | //outp[2]=(float)(mid_res->gpp_o_sunlit+mid_res->gpp_u_sunlit)*12*step*0.000001; 403 | //outp[3]=(float)(mid_res->gpp_o_shaded+mid_res->gpp_u_shaded)*12*step*0.000001; 404 | outp[2] = (float)(mid_res->SIF); 405 | //outp[3] = (float)(mid_res->NEP); 406 | 407 | } // end of simulation if lc<0 else 408 | 409 | 410 | /* --- Writing outputs of this time step --- */ 411 | 412 | fwrite(&outp[1],sizeof(float),1,outp1_p); 413 | fwrite(&outp[2],sizeof(float),1,outp2_p); 414 | //fwrite(&outp[3],sizeof(float),1,outp3_p); 415 | 416 | total[1]=total[1]+outp[1]; 417 | total[2]=total[2]+outp[2]; 418 | total[3]=total[3]+outp[3]; 419 | 420 | } /* end of rstep - hourly cycle */ 421 | } /* end of for day loop */ 422 | 423 | ann1[line][pix]=total[1]; 424 | ann2[line][pix]=total[2]; 425 | ann3[line][pix]=total[3]; 426 | 427 | } /* end of line/pix loop */ 428 | } 429 | 430 | fclose(outp1_p); 431 | fclose(outp2_p); 432 | //fclose(outp3_p); 433 | 434 | 435 | /* --- Writing annual outputs to files (optional) --- */ 436 | 437 | /*sprintf(outp1fn,"%s_%dann.bin",fp4outp1,yr); 438 | sprintf(outp2fn,"%s_%dann.bin",fp4outp2,yr); 439 | sprintf(outp3fn,"%s_%dann.bin",fp4outp3,yr); 440 | 441 | if ((outp1_p=fopen(outp1fn, "wb")) == NULL) 442 | { printf("\n Unable to open ann. output1, exitting...\n"); 443 | exit(0); 444 | } 445 | if ((outp2_p=fopen(outp2fn, "wb")) == NULL) 446 | { printf("\n Unable to open ann. output2, exitting ...\n"); 447 | exit(0); 448 | } 449 | if ((outp3_p=fopen(outp3fn, "wb")) == NULL) 450 | { printf("\n Unable to open ann. output3, exitting ...\n"); 451 | exit(0); 452 | } 453 | 454 | 455 | for (line=0; line0.02) *percent_snow_g=1; 61 | else *percent_snow_g=(*mass_snow_g)/(0.025*density_snow); 62 | *percent_snow_g=max(*percent_snow_g,0); 63 | *percent_snow_g=min(*percent_snow_g,1); 64 | 65 | // when there are pond water on ground, there is evaporation from the water 66 | if (*depth_water>0 && *depth_snow == 0) 67 | { 68 | *evapo_water_g=1/(latent_water )*(slope_vapor_g *(netRad_g*0.8-0)+density_air_g *cp_air_g *vpd_g*Gheat_g)/(slope_vapor_g+psy_air_g*(1+(Gheat_g)/0.01)); 69 | } 70 | else 71 | { 72 | *evapo_water_g = 0; 73 | } 74 | //*evapo_water_g = max(-0.002/length_step,*evapo_water_g); 75 | *evapo_water_g = max(0,*evapo_water_g); 76 | if(*evapo_water_g >0) *evapo_water_g =min(*evapo_water_g,(*depth_water)*density_water/length_step); 77 | 78 | *depth_water=*depth_water-(*evapo_water_g)/density_water*length_step; 79 | *depth_water=max(0,*depth_water); 80 | *mass_water_g=*mass_water_g-(*evapo_water_g)*length_step; 81 | // 82 | // // when there are snow on ground, there is only evaporation from the snow 83 | if (*depth_snow >0) 84 | { 85 | *evapo_snow_g=1/(latent_snow )*(slope_vapor_g *(netRad_g*0.8-0)+density_air_g *cp_air_g *vpd_g*Gheat_g)/(slope_vapor_g+psy_air_g*(1+(Gheat_g)/0.01))*(*percent_snow_g); 86 | } 87 | else 88 | { 89 | *evapo_snow_g = 0; 90 | } 91 | //*evapo_snow_g = max(-0.002/length_step,*evapo_snow_g); 92 | *evapo_snow_g = max(0,*evapo_snow_g); 93 | if(*evapo_snow_g >0) *evapo_snow_g =min(*evapo_snow_g,*mass_snow_g/length_step); 94 | 95 | *mass_snow_g=*mass_snow_g-(*evapo_snow_g)*length_step; 96 | *mass_snow_g=max(*mass_snow_g,0); 97 | 98 | if(*mass_snow_g>0) 99 | *depth_snow=*depth_snow-(*evapo_snow_g)/density_snow*length_step; 100 | else 101 | *depth_snow=0; 102 | // 103 | // 104 | // // if evaporation from pond and snow have not consumed all energy, then no evaporation from soil surface 105 | // //change_depth_water=(*evapo_water_g/density_water); 106 | // //change_depth_snow=(*evapo_snow_g/density_snow); 107 | 108 | // 109 | if ( *depth_water >0 || *depth_snow >0 ) 110 | *evapo_soil=0; 111 | else 112 | { 113 | *evapo_soil=(1-(*percent_snow_g))*1/(latent_water )*(slope_vapor_g*(netRad_g-0)+density_air_g*cp_air_g*vpd_g*Gheat_g)/(slope_vapor_g +psy_air_g*(1 + Gheat_g/Gwater_g)); 114 | *evapo_soil = max(0,*evapo_soil); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /BEPS-SIF/init_soil.c: -------------------------------------------------------------------------------- 1 | #include "soil.h" 2 | #include 3 | 4 | // Liming He 5 | // June 2, 2015 6 | 7 | // function: 8 | // (1) set the depth for each layer 9 | // (2) set the parameters for each layer 10 | 11 | void Init_Soil_Parameters(int landcover, int stxt, double r_root_decay, struct Soil p[]) 12 | { 13 | p->n_layer = 5; 14 | 15 | if (landcover == 6 || landcover == 9) 16 | { 17 | p->psi_min = 10.0; 18 | p->alpha = 1.5; 19 | } 20 | else 21 | { 22 | p->psi_min = 33.0; 23 | p->alpha = 0.4; 24 | } 25 | 26 | p->d_soil[0] = 0.05; /* depth_layer0 */ 27 | p->d_soil[1] = 0.10; /* depth_layer1 */ 28 | p->d_soil[2] = 0.20; /* depth_layer2 */ 29 | p->d_soil[3] = 0.40; /* depth_layer3 */ 30 | p->d_soil[4] = 1.25; /* depth_layer4 */ 31 | 32 | p->r_root_decay = r_root_decay; 33 | SoilRootFraction(p); 34 | 35 | p->density_soil[0] = 1300.0; // from flux tower. 36 | p->density_soil[1] = 1500.0; 37 | p->density_soil[2] = 1517.0; 38 | p->density_soil[3] = 1517.0; 39 | p->density_soil[4] = 1517.0; 40 | 41 | p->f_org[0] = 5; 42 | p->f_org[1] = 2; 43 | p->f_org[2] = 1; 44 | p->f_org[3] = 1; 45 | p->f_org[4] = 0.3; 46 | 47 | 48 | 49 | switch (stxt) 50 | { 51 | case 1: //sand 52 | p->b[0] = 1.7; p->b[1] = 1.9; p->b[2] = 2.1; p->b[3] = 2.3; p->b[4] = 2.5; 53 | p->Ksat[0] = 0.000058; p->Ksat[1] = 0.000052; p->Ksat[2] = 0.000046; p->Ksat[3] = 0.000035; p->Ksat[4] = 0.000010; /* saturated hydraulic conductivity */ 54 | p->fei[0] = 0.437; p->fei[1] = 0.437; p->fei[2] = 0.437; p->fei[3] = 0.437; p->fei[4] = 0.437; /* porosity */ 55 | p->theta_vfc[0] = 0.09; p->theta_vfc[1] = 0.09; p->theta_vfc[2] = 0.09; p->theta_vfc[3] = 0.09; p->theta_vfc[4] = 0.09; /* field capacity */ 56 | p->theta_vwp[0] = 0.03; p->theta_vwp[1] = 0.03; p->theta_vwp[2] = 0.03; p->theta_vwp[3] = 0.03; p->theta_vwp[4] = 0.03; /* wilt point*/ 57 | p->thermal_cond[0] = 8.6; p->thermal_cond[1] = 8.6; p->thermal_cond[2] = 8.6; p->thermal_cond[3] = 8.6; p->thermal_cond[4] = 8.6; /* thermal conductivity */ 58 | p->psi_sat[0] = 0.07; p->psi_sat[1] = 0.08; p->psi_sat[2] = 0.09; p->psi_sat[3] = 0.10; p->psi_sat[4] = 0.12; /* water potential at sat */ 59 | break; 60 | 61 | case 2: //loamy sand 62 | p->b[0] = 2.1; p->b[1] = 2.3; p->b[2] = 2.5; p->b[3] = 2.7; p->b[4] = 2.9; 63 | p->Ksat[0] = 0.000017; p->Ksat[1] = 0.000015; p->Ksat[2] = 0.000014; p->Ksat[3] = 0.000010; p->Ksat[4] = 0.000003; 64 | p->fei[0] = 0.437; p->fei[1] = 0.437; p->fei[2] = 0.437; p->fei[3] = 0.437; p->fei[4] = 0.437; 65 | p->theta_vfc[0] = 0.21; p->theta_vfc[1] = 0.21; p->theta_vfc[2] = 0.21; p->theta_vfc[3] = 0.21; p->theta_vfc[4] = 0.21; 66 | p->theta_vwp[0] = 0.06; p->theta_vwp[1] = 0.06; p->theta_vwp[2] = 0.06; p->theta_vwp[3] = 0.06; p->theta_vwp[4] = 0.06; 67 | p->thermal_cond[0] = 8.3; p->thermal_cond[1] = 8.3; p->thermal_cond[2] = 8.3; p->thermal_cond[3] = 8.3; p->thermal_cond[4] = 8.3; 68 | p->psi_sat[0] = 0.09; p->psi_sat[1] = 0.10; p->psi_sat[2] = 0.11; p->psi_sat[3] = 0.12; p->psi_sat[4] = 0.14; 69 | break; 70 | 71 | case 3: // sandy loam 72 | p->b[0] = 3.1; p->b[1] = 3.3; p->b[2] = 3.5; p->b[3] = 3.7; p->b[4] = 3.9; 73 | p->Ksat[0] = 0.0000072; p->Ksat[1] = 0.00000648; p->Ksat[2] = 0.00000576; p->Ksat[3] = 0.00000432; p->Ksat[4] = 0.00000144; 74 | p->fei[0] = 0.453; p->fei[1] = 0.453; p->fei[2] = 0.453; p->fei[3] = 0.453; p->fei[4] = 0.453; 75 | p->theta_vfc[0] = 0.21; p->theta_vfc[1] = 0.21; p->theta_vfc[2] = 0.21; p->theta_vfc[3] = 0.21; p->theta_vfc[4] = 0.21; 76 | p->theta_vwp[0] = 0.10; p->theta_vwp[1] = 0.10; p->theta_vwp[2] = 0.10; p->theta_vwp[3] = 0.10; p->theta_vwp[4] = 0.10; 77 | p->thermal_cond[0] = 8.0; p->thermal_cond[1] = 8.0; p->thermal_cond[2] = 8.0; p->thermal_cond[3] = 8.0; p->thermal_cond[4] = 8.0; 78 | p->psi_sat[0] = 0.15; p->psi_sat[1] = 0.16; p->psi_sat[2] = 0.17; p->psi_sat[3] = 0.18; p->psi_sat[4] = 0.20; 79 | break; 80 | 81 | case 4: // loam 82 | p->b[0] = 4.5; p->b[1] = 4.7; p->b[2] = 4.9; p->b[3] = 5.1; p->b[4] = 5.3; 83 | p->Ksat[0] = 0.0000037; p->Ksat[1] = 0.0000033; p->Ksat[2] = 0.00000296; p->Ksat[3] = 0.00000222; p->Ksat[4] = 0.00000074; 84 | p->fei[0] = 0.463; p->fei[1] = 0.463; p->fei[2] = 0.463; p->fei[3] = 0.463; p->fei[4] = 0.463; 85 | p->theta_vfc[0] = 0.27; p->theta_vfc[1] = 0.27; p->theta_vfc[2] = 0.27; p->theta_vfc[3] = 0.27; p->theta_vfc[4] = 0.27; 86 | p->theta_vwp[0] = 0.12; p->theta_vwp[1] = 0.12; p->theta_vwp[2] = 0.12; p->theta_vwp[3] = 0.12; p->theta_vwp[4] = 0.12; 87 | p->thermal_cond[0] = 7.0; p->thermal_cond[1] = 7.0; p->thermal_cond[2] = 7.0; p->thermal_cond[3] = 7.0; p->thermal_cond[4] = 7.0; 88 | p->psi_sat[0] = 0.11; p->psi_sat[1] = 0.12; p->psi_sat[2] = 0.13; p->psi_sat[3] = 0.14; p->psi_sat[4] = 0.16; 89 | break; 90 | 91 | case 5: // silty loam 92 | p->b[0] = 4.7; p->b[1] = 4.9; p->b[2] = 5.1; p->b[3] = 5.3; p->b[4] = 5.5; 93 | p->Ksat[0] = 0.0000019; p->Ksat[1] = 0.0000017; p->Ksat[2] = 0.00000152; p->Ksat[3] = 0.00000114; p->Ksat[4] = 0.00000038; 94 | p->fei[0] = 0.501; p->fei[1] = 0.501; p->fei[2] = 0.501; p->fei[3] = 0.501; p->fei[4] = 0.501; 95 | p->theta_vfc[0] = 0.33; p->theta_vfc[1] = 0.33; p->theta_vfc[2] = 0.33; p->theta_vfc[3] = 0.33; p->theta_vfc[4] = 0.33; 96 | p->theta_vwp[0] = 0.13; p->theta_vwp[1] = 0.13; p->theta_vwp[2] = 0.13; p->theta_vwp[3] = 0.13; p->theta_vwp[4] = 0.13; 97 | p->thermal_cond[0] = 6.3; p->thermal_cond[1] = 6.3; p->thermal_cond[2] = 6.3; p->thermal_cond[3] = 6.3; p->thermal_cond[4] = 6.3; 98 | p->psi_sat[0] = 0.21; p->psi_sat[1] = 0.22; p->psi_sat[2] = 0.23; p->psi_sat[3] = 0.24; p->psi_sat[4] = 0.26; 99 | break; 100 | 101 | case 6: // sandy caly loam 102 | p->b[0] = 4.0; p->b[1] = 4.2; p->b[2] = 4.4; p->b[3] = 4.6; p->b[4] = 4.8; 103 | p->Ksat[0] = 0.0000012; p->Ksat[1] = 0.00000108; p->Ksat[2] = 0.0000096; p->Ksat[3] = 0.0000072; p->Ksat[4] = 0.0000024; 104 | p->fei[0] = 0.398; p->fei[1] = 0.398; p->fei[2] = 0.398; p->fei[3] = 0.398; p->fei[4] = 0.398; 105 | p->theta_vfc[0] = 0.26; p->theta_vfc[1] = 0.26; p->theta_vfc[2] = 0.26; p->theta_vfc[3] = 0.26; p->theta_vfc[4] = 0.26; 106 | p->theta_vwp[0] = 0.15; p->theta_vwp[1] = 0.15; p->theta_vwp[2] = 0.15; p->theta_vwp[3] = 0.15; p->theta_vwp[4] = 0.15; 107 | p->thermal_cond[0] = 7.0; p->thermal_cond[1] = 7.0; p->thermal_cond[2] = 7.0; p->thermal_cond[3] = 7.0; p->thermal_cond[4] = 7.0; 108 | p->psi_sat[0] = 0.28; p->psi_sat[1] = 0.29; p->psi_sat[2] = 0.30; p->psi_sat[3] = 0.31; p->psi_sat[4] = 0.33; 109 | break; 110 | 111 | 112 | case 7: // clay loam 113 | p->b[0] = 5.2; p->b[1] = 5.4; p->b[2] = 5.6; p->b[3] = 5.8; p->b[4] = 6.0; 114 | p->Ksat[0] = 0.00000064; p->Ksat[1] = 0.00000058; p->Ksat[2] = 0.00000051; p->Ksat[3] = 0.00000038; p->Ksat[4] = 0.00000013; 115 | p->fei[0] = 0.464; p->fei[1] = 0.464; p->fei[2] = 0.464; p->fei[3] = 0.464; p->fei[4] = 0.464; 116 | p->theta_vfc[0] = 0.32; p->theta_vfc[1] = 0.32; p->theta_vfc[2] = 0.32; p->theta_vfc[3] = 0.32; p->theta_vfc[4] = 0.32; 117 | p->theta_vwp[0] = 0.20; p->theta_vwp[1] = 0.20; p->theta_vwp[2] = 0.20; p->theta_vwp[3] = 0.20; p->theta_vwp[4] = 0.20; 118 | p->thermal_cond[0] = 5.8; p->thermal_cond[1] = 5.8; p->thermal_cond[2] = 5.7; p->thermal_cond[3] = 5.8; p->thermal_cond[4] = 5.8; 119 | p->psi_sat[0] = 0.26; p->psi_sat[1] = 0.27; p->psi_sat[2] = 0.28; p->psi_sat[3] = 0.29; p->psi_sat[4] = 0.31; 120 | break; 121 | 122 | case 8: // silty clay loam 123 | p->b[0] = 6.6; p->b[1] = 6.8; p->b[2] = 7.0; p->b[3] = 7.2; p->b[4] = 7.4; 124 | p->Ksat[0] = 0.00000042; p->Ksat[1] = 0.00000038; p->Ksat[2] = 0.00000034; p->Ksat[3] = 0.000000252; p->Ksat[4] = 0.000000084; 125 | p->fei[0] = 0.471; p->fei[1] = 0.471; p->fei[2] = 0.471; p->fei[3] = 0.471; p->fei[4] = 0.471; 126 | p->theta_vfc[0] = 0.37; p->theta_vfc[1] = 0.37; p->theta_vfc[2] = 0.37; p->theta_vfc[3] = 0.37; p->theta_vfc[4] = 0.37; 127 | p->theta_vwp[0] = 0.32; p->theta_vwp[1] = 0.32; p->theta_vwp[2] = 0.32; p->theta_vwp[3] = 0.32; p->theta_vwp[4] = 0.32; 128 | p->thermal_cond[0] = 4.2; p->thermal_cond[1] = 4.2; p->thermal_cond[2] = 4.2; p->thermal_cond[3] = 4.2; p->thermal_cond[4] = 4.2; 129 | p->psi_sat[0] = 0.33; p->psi_sat[1] = 0.34; p->psi_sat[2] = 0.35; p->psi_sat[3] = 0.36; p->psi_sat[4] = 0.38; 130 | break; 131 | 132 | 133 | case 9: // sandy clay 134 | p->b[0] = 6.0; p->b[1] = 6.2; p->b[2] = 6.4; p->b[3] = 6.6; p->b[4] = 6.8; 135 | p->Ksat[0] = 0.00000033; p->Ksat[1] = 0.0000003; p->Ksat[2] = 0.000000264; p->Ksat[3] = 0.000000198; p->Ksat[4] = 0.000000066; 136 | p->fei[0] = 0.430; p->fei[1] = 0.430; p->fei[2] = 0.430; p->fei[3] = 0.430; p->fei[4] = 0.430; 137 | p->theta_vfc[0] = 0.34; p->theta_vfc[1] = 0.34; p->theta_vfc[2] = 0.34; p->theta_vfc[3] = 0.34; p->theta_vfc[4] = 0.34; 138 | p->theta_vwp[0] = 0.24; p->theta_vwp[1] = 0.24; p->theta_vwp[2] = 0.24; p->theta_vwp[3] = 0.24; p->theta_vwp[4] = 0.24; 139 | p->thermal_cond[0] = 6.3; p->thermal_cond[1] = 6.3; p->thermal_cond[2] = 6.3; p->thermal_cond[3] = 6.3; p->thermal_cond[4] = 6.3; 140 | p->psi_sat[0] = 0.29; p->psi_sat[1] = 0.30; p->psi_sat[2] = 0.31; p->psi_sat[3] = 0.32; p->psi_sat[4] = 0.34; 141 | break; 142 | 143 | case 10: // silty clay 144 | p->b[0] = 7.9; p->b[1] = 8.1; p->b[2] = 8.3; p->b[3] = 8.5; p->b[4] = 8.7; 145 | p->Ksat[0] = 0.00000025; p->Ksat[1] = 0.000000225; p->Ksat[2] = 0.0000002; p->Ksat[3] = 0.00000015; p->Ksat[4] = 0.00000005; 146 | p->fei[0] = 0.479; p->fei[1] = 0.479; p->fei[2] = 0.479; p->fei[3] = 0.479; p->fei[4] = 0.479; 147 | p->theta_vfc[0] = 0.39; p->theta_vfc[1] = 0.39; p->theta_vfc[2] = 0.39; p->theta_vfc[3] = 0.39; p->theta_vfc[4] = 0.39; 148 | p->theta_vwp[0] = 0.25; p->theta_vwp[1] = 0.25; p->theta_vwp[2] = 0.25; p->theta_vwp[3] = 0.25; p->theta_vwp[4] = 0.25; 149 | p->thermal_cond[0] = 4.0; p->thermal_cond[1] = 4.0; p->thermal_cond[2] = 4.0; p->thermal_cond[3] = 4.0; p->thermal_cond[4] = 4.0; 150 | p->psi_sat[0] = 0.34; p->psi_sat[1] = 0.35; p->psi_sat[2] = 0.36; p->psi_sat[3] = 0.37; p->psi_sat[4] = 0.39; 151 | break; 152 | 153 | case 11: // clay 154 | p->b[0] = 7.6; p->b[1] = 7.8; p->b[2] = 8.0; p->b[3] = 8.2; p->b[4] = 8.4; 155 | p->Ksat[0] = 0.00000017; p->Ksat[1] = 0.000000153; p->Ksat[2] = 0.000000136; p->Ksat[3] = 0.000000102; p->Ksat[4] = 0.000000034; 156 | p->fei[0] = 0.475; p->fei[1] = 0.475; p->fei[2] = 0.475; p->fei[3] = 0.475; p->fei[4] = 0.475; 157 | p->theta_vfc[0] = 0.40; p->theta_vfc[1] = 0.40; p->theta_vfc[2] = 0.40; p->theta_vfc[3] = 0.40; p->theta_vfc[4] = 0.40; 158 | p->theta_vwp[0] = 0.27; p->theta_vwp[1] = 0.27; p->theta_vwp[2] = 0.27; p->theta_vwp[3] = 0.27; p->theta_vwp[4] = 0.27; 159 | p->thermal_cond[0] = 4.4; p->thermal_cond[1] = 4.4; p->thermal_cond[2] = 4.4; p->thermal_cond[3] = 4.4; p->thermal_cond[4] = 4.4; 160 | p->psi_sat[0] = 0.37; p->psi_sat[1] = 0.38; p->psi_sat[2] = 0.39; p->psi_sat[3] = 0.40; p->psi_sat[4] = 0.42; 161 | break; 162 | 163 | default: 164 | p->b[0] = 7.6; p->b[1] = 7.8; p->b[2] = 8.0; p->b[3] = 8.2; p->b[4] = 8.4; 165 | p->Ksat[0] = 0.00000017; p->Ksat[1] = 0.000000153; p->Ksat[2] = 0.000000136; p->Ksat[3] = 0.000000102; p->Ksat[4] = 0.000000034; 166 | p->fei[0] = 0.475; p->fei[1] = 0.475; p->fei[2] = 0.475; p->fei[3] = 0.475; p->fei[4] = 0.475; 167 | p->theta_vfc[0] = 0.40; p->theta_vfc[1] = 0.40; p->theta_vfc[2] = 0.40; p->theta_vfc[3] = 0.40; p->theta_vfc[4] = 0.40; 168 | p->theta_vwp[0] = 0.27; p->theta_vwp[1] = 0.27; p->theta_vwp[2] = 0.27; p->theta_vwp[3] = 0.27; p->theta_vwp[4] = 0.27; 169 | p->thermal_cond[0] = 4.4; p->thermal_cond[1] = 4.4; p->thermal_cond[2] = 4.4; p->thermal_cond[3] = 4.4; p->thermal_cond[4] = 4.4; 170 | p->psi_sat[0] = 0.37; p->psi_sat[1] = 0.38; p->psi_sat[2] = 0.39; p->psi_sat[3] = 0.40; p->psi_sat[4] = 0.42; 171 | 172 | } 173 | 174 | } 175 | 176 | 177 | // Init. the soil status: 178 | // soil temperatures and moistures for each layer. 179 | // ponded water, snow depth et al. 180 | 181 | // Liming He, Jun. 2, 2015 182 | 183 | void Init_Soil_Status(struct Soil p[], double Tsoil, double Tair, double Ms, double snowdepth) 184 | { 185 | int i; 186 | double d_t = Tsoil - Tair; 187 | 188 | p->Zp = 0.0; /* depth of ponded water on the surface*/ 189 | p->Zsp = snowdepth; /*Snow depth;*/ 190 | p->r_rain_g = 0.0; /*the rainfall rate, un--on understory g--on ground surface m/s */ 191 | 192 | 193 | if (d_t>5.0) d_t = 5.0; 194 | if (d_t<-5.0) d_t = -5.0; 195 | 196 | p->temp_soil_c[0] = Tair + 0.4*d_t; 197 | p->temp_soil_c[1] = Tair + 0.5*d_t; 198 | p->temp_soil_c[2] = Tair + d_t; 199 | p->temp_soil_c[3] = Tair + 1.2*d_t; 200 | p->temp_soil_c[4] = Tair + 1.4*d_t; 201 | 202 | p->temp_soil_p[0] = Tair + 0.4*d_t; 203 | p->temp_soil_p[1] = Tair + 0.5*d_t; 204 | p->temp_soil_p[2] = Tair + d_t; 205 | p->temp_soil_p[3] = Tair + 1.2*d_t; 206 | p->temp_soil_p[4] = Tair + 1.4*d_t; 207 | 208 | //p->thetam[0] = 0.75*Ms; 209 | p->thetam[0] = 0.8*Ms; 210 | p->thetam[1] = Ms; 211 | p->thetam[2] = 1.05*Ms; 212 | p->thetam[3] = 1.10*Ms; 213 | p->thetam[4] = 1.15*Ms; 214 | 215 | //p->thetam_prev[0] = 0.75*Ms; 216 | p->thetam_prev[0] = 0.8*Ms; 217 | p->thetam_prev[1] = Ms; 218 | p->thetam_prev[2] = 1.05*Ms; 219 | p->thetam_prev[3] = 1.10*Ms; 220 | p->thetam_prev[4] = 1.15*Ms; 221 | 222 | for (i = 0; i < p->n_layer; i++) 223 | { 224 | if (p->temp_soil_c[i]<-1.0) 225 | p->ice_ratio[i] = 1.0; 226 | else if (p->temp_soil_c[i]>0) 227 | p->ice_ratio[i] = 0; 228 | else 229 | p->ice_ratio[i] = (0 - p->temp_soil_c[i]) / 1.0; 230 | } 231 | } 232 | 233 | // funtion rewritten by LHE. Jan 31, 2013. 234 | // Last revision: May 16, 2015 235 | // This function calculates the fraction of root in the soil for each soil layer. 236 | 237 | void SoilRootFraction(struct Soil soil[]) 238 | { 239 | int i; 240 | double cum_depth[MAX_LAYERS]; 241 | 242 | // for the 0 layer 243 | cum_depth[0] = soil->d_soil[0]; 244 | soil->f_root[0] = 1 - pow(soil->r_root_decay, cum_depth[0] * 100); 245 | 246 | // for 1 to n_layer-1 247 | for (i = 1; i < soil->n_layer - 1; i++) 248 | { 249 | cum_depth[i] = cum_depth[i - 1] + soil->d_soil[i]; 250 | soil->f_root[i] = pow(soil->r_root_decay, cum_depth[i - 1] * 100) - pow(soil->r_root_decay, cum_depth[i] * 100); 251 | } 252 | 253 | // for the last layer. Put all reminding roots to the last layer. 254 | // soil->Layer[layer].f_root = 1 - (1-pow(soil->r_root_decay, cum_depth[i-1] *100)); 255 | soil->f_root[soil->n_layer - 1] = pow(soil->r_root_decay, cum_depth[soil->n_layer - 2] * 100); 256 | } 257 | -------------------------------------------------------------------------------- /BEPS-SIF/lai_calc.c: -------------------------------------------------------------------------------- 1 | #include "beps.h" 2 | 3 | 4 | //Bin Chen: 30/05/2015 5 | 6 | void lai2(stem_o,stem_u,LC,CosZs,GMU,lai_o,clumping,lai_u,lai_o_sunlit,lai_o_shaded,lai_u_sunlit,lai_u_shaded,PAI_o_sunlit,PAI_o_shaded,PAI_u_sunlit,PAI_u_shaded) 7 | 8 | double stem_o; // overstory woody area 9 | double stem_u; // understory woody area 10 | int LC; // landcover type 11 | double CosZs; // cosine solar zenith angle 12 | double lai_o; // overstory lai 13 | double GMU; 14 | double clumping; // clumping index 15 | double lai_u; // understory lai 16 | double *lai_o_sunlit; // overstory sunlit lai 17 | double *lai_o_shaded; // overstory shaded lai 18 | double *lai_u_sunlit ; // understory sunlit lai 19 | double *lai_u_shaded; // understory shaded lai 20 | 21 | double *PAI_o_sunlit ; // overstory sunlit lai 22 | double *PAI_o_shaded ; // overstory shaded lai 23 | double *PAI_u_sunlit ; // understory sunlit lai 24 | double *PAI_u_shaded ; // understory shaded lai 25 | 26 | { 27 | if(CosZs>0) 28 | *PAI_o_sunlit =2*CosZs*(1-exp(-GMU*clumping*(lai_o+stem_o)/CosZs)); 29 | else 30 | *PAI_o_sunlit =0; 31 | 32 | *PAI_o_shaded =(lai_o+stem_o)-*PAI_o_sunlit ; 33 | 34 | if(CosZs>0) 35 | *PAI_u_sunlit =2*CosZs*(1-exp(-GMU*clumping*(lai_o+stem_o+lai_u+stem_u)/CosZs))-*PAI_o_sunlit ; 36 | else 37 | *PAI_u_sunlit =0; 38 | 39 | *PAI_u_shaded =(lai_u+stem_u)-*PAI_u_sunlit ; 40 | 41 | if(CosZs>0) 42 | *lai_o_sunlit=2*CosZs*(1-exp(-GMU*clumping*lai_o/CosZs)); 43 | else 44 | *lai_o_sunlit=0; 45 | 46 | *lai_o_shaded=max(0,lai_o-*PAI_o_sunlit ); 47 | 48 | if(CosZs>0) 49 | *lai_u_sunlit =2*CosZs*(1-exp(-GMU*clumping*(lai_o+lai_u)/CosZs))-*lai_o_sunlit; 50 | else 51 | *lai_u_sunlit =0; 52 | 53 | *lai_u_shaded=max(0,lai_u-*PAI_u_sunlit ); 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /BEPS-SIF/makefile: -------------------------------------------------------------------------------- 1 | # beps.make 2 | # make file to compile beps program 3 | 4 | # CFLAGS=-std=c99 -O3 5 | CFLAGS=-std=c99 -g 6 | 7 | # first name a variable objects for all object files 8 | objects = aerodynamic_conductance.o beps401b_glb_hr.o calc_temp_leaf.o \ 9 | inter_prg.o evaporation_canopy.o evaporation_soil.o init_soil.o \ 10 | lai_calc.o meteo_pack.o netRadiation.o photosyn_gs.o \ 11 | rainfall.o readparam_l.o s_coszs.o plant_respir_l.o\ 12 | sensible_heat.o snowpack.o soil_thermal_regime.o \ 13 | soil_water_stress.o surface_temp.o soilresp.o\ 14 | transpiration.o updatesoilmoisture.o vcmax_jmax_mod.o \ 15 | readcontrolf_b.o readlonlat.o read_yrdata_c.o read_input2.o readcoef_l.o read_all_lai.o 16 | 17 | # name a variable sources for all source files 18 | sources = aerodynamic_conductance.c beps401b_glb_hr.c calc_temp_leaf.c \ 19 | inter_prg.c evaporation_canopy.c evaporation_soil.c init_soil.c \ 20 | lai_calc.c meteo_pack.c netRadiation.c photosyn_gs.c \ 21 | rainfall.c readparam_l.c s_coszs.c plant_respir_l.c\ 22 | sensible_heat.c snowpack.c soil_thermal_regime.c \ 23 | soil_water_stress.c surface_temp.c soilresp.c\ 24 | transpiration.c updatesoilmoisture.c vcmax_jmax_mod.c \ 25 | readcontrolf_b.c readlonlat.c read_yrdata_c.c read_input2.c readcoef_l.c read_all_lai.c 26 | 27 | # now give target as makebeps with objects as variable dependencies + command line 28 | 29 | beps: $(objects) 30 | # icc -g -lm -o bepsb $(objects) 31 | gcc $(CFLAGS) -o bepsb $(objects) -lm 32 | 33 | # list the dependencies for object files - those header files which help build objects 34 | 35 | # how to build all object files from all dependent source files 36 | 37 | $(objects): $(sources) 38 | # icc -g -c $(sources) 39 | gcc $(CFLAGS) -c $(sources) 40 | 41 | clean: 42 | rm $(objects) bepsb 43 | 44 | -------------------------------------------------------------------------------- /BEPS-SIF/meteo_pack.c: -------------------------------------------------------------------------------- 1 | // this function will calculate all the meteorological variables based on input 2 | // edited by XZ Luo, May 19, 2015 3 | // default input is temperture (C) and relative humidity (0-100) 4 | // output is an array, named as meteo_pack_output [] 5 | /* meteo_pack_output [1]= air_density kg/m3 6 | meteo_pack_output [2]= specific heat of air J/kg/C 7 | meteo_pack_output [3]= VPD kPa 8 | meteo_pack_output [4]= slope of vapor pressure to temperature kPa/C 9 | meteo_pack_output [5]= psychrometer constant kPa/C 10 | meteo_pack_output [6]= saturate water vapor potential kPa 11 | meteo_pack_output [7]= actual water vapor potential kPa 12 | meteo_pack_output [8]= specific humidity g/g 13 | */ 14 | # include "beps.h" 15 | 16 | void meteo_pack (temp, rh, meteo_pack_output) 17 | 18 | double temp, rh; 19 | double meteo_pack_output[]; 20 | 21 | { 22 | double density_air, cp_air, vpd, slope_vapor, psy, e_saturate, e_actual, sp_humidity; 23 | double latent_water;//latent heat of water J/kg 24 | density_air=1.292; 25 | e_saturate=0.61078*exp(17.3*temp/(237.3+temp)); 26 | e_actual=e_saturate*rh/100; 27 | vpd=e_saturate-e_actual; 28 | sp_humidity=0.622*e_actual/(101.35-0.378*e_actual); 29 | cp_air=1004.65*(1+0.84*sp_humidity); 30 | slope_vapor=2503.0/pow((temp+237.3),2)*exp(17.27*temp/(temp+237.3)); 31 | psy=0.066; 32 | latent_water=(2.501-0.00237*temp)*1000000; 33 | //psy=cp_air*101.13/(0.622*latent_water); 34 | 35 | meteo_pack_output[1]= density_air; 36 | meteo_pack_output[2]= cp_air; 37 | meteo_pack_output[3]= vpd; 38 | meteo_pack_output[4]= slope_vapor; 39 | meteo_pack_output[5]= psy; 40 | meteo_pack_output[6]= e_saturate; 41 | meteo_pack_output[7]= e_actual; 42 | meteo_pack_output[8]= sp_humidity; 43 | } 44 | -------------------------------------------------------------------------------- /BEPS-SIF/netRadiation.c: -------------------------------------------------------------------------------- 1 | // This module will calculate net radiation at both canopy level and leaf level 2 | // edited by XZ Luo, May 23, 2015 3 | 4 | /* output: 5 | net radiation for canopy, overstorey, understorey and ground 6 | net radiation on sunlit, shaded leaves of overstorey and understorey. 7 | */ 8 | 9 | /* input: 10 | global solar radiation, cosine value for solar zenith angle, albedo of leaves 11 | albedo of snow, percentage of snow cover, 12 | leaf area index overstorey and understorey, 13 | temperature of overstorey, understorey and ground (contain snow?) 14 | temperature of air (C), relative humidity (0-100) 15 | */ 16 | # include "beps.h" 17 | void netRadiation(shortRad_global, CosZs, temp_o, temp_u, temp_g, 18 | lai_o, lai_u, lai_os, lai_us, // LAI of overstorey and understorey, with and without stem 19 | lai_o_sunlit, lai_o_shaded, lai_u_sunlit, lai_u_shaded, 20 | clumping, 21 | temp_air, rh, 22 | albedo_snow_v, albedo_snow_n, percentArea_snow_o, percentArea_snow_u, percent_snow_g, 23 | albedo_v_o, albedo_n_o, albedo_v_u, albedo_n_u, albedo_v_g, albedo_n_g, 24 | netRad_o, netRad_u, netRad_g, 25 | netRadLeaf_o_sunlit, netRadLeaf_o_shaded, netRadLeaf_u_sunlit, netRadLeaf_u_shaded, 26 | netShortRadLeaf_o_sunlit, netShortRadLeaf_o_shaded, netShortRadLeaf_u_sunlit, netShortRadLeaf_u_shaded) 27 | 28 | double shortRad_global, CosZs; // global short radiation, cosine value of solar zenith angle 29 | double temp_o, temp_u, temp_g; // temperature of overstorey, understorey and ground 30 | double lai_o, lai_u, lai_os, lai_us; // LAI of overstorey and understorey, with and without stem 31 | double lai_o_sunlit, lai_o_shaded, lai_u_sunlit, lai_u_shaded; // sunlit and shaded leaves with consideration of stem 32 | double clumping; // clumping index 33 | double temp_air, rh; 34 | double albedo_snow_v, albedo_snow_n; // albedo of snow in this step 35 | double percentArea_snow_o, percentArea_snow_u, percent_snow_g; // percentage of snow on overstorey and understorey (by area), and on ground (by mass) 36 | double albedo_v_o, albedo_n_o, albedo_v_u, albedo_n_u, albedo_v_g, albedo_n_g; // albedo of three parts, not considering snow, decided by land cover 37 | double *netRad_o, *netRad_u, *netRad_g; // net radiation on overstorey, understorey and ground 38 | double *netRadLeaf_o_sunlit, *netRadLeaf_o_shaded, *netRadLeaf_u_sunlit, *netRadLeaf_u_shaded;//net radiation at the leaf level, for ET calculation 39 | double *netShortRadLeaf_o_sunlit, *netShortRadLeaf_o_shaded, *netShortRadLeaf_u_sunlit, *netShortRadLeaf_u_shaded; //net shortwave radiation at leaf level, for GPP calculation 40 | 41 | { 42 | double netShortRad_o, netShortRad_u, netShortRad_g; // net short wave radiation on overstorey, understorey and ground 43 | double netShortRad_o_dir, netShortRad_o_df,netShortRad_u_dir, netShortRad_u_df, netShortRad_g_dir, netShortRad_g_df; // direct and diffuse part of net solar radiation 44 | double shortRad_dir, shortRad_df; //direct and diffuse radiation on top of the canopy 45 | double netLongRadLeaf_o_sunlit, netLongRadLeaf_o_shaded, netLongRadLeaf_u_sunlit, netLongRadLeaf_u_shaded; 46 | 47 | double netLongRad_o, netLongRad_u, netLongRad_g; // net long wave radiation 48 | double shortRadLeaf_o_dir, shortRadLeaf_u_dir, shortRadLeaf_o_df, shortRadLeaf_u_df; 49 | double albedo_o, albedo_u, albedo_g; //albedo of overstorey, understorey and ground (considering snow) 50 | double albedo_v_os, albedo_n_os, albedo_v_us, albedo_n_us, albedo_v_gs, albedo_n_gs; // albedo of three parts in visible and NIR band, (considering snow) 51 | 52 | double e_actual; // saturated and actual water vapor potential 53 | double meteo_pack_output[10]; // used to get actual vapor pressure 54 | 55 | double emissivity_air, emissivity_o, emissivity_u, emissivity_g; //emissivity of air, overstorey, understorey and ground 56 | double longRad_air, longRad_o, longRad_u, longRad_g; // long wave radiation emitted by different part 57 | double sb_constant=5.67 / 100000000; // stephen-boltzman constant 58 | double cosQ_o, cosQ_u; // indicators to decribe leaf distribution angles in canopy. slightly related with LAI 59 | double gap_o_dir, gap_u_dir, gap_o_df, gap_u_df; //gap fraction of direct and diffuse radiation for overstorey and understorey (diffuse used for diffuse solar radiation and longwave radiation) 60 | double gap_os_dir, gap_us_dir, gap_os_df, gap_us_df; // like above, considering stem 61 | double ratio_cloud; // a simple ratio to differentiate diffuse and direct radiation 62 | 63 | 64 | //calculate albedo of canopy in this step 65 | albedo_v_os=albedo_v_o*(1-percentArea_snow_o)+albedo_snow_v*percentArea_snow_o; 66 | albedo_n_os=albedo_n_o*(1-percentArea_snow_o)+albedo_snow_n*percentArea_snow_o; 67 | albedo_v_us=albedo_v_u*(1-percentArea_snow_u)+albedo_snow_v*percentArea_snow_u; 68 | albedo_n_us=albedo_n_u*(1-percentArea_snow_u)+albedo_snow_n*percentArea_snow_u; 69 | 70 | albedo_o=0.5*(albedo_v_os+albedo_n_os); 71 | albedo_u=0.5*(albedo_v_us+albedo_n_us); 72 | //calculate albedo of ground in this step 73 | albedo_v_gs=albedo_v_g*(1-percent_snow_g)+albedo_snow_v*percent_snow_g; 74 | albedo_n_gs=albedo_n_g*(1-percent_snow_g)+albedo_snow_n*percent_snow_g; 75 | albedo_g=0.5*(albedo_v_gs+albedo_n_gs); 76 | 77 | // separate global solar radiation into direct and diffuse one 78 | if (CosZs < 0.001) // solar zenith angle small, all diffuse radiation 79 | ratio_cloud=0; 80 | else 81 | ratio_cloud=shortRad_global/(1367*CosZs); 82 | 83 | if (ratio_cloud > 0.8) 84 | shortRad_df=0.13*shortRad_global; 85 | else 86 | shortRad_df=(0.943 + 0.734 *ratio_cloud - 4.9*pow((ratio_cloud),2)+ 1.796 *pow((ratio_cloud), 3 ) + 2.058*pow ((ratio_cloud),4))*shortRad_global; 87 | 88 | shortRad_df=min(shortRad_df,shortRad_global); 89 | shortRad_df=max(shortRad_df,0); 90 | 91 | shortRad_dir=shortRad_global-shortRad_df; 92 | 93 | //fraction at each layer of canopy, direct and diffuse. use Leaf only lai here 94 | gap_o_dir=exp(-0.5*clumping*lai_o/CosZs); 95 | gap_u_dir=exp(-0.5*clumping*lai_u/CosZs); 96 | 97 | gap_os_dir=exp(-0.5*clumping*lai_os/CosZs); // considering stem 98 | gap_us_dir=exp(-0.5*clumping*lai_us/CosZs); 99 | 100 | cosQ_o=0.537+0.025*lai_o; 101 | cosQ_u=0.537+0.025*lai_u; 102 | gap_o_df=exp(-0.5*clumping*lai_o/cosQ_o); 103 | gap_u_df=exp(-0.5*clumping*lai_u/cosQ_u); 104 | 105 | gap_os_df=exp(-0.5*clumping*lai_os/cosQ_o); // considering stem 106 | gap_us_df=exp(-0.5*clumping*lai_us/cosQ_u); 107 | 108 | //emissivity of each part 109 | meteo_pack (temp_air, rh, meteo_pack_output); 110 | e_actual=meteo_pack_output [7]; 111 | 112 | emissivity_air =1-exp(-(pow(e_actual*10.0,(temp_air+273.15)/1200.0))); 113 | emissivity_air =min(1,emissivity_air); 114 | emissivity_air =max(0.7,emissivity_air); 115 | 116 | emissivity_o=0.98; 117 | emissivity_u=0.98; 118 | emissivity_g=0.96; 119 | 120 | /// net short direct radiation on canopy and ground 121 | if (shortRad_global>zero && CosZs >zero ) // only happens in day time, when sun is out 122 | { 123 | netShortRad_o_dir=shortRad_dir*((1-albedo_o)-(1-albedo_u)*gap_o_dir); 124 | netShortRad_u_dir=shortRad_dir*gap_o_dir*((1-albedo_u)-(1-albedo_g)*gap_u_dir); 125 | netShortRad_g_dir=shortRad_dir*gap_o_dir*gap_u_dir*(1-albedo_g); 126 | } 127 | else 128 | { 129 | netShortRad_o_dir=0; 130 | netShortRad_u_dir=0; 131 | netShortRad_g_dir=0; 132 | } 133 | 134 | ///net short diffuse radiation on canopy and ground 135 | if (shortRad_global>zero && CosZs >zero ) // only happens in day time, when sun is out 136 | { 137 | netShortRad_o_df=shortRad_df*((1-albedo_o)-(1-albedo_u)*gap_o_df)+0.21*clumping*shortRad_dir*(1.1-0.1*lai_o)*exp(-CosZs); 138 | netShortRad_u_df=shortRad_df*gap_o_df*((1-albedo_u)-(1-albedo_g)*gap_u_df)+0.21*clumping*shortRad_dir*gap_o_dir*(1.1-0.1*lai_u)*exp(-CosZs); 139 | netShortRad_g_df=shortRad_df*gap_o_df*gap_u_df*(1-albedo_g); 140 | } 141 | else 142 | { 143 | netShortRad_o_df=0; 144 | netShortRad_u_df=0; 145 | netShortRad_g_df=0; 146 | } 147 | 148 | /// total net shortwave radiation at canopy level 149 | netShortRad_o=netShortRad_o_dir+netShortRad_o_df; 150 | netShortRad_u=netShortRad_u_dir+netShortRad_u_df; 151 | netShortRad_g=netShortRad_g_dir+netShortRad_g_df; 152 | 153 | 154 | // net long wave radiation on canopy and ground 155 | longRad_air=emissivity_air*sb_constant*pow((temp_air+273.15),4); 156 | longRad_o=emissivity_o*sb_constant*pow((temp_o+273.15),4); 157 | longRad_u=emissivity_u*sb_constant*pow((temp_u+273.15),4); 158 | longRad_g=emissivity_g*sb_constant*pow((temp_g+273.15),4); 159 | 160 | netLongRad_o=(emissivity_o*(longRad_air+longRad_u*(1-gap_u_df)+longRad_g*gap_u_df)-2*longRad_o ) 161 | *(1-gap_o_df )+emissivity_o*(1-emissivity_u )*(1-gap_u_df )*(longRad_air*gap_o_df 162 | +longRad_o*(1-gap_o_df)); 163 | 164 | netLongRad_u=(emissivity_u*(longRad_air*gap_o_df+longRad_o*(1-gap_o_df)+longRad_g )-2*longRad_u ) 165 | *(1-gap_u_df )+(1-emissivity_g )*((longRad_air*gap_o_df+longRad_o*(1-gap_o_df ) )*gap_u_df 166 | +longRad_u*(1-gap_u_df)) 167 | +emissivity_u*(1-emissivity_o )*(longRad_u*(1-gap_u_df )+longRad_g*gap_u_df)*(1-gap_o_df); 168 | 169 | netLongRad_g=emissivity_g*((longRad_air*gap_o_df+longRad_o*(1-gap_o_df ) )*gap_u_df 170 | +longRad_u*(1-gap_u_df) ) 171 | -longRad_g+(1-emissivity_u )*longRad_g*(1-gap_u_df); 172 | 173 | // total net radiation for overstorey, understorey and ground. 174 | *netRad_o=netShortRad_o+netLongRad_o; 175 | *netRad_u=netShortRad_u+netLongRad_u; 176 | *netRad_g=netShortRad_g+netLongRad_g; 177 | 178 | //leaf level net radiation updated way 179 | // reference Chen 2012 clumping index paper 180 | 181 | 182 | if (shortRad_global>zero && CosZs >zero ) // only happens in day time, when sun is out 183 | { 184 | shortRadLeaf_o_dir=0.5*shortRad_dir/CosZs; 185 | shortRadLeaf_o_dir=min(shortRadLeaf_o_dir,0.7*1362); 186 | shortRadLeaf_u_dir=shortRadLeaf_o_dir; 187 | 188 | shortRadLeaf_o_df=(shortRad_df-shortRad_df*gap_os_df)/lai_os+0.07*shortRad_dir*(1.1-0.1*lai_os)*exp(-CosZs); 189 | shortRadLeaf_u_df=(shortRad_df*gap_o_df-shortRad_df*gap_o_df*gap_us_df)/lai_us // pay attention to the type of gap fraction used here 190 | +0.05*shortRad_dir*gap_o_dir*(1.1-0.1*lai_us)*exp(-CosZs); 191 | } 192 | else 193 | { 194 | shortRadLeaf_o_dir=0; 195 | shortRadLeaf_u_dir=0; 196 | shortRadLeaf_o_df=0; 197 | shortRadLeaf_u_df=0; 198 | } 199 | 200 | //overstorey sunlit leaves 201 | 202 | if (lai_o_sunlit>0) 203 | { 204 | *netShortRadLeaf_o_sunlit=(shortRadLeaf_o_dir+shortRadLeaf_o_df)*(1-albedo_o); // diffuse 205 | netLongRadLeaf_o_sunlit=netLongRad_o/lai_os; // leaf level net long 206 | *netRadLeaf_o_sunlit = *netShortRadLeaf_o_sunlit + netLongRadLeaf_o_sunlit; 207 | } 208 | else 209 | { 210 | *netShortRadLeaf_o_sunlit=(shortRadLeaf_o_dir+shortRadLeaf_o_df)*(1-albedo_o); 211 | netLongRadLeaf_o_sunlit=netLongRad_o; 212 | *netRadLeaf_o_sunlit = *netShortRadLeaf_o_sunlit + netLongRadLeaf_o_sunlit; 213 | } 214 | 215 | //overstorey shaded leaf 216 | if(lai_o_shaded>0) 217 | { 218 | *netShortRadLeaf_o_shaded=shortRadLeaf_o_df*(1-albedo_o); // diffuse 219 | netLongRadLeaf_o_shaded=netLongRad_o/lai_os; 220 | 221 | *netRadLeaf_o_shaded = *netShortRadLeaf_o_shaded + netLongRadLeaf_o_shaded; 222 | } 223 | else 224 | { 225 | *netShortRadLeaf_o_shaded=shortRadLeaf_o_df*(1-albedo_o); // diffuse 226 | netLongRadLeaf_o_shaded=netLongRad_o; 227 | *netRadLeaf_o_shaded = *netShortRadLeaf_o_shaded + netLongRadLeaf_o_shaded; 228 | } 229 | 230 | 231 | //understorey sunlit leaf 232 | if(lai_u_sunlit>0) 233 | { 234 | *netShortRadLeaf_u_sunlit=(shortRadLeaf_u_dir+shortRadLeaf_u_df)*(1-albedo_u); 235 | netLongRadLeaf_u_sunlit=netLongRad_u/lai_us; 236 | 237 | *netRadLeaf_u_sunlit = *netShortRadLeaf_u_sunlit + netLongRadLeaf_u_sunlit; 238 | } 239 | else 240 | { 241 | *netShortRadLeaf_u_sunlit=(shortRadLeaf_u_dir+shortRadLeaf_u_df)*(1-albedo_u); 242 | netLongRadLeaf_u_sunlit=netLongRad_u; 243 | 244 | *netRadLeaf_u_sunlit = *netShortRadLeaf_u_sunlit + netLongRadLeaf_u_sunlit; 245 | } 246 | 247 | //understorey shaded leaf 248 | if(lai_u_shaded>0) 249 | { 250 | *netShortRadLeaf_u_shaded=shortRadLeaf_u_df*(1-albedo_u); 251 | netLongRadLeaf_u_shaded=netLongRad_u/lai_us; 252 | 253 | *netRadLeaf_u_shaded = *netShortRadLeaf_u_shaded + netLongRadLeaf_u_shaded; 254 | } 255 | else 256 | { 257 | *netShortRadLeaf_u_shaded=shortRadLeaf_u_df*(1-albedo_u); 258 | netLongRadLeaf_u_shaded=netLongRad_u; 259 | 260 | *netRadLeaf_u_shaded = *netShortRadLeaf_u_shaded + netLongRadLeaf_u_shaded; 261 | } 262 | 263 | //leaf level net radiation: original way, use canopy radiation divided by LAI. 264 | // here calculate net radiation for all leaf component again use the original method. 265 | //These code could be commented, because not right, I just put it here to validate model. 266 | // if(lai_o_sunlit>0) 267 | // *netRadLeaf_o_sunlit = netShortRad_o_dir/lai_o_sunlit + netLongRad_o/lai_os; 268 | // else 269 | // *netRadLeaf_o_sunlit = netShortRad_o_dir + netLongRad_o; 270 | // 271 | // if(lai_o_shaded>0) 272 | // *netRadLeaf_o_shaded = netShortRad_o_df/lai_o_shaded + netLongRad_o/lai_os; 273 | // else 274 | // *netRadLeaf_o_shaded = netShortRad_o_df + netLongRad_o; 275 | // 276 | // 277 | // if(lai_u_sunlit>0) 278 | // *netRadLeaf_u_sunlit = netShortRad_u_dir/lai_u_sunlit + netLongRad_u/lai_us; 279 | // else 280 | // *netRadLeaf_u_sunlit = netShortRad_u_dir + netLongRad_u; 281 | // 282 | // 283 | // if(lai_u_shaded>0) 284 | // *netRadLeaf_u_shaded = netShortRad_u_df/lai_u_shaded + netLongRad_u/lai_us; 285 | // else 286 | // *netRadLeaf_u_shaded =netShortRad_u_df + netLongRad_u; 287 | } 288 | -------------------------------------------------------------------------------- /BEPS-SIF/photosyn_gs.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yongguangzhang/BEPS-SIF-model/40762d9265dedadb0dbd36929fcf0bfe02e5d140/BEPS-SIF/photosyn_gs.c -------------------------------------------------------------------------------- /BEPS-SIF/plant_respir.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | Program: plant_respir.c 3 | -------- 4 | Description: Estimate plant respiration. 5 | 6 | Written by: J. Liu. and W.Ju, Modified by G. Mo 7 | Last update: May 2015 8 | 9 | *****************************************************************************/ 10 | 11 | #include "beps.h" 12 | 13 | void plantresp(LC,mid_res,lai_yr,lai,temp_air,temp_soil,CosZs) 14 | 15 | int LC; 16 | struct results mid_res[]; 17 | double lai_yr; 18 | double temp_air; 19 | double lai,temp_soil; 20 | double CosZs; 21 | 22 | { 23 | double temp_opt25=25.0; 24 | double biomass,biomass_leaf_o,biomass_stem_o,biomass_root_o,biomass_leaf_u,biomass_stem_u,biomass_root_u; 25 | double respir_croot_o,respir_root_o,respir_stem_o,respir_leaf_o; 26 | double respir_croot_u,respir_root_u,respir_stem_u,respir_leaf_u; 27 | double q10; 28 | double exponent; 29 | double lai_u,lai_max_o,lai_max_u; 30 | double ra; 31 | double coef_leaf_respir,coef_stem_respir,coef_root_respir,coef_fineroot_respir; 32 | double gpp_o,gpp_u,gpp_r,rg,ratio_froot; 33 | 34 | 35 | if (LC==25 || LC==40) lai_u=0.01; 36 | else 37 | lai_u=1.18*exp(-0.99*lai); 38 | 39 | if (lai_u>lai) lai_u=0.01; 40 | 41 | if(LC==6) 42 | ra=0.6; 43 | else 44 | ra=1.0; 45 | 46 | q10=3.22-0.046*temp_air; 47 | 48 | 49 | switch(LC) 50 | { 51 | case 1: case 2: case 3: case 4: case 5: /* conifer */ 52 | /* calculating aboveground biomass based on LAI J. Liu 2002 */ 53 | biomass=0.9097*lai_yr+0.125*lai_yr*lai_yr; 54 | biomass_leaf_o=0.05*biomass; /* leaf C of overstory */ 55 | biomass_stem_o=0.95*biomass; /* stem C of overstory */ 56 | biomass_root_o=0.454*biomass; 57 | /*biomass_root_o=0.232*biomass; // root C of overstoryKurz 1996 */ 58 | biomass_leaf_u=0.3*biomass_leaf_o; /* leaf C of understory */ 59 | biomass_stem_u=0.02*biomass_stem_o; /* stem C of understory */ 60 | biomass_root_u=0.05*biomass_root_o; /* root C of understory */ 61 | 62 | coef_leaf_respir=0.0015/RTIMES; /* leaf resp co. kg C-1 d-1 kg-1 */ 63 | coef_stem_respir=0.0020/RTIMES; /* stem resp co. kg C-1 d-1 kg-1 */ 64 | coef_root_respir=0.0020/RTIMES; /* root resp co. kg C-1 d-1 kg-1 */ 65 | coef_fineroot_respir=0.003/RTIMES; /* fine root resp co. kg C-1 d-1 kg-1 */ 66 | 67 | lai_max_o=4.5; /* LAI_max_overstory 3.3*/ 68 | lai_max_u=2.4; /* LAI_max_understroy 2.4*/ 69 | 70 | 71 | break; 72 | 73 | case 6: case 9: /* deciduous forest, tropic evergreen */ 74 | /* calculating aboveground biomass based on LAI J. Liu 2002 */ 75 | biomass=1.545*lai_yr+0.183*lai_yr*lai_yr; 76 | biomass_leaf_o=0.04*biomass; /* leaf C of overstory */ 77 | biomass_stem_o=0.96*biomass; /* stem C of overstory */ 78 | biomass_root_o=1.432*pow(biomass,0.639); /* root C of overstory Kurz 1996 */ 79 | biomass_leaf_u=0.3*biomass_leaf_o; /* leaf C of understory */ 80 | biomass_stem_u=0.01*biomass_stem_o; /* stem C of understory */ 81 | biomass_root_u=0.01*biomass_root_o; /* root C of understory */ 82 | 83 | coef_leaf_respir=0.015/RTIMES; /* leaf resp co. kg C-1 d-1 kg-1 */ 84 | coef_stem_respir=0.0035/RTIMES; /* stem resp co. kg C-1 d-1 kg-1 */ 85 | coef_root_respir=0.0025/RTIMES; /* root resp co. kg C-1 d-1 kg-1 */ 86 | coef_fineroot_respir=0.003/RTIMES; /* fine root resp co. kg C-1 d-1 kg-1 */ 87 | 88 | lai_max_o=4.5; /* LAI_max_overstory 3.3*/ 89 | lai_max_u=2.4; /* LAI_max_understroy 2.4*/ 90 | 91 | break; 92 | 93 | case 13: /* shrub */ 94 | biomass=1.545*lai_yr+0.183*lai_yr*lai_yr; 95 | biomass_leaf_o=0.1*biomass; /* leaf C of overstory */ 96 | biomass_stem_o=0.90*biomass; /* stem C of overstory */ 97 | biomass_root_o=1.432*pow(biomass,0.639); /* root C of overstory Kurz 1996 */ 98 | biomass_leaf_u=0.3*biomass_leaf_o; /* leaf C of understory */ 99 | biomass_stem_u=0.01*biomass_stem_o; /* stem C of understory */ 100 | biomass_root_u=0.01*biomass_root_o; /* root C of understory */ 101 | 102 | coef_leaf_respir=0.001/RTIMES; /* leaf resp co. kg C-1 d-1 kg-1 */ 103 | coef_stem_respir=0.002/RTIMES; /* stem resp co. kg C-1 d-1 kg-1 */ 104 | coef_root_respir=0.0015/RTIMES; /* root resp co. kg C-1 d-1 kg-1 */ 105 | coef_fineroot_respir=0.003/RTIMES; /* fine root resp co. kg C-1 d-1 kg-1 */ 106 | 107 | lai_max_o=3.3; /* LAI_max_overstory */ 108 | lai_max_u=0.01; /* LAI_max_understroy */ 109 | 110 | break; 111 | 112 | case 25: case 40: 113 | biomass_leaf_o=0.05*lai_yr; /* leaf C = lai/20 from W.Ju 05y11*/ 114 | biomass_stem_o=0.0; /* stem C */ 115 | biomass_root_o=0.061*lai_yr; /* root C = lai/20*0.55/0.45 from W.Ju 05y11*/ 116 | biomass_leaf_u=0.0; 117 | biomass_stem_u=0.0; 118 | biomass_root_u=0.0; 119 | 120 | coef_leaf_respir=0.001/RTIMES; /* leaf resp co. kg C-1 d-1 kg-1 */ 121 | coef_stem_respir=0.002/RTIMES; /* stem resp co. kg C-1 d-1 kg-1 */ 122 | coef_root_respir=0.0015/RTIMES; /* root resp co. kg C-1 d-1 kg-1 */ 123 | coef_fineroot_respir=0.003/RTIMES; /* fine root resp co. kg C-1 d-1 kg-1 */ 124 | 125 | lai_max_o=3.3; /* LAI_max_overstory */ 126 | lai_max_u=0.01; /* LAI_max_understroy */ 127 | 128 | } /* end of switch */ 129 | 130 | /* ---- calculation for overstory ---- */ 131 | 132 | /* stem maintenance respiration */ 133 | exponent=(temp_air-temp_opt25)/10.0; 134 | respir_stem_o = (biomass_stem_o*0.35/(biomass_stem_o+0.35))*coef_stem_respir*pow(q10,exponent)*ra; 135 | respir_stem_o = max(respir_stem_o, 0.0); 136 | 137 | /* root maintenance respiration changed in Nov.2005 by W. Ju */ 138 | /* exponent=(temp_soil-temp_opt25)/10.0; 139 | respir_root_o = biomass_root_o*coef_root_respir*pow(q10,exponent)*ra; 140 | respir_root_o = max (respir_root_o, 0.0); */ 141 | exponent=(temp_soil-temp_opt25)/10.0; 142 | 143 | if (LC==25 || LC==40) 144 | respir_root_o = biomass_root_o*coef_root_respir*pow(q10,exponent)*ra; 145 | else 146 | { 147 | ratio_froot=exp(1.007)*pow(biomass_root_o,-(0.841)); 148 | ratio_froot=min(0.9, ratio_froot); 149 | 150 | respir_croot_o=0.05*biomass_root_o*(1-ratio_froot)*coef_root_respir*pow(q10,exponent); /*coarse root */ 151 | respir_root_o=respir_croot_o+0.05*biomass_root_o*ratio_froot*coef_fineroot_respir*pow(q10,exponent); /* coarse + fine root */ 152 | } 153 | respir_root_o = max (respir_root_o, 0.0); 154 | 155 | 156 | /* leaf day/night time maintenance respiration */ 157 | if (CosZs>0.01) respir_leaf_o=0; 158 | else 159 | { 160 | exponent=(temp_air-temp_opt25)/10.0; 161 | respir_leaf_o =lai/lai_max_o*biomass_leaf_o*coef_leaf_respir*pow(q10,exponent)*ra; 162 | } 163 | respir_leaf_o =max( respir_leaf_o, 0.0); 164 | 165 | /* changed in Nov.2005 by W. Ju */ 166 | // *npp_o = 0.8*gpp_o-respir_leaf_o-respir_stem_o-respir_root_o; 167 | 168 | gpp_o = (mid_res->gpp_o_sunlit + mid_res->gpp_o_shaded)*12*step*0.000001; 169 | gpp_r = gpp_o - (respir_leaf_o+respir_stem_o+respir_root_o)*1000; 170 | if (gpp_r <= 0) rg = 0; 171 | else rg = 0.35*gpp_r; 172 | 173 | mid_res->npp_o = (gpp_r - rg); //NPP_overstory; gC/m2 174 | 175 | /* ---- calculation for understory ---- */ 176 | 177 | /* stem maintenance respiration */ 178 | exponent=(temp_air-temp_opt25)/10.0; 179 | respir_stem_u =(biomass_stem_u*0.35/(biomass_stem_u+0.35))*coef_stem_respir*pow(q10,exponent)*ra; 180 | respir_stem_u = max(respir_stem_u, 0.0); 181 | 182 | /* root maintenance respiration changed in Nov.2005 by W. Ju */ 183 | exponent=(temp_soil-temp_opt25)/10.0; 184 | if (LC==25 || LC==40) 185 | respir_root_u = biomass_root_u*coef_root_respir*pow(q10,exponent)*ra; 186 | 187 | else 188 | { 189 | ratio_froot=exp(1.007)*pow(biomass_root_u,-(0.841)); 190 | ratio_froot=min(0.9, ratio_froot); 191 | 192 | respir_croot_u=0.05*biomass_root_u*(1-ratio_froot)*coef_root_respir*pow(q10,exponent); /*coarse root */ 193 | respir_root_u=respir_croot_u+0.05*biomass_root_u*ratio_froot*coef_fineroot_respir*pow(q10,exponent); /* coarse + fine root */ 194 | } 195 | 196 | respir_root_u = max(respir_root_u, 0.0); 197 | 198 | 199 | if (CosZs>0.01) respir_leaf_u=0; 200 | else 201 | { 202 | exponent=(temp_air-temp_opt25)/10.0; 203 | respir_leaf_u =lai_u/lai_max_u*biomass_leaf_u*coef_leaf_respir*pow(q10,exponent)*ra*0.5; 204 | } 205 | respir_leaf_u =max(respir_leaf_u, 0.0); 206 | 207 | /* changed in Nov.2005 by W. Ju */ 208 | // *npp_u = 0.8*gpp_u-respir_leaf_u-respir_stem_u-respir_root_u; 209 | 210 | gpp_u = (mid_res->gpp_u_sunlit + mid_res->gpp_u_shaded)*12*step*0.000001; 211 | gpp_r = gpp_u - (respir_leaf_u+respir_stem_u+respir_root_u)*1000; 212 | if (gpp_r <= 0) rg = 0; 213 | else rg = 0.35*gpp_r; 214 | 215 | mid_res->npp_u = (gpp_r - rg); //understory NPP gC/m2 216 | 217 | 218 | } 219 | 220 | 221 | 222 | -------------------------------------------------------------------------------- /BEPS-SIF/plant_respir_l.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | Program: plant_respir.c 3 | -------- 4 | Description: Estimate plant respiration. 5 | 6 | Written by: J. Liu. and W.Ju, Modified by G. Mo 7 | Last update: May 2015 8 | 9 | *****************************************************************************/ 10 | 11 | #include "beps.h" 12 | 13 | void plantresp(LC,mid_res,lai_yr,lai,temp_air,temp_soil,CosZs) 14 | 15 | int LC; 16 | struct results mid_res[]; 17 | double lai_yr; 18 | double temp_air; 19 | double lai,temp_soil; 20 | double CosZs; 21 | 22 | { 23 | double temp_opt25=25.0; 24 | double biomass,biomass_leaf_o,biomass_stem_o,biomass_root_o,biomass_leaf_u,biomass_stem_u,biomass_root_u; 25 | double respir_croot_o,respir_root_o,respir_stem_o,respir_leaf_o; 26 | double respir_croot_u,respir_root_u,respir_stem_u,respir_leaf_u; 27 | double q10; 28 | double exponent; 29 | double lai_u,lai_max_o,lai_max_u; 30 | double ra; 31 | double coef_leaf_respir,coef_stem_respir,coef_root_respir,coef_fineroot_respir; 32 | double gpp_o,gpp_u,gpp_r,rg,ratio_froot; 33 | 34 | 35 | if (LC==25 || LC==40) lai_u=0.01; 36 | else 37 | lai_u=1.18*exp(-0.99*lai); 38 | 39 | if (lai_u>lai) lai_u=0.01; 40 | 41 | if(LC==6) 42 | ra=0.6; 43 | else 44 | ra=1.0; 45 | 46 | q10=3.22-0.046*temp_air; 47 | 48 | 49 | switch(LC) 50 | { 51 | case 1: case 2: case 3: case 4: case 5: /* conifer */ 52 | /* calculating aboveground biomass based on LAI J. Liu 2002 */ 53 | biomass=0.9097*lai_yr+0.125*lai_yr*lai_yr; 54 | biomass_leaf_o=0.05*biomass; /* leaf C of overstory */ 55 | biomass_stem_o=0.95*biomass; /* stem C of overstory */ 56 | biomass_root_o=0.454*biomass; 57 | /*biomass_root_o=0.232*biomass; // root C of overstoryKurz 1996 */ 58 | biomass_leaf_u=0.3*biomass_leaf_o; /* leaf C of understory */ 59 | biomass_stem_u=0.02*biomass_stem_o; /* stem C of understory */ 60 | biomass_root_u=0.05*biomass_root_o; /* root C of understory */ 61 | 62 | coef_leaf_respir=0.0015/RTIMES; /* leaf resp co. kg C-1 d-1 kg-1 */ 63 | coef_stem_respir=0.0020/RTIMES; /* stem resp co. kg C-1 d-1 kg-1 */ 64 | coef_root_respir=0.0020/RTIMES; /* root resp co. kg C-1 d-1 kg-1 */ 65 | coef_fineroot_respir=0.003/RTIMES; /* fine root resp co. kg C-1 d-1 kg-1 */ 66 | 67 | lai_max_o=4.5; /* LAI_max_overstory 3.3*/ 68 | lai_max_u=2.4; /* LAI_max_understroy 2.4*/ 69 | 70 | 71 | break; 72 | 73 | case 6: case 9: /* deciduous forest, tropic evergreen */ 74 | /* calculating aboveground biomass based on LAI J. Liu 2002 */ 75 | biomass=1.545*lai_yr+0.183*lai_yr*lai_yr; 76 | biomass_leaf_o=0.04*biomass; /* leaf C of overstory */ 77 | biomass_stem_o=0.96*biomass; /* stem C of overstory */ 78 | biomass_root_o=1.432*pow(biomass,0.639); /* root C of overstory Kurz 1996 */ 79 | biomass_leaf_u=0.3*biomass_leaf_o; /* leaf C of understory */ 80 | biomass_stem_u=0.01*biomass_stem_o; /* stem C of understory */ 81 | biomass_root_u=0.01*biomass_root_o; /* root C of understory */ 82 | 83 | coef_leaf_respir=0.015/RTIMES; /* leaf resp co. kg C-1 d-1 kg-1 */ 84 | coef_stem_respir=0.0035/RTIMES*0.65; /* stem resp co. kg C-1 d-1 kg-1 */ 85 | coef_root_respir=0.0025/RTIMES*0.85; /* root resp co. kg C-1 d-1 kg-1 */ 86 | coef_fineroot_respir=0.003/RTIMES; /* fine root resp co. kg C-1 d-1 kg-1 */ 87 | 88 | lai_max_o=4.5; /* LAI_max_overstory 3.3*/ 89 | lai_max_u=2.4; /* LAI_max_understroy 2.4*/ 90 | 91 | break; 92 | 93 | case 10: /* mix forest */ 94 | /* calculating aboveground biomass based on LAI J. Liu 2002 */ 95 | biomass=1.227*lai_yr+0.154*lai_yr*lai_yr; 96 | biomass_leaf_o=0.045*biomass; /* leaf C of overstory */ 97 | biomass_stem_o=0.95*biomass; /* stem C of overstory */ 98 | biomass_root_o=(0.454*biomass+1.432*pow(biomass,0.639))/2.0; 99 | /*biomass_root_o=0.232*biomass; // root C of overstoryKurz 1996 */ 100 | biomass_leaf_u=0.3*biomass_leaf_o; /* leaf C of understory */ 101 | biomass_stem_u=0.015*biomass_stem_o; /* stem C of understory */ 102 | biomass_root_u=0.03*biomass_root_o; /* root C of understory */ 103 | 104 | coef_leaf_respir=0.008/RTIMES; /* leaf resp co. kg C-1 d-1 kg-1 */ 105 | coef_stem_respir=0.0028/RTIMES; /* stem resp co. kg C-1 d-1 kg-1 */ 106 | coef_root_respir=0.0023/RTIMES; /* root resp co. kg C-1 d-1 kg-1 */ 107 | coef_fineroot_respir=0.003/RTIMES; /* fine root resp co. kg C-1 d-1 kg-1 */ 108 | 109 | lai_max_o=4.5; /* LAI_max_overstory 3.3*/ 110 | lai_max_u=2.4; /* LAI_max_understroy 2.4*/ 111 | 112 | 113 | break; 114 | 115 | case 13: /* shrub */ 116 | biomass=1.545*lai_yr+0.183*lai_yr*lai_yr; 117 | biomass_leaf_o=0.1*biomass; /* leaf C of overstory */ 118 | biomass_stem_o=0.90*biomass; /* stem C of overstory */ 119 | biomass_root_o=1.432*pow(biomass,0.639); /* root C of overstory Kurz 1996 */ 120 | biomass_leaf_u=0.3*biomass_leaf_o; /* leaf C of understory */ 121 | biomass_stem_u=0.01*biomass_stem_o; /* stem C of understory */ 122 | biomass_root_u=0.01*biomass_root_o; /* root C of understory */ 123 | 124 | coef_leaf_respir=0.001/RTIMES; /* leaf resp co. kg C-1 d-1 kg-1 */ 125 | coef_stem_respir=0.002/RTIMES; /* stem resp co. kg C-1 d-1 kg-1 */ 126 | coef_root_respir=0.0015/RTIMES; /* root resp co. kg C-1 d-1 kg-1 */ 127 | coef_fineroot_respir=0.003/RTIMES; /* fine root resp co. kg C-1 d-1 kg-1 */ 128 | 129 | lai_max_o=3.3; /* LAI_max_overstory */ 130 | lai_max_u=0.01; /* LAI_max_understroy */ 131 | 132 | break; 133 | 134 | case 25: case 40: case 14: case 15: 135 | biomass_leaf_o=0.05*lai_yr; /* leaf C = lai/20 from W.Ju 05y11*/ 136 | biomass_stem_o=0.0; /* stem C */ 137 | biomass_root_o=0.061*lai_yr; /* root C = lai/20*0.55/0.45 from W.Ju 05y11*/ 138 | biomass_leaf_u=0.0; 139 | biomass_stem_u=0.0; 140 | biomass_root_u=0.0; 141 | 142 | coef_leaf_respir=0.001/RTIMES; /* leaf resp co. kg C-1 d-1 kg-1 */ 143 | coef_stem_respir=0.002/RTIMES; /* stem resp co. kg C-1 d-1 kg-1 */ 144 | coef_root_respir=0.0015/RTIMES; /* root resp co. kg C-1 d-1 kg-1 */ 145 | coef_fineroot_respir=0.003/RTIMES; /* fine root resp co. kg C-1 d-1 kg-1 */ 146 | 147 | lai_max_o=3.3; /* LAI_max_overstory */ 148 | lai_max_u=0.01; /* LAI_max_understroy */ 149 | 150 | } /* end of switch */ 151 | 152 | /* ---- calculation for overstory ---- */ 153 | 154 | /* stem maintenance respiration */ 155 | exponent=(temp_air-temp_opt25)/10.0; 156 | respir_stem_o = (biomass_stem_o*0.35/(biomass_stem_o+0.35))*coef_stem_respir*pow(q10,exponent)*ra; 157 | respir_stem_o = max(respir_stem_o, 0.0); 158 | 159 | /* root maintenance respiration changed in Nov.2005 by W. Ju */ 160 | /* exponent=(temp_soil-temp_opt25)/10.0; 161 | respir_root_o = biomass_root_o*coef_root_respir*pow(q10,exponent)*ra; 162 | respir_root_o = max (respir_root_o, 0.0); */ 163 | exponent=(temp_soil-temp_opt25)/10.0; 164 | 165 | if (LC==25 || LC==40 || LC==14 || LC==15) 166 | respir_root_o = biomass_root_o*coef_root_respir*pow(q10,exponent)*ra; 167 | else 168 | { 169 | ratio_froot=exp(1.007)*pow(biomass_root_o,-(0.841)); 170 | ratio_froot=min(0.9, ratio_froot); 171 | 172 | respir_croot_o=0.05*biomass_root_o*(1-ratio_froot)*coef_root_respir*pow(q10,exponent); /*coarse root */ 173 | respir_root_o=respir_croot_o+0.05*biomass_root_o*ratio_froot*coef_fineroot_respir*pow(q10,exponent); /* coarse + fine root */ 174 | } 175 | respir_root_o = max (respir_root_o, 0.0); 176 | 177 | 178 | /* leaf day/night time maintenance respiration */ 179 | if (CosZs>0.01) respir_leaf_o=0; 180 | else 181 | { 182 | exponent=(temp_air-temp_opt25)/10.0; 183 | respir_leaf_o =lai/lai_max_o*biomass_leaf_o*coef_leaf_respir*pow(q10,exponent)*ra; 184 | } 185 | respir_leaf_o =max( respir_leaf_o, 0.0); 186 | 187 | /* changed in Nov.2005 by W. Ju */ 188 | // *npp_o = 0.8*gpp_o-respir_leaf_o-respir_stem_o-respir_root_o; 189 | 190 | gpp_o = (mid_res->gpp_o_sunlit + mid_res->gpp_o_shaded)*12*step*0.000001; 191 | gpp_r = gpp_o - (respir_leaf_o+respir_stem_o+respir_root_o)*1000; 192 | if (gpp_r <= 0) rg = 0; 193 | else rg = 0.35*gpp_r; 194 | 195 | //mid_res->npp_o = (gpp_r - rg); //NPP_overstory; gC/m2 196 | //Xuhe Lu modify 197 | mid_res->npp_o = 0.45 * gpp_o; 198 | 199 | /* ---- calculation for understory ---- */ 200 | 201 | /* stem maintenance respiration */ 202 | exponent=(temp_air-temp_opt25)/10.0; 203 | respir_stem_u =(biomass_stem_u*0.35/(biomass_stem_u+0.35))*coef_stem_respir*pow(q10,exponent)*ra; 204 | respir_stem_u = max(respir_stem_u, 0.0); 205 | 206 | /* root maintenance respiration changed in Nov.2005 by W. Ju */ 207 | exponent=(temp_soil-temp_opt25)/10.0; 208 | if (LC==25 || LC==40 || LC==14 || LC==15) 209 | respir_root_u = biomass_root_u*coef_root_respir*pow(q10,exponent)*ra; 210 | 211 | else 212 | { 213 | ratio_froot=exp(1.007)*pow(biomass_root_u,-(0.841)); 214 | ratio_froot=min(0.9, ratio_froot); 215 | 216 | respir_croot_u=0.05*biomass_root_u*(1-ratio_froot)*coef_root_respir*pow(q10,exponent); /*coarse root */ 217 | respir_root_u=respir_croot_u+0.05*biomass_root_u*ratio_froot*coef_fineroot_respir*pow(q10,exponent); /* coarse + fine root */ 218 | } 219 | 220 | respir_root_u = max(respir_root_u, 0.0); 221 | 222 | 223 | if (CosZs>0.01) respir_leaf_u=0; 224 | else 225 | { 226 | exponent=(temp_air-temp_opt25)/10.0; 227 | respir_leaf_u =lai_u/lai_max_u*biomass_leaf_u*coef_leaf_respir*pow(q10,exponent)*ra*0.5; 228 | } 229 | respir_leaf_u =max(respir_leaf_u, 0.0); 230 | 231 | /* changed in Nov.2005 by W. Ju */ 232 | // *npp_u = 0.8*gpp_u-respir_leaf_u-respir_stem_u-respir_root_u; 233 | 234 | gpp_u = (mid_res->gpp_u_sunlit + mid_res->gpp_u_shaded)*12*step*0.000001; 235 | gpp_r = gpp_u - (respir_leaf_u+respir_stem_u+respir_root_u)*1000; 236 | if (gpp_r <= 0) rg = 0; 237 | else rg = 0.35*gpp_r; 238 | 239 | mid_res->npp_u = (gpp_r - rg); //understory NPP gC/m2 240 | //Xuhe Lu modify 241 | mid_res->npp_u = 0.45 * gpp_u; 242 | 243 | 244 | } 245 | 246 | 247 | 248 | -------------------------------------------------------------------------------- /BEPS-SIF/rainfall.c: -------------------------------------------------------------------------------- 1 | // rainfall_stage1 happens before evaporation of intercepted water from canopy (supply) 2 | // rainfall_stage2 happens after evaporation of intercepted water from canopy (demand) 3 | /*output: 4 | percentage of canopy covered by rainfall, overstorey and understorey (provided to evaporation_canopy); 5 | mass of water available for evaporation on canopy in this step 6 | precipitation on ground 7 | optical output: intercepted mass of rainfall in this step 8 | */ 9 | 10 | /*input: 11 | air temperature 12 | percipitation (m/s) 13 | remain of water on leaves from last step (kg/m2) per leaf area 14 | leaf area index of overstorey and understorey, excluding stem. 15 | length of this step (s), if 10min, then it is set as 600 16 | air temperature and humidity 17 | */ 18 | 19 | #include "beps.h" 20 | void rainfall_stage1(temp_air, precipitation,mass_water_o_last,mass_water_u_last, 21 | lai_o, lai_u, clumping, 22 | mass_water_o, mass_water_u, 23 | percent_water_o, percent_water_u,precipitation_g) 24 | 25 | double temp_air, precipitation; // (C),(m/s) 26 | double mass_water_o_last, mass_water_u_last; // remains of water from last step 27 | double lai_o, lai_u; // leaf area index, no stem 28 | double clumping; //clumping index 29 | //double length_step; 30 | double *mass_water_o, *mass_water_u; // mass of water on leaves, kg/m2, per ground area 31 | double *percent_water_o, *percent_water_u; 32 | double *precipitation_g; // precipitation on ground 33 | 34 | { 35 | double precipitation_o, precipitation_u; // rate of precipitation on overstorey, understorey and ground 36 | 37 | double massMax_water_o, massMax_water_u; // Maximum mass of water could be intercepted per leaf area, in kg/m2 38 | double massStep_water_o, massStep_water_u; // mass of water intercepted in this step per leaf area, in kg/m2 39 | double density_water; 40 | 41 | double length_step; 42 | 43 | length_step=kstep; 44 | 45 | if (temp_air < 0|| temp_air == 0) // temperature > 0, otherwise it is snow fall 46 | precipitation=0; 47 | 48 | density_water=1025.0; 49 | *precipitation_g=0; 50 | 51 | // overstorey 52 | precipitation_o=precipitation; 53 | *mass_water_o=mass_water_o_last+precipitation_o*length_step*density_water*(1-exp(-lai_o*clumping)); 54 | massMax_water_o=0.1*lai_o; 55 | 56 | *mass_water_o=max(0,*mass_water_o); 57 | *mass_water_o=min(massMax_water_o, *mass_water_o); 58 | 59 | massStep_water_o=(*mass_water_o)-mass_water_o_last; 60 | massStep_water_o=max(0,massStep_water_o); 61 | 62 | *percent_water_o = (*mass_water_o)/massMax_water_o; 63 | *percent_water_o = min(1,*percent_water_o); 64 | 65 | 66 | // understorey 67 | precipitation_u=precipitation_o-(massStep_water_o)/density_water/length_step; 68 | *mass_water_u=mass_water_u_last+precipitation_u*length_step*density_water*(1-exp(-lai_u*clumping)); 69 | massMax_water_u=0.1*lai_u; 70 | 71 | *mass_water_u=max(0,*mass_water_u); 72 | *mass_water_u=min(massMax_water_u, *mass_water_u); 73 | 74 | massStep_water_u=(*mass_water_u)-mass_water_u_last; 75 | massStep_water_u=max(0,massStep_water_u); 76 | 77 | *percent_water_u = (*mass_water_u)/massMax_water_u; 78 | *percent_water_u = min(1,*percent_water_u); 79 | 80 | 81 | //ground 82 | *precipitation_g=precipitation_u-(massStep_water_u)/density_water/length_step; 83 | } 84 | 85 | // this module will calculate the water remained on canopy surface after evaporation in this step (used for next step) 86 | // edited by XZ Luo, May 25, 2015 87 | 88 | // rainfall_stage1 happens before evaporation of intercepted water from canopy (supply) 89 | // rainfall_stage2 happens after evaporation of intercepted water from canopy (demand) 90 | // Note: rainfall on ground is considered in stage1, and then considered in surface water module (or soil moisture module) 91 | 92 | /*input: 93 | mass of water on leaves after precipitation in this step, 94 | evaporation from leaves in this step 95 | */ 96 | 97 | /*output: 98 | mass of water on leaves after the evaporation on leaves in this step (this value is transferred to next step) 99 | */ 100 | void rainfall_stage2(evapo_water_o, evapo_water_u, mass_water_o, mass_water_u) 101 | 102 | double evapo_water_o, evapo_water_u; // evaporation of intercepted rain in this step, overstorey and understorey, kg/m2/s = mm/s 103 | double *mass_water_o, *mass_water_u; // supply of rain on leaves, already added precipitation in this step 104 | 105 | { 106 | double length_step; // length of step 107 | length_step=kstep; 108 | 109 | *mass_water_o=*mass_water_o-evapo_water_o*length_step; 110 | *mass_water_o=max(0,*mass_water_o); 111 | 112 | *mass_water_u=*mass_water_u-evapo_water_u*length_step; 113 | *mass_water_u=max(0,*mass_water_u); 114 | } 115 | 116 | -------------------------------------------------------------------------------- /BEPS-SIF/read_all_lai.c: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | To read LAI data 3 | *************************************************************/ 4 | 5 | #include"beps.h" 6 | 7 | void readlai_all(lai0) 8 | float **lai0; 9 | { 10 | int l,p,jday,yd,x; 11 | float laiv; 12 | char laif[255]; 13 | FILE *laif_ptr; 14 | 15 | 16 | for (jday=1; jday<=361; jday=jday+8) 17 | { 18 | yd = yr*1000+jday; 19 | 20 | sprintf(laif,"%s%d.txt",lai_fn,yd); 21 | 22 | if ((laif_ptr=fopen(laif, "r")) == NULL) { 23 | printf("\n Unable to open laif file ...\n\n"); 24 | exit(0); } 25 | 26 | /* Read lai data for each pix */ 27 | for (l=0; l0.00001) coef[28]=0.25*(1-0.55-(0.003-0.009*clay1)); 145 | else coef[28]=0.25*(1-0.55-0.00001); 146 | 147 | /* coef[29]=0.0045*0.5; 148 | coef[30]=0.0045*0.5;*/ 149 | coef[29]=0.007*0.5; 150 | coef[30]=0.007*0.5; 151 | break; 152 | 153 | case 6: case 9: /* deciduous, tropic evergreen forest */ 154 | coef[0]=0.422354; 155 | coef[1]=0.108994; 156 | coef[2]=0.242626; 157 | coef[3]=0.226026; 158 | coef[4]=0.01680; 159 | coef[5]=0.0248; 160 | coef[6]=1; 161 | coef[7]=0.5948; 162 | coef[31]=650; 163 | coef[32]=380; 164 | coef[33]=100; 165 | coef[34]=190; 166 | coef[35]=350.26; 167 | coef[36]=56.532; 168 | coef[37]=56.532; 169 | coef[38]=56.532; 170 | coef[39]=56.532; 171 | coef[40]=32.74; 172 | coef[41]=350.26; 173 | coef[42]=56.532; 174 | coef[43]=56.532; 175 | coef[44]=12.0; 176 | coef[45]=10.0; 177 | coef[46]=1.3557; 178 | coef[47]=20.0; 179 | 180 | lignion_leaf=0.224/(0.15+0.018*0.6*coef[36]); 181 | lignion_fr=0.200/(0.15+0.018*0.6*coef[37]); 182 | lignion_wd=0.30; 183 | 184 | coef[8]=3.9*(exp(-3*lignion_leaf))*((1-lignion_leaf)*0.6+lignion_leaf*0.3); 185 | coef[9]=3.9*(exp(-3*lignion_leaf))*(1-lignion_leaf)*0.4; 186 | coef[10]=3.9*(exp(-3*lignion_leaf))*lignion_leaf*0.7; 187 | 188 | coef[11]=14.8*0.6; 189 | coef[12]=14.8*0.4; 190 | 191 | coef[13]= 4.8*(exp(-3*lignion_fr))*((1-lignion_fr)*0.55+lignion_fr*0.3); 192 | coef[14]= 4.8*(exp(-3*lignion_fr))*(1-lignion_fr)*0.45; 193 | coef[15]= 4.8*(exp(-3*lignion_fr))*lignion_fr*0.7; 194 | 195 | coef[16]=18.5*0.5; 196 | coef[17]=18.5*0.5; 197 | 198 | coef[18]= 2.4*(exp(-3*lignion_wd))*((1-lignion_wd)*0.55+lignion_wd*0.45); 199 | coef[19]= 2.4*(exp(-3*lignion_wd))*(1-lignion_wd)*0.45; 200 | coef[20]= 2.4*(exp(-3*lignion_wd))*lignion_wd*0.55; 201 | 202 | coef[21]= 7.3*(1-0.75*clay_silt1)*(0.85-0.68*clay_silt1); 203 | coef[22]= 7.3*(1-0.75*clay_silt1)*(0.003+0.032*clay1); 204 | coef[23]= 7.3*(1-0.75*clay_silt1)*(1-(0.003+0.032*clay1)-(0.85-0.68*clay_silt1)-5.0/18.0*(0.01+0.04*(1-clay_silt1))); 205 | 206 | coef[24]=6.0*0.6; 207 | coef[25]=6.0*0.4; 208 | 209 | coef[26]=0.25*0.55; 210 | coef[27]=0.25*(0.003-0.009*clay1); 211 | 212 | if(coef[27]<0.00001)coef[27]=0.00001; 213 | if((0.003-0.009*clay1)>0.00001) coef[28]=0.25*(1-0.55-(0.003-0.009*clay1)); 214 | else coef[28]=0.25*(1-0.55-0.00001); 215 | 216 | coef[29]=0.0045*0.5; 217 | coef[30]=0.0045*0.5; 218 | /* coef[29]=0.007*0.5; 219 | // coef[30]=0.007*0.5;*/ 220 | 221 | break; 222 | 223 | case 10: /* mix forest */ 224 | coef[0]=0.4; 225 | coef[1]=0.1; 226 | coef[2]=0.3; 227 | coef[3]=0.2; 228 | coef[4]=0.03; 229 | coef[5]=0.03; 230 | coef[6]=0.5; 231 | coef[7]=0.5; 232 | coef[31]=650; 233 | coef[32]=380; 234 | coef[33]=100; 235 | coef[34]=190; 236 | coef[35]=350.26; 237 | coef[36]=56.532; 238 | coef[37]=56.532; 239 | coef[38]=56.532; 240 | coef[39]=56.532; 241 | coef[40]=32.74; 242 | coef[41]=350.26; 243 | coef[42]=56.532; 244 | coef[43]=56.532; 245 | coef[44]=12.0; 246 | coef[45]=10.0; 247 | coef[46]=1.3557; 248 | coef[47]=20.0; 249 | 250 | lignion_leaf=0.224/(0.15+0.018*0.6*coef[36]); 251 | lignion_fr=0.200/(0.15+0.018*0.6*coef[37]); 252 | lignion_wd=0.30; 253 | 254 | coef[8]=3.9*(exp(-3*lignion_leaf))*((1-lignion_leaf)*0.6+lignion_leaf*0.3); 255 | coef[9]=3.9*(exp(-3*lignion_leaf))*(1-lignion_leaf)*0.4; 256 | coef[10]=3.9*(exp(-3*lignion_leaf))*lignion_leaf*0.7; 257 | 258 | coef[11]=14.8*0.6; 259 | coef[12]=14.8*0.4; 260 | 261 | coef[13]= 4.8*(exp(-3*lignion_fr))*((1-lignion_fr)*0.55+lignion_fr*0.3); 262 | coef[14]= 4.8*(exp(-3*lignion_fr))*(1-lignion_fr)*0.45; 263 | coef[15]= 4.8*(exp(-3*lignion_fr))*lignion_fr*0.7; 264 | 265 | coef[16]=18.5*0.5; 266 | coef[17]=18.5*0.5; 267 | 268 | coef[18]= 2.4*(exp(-3*lignion_wd))*((1-lignion_wd)*0.55+lignion_wd*0.45); 269 | coef[19]= 2.4*(exp(-3*lignion_wd))*(1-lignion_wd)*0.45; 270 | coef[20]= 2.4*(exp(-3*lignion_wd))*lignion_wd*0.55; 271 | 272 | coef[21]= 7.3*(1-0.75*clay_silt1)*(0.85-0.68*clay_silt1); 273 | coef[22]= 7.3*(1-0.75*clay_silt1)*(0.003+0.032*clay1); 274 | coef[23]= 7.3*(1-0.75*clay_silt1)*(1-(0.003+0.032*clay1)-(0.85-0.68*clay_silt1)-5.0/18.0*(0.01+0.04*(1-clay_silt1))); 275 | 276 | coef[24]=6.0*0.6; 277 | coef[25]=6.0*0.4; 278 | 279 | coef[26]=0.25*0.55; 280 | coef[27]=0.25*(0.003-0.009*clay1); 281 | 282 | if(coef[27]<0.00001)coef[27]=0.00001; 283 | if((0.003-0.009*clay1)>0.00001) coef[28]=0.25*(1-0.55-(0.003-0.009*clay1)); 284 | else coef[28]=0.25*(1-0.55-0.00001); 285 | 286 | coef[29]=0.0045*0.5; 287 | coef[30]=0.0045*0.5; 288 | /* coef[29]=0.007*0.5; 289 | // coef[30]=0.007*0.5;*/ 290 | 291 | break; 292 | 293 | case 13: /* shrub */ 294 | coef[0]=0.189428; 295 | coef[1]=0.053605; 296 | coef[2]=0.45; 297 | coef[3]=0.306967; 298 | coef[4]=0.025; 299 | coef[5]=0.04; 300 | coef[6]=0.8; 301 | coef[7]=0.75; 302 | coef[31]=650; 303 | coef[32]=380; 304 | coef[33]=100; 305 | coef[34]=190; 306 | coef[35]=370.26; 307 | coef[36]=63.532; 308 | coef[37]=63.532; 309 | coef[38]=63.532; 310 | coef[39]=63.532; 311 | coef[40]=32.74; 312 | coef[41]=370.26; 313 | coef[42]=63.532; 314 | coef[43]=63.532; 315 | coef[44]=12; 316 | coef[45]=10; 317 | coef[46]=1.3557; 318 | coef[47]=20; 319 | 320 | lignion_leaf=0.282/(0.15+0.018*0.6*coef[36]); 321 | lignion_fr=0.24/(0.15+0.018*0.6*coef[37]); 322 | lignion_wd=0.35; 323 | 324 | coef[8]=3.9*(exp(-3*lignion_leaf))*((1-lignion_leaf)*0.6+lignion_leaf*0.3); 325 | coef[9]=3.9*(exp(-3*lignion_leaf))*(1-lignion_leaf)*0.4; 326 | coef[10]=3.9*(exp(-3*lignion_leaf))*lignion_leaf*0.7; 327 | 328 | coef[11]=14.8*0.6; 329 | coef[12]=14.8*0.4; 330 | 331 | coef[13]= 4.8*(exp(-3*lignion_fr))*((1-lignion_fr)*0.55+lignion_fr*0.3); 332 | coef[14]= 4.8*(exp(-3*lignion_fr))*(1-lignion_fr)*0.45; 333 | coef[15]= 4.8*(exp(-3*lignion_fr))*lignion_fr*0.7; 334 | 335 | coef[16]=18.5*0.5; 336 | coef[17]=18.5*0.5; 337 | 338 | coef[18]= 2.4*(exp(-3*lignion_wd))*((1-lignion_wd)*0.55+lignion_wd*0.45); 339 | coef[19]= 2.4*(exp(-3*lignion_wd))*(1-lignion_wd)*0.45; 340 | coef[20]= 2.4*(exp(-3*lignion_wd))*lignion_wd*0.55; 341 | 342 | coef[21]= 7.3*(1-0.75*clay_silt1)*(0.85-0.68*clay_silt1); 343 | coef[22]= 7.3*(1-0.75*clay_silt1)*(0.003+0.032*clay1); 344 | coef[23]= 7.3*(1-0.75*clay_silt1)*(1-(0.003+0.032*clay1)-(0.85-0.68*clay_silt1)-5.0/18.0*(0.01+0.04*(1-clay_silt1))); 345 | 346 | coef[24]=6.0*0.6; 347 | coef[25]=6.0*0.4; 348 | 349 | coef[26]=0.25*0.55; 350 | coef[27]=0.25*(0.003-0.009*clay1); 351 | 352 | if(coef[27]<0.00001)coef[27]=0.00001; 353 | if((0.003-0.009*clay1)>0.00001) coef[28]=0.25*(1-0.55-(0.003-0.009*clay1)); 354 | else coef[28]=0.25*(1-0.55-0.00001); 355 | 356 | coef[29]=0.007*0.5; 357 | coef[30]=0.007*0.5; 358 | /* coef[29]=0.0045*0.5; 359 | // coef[30]=0.0045*0.5;*/ 360 | break; 361 | case 14: case 15: /* grassland and cropland */ 362 | coef[0]=0.0; 363 | coef[1]=0.0; 364 | coef[2]=0.5; 365 | coef[3]=0.5; 366 | coef[4]=0.0001; 367 | coef[5]=0.0001; 368 | coef[6]=1.0; 369 | coef[7]=0.75; 370 | coef[31]=650; 371 | coef[32]=380; 372 | coef[33]=100; 373 | coef[34]=190; 374 | coef[35]=370.26; 375 | coef[36]=63.532; 376 | coef[37]=63.532; 377 | coef[38]=63.532; 378 | coef[39]=63.532; 379 | coef[40]=32.74; 380 | coef[41]=370.26; 381 | coef[42]=63.532; 382 | coef[43]=63.532; 383 | coef[44]=12; 384 | coef[45]=10; 385 | coef[46]=1.3557; 386 | coef[47]=20; 387 | 388 | lignion_leaf=0.282/(0.15+0.018*0.6*coef[36]); 389 | lignion_fr=0.24/(0.15+0.018*0.6*coef[37]); 390 | lignion_wd=0.35; 391 | 392 | coef[8]=3.9*(exp(-3*lignion_leaf))*((1-lignion_leaf)*0.6+lignion_leaf*0.3); 393 | coef[9]=3.9*(exp(-3*lignion_leaf))*(1-lignion_leaf)*0.4; 394 | coef[10]=3.9*(exp(-3*lignion_leaf))*lignion_leaf*0.7; 395 | 396 | coef[11]=14.8*0.6; 397 | coef[12]=14.8*0.4; 398 | 399 | coef[13]= 4.8*(exp(-3*lignion_fr))*((1-lignion_fr)*0.55+lignion_fr*0.3); 400 | coef[14]= 4.8*(exp(-3*lignion_fr))*(1-lignion_fr)*0.45; 401 | coef[15]= 4.8*(exp(-3*lignion_fr))*lignion_fr*0.7; 402 | 403 | coef[16]=18.5*0.5; 404 | coef[17]=18.5*0.5; 405 | 406 | coef[18]= 2.4*(exp(-3*lignion_wd))*((1-lignion_wd)*0.55+lignion_wd*0.45); 407 | coef[19]= 2.4*(exp(-3*lignion_wd))*(1-lignion_wd)*0.45; 408 | coef[20]= 2.4*(exp(-3*lignion_wd))*lignion_wd*0.55; 409 | 410 | coef[21]= 7.3*(1-0.75*clay_silt1)*(0.85-0.68*clay_silt1); 411 | coef[22]= 7.3*(1-0.75*clay_silt1)*(0.003+0.032*clay1); 412 | coef[23]= 7.3*(1-0.75*clay_silt1)*(1-(0.003+0.032*clay1)-(0.85-0.68*clay_silt1)-5.0/18.0*(0.01+0.04*(1-clay_silt1))); 413 | 414 | coef[24]=6.0*0.6; 415 | coef[25]=6.0*0.4; 416 | 417 | coef[26]=0.25*0.55; 418 | coef[27]=0.25*(0.003-0.009*clay1); 419 | 420 | if(coef[27]<0.00001)coef[27]=0.00001; 421 | if((0.003-0.009*clay1)>0.00001) coef[28]=0.25*(1-0.55-(0.003-0.009*clay1)); 422 | else coef[28]=0.25*(1-0.55-0.00001); 423 | 424 | coef[29]=0.007*0.5; 425 | coef[30]=0.007*0.5; 426 | /* coef[29]=0.0045*0.5; 427 | // coef[30]=0.0045*0.5;*/ 428 | break; 429 | 430 | default: /* others landcover */ 431 | coef[0]=0.331684; 432 | coef[1]=0.053605; 433 | coef[2]=0.307745; 434 | coef[3]=0.306967; 435 | coef[4]=0.0278; 436 | coef[5]=0.0448; 437 | coef[6]=0.39448; 438 | coef[7]=0.5948; 439 | 440 | coef[31]=650; 441 | coef[32]=380; 442 | coef[33]=100; 443 | coef[34]=190; 444 | coef[35]=370.26; 445 | coef[36]=63.532; 446 | coef[37]=63.532; 447 | coef[38]=63.532; 448 | coef[39]=63.532; 449 | coef[40]=32.74; 450 | coef[41]=370.26; 451 | coef[42]=63.532; 452 | coef[43]=63.532; 453 | coef[44]=12; 454 | coef[45]=10; 455 | coef[46]=1.3557; 456 | coef[47]=20; 457 | 458 | lignion_leaf=0.6*0.224/(0.15+0.018*0.6*coef[36]); 459 | lignion_fr=0.6*0.200/(0.15+0.018*0.6*coef[37]); 460 | lignion_wd=0.30; 461 | 462 | coef[8]=3.9*(exp(-3*lignion_leaf))*((1-lignion_leaf)*0.6+lignion_leaf*0.3); 463 | coef[9]=3.9*(exp(-3*lignion_leaf))*(1-lignion_leaf)*0.4; 464 | coef[10]=3.9*(exp(-3*lignion_leaf))*lignion_leaf*0.7; 465 | 466 | coef[11]=14.8*0.6; 467 | coef[12]=14.8*0.4; 468 | 469 | coef[13]= 4.8*(exp(-3*lignion_fr))*((1-lignion_fr)*0.55+lignion_fr*0.3); 470 | coef[14]= 4.8*(exp(-3*lignion_fr))*(1-lignion_fr)*0.45; 471 | coef[15]= 4.8*(exp(-3*lignion_fr))*lignion_fr*0.7; 472 | 473 | coef[16]=18.5*0.5; 474 | coef[17]=18.5*0.5; 475 | 476 | coef[18]= 2.4*(exp(-3*lignion_wd))*((1-lignion_wd)*0.55+lignion_wd*0.45); 477 | coef[19]= 2.4*(exp(-3*lignion_wd))*(1-lignion_wd)*0.45; 478 | coef[20]= 2.4*(exp(-3*lignion_wd))*lignion_wd*0.55; 479 | 480 | coef[21]= 7.3*(1-0.75*clay_silt1)*(0.85-0.68*clay_silt1); 481 | coef[22]= 7.3*(1-0.75*clay_silt1)*(0.003+0.032*clay1); 482 | coef[23]= 7.3*(1-0.75*clay_silt1)*(1-(0.003+0.032*clay1)-(0.85-0.68*clay_silt1)-5.0/18.0*(0.01+0.04*(1-clay_silt1))); 483 | 484 | coef[24]=6.0*0.6; 485 | coef[25]=6.0*0.4; 486 | 487 | coef[26]=0.25*0.55; 488 | coef[27]=0.25*(0.003-0.009*clay1); 489 | 490 | if(coef[27]<0.00001)coef[27]=0.00001; 491 | if((0.003-0.009*clay1)>0.00001) coef[28]=0.25*(1-0.55-(0.003-0.009*clay1)); 492 | else coef[28]=0.25*(1-0.55-0.00001); 493 | 494 | coef[29]=0.007*0.5; 495 | coef[30]=0.007*0.5; 496 | /* coef[29]=0.0045*0.5; 497 | // coef[30]=0.0045*0.5;*/ 498 | 499 | } 500 | 501 | return; 502 | } 503 | -------------------------------------------------------------------------------- /BEPS-SIF/readcontrolf_b.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | readcontrolf.c 3 | -------- 4 | To Read a model control file. 5 | A control file contains input/output files' path and names. 6 | *****************************************************************************/ 7 | #include "beps.h" 8 | 9 | void readconf(conf) 10 | char conf[]; /* control file name */ 11 | { 12 | 13 | char field_descr[255]; /* Field description in control file */ 14 | FILE *fcon; /* Control file pointer */ 15 | 16 | /* If can not open control parameter file */ 17 | if ((fcon = fopen(conf,"r")) == NULL) 18 | { 19 | printf("Can not open parameter file <%s>, exitting program ...\n",conf); 20 | exit(0); 21 | } 22 | 23 | /* Read control file parameters */ 24 | fscanf(fcon,"%s %d", field_descr, &yr); 25 | fscanf(fcon,"%s %d", field_descr, &bgn_day); 26 | fscanf(fcon,"%s %d", field_descr, &end_day); 27 | fscanf(fcon,"%s %d", field_descr, &nlines); 28 | fscanf(fcon,"%s %d", field_descr, &npixels); 29 | fscanf(fcon,"%s %s", field_descr, lc_fn); 30 | fscanf(fcon,"%s %s", field_descr, lai_fn); 31 | fscanf(fcon,"%s %s", field_descr, stxt_fn); 32 | fscanf(fcon,"%s %s", field_descr, ci_fn); 33 | fscanf(fcon,"%s %s", field_descr, lon_fn); 34 | fscanf(fcon,"%s %s", field_descr, lat_fn); 35 | fscanf(fcon,"%s %s", field_descr, st_fn); 36 | fscanf(fcon,"%s %s", field_descr, sw_fn); 37 | fscanf(fcon,"%s %s", field_descr, sdp_fn); 38 | fscanf(fcon,"%s %s", field_descr, r_fn); 39 | fscanf(fcon,"%s %s", field_descr, t_fn); 40 | fscanf(fcon,"%s %s", field_descr, h_fn); 41 | fscanf(fcon,"%s %s", field_descr, p_fn); 42 | fscanf(fcon,"%s %s", field_descr, wd_fn); 43 | 44 | fscanf(fcon,"%s %s", field_descr, laiy_fn); 45 | fscanf(fcon,"%s %s", field_descr, nppy_fn); 46 | fscanf(fcon,"%s %s", field_descr, ccd_fn); 47 | fscanf(fcon,"%s %s", field_descr, cssd_fn); 48 | fscanf(fcon,"%s %s", field_descr, csmd_fn); 49 | fscanf(fcon,"%s %s", field_descr, cfsd_fn); 50 | fscanf(fcon,"%s %s", field_descr, cfmd_fn); 51 | fscanf(fcon,"%s %s", field_descr, csm_fn); 52 | fscanf(fcon,"%s %s", field_descr, cm_fn); 53 | fscanf(fcon,"%s %s", field_descr, cs_fn); 54 | fscanf(fcon,"%s %s", field_descr, cp_fn); 55 | 56 | fscanf(fcon,"%s %s", field_descr, fp4outp1); 57 | fscanf(fcon,"%s %s", field_descr, fp4outp2); 58 | fscanf(fcon,"%s %s", field_descr, fp4outp3); 59 | 60 | 61 | /* Output control parameters */ 62 | printf("\n Simulating...\n"); 63 | printf(" day: %d - %d year: %d\n",bgn_day,end_day,yr); 64 | // printf(" LC: %s CI: %s soilt: %s\n",lc_fn,ci_fn,stxt_fn); 65 | // printf(" output: %s %s %s\n",fp4outp1,fp4outp2,fp4outp3); 66 | 67 | 68 | fclose(fcon); 69 | 70 | } 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /BEPS-SIF/readlonlat.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | Read longitude and latitude from a file in a given line. 3 | *****************************************************************************/ 4 | #include 5 | #include 6 | #include 7 | #include "beps.h" 8 | 9 | void readlonlat(lon,lat) 10 | float **lon,**lat; 11 | { 12 | short line,pix; 13 | float lcv; 14 | FILE *lon_ptr,*lat_ptr; 15 | 16 | /* Open longitude file */ 17 | if ((lon_ptr=fopen(lon_fn, "r")) == NULL) 18 | { printf("\n Unable to open lon. file, exitting...\n"); 19 | exit(0); 20 | } 21 | /* Open latitude file */ 22 | if ((lat_ptr=fopen(lat_fn, "r")) == NULL) 23 | { printf("\n Unable to open lat. file, exitting...\n"); 24 | exit(0); 25 | } 26 | 27 | for (line = 0; line 24) hr=24-hr; 25 | if (hr<0) hr=24+hr; 26 | 27 | Lat_arc=3.1415926*lat/180.0; 28 | Hsolar1 = (hr - 12.0) * 2.0 *3.1415926 / 24.0; /*local hour angle in arc. */ 29 | 30 | *CosZs = cos(Delta) * cos(Lat_arc) * cos(Hsolar1) + sin(Delta) * sin(Lat_arc); 31 | } 32 | -------------------------------------------------------------------------------- /BEPS-SIF/sensible_heat.c: -------------------------------------------------------------------------------- 1 | // this module will calculate sensible heat from overstorey, understorey and ground 2 | // edited by XZ Luo, May 23, 2015 3 | /* input includes: 4 | temperature of sunlit and shaded leaves from other storey (leaf temperature module); 5 | temperature of air, relative humidity, 6 | temperature of ground (soil heat flux module); 7 | aerodynamic heat conductance of sunlit shaded leaves from overstorey and understorey; 8 | aerodynamic heat conductance of ground; 9 | leaf area index, sunlit and shaded, overstorey and understorey (from leaf area index module); 10 | */ 11 | 12 | /* output includes: 13 | sensible heat from overstorey, understorey and ground*/ 14 | # include "beps.h" 15 | void sensible_heat (tempL_o_sunlit, tempL_o_shaded, tempL_u_sunlit, tempL_u_shaded, temp_g, temp_air, rh_air, 16 | Gheat_o_sunlit, Gheat_o_shaded, Gheat_u_sunlit, Gheat_u_shaded, Gheat_g, 17 | lai_o_sunlit, lai_o_shaded, lai_u_sunlit, lai_u_shaded, 18 | SH_o, SH_u, SH_g) 19 | 20 | double tempL_o_sunlit, tempL_o_shaded, tempL_u_sunlit, tempL_u_shaded; //temperature of overstorey, understorey, sunlit and shaded 21 | double temp_g; // temperature of ground 22 | double temp_air, rh_air; 23 | double Gheat_o_sunlit, Gheat_o_shaded, Gheat_u_sunlit, Gheat_u_shaded; // aerodynamic resistance of heat for each part 24 | double Gheat_g; 25 | double lai_o_sunlit, lai_o_shaded, lai_u_sunlit, lai_u_shaded; // lai 26 | double *SH_o, *SH_u, *SH_g; // output sensible heat 27 | { 28 | double SH_o_sunlit, SH_o_shaded, SH_u_sunlit, SH_u_shaded; // sensible heat from leaves 29 | double meteo_pack_output[10]; 30 | double density_air0, cp_air, vpd; 31 | 32 | meteo_pack (temp_air, rh_air, meteo_pack_output); 33 | density_air0 =meteo_pack_output[1]; 34 | cp_air = meteo_pack_output[2]; 35 | vpd = meteo_pack_output[3]; 36 | 37 | ////////////// 38 | SH_o_sunlit=(tempL_o_sunlit-temp_air)*density_air0*cp_air*Gheat_o_sunlit; 39 | SH_o_shaded=(tempL_o_shaded-temp_air)*density_air0*cp_air*Gheat_o_shaded; 40 | 41 | SH_u_sunlit=(tempL_u_sunlit-temp_air)*density_air0*cp_air*Gheat_u_sunlit; 42 | SH_u_shaded=(tempL_u_shaded-temp_air)*density_air0*cp_air*Gheat_u_shaded; 43 | /////////////// 44 | 45 | *SH_o = SH_o_sunlit*lai_o_sunlit+SH_o_shaded*lai_o_shaded; 46 | *SH_u = SH_u_sunlit*lai_u_sunlit+SH_u_shaded*lai_u_shaded; 47 | 48 | *SH_o=max(-200, *SH_o); 49 | *SH_u=max(-200, *SH_u); 50 | 51 | *SH_g=(temp_g-temp_air)*density_air0*cp_air*Gheat_g; 52 | } 53 | -------------------------------------------------------------------------------- /BEPS-SIF/snowpack.c: -------------------------------------------------------------------------------- 1 | // this module will calculate the percentage of canopy and ground covered by snow 2 | // and output albedo of snow (used in energy balance) and density of snow in this step 3 | // edited by XZ Luo, May 25, 2015 4 | 5 | // snowpack_stage1 happens before any consumption of snow in this step, after the snow fall (supply) 6 | // snowpack_stage2 happens after sublimation from ground and canopy (demand) 7 | // snowpack stage3 happens after frozen and melt of snow pack (demand) 8 | 9 | /* input: air temperature, precipitation,depth of snow from last step 10 | density of snow from last step, mass of snow on canopy and ground (per ground area) from last step 11 | length of step 12 | leaf area index of overstorey and understorey, excluding stem. 13 | albedo of snow from last step 14 | */ 15 | 16 | /* output: 17 | mass of snow on canopy and ground accumulation of snowfall 18 | albedo of snow in this step 19 | density of snow in this step 20 | */ 21 | # include "beps.h" 22 | void snowpack_stage1 (temp_air, precipitation, mass_snow_o_last,mass_snow_u_last,mass_snow_g_last, 23 | mass_snow_o, mass_snow_u,mass_snow_g, lai_o,lai_u,clumping, 24 | area_snow_o, area_snow_u, percent_snow_o, percent_snow_u, percent_snow_g, 25 | density_snow, depth_snow, albedo_v_snow, albedo_n_snow) 26 | 27 | double temp_air, precipitation; // air temperature, and precipitation (m/s) 28 | double mass_snow_o_last, mass_snow_u_last, mass_snow_g_last; // weight of snow on overstorey, understorey and ground from last step 29 | double *mass_snow_o, *mass_snow_u, *mass_snow_g; // mass of intercepted snow on canopy and ground, input from last step, kg/m2 30 | double lai_o, lai_u, clumping; // overstorey and understorey lai, clumping index 31 | double *area_snow_o, *area_snow_u; // area of snow at overstorey and understorey 32 | double *percent_snow_o, *percent_snow_u, *percent_snow_g; // percentage of snow cover on canopy and ground, DECIDED by weight 33 | double *density_snow; //input from last step, then changed in this module, density of snowpack on ground 34 | double *depth_snow; //input from last step, changed here, then changed in stage2 35 | double *albedo_v_snow, *albedo_n_snow; //albedo of snow, input from this step, changed in this module 36 | //double *deltaz; 37 | 38 | { 39 | double massMax_snow_o, massMax_snow_u; // maximum weight of snow on overstorey and understorey 40 | double massStep_snow_o, massStep_snow_u;// weight (mass) of snow accumulated in this step 41 | 42 | double areaMax_snow_o, areaMax_snow_u; // Maximum area of snow at overstorey and understorey 43 | 44 | double change_depth_snow; //change of snow depth on ground 45 | double density_water, density_new_snow; // density of water, density of newly fallen snow 46 | double snowrate, snowrate_o, snowrate_u, snowrate_g; // snowrate, and snowrate for every part 47 | double albedo_v_Newsnow, albedo_n_Newsnow; // albedo of newly fallen snow in visible and near infrared band 48 | 49 | double length_step; 50 | 51 | length_step=kstep; 52 | 53 | density_new_snow=67.9+51.3*exp(temp_air/2.6); 54 | density_water=1025; 55 | albedo_v_Newsnow=0.94; 56 | albedo_n_Newsnow=0.8; 57 | 58 | massMax_snow_o=0.1*lai_o; 59 | massMax_snow_u=0.1*lai_u; 60 | areaMax_snow_o=lai_o*0.01; 61 | areaMax_snow_u=lai_u*0.01; 62 | 63 | mass_snow_o_last=*mass_snow_o; 64 | mass_snow_u_last=*mass_snow_u; 65 | mass_snow_g_last=*mass_snow_g; 66 | 67 | //////// 68 | 69 | if (temp_air>0) // if temperature >0, no snow fall 70 | snowrate=0; 71 | else 72 | snowrate=precipitation*density_water/density_new_snow; 73 | 74 | if (temp_air<0) // there is snow 75 | { 76 | //overstorey 77 | snowrate_o=snowrate; 78 | *mass_snow_o=mass_snow_o_last+snowrate_o*length_step*density_new_snow*(1-exp(-lai_o*clumping)); 79 | 80 | *percent_snow_o = *mass_snow_o/massMax_snow_o; 81 | *percent_snow_o = max(0,*percent_snow_o); 82 | *percent_snow_o = min(1,*percent_snow_o); 83 | 84 | // change the weight based percentage to area based percentage 85 | 86 | *area_snow_o=*percent_snow_o*areaMax_snow_o; 87 | //*percentArea_snow_o=area_snow_o/(lai_o)/2; 88 | 89 | massStep_snow_o=*mass_snow_o-mass_snow_o_last; 90 | 91 | //understorey 92 | snowrate_u=snowrate_o-(massStep_snow_o)/density_new_snow/length_step; 93 | snowrate_u=max(0,snowrate_u); 94 | 95 | *mass_snow_u=mass_snow_u_last+snowrate_u*length_step*density_new_snow*(1-exp(-lai_u*clumping)); 96 | 97 | *percent_snow_u = *mass_snow_u/massMax_snow_u; 98 | *percent_snow_u = max(0,*percent_snow_u); 99 | *percent_snow_u = min(1,*percent_snow_u); 100 | 101 | // change the weight based percentage to area based percentage 102 | 103 | *area_snow_u=*percent_snow_u*areaMax_snow_u; 104 | //*percentArea_snow_u=area_snow_u/(lai_u)/2; 105 | 106 | massStep_snow_u=*mass_snow_u-mass_snow_u_last; 107 | 108 | //ground, output mass of snow, percent of snow coverage, density of snow, depth of snow 109 | snowrate_g=snowrate_u-(massStep_snow_u)/density_new_snow/length_step; 110 | snowrate_g=max(0,snowrate_g); 111 | 112 | change_depth_snow=snowrate_g*length_step; 113 | } 114 | else 115 | { 116 | //overstorey 117 | *mass_snow_o = mass_snow_o_last; 118 | *percent_snow_o = *mass_snow_o/massMax_snow_o; 119 | *percent_snow_o = max(0,*percent_snow_o); 120 | *percent_snow_o = min(1,*percent_snow_o); 121 | 122 | *area_snow_o = *area_snow_o; 123 | 124 | // understorey 125 | *mass_snow_u = mass_snow_u_last; 126 | *percent_snow_u = *mass_snow_u/massMax_snow_u; 127 | *percent_snow_u = max(0,*percent_snow_u); 128 | *percent_snow_u = min(1,*percent_snow_u); 129 | *area_snow_u = *area_snow_u; 130 | 131 | //ground 132 | change_depth_snow=0; 133 | 134 | } 135 | change_depth_snow=max(0,change_depth_snow); 136 | *mass_snow_g=mass_snow_g_last+change_depth_snow*density_new_snow; 137 | *mass_snow_g=max(0,*mass_snow_g); 138 | 139 | if (change_depth_snow > 0) 140 | *density_snow=(*density_snow*(*depth_snow)+density_new_snow*change_depth_snow)/((*depth_snow)+change_depth_snow); 141 | else 142 | *density_snow=(*density_snow-250)*exp(-0.001*length_step/3600.0) + 250.0; 143 | 144 | if (*mass_snow_g > 0) 145 | *depth_snow=*mass_snow_g/(*density_snow); 146 | else 147 | *depth_snow=0; 148 | 149 | *percent_snow_g=*mass_snow_g/(0.05*(*density_snow)); 150 | *percent_snow_g=min(*percent_snow_g,1); 151 | 152 | //*deltaz=change_depth_snow; 153 | // albedo of snow in this step 154 | if (snowrate_o>0) 155 | { 156 | *albedo_v_snow=(*albedo_v_snow-0.70)*exp(-0.005*length_step/3600)+0.7; 157 | *albedo_n_snow=(*albedo_n_snow-0.42)*exp(-0.005*length_step/3600)+0.42; 158 | } 159 | else 160 | { 161 | *albedo_v_snow=albedo_v_Newsnow; 162 | *albedo_n_snow=albedo_n_Newsnow; 163 | } 164 | 165 | 166 | } 167 | 168 | // this module will calculate the snow remained on canopy surface after evaporation in this step 169 | // edited by XZ Luo, May 25, 2015 170 | 171 | // snowpack_stage1 happens before any consumption of snow in this step, after the snow fall (supply) 172 | // snowpack_stage2 happens after sublimation from ground and canopy (demand) 173 | // snowpack stage3 happens after frozen and melt of snow pack (demand) 174 | 175 | /*input: 176 | mass of snow on leaves after precipitation in this step, 177 | sublimation from leaves in this step 178 | */ 179 | 180 | /*output: 181 | mass of snow on leaves after the sublimation on leaves in this step 182 | */ 183 | void snowpack_stage2(evapo_snow_o, evapo_snow_u, mass_snow_o, mass_snow_u) 184 | 185 | double evapo_snow_o, evapo_snow_u; // evaporation of intercepted rain in this step, overstorey and understorey, kg/m2/s = mm/s 186 | double *mass_snow_o, *mass_snow_u; // supply of rain on leaves, already added precipitation in this step 187 | 188 | { 189 | double length_step; // length of step 190 | length_step=kstep; 191 | 192 | *mass_snow_o=*mass_snow_o-evapo_snow_o*length_step; 193 | *mass_snow_o=max(0,*mass_snow_o); 194 | 195 | *mass_snow_u=*mass_snow_u-evapo_snow_u*length_step; 196 | *mass_snow_u=max(0,*mass_snow_u); 197 | } 198 | 199 | // This module simulates the process of snow melting and water frozen in this step 200 | // edited by XZ Luo, May 27 2015 201 | 202 | // snowpack_stage1 happens before any consumption of snow in this step, after the snow fall (supply) 203 | // snowpack_stage2 happens after sublimation from ground and canopy (demand) 204 | // snowpack stage3 happens after frozen and melt of snow pack (demand) 205 | 206 | /* input: 207 | depth of snow on ground after stage 1, 208 | air temperature, 209 | ground surface temperature 210 | */ 211 | 212 | /* output: 213 | the amount of the melted snow, frozen snow 214 | */ 215 | 216 | void snowpack_stage3(temp_air, temp_snow, temp_snow_last, 217 | density_snow, depth_snow, depth_water, mass_snow_g) 218 | 219 | double temp_air; // temperature of air in this step 220 | double temp_snow, temp_snow_last; // temperature of snow in this step and last step 221 | 222 | //double evapo_snow_g; // sublimation of snow on ground, input from evaporation_soil module, in mm/s 223 | double density_snow; // density of snow output from stage1 224 | double *depth_snow, *mass_snow_g; //depth and mass of snow on ground after stage1 225 | double *depth_water; //depth of water after all precipitation and evaporation 226 | 227 | { 228 | double depth_snow_sup, mass_snow_sup; // depth and mass of snow after stage1, and minus the amount of sublimation. ( or the total supply of snow in this step) 229 | double mass_snow_melt, mass_water_frozen; // newly melted or forzen snow in this step, kg/m2; 230 | double cp_ice; // specific heat of ice 2228.261 J/kg/C 231 | double latent_fusion; // latent heat for fusion 3.34*1000000 J/kg 232 | double density_water; 233 | 234 | double melt_depth_snow, frozen_depth_snow; // change of snow weight valued in depth of snow 235 | double melt_depth_water, frozen_depth_water; // change of snow weight valued in depth of water 236 | 237 | double length_step; // length_step in model 238 | 239 | length_step=kstep; 240 | 241 | //// it is assumed sublimation happens before the metling and freezing process 242 | depth_snow_sup=*depth_snow; // this snow depth has already consider sublimation 243 | mass_snow_sup=*mass_snow_g; 244 | 245 | //parameters 246 | cp_ice=2228.261; 247 | latent_fusion=3.34*1000000; 248 | density_water=1025; 249 | 250 | //simulate snow melt and freeze process 251 | mass_snow_melt=0; 252 | mass_water_frozen=0; 253 | // case 1 depth of snow <0.02 m 254 | if (depth_snow_sup<=0.02) 255 | { 256 | if (temp_air>0 && depth_snow_sup >0) 257 | { 258 | mass_snow_melt=temp_air*0.0075*length_step/3600*0.3; 259 | mass_snow_melt=min(mass_snow_sup, mass_snow_melt); // the amount of melted snow could not be larger than supply 260 | } 261 | else 262 | mass_snow_melt=0; 263 | } 264 | 265 | //case 2 depth of snow > 0.02 < 0.05 m 266 | else if (depth_snow_sup > 0.02 && depth_snow_sup <=0.05) 267 | { 268 | if (temp_snow>0 && temp_snow_last<0 && mass_snow_sup > 0) // metling 269 | { 270 | mass_snow_melt=temp_snow*cp_ice*density_snow*depth_snow_sup/latent_fusion; 271 | mass_snow_melt=min(mass_snow_sup, mass_snow_melt); // the amount of melted snow could not be larger than supply 272 | } 273 | else 274 | mass_snow_melt=0; 275 | 276 | if (temp_snow<=0 && temp_snow_last >0 && *depth_water>0) //freezing 277 | { 278 | mass_water_frozen=(0-temp_snow)*cp_ice*density_snow*depth_snow_sup/latent_fusion; 279 | mass_water_frozen=max(mass_water_frozen,*depth_water*density_water); 280 | } 281 | else 282 | mass_water_frozen=0; 283 | } 284 | 285 | ////case 3 depth of snow > 0.05 m 286 | else if(depth_snow_sup>0.05) 287 | { 288 | if (temp_snow>0 && temp_snow_last<=0 && mass_snow_sup > 0) // metling 289 | { 290 | mass_snow_melt=temp_snow*cp_ice*density_snow*depth_snow_sup*0.02/latent_fusion; 291 | mass_snow_melt=min(mass_snow_sup, mass_snow_melt); // the amount of melted snow could not be larger than supply 292 | } 293 | else 294 | mass_snow_melt=0; 295 | 296 | if (temp_snow<=0 && temp_snow_last >0 && *depth_water>0) //freezing 297 | { 298 | mass_water_frozen=(0-temp_snow)*cp_ice*density_snow*depth_snow_sup*0.02/latent_fusion; 299 | mass_water_frozen=max(mass_water_frozen,*depth_water*density_water); 300 | } 301 | else 302 | mass_water_frozen=0; 303 | } 304 | 305 | // change in mass of snow on ground 306 | *mass_snow_g=*mass_snow_g-mass_snow_melt+mass_water_frozen; 307 | *mass_snow_g=max(0,*mass_snow_g); 308 | 309 | // change of depth in snow 310 | melt_depth_snow=mass_snow_melt/density_snow; 311 | frozen_depth_snow=mass_water_frozen/density_snow; 312 | // *depth_snow=depth_snow_sup-melt_depth_snow+frozen_depth_water; 313 | *depth_snow=depth_snow_sup-melt_depth_snow+frozen_depth_snow; 314 | *depth_snow=max(0,*depth_snow); 315 | 316 | // change of depth in water 317 | melt_depth_water=mass_snow_melt/density_water; 318 | frozen_depth_water=mass_water_frozen/density_water; 319 | *depth_water=*depth_water+melt_depth_water-frozen_depth_water; 320 | *depth_water=max(0,*depth_water); 321 | } 322 | 323 | -------------------------------------------------------------------------------- /BEPS-SIF/soil.h: -------------------------------------------------------------------------------- 1 | // Header file for struct Soil 2 | // Created on Dec. 05, 2012 by Liming He 3 | // Last revision on May 15, 2015 4 | 5 | #ifndef SOIL_H 6 | #define SOIL_H 7 | 8 | #define FW_VERSION 1 // 0 for soil water uptake using R, and 1 for soil water uptake using R*fpsisr 9 | 10 | #define max(a,b) ((a)>(b))?(a):(b) 11 | #define min(a,b) ((a)<(b))?(a):(b) 12 | 13 | // Note: change the value of MAX_LAYERS to a small one for global application 14 | // e. g. max layers = 6. 15 | #define MAX_LAYERS 10 // LHE. Jan 28, 2013. 16 | #define DEPTH_F 6 17 | 18 | struct Soil{ 19 | ////////////////////////////////////////////////////////////////////////////////////////////////////// 20 | // Properties belong to the whole soil profile 21 | int flag; // reserved for EnKF usage. 22 | int n_layer; /* the number of layers used in the model. Make sure n_layer <= MAX_LAYERS */ 23 | int step_peroid; 24 | 25 | /* condition on the top boundary */ 26 | double Zp; /* depth of ponded water on the ground surface*/ 27 | double Zsp; /*Snow depth;*/ 28 | double r_rain_g; /*the rainfall rate, un--on understory g--on ground surface m/s */ 29 | double soil_r; // soil surface resistance for water, disuss with Remi - an interface here. 30 | double r_drainage; 31 | 32 | /* some variable used for soil */ 33 | //double t1; 34 | //double t2; 35 | double r_root_decay; /* decay_rate_of_root_distribution */ 36 | double psi_min; // for fw 37 | double alpha; // for fw 38 | double f_soilwater; 39 | 40 | ///////////////////////////////////////////////////////////////////////////////////////////////////////// 41 | // Properties belong to each soil horizon 42 | double d_soil[MAX_LAYERS]; 43 | double f_root[MAX_LAYERS]; /* root weight*/ 44 | double dt[MAX_LAYERS]; /* the weight calcualted from soil_water_factor **re-calculate in the model*/ 45 | // from read-param 46 | double thermal_cond[MAX_LAYERS]; /* thermal conductivity. Unit: */ 47 | double theta_vfc[MAX_LAYERS]; /* field capacity */ // not used in this model. LHE. Feb. 01, 2013 48 | double theta_vwp[MAX_LAYERS]; /* wilt point*/ 49 | double fei[MAX_LAYERS]; /* porosity */ 50 | double Ksat[MAX_LAYERS]; /* saturated hydraulic conductivity */ 51 | double psi_sat[MAX_LAYERS]; /* water potential at sat */ 52 | double b[MAX_LAYERS]; /* Cambell parameter b */ 53 | double density_soil[MAX_LAYERS]; // soil bulk density of layer. LHE. Feb. 12, 2013. 54 | double f_org[MAX_LAYERS]; // volume fraction of organic matter in layer (%). 55 | 56 | // need to save 57 | double ice_ratio[MAX_LAYERS];/* The ratio of ice of soil layer **save */ 58 | double thetam[MAX_LAYERS], thetam_prev[MAX_LAYERS]; /* soil water content in this layer */ 59 | double temp_soil_p[MAX_LAYERS]; /* soil temperature in this layer */ // don't change because it is used in soil_water_factor_v2, and UpdateSoil_Moisture. 60 | double temp_soil_c[MAX_LAYERS]; /* soil temperature in this layer */ // don't change because it is used in soil_water_factor_v2, and UpdateSoil_Moisture. 61 | 62 | // derived variables below: 63 | double f_ice[MAX_LAYERS]; // derived var. 64 | double psim[MAX_LAYERS]; /*soil water suction in this layer. Note: this variable can be derived from other parameters. LHE. */ 65 | double thetab[MAX_LAYERS]; /* soil water content at the bottom of each layer*/ 66 | double psib[MAX_LAYERS]; /*soil water suction at the bottom this layer. */ 67 | double r_waterflow[MAX_LAYERS]; /*'the liquid water flow rates at the soil layer interfaces 'eg. 0,1,2..., represents the surface, the bottom of layer1, the bottom of layer2,...*/ 68 | 69 | double km[MAX_LAYERS], Kb[MAX_LAYERS]; /*'the hydraulic conductivity of certain soil layer*/ 70 | double KK[MAX_LAYERS]; /* The average conductivity of two soil layers.*/ 71 | 72 | double Cs[MAX_LAYERS]; 73 | double lambda[MAX_LAYERS]; /*thermal conductivity of each soil layer;*/ /* ={0} by LHE */ // not used in gpp-only version. derived var. 74 | double Ett[MAX_LAYERS]; /*ET in each layer. derived var. */ 75 | /* define a lambda_top for ice? */ 76 | double G[MAX_LAYERS]; /* energy fluxes */ 77 | }; 78 | 79 | void SoilRootFraction(struct Soil soil[]); 80 | void Init_Soil_Parameters(int landcover, int stxt, double r_root_decay, struct Soil p[]); 81 | void Init_Soil_Status(struct Soil p[], double Tsoil, double Tair, double Ms, double snowdepth); 82 | void soil_water_factor_v2(struct Soil p[]); 83 | void Soil_Water_Uptake(struct Soil p[], double Trans_o, double Trans_u, double Evap_soil); 84 | void UpdateSoilLambda(struct Soil soil[]); 85 | void init_soil_parameter(unsigned char T_USDA, unsigned char S_USDA, unsigned char Ref_Depth, double T_Density, double S_Density, double T_OC, double S_OC, struct Soil soil[]); 86 | void Update_Cs(struct Soil p[]); 87 | void Update_ice_ratio(struct Soil p[]); 88 | void UpdateSoilThermalConductivity(struct Soil p[]); 89 | void UpdateHeatFlux(struct Soil p[], double Xg_snow, double lambda_snow, double Tsn0, double Tair_annual_mean, double peroid_in_seconds); 90 | void UpdateSoilMoisture(struct Soil p[], double peroid_in_seconds); 91 | #endif 92 | 93 | -------------------------------------------------------------------------------- /BEPS-SIF/soil_thermal_regime.c: -------------------------------------------------------------------------------- 1 | 2 | // Soil thermal regime: update the soil temperature fore each soil layer 3 | 4 | // Liming He 5 | // Last update: 09/15/2015 6 | 7 | #include "soil.h" 8 | #include 9 | 10 | 11 | void UpdateHeatFlux(struct Soil p[], double Xg_snow, double lambda_snow, double Tsn0, double Tair_annual_mean, double peroid_in_seconds) 12 | { 13 | int i; 14 | 15 | for (i = 1; i <= p->n_layer; i++) 16 | { 17 | if (i < p->n_layer) 18 | p->G[i] = (p->temp_soil_p[i - 1] - p->temp_soil_p[i]) / (0.5 * p->d_soil[i - 1] / p->lambda[i - 1] + 0.5 * p->d_soil[i] / p->lambda[i]); 19 | else 20 | p->G[i] = p->lambda[i-1] * (p->temp_soil_p[i-1] - Tair_annual_mean) / (DEPTH_F + p->d_soil[i-1] * 0.5); // NOTE: sdat->temp: change to annual Tair 21 | 22 | if (p->G[i]>200) p->G[i] = 200; /*juweimin05*/ 23 | if (p->G[i]<-200) p->G[i] = -200; /*juweimin05*/ 24 | } 25 | 26 | 27 | 28 | /*juweimin05--------------------------------------------------------------------*/ 29 | for (i = 0; i < p->n_layer; i++) // starting from zero layers. 30 | { 31 | double S = 0; 32 | p->temp_soil_c[i] = p->temp_soil_p[i] + (p->G[i] - p->G[i + 1] + S) / (p->Cs[i] * p->d_soil[i]) * peroid_in_seconds; // soil temperatures are updated here. LHE 33 | 34 | if (p->temp_soil_c[i] > 50.0) p->temp_soil_c[i] = 50.0; // the two lines are from Ju. 35 | if (p->temp_soil_c[i] < -50.0) p->temp_soil_c[i] = -50.0;// I see no necessarity to use this. LHe. May 19, 2015 36 | 37 | } /* end of ii loop */ 38 | 39 | Update_ice_ratio(p); 40 | 41 | for (i = 0; i < p->n_layer; i++) 42 | p->temp_soil_p[i] = p->temp_soil_c[i]; 43 | 44 | } 45 | 46 | 47 | void Update_Cs(struct Soil p[]) 48 | { 49 | int i; 50 | 51 | for (i = 0; i < p->n_layer; i++) 52 | { 53 | // Chen B. (2007) Ecological Modelling 209, 277-300 (equation 18) 54 | double term1, term2, term3; // LHE. Feb. 12, 2013. 55 | 56 | term1 = 2.0 * 1.0e+3 * p->density_soil[i] / 2.65; 57 | term2 = 1.0e+6 * p->thetam[i] * (4.2 * (1 - p->ice_ratio[i]) + 2.09 * p->ice_ratio[i]); 58 | term3 = 2.5 * 1.0e+6 * p->f_org[i]; 59 | 60 | p->Cs[i] = term1 + term2 + term3; 61 | } 62 | } 63 | 64 | // update the frozen status of each soil. 65 | 66 | void Update_ice_ratio(struct Soil p[]) 67 | { 68 | int i; 69 | double Lf0 = 3.34 * 100000; /* latet heat of fusion (liquid: solid) at 0C*/ 70 | 71 | for (i = 0; i < p->n_layer; i++) 72 | { 73 | // starting to frozen 74 | if (p->temp_soil_p[i] >= 0.0 && p->temp_soil_c[i] < 0.0 && p->ice_ratio[i] < 1.0) 75 | { 76 | // to do: change Gsf to a tmp var. 77 | double Gsf = (0.0 - p->temp_soil_c[i]) * p->Cs[i] * p->d_soil[i]; 78 | p->ice_ratio[i] = p->ice_ratio[i] + Gsf / Lf0 / 1000.0 / (p->thetam[i] * p->d_soil[i]); 79 | p->ice_ratio[i] = min(1.0, p->ice_ratio[i]); 80 | 81 | p->temp_soil_c[i] = 0; 82 | } 83 | // starting to melt 84 | else if (p->temp_soil_p[i] <= 0.0 && p->temp_soil_c[i] > 0.0 && p->ice_ratio[i] > 0.0) 85 | { 86 | double Gsm = (p->temp_soil_c[i] - 0.0) * p->Cs[i] * p->d_soil[i]; 87 | p->ice_ratio[i] = p->ice_ratio[i] - Gsm / Lf0 / 1000.0 / (p->thetam[i] * p->d_soil[i]); 88 | p->ice_ratio[i] = max(0.0, p->ice_ratio[i]); 89 | 90 | p->temp_soil_c[i] = 0; 91 | } 92 | 93 | p->ice_ratio[i] = p->ice_ratio[i] * p->thetam_prev[i] / p->thetam[i]; 94 | p->ice_ratio[i] = min(1.0, p->ice_ratio[i]); 95 | } 96 | } 97 | 98 | 99 | 100 | // Liming HE. Jan 30, 2013. 101 | // Input: thermal_cond, fei, ice_ratio, thetam, kw, ki 102 | // Output: lambda for each layer. 103 | void UpdateSoilThermalConductivity(struct Soil p[]) 104 | { 105 | int i; 106 | 107 | /*to calculate thermal conductivity of each soil layer, advances in water resources 26(2003), 79-93*/ 108 | double ki = 2.1; /*the thermal conductivity of ice*/ 109 | double kw = 0.61; /*the thermal conductivity of water*/ 110 | 111 | for (i = 0; i < p->n_layer; i++) 112 | { 113 | double tmp1, tmp2, tmp3, tmp4; 114 | tmp1 = pow(p->thermal_cond[i], (1 - p->fei[i])); // dry 115 | tmp2 = pow(ki, (1.2 * p->thetam[i] * p->ice_ratio[i]) ); // ice. no source for "1.2" 116 | tmp3 = pow(kw, p->thetam[i] * (1 - p->ice_ratio[i]) ); // water 117 | tmp4 = p->thetam[i] / p->fei[i]; // Sr 118 | 119 | p->lambda[i] = (tmp1 * tmp2 * tmp3 - 0.15) * tmp4 + 0.15; // Note: eq. 8. LHE 120 | 121 | p->lambda[i] = max(p->lambda[i], 0.15); /*juweimin05*/ 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /BEPS-SIF/soil_water_stress.c: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | ---------------------------- 3 | Program: SOIL_WATER_FACTOR.C 4 | Version 2.0 5 | ---------------------------- 6 | Description: Compute soil water stress factor. please refer to file soil_water_factor.cpp for 7 | the orginal version. LHE. 8 | 9 | Last revision by LHE. May 22, 2015. 10 | Rewritten by: Liming He. Jan 29, 2013. 11 | Modified by: Mustapha El Maayar - March 2008 12 | Written by: Weiming Ju 13 | *********************************************************************/ 14 | # include "stdio.h" 15 | # include "stdlib.h" 16 | #include "soil.h" // added by LHE. 17 | #include 18 | 19 | /********************************************************************/ 20 | void soil_water_factor_v2(struct Soil p[]) 21 | // output: dt, fw; LHE. Jan 29. 2013. 22 | { 23 | double ft[MAX_LAYERS], fpsisr[MAX_LAYERS]; 24 | double dtt[MAX_LAYERS]; 25 | double t1, t2; 26 | // double fw; 27 | int i; 28 | 29 | t1 = -0.02; 30 | t2 = 2.0; 31 | 32 | if (p->psim[0] <= 0.000001) // just in case that this function is called before "updatesoilmoisture". LHE 33 | for (i = 0; i < p->n_layer; i++) 34 | { 35 | p->psim[i] = p->psi_sat[i] * pow(p->thetam[i] / p->fei[i], -p->b[i]); 36 | p->psim[i] = max(p->psi_sat[i], p->psim[i]); // I see no necessity to use this line unless thetam > fei. LHE May 20, 2015 37 | } 38 | 39 | for (i = 0; i < p->n_layer; i++) 40 | { 41 | if (p->psim[i] > p->psi_min) // changed 10.0 to psi_min. LHE. Feb. 13, 2013. 42 | fpsisr[i] = 1.0 / (1 + pow((p->psim[i] - p->psi_min) / p->psi_min, p->alpha)); //psi_sr in m H2O! This is the old version. LHE. 43 | else 44 | fpsisr[i] = 1.0; 45 | 46 | if (p->temp_soil_p[i] > 0.0) // using a previous temperature | soil water factor is calculated before Tm is updated. LHE. 47 | ft[i] = (1.0 - exp(t1 * pow(p->temp_soil_p[i], t2))); // 1/x 48 | else 49 | ft[i] = 0.0; 50 | 51 | // ft[i] = min(ft[i], 1.0); // LHE. 52 | //ft[i] = max(0.001, ft[i]); // changed 0.1 to 0.001. LHE. 53 | 54 | fpsisr[i] = fpsisr[i] * ft[i]; 55 | } 56 | 57 | if (FW_VERSION == 1) 58 | { 59 | for (i = 0; i < p->n_layer; i++) 60 | dtt[i] = p->f_root[i] * fpsisr[i]; /* eq. 14 in Ju 2006 */ 61 | } 62 | else 63 | { 64 | for (i = 0; i < p->n_layer; i++) 65 | dtt[i] = p->f_root[i]; 66 | } 67 | 68 | //dtt[0] = 0.0; 69 | double dtt_sum = 0.0; 70 | for (i = 0; i < p->n_layer; i++) 71 | dtt_sum = dtt_sum + dtt[i];/* eq. 14 in JU2006 */ 72 | 73 | if (dtt_sum < 0.000001) 74 | p->f_soilwater = 0.1; // when soil temperatures in all layers are <=0. LHe 75 | else 76 | { 77 | for (i = 0; i < p->n_layer; i++) 78 | { 79 | p->dt[i] = dtt[i] / dtt_sum; 80 | 81 | // if (p->dt[0] < 0.0000001) 82 | // printf("%f\n", p->dt[0]); 83 | if (isnan(p->dt[i])) 84 | printf("%f\n", p->dt[0]); 85 | } 86 | 87 | 88 | //fpsisr[0] = 0; 89 | double fpsisr_sum = 0; 90 | for (i = 0; i < p->n_layer; i++) 91 | { 92 | fpsisr_sum = fpsisr_sum + fpsisr[i] * p->dt[i]; /* eq. 12, in Chen 2012 GBC; eq 15 in JU */ 93 | } 94 | 95 | p->f_soilwater = max(0.1, fpsisr_sum); 96 | } 97 | 98 | 99 | //printf("fpsisr[0]=%f\n",fpsisr[0]); 100 | 101 | } 102 | 103 | // a very simple fw by LHE July 29, 2014 @home 104 | //double tan_theta = (1.5 - 0.3) / (soil->Layer[2].theta_vfc - soil->Layer[2].theta_vwp); 105 | //fw = 0.3 + (soil->Layer[2].thetam - soil->Layer[2].theta_vwp) * tan_theta; 106 | //fw = max(0.3, fw); 107 | 108 | //double tan_theta = (1.0 - 0.3) / (soil->Layer[2].theta_vfc - soil->Layer[2].theta_vwp); 109 | //fw = 0.3 + (soil->Layer[2].thetam - soil->Layer[2].theta_vwp) * tan_theta; 110 | //fw = max(0.3, fw); 111 | // 112 | //fw = min(3.0, fw); 113 | // 114 | //soil->f_soilwater = fw; 115 | 116 | -------------------------------------------------------------------------------- /BEPS-SIF/soilresp.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | soilresp.c 3 | 4 | Calculating soil respiration. 5 | *****************************************************************************/ 6 | #include "beps.h" 7 | #include "soil.h" 8 | 9 | 10 | void soilresp(Ccd,Cssd,Csmd,Cfsd,Cfmd,Csm,Cm,Cs,Cp,npp_yr,coef,soiltype,soilp,mid_res) 11 | 12 | double *Ccd; 13 | double *Cssd; 14 | double *Csmd; 15 | double *Cfsd; 16 | double *Cfmd; 17 | double *Csm; 18 | double *Cm; 19 | double *Cs; 20 | double *Cp; 21 | float npp_yr; 22 | double *coef; 23 | int soiltype; 24 | struct Soil *soilp; 25 | struct results *mid_res; 26 | 27 | 28 | { 29 | double fw, fcr, fl, ffr; 30 | double kw_cd, kcr_cd; 31 | double kl_sl, kfr_fl; 32 | double km_p, ks_p; 33 | double kssd_a, kssd_sm, kssd_s, ksmd_a, ksmd_sm,kfsd_a, kfsd_m, kfsd_s, kfmd_a, kfmd_m; 34 | double kcd_a, kcd_m; 35 | double kcd_s,ksm_a,ksm_s, km_a, km_s, ks_a, ks_m,kp_a, kp_m; 36 | double Cw[10], Ccr[10]; 37 | double Cl[10], Cfr[10]; 38 | double dCw[10], dCcr[10]; 39 | double dCl[10], dCfr[10]; 40 | double dCcd[10],dCssd[10],dCsmd[10],dCfsd[10],dCfmd[10]; 41 | double dCsm[10], dCm[10]; 42 | double dCs[10], dCp[10]; 43 | double part1,part2; 44 | double Fm[10],npp; 45 | double lambda[layer+1],lambda_t[layer+1],lambda_w[layer+1]; 46 | double lam_u,lam_d; 47 | int ii; 48 | 49 | for(ii=1;ii<=layer;ii++) 50 | { 51 | lambda_t[ii]=exp(308.56*(1/(35.0+46.032)-1/(46.032+soilp->temp_soil_c[ii - 1]))); 52 | lambda_t[ii]=min(1.0,lambda_t[ii]); 53 | lambda_t[ii]=max(0.3,lambda_t[ii]); 54 | } 55 | for(ii=1;ii<=layer;ii++) 56 | { 57 | if(soiltype>=6) 58 | lambda_w[ii]=5.44*soilp->thetam[ii-1]/soilp->fei[ii-1]-5.03*pow(soilp->thetam[ii-1]/soilp->fei[ii-1],2)-0.472; 59 | else 60 | lambda_w[ii]=5.63*soilp->thetam[ii-1]/soilp->fei[ii-1]-4.64*pow(soilp->thetam[ii-1]/soilp->fei[ii-1],2)-0.710; 61 | lambda_w[ii]=max(0.3,lambda_w[ii]); 62 | } 63 | for(ii=1;ii<=layer;ii++) lambda[ii]=lambda_t[ii]*lambda_w[ii]; 64 | 65 | lam_u= lambda[1]; /*for surface pool*/ 66 | lam_d= lambda[2]; /* for soil pool */ 67 | 68 | fw = coef[0]; 69 | fcr = coef[1]; 70 | fl = coef[2]; 71 | ffr = coef[3]; 72 | kw_cd =coef[4]/8760 ; 73 | kcr_cd =coef[5]/8760; 74 | kl_sl =coef[6]/8760; 75 | kfr_fl =coef[7]/8760; 76 | kssd_a = coef[8]/8760; 77 | kssd_sm = coef[9]/8760; 78 | kssd_s = coef[10]/8760; 79 | ksmd_a = coef[11]/8760; 80 | ksmd_sm = coef[12]/8760; 81 | kfsd_a = coef[13]/8760; 82 | kfsd_m = coef[14]/8760; 83 | kfsd_s = coef[15]/8760; 84 | kfmd_a = coef[16]/8760; 85 | kfmd_m = coef[17]/8760; 86 | kcd_a = coef[18]/8760; 87 | kcd_m = coef[19]/8760; 88 | kcd_s = coef[20]/8760; 89 | km_a = coef[21]/8760; 90 | km_p = coef[22]/8760; 91 | km_s = coef[23]/8760; 92 | ksm_a= coef[24]/8760; 93 | ksm_s= coef[25]/8760; 94 | ks_a = coef[26]/8760; 95 | ks_p = coef[27]/8760; 96 | ks_m = coef[28]/8760; 97 | kp_a = coef[29]/8760; 98 | kp_m = coef[30]/8760; 99 | 100 | 101 | Cw[0] = coef[0]/coef[4] * npp_yr; // for stem gC/m2 102 | Ccr[0] = coef[1]/coef[5] * npp_yr; // for coast root gC/m2 103 | Cl[0] = coef[2]/coef[6] * npp_yr; // for leaf gC/m2 104 | Cfr[0] = coef[3]/coef[7] * npp_yr; // for fine root gC/m2 105 | 106 | Fm[1]=0.2; 107 | 108 | npp = mid_res->npp_o + mid_res->npp_u; 109 | 110 | dCw[1] = fw * npp- kw_cd * Cw[0]; 111 | dCcr[1] = fcr* npp - kcr_cd * Ccr[0]; 112 | dCl[1] = fl * npp - kl_sl * Cl[0]; 113 | dCfr[1] = ffr* npp- kfr_fl * Cfr[0]; 114 | 115 | Cw[1] =Cw[0] + dCw[1]; 116 | Ccr[1] =Ccr[0] + dCcr[1]; 117 | Cl[1] =Cl[0] + dCl[1]; 118 | Cfr[1] =Cfr[0] + dCfr[1]; 119 | 120 | part1=(kw_cd * Cw[1]+kcr_cd * Ccr[1])/(1+lam_d*(kcd_a + kcd_m + kcd_s)); 121 | part2=Ccd[0] * lam_d* (kcd_a + kcd_m + kcd_s); 122 | dCcd[1]=part1-part2; 123 | Ccd[1] = Ccd[0] + dCcd[1]; 124 | /* Coarse detritus from woody and coarse root;*/ 125 | 126 | part1=(1 - Fm[1])* kl_sl*Cl[1]/(1+lam_u*(kssd_a + kssd_sm + kssd_s)); 127 | part2=Cssd[0]* lam_u * (kssd_a + kssd_sm + kssd_s); 128 | dCssd[1]=part1-part2; 129 | Cssd[1]= Cssd[0]+dCssd[1]; 130 | /* for surface structural litter*/ 131 | 132 | part1=Fm[1]* kl_sl * Cl[1]/(1+lam_u*(ksmd_a + ksmd_sm)); 133 | part2= Csmd[0]* lam_u * (ksmd_a + ksmd_sm); 134 | dCsmd[1]=part1-part2; 135 | Csmd[1]= Csmd[0]+dCsmd[1]; 136 | /* for surface metabolic litter*/ 137 | 138 | part1=(1 - Fm[1])* kfr_fl* Cfr[1]/(1+lam_d*(kfsd_a + kfsd_m + kfsd_s)); 139 | part2=Cfsd[0]* lam_d * (kfsd_a + kfsd_m + kfsd_s); 140 | dCfsd[1]=part1-part2; 141 | Cfsd[1]= Cfsd[0]+dCfsd[1]; 142 | /*for soil strutural litter pool*/ 143 | 144 | part1=Fm[1] * kfr_fl * Cfr[1]/(1+lam_d * (kfmd_a + kfmd_m)); 145 | part2=lam_d * (kfmd_a + kfmd_m)* Cfmd[0]; 146 | dCfmd[1]=part1-part2; 147 | Cfmd[1]= Cfmd[0]+dCfmd[1]; 148 | /* for soil metabolic pool*/ 149 | 150 | part1=lam_u*(Cssd[1]*kssd_sm+Csmd[1]*ksmd_sm); 151 | part2=lam_u*Csm[0]*(ksm_a+ksm_s); 152 | dCsm[1]=part1-part2; 153 | Csm[1]=Csm[0]+dCsm[1]; 154 | /* for surface microbe pool*/ 155 | 156 | part1=(lam_d * (kfsd_m * Cfsd[1]+kfmd_m*Cfmd[1] + Ccd[1] * kcd_m) +lam_d*(Cs[1-1]*ks_m+Cp[1-1] * kp_m)); 157 | part2=Cm[0] * lam_d*(km_a + km_s +km_p); 158 | dCm[1]=part1-part2; 159 | Cm[1]=Cm[0]+dCm[1]; 160 | /* for soil microbe pool*/ 161 | 162 | part1=(lam_d*(Cm[1]*km_s + Ccd[1] * kcd_s +Cfsd[1]*kfsd_s )+ lam_u* (Csm[1]*ksm_s + Cssd[1]*kssd_s)); 163 | part2=Cs[0]* lam_d *( ks_a + ks_p+ks_m); 164 | dCs[1]=part1-part2; 165 | Cs[1]=Cs[0]+dCs[1]; 166 | /* for slow carbon pool*/ 167 | 168 | dCp[1] =(lam_d *( km_p * Cm[1] + ks_p * Cs[1]) - lam_d * (kp_m * Cp[1-1] + kp_a * Cp[1-1])); 169 | Cp[1]=Cp[0]+dCp[1]; 170 | /* for passive carbon pool.*/ 171 | 172 | 173 | /** NEP ***/ 174 | mid_res->NEP = npp+(dCsmd[1]+dCssd[1]+dCfsd[1]+dCfmd[1]+dCcd[1]+dCm[1]+dCsm[1]+dCs[1]+dCp[1]); 175 | /** NPP ***/ 176 | mid_res->NPP= npp; 177 | 178 | /* soil respiration */ 179 | // mid_res->soil_resp = npp - mid_res->NEP; 180 | 181 | return; 182 | } 183 | -------------------------------------------------------------------------------- /BEPS-SIF/surface_temp.c: -------------------------------------------------------------------------------- 1 | // This module will simulate surface temperature in each step, as well as heat flux for surface to soil layers 2 | // edited by XZ Luo, June 1, 2015 3 | 4 | /* as it is a interface between ground, air and soil, the core idea is to separate the interface as different layers 5 | by depth of snow, then calculate the temperature gradient and at last calculate the heat flux from ground surface to soil*/ 6 | 7 | #include "beps.h" 8 | // original beps would use Xg_snow[kkk] at some places after snow melt & frozen, now we uniformly use the value before snow melt & frozen. 9 | void surface_temperature (temp_air,rh_air, depth_snow, depth_water, 10 | capacity_heat_soil1, capacity_heat_soil0, Gheat_g, depth_soil1, density_snow,tempL_u, 11 | netRad_g, evapo_soil, evapo_water_g, evapo_snow_g, 12 | lambda_soil1,percent_snow_g,heat_flux_soil1, 13 | temp_ground_last,temp_soil1_last,temp_any0_last, temp_snow_last, 14 | temp_soil0_last, temp_snow1_last, temp_snow2_last, 15 | temp_ground, temp_any0, temp_snow, 16 | temp_soil0,temp_snow1, temp_snow2, 17 | heat_flux) 18 | 19 | double depth_snow, depth_water; 20 | double density_snow; // density of snow at this step; 21 | double percent_snow_g; // percentage of snow coverage on ground 22 | 23 | double lambda_soil1;// thermal conductivity of first layer soil in this step 24 | double depth_soil1;// depth of soil layer 1; 25 | double capacity_heat_soil1,capacity_heat_soil0; // soil heat capacity of first layer soil and 0 layer(?) at step kkk 26 | double heat_flux_soil1; // the heat flux from soil layer 1 to the next layer 27 | 28 | double Gheat_g; // aerodynamic conductance of heat at ground, Gheat_g=1/ra_g 29 | 30 | double tempL_u; 31 | double netRad_g;// net radiation on ground double evapo_soil, evapo_water_g, evapo_snow_g; // evaporation and sublimation from ground 32 | double temp_air, rh_air; // air temperature, relative humidity 33 | 34 | double *temp_ground; // ground temperature at this step; 35 | double *temp_any0; // temperature of any layer right above the soil, could be a mixture of snow temperature and soil surface temperature 36 | double *temp_snow; // snow temperature at this step; 37 | double *temp_soil0;// temperature of soil surface right above the soil, the part not covered by snow 38 | double *temp_snow1, *temp_snow2; // temperature of snow layer 2 and 3, used in depth_snow>0.05 m 39 | 40 | double temp_ground_last; // ground surface temperature from last step 41 | double temp_any0_last; 42 | double temp_snow_last; 43 | double temp_soil1_last; // temperature of first layer soil in last step 44 | double temp_soil0_last; // temperature of soil surface right above the soil in last step, the part not covered by snow 45 | double temp_snow1_last, temp_snow2_last; 46 | 47 | double *heat_flux;//heat flux from ground to soil 48 | 49 | 50 | { 51 | double length_step; 52 | double meteo_pack_output[10]; 53 | double density_air, cp_air; // density of air, specific heat of air 54 | double cp_ice; // specific heat of ice 55 | double latent_water, latent_snow; 56 | double Gg; // radiation available for heating the ground; 57 | double lambda_snow;// thermal conductivity of snow in this step 58 | double heat_flux_soil, heat_flux_snow; // heat flux through the soil and snow fraction on ground, separately. 59 | double heat_flux_snow1, heat_flux_snow2; 60 | 61 | double ra_g; // aerodynamic resistance of heat 62 | 63 | double ttt;// temporary variables 64 | 65 | length_step=kstep; 66 | 67 | cp_ice=2228.261; 68 | latent_water=(2.501-0.00237*temp_air)*1000000; 69 | latent_snow=2.83*1000000; 70 | meteo_pack (temp_air, rh_air, meteo_pack_output); 71 | density_air = meteo_pack_output[1]; 72 | cp_air = meteo_pack_output[2]; 73 | ra_g=1/Gheat_g; 74 | 75 | /*thermal conductivity of snow*/ 76 | lambda_snow=0.021+4.2*density_snow/10000+2.2*pow(density_snow,3)*pow(10,-9); 77 | 78 | // available energy on ground for 79 | Gg=netRad_g - evapo_snow_g*latent_snow-(evapo_water_g+evapo_soil)*latent_water; 80 | 81 | //case 1, snow depth<2cm, snow temperature, ground surface temperature, soil surface temperature are the same 82 | if(depth_snow<=0.02) 83 | { 84 | ttt=capacity_heat_soil1*0.02/length_step; 85 | *temp_ground=(temp_ground_last*(ttt)*ra_g*depth_soil1+Gg*ra_g*depth_soil1+density_air*cp_air*temp_air*depth_soil1+ ra_g*lambda_soil1*temp_soil1_last); 86 | *temp_ground=*temp_ground/(density_air*cp_air*depth_soil1+ ra_g*lambda_soil1+ttt*ra_g*depth_soil1); 87 | 88 | *temp_ground=max(temp_ground_last-25,*temp_ground); 89 | *temp_ground=min(temp_ground_last+25,*temp_ground); 90 | 91 | *temp_any0 = *temp_ground; 92 | *temp_snow =*temp_any0; 93 | *temp_soil0 =*temp_any0; 94 | *temp_snow1 =*temp_any0; 95 | *temp_snow2 =*temp_any0; 96 | 97 | *heat_flux=2*lambda_soil1*((*temp_any0)-temp_soil1_last)/depth_soil1; 98 | *heat_flux=min(100,*heat_flux); 99 | *heat_flux=max(-100,*heat_flux); 100 | } 101 | 102 | // case 2: depth of snow larger than 2cm, smaller than 5 cm. 103 | // snow fraction on ground decide the snow temperature based on energy balance 104 | // soil fraction on ground decide the soil surface temperature based on energy balance 105 | // snow and soil fraction works in parallel to determine the ground surface temperature 106 | else if(depth_snow>0.02 && depth_snow<=0.05) 107 | { 108 | ttt=capacity_heat_soil1*0.02/length_step; /* for soil fraction part*/ 109 | 110 | *temp_soil0=(temp_soil0_last*ttt*ra_g*depth_soil1+Gg*ra_g*depth_soil1+density_air*cp_air*temp_air*depth_soil1+ 2*ra_g*lambda_soil1*temp_soil1_last)/ 111 | (density_air*cp_air*depth_soil1+ 2*ra_g*lambda_soil1+ttt*ra_g*depth_soil1); 112 | 113 | *temp_soil0=max(temp_air-25,(*temp_soil0)); 114 | *temp_soil0=min(temp_air+25,(*temp_soil0)); 115 | 116 | ttt=cp_ice*density_snow*depth_snow/length_step; /*for snow part*/ 117 | *temp_snow=(temp_snow_last*ttt*ra_g*depth_snow+Gg*ra_g*depth_snow+density_air*cp_air*tempL_u*depth_snow+ ra_g*lambda_snow*temp_any0_last)/ 118 | (density_air*cp_air*depth_snow+ ra_g*lambda_snow+ttt*ra_g*depth_snow); 119 | 120 | *temp_snow=max(temp_air-25,*temp_snow); 121 | *temp_snow=min(temp_air+25,*temp_snow); 122 | 123 | ttt=(lambda_soil1*temp_soil1_last/depth_soil1+(*temp_snow)*lambda_snow+0.02*capacity_heat_soil1/length_step*temp_any0_last)/ 124 | (lambda_soil1/depth_soil1+lambda_snow/depth_snow+0.02*capacity_heat_soil1/length_step); 125 | *temp_any0=(*temp_soil0)*(1-percent_snow_g)+ttt*percent_snow_g; 126 | 127 | heat_flux_snow = lambda_snow/(depth_snow+0.5*depth_soil1)*((*temp_snow)-temp_soil1_last); 128 | heat_flux_soil = heat_flux_snow*((*temp_any0)-temp_soil1_last)/depth_soil1; 129 | 130 | *heat_flux=heat_flux_snow*percent_snow_g+heat_flux_soil*(1-percent_snow_g); 131 | 132 | *heat_flux=min(100,*heat_flux); 133 | *heat_flux=max(-100,*heat_flux); 134 | 135 | /* starting to melt*/ 136 | if(*temp_snow>zero && temp_snow_last<=zero && depth_snow>zero) 137 | { 138 | *temp_snow=0; 139 | } 140 | 141 | /* starting to frozen*/ 142 | if(*temp_snow=zero && depth_water>zero) 143 | { 144 | *temp_snow=0; 145 | } 146 | 147 | //percent_snow_g =min(1.0,Wg_snow[kkk] / (0.05 * rho_snow[kkk])); // use the fraction before 148 | *temp_ground =(*temp_snow)*percent_snow_g+(*temp_soil0)*(1-percent_snow_g); 149 | *temp_ground=max(temp_air-25,*temp_ground); 150 | *temp_ground=min(temp_air+25,*temp_ground); 151 | 152 | *temp_snow1=*temp_snow; 153 | *temp_snow2=*temp_snow; 154 | } 155 | 156 | // case 3, snow depth is larger than 5 cm 157 | // snow coverage on ground is 100% 158 | // the first layer of snow is set as 2 cm 159 | // the second layer of snow is set as 2 cm, too 160 | // the depth of third snow layer is depth_snow-0.04; 161 | else if(depth_snow>0.05) 162 | { 163 | ttt=cp_ice*density_snow*0.02/length_step; 164 | 165 | *temp_snow=(temp_snow_last*ttt*ra_g*0.04+Gg*ra_g*0.02+density_air*cp_air*temp_air*0.04+ra_g*lambda_snow*temp_snow1_last)/ 166 | (density_air*cp_air*0.04+ ra_g*lambda_snow+ttt*ra_g*0.04); 167 | *temp_snow=max(temp_air-25,*temp_snow); 168 | *temp_snow=min(temp_air+25,*temp_snow); 169 | 170 | heat_flux_snow=lambda_snow*(*temp_snow-temp_snow1_last)/0.04; // why 0.04 here? 171 | 172 | *heat_flux=heat_flux_snow; 173 | *heat_flux=min(100,*heat_flux); 174 | *heat_flux=max(-100,*heat_flux); 175 | 176 | heat_flux_snow1 = lambda_snow*(temp_snow1_last-temp_snow2_last)/(depth_snow-0.02); 177 | *temp_snow1=temp_snow1_last+((*heat_flux)- heat_flux_snow1)/(cp_ice*density_snow*0.02 )*length_step ; 178 | heat_flux_snow2 = (temp_snow2_last-temp_any0_last)/(0.5*(depth_snow-0.04)/lambda_snow+0.02/lambda_soil1); //?? 179 | *temp_snow2=temp_snow2_last+(heat_flux_snow1- heat_flux_snow2)/(cp_ice*density_snow*(depth_snow-0.04))*length_step ; 180 | 181 | *temp_any0 = temp_any0_last+(heat_flux_snow2- heat_flux_soil1) / (capacity_heat_soil0 * 0.02)*length_step; 182 | *temp_soil0=*temp_any0; 183 | /* starting to melt*/ 184 | if(*temp_snow>zero && temp_snow_last<=zero && depth_snow>zero) 185 | { 186 | *temp_snow=0; 187 | } 188 | 189 | /* starting to frozen */ 190 | if(*temp_snow=zero && depth_water>zero) 191 | { 192 | *temp_snow=0; 193 | } 194 | 195 | *temp_ground=*temp_snow; 196 | } 197 | } 198 | 199 | /*==========================* 200 | theoretical top layer: temp_any0 201 | heat_flux_snow2 202 | snow layer 3: temp_snow2 203 | heat_flux_snow1 204 | snow layer 2: temp_snow1 205 | heat_flux_snow 206 | snow layer 1: temp_snow 207 | */ 208 | -------------------------------------------------------------------------------- /BEPS-SIF/transpiration.c: -------------------------------------------------------------------------------- 1 | // this module calculates transpiration, from overstorey understorey sunlit and shaded 2 | // edited by XZ Luo May 20, 2015 3 | 4 | /* A transformation of Penmman-Monteith equation is used here. 5 | It could be regarded as a mass transfer process, water vapor inside cells are required by VPD from air and VPD on leaf surface 6 | */ 7 | 8 | /* input includes: 9 | temperature of sunlit and shaded leaves from other storey (leaf temperature module); 10 | temperature of air, relative humidity, 11 | conductance of water for sunlit shaded leaves from overstorey and understorey; 12 | leaf area index, sunlit and shaded, overstorey and understorey (from leaf area index module); 13 | */ 14 | 15 | /* output: 16 | transpiration from overstorey and understorey 17 | */ 18 | #include "beps.h" 19 | void transpiration (tempL_o_sunlit, tempL_o_shaded, tempL_u_sunlit, tempL_u_shaded, temp_air, rh_air, 20 | Gtrans_o_sunlit, Gtrans_o_shaded, Gtrans_u_sunlit, Gtrans_u_shaded, 21 | lai_o_sunlit, lai_o_shaded, lai_u_sunlit, lai_u_shaded, 22 | trans_o, trans_u) 23 | 24 | double tempL_o_sunlit, tempL_o_shaded, tempL_u_sunlit, tempL_u_shaded; 25 | double temp_air, rh_air; 26 | double Gtrans_o_sunlit, Gtrans_o_shaded, Gtrans_u_sunlit, Gtrans_u_shaded; 27 | double lai_o_sunlit, lai_o_shaded, lai_u_sunlit, lai_u_shaded; 28 | double *trans_o, *trans_u; 29 | { 30 | double LHt_o_sunlit, LHt_o_shaded, LHt_u_sunlit, LHt_u_shaded; // latent heat from leaves W/m2 31 | double meteo_pack_output[10]; 32 | double density_air, cp_air, vpd_air, slope_vapor_air, psy_air; 33 | double latent_water; 34 | 35 | meteo_pack (temp_air, rh_air, meteo_pack_output); 36 | density_air = meteo_pack_output [1]; 37 | cp_air = meteo_pack_output [2]; 38 | vpd_air = meteo_pack_output [3]; 39 | slope_vapor_air = meteo_pack_output [4]; 40 | psy_air = meteo_pack_output [5]; 41 | 42 | latent_water=(2.501-0.00237*temp_air)*1000000; 43 | 44 | ////////////////// 45 | LHt_o_sunlit =(vpd_air+slope_vapor_air *(tempL_o_sunlit -temp_air ))*density_air*cp_air*Gtrans_o_sunlit /psy_air; 46 | LHt_o_shaded =(vpd_air+slope_vapor_air *(tempL_o_shaded -temp_air ))*density_air*cp_air*Gtrans_o_shaded /psy_air; 47 | 48 | LHt_u_sunlit =(vpd_air+slope_vapor_air *(tempL_u_sunlit -temp_air ))*density_air*cp_air*Gtrans_u_sunlit /psy_air; 49 | LHt_u_shaded =(vpd_air+slope_vapor_air *(tempL_u_shaded -temp_air ))*density_air*cp_air*Gtrans_u_shaded /psy_air; 50 | 51 | ////////////////// 52 | *trans_o =1/(latent_water )*(LHt_o_sunlit *lai_o_sunlit +LHt_o_shaded *lai_o_shaded ); 53 | *trans_u =1/(latent_water )*(LHt_u_sunlit *lai_u_sunlit +LHt_u_shaded *lai_u_shaded ); 54 | } 55 | -------------------------------------------------------------------------------- /BEPS-SIF/updatesoilmoisture.c: -------------------------------------------------------------------------------- 1 | 2 | #include "soil.h" 3 | #include 4 | 5 | void UpdateSoilMoisture(struct Soil p[], double kstep) 6 | // Last revision: May 20, 2015, by LHe. 7 | // L. HE. Jan 24, 2013. 8 | 9 | // Given the current condition, to calcualte soil mositure after a peroid. 10 | // Richards equation. sources: ET and rain 11 | 12 | // kstep is defined in beps.h: the total second in this step (the peroid). 13 | // kkk (outside of the function): step within an hour or half hour measurement. 14 | 15 | { 16 | double Inf, Inf_max; // infiltration, and Maximum infiltration 17 | int i; 18 | double this_step = 0; //LHE 19 | double total_t = 0; //LHE 20 | double max_Fb = 0; //LHE 21 | 22 | // assign the current soil temperature to prev variabls. 23 | for(i=0; i<=p->n_layer; i++) // save previous thetam. LHE. 24 | p->thetam_prev[i] = p->thetam[i]; 25 | 26 | for(i=0; i<=p->n_layer; i++) 27 | { 28 | if( p->temp_soil_c[i] > 0.0) 29 | p->f_ice[i] = 1.0; // f_ice should be named as f_water? LHe 30 | else if( p->temp_soil_c[i] < -1.0) 31 | p->f_ice[i] = 0.1; // maybe f_ice should be zero? LHE. 32 | else p->f_ice[i] = 0.1 + 0.9 * ( p->temp_soil_c[i] + 1.0); 33 | } 34 | 35 | /*juweimin================================================*/ 36 | // this part solve the upper boundary condition(Infiltration). LHE 37 | // the maximum Infiltration. Reference? The inf should be changing very fast during a precipaiton because thetam is changing. LHE. 38 | Inf_max=p->f_ice[0] * p->Ksat[0] * ( 1 + (p->fei[0] - p->thetam_prev[0]) / p->d_soil[0] * p->psi_sat[0] * p->b[0] / p->fei[0]); 39 | 40 | Inf = max(p->f_ice[0] * (p->Zp / kstep + p->r_rain_g), 0); // This should be unnessary since tmp >=0; LHE. 41 | Inf=min(Inf_max,Inf); 42 | Inf=max(0,Inf); // This should be unnessary since Inf_max >=0; LHE. 43 | 44 | p->Zp = (p->Zp / kstep + p->r_rain_g - Inf) * kstep * p->r_drainage; // Ponded water after runoff. This one is related to runoff. LHe. 45 | 46 | /*==============juweimin----------------------------------------*/ 47 | 48 | //// begining of self-adaption step by LHE. Oct 16, 2012 49 | while(total_t < kstep) 50 | { 51 | for(i=0; i < p->n_layer; i++) 52 | p->km[i] = p->f_ice[i] * p->Ksat[i] * pow((p->thetam[i] / p->fei[i]), (2 * p->b[i] + 3)); 53 | 54 | // soil moisture in the boundaries 55 | for(i=0; i < p->n_layer; i++) // 56 | { 57 | if(i < p->n_layer - 1 ) 58 | p->thetab[i] = (p->thetam[i + 1] / p->d_soil[i + 1] + p->thetam[i] / p->d_soil[i]) / (1 / p->d_soil[i] + 1 / p->d_soil[i + 1]); 59 | else { // the lowest p->n_layer 60 | double d1; 61 | d1 = (p->thetam[i] - p->thetab[i-1]) * 2.0 / p->d_soil[i]; 62 | d1=max(d1,0); 63 | p->thetab[i] = p->thetam[i] + d1*p->d_soil[i] / 2.0; 64 | p->thetab[i] = min(p->thetab[i], p->fei[i]); 65 | } 66 | 67 | } 68 | 69 | for(i = 0; i < p->n_layer; i++) 70 | { 71 | if(i < p->n_layer - 1 ) // the unsaturated hydraulic conductivity at soil lower boundary. 72 | p->Kb[i] = p->f_ice[i] * (p->Ksat[i] * p->d_soil[i] + p->Ksat[i+1] * p->d_soil[i + 1]) / (p->d_soil[i] + p->d_soil[i + 1]) * \ 73 | pow(p->thetab[i] / p->fei[i], (2 * p->b[i] + 3)); // Note: Kb[0] to Kb[n_layer-1] are not used in the model. LHe. 74 | else // when i == p->LAYER - 1 75 | p->Kb[i] = 0.5 * p->f_ice[i] * p->Ksat[i] * pow(p->thetab[i] / p->fei[i], (2 * p->b[i] + 3)); 76 | } 77 | 78 | // the unsaturated soil water retention. LHe 79 | for(i = 0;i <= p->n_layer - 1;i++) 80 | { 81 | p->psim[i] = p->psi_sat[i] * pow(p->thetam[i] / p->fei[i], - p->b[i]); 82 | p->psim[i] = max(p->psi_sat[i], p->psim[i] ); // I see no necessity to use this line unless thetam > fei. LHE May 20, 2015 83 | 84 | // if (p->psim[i] > 300) p->psim[i] = 300.0; /*juweimin05 130->300 */ 85 | } 86 | 87 | //the unsaturated soil water retention @ boundaries. LHe 88 | for(i=0; i < p->n_layer; i++) 89 | { 90 | p->psib[i] = p->psi_sat[i] * pow(p->thetab[i] / p->fei[i], - p->b[i]); 91 | p->psib[i] = max(p->psi_sat[i], p->psib[i]); 92 | // p->psib[i] = min(300,p->psib[i]); 93 | } 94 | 95 | // the unsaturated hydraulic conductivity of soil p->n_layer @ boundaries 96 | for(i=0; i < p->n_layer; i++) 97 | { 98 | if(i < p-> n_layer-1) 99 | p->KK[i] = (p->km[i] * p->psim[i] + p->km[i + 1] * p->psim[i + 1]) \ 100 | / (p->psim[i] + p->psim[i + 1]) * (p->b[i] + p->b[i + 1]) / (p->b[i] + p->b[i + 1] + 6); /*See seller's*/ 101 | else // when i == LAYER-1 102 | p->KK[i] = (p->km[i] * p->psim[i] + p->Kb[i] * p->psib[i]) \ 103 | /(p->psim[i] + p->psib[i]) * p->b[i] / (p->b[i] + 3); 104 | } 105 | 106 | /// // Fb, flow speed. Dancy's law. LHE. 107 | for(i=0;i <= p->n_layer - 1; i++) 108 | { 109 | if(i < p->n_layer - 1) 110 | { 111 | p->r_waterflow[i] = p->KK[i] * (2*(p->psim[i+1] - p->psim[i]) / (p->d_soil[i] + p->d_soil[i+1])+1); /* downwards, positive*/ 112 | // +1 accounts for gravitational drainage. LHE 113 | } 114 | else 115 | //p->r_waterflow[i] = p->km[i] * (0+1); // Seller's 1996. Eq. 37. simplified. 116 | p->r_waterflow[i] = 0; // from Ju. 117 | } 118 | 119 | 120 | // check the r_waterflow further. LHE 121 | for(i=0;in_layer-1;i++) 122 | { 123 | p->r_waterflow[i] = min((p->fei[i+1] - p->thetam[i+1]) * p->d_soil[i+1] / kstep + p->Ett[i+1], p->r_waterflow[i]); // this line is supposed to confine the flux or flow speed but this is not enough. LHE Oct 16, 2012. 124 | if(fabs(p->r_waterflow[i]) > max_Fb) max_Fb = fabs(p->r_waterflow[i]); // find max_Fb for all p->LAYERSs. 125 | } 126 | 127 | 128 | if(max_Fb > 1.0e-5) 129 | this_step = 1.0; // determinte the sub-step according to order of Fb empirically . 130 | else if(max_Fb > 1.0e-6) 131 | this_step = 30.0; 132 | else this_step = 360.0; 133 | 134 | total_t = total_t + this_step; 135 | if(total_t > kstep) this_step = this_step - (total_t - kstep); 136 | 137 | // from there: kstep is replaced by this_step. LHE 138 | for(i=0;i < p->n_layer;i++) 139 | { 140 | if(i==0) 141 | p->thetam[i] = p->thetam[i] + (Inf * this_step - p->r_waterflow[i] * this_step - p->Ett[i] * this_step) / p->d_soil[i]; // kstep->this_step 142 | else 143 | p->thetam[i] = p->thetam[i] + (p->r_waterflow[i-1] * this_step - p->r_waterflow[i] * this_step - p->Ett[i] * this_step) / p->d_soil[i]; // kstep->this_step 144 | 145 | /* thetam[i][kkk]=max(theta_vwp[i]*0.25,thetam[i][kkk]); */ 146 | p->thetam[i] = max(p->theta_vwp[i], p->thetam[i]); 147 | p->thetam[i] = min(p->fei[i],p->thetam[i]); 148 | } 149 | 150 | } // end of while: the self-adaption step. by LHE. 151 | 152 | 153 | for(i=0;in_layer;i++) 154 | { // ref? 155 | p->ice_ratio[i] = p->ice_ratio[i] * p->thetam_prev[i] / p->thetam[i]; 156 | p->ice_ratio[i] = min(1.0, p->ice_ratio[i]); 157 | } 158 | 159 | } 160 | 161 | 162 | 163 | // Soil water uptake from a layer. 164 | // Liming He @ PGB 205B, May 26, 2015 165 | void Soil_Water_Uptake(struct Soil p[], double Trans_o, double Trans_u, double Evap_soil) 166 | { 167 | int i; 168 | double rho_w = 1025.0; 169 | double Source; 170 | 171 | Source = Trans_o + Trans_u; 172 | 173 | // for the top layer 174 | p->Ett[0] = Source / rho_w * p->dt[0] + Evap_soil / rho_w; 175 | 176 | // for each layer: 177 | for (i = 1; i < p->n_layer; i++) 178 | p->Ett[i] = Source / rho_w * p->dt[i]; 179 | } 180 | 181 | -------------------------------------------------------------------------------- /BEPS-SIF/vcmax_jmax_mod.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | * Subroutine to calculate the Vcmax and Jmax for sunlit and shaded big-leaf 3 | * 4 | * Written and refactored by Liming He (liming.he@gmail.com) 5 | * Original contributor: Gang Mo 6 | * Reference: 7 | * (1) Chen, J. M., G. Mo, J. Pisek, F. Deng, M. Ishozawa, D. Chan, 2012. 8 | * Effects of foliage clumping on global terrestrial gross primary 9 | * productivity. Global Biogeochemical Cycles, VOL. 26, GB1019, 18, 10 | * doi:10.1029/2010GB003996 11 | * (2) Medlyn, B.E. et al., 1999. Effects of elevated [CO2] on photosynthesis 12 | * in European forest species: a meta-analysis of model parameters. 13 | * Plant, Cell & Environment, 22(12): 1475-1495. 14 | * 15 | * Last update: May 5, 2015 16 | * This subroutine was created on Mar. 18, 2014 17 | **************************************************************************/ 18 | 19 | #include "beps.h" 20 | 21 | void Vcmax_Jmax(double lai_o, double clumping, double Vcmax0, \ 22 | double slope_Vcmax_N, double leaf_N, double CosZs, \ 23 | double *Vcmax_sunlit, double *Vcmax_shaded, double *Jmax_sunlit, double *Jmax_shaded) 24 | { 25 | // Note: Vcmax0 is for the leaf vcmax at top of the canopy. LHE 26 | 27 | double Kn = 0.3; // Kn = 0.713/2.4; 28 | double G_theta = 0.5; 29 | double K,expr1,expr2,expr3; 30 | 31 | if(lai_o < 0.001) lai_o = 0.001; // to avoid error in the code, a minimum is setup here. LHE. 32 | 33 | if (CosZs>0) 34 | { 35 | K = G_theta*clumping/CosZs; // always > 0 LHE 36 | 37 | expr1 = 1 - exp(-K*lai_o); // always > 0. LHE 38 | expr2 = 1 - exp(-(Kn + K)*lai_o); 39 | expr3 = 1 - exp(-Kn*lai_o); 40 | 41 | if(expr1>0) 42 | *Vcmax_sunlit = Vcmax0 * slope_Vcmax_N * leaf_N * K*expr2 / (Kn + K) / expr1; // LHE. May 15, 2014@PGB205b 43 | 44 | else *Vcmax_sunlit = Vcmax0; 45 | 46 | if (K > 0 && lai_o > expr1/K) 47 | //Vcmax_shaded = Vcmax0*parameter1[47]*parameter1[46]*(expr3/Kn-expr2*clumping/(Kn+K))/(lai_o-expr1*2*CosZs); /* modified by Ting, Mar,28,2013 */ 48 | 49 | *Vcmax_shaded = Vcmax0 * slope_Vcmax_N * leaf_N * (expr3 / Kn - expr2 / (Kn + K)) / (lai_o - expr1/K); // original code. 50 | // *Vcmax_shaded = Vcmax0 * slope_Vcmax_N * leaf_N * (expr3 / Kn - expr2 * clumping / (Kn + K)) / (lai_o - 2 * CosZs * expr1); // LHE May 15, 2014@PGB205b. 51 | 52 | else 53 | *Vcmax_shaded = Vcmax0; 54 | 55 | } 56 | else 57 | { 58 | *Vcmax_sunlit = Vcmax0; 59 | *Vcmax_shaded = Vcmax0; 60 | } 61 | 62 | *Jmax_sunlit = *Vcmax_sunlit * 2.39 - 14.2; 63 | *Jmax_shaded = *Vcmax_shaded * 2.39 - 14.2; 64 | } 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BEPS-SIF-model 2 | The Boreal Ecosystem Productivity Simulator (BEPS) is a two-leaf 3 | enzyme-kinetic model initially developed to estimate the carbon uptake 4 | and the water cycle of boreal ecosystems. It has been substantially upgraded 5 | since its original release to simulate carbon and water fluxes at an hourly 6 | time step over various PFTs. Several inter-model comparisons 7 | and site-level validations have shown that BEPS can produce reliable 8 | GPP and ET estimates. 9 | This version of BEPS model (BEPS-SIF) can simulate the Solar-induced chlorophyll 10 | fluorescence at the global level. This SIF scheme was developed based on 11 | radiative transfer physics to account for the canopy scattering effects 12 | and can be used at the global scale. 13 | 14 | Main modules of BEPS-SIF model: 15 | beps401b_glb_hr: main program for global simulation 16 | 17 | inter_prg: This module is a inter-program between main program and modules 18 | 19 | evaporation_canopy: This module calculates evaporation and sublimation from 20 | canopy, from overstorey understorey sunlit and shaded leaf 21 | 22 | netRadiation: This module calculates net radiation at both canopy level and leaf level 23 | 24 | sensible_heat: This module calculates sensible heat from overstorey, understorey and ground 25 | 26 | snowpack: This module calculates will calculate sensible heat from overstorey, understorey and ground 27 | 28 | surface_temp: This module calculates surface temperature in each step, 29 | as well as heat flux for surface to soil layers 30 | 31 | transpiration: This module calculates transpiration, from overstorey understorey sunlit and shaded leaf 32 | 33 | photosyn_gs: This program solves a cubic equation to calculate leaf 34 | photosynthesis and chlorophyll fluorescence. Stomatal conductance 35 | is computed with the Ball-Berry model. A global sun-induced fluorescence 36 | model considers the multiple scattering effects within a canopy. 37 | --------------------------------------------------------------------------------