|
| 1 | +/******************************************************************************** |
| 2 | + filename : compute_soil_resp.c |
| 3 | + purpose : Calculate soil respiration (heterotrophic respiration, or Rh) |
| 4 | + interface : - input : |
| 5 | + - Nnodes: number of points (vertically) at which to evaluate soil respiration |
| 6 | + - dZ[]: array of layer thicknesses [m] pertaining to nodes |
| 7 | + - dZTot: total depth [m] of all layers (total depth of soil containing carbon) |
| 8 | + - dt: timestep length [h] |
| 9 | + - T[]: array of node temperatures [K] |
| 10 | + - w[]: array of node moisture fractions [fraction] |
| 11 | + - CLitter: carbon storage in litter pool [gC/m2] |
| 12 | + - CInter: carbon storage in intermediate pool [gC/m2] |
| 13 | + - CSlow: carbon storage in slow pool [gC/m2] |
| 14 | + Note: the litter pool is concentrated at the soil surface, while the intermediate and |
| 15 | + slow pools are both assumed to be distributed uniformly throughout soil column. |
| 16 | +
|
| 17 | + - constants: |
| 18 | + - E0_LT: Lloyd-Taylor E0 parameter [K] |
| 19 | + - T0_LT: Lloyd-Taylor E0 parameter [K] |
| 20 | + - wminFM: minimum soil moisture (fraction) at which soil respiration can occur |
| 21 | + - wmaxFM: maximum soil moisture (fraction) at which soil respiration can occur |
| 22 | + - woptFM: soil moisture (fraction) at which maximum soil respiration occurs |
| 23 | + - Rhsat: ratio of soil respiration rate under saturated conditions (w=wmaxFM) to |
| 24 | + that under optimal conditions (w=woptFM) |
| 25 | + - Rfactor: scaling factor to account for other (non-moisture) sources of inhibition |
| 26 | + of respiration |
| 27 | + - tauLitter: Litter pool turnover time [y] |
| 28 | + - tauInter: Intermediate pool turnover time [y] |
| 29 | + - tauSlow: Slow pool turnover time [y] |
| 30 | +
|
| 31 | + - output: |
| 32 | + - RhLitter: Soil respiration from litter pool [gC/m2] |
| 33 | + - RhInterTot: Soil respiration from intermediate pool [gC/m2] |
| 34 | + - RhSlowTot: Soil respiration from slow pool [gC/m2] |
| 35 | +
|
| 36 | + programmer: Ted Bohn |
| 37 | + date : July 25, 2013 |
| 38 | + changes : |
| 39 | + references: |
| 40 | +********************************************************************************/ |
| 41 | + |
| 42 | +#include <stdio.h> |
| 43 | +#include <stdlib.h> |
| 44 | +#include <string.h> |
| 45 | +#include <vicNl.h> |
| 46 | + |
| 47 | +static char vcid[] = "$Id: $"; |
| 48 | + |
| 49 | +void compute_soil_resp(int Nnodes, |
| 50 | + double *dZ, |
| 51 | + double dZTot, |
| 52 | + double dt, |
| 53 | + double *T, |
| 54 | + double *w, |
| 55 | + double CLitter, |
| 56 | + double CInter, |
| 57 | + double CSlow, |
| 58 | + double *RhLitter, |
| 59 | + double *RhInterTot, |
| 60 | + double *RhSlowTot) |
| 61 | +{ |
| 62 | + extern option_struct options; |
| 63 | + int i; |
| 64 | + double Tref; |
| 65 | + double *TK; |
| 66 | + double fTLitter; |
| 67 | + double *fTSoil; |
| 68 | + double fMLitter; |
| 69 | + double *fMSoil; |
| 70 | + double *CInterNode; |
| 71 | + double *CSlowNode; |
| 72 | + double *RhInter; |
| 73 | + double *RhSlow; |
| 74 | + |
| 75 | + /* Allocate temp arrays */ |
| 76 | + TK = (double*)calloc(Nnodes,sizeof(double)); |
| 77 | + fTSoil = (double*)calloc(Nnodes,sizeof(double)); |
| 78 | + fMSoil = (double*)calloc(Nnodes,sizeof(double)); |
| 79 | + CInterNode = (double*)calloc(Nnodes,sizeof(double)); |
| 80 | + CSlowNode = (double*)calloc(Nnodes,sizeof(double)); |
| 81 | + RhInter = (double*)calloc(Nnodes,sizeof(double)); |
| 82 | + RhSlow = (double*)calloc(Nnodes,sizeof(double)); |
| 83 | + |
| 84 | + /* Compute Lloyd-Taylor temperature dependence */ |
| 85 | + Tref = 10+KELVIN; /* reference temperature of 10 C */ |
| 86 | + for (i=0; i<Nnodes; i++) { |
| 87 | + TK[i] = T[i]+KELVIN; |
| 88 | + if (TK[i] < T0_LT) TK[i] = T0_LT; |
| 89 | + } |
| 90 | + fTLitter = exp( E0_LT * ( 1/(Tref-T0_LT) - 1/(TK[0]-T0_LT) ) ); |
| 91 | + for (i=0; i<Nnodes; i++) { |
| 92 | + fTSoil[i] = exp( E0_LT * ( 1/(Tref-T0_LT) - 1/(TK[i]-T0_LT) ) ); |
| 93 | + } |
| 94 | + |
| 95 | + /* Compute moisture dependence */ |
| 96 | + for (i=0; i<Nnodes; i++) { |
| 97 | + if (w[i] < wminFM) w[i] = wminFM; |
| 98 | + if (w[i] > wmaxFM) w[i] = wmaxFM; |
| 99 | + } |
| 100 | + if (w[0] <= woptFM) |
| 101 | + fMLitter = (w[0]-wminFM)*(w[0]-wmaxFM)/((w[0]-wminFM)*(w[0]-wmaxFM)-(w[0]-woptFM)*(w[0]-woptFM)); |
| 102 | + else |
| 103 | + fMLitter = Rhsat + (1-Rhsat)*(w[0]-wminFM)*(w[0]-wmaxFM)/((w[0]-wminFM)*(w[0]-wmaxFM)-(w[0]-woptFM)*(w[0]-woptFM)); |
| 104 | + if (fMLitter > 1.0) fMLitter = 1.0; |
| 105 | + if (fMLitter < 0.0) fMLitter = 0.0; |
| 106 | + for (i=0; i<Nnodes; i++) { |
| 107 | + if (w[i] <= woptFM) |
| 108 | + fMSoil[i] = (w[i]-wminFM)*(w[i]-wmaxFM)/((w[i]-wminFM)*(w[i]-wmaxFM)-(w[i]-woptFM)*(w[i]-woptFM)); |
| 109 | + else |
| 110 | + fMSoil[i] = Rhsat + (1-Rhsat)*(w[i]-wminFM)*(w[i]-wmaxFM)/((w[i]-wminFM)*(w[i]-wmaxFM)-(w[i]-woptFM)*(w[i]-woptFM)); |
| 111 | + if (fMSoil[i] > 1.0) fMSoil[i] = 1.0; |
| 112 | + if (fMSoil[i] < 0.0) fMSoil[i] = 0.0; |
| 113 | + } |
| 114 | + |
| 115 | + /* Compute C per node */ |
| 116 | + for (i=0; i<Nnodes; i++) { |
| 117 | + CInterNode[i] = CInter * dZ[i]/dZTot; |
| 118 | + CSlowNode[i] = CSlow * dZ[i]/dZTot; |
| 119 | + } |
| 120 | + |
| 121 | + /* Compute Rh for various pools, nodes; C fluxes in [gC/m2d] */ |
| 122 | + *RhLitter = Rfactor*(fTLitter*fMLitter/(tauLitter*365.25*24/dt))*CLitter; |
| 123 | + *RhInterTot = 0; |
| 124 | + *RhSlowTot = 0; |
| 125 | + for (i=0; i<Nnodes; i++) { |
| 126 | + RhInter[i] = Rfactor*(fTSoil[i]*fMSoil[i]/(tauInter*365.25*24/dt))*CInterNode[i]; |
| 127 | + RhSlow[i] = Rfactor*(fTSoil[i]*fMSoil[i]/(tauSlow*365.25*24/dt))*CSlowNode[i]; |
| 128 | + *RhInterTot += RhInter[i]; |
| 129 | + *RhSlowTot += RhSlow[i]; |
| 130 | + } |
| 131 | + |
| 132 | + free((char *)TK); |
| 133 | + free((char *)fTSoil); |
| 134 | + free((char *)fMSoil); |
| 135 | + free((char *)CInterNode); |
| 136 | + free((char *)CSlowNode); |
| 137 | + free((char *)RhInter); |
| 138 | + free((char *)RhSlow); |
| 139 | + |
| 140 | +} |
| 141 | + |
0 commit comments