35 void get_npp(l2str *l2rec,
int prodnum,
float prod[]) {
39 static float32 *parin, *
lat, *
lon;
40 static int nlat, nlon;
41 float sst, chl, trise, tset, mld, bbp, zno3, irr;
42 static int firstCall = 1, havefile;
45 l1str *
l1rec = l2rec->l1rec;
51 char sdsname[H4_MAX_NC_NAME];
56 int dimids[H4_MAX_VAR_DIMS];
61 float *aph,*adg,*bbp_temp,*bbp_s;
64 if (firstCall && strcmp(
parfile,
"") != 0) {
66 if (nc_open(
parfile, NC_NOWRITE, &ncid) == NC_NOERR) {
71 status = nc_inq_varid(ncid, sdsname, &sds_id);
73 fprintf(
stderr,
"-E- %s line %d: Error reading %s from %s.\n",
74 __FILE__, __LINE__, sdsname,
parfile);
78 status = nc_inq_var(ncid, sds_id, 0, &rh_type, &ndims, dimids,
81 if (nc_inq_dimlen(ncid, dimids[0], &length) != NC_NOERR) {
82 char name[H4_MAX_NC_NAME];
83 nc_inq_dim(ncid, dimids[0],
name, &length);
85 "-E- %s line %d: could not get size of dimension \"%s\" in netCDF File.\n",
86 __FILE__, __LINE__,
name);
92 if ((
lat = (
float *) calloc(nlat,
sizeof (
float))) ==
NULL) {
93 printf(
"-E- : Error allocating memory to tindx\n");
97 if (nc_get_var(ncid, sds_id,
lat) != NC_NOERR) {
98 fprintf(
stderr,
"-E- %s line %d: Error reading %s from %s.\n",
99 __FILE__, __LINE__, sdsname,
parfile);
105 status = nc_inq_varid(ncid, sdsname, &sds_id);
107 fprintf(
stderr,
"-E- %s line %d: Error reading %s from %s.\n",
108 __FILE__, __LINE__, sdsname,
parfile);
112 status = nc_inq_var(ncid, sds_id, 0, &rh_type, &ndims, dimids,
115 fprintf(
stderr,
"-E- %s line %d: Error reading %s from %s.\n",
116 __FILE__, __LINE__, sdsname,
parfile);
120 if (nc_inq_dimlen(ncid, dimids[0], &length) != NC_NOERR) {
121 char name[H4_MAX_NC_NAME];
122 nc_inq_dim(ncid, dimids[0],
name, &length);
124 "-E- %s line %d: could not get size of dimension \"%s\" in netCDF File.\n",
125 __FILE__, __LINE__,
name);
131 if ((
lon = (
float *) calloc(nlon,
sizeof (
float))) ==
NULL) {
132 printf(
"-E- : Error allocating memory to tindx\n");
136 if (nc_get_var(ncid, sds_id,
lon) != NC_NOERR) {
137 fprintf(
stderr,
"-E- %s line %d: Error reading %s from %s.\n",
138 __FILE__, __LINE__, sdsname,
parfile);
144 status = nc_inq_varid(ncid, sdsname, &sds_id);
146 fprintf(
stderr,
"-E- %s line %d: Error reading %s from %s.\n",
147 __FILE__, __LINE__, sdsname,
parfile);
151 status = nc_inq_var(ncid, sds_id, 0, &rh_type, &ndims, dimids,
154 fprintf(
stderr,
"-E- %s line %d: Error reading %s from %s.\n",
155 __FILE__, __LINE__, sdsname,
parfile);
159 fprintf(
stderr,
"-E- %s line %d: Wrong number of dimensions for %s. Need 2 got %d.\n",
160 __FILE__, __LINE__, sdsname, ndims);
164 printf(
"PARFILE: %s nlat=%d nlon=%d\n",
parfile, nlat, nlon);
166 if ((parin = (
float *) calloc(nlat * nlon,
sizeof (
float))) ==
NULL) {
167 printf(
"-E- : Error allocating memory to tindx\n");
171 if (nc_get_var_float(ncid, sds_id, parin) != NC_NOERR) {
172 fprintf(
stderr,
"-E- %s line %d: Error reading %s from %s.\n",
173 __FILE__, __LINE__, sdsname,
parfile);
177 double add_offset = 0.0, scale_factor = 1.0;
178 nc_get_att_double(ncid, sds_id,
"add_offset", &add_offset);
179 nc_get_att_double(ncid, sds_id,
"scale_factor", &scale_factor);
181 for (
i=0;
i<nlat*nlon;
i++){
182 parin[
i] *= scale_factor;
183 parin[
i] += add_offset;
189 fprintf(
stderr,
"-E- %s line %d: Error opening parfile = %s.\n",
195 if ((kd = (
float *) calloc(
l1rec->npix, sizeof (
float))) ==
NULL) {
196 printf(
"-E- : Error allocating memory to par in get_opp\n");
199 if ((par = (
float *) calloc(
l1rec->npix, sizeof (
float))) ==
NULL) {
200 printf(
"-E- : Error allocating memory to par in get_opp\n");
206 printf(
"IOP-based Kd_lee product requires iop model selection (iop_opt). ");
207 printf(
"Using default model.\n");
221 for (ip = 0; ip <
l1rec->npix; ip++) {
222 sst =
l1rec->sstref[ip];
223 chl = l2rec->chl[ip];
235 prod[ip] = l2rec->bb[
l1rec->l1file->nbands * ip + ib440];
242 if (par[ip] !=
BAD_FLT && chl > 0) {
247 prod[ip] =
npp_vgpm(chl, par[ip], sst, tset - trise);
254 prod[ip] =
npp_eppley(chl, par[ip], sst, tset - trise);
264 printf(
"opp_cbpm2: incompatible sensor wavelengths (no 440 for backscatter coefficient).\n");
270 bbp = l2rec->bb[
l1rec->l1file->nbands * ip + ib440];
283 prod[ip] =
npp_cbpm2(chl, bbp, irr, kd[ip], mld, zno3, tset - trise);
298 printf(
"npp_cafe: incompatible sensor wavelengths (no 443 for aph, adg, and bbp).\n");
313 prod[ip]=
opp_cafe(par[ip],chl,mld,
l1rec->lat[ip],
day,aph[ipb],adg[ipb],bbp_temp[ipb],bbp_s[ip],sst);
316 printf(
"Error: %s : Unknown product specifier: %d\n", __FILE__, prodnum);
336 void get_par_clim(
float *parin,
float *
lat,
float *
lon,
int nlat,
int nlon,
float *latp,
float *lonp, int32_t
npix,
float *par) {
338 int32_t
i,
j, n, incx, incy, startx, starty;
359 for (n = 0; n <
npix; n++) {
360 for (
i = startx;
i >= 0 &&
i < nlon && (
fabs(lonp[n] -
lon[
i]) >
fabs(dx));
i += incx);
361 for (
j = starty;
j >= 0 &&
j < nlat && (
fabs(latp[n] -
lat[
j]) >
fabs(dy));
j += incy);
363 if (
j < nlat && i < nlon && i > 0 &&
j > 0)
364 par[n] = parin[
j * nlon +
i];
420 float npp_vgpm(
float chl,
float irr,
float sst,
float dayL) {
433 chl_tot = 38.0 * pow(chl, 0.425);
435 chl_tot = 40.2 * pow(chl, 0.507);
438 z_eu = 200.0 * pow(chl_tot, (-.293));
441 z_eu = 568.2 * pow(chl_tot, (-.746));
453 pb_opt = 1.2956 + 2.749e-1 * sst + 6.17e-2 * pow(sst, 2) - 2.05e-2 * pow(sst, 3)
454 + 2.462e-3 * pow(sst, 4) - 1.348e-4 * pow(sst, 5) + 3.4132e-6 * pow(sst, 6)
455 - 3.27e-8 * pow(sst, 7);
461 irrFunc = 0.66125 * irr / (irr + 4.1);
466 npp = pb_opt * chl * dayL * irrFunc * z_eu;
546 chl_tot = 38.0 * pow(chl, 0.425);
548 chl_tot = 40.2 * pow(chl, 0.507);
551 z_eu = 200.0 * pow(chl_tot, (-.293));
554 z_eu = 568.2 * pow(chl_tot, (-.746));
559 pb_opt = 1.54 * pow(10, 0.0275 * sst - 0.07);
564 irrFunc = 0.66125 * irr / (irr + 4.1);
569 npp = pb_opt * chl * dayL * irrFunc * z_eu;
686 double lambda[] = {400, 412, 443, 490, 510, 555, 625, 670, 700};
687 double parFraction[] = {0.0029, 0.0032, 0.0035, 0.0037, 0.0037, 0.0036, 0.0032, 0.0030, 0.0024};
688 double X[] = {.11748, .122858, .107212, .07242, .05943, .03996, .04000, .05150, .03000};
689 double e[] = {.64358, .653270, .673358, .68955, .68567, .64204, .64700, .69500, .60000};
690 double Kw[] = {.01042, .007932, .009480, .01660, .03385, .06053, .28400, .43946, .62438};
711 double Ezlambda[9][200];
740 for (
i = 0;
i < 200;
i++) {
749 for (
i = 0;
i < 9;
i++) {
751 Eo[
i] = irr * parFraction[
i];
752 Ez_mld[
i] = Eo[
i] * 0.975 * exp(-Klambda[
i] * mld / 2.0);
762 for (
i = 0;
i < 8;
i++) {
766 par_mld /= daylength;
768 IgFunc = 1 - exp(-5.0 * par_mld);
772 carbon = 13000.0 * (bbp - 0.00035);
774 chlCarbonSat = chl / carbon;
776 if (chlCarbonSat < y0) {
780 chlCarbonMax = 0.022 + (0.045 - 0.022) * exp(-3.0 * par_mld);
781 delChlC = chlCarbonMax - chlCarbonSat;
783 nutTempFunc = (chlCarbonSat - y0) / (chlCarbonMax - y0);
791 for (
i = 0;
i < 9;
i++) {
792 Kbio = X[
i] * pow(chl, e[
i]);
793 Kd[
i] = Kw[
i] + Kbio;
794 Kdif[
i] = Klambda[
i] - Kd[
i];
802 for (m = 0; m < 200; m++) {
809 chl_C[m] = chlCarbonSat;
810 chlz[m] = chl_C[m] * carbon;
811 mu[m] = uMax * nutTempFunc * IgFunc;
817 for (
i = 0;
i < 9;
i++) {
818 Ezlambda[
i][m] = Eo[
i]*0.975 * exp(-Klambda[
i] * z[m]);
822 for (
i = 0;
i < 8;
i++) {
823 parz[m] += (
lambda[
i + 1] -
lambda[
i])*(Ezlambda[
i + 1][m] + Ezlambda[
i][m]) / 2;
834 for (
i = 0;
i < 9;
i++) {
835 Kbio = X[
i] * pow(chlz[m - 1], e[
i]);
836 Kd[
i] = Kw[
i] + Kbio;
838 Ezlambda[
i][m] = Ezlambda[
i][m - 1] * exp(-Kd[
i]*1.0);
842 for (
i = 0;
i < 8;
i++) {
843 parz[m] += (
lambda[
i + 1] -
lambda[
i])*(Ezlambda[
i + 1][m] + Ezlambda[
i][m]) / 2;
846 deltaZ = zno3 - z[m];
851 chl_C[m] = (0.022 + (0.045 - 0.022) * exp(-3.0 * parz[m] / daylength));
852 chl_C[m] -= delChlC * (1 - exp(-0.075 * deltaZ));
854 IgFuncz = 1 - exp(-5.0 * parz[m] / daylength);
855 mu[m] = uMax * nutTempFunc * IgFuncz;
861 if (
mu[m - 1] >=
r) {
864 Cz[m] = carbon *
mu[m - 1] /
r;
867 chlz[m] = chl_C[m] * Cz[m];
871 prcnt[m] = parz[m] / (irr * 0.975);
875 if (prcnt[m] >= 0.01) {
886 prcnt0 = prcnt[mzeu];
887 prcnt1 = prcnt[mzeu + 1];
890 numerator = prcnt0 - 0.01;
891 denominator = prcnt0 - prcnt1;
892 fraction = numerator / denominator;
893 z_eu = z0 + (z1 - z0) * fraction;
897 ppz[m] =
mu[m] * Cz[m];
910 for (
i = 0;
i < 199;
i++) {
911 npp += (z[
i + 1] - z[
i])*(ppz[
i + 1] + ppz[
i]) / 2;
928 double wave[] = {350, 360, 370, 380, 390, 400,
929 410, 420, 430, 440, 450, 460, 470, 480, 490, 500,
930 510, 520, 530, 540, 550, 560, 570, 580, 590, 600,
931 610, 620, 630, 640, 650, 660, 670, 680, 690, 700};
933 double M[] = {2.1442, 2.0504, 1.9610, 1.8772, 1.8009, 1.7383,
934 1.7591, 1.6974, 1.6108, 1.5169, 1.4158, 1.3077, 1.1982, 1.0955, 1.0000, 0.9118,
935 0.8310, 0.7578, 0.6924, 0.6350, 0.5860, 0.5457, 0.5146, 0.4935, 0.4840, 0.4903,
936 0.5090, 0.5380, 0.6231, 0.7001, 0.7300, 0.7301, 0.7008, 0.6245, 0.4901, 0.2891};
938 double Kdw[] = {0.0510, 0.0405, 0.0331, 0.0278, 0.0242, 0.0217,
939 0.0200, 0.0189, 0.0182, 0.0178, 0.0176, 0.0176, 0.0179, 0.0193, 0.0224, 0.0280,
940 0.0369, 0.0498, 0.0526, 0.0577, 0.0640, 0.0723, 0.0842, 0.1065, 0.1578, 0.2409,
941 0.2892, 0.3124, 0.3296, 0.3290, 0.3559, 0.4105, 0.4278, 0.4521, 0.5116, 0.6514};
963 for (
i = 1;
i < 36;
i++) {
976 printf(
"-E- %s:%d - lambda = %f, out of range\n", __FILE__, __LINE__,
lambda);
985 Kdw_l = k0 + frac*kdiff;
988 M_l = m0 + frac*mdiff;
1070 double wv[] = { 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560,
1071 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700 };
1074 double aw[] = { 0.00663, 0.00473, 0.00454, 0.00495, 0.00635, 0.00922, 0.00979, 0.0106, 0.0127,
1075 0.015, 0.0204, 0.0325, 0.0409, 0.0434, 0.0474, 0.0565, 0.0619, 0.0695,
1076 0.0896, 0.1351, 0.2224, 0.2644, 0.2755, 0.2916, 0.3108, 0.34, 0.41, 0.439, 0.465,
1080 double A_Bricaud[] = { 0.0241, 0.0287, 0.0328, 0.0359, 0.0378, 0.0350, 0.0328, 0.0309, 0.0281,
1081 0.0254, 0.0210, 0.0162, 0.0126, 0.0103, 0.0085, 0.0070, 0.0057, 0.0050,
1082 0.0051, 0.0054, 0.0052, 0.0055, 0.0061, 0.0066, 0.0071, 0.0078, 0.0108,
1083 0.0174, 0.0161, 0.0069, 0.0025 };
1085 double E_Bricaud[] = { 0.6877, 0.6834, 0.6664, 0.6478, 0.6266, 0.5993, 0.5961, 0.5970, 0.5890,
1086 0.6074, 0.6529, 0.7212, 0.7939, 0.8500, 0.9036, 0.9312, 0.9345, 0.9298,
1087 0.8933, 0.8589, 0.8410, 0.8548, 0.8704, 0.8638, 0.8524, 0.8155, 0.8233,
1088 0.8138, 0.8284, 0.9255, 1.0286 };
1091 double PAR_spectrum[] = { 0.00227, 0.00218, 0.00239, 0.00189, 0.00297, 0.00348, 0.00345,
1092 0.00344, 0.00373, 0.00377, 0.00362, 0.00364, 0.00360, 0.00367,
1093 0.00354, 0.00368, 0.00354, 0.00357, 0.00363, 0.00332, 0.00358,
1094 0.00357, 0.00359, 0.00340, 0.00350, 0.00332, 0.00342, 0.00347,
1095 0.00342, 0.00290, 0.00314 };
1110 double absorbed_photons = 0.0;
1111 double PAR_noon[31];
1112 double AP_tzw[101][101][31];
1113 double AP_tz[101][101];
1114 double AP_tz2[101][101];
1119 double E_tzw[101][101][31];
1120 double E_tz[101][101];
1134 double mean_aphi = 0.0;
1138 double phirange[2] = {0.018, 0.030};
1139 double Ekrange[2] = {150*0.086400, 10*0.0864};
1142 double aphi_fact[101];
1145 double NPP_tz[101][101] = {{0.0}};
1146 double NPP_z[101] = {0.0};
1158 for ( w=0; w<31; w++ ){
1160 aphi[w] = aph_443 * A_Bricaud[w] * pow(chl, E_Bricaud[w]) / (0.03711 * pow(chl, 0.61479));
1161 a[w] = aw[w] + aphi[w] + adg_443 * exp(-0.018 * (wv[w] - 443));
1162 bb[w] = bbw[w] + bbp_443 * pow(443 / wv[w], bbp_s);
1169 for (w=0; w<30; w++){
1170 absorbed_photons += 0.5 * 10 * (PAR_spectrum[w+1] * aphi[w+1]/
a[w+1] +
1171 PAR_spectrum[w] * aphi[w]/
a[w]);
1174 absorbed_photons *= PAR * 0.95;
1181 decl = 23.5 * cos (2 *
M_PI * (yd - 172) / 365) *
M_PI / 180;
1182 DL = -1 * tan(
lat*
M_PI/180) * tan(decl);
1184 if (
DL > 1) {
DL = 1;}
1185 if (
DL < -1) {
DL = -1;}
1189 solzen = 90 - asin (sin(
lat*
M_PI/180) * sin(decl) - cos(
lat*
M_PI/180) * cos(decl) *
1191 m0 = sqrt((1 + 0.005 * solzen) * (1 + 0.005 * solzen));
1193 for (w=0; w<31; w++){
1194 kd[w] = m0 *
a[w] + 4.18 * (1 - 0.52 * exp(-10.8 *
a[w])) * bb[w];
1197 kdpar = 0.0665 + (0.874 * kd[9]) - (0.00121 / kd[9]);
1198 zeu = -1 * log (0.1 /(PAR * 0.95)) / kdpar;
1209 for (
t=0;
t<101;
t++){
1211 zseq[
t] = (
double)
t / 100 * ceil(zeu);
1213 for (
t=0;
t<51;
t++){
1216 delz = zseq[1] - zseq[0];
1218 for (w=0; w<31; w++){
1219 PAR_noon[w] =
M_PI / 2 * PAR * 0.95 * PAR_spectrum[w];
1231 for (
t=0;
t<26;
t++){
1232 for (z=0; z<101; z++){
1233 for (w=0; w<31; w++){
1234 E_tzw[
t][z][w] = PAR_noon[w] * sin(
M_PI*tseq[
t]) * exp(-1*kd[w]*zseq[z]);
1235 AP_tzw[
t][z][w] = E_tzw[
t][z][w] * aphi[w];
1239 for (
t=26;
t<51;
t++){
1240 tsym = 25 - (
t - 25);
1241 for (z=0; z<101; z++){
1242 for (w=0; w<31; w++){
1243 E_tzw[
t][z][w] = E_tzw[tsym][z][w];
1244 AP_tzw[
t][z][w] = AP_tzw[tsym][z][w];
1250 for (z=0; z<101; z++){
1260 for (
t=0;
t<26;
t++){
1263 for (w=0; w<30; w++){
1264 E_tz[
t][z] += 10 * (E_tzw[
t][z][w+1] + E_tzw[
t][z][w])/2;
1265 AP_tz[
t][z] += 10 * (AP_tzw[
t][z][w+1] + AP_tzw[
t][z][w])/2;
1268 for (
t=26;
t<51;
t++){
1269 tsym = 25 - (
t - 25);
1270 for (w=0; w<30; w++){
1271 E_tz[
t][z] = E_tz[tsym][z];
1272 AP_tz[
t][z] = AP_tz[tsym][z];
1278 for (z=0; z<101; z++){
1289 for (
t=0;
t<25;
t++){
1291 AP_z[z] += 0.02 * (AP_tz[
t+1][z] + AP_tz[
t][z])/2;
1293 AP_z[z] = 2*AP_z[z];
1297 for (z=0; z<100; z++){
1298 AP += delz * (AP_z[z] + AP_z[z+1])/2;
1302 Eu = absorbed_photons / AP;
1315 for (
t=0;
t<26;
t++){
1316 for (z=0; z<101; z++){
1321 for (
t=26;
t<51;
t++){
1322 tsym = 25 - (
t - 25);
1323 for (z=0; z<101; z++){
1324 E_tz[
t][z] = E_tz[tsym][z];
1325 AP_tz[
t][z] = AP_tz[tsym][z];
1333 IML = (PAR * 0.95 / (
DL* 24)) * exp(-0.5 * kdpar * mld);
1335 for (z=0; z<101; z++){
1336 Ek[z] = 19 * exp(0.038 * pow(PAR * 0.95 / (
DL * 24), 0.45) / kdpar);
1342 Eg_mld = (PAR /
DL) * exp(-1*kdpar*mld);
1343 for (z=0; z<101; z++){
1344 Ek[z] *= (1 + exp(-0.15 * (0.95 * PAR / (
DL * 24)))) / (1 + exp(-3 * IML));
1346 Eg = (PAR /
DL) * exp(-1*kdpar*zseq[z]);
1347 Ek[z] = 10 + (Ek[z] - 10) / (Eg_mld - 0.1) * (Eg -0.1);
1349 if (Ek[z] < 10) {Ek[z] = 10;}
1353 for (z=0; z<101; z++){
1365 for (w=0; w<31; w++){
1366 mean_aphi += aphi[w];
1370 for (z=0; z<101; z++){
1373 for (w=0; w<30; w++){
1377 numerator += 10 * 0.5 * (AP_tzw[24][z][w] + AP_tzw[24][z][w+1]);
1378 denominator += 10 * 0.5 * (E_tzw[24][z][w] + E_tzw[24][z][w+1]);
1380 KPUR[z] = Ek[z] / (numerator / (denominator * mean_aphi) / 1.3);
1387 slope = (phirange[1] - phirange[0]) / (Ekrange[1] - Ekrange[0]);
1389 for (z=0; z<101; z++){
1390 phimax[z] = phirange[1] + (Ek[z] - Ekrange[1]) *
slope;
1391 if (phimax[z] > phirange[1]) {phimax[z] = phirange[1];}
1392 if (phimax[z] < phirange[0]) {phimax[z] = phirange[0];}
1400 for (z=0; z<101; z++){
1402 aphi_fact[z] = 1 + Ek[0]/Ek[z] * 0.15;
1424 for (
t=0;
t<26;
t++){
1425 for (w=0; w<31; w++){
1426 AP_tzw[
t][0][w] = E_tzw[
t][0][w] * aphi[w];
1428 for (z=1; z<101; z++){
1429 for (w=0; w<31; w++){
1430 a[w] = aw[w] + aphi[w] * aphi_fact[z] + adg_443 * exp(-0.018 * (wv[w] - 443));
1431 kd[w] = m0 *
a[w] + 4.18 * (1 - 0.52 * exp(-10.8 *
a[w])) * bb[w];
1432 E_tzw[
t][z][w] = E_tzw[
t][z-1][w] * exp(-1*kd[w]*delz);
1433 AP_tzw[
t][z][w] = E_tzw[
t][z][w] * aphi[w] * aphi_fact[z];
1437 for (
t=26;
t<51;
t++){
1438 tsym = 25 - (
t - 25);
1439 for (w=0; w<31; w++){
1440 AP_tzw[
t][0][w] = AP_tzw[tsym][0][w];
1442 for (z=1; z<101; z++){
1443 for (w=0; w<31; w++){
1444 E_tzw[
t][z][w] = E_tzw[tsym][z][w];
1445 AP_tzw[
t][z][w] = AP_tzw[tsym][z][w];
1451 for (z=0; z<101; z++){
1461 for (
t=0;
t<26;
t++){
1463 for (w=0; w<30; w++){
1464 AP_tz2[
t][z] += 10 * (AP_tzw[
t][z][w+1] + AP_tzw[
t][z][w])/2;
1468 for (
t=26;
t<51;
t++){
1469 tsym = 25 - (
t - 25);
1470 AP_tz2[
t][z] = AP_tz2[tsym][z];
1476 for (z=0; z<101; z++){
1478 for (
t=0;
t<51;
t++){
1479 AP_tz2[
t][z] = AP_tz[
t][z];
1499 for (
t=0;
t<26;
t++){
1500 for (z=0; z<101; z++){
1501 NPP_tz[
t][z] = phimax[z] * AP_tz2[
t][z] * tanh(KPUR[z] / E_tz[
t][z]) * 12000;
1504 for (
t=26;
t<51;
t++){
1505 tsym = 25 - (
t - 25);
1506 for (z=0; z<101; z++){
1507 NPP_tz[
t][z] = NPP_tz[tsym][z];
1513 for (z=0; z<101; z++){
1525 for (
t=0;
t<25;
t++){
1527 NPP_z[z] += 0.02 * (NPP_tz[
t+1][z] + NPP_tz[
t][z])/2;
1528 AP_z2[z] += 0.02 * (AP_tz2[
t+1][z] + AP_tz2[
t][z])/2;
1530 NPP_z[z] = 2*NPP_z[z];
1531 AP_z2[z] = 2*AP_z2[z];
1537 for (z=0; z<100; z++){
1538 NPP += delz * (NPP_z[z] + NPP_z[z+1])/2;
1539 AP2 += delz * (AP_z2[z] + AP_z2[z+1])/2;
1598 double Na = 6.0221417930e23 ;
1599 double Kbz = 1.3806503e-23 ;
1600 double Tk = Tc + 273.15 ;
1602 double delta= 0.039;
1628 n_air = 1.0 + (5792105.0 / (238.0185 - 1 / pow(
lambda / 1e3, 2)) + 167917.0 /
1629 (57.362 - 1 / pow(
lambda/1e3,2))) /1e8;
1632 double n0 = 1.31405;
double n1 = 1.779e-4 ;
double n2 = -1.05e-6 ;
1633 double n3 = 1.6e-8 ;
double n4 = -2.02e-6 ;
double n5 = 15.868;
1634 double n6 = 0.01155;
double n7 = -0.00423;
double n8 = -4382 ;
1635 double n9 = 1.1455e6;
1638 nsw = n0 + (n1 + n2 * Tc + n3 * pow(Tc, 2)) * S + n4 * pow(Tc, 2) +
1641 dnswds = (n1 + n2 * Tc + n3 * pow(Tc, 2) + n6 /
lambda) * n_air;
1653 kw = 19652.21 + 148.4206 * Tc - 2.327105 * pow(Tc, 2) + 1.360477e-2 * pow(Tc, 3) -
1654 5.155288e-5 * pow(Tc, 4);
1663 g0 = 54.6746 - 0.603459 * Tc + 1.09987e-2 * pow(Tc, 2) - 6.167e-5 * pow(Tc, 3);
1664 g1 = 7.944e-2 + 1.6483e-2 * Tc - 5.3009e-4 * pow(Tc, 2);
1666 Ks = kw + g0 * S + g1 * pow(S, 1.5);
1669 IsoComp = ( 1 / Ks * 1e-5);
1675 double a0 = 8.24493e-1;
double a1 = -4.0899e-3;
double a2 = 7.6438e-5;
1676 double a3 = -8.2467e-7;
double a4 = 5.3875e-9;
double a5 = -5.72466e-3;
1677 double a6 = 1.02270e-4;
double a7 = -1.6546e-6;
double a8 = 4.8314e-4;
1678 double b0 = 999.842594;
double b1 = 6.793952e-2;
double b2 = -9.09529e-3;
1679 double b3 = 1.001685e-4;
double b4 = -1.120083e-6;
double b5 = 6.536332e-9;
1682 density = b0 +
b1 * Tc + b2 * pow(Tc, 2) + b3 * pow(Tc, 3) + b4 * pow(Tc, 4) + b5 * pow(Tc, 5);
1684 density += (( a0 + a1 * Tc + a2 * pow(Tc, 2) + a3 * pow(Tc, 3) + a4 * pow(Tc, 4)) * S +
1685 ( a5 + a6 * Tc + a7 * pow(Tc, 2)) * pow(S, 1.5) + a8 * pow(S, 2));
1697 dlnawds = (-5.58651e-4 + 2.40452e-7 * Tc -3.12165e-9 * pow(Tc, 2) + 2.40808e-11 * pow(Tc, 3)) +
1698 1.5*(1.79613e-5 -9.9422e-8 * Tc +2.08919e-9 * pow(Tc, 2) - 1.39872e-11 * pow(Tc, 3)) *
1699 pow(S, 0.5) + 2 * (-2.31065e-6 - 1.37674e-9 * Tc -1.93316e-11 * pow(Tc, 2)) * S;
1706 n_wat2 = pow(nsw, 2);
1708 base = (nsw/3 - (1.0/3.0) / nsw);
1710 DFRI = (n_wat2 - 1) * (1 + (2.0/3.0) * (n_wat2 + 2) * pow(
base, 2)) ;
1716 beta_df =
M_PI *
M_PI / 2 * pow(
lambda*1e-9, -4) * Kbz * Tk * IsoComp * pow(DFRI,2) *
1720 flu_con = S * M0 * pow(dnswds,2) /
density / (-1 * dlnawds) / Na;
1721 beta_cf = 2 *
M_PI *
M_PI * pow(
lambda*1e-9, -4) * pow(nsw, 2) * flu_con * (6 + 6 *
delta) /
1725 beta90sw = beta_df + beta_cf;