1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
/* SWT.c Calculate updated textural parameters for soilwater submodel*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "soilwater.h"
#include "n2o_model.h"
extern LAYERPAR_SPT layers; float bulkd; float edepth;
float somsc;float ompc;
void SWT(int *swflag, int ilyr, double fcsa, double fcsi, double fccl,
double fcom, double fcbd, double fcwp, double fcin,
double wpsa, double wpsi, double wpcl,
double wpom, double pbd, double wpwp, double wpbd, double wpin,
float som1c2, float som2c2, float som3c, float adep[CENTMAXLYR],
int *nlayer, int *numlyrs,float *bulkd,
float *pH, float awilt[], float afiel[])
{
int clyr;
float adepmin[CENTMAXLYR], adepmax[CENTMAXLYR];
float width;
adepmin[0] = 0.0f;
adepmax[0] = adep[0];
*bulkd = 0.0f;
*pH = 0.0f;
*swflag = 2;
for (clyr=1; clyr < *nlayer; clyr++) {
adepmin[clyr] = adepmax[clyr-1];
adepmax[clyr] = adepmin[clyr] + adep[clyr];}
/* values for swflag 2 */
fcsa=0.5018; fcsi=0.8548; fccl=0.8833; fcom=4.966E-03;
fcbd=-0.2423; fcwp=0.0; fcin=0.0; wpsa=-0.0059; wpsi=0.1142; wpcl=0.5766;
wpom=2.228E-03; wpbd=0.02671; wpwp=0.0; wpin=0.0;
/* Check for incompatible soil profiles */
for (clyr=0; clyr<=*nlayer; clyr++) {
awilt[clyr] = 0.0f;
afiel[clyr] = 0.0f;
if (clyr == 0) {
width = 0.0f;
for (ilyr=layers->ubnd[clyr]; ilyr<= layers->lbnd[clyr]; ilyr++)
{
*bulkd += layers->bulkd[ilyr] * layers->width[ilyr];
*pH += layers->pH[ilyr] * layers->width[ilyr];
width += layers->width[ilyr];
}
*bulkd /= width;
printf("bulkd = %5.2f\n", *bulkd);
}
}
}
for (ilyr=layers->ubnd[clyr]; ilyr<= layers->lbnd[clyr]; ilyr++)
{
/*Calculate updated textural parameters*/
layers->fieldc[ilyr] = fcsa * layers->sandfrac[ilyr] + fcsi *
(1 - (layers->sandfrac[ilyr] + layers->clayfrac[ilyr]))+
fccl * layers->clayfrac[ilyr] + fcom * ompc +
fcbd * layers->bulkd[ilyr] + fcwp * layers->wiltpt[ilyr]+
fcin ;
layers->wiltpt[ilyr] = wpsa * layers->sandfrac[ilyr] + wpsi *
(1- (layers->sandfrac[ilyr] + layers->clayfrac[ilyr])) +
wpcl * layers->clayfrac[ilyr] + wpom *ompc +
wpbd * layers->bulkd[ilyr] + wpwp * layers->wiltpt[ilyr] +
wpin;
somsc = som1c2 + som2c2 + som3c;
layers->ompc[ilyr] = somsc * 1.724/(10000 * layers->bulkd[ilyr]
* layers->dpthmx[ilyr]-layers->dpthmn[ilyr]) ;
/* Convert volumetric soil water content to */
/* soil water content per layer (in cm H2O) */
layers->swcfc[ilyr] = layers->fieldc[ilyr] * layers->width[ilyr];
layers->swcwp[ilyr] = layers->wiltpt[ilyr] * layers->width[ilyr];
}
width = 0.0f;
for (ilyr=layers->ubnd[clyr]; ilyr<= layers->lbnd[clyr];ilyr++) {
awilt[clyr] += layers->c[ilyr] * layers->width[ilyr];
afiel[clyr] += layers->a[ilyr] * layers->width[ilyr];
width += layers->width[ilyr];
}
awilt[clyr] /= width;
afiel[clyr] /= width;
printf("awilt[%1d] = %8.6f\n", clyr, awilt[clyr]);
printf("afiel[%1d] = %8.6f\n", clyr, afiel[clyr]);
}
/* export calculated values*/
printf(" update for SWC");
printf(" ph and bd updates later\n");
for (ilyr=0; ilyr < layers->numlyrs; ilyr++) {
printf("%6.4f\t%6.4f\t",
layers->fieldc[ilyr],layers->wiltpt[ilyr]);
printf("%4.2f\t%4.2f\t",
layers->swcfc[ilyr], layers->swcwp[ilyr]);
}
|