Ecological Landscape Modeling: Models Pages

budgstats.h File Reference

Header file for calculations of Basin/Indicator-Region budgets, and other statistical summaries. More...

#include "globals.h"

Include dependency graph for budgstats.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define conv_m3TOthousacrft   8.1070e-7

Functions

void stats (int step)
 Calling function for budget and summary stats.
void BIRstats_sum (void)
 Generate variable sums/means for Basins/Indicator-Regions (non-budget) stats.
void BIRbudg_sum (void)
 Generate (every time step) budget summations for Basins/Indicator-Regions.
void BIRstats_hydro_sumFinal (void)
 Assemble the final sums for end-of-day hydrologic summary statistics.
void BIRstats_hydro_print (ibas)
void BIRstats_hydro_date (void)
 Print date stamp on current BIRhydro output record.
void BIRstats_hydro_reset (void)
 Reset BIR hydro (non-budget) statistics summations to zero.
void BIRstats_sumFinal (void)
 Assemble the final sums for end-of-period summary statistics.
void BIRbudg_sumFinal (void)
 Assemble the final sums for end-of-period budget.
void BIRstats_print (int ibas)
 Print out values of BIRavg Performance Measure data.
void BIRbudg_print (int ibas)
 Calculate the mass balance errors and the in/out averages, then print out values of BIR budget data.
void BIRstats_date (void)
 Print date stamp on current BIRavg output record.
void BIRbudg_date (void)
 Print date stamp on current BIR budget output record.
void BIRstats_reset (void)
 Reset BIR (non-budget) statistics summations to zero.
void BIRbudg_reset (void)
 Reset BIR budget summations to zero.
void BIRinit (void)
 Set up the Basin & Indicator Region (BIR) linkages/inheritances.
void BIRoutfiles (void)
 Open files and create headers for BIR output.
void CellAvg (void)
 Generate sums, means (avgs), on cell-by-cell basis (not by Basin/IRegion here).
void Cell_reset_avg (void)
 Zero the arrays holding selected variable averages in cells (after printing)/.
void Cell_reset_hydper (void)
 Zero the array holding hydroperiod data in cells (after printing).
void alloc_mem_stats (void)
 Allocate memory for the BIR-based and cell-based stats variables.
char * Scip (char *s, char SYM)
 Skip ahead in a string until next field.
void init_pvar (VOIDP Map, UCHAR *mask, unsigned char Mtype, float iv)
 Initialize a variable to a value.
VOIDP nalloc (unsigned mem_size, const char var_name[])
 Allocate memory for a variable.
float FMOD (float x, float y)
 Modulus of a pair of (double) arguments.

Variables

FILE * basInFile
FILE * budget_Wacr1
FILE * budget_Wacr2
FILE * budget_Wacr3
FILE * budget_Wacr4
FILE * budget_Wacr5
FILE * budget_Wcm1
FILE * budget_Wcm2
FILE * budget_Wcm3
FILE * budget_Wcm4
FILE * budget_Wcm5
FILE * budget_P1
FILE * budget_P2
FILE * budget_P3
FILE * budget_P4
FILE * budget_P5
FILE * budget_Par1
FILE * budget_Par2
FILE * budget_Par3
FILE * budget_Par4
FILE * budget_Par5
FILE * budget_Plive1
FILE * budget_Plive2
FILE * budget_Plive3
FILE * budget_Plive4
FILE * budget_Plive5
FILE * budget_Pdead1
FILE * budget_Pdead2
FILE * budget_Pdead3
FILE * budget_Pdead4
FILE * budget_Pdead5
FILE * budget_Pwat1
FILE * budget_Pwat2
FILE * budget_Pwat3
FILE * budget_Pwat4
FILE * budget_Pwat5
FILE * budget_S1
FILE * budget_S2
FILE * budget_S3
FILE * budget_S4
FILE * budget_S5
FILE * BIRavg1
FILE * BIRavg2
FILE * BIRavg3
FILE * BIRavg4
FILE * BIRavg5
FILE * BIRhydro
basnDef ** basn_list
basnDefbasins
int numBasn
char modelFileName [300]
float DAYJUL
char * ModelPath
char * ProjName
char * OutputPath
char modelName [20]
char modelVers [10]
char SimAlt [20]
char SimModif [20]
int ESPmodeON
float budg_Intvl
float BIRavg_Intvl
float BIRhyd_avg_Intvl
float avg_Intvl
int avgPrint


Detailed Description

Header file for calculations of Basin/Indicator-Region budgets, and other statistical summaries.

This defines or declares variables & functions that are global to BudgStats.c.

Note: documented with Doxygen, which expects specific syntax within special comments.

The Everglades Landscape Model (ELM).
last updated: Jan 2008 (v2.8)

Definition in file budgstats.h.


Define Documentation

#define conv_m3TOthousacrft   8.1070e-7

conversion from m^3 to thousands of acre-feet (m^3 * (2.471e-4acre/m^2) * (3.2808399 ft/m) == m^3 * 0.00081070 acre-ft/m^3)

Definition at line 29 of file budgstats.h.

Referenced by BIRbudg_print().


Function Documentation

void stats ( int  step  ) 

Calling function for budget and summary stats.

Called every time step, this calls functions to summarize variables across time At the time interval for output, this calls functions to make the final summaries, and then resets the data for new interval.

Definition at line 63 of file BudgStats.c.

Referenced by call_cell_dyn().

00064 {
00065     CellAvg();  /* Generate sums, means (avgs), on cell-by-cell basis (not by Basin/IRegion here) */
00066         
00067     BIRstats_sum();  
00068     BIRbudg_sum();  
00069 
00070 /* v2.8 hydro Perf Measure summaries - is a first cut, TODO is re-organize it */
00071     if ( (SimTime.IsBIRhydEnd) )  {
00072                 if (!SimTime.IsDay0) BIRstats_hydro_date(); 
00073                 BIRstats_hydro_sumFinal();
00074         BIRstats_hydro_reset();
00075     } 
00076     if ( (SimTime.IsBIRavgEnd) )  {
00077         if (!SimTime.IsDay0) BIRstats_date(); /* skip TIME 0 of simulation */
00078                 BIRstats_sumFinal();
00079         BIRstats_reset();
00080     } 
00081     if ( (SimTime.IsBudgEnd) )  {
00082         if (!SimTime.IsBudgFirst) BIRbudg_date(); /* skip first budget interval to accumulate info for mass-balance budget check */
00083                 BIRbudg_sumFinal();
00084         BIRbudg_reset();
00085     } 
00086 } 

void BIRstats_sum ( void   ) 

Generate variable sums/means for Basins/Indicator-Regions (non-budget) stats.

Definition at line 93 of file BudgStats.c.

References basn, BIR_DayFire, BIR_Sf_vel, C_ALG, CELL_SIZE, CLsf_avg, Cperi_avg, DayFire, DT, Elev_avg, Mac_avg, MAC_TOT_BIOM, NC_ALG, NCperi_avg, ON_MAP, s0, s1, SAL_SF_WT, SED_ELEV, SF_WT_VEL_mag, Sfwat_avg, StgMinElev, SURFACE_WAT, T, TP_SEDWT_CONCACTMG, TP_SFWT_CONC_MG, TPpore_avg, TPsf_avg, TPsoil_avg, TPtoSOIL_rep, Unsat_avg, UNSAT_DEPTH, and UNSAT_MOIST_PRP.

Referenced by stats().

00094 {
00095     int ix, iy, cellLoc;
00096     float cellSiz_DT = CELL_SIZE * DT;
00097     
00098    
00099     for(ix=1; ix<=s0; ix++) 
00100         for(iy=1; iy<=s1; iy++) 
00101 
00102             if(ON_MAP[cellLoc= T(ix,iy)])  {
00103 /* get the (non-budget) Performance Measure summary values for cells within basins/indicator regions */
00104                     Sfwat_avg[basn[cellLoc]] +=  SURFACE_WAT[cellLoc];
00105                     Sfwat_avg[0]             +=  SURFACE_WAT[cellLoc];
00106                     Unsat_avg[basn[cellLoc]] +=  UNSAT_DEPTH[cellLoc];
00107                     Unsat_avg[0]             +=  UNSAT_DEPTH[cellLoc];
00108                     /* v2.8 hydro Perf Measure summaries - is a first cut, TODO is re-organize it */
00109                     StgMinElev[basn[cellLoc]] +=  ( (SURFACE_WAT[cellLoc] > UNSAT_DEPTH[cellLoc]) ? (SURFACE_WAT[cellLoc]) : (-UNSAT_DEPTH[cellLoc]) );
00110                     StgMinElev[0]             +=  ( (SURFACE_WAT[cellLoc] > UNSAT_DEPTH[cellLoc]) ? (SURFACE_WAT[cellLoc]) : (-UNSAT_DEPTH[cellLoc]) );
00111                     BIR_Sf_vel[basn[cellLoc]] += SF_WT_VEL_mag[cellLoc];
00112                     BIR_Sf_vel[0] += SF_WT_VEL_mag[cellLoc];
00113                     if (UNSAT_DEPTH[cellLoc] > 0.15 && UNSAT_MOIST_PRP[cellLoc] < 0.5) { /* yes, hardcoded thresholds here!! */
00114                         DayFire[cellLoc] += 1.0;
00115                     }
00116                     else {
00117                         DayFire[cellLoc] = 0.0;
00118                     }
00119                     BIR_DayFire[basn[cellLoc]] += DayFire[cellLoc];
00120                     BIR_DayFire[0] += DayFire[cellLoc];
00121                     CLsf_avg[basn[cellLoc]] +=  SAL_SF_WT[cellLoc];
00122                     CLsf_avg[0] +=  SAL_SF_WT[cellLoc];
00123                     /* v2.8 end of hydro Perf Measure summaries - is a first cut, TODO is re-organize it */
00124 
00125                     TPsf_avg[basn[cellLoc]] +=  TP_SFWT_CONC_MG[cellLoc];
00126                     TPsf_avg[0]             +=  TP_SFWT_CONC_MG[cellLoc];
00127                     TPpore_avg[basn[cellLoc]] +=  TP_SEDWT_CONCACTMG[cellLoc];
00128                     TPpore_avg[0]             +=  TP_SEDWT_CONCACTMG[cellLoc];
00129                     TPsoil_avg[basn[cellLoc]] +=  TPtoSOIL_rep[cellLoc];
00130                     TPsoil_avg[0]             +=  TPtoSOIL_rep[cellLoc];
00131                     NCperi_avg[basn[cellLoc]] +=  NC_ALG[cellLoc];
00132                     NCperi_avg[0]             +=  NC_ALG[cellLoc];
00133                     Cperi_avg[basn[cellLoc]] +=  C_ALG[cellLoc];
00134                     Cperi_avg[0]             +=  C_ALG[cellLoc];
00135                     Mac_avg[basn[cellLoc]] +=  MAC_TOT_BIOM[cellLoc];
00136                     Mac_avg[0]             +=  MAC_TOT_BIOM[cellLoc];
00137                     Elev_avg[basn[cellLoc]] +=  SED_ELEV[cellLoc];
00138                     Elev_avg[0]             +=  SED_ELEV[cellLoc];
00139             } /* end spatial loop for summations across domain*/
00140 } 

void BIRbudg_sum ( void   ) 

Generate (every time step) budget summations for Basins/Indicator-Regions.

Definition at line 147 of file BudgStats.c.

References basn, C_ALG_GPP_P, C_ALG_MORT_P, C_ALG_P, Calg_GPP, Calg_mort, CELL_SIZE, conv_gTOkg, DOP, DOP_DECOMP, dop_decomp, dop_desorb, dop_macIn, DOP_nphBio, dop_sorbIn, DT, ESPmodeON, EVAP, floc_decomp, floc_In, FlocP, FlocP_DECOMP, FlocP_FR_ALGAE, FlocP_PhBio, simTime::IsBudgEnd, mac_mort, mac_nph_P, mac_NPP, mac_ph_P, NC_ALG_GPP_P, NC_ALG_MORT_P, NC_ALG_P, NCalg_GPP, NCalg_mort, nphbio_mort_P, ON_MAP, P_ATMOS, P_Calg, P_CELL, P_DEAD_CELL, P_LIVE_CELL, P_MAC, P_NCalg, P_settl, P_WAT_CELL, phbio_mort_P, phbio_npp_P, RAIN, RCHG, s0, s1, SALT_Atm_Depos, SALT_ATMOS, SALT_SED_WT, SALT_SURF_WT, SAT_WATER, SAT_WT_RECHG, SAT_WT_TRANSP, SF_WT_EVAP, SF_WT_FROM_RAIN, SimTime, SUMGW, SUMSF, SUMUW, SURFACE_WAT, T, TOT_S_CELL, TP_Atm_Depos, TP_SED_MINER, TP_SED_WT, TP_SEDWT_UPTAKE, TP_settl, TP_SF_WT, TP_SFWT_MINER, TP_SFWT_UPTAK, TP_SORB, TP_SORBTION, TRANSP, UNSAT_TRANSP, UNSAT_WATER, wat_sedMiner, wat_sedUpt, wat_sfMiner, and wat_sfUpt.

Referenced by stats().

00148 {
00149     int ix, iy, cellLoc;
00150     float cellSiz_DT = CELL_SIZE * DT;
00151    
00152     for(ix=1; ix<=s0; ix++) 
00153         for(iy=1; iy<=s1; iy++) 
00154 
00155             if(ON_MAP[cellLoc= T(ix,iy)])  {
00156 
00157 /* calculate sums of inputs/outputs, then sum the storages */
00158 /* the summations here are ONLY relating to vertical flows in this source file */
00159 /* horizontal cell<->cell, cell<->canal, and cell<->external_system flows in WatMgmt.c and Fluxes.c source files */
00160 /****/
00161 /*  sums of water inflow/outflow (m) */
00162                     /*  vertical system inputs to cells: rain  */
00163                 RAIN[basn[cellLoc]] += (double) SF_WT_FROM_RAIN[cellLoc]*cellSiz_DT ; 
00164                 RAIN[0]             += (double) SF_WT_FROM_RAIN[cellLoc]*cellSiz_DT; 
00165 
00166                     /*  vertical system outputs from cells: evap, transp, recharge */
00167                 EVAP[basn[cellLoc]] += (double) (SF_WT_EVAP[cellLoc])*cellSiz_DT; 
00168                 EVAP[0]             += (double) (SF_WT_EVAP[cellLoc])*cellSiz_DT; 
00169                 TRANSP[basn[cellLoc]] += (double) (SAT_WT_TRANSP[cellLoc] 
00170                                                    + UNSAT_TRANSP[cellLoc])*cellSiz_DT; 
00171                 TRANSP[0]             += (double) (SAT_WT_TRANSP[cellLoc] 
00172                                                    + UNSAT_TRANSP[cellLoc])*cellSiz_DT; 
00173 
00174                     /* Important NOTE: recharge is 0 in elm, not now linked to solute fluxes */
00175                 RCHG[basn[cellLoc]] += (double) (SAT_WT_RECHG[cellLoc])*cellSiz_DT; 
00176                 RCHG[0]             += (double) (SAT_WT_RECHG[cellLoc])*cellSiz_DT; 
00177 
00178 
00179                     /* mass (kg P) sums of P inflow/outflow */
00180                         
00181                 P_ATMOS[basn[cellLoc]] += (double) (TP_Atm_Depos[cellLoc]* DT); 
00182                 P_ATMOS[0]             += (double) (TP_Atm_Depos[cellLoc]* DT); 
00183                 P_settl[basn[cellLoc]] += (double) TP_settl[cellLoc]*DT;  /* kgP */
00184                 P_settl[0]             += (double) TP_settl[cellLoc]*DT;  /* kgP */
00185 
00186                     /* mass (kg Salt) sums of Salt inflow/outflow */
00187                         
00188                 SALT_ATMOS[basn[cellLoc]] += (double) (SALT_Atm_Depos[cellLoc]* DT); 
00189                 SALT_ATMOS[0]             += (double) (SALT_Atm_Depos[cellLoc]* DT); 
00190                         
00191                 if (!ESPmodeON) { /* not calc'd if running in ESP (Everglades Settling-of Phosphorus, i.e., EWQModel emulation) mode */
00192 
00193 
00194                     Calg_GPP[basn[cellLoc]] += (double) ( (C_ALG_GPP_P[cellLoc]  ) 
00195                                                           * conv_gTOkg * cellSiz_DT);/* gP/m2 => kgP */
00196                     NCalg_GPP[basn[cellLoc]] += (double) ( (NC_ALG_GPP_P[cellLoc] ) 
00197                                                            * conv_gTOkg * cellSiz_DT);/* gP/m2 => kgP */
00198                     Calg_mort[basn[cellLoc]] += (double) ( (C_ALG_MORT_P[cellLoc]) 
00199                                                            * conv_gTOkg * cellSiz_DT);/* gP/m2 => kgP */
00200                     NCalg_mort[basn[cellLoc]] += (double) ( (NC_ALG_MORT_P[cellLoc]) 
00201                                                             * conv_gTOkg * cellSiz_DT);/* gP/m2 => kgP */
00202                     dop_macIn[basn[cellLoc]] += (double) DOP_nphBio[cellLoc] 
00203                         * cellSiz_DT;  /* kgP/m2 => kgP */
00204                     dop_sorbIn[basn[cellLoc]] += (double) (TP_SORBTION[cellLoc]>0.0) ? (TP_SORBTION[cellLoc] * DT) : (0.0); /* kgP */
00205                     dop_decomp[basn[cellLoc]] += (double)  DOP_DECOMP[cellLoc] 
00206                         * cellSiz_DT;  /* kgP/m2 => kgP */
00207                     dop_desorb[basn[cellLoc]] += (double)  (TP_SORBTION[cellLoc]<=0.0) ? (-TP_SORBTION[cellLoc] * DT) : (0.0) ; /* kgP */
00208                     
00209                     floc_decomp[basn[cellLoc]] += (double)  FlocP_DECOMP[cellLoc]
00210                         * cellSiz_DT;  /* kgP/m2 => kgP */
00211                     floc_In[basn[cellLoc]] += (double)  (FlocP_FR_ALGAE[cellLoc] + FlocP_PhBio[cellLoc])
00212                         * cellSiz_DT;  /* kgP/m2 => kgP */
00213 
00214                     mac_NPP[basn[cellLoc]] += (double) phbio_npp_P[cellLoc] 
00215                         * cellSiz_DT;  /* kgP/m2 => kgP */
00216                     mac_mort[basn[cellLoc]] += (double) ( phbio_mort_P[cellLoc]+ nphbio_mort_P[cellLoc]) 
00217                         * cellSiz_DT;  /* kgP/m2 => kgP */
00218                     wat_sfMiner[basn[cellLoc]] += (double) TP_SFWT_MINER[cellLoc]*DT;  /* kgP */
00219                     wat_sedMiner[basn[cellLoc]] += (double) TP_SED_MINER[cellLoc]*DT;  /* kgP */
00220                     wat_sfUpt[basn[cellLoc]] += (double) TP_SFWT_UPTAK[cellLoc] * DT;  /* kgP */
00221                     wat_sedUpt[basn[cellLoc]] += (double) TP_SEDWT_UPTAKE[cellLoc]*DT;  /* kgP */
00222                         
00223                         
00224                     Calg_GPP[0] += (double) ( (C_ALG_GPP_P[cellLoc]  ) 
00225                                               * conv_gTOkg * cellSiz_DT);/* gP/m2 => kgP */
00226                     NCalg_GPP[0] += (double) ( (NC_ALG_GPP_P[cellLoc] ) 
00227                                                * conv_gTOkg * cellSiz_DT);/* gP/m2 => kgP */
00228                     Calg_mort[0] += (double) ( (C_ALG_MORT_P[cellLoc]) 
00229                                                * conv_gTOkg * cellSiz_DT);/* gP/m2 => kgP */
00230                     NCalg_mort[0] += (double) ( (NC_ALG_MORT_P[cellLoc]) 
00231                                                 * conv_gTOkg * cellSiz_DT);/* gP/m2 => kgP */
00232                     dop_macIn[0] += (double) DOP_nphBio[cellLoc] 
00233                         * cellSiz_DT;/* kgP/m2 => kgP */
00234                     dop_sorbIn[0] += (double) (TP_SORBTION[cellLoc]>0.0) ? (TP_SORBTION[cellLoc] * DT) : (0.0); /* kgP */
00235                     dop_decomp[0] += (double) DOP_DECOMP[cellLoc] 
00236                         * cellSiz_DT;/* kgP/m2 => kgP */
00237                     dop_desorb[0] += (double)  (TP_SORBTION[cellLoc]<=0.0) ? (-TP_SORBTION[cellLoc] * DT) : (0.0) ; /* kgP */
00238                     floc_decomp[0] += (double)  FlocP_DECOMP[cellLoc]
00239                         * cellSiz_DT;/* kgP/m2 => kgP */
00240                     floc_In[0] += (double)  (FlocP_FR_ALGAE[cellLoc] + FlocP_PhBio[cellLoc])
00241                         * cellSiz_DT;/* kgP/m2 => kgP */
00242                     mac_NPP[0] += (double) phbio_npp_P[cellLoc] 
00243                         * cellSiz_DT;/* kgP/m2 => kgP */
00244                     mac_mort[0] += (double) ( phbio_mort_P[cellLoc]+ nphbio_mort_P[cellLoc]) 
00245                         * cellSiz_DT;/* kgP/m2 => kgP */
00246                     wat_sfMiner[0] += (double) TP_SFWT_MINER[cellLoc]*DT;  /* kgP */
00247                     wat_sedMiner[0] += (double) TP_SED_MINER[cellLoc]*DT;  /* kgP */
00248                     wat_sfUpt[0] += (double) TP_SFWT_UPTAK[cellLoc] * DT;  /* kgP */
00249                     wat_sedUpt[0] += (double) TP_SEDWT_UPTAKE[cellLoc]*DT;  /* kgP */
00250                 }
00251                         
00252                     /* no salt inflow/outflow to/from system in vertical direction */
00253 
00254                     /* sum the storages (budgets) in IndRegions at the desired interval  */
00255                 if ( (SimTime.IsBudgEnd ) ) { 
00256                                 /* water (m * m2) */
00257                     SUMSF[basn[cellLoc]] += (double) SURFACE_WAT[cellLoc]*CELL_SIZE;
00258                     SUMSF[0]             += (double) SURFACE_WAT[cellLoc]*CELL_SIZE; 
00259                     SUMUW[basn[cellLoc]] += (double) UNSAT_WATER[cellLoc]*CELL_SIZE;
00260                     SUMUW[0]             += (double) UNSAT_WATER[cellLoc]*CELL_SIZE; 
00261                     SUMGW[basn[cellLoc]] += (double) SAT_WATER[cellLoc]*CELL_SIZE;
00262                     SUMGW[0]             += (double) SAT_WATER[cellLoc]*CELL_SIZE;  
00263 
00264                       /* most of this not needed when only running in ESP mode (ESPmodeOn), not bothering to clean up now */
00265                                 /* phosphorus (units converted to kg P)*/
00266                         P_Calg[basn[cellLoc]] += (double) (C_ALG_P[cellLoc] ) 
00267                             * conv_gTOkg * CELL_SIZE; /* gP/m2 => kgP */
00268                         P_Calg[0] += (double) (C_ALG_P[cellLoc] ) 
00269                             * conv_gTOkg * CELL_SIZE; /* gP/m2 => kgP */
00270                         P_NCalg[basn[cellLoc]] += (double) (NC_ALG_P[cellLoc]) 
00271                             * conv_gTOkg * CELL_SIZE; /* gP/m2 => kgP */
00272                         P_NCalg[0] += (double) (NC_ALG_P[cellLoc]) 
00273                             * conv_gTOkg * CELL_SIZE; /* gP/m2 => kgP */
00274                         P_MAC[basn[cellLoc]] += (double) (mac_nph_P[cellLoc] + mac_ph_P[cellLoc] )  
00275                             * CELL_SIZE; /* kgP/m2 => kgP */
00276                         P_MAC[0] += (double) (mac_nph_P[cellLoc] + mac_ph_P[cellLoc] )  
00277                             * CELL_SIZE; /* kgP/m2 => kgP */
00278 
00279                         P_LIVE_CELL[basn[cellLoc]] = (P_Calg[basn[cellLoc]] + P_NCalg[basn[cellLoc]] + P_MAC[basn[cellLoc]]);
00280                         P_LIVE_CELL[0]         = (P_Calg[0] + P_NCalg[0] + P_MAC[0]);
00281 
00282                         P_DEAD_CELL[basn[cellLoc]] += (double) ( TP_SORB[cellLoc] +
00283                                                                 ( FlocP[cellLoc] + DOP[cellLoc]  ) /* kgP/m2 */ * CELL_SIZE );
00284                         P_DEAD_CELL[0]         += (double) ( TP_SORB[cellLoc] +
00285                                                                 ( FlocP[cellLoc] + DOP[cellLoc] ) /* kgP/m2 */ * CELL_SIZE );
00286 
00287                         P_WAT_CELL[basn[cellLoc]] += (double) (TP_SED_WT[cellLoc] + TP_SF_WT[cellLoc] ); /*kgP*/
00288                         P_WAT_CELL[0]           += (double) (TP_SED_WT[cellLoc] + TP_SF_WT[cellLoc] ); /*kgP*/
00289                                 
00290                         P_CELL[basn[cellLoc]] = (double) (P_LIVE_CELL[basn[cellLoc]] + P_DEAD_CELL[basn[cellLoc]] + P_WAT_CELL[basn[cellLoc]]);
00291                         P_CELL[0]                 = (double) (P_LIVE_CELL[0] + P_DEAD_CELL[0] + P_WAT_CELL[0]);
00292                     
00293                     
00294                     
00295                                 /* salt (kgS) */
00296                     TOT_S_CELL[basn[cellLoc]] += (double) (SALT_SED_WT[cellLoc] + SALT_SURF_WT[cellLoc] ); 
00297                     TOT_S_CELL[0] +=             (double) (SALT_SED_WT[cellLoc] + SALT_SURF_WT[cellLoc] ); 
00298                 }
00299             } /* end spatial loop for summations across domain*/
00300 
00301 } /* end BIRbudg_sum() */

void BIRstats_hydro_sumFinal ( void   ) 

Assemble the final sums for end-of-day hydrologic summary statistics.

Assemble the sums for parent hydrologic Basins from their children Indicator Regions.

Note:
Please remember that the struct "basins" is generic to include hydrologic Basins and Indicator Regions.

v2.8 hydro Perf Measure summaries - is a first cut, TODO is re-organize it

Definition at line 312 of file BudgStats.c.

References basins, basn_list, BIR_DayFire, BIR_Sf_vel, BIRstats_hydro_print(), CLsf_avg, basndef::IR, simTime::IsDay0, numBasn, basndef::numIR, SimTime, and StgMinElev.

Referenced by stats().

00313 {
00314     int ibas, ii; 
00315         
00316         for (ibas = numBasn; ibas >= 0; ibas--) {
00317             basins = basn_list[ibas];
00318 
00319             for (ii=0; ii<basins->numIR; ii++) { 
00320 /* to a parent basin, add the (non-budget) Performance Measure summation values within any child- Indicator Regions */ 
00321                                 StgMinElev[ibas] +=  StgMinElev[basins->IR[ii]];
00322                                 BIR_Sf_vel[ibas] +=  BIR_Sf_vel[basins->IR[ii]];
00323                                 BIR_DayFire[ibas] +=  BIR_DayFire[basins->IR[ii]];
00324                 CLsf_avg[ibas] +=  CLsf_avg[basins->IR[ii]];
00325             }
00326 
00327         /* now time for output of data */
00328             if (!SimTime.IsDay0) BIRstats_hydro_print(ibas); /* skip TIME 0 of simulation */
00329             
00330         }
00331 }

Here is the call graph for this function:

void BIRstats_hydro_print ( ibas   ) 

Referenced by BIRstats_hydro_sumFinal().

void BIRstats_hydro_date ( void   ) 

Print date stamp on current BIRhydro output record.

Definition at line 916 of file BudgStats.c.

References BIRhydro, simTime::da, simTime::mo, SimTime, and simTime::yr.

Referenced by stats().

00917 {
00918    
00919 /* date stamp for each record in the output files  */
00920      fprintf(BIRhydro, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00921       
00922 }

void BIRstats_hydro_reset ( void   ) 

Reset BIR hydro (non-budget) statistics summations to zero.

Parameters:
ibas Basin/Indicator-Region ID number

Definition at line 1049 of file BudgStats.c.

References BIR_DayFire, BIR_Sf_vel, BIRhydro, CLsf_avg, numBasn, and StgMinElev.

Referenced by stats().

01050 {
01051     int ibas;
01052     
01053         for (ibas = numBasn; ibas >= 0; ibas--) {
01054             StgMinElev[ibas] = BIR_Sf_vel[ibas] = BIR_DayFire[ibas] = CLsf_avg[ibas] = 0.0; /* zero the daily avg after printing */
01055         }
01056         fflush (BIRhydro); 
01057 
01058 }

void BIRstats_sumFinal ( void   ) 

Assemble the final sums for end-of-period summary statistics.

Assemble the sums for parent hydrologic Basins from their children Indicator Regions.

Note:
Please remember that the struct "basins" is generic to include hydrologic Basins and Indicator Regions.

Definition at line 340 of file BudgStats.c.

References basins, basn_list, BIRstats_print(), Cperi_avg, Elev_avg, basndef::IR, simTime::IsDay0, Mac_avg, NCperi_avg, numBasn, basndef::numIR, Sfwat_avg, SimTime, TPpore_avg, TPsf_avg, TPsoil_avg, and Unsat_avg.

Referenced by stats().

00341 {
00342     int ibas, ii; 
00343         
00344         for (ibas = numBasn; ibas >= 0; ibas--) {
00345             basins = basn_list[ibas];
00346 
00347             for (ii=0; ii<basins->numIR; ii++) { 
00348 /* to a parent basin, add the (non-budget) Performance Measure summation values within any child- Indicator Regions */
00349                                 Sfwat_avg[ibas] +=  Sfwat_avg[basins->IR[ii]];
00350                 Unsat_avg[ibas] +=  Unsat_avg[basins->IR[ii]];
00351                 TPsf_avg[ibas] +=  TPsf_avg[basins->IR[ii]];
00352                 TPpore_avg[ibas] +=  TPpore_avg[basins->IR[ii]];
00353                 TPsoil_avg[ibas] +=  TPsoil_avg[basins->IR[ii]];
00354                 NCperi_avg[ibas] +=  NCperi_avg[basins->IR[ii]];
00355                 Cperi_avg[ibas] +=  Cperi_avg[basins->IR[ii]];
00356                 Mac_avg[ibas] +=  Mac_avg[basins->IR[ii]];
00357                 Elev_avg[ibas] +=  Elev_avg[basins->IR[ii]];
00358             }
00359 
00360         /* now time for output of data */
00361             if (!SimTime.IsDay0) BIRstats_print(ibas); /* skip TIME 0 of simulation */
00362         }
00363 }

Here is the call graph for this function:

void BIRbudg_sumFinal ( void   ) 

Assemble the final sums for end-of-period budget.

Assemble the sums for parent hydrologic Basins from their children Indicator Regions, and assemble the grand sums of inflow/outflow to/from all Basins/Indicator Regions.

Note:
Please remember that the struct "basins" is generic to include hydrologic Basins and Indicator Regions.

Definition at line 374 of file BudgStats.c.

References basins, basn_list, BIRbudg_print(), Calg_GPP, Calg_mort, dop_decomp, dop_desorb, dop_macIn, dop_sorbIn, ESPmodeON, EVAP, floc_decomp, floc_In, basndef::IR, simTime::IsBudgFirst, mac_mort, mac_NPP, NCalg_GPP, NCalg_mort, numBasn, basndef::numIR, P, P_ATMOS, P_CELL, P_DEAD, P_DEAD_CELL, P_DEAD_IN, P_DEAD_IN_SUM, P_DEAD_OUT, P_DEAD_OUT_SUM, P_IN, P_IN_GW, P_IN_OVL, P_IN_SPG, P_IN_STR, P_IN_SUM, P_LIVE, P_LIVE_CELL, P_LIVE_IN, P_LIVE_IN_SUM, P_LIVE_OUT, P_LIVE_OUT_SUM, P_OUT, P_OUT_GW, P_OUT_OVL, P_OUT_SPG, P_OUT_STR, P_OUT_SUM, P_settl, P_WAT, P_WAT_CELL, P_WAT_IN, P_WAT_IN_SUM, P_WAT_OUT, P_WAT_OUT_SUM, RAIN, RCHG, S_IN, S_IN_GW, S_IN_OVL, S_IN_SPG, S_IN_STR, S_IN_SUM, S_OUT, S_OUT_GW, S_OUT_OVL, S_OUT_SPG, S_OUT_STR, S_OUT_SUM, SALT_ATMOS, SimTime, SUMGW, SUMSF, SUMUW, TOT_P_CAN, TOT_S, TOT_S_CAN, TOT_S_CELL, TOT_VOL, TOT_VOL_CAN, TRANSP, VOL_IN, VOL_IN_GW, VOL_IN_OVL, VOL_IN_SPG, VOL_IN_STR, VOL_IN_SUM, VOL_OUT, VOL_OUT_GW, VOL_OUT_OVL, VOL_OUT_SPG, VOL_OUT_STR, VOL_OUT_SUM, wat_sedMiner, wat_sedUpt, wat_sfMiner, and wat_sfUpt.

Referenced by stats().

00375 {
00376     int ibas, ii; 
00377         
00378         for (ibas = numBasn; ibas >= 0; ibas--) {
00379             basins = basn_list[ibas];
00380 
00381             for (ii=0; ii<basins->numIR; ii++) { 
00382                     /* sum up all the I/O to child- Indicator Regions within a parent hydrologic basin,
00383                        adding that to the parent (the horizontal flows are treated within the flow calcs) */
00384 
00385                     /* flows */
00386                 RAIN[ibas]+=RAIN[basins->IR[ii]];  
00387                 EVAP[ibas]+=EVAP[basins->IR[ii]];
00388                 TRANSP[ibas]+=TRANSP[basins->IR[ii]]; 
00389                 RCHG[ibas]+=RCHG[basins->IR[ii]];
00390 
00391                 VOL_IN_STR[ibas]+=VOL_IN_STR[basins->IR[ii]]; 
00392                 VOL_OUT_STR[ibas]+=VOL_OUT_STR[basins->IR[ii]];
00393                 S_IN_STR[ibas]+=S_IN_STR[basins->IR[ii]]; 
00394                 S_OUT_STR[ibas]+=S_OUT_STR[basins->IR[ii]];
00395                 P_IN_STR[ibas]+=P_IN_STR[basins->IR[ii]];
00396                 P_OUT_STR[ibas]+=P_OUT_STR[basins->IR[ii]];
00397 
00398                 SALT_ATMOS[ibas]+=SALT_ATMOS[basins->IR[ii]];
00399 
00400                 P_ATMOS[ibas]+=P_ATMOS[basins->IR[ii]];
00401                 Calg_GPP[ibas]+=Calg_GPP[basins->IR[ii]];  
00402                 NCalg_GPP[ibas]+=NCalg_GPP[basins->IR[ii]];
00403                 Calg_mort[ibas]+=Calg_mort[basins->IR[ii]]; 
00404                 NCalg_mort[ibas]+=NCalg_mort[basins->IR[ii]];
00405                 mac_NPP[ibas]+=mac_NPP[basins->IR[ii]]; 
00406                 mac_mort[ibas]+=mac_mort[basins->IR[ii]]; 
00407                 dop_macIn[ibas]+=dop_macIn[basins->IR[ii]]; 
00408                 dop_sorbIn[ibas]+=dop_sorbIn[basins->IR[ii]];
00409                 floc_decomp[ibas]+=floc_decomp[basins->IR[ii]]; 
00410                 floc_In[ibas]+=floc_In[basins->IR[ii]];
00411                  P_settl[ibas]+=P_settl[basins->IR[ii]]; 
00412                 dop_decomp[ibas]+=dop_decomp[basins->IR[ii]]; 
00413                 dop_desorb[ibas]+=dop_desorb[basins->IR[ii]]; 
00414                 wat_sfMiner[ibas]+=wat_sfMiner[basins->IR[ii]]; 
00415                 wat_sedMiner[ibas]+=wat_sedMiner[basins->IR[ii]];
00416                 wat_sfUpt[ibas]+=wat_sfUpt[basins->IR[ii]];  
00417                 wat_sedUpt[ibas]+=wat_sedUpt[basins->IR[ii]];
00418 
00419                     /* stocks */
00420                 SUMSF[ibas]+=SUMSF[basins->IR[ii]];  
00421                 SUMUW[ibas]+=SUMUW[basins->IR[ii]];
00422                 SUMGW[ibas]+=SUMGW[basins->IR[ii]];  
00423                 TOT_VOL_CAN[ibas]+=TOT_VOL_CAN[basins->IR[ii]];
00424 
00425                 TOT_S_CELL[ibas]+=TOT_S_CELL[basins->IR[ii]];  
00426                 TOT_S_CAN[ibas]+=TOT_S_CAN[basins->IR[ii]];
00427                 
00428                 P_CELL[ibas]+=P_CELL[basins->IR[ii]];  
00429                 TOT_P_CAN[ibas]+=TOT_P_CAN[basins->IR[ii]];
00430                 P_LIVE_CELL[ibas]+=P_LIVE_CELL[basins->IR[ii]];  
00431                 P_DEAD_CELL[ibas]+=P_DEAD_CELL[basins->IR[ii]];  
00432                 P_WAT_CELL[ibas]+=P_WAT_CELL[basins->IR[ii]];  
00433 
00434             } /* end of IR summation */
00435             
00436                 /*  inputs  */
00437             VOL_IN[ibas] = RAIN[ibas] + VOL_IN_STR[ibas] + VOL_IN_OVL[ibas] + VOL_IN_SPG[ibas] + VOL_IN_GW[ibas]; 
00438             VOL_IN_SUM[ibas] += VOL_IN[ibas];
00439             S_IN[ibas] = SALT_ATMOS[ibas] + S_IN_STR[ibas] + S_IN_OVL[ibas] + S_IN_SPG[ibas] + S_IN_GW[ibas]; 
00440             S_IN_SUM[ibas] += S_IN[ibas];
00441             P_IN[ibas] = P_ATMOS[ibas] + P_IN_STR[ibas] + P_IN_OVL[ibas] + P_IN_SPG[ibas] + P_IN_GW[ibas]; 
00442             P_IN_SUM[ibas] += P_IN[ibas];
00443             
00444 
00445                 /*  outputs */
00446             VOL_OUT[ibas] = EVAP[ibas] + TRANSP[ibas] + RCHG[ibas] + VOL_OUT_STR[ibas] + VOL_OUT_OVL[ibas] + VOL_OUT_SPG[ibas] + VOL_OUT_GW[ibas]; 
00447             VOL_OUT_SUM[ibas] += VOL_OUT[ibas];
00448             S_OUT[ibas] = S_OUT_STR[ibas] + S_OUT_OVL[ibas] + S_OUT_SPG[ibas] + S_OUT_GW[ibas]; 
00449             S_OUT_SUM[ibas] += S_OUT[ibas];
00450             P_OUT[ibas] = P_OUT_STR[ibas] + P_OUT_OVL[ibas] + P_OUT_SPG[ibas] + P_OUT_GW[ibas]; 
00451             if (ESPmodeON) P_OUT[ibas] += P_settl[ibas]; /* only if running ESP (Everglades Settling-of Phosphorus, i.e., EWQModel emulation) with settling losses from system */
00452             P_OUT_SUM[ibas] += P_OUT[ibas];
00453             
00454 
00455                 /* actual new volume/mass = sum of the current storages */
00456             TOT_VOL[ibas] = SUMSF[ibas] + SUMUW[ibas] + SUMGW[ibas] + TOT_VOL_CAN[ibas]; 
00457             TOT_S[ibas] = TOT_S_CELL[ibas] + TOT_S_CAN[ibas]; 
00458             P[ibas] = P_CELL[ibas] + TOT_P_CAN[ibas]; 
00459             
00460             if (!ESPmodeON) { /* do same for diff P fractions when running full model */
00461                     /*  inputs  */
00462                 P_LIVE_IN[ibas] = Calg_GPP[ibas] + NCalg_GPP[ibas] + mac_NPP[ibas];
00463                 P_LIVE_IN_SUM[ibas] += P_LIVE_IN[ibas];
00464                 P_DEAD_IN[ibas] = dop_macIn[ibas]  + dop_sorbIn[ibas] + P_settl[ibas] + floc_In[ibas];
00465                 P_DEAD_IN_SUM[ibas] += P_DEAD_IN[ibas];
00466                 P_WAT_IN[ibas] =  P_ATMOS[ibas] + dop_decomp[ibas] + floc_decomp[ibas] + dop_desorb[ibas] 
00467                     + P_IN_STR[ibas] + P_IN_OVL[ibas] + P_IN_SPG[ibas] + P_IN_GW[ibas] ;
00468                 P_WAT_IN_SUM[ibas] += P_WAT_IN[ibas] ;
00469                     /*  outputs */
00470                 P_LIVE_OUT[ibas] =  Calg_mort[ibas] + NCalg_mort[ibas] + mac_mort[ibas];
00471                 P_LIVE_OUT_SUM[ibas] += P_LIVE_OUT[ibas];
00472                 P_DEAD_OUT[ibas] = dop_decomp[ibas] + dop_desorb[ibas] + floc_decomp[ibas];
00473                 P_DEAD_OUT_SUM[ibas] += P_DEAD_OUT[ibas];
00474                 P_WAT_OUT[ibas] = Calg_GPP[ibas] + NCalg_GPP[ibas] + mac_NPP[ibas] + dop_sorbIn[ibas] + P_settl[ibas]
00475                     + P_OUT_STR[ibas] + P_OUT_OVL[ibas] + P_OUT_SPG[ibas] + P_OUT_GW[ibas] ;
00476                 P_WAT_OUT_SUM[ibas] += P_WAT_OUT[ibas];
00477                     /* actual new volume/mass = sum of the current storages */
00478                 P_LIVE[ibas] = P_LIVE_CELL[ibas]; 
00479                 P_DEAD[ibas] = P_DEAD_CELL[ibas]; 
00480                 P_WAT[ibas] = P_WAT_CELL[ibas] + TOT_P_CAN[ibas]; 
00481             } /* end of specific P-fraction summations */
00482            
00483         /* now time for output of data */
00484             if (!SimTime.IsBudgFirst) BIRbudg_print(ibas); /* skip first budget interval to accumulate info for mass-balance budget check */
00485         }
00486 }

Here is the call graph for this function:

void BIRstats_print ( int  ibas  ) 

Print out values of BIRavg Performance Measure data.

Parameters:
ibas Basin number

Definition at line 517 of file BudgStats.c.

References basins, basn_list, BIRavg1, BIRavg2, BIRavg3, BIRavg4, BIRavg5, BIRavg_Intvl, Cperi_avg, DT, Elev_avg, Mac_avg, NCperi_avg, numCells, Sfwat_avg, TPpore_avg, TPsf_avg, TPsoil_avg, and Unsat_avg.

Referenced by BIRstats_sumFinal().

00518 {
00519     int Fnum;
00520     float BIRavgStep = BIRavg_Intvl / DT;
00521             
00522     basins = basn_list[ibas];
00523 
00524     Fnum = ((ibas>=52)?(5):
00525             ((ibas>=39)?(4):
00526              ((ibas>=26)?(3):
00527               ((ibas>=13)?(2):
00528                (1) ) )) );
00529     
00530 /* non-budget, Basin/Indicator-Region mean values are printed */
00531     fprintf(   ((Fnum==5)?(BIRavg5):
00532                 ((Fnum==4)?(BIRavg4):
00533                    ((Fnum==3)?(BIRavg3):
00534                     ((Fnum==2)?(BIRavg2):
00535                      (BIRavg1) ) ) ) ),
00536                "%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t",
00537                Sfwat_avg[ibas]/numCells[ibas]/BIRavgStep, 
00538                Unsat_avg[ibas]/numCells[ibas]/BIRavgStep,
00539                TPsf_avg[ibas]/numCells[ibas]/BIRavgStep, 
00540                TPpore_avg[ibas]/numCells[ibas]/BIRavgStep, 
00541                TPsoil_avg[ibas]/numCells[ibas]/BIRavgStep,
00542                NCperi_avg[ibas]/numCells[ibas]/BIRavgStep, 
00543                Cperi_avg[ibas]/numCells[ibas]/BIRavgStep, 
00544                Mac_avg[ibas]/numCells[ibas]/BIRavgStep, 
00545                Elev_avg[ibas]/numCells[ibas]/BIRavgStep);
00546 
00547 }

void BIRbudg_print ( int  ibas  ) 

Calculate the mass balance errors and the in/out averages, then print out values of BIR budget data.

Parameters:
ibas Basin number

Definition at line 554 of file BudgStats.c.

References basins, basn_list, budg_Intvl, budget_P1, budget_P2, budget_P3, budget_P4, budget_P5, budget_Par1, budget_Par2, budget_Par3, budget_Par4, budget_Par5, budget_Pdead1, budget_Pdead2, budget_Pdead3, budget_Pdead4, budget_Pdead5, budget_Plive1, budget_Plive2, budget_Plive3, budget_Plive4, budget_Plive5, budget_Pwat1, budget_Pwat2, budget_Pwat3, budget_Pwat4, budget_Pwat5, budget_S1, budget_S2, budget_S3, budget_S4, budget_S5, budget_Wacr1, budget_Wacr2, budget_Wacr3, budget_Wacr4, budget_Wacr5, budget_Wcm1, budget_Wcm2, budget_Wcm3, budget_Wcm4, budget_Wcm5, Calg_GPP, Calg_mort, conv_cmTOmm, conv_kgTO_Mg, basndef::conv_kgTOmgm2, basndef::conv_m3TOcm, conv_m3TOthousacrft, conv_mgTOug, dop_decomp, dop_desorb, dop_macIn, dop_sorbIn, DT, ESPmodeON, EVAP, floc_decomp, floc_In, mac_mort, mac_NPP, NCalg_GPP, NCalg_mort, P, P_ATMOS, P_Calg, P_DEAD, P_DEAD_ERR, P_DEAD_ERR_CUM, P_DEAD_IN, P_DEAD_IN_AVG, P_DEAD_IN_SUM, P_DEAD_OLD, P_DEAD_OUT, P_DEAD_OUT_AVG, P_DEAD_OUT_SUM, P_ERR, P_ERR_CUM, P_IN, P_IN_AVG, P_IN_GW, P_IN_OVL, P_IN_SPG, P_IN_STR, P_IN_SUM, P_LIVE, P_LIVE_ERR, P_LIVE_ERR_CUM, P_LIVE_IN, P_LIVE_IN_AVG, P_LIVE_IN_SUM, P_LIVE_OLD, P_LIVE_OUT, P_LIVE_OUT_AVG, P_LIVE_OUT_SUM, P_MAC, P_NCalg, P_OLD, P_OUT, P_OUT_AVG, P_OUT_GW, P_OUT_OVL, P_OUT_SPG, P_OUT_STR, P_OUT_SUM, P_settl, P_WAT, P_WAT_ERR, P_WAT_ERR_CUM, P_WAT_IN, P_WAT_IN_AVG, P_WAT_IN_SUM, P_WAT_OLD, P_WAT_OUT, P_WAT_OUT_AVG, P_WAT_OUT_SUM, RAIN, RCHG, S_ERR_CUM, S_IN, S_IN_AVG, S_IN_GW, S_IN_OVL, S_IN_SPG, S_IN_STR, S_IN_SUM, S_OUT, S_OUT_AVG, S_OUT_GW, S_OUT_OVL, S_OUT_SPG, S_OUT_STR, S_OUT_SUM, SALT_ATMOS, SimTime, simTime::TIME, TOT_S, TOT_S_ERR, TOT_S_OLD, TOT_VOL, TOT_VOL_CUM_ERR, TOT_VOL_ERR, TOT_VOL_OLD, TRANSP, VOL_IN, VOL_IN_AVG, VOL_IN_GW, VOL_IN_OVL, VOL_IN_SPG, VOL_IN_STR, VOL_IN_SUM, VOL_OUT, VOL_OUT_AVG, VOL_OUT_GW, VOL_OUT_OVL, VOL_OUT_SPG, VOL_OUT_STR, VOL_OUT_SUM, wat_sedMiner, wat_sedUpt, wat_sfMiner, and wat_sfUpt.

Referenced by BIRbudg_sumFinal().

00555 {
00556     int Fnum;
00557     float budgStep = budg_Intvl / DT;
00558             
00559     basins = basn_list[ibas];
00560 
00561     Fnum = ((ibas>=52)?(5):
00562             ((ibas>=39)?(4):
00563              ((ibas>=26)?(3):
00564               ((ibas>=13)?(2):
00565                (1) ) )) );
00566     
00567         /* error  = newVol - (oldVol+inputs-outputs) */
00568     TOT_VOL_ERR[ibas] = TOT_VOL[ibas] - (TOT_VOL_OLD[ibas]+VOL_IN[ibas]-VOL_OUT[ibas] ); 
00569     TOT_S_ERR[ibas] = TOT_S[ibas] - (TOT_S_OLD[ibas]+S_IN[ibas]-S_OUT[ibas] ); 
00570     P_ERR[ibas] = P[ibas] - (P_OLD[ibas]+P_IN[ibas]-P_OUT[ibas] ); 
00571                 
00572         /* cumulative error  */
00573     TOT_VOL_CUM_ERR[ibas] += TOT_VOL_ERR[ibas]; /* cumulative net error */
00574     S_ERR_CUM[ibas] += TOT_S_ERR[ibas];
00575     P_ERR_CUM[ibas] += P_ERR[ibas]; 
00576                 
00577         /* average inputs and outputs */
00578     VOL_IN_AVG[ibas] = VOL_IN_SUM[ibas]/(SimTime.TIME/budg_Intvl);
00579     VOL_OUT_AVG[ibas] = VOL_OUT_SUM[ibas]/(SimTime.TIME/budg_Intvl); 
00580     S_IN_AVG[ibas] = S_IN_SUM[ibas]/(SimTime.TIME/budg_Intvl);
00581     S_OUT_AVG[ibas] = S_OUT_SUM[ibas]/(SimTime.TIME/budg_Intvl); 
00582     P_IN_AVG[ibas] = P_IN_SUM[ibas]/(SimTime.TIME/budg_Intvl);
00583     P_OUT_AVG[ibas] = P_OUT_SUM[ibas]/(SimTime.TIME/budg_Intvl); 
00584 
00585         /* do same for diff P fractions when running full model */
00586     if (!ESPmodeON) { 
00587         P_LIVE_ERR[ibas] = P_LIVE[ibas] - (P_LIVE_OLD[ibas]+P_LIVE_IN[ibas]-P_LIVE_OUT[ibas] ); 
00588         P_DEAD_ERR[ibas] = P_DEAD[ibas] - (P_DEAD_OLD[ibas]+P_DEAD_IN[ibas]-P_DEAD_OUT[ibas] ); 
00589         P_WAT_ERR[ibas] = P_WAT[ibas] - (P_WAT_OLD[ibas]+P_WAT_IN[ibas]-P_WAT_OUT[ibas] ); 
00590         P_LIVE_ERR_CUM[ibas] += P_LIVE_ERR[ibas];  
00591         P_DEAD_ERR_CUM[ibas] += P_DEAD_ERR[ibas]; 
00592         P_WAT_ERR_CUM[ibas] += P_WAT_ERR[ibas]; 
00593         P_LIVE_IN_AVG[ibas] = P_LIVE_IN_SUM[ibas]/(SimTime.TIME/budg_Intvl);
00594         P_LIVE_OUT_AVG[ibas] = P_LIVE_OUT_SUM[ibas]/(SimTime.TIME/budg_Intvl); 
00595         P_DEAD_IN_AVG[ibas] = P_DEAD_IN_SUM[ibas]/(SimTime.TIME/budg_Intvl);
00596         P_DEAD_OUT_AVG[ibas] = P_DEAD_OUT_SUM[ibas]/(SimTime.TIME/budg_Intvl); 
00597         P_WAT_IN_AVG[ibas] = P_WAT_IN_SUM[ibas]/(SimTime.TIME/budg_Intvl);
00598         P_WAT_OUT_AVG[ibas] = P_WAT_OUT_SUM[ibas]/(SimTime.TIME/budg_Intvl); 
00599     }
00600                 
00601 
00602 /********** PRINTING DATA 
00603  **********/
00604 
00605 /* now all the various budget files are printed */
00606 
00607 /* hydrology */
00608         /* print two files, one with volumes and inputs/outputs in units of thousands acre-feet, the other in units of cm across basin */
00609         /* HYDRO: units used in calcs =  m^3, */
00610         /* OUTPUT of flows, storages are in thousands of acre-ft and in cm across basin (for SFWMM comp) */
00611         /* OUTPUT of error analyses use mm height across the basin */
00612 /* hydrology - volume units */
00613     fprintf(  ((Fnum==5)?(budget_Wacr5):
00614                ((Fnum==4)?(budget_Wacr4):
00615                    ((Fnum==3)?(budget_Wacr3):
00616                     ((Fnum==2)?(budget_Wacr2):
00617                      (budget_Wacr1) ) ) ) ),
00618                "%9.2f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.2f\t", 
00619                TOT_VOL_OLD[ibas]*conv_m3TOthousacrft, 
00620                RAIN[ibas]*conv_m3TOthousacrft, 
00621                EVAP[ibas]*conv_m3TOthousacrft, 
00622                TRANSP[ibas]*conv_m3TOthousacrft,
00623                RCHG[ibas]*conv_m3TOthousacrft, 
00624                VOL_IN_STR[ibas]*conv_m3TOthousacrft, 
00625                VOL_OUT_STR[ibas]*conv_m3TOthousacrft, 
00626                VOL_IN_OVL[ibas]*conv_m3TOthousacrft, 
00627                VOL_OUT_OVL[ibas]*conv_m3TOthousacrft, 
00628                VOL_IN_SPG[ibas]*conv_m3TOthousacrft, 
00629                VOL_OUT_SPG[ibas]*conv_m3TOthousacrft, 
00630                VOL_IN_GW[ibas]*conv_m3TOthousacrft,  
00631                VOL_OUT_GW[ibas]*conv_m3TOthousacrft,
00632                (TOT_VOL_OLD[ibas]+VOL_IN[ibas]-VOL_OUT[ibas])*conv_m3TOthousacrft );
00633         /* the new volume, error (mm in basin),  error/inflow, avg Total vol In and Out */
00634     fprintf(   ((Fnum==5)?(budget_Wacr5):
00635                 ((Fnum==4)?(budget_Wacr4):
00636                    ((Fnum==3)?(budget_Wacr3):
00637                     ((Fnum==2)?(budget_Wacr2):
00638                      (budget_Wacr1) ) ) ) ),
00639                "%9.2f\t%9.4f\t%9.3f\t%9.3f\t%9.3f\t", 
00640                TOT_VOL[ibas]*conv_m3TOthousacrft, 
00641                TOT_VOL_ERR[ibas]*conv_cmTOmm*basins->conv_m3TOcm, 
00642                TOT_VOL_CUM_ERR[ibas]*conv_cmTOmm*basins->conv_m3TOcm, 
00643                VOL_IN_AVG[ibas]*conv_m3TOthousacrft, 
00644                VOL_OUT_AVG[ibas]*conv_m3TOthousacrft );  
00645     
00646 /* hydrology - height units */
00647     fprintf(   ((Fnum==5)?(budget_Wcm5):
00648                 ((Fnum==4)?(budget_Wcm4):
00649                    ((Fnum==3)?(budget_Wcm3):
00650                     ((Fnum==2)?(budget_Wcm2):
00651                      (budget_Wcm1) ) ) ) ),
00652                "%9.2f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.3f\t%9.2f\t", 
00653                TOT_VOL_OLD[ibas]*basins->conv_m3TOcm, 
00654                RAIN[ibas]*basins->conv_m3TOcm, 
00655                EVAP[ibas]*basins->conv_m3TOcm, 
00656                TRANSP[ibas]*basins->conv_m3TOcm, 
00657                RCHG[ibas]*basins->conv_m3TOcm, 
00658                VOL_IN_STR[ibas]*basins->conv_m3TOcm, 
00659                VOL_OUT_STR[ibas]*basins->conv_m3TOcm, 
00660                VOL_IN_OVL[ibas]*basins->conv_m3TOcm, 
00661                VOL_OUT_OVL[ibas]*basins->conv_m3TOcm, 
00662                VOL_IN_SPG[ibas]*basins->conv_m3TOcm, 
00663                VOL_OUT_SPG[ibas]*basins->conv_m3TOcm, 
00664                VOL_IN_GW[ibas]*basins->conv_m3TOcm,  
00665                VOL_OUT_GW[ibas]*basins->conv_m3TOcm,
00666                (TOT_VOL_OLD[ibas]+VOL_IN[ibas]-VOL_OUT[ibas])*basins->conv_m3TOcm );
00667         /* the new volume, error (mm in basin),  error/inflow, avg Total vol In and Out */
00668     fprintf(   ((Fnum==5)?(budget_Wcm5):
00669                 ((Fnum==4)?(budget_Wcm4):
00670                    ((Fnum==3)?(budget_Wcm3):
00671                     ((Fnum==2)?(budget_Wcm2):
00672                      (budget_Wcm1) ) ) ) ),
00673                "%9.2f\t%9.4f\t%9.3f\t%9.3f\t%9.3f\t", 
00674                TOT_VOL[ibas]*basins->conv_m3TOcm, 
00675                TOT_VOL_ERR[ibas]*conv_cmTOmm*basins->conv_m3TOcm, 
00676                TOT_VOL_CUM_ERR[ibas]*conv_cmTOmm*basins->conv_m3TOcm, 
00677                VOL_IN_AVG[ibas]*basins->conv_m3TOcm, 
00678                VOL_OUT_AVG[ibas]*basins->conv_m3TOcm );  
00679 
00680 /* salt/tracer - mass units */
00681         /* mass and inputs/outputs in metric tons (Mg) */
00682     fprintf(  ((Fnum==5)?(budget_S5):
00683                ((Fnum==4)?(budget_S4):
00684                    ((Fnum==3)?(budget_S3):
00685                     ((Fnum==2)?(budget_S2):
00686                      (budget_S1) ) ) ) ),
00687                "%9.3f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.3f\t", 
00688                TOT_S_OLD[ibas]*conv_kgTO_Mg, 
00689                SALT_ATMOS[ibas]*conv_kgTO_Mg, 
00690                S_IN_STR[ibas]*conv_kgTO_Mg, 
00691                S_OUT_STR[ibas]*conv_kgTO_Mg, 
00692                S_IN_OVL[ibas]*conv_kgTO_Mg, 
00693                S_OUT_OVL[ibas]*conv_kgTO_Mg, 
00694                S_IN_SPG[ibas]*conv_kgTO_Mg, 
00695                S_OUT_SPG[ibas]*conv_kgTO_Mg, 
00696                S_IN_GW[ibas]*conv_kgTO_Mg,  
00697                S_OUT_GW[ibas]*conv_kgTO_Mg,
00698                (TOT_S_OLD[ibas]+S_IN[ibas]-S_OUT[ibas])*conv_kgTO_Mg );
00699         /* the new mass (Mg), error & cumulative error (ug/m2 of basin), cumulative avg Total mass In and Out */
00700     fprintf(   ((Fnum==5)?(budget_S5):
00701                 ((Fnum==4)?(budget_S4):
00702                    ((Fnum==3)?(budget_S3):
00703                     ((Fnum==2)?(budget_S2):
00704                      (budget_S1) ) ) ) ),
00705                "%9.3f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t", 
00706                TOT_S[ibas]*conv_kgTO_Mg, 
00707                TOT_S_ERR[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00708                S_ERR_CUM[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00709                S_IN_AVG[ibas]*conv_kgTO_Mg, 
00710                S_OUT_AVG[ibas]*conv_kgTO_Mg );  
00711                 
00712 /* phosphorus */
00713 /* phosphorus: total, all fractions of P */
00714         /* we print to two files, one with units of Mg per basin, the other in mg/m2 per basin */
00715     if (ESPmodeON) {
00716         fprintf(   ((Fnum==5)?(budget_P5):
00717                     ((Fnum==4)?(budget_P4):
00718                    ((Fnum==3)?(budget_P3):
00719                     ((Fnum==2)?(budget_P2):
00720                      (budget_P1) ) ) ) ),
00721                    "%9.3f\t%9.4f\t%9.4f\t", 
00722                    P_OLD[ibas]*conv_kgTO_Mg,
00723                    P_ATMOS[ibas]*conv_kgTO_Mg, 
00724                    P_settl[ibas]*conv_kgTO_Mg);
00725                    
00726         fprintf(  ((Fnum==5)?(budget_Par5):
00727                    ((Fnum==4)?(budget_Par4):
00728                    ((Fnum==3)?(budget_Par3):
00729                     ((Fnum==2)?(budget_Par2):
00730                      (budget_Par1) ) ) ) ),
00731                    "%9.3f\t%9.4f\t%9.4f\t", 
00732                    P_OLD[ibas]*basins->conv_kgTOmgm2,
00733                    P_ATMOS[ibas]*basins->conv_kgTOmgm2, 
00734                    P_settl[ibas]*basins->conv_kgTOmgm2);
00735     }
00736     
00737     else {
00738         fprintf(  ((Fnum==5)?(budget_P5):
00739                    ((Fnum==4)?(budget_P4):
00740                    ((Fnum==3)?(budget_P3):
00741                     ((Fnum==2)?(budget_P2):
00742                      (budget_P1) ) ) ) ),
00743                    "%9.3f\t%9.4f\t", 
00744                    P_OLD[ibas]*conv_kgTO_Mg,
00745                    P_ATMOS[ibas]*conv_kgTO_Mg);
00746                    
00747         fprintf(   ((Fnum==5)?(budget_Par5):
00748                     ((Fnum==4)?(budget_Par4):
00749                      ((Fnum==3)?(budget_Par3):
00750                       ((Fnum==2)?(budget_Par2):
00751                        (budget_Par1) ) ) ) ),
00752                    "%9.3f\t%9.4f\t", 
00753                    P_OLD[ibas]*basins->conv_kgTOmgm2,
00754                    P_ATMOS[ibas]*basins->conv_kgTOmgm2);
00755     }
00756     
00757     fprintf(   ((Fnum==5)?(budget_P5):
00758                 ((Fnum==4)?(budget_P4):
00759                    ((Fnum==3)?(budget_P3):
00760                     ((Fnum==2)?(budget_P2):
00761                      (budget_P1) ) ) ) ),
00762                "%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.3f\t", 
00763                P_IN_STR[ibas]*conv_kgTO_Mg, 
00764                P_OUT_STR[ibas]*conv_kgTO_Mg, 
00765                P_IN_OVL[ibas]*conv_kgTO_Mg, 
00766                P_OUT_OVL[ibas]*conv_kgTO_Mg, 
00767                P_IN_SPG[ibas]*conv_kgTO_Mg, 
00768                P_OUT_SPG[ibas]*conv_kgTO_Mg, 
00769                P_IN_GW[ibas]*conv_kgTO_Mg,  
00770                P_OUT_GW[ibas]*conv_kgTO_Mg,
00771                (P_OLD[ibas]+P_IN[ibas]-P_OUT[ibas])*conv_kgTO_Mg );
00772         /* the new mass (Mg), error & cumulative error (ug/m2 of basin), cumulative avg Total mass In and Out */
00773     fprintf(   ((Fnum==5)?(budget_P5):
00774                 ((Fnum==4)?(budget_P4):
00775                    ((Fnum==3)?(budget_P3):
00776                     ((Fnum==2)?(budget_P2):
00777                      (budget_P1) ) ) ) ),
00778                "%9.3f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t", 
00779                P[ibas]*conv_kgTO_Mg, 
00780                P_ERR[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00781                P_ERR_CUM[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00782                P_IN_AVG[ibas]*conv_kgTO_Mg, 
00783                P_OUT_AVG[ibas]*conv_kgTO_Mg );  
00784     
00785     fprintf(   ((Fnum==5)?(budget_Par5):
00786                 ((Fnum==4)?(budget_Par4):
00787                    ((Fnum==3)?(budget_Par3):
00788                     ((Fnum==2)?(budget_Par2):
00789                      (budget_Par1) ) ) ) ),
00790                "%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.3f\t", 
00791                P_IN_STR[ibas]*basins->conv_kgTOmgm2, 
00792                P_OUT_STR[ibas]*basins->conv_kgTOmgm2, 
00793                P_IN_OVL[ibas]*basins->conv_kgTOmgm2, 
00794                P_OUT_OVL[ibas]*basins->conv_kgTOmgm2, 
00795                P_IN_SPG[ibas]*basins->conv_kgTOmgm2, 
00796                P_OUT_SPG[ibas]*basins->conv_kgTOmgm2, 
00797                P_IN_GW[ibas]*basins->conv_kgTOmgm2,  
00798                P_OUT_GW[ibas]*basins->conv_kgTOmgm2,
00799                (P_OLD[ibas]+P_IN[ibas]-P_OUT[ibas])*basins->conv_kgTOmgm2 );
00800         /* the new mass (mg/m^2), error & cumulative error (ug/m2 of basin), cumulative avg Total mass In and Out */
00801     fprintf(   ((Fnum==5)?(budget_Par5):
00802                 ((Fnum==4)?(budget_Par4):
00803                    ((Fnum==3)?(budget_Par3):
00804                     ((Fnum==2)?(budget_Par2):
00805                      (budget_Par1) ) ) ) ),
00806                "%9.3f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t", 
00807                P[ibas]*basins->conv_kgTOmgm2, 
00808                P_ERR[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00809                P_ERR_CUM[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00810                P_IN_AVG[ibas]*basins->conv_kgTOmgm2, 
00811                P_OUT_AVG[ibas]*basins->conv_kgTOmgm2 );
00812     
00813 /* phosphorus: separate (live, dead, water-borne) fractions of P */
00814 /* don't print for ESPmodeON, which does not include live, dead, water-borne fractions */
00815     if (!ESPmodeON) { 
00816 /* phosphorus: live P fraction */
00817             /* mass and inputs/outputs in mg/m2 */
00818         fprintf(   ((Fnum==5)?(budget_Plive5):
00819                     ((Fnum==4)?(budget_Plive4):
00820                        ((Fnum==3)?(budget_Plive3):
00821                         ((Fnum==2)?(budget_Plive2):
00822                          (budget_Plive1) ) ) ) ),
00823                    "%9.3f\t%9.3f\t%9.3f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.3f\t", 
00824                    P_MAC[ibas]*basins->conv_kgTOmgm2, 
00825                    P_Calg[ibas]*basins->conv_kgTOmgm2, 
00826                    P_NCalg[ibas]*basins->conv_kgTOmgm2,
00827                    mac_NPP[ibas]*basins->conv_kgTOmgm2, 
00828                    Calg_GPP[ibas]*basins->conv_kgTOmgm2, 
00829                    NCalg_GPP[ibas]*basins->conv_kgTOmgm2,
00830                    mac_mort[ibas]*basins->conv_kgTOmgm2, 
00831                    Calg_mort[ibas]*basins->conv_kgTOmgm2, 
00832                    NCalg_mort[ibas]*basins->conv_kgTOmgm2,
00833                    (P_LIVE_OLD[ibas]+P_LIVE_IN[ibas]-P_LIVE_OUT[ibas])*basins->conv_kgTOmgm2 );
00834             /* the new mass (mg/m2), error & cumulative error (ug/m2 of basin), cumulative avg Total mass In and Out */
00835         fprintf(   ((Fnum==5)?(budget_Plive5):
00836                     ((Fnum==4)?(budget_Plive4):
00837                        ((Fnum==3)?(budget_Plive3):
00838                         ((Fnum==2)?(budget_Plive2):
00839                          (budget_Plive1) ) ) ) ),
00840                    "%9.3f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t", 
00841                    P_LIVE[ibas]*basins->conv_kgTOmgm2, 
00842                    P_LIVE_ERR[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00843                    P_LIVE_ERR_CUM[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00844                    P_LIVE_IN_AVG[ibas]*basins->conv_kgTOmgm2, 
00845                    P_LIVE_OUT_AVG[ibas]*basins->conv_kgTOmgm2 );  
00846         
00847 /* phosphorus: dead P fraction */
00848             /* mass and inputs/outputs in mg/m2 */
00849         fprintf( ((Fnum==5)?(budget_Pdead5):
00850                   ((Fnum==4)?(budget_Pdead4):
00851                        ((Fnum==3)?(budget_Pdead3):
00852                         ((Fnum==2)?(budget_Pdead2):
00853                          (budget_Pdead1) ) ) ) ),
00854                  "%9.3f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.3f\t", 
00855                  P_DEAD_OLD[ibas]*basins->conv_kgTOmgm2, 
00856                  dop_macIn[ibas]*basins->conv_kgTOmgm2, 
00857                  floc_In[ibas]*basins->conv_kgTOmgm2, 
00858                  (dop_decomp[ibas]+floc_decomp[ibas])*basins->conv_kgTOmgm2, 
00859                  P_settl[ibas]*basins->conv_kgTOmgm2, 
00860                  dop_sorbIn[ibas]*basins->conv_kgTOmgm2, 
00861                  dop_desorb[ibas]*basins->conv_kgTOmgm2, 
00862                  (P_DEAD_OLD[ibas]+P_DEAD_IN[ibas]-P_DEAD_OUT[ibas])*basins->conv_kgTOmgm2 );
00863             /* the new mass (mg/m2), error & cumulative error (ug/m2 of basin), cumulative avg Total mass In and Out */
00864         fprintf(  ((Fnum==5)?(budget_Pdead5):
00865                    ((Fnum==4)?(budget_Pdead4):
00866                        ((Fnum==3)?(budget_Pdead3):
00867                         ((Fnum==2)?(budget_Pdead2):
00868                          (budget_Pdead1) ) ) ) ),
00869                  "%9.3f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t", 
00870                  P_DEAD[ibas]*basins->conv_kgTOmgm2, 
00871                  P_DEAD_ERR[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00872                  P_DEAD_ERR_CUM[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00873                  P_DEAD_IN_AVG[ibas]*basins->conv_kgTOmgm2, 
00874                  P_DEAD_OUT_AVG[ibas]*basins->conv_kgTOmgm2 );  
00875 
00876 /* phosphorus: water-borne P fraction */
00877             /* mass and inputs/outputs in mg/m2 */ /* there is a blank column to match the old budget summary template */
00878         fprintf(  ((Fnum==5)?(budget_Pwat5):
00879                    ((Fnum==4)?(budget_Pwat4):
00880                        ((Fnum==3)?(budget_Pwat3):
00881                         ((Fnum==2)?(budget_Pwat2):
00882                          (budget_Pwat1) ) ) ) ),
00883                  "%9.3f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t%9.3f\t", 
00884                  P_WAT_OLD[ibas]*basins->conv_kgTOmgm2,  
00885                  P_ATMOS[ibas]*basins->conv_kgTOmgm2, 
00886                  P_settl[ibas]*basins->conv_kgTOmgm2,
00887                  wat_sfMiner[ibas]*basins->conv_kgTOmgm2, 
00888                  wat_sedMiner[ibas]*basins->conv_kgTOmgm2, 
00889                  wat_sfUpt[ibas]*basins->conv_kgTOmgm2,
00890                  wat_sedUpt[ibas]*basins->conv_kgTOmgm2, 
00891                  dop_desorb[ibas]*basins->conv_kgTOmgm2, 
00892                  dop_sorbIn[ibas]*basins->conv_kgTOmgm2,
00893                  P_IN_STR[ibas]*basins->conv_kgTOmgm2, 
00894                  P_OUT_STR[ibas]*basins->conv_kgTOmgm2,
00895                  (P_WAT_OLD[ibas]+P_WAT_IN[ibas]-P_WAT_OUT[ibas])*basins->conv_kgTOmgm2 );
00896             /* the new mass (mg/m2), error & cumulative error (ug/m2 of basin), cumulative avg Total mass In and Out */
00897         fprintf(  ((Fnum==5)?(budget_Pwat5):
00898                    ((Fnum==4)?(budget_Pwat4):
00899                        ((Fnum==3)?(budget_Pwat3):
00900                         ((Fnum==2)?(budget_Pwat2):
00901                          (budget_Pwat1) ) ) ) ),
00902                  "%9.3f\t%9.4f\t%9.4f\t%9.4f\t%9.4f\t", 
00903                  P_WAT[ibas]*basins->conv_kgTOmgm2, 
00904                  P_WAT_ERR[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00905                  P_WAT_ERR_CUM[ibas]*conv_mgTOug*basins->conv_kgTOmgm2, 
00906                  P_WAT_IN_AVG[ibas]*basins->conv_kgTOmgm2, 
00907                  P_WAT_OUT_AVG[ibas]*basins->conv_kgTOmgm2 );  
00908     } /* end of non-ESPmodeON prints */
00909 
00910 } /* end of BIRbudg_print() */

void BIRstats_date ( void   ) 

Print date stamp on current BIRavg output record.

Definition at line 927 of file BudgStats.c.

References BIRavg1, BIRavg2, BIRavg3, BIRavg4, BIRavg5, simTime::da, simTime::mo, numBasn, ProgExec, prog_attr::S_ParmName, prog_attr::S_ParmVal, SimTime, and simTime::yr.

Referenced by stats().

00928 {
00929     int Fileset;
00930     int FileNum;
00931     extern ProgAttr *ProgExec;
00932 
00933 /* TODO:  yes, yes all of the output in BIR stuff is absurdly crude/repetitive */
00934 
00935     if (numBasn>=52) { /* with more than 58 (plus whole-system basin == 59) basins: */
00936         Fileset=5;              /* we have five sets of basin files */
00937     }
00938     else if (numBasn>=39) { /* with more than 38 (plus whole-system basin == 39) basins: */
00939         Fileset=4;              /* we have four sets of basin files */
00940     }
00941     else if (numBasn>=26) { /* with more than 25 (plus whole-system basin == 26) basins: */
00942         Fileset=3;              /* we have three sets of basin files */
00943     }
00944     else if (numBasn>=13) { /* with more than 12 (plus whole-system basin == 13) basins: */
00945         Fileset=2;              /* we have two sets of basin files */
00946     }
00947     else {
00948         Fileset=1;       /* otherwise, just one set of files */
00949     }
00950     
00951    /* for (FileNum = 1; FileNum <= Fileset; FileNum++) */
00952    
00953 /* date stamp for each record in the output files, including (feb05) which parameter being evaluated in sensitivity analysis (or "NONE" for standard, nominal run)  */
00954                      fprintf(BIRavg1, "\n%s\t%f\t%d/%d/%d\t",ProgExec->S_ParmName,ProgExec->S_ParmVal,SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00955     if (numBasn>=13) fprintf(BIRavg2, "\n%s\t%f\t%d/%d/%d\t",ProgExec->S_ParmName,ProgExec->S_ParmVal,SimTime.yr[0],SimTime.mo[0],SimTime.da[0] );
00956     if (numBasn>=26) fprintf(BIRavg3, "\n%s\t%f\t%d/%d/%d\t",ProgExec->S_ParmName,ProgExec->S_ParmVal,SimTime.yr[0],SimTime.mo[0],SimTime.da[0] );
00957     if (numBasn>=39) fprintf(BIRavg4, "\n%s\t%f\t%d/%d/%d\t",ProgExec->S_ParmName,ProgExec->S_ParmVal,SimTime.yr[0],SimTime.mo[0],SimTime.da[0] );
00958     if (numBasn>=52) fprintf(BIRavg5, "\n%s\t%f\t%d/%d/%d\t",ProgExec->S_ParmName,ProgExec->S_ParmVal,SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00959       
00960 }

void BIRbudg_date ( void   ) 

Print date stamp on current BIR budget output record.

Definition at line 967 of file BudgStats.c.

References budget_P1, budget_P2, budget_P3, budget_P4, budget_P5, budget_Par1, budget_Par2, budget_Par3, budget_Par4, budget_Par5, budget_Pdead1, budget_Pdead2, budget_Pdead3, budget_Pdead4, budget_Pdead5, budget_Plive1, budget_Plive2, budget_Plive3, budget_Plive4, budget_Plive5, budget_Pwat1, budget_Pwat2, budget_Pwat3, budget_Pwat4, budget_Pwat5, budget_S1, budget_S2, budget_S3, budget_S4, budget_S5, budget_Wacr1, budget_Wacr2, budget_Wacr3, budget_Wacr4, budget_Wacr5, budget_Wcm1, budget_Wcm2, budget_Wcm3, budget_Wcm4, budget_Wcm5, simTime::da, ESPmodeON, simTime::mo, numBasn, SimTime, and simTime::yr.

Referenced by stats().

00968 {
00969 
00970 /* date stamp for each record in the budget output files (TODO: not labeled (feb05) for sensi analysis) */
00971     
00972     fprintf(budget_Wacr1, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00973     if (numBasn>=13) fprintf(budget_Wacr2, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00974     if (numBasn>=26) fprintf(budget_Wacr3, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00975     if (numBasn>=39) fprintf(budget_Wacr4, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00976     if (numBasn>=52) fprintf(budget_Wacr5, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00977 
00978     fprintf(budget_Wcm1, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00979     if (numBasn>=13) fprintf(budget_Wcm2, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00980     if (numBasn>=26) fprintf(budget_Wcm3, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00981     if (numBasn>=39) fprintf(budget_Wcm4, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00982     if (numBasn>=52) fprintf(budget_Wcm5, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00983 
00984     fprintf(budget_P1, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] );
00985     if (numBasn>=13) fprintf(budget_P2, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00986     if (numBasn>=26) fprintf(budget_P3, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00987     if (numBasn>=39) fprintf(budget_P4, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00988     if (numBasn>=52) fprintf(budget_P5, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00989 
00990     fprintf(budget_Par1, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00991     if (numBasn>=13) fprintf(budget_Par2, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00992     if (numBasn>=26) fprintf(budget_Par3, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00993     if (numBasn>=39) fprintf(budget_Par4, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00994     if (numBasn>=52) fprintf(budget_Par5, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
00995 
00996     fprintf(budget_S1, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] );
00997     if (numBasn>=13) fprintf(budget_S2, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] );
00998     if (numBasn>=26) fprintf(budget_S3, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] );
00999     if (numBasn>=39) fprintf(budget_S4, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] );
01000     if (numBasn>=52) fprintf(budget_S5, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] );
01001 
01002     if (!ESPmodeON) {
01003         fprintf(budget_Plive1, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01004         if (numBasn>=13) fprintf(budget_Plive2, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01005         if (numBasn>=26) fprintf(budget_Plive3, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01006         if (numBasn>=39) fprintf(budget_Plive4, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01007         if (numBasn>=52) fprintf(budget_Plive5, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01008 
01009         fprintf(budget_Pdead1, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01010         if (numBasn>=13) fprintf(budget_Pdead2, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01011         if (numBasn>=26) fprintf(budget_Pdead3, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01012         if (numBasn>=39) fprintf(budget_Pdead4, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01013         if (numBasn>=52) fprintf(budget_Pdead5, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01014 
01015         fprintf(budget_Pwat1, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01016         if (numBasn>=13) fprintf(budget_Pwat2, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01017         if (numBasn>=26) fprintf(budget_Pwat3, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01018         if (numBasn>=39) fprintf(budget_Pwat4, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01019         if (numBasn>=52) fprintf(budget_Pwat5, "\n%d/%d/%d\t",SimTime.yr[0],SimTime.mo[0],SimTime.da[0] ); 
01020     }
01021 } 

void BIRstats_reset ( void   ) 

Reset BIR (non-budget) statistics summations to zero.

Parameters:
ibas Basin/Indicator-Region ID number

Definition at line 1028 of file BudgStats.c.

Referenced by reinitBIR(), and stats().

01029 {
01030     int ibas;
01031     
01032         for (ibas = numBasn; ibas >= 0; ibas--) {
01033             Sfwat_avg[ibas]=Unsat_avg[ibas]=TPsf_avg[ibas]=TPpore_avg[ibas]=TPsoil_avg[ibas]=
01034                 NCperi_avg[ibas]=Cperi_avg[ibas]=Mac_avg[ibas]=Elev_avg[ibas]=0.0;
01035         }
01036         fflush (BIRavg1); 
01037         if (numBasn>=13) fflush (BIRavg2);
01038         if (numBasn>=26) fflush (BIRavg3); 
01039         if (numBasn>=39) fflush (BIRavg4); 
01040         if (numBasn>=52) fflush (BIRavg5); 
01041 
01042 }

void BIRbudg_reset ( void   ) 

Reset BIR budget summations to zero.

For ALL budgets, store the old total volume in array TOT_xxx_OLD and reset any summations and BIRavgs to 0.

Parameters:
ibas Basin/Indicator-Region ID number

Definition at line 1066 of file BudgStats.c.

Referenced by reinitBIR(), and stats().

01067 {
01068     int ibas;
01069     
01070         for (ibas = numBasn; ibas >= 0; ibas--) {
01071             TOT_VOL_OLD[ibas] = TOT_VOL[ibas]; 
01072             TOT_S_OLD[ibas] = TOT_S[ibas]; 
01073             P_OLD[ibas] = P[ibas]; 
01074             if (!ESPmodeON) {
01075                 P_LIVE_OLD[ibas] = P_LIVE[ibas]; 
01076                 P_DEAD_OLD[ibas] = P_DEAD[ibas]; 
01077                 P_WAT_OLD[ibas] = P_WAT[ibas];
01078             }
01079          
01080             SUMSF[ibas] = SUMGW[ibas] = SUMUW[ibas] = TOT_VOL[ibas] = TOT_VOL_CAN[ibas] =  0.0;
01081             RAIN[ibas] = VOL_IN_STR[ibas] = VOL_IN_OVL[ibas] = VOL_IN_SPG[ibas] = VOL_IN_GW[ibas] =  0.0;
01082             EVAP[ibas] = TRANSP[ibas] = RCHG[ibas] = VOL_OUT_STR[ibas] = VOL_OUT_OVL[ibas] = VOL_OUT_SPG[ibas] = VOL_OUT_GW[ibas] =  0.0;
01083 
01084             TOT_S[ibas] = TOT_S_CELL[ibas] = TOT_S_CAN[ibas] =  0.0;
01085             SALT_ATMOS[ibas] = S_IN_STR[ibas] = S_IN_OVL[ibas] = S_IN_SPG[ibas] = S_IN_GW[ibas] =  0.0;
01086             S_OUT_STR[ibas] = S_OUT_OVL[ibas] = S_OUT_SPG[ibas] = S_OUT_GW[ibas] =  0.0;
01087 
01088             P[ibas] = P_CELL[ibas] = TOT_P_CAN[ibas] =  0.0;
01089             P_ATMOS[ibas] = P_IN_STR[ibas] = P_IN_OVL[ibas] = P_IN_SPG[ibas] = P_IN_GW[ibas] =  0.0;
01090             P_OUT_STR[ibas] = P_OUT_OVL[ibas] = P_OUT_SPG[ibas] = P_OUT_GW[ibas] =  0.0;
01091 
01092             P_LIVE[ibas] = P_LIVE_CELL[ibas] = P_MAC[ibas] = P_Calg[ibas] = P_NCalg[ibas] = 0.0;
01093             Calg_GPP[ibas] = NCalg_GPP[ibas] = Calg_mort[ibas] = NCalg_mort[ibas] = 0.0;
01094             mac_NPP[ibas] = mac_mort[ibas] = 0.0;
01095 
01096             P_DEAD[ibas] = P_DEAD_CELL[ibas] = 0.0;
01097             dop_macIn[ibas] =  dop_sorbIn[ibas] = floc_In[ibas] = 0.0;
01098             dop_decomp[ibas] = dop_desorb[ibas] = floc_decomp[ibas] = 0.0;
01099 
01100             P_WAT[ibas] = P_WAT_CELL[ibas] = 0.0;
01101             wat_sfMiner[ibas] = wat_sedMiner[ibas] = wat_sfUpt[ibas] = wat_sedUpt[ibas] =  P_settl[ibas] = 0.0;
01102 
01103             
01104         }
01105 
01106 
01107         fflush (budget_Wacr1); 
01108         if (numBasn>=13) fflush (budget_Wacr2);
01109         if (numBasn>=26) fflush (budget_Wacr3); 
01110         if (numBasn>=39) fflush (budget_Wacr4); 
01111         if (numBasn>=52) fflush (budget_Wacr5); 
01112 
01113         fflush (budget_Wcm1); 
01114         if (numBasn>=13) fflush (budget_Wcm2); 
01115         if (numBasn>=26) fflush (budget_Wcm3); 
01116         if (numBasn>=39) fflush (budget_Wcm4); 
01117         if (numBasn>=52) fflush (budget_Wcm5); 
01118 
01119         fflush (budget_S1); 
01120         if (numBasn>=13) fflush (budget_S2); 
01121         if (numBasn>=26) fflush (budget_S3); 
01122         if (numBasn>=39) fflush (budget_S4); 
01123         if (numBasn>=52) fflush (budget_S5); 
01124 
01125         fflush (budget_P1); 
01126         if (numBasn>=13) fflush (budget_P2); 
01127         if (numBasn>=26) fflush (budget_P3); 
01128         if (numBasn>=39) fflush (budget_P4); 
01129         if (numBasn>=52) fflush (budget_P5); 
01130 
01131         fflush (budget_Par1); 
01132         if (numBasn>=13) fflush (budget_Par2); 
01133         if (numBasn>=26) fflush (budget_Par3); 
01134         if (numBasn>=39) fflush (budget_Par4); 
01135         if (numBasn>=52) fflush (budget_Par5); 
01136 
01137         if (!ESPmodeON) { 
01138             fflush (budget_Plive1);  
01139             if (numBasn>=13) fflush (budget_Plive2);  
01140             if (numBasn>=26) fflush (budget_Plive3); 
01141             if (numBasn>=39) fflush (budget_Plive4); 
01142             if (numBasn>=52) fflush (budget_Plive5); 
01143 
01144             fflush (budget_Pdead1);  
01145             if (numBasn>=13) fflush (budget_Pdead2);  
01146             if (numBasn>=26) fflush (budget_Pdead3); 
01147             if (numBasn>=39) fflush (budget_Pdead4); 
01148             if (numBasn>=52) fflush (budget_Pdead5); 
01149 
01150             fflush (budget_Pwat1);  
01151             if (numBasn>=13) fflush (budget_Pwat2);  
01152             if (numBasn>=26) fflush (budget_Pwat3); 
01153             if (numBasn>=39) fflush (budget_Pwat4); 
01154             if (numBasn>=52) fflush (budget_Pwat5); 
01155         } 
01156 } /* end of BIRbudg_reset() */

void BIRinit ( void   ) 

Set up the Basin & Indicator Region (BIR) linkages/inheritances.

Definition at line 1164 of file BudgStats.c.

Referenced by init_static_data().

01165 {
01166     int ix,iy,cellLoc,ibas;
01167     int ii, jj, basnID;
01168     int basnCnt=-1; /* the whole system basin-0 in the basinIR file is not considered part of this count of the number of Basin/IRs */
01169     char ss[222], *line, modnam[20], boundIR[3];
01170 
01171     sprintf( modelFileName, "%s/%s/Data/basinIR", ModelPath, ProjName );
01172 /* Open file with basin linkage/inheritance data */
01173     if ( ( basInFile = fopen( modelFileName, "r" ) ) ==  NULL )
01174     {
01175         sprintf( msgStr,"Can't open %s basin definition input file! ",modelFileName ) ; usrErr(msgStr);
01176         exit(-1) ;
01177     }
01178 
01179     fgets( ss, 220, basInFile );fgets( ss, 220, basInFile ); /* skip 2 header lines */
01180     fgets( ss, 220, basInFile ); sscanf( ss,"%s", &modnam); 
01181     if (strcmp(modnam,modelName) != 0) {
01182         sprintf(msgStr, "The model name (%s) found in the %s file doesn't match the one (%s) you asked for in Driver.parm!",
01183                 modnam, modelFileName, modelName); usrErr(msgStr);
01184         exit(-1);
01185     }
01186         /* Allocate memory for first basin */
01187     if ( (basins = ( basnDef *) malloc( (size_t) sizeof( basnDef ))) == NULL ) {
01188         printf( "Failed to allocate memory for first basin (%s)\n ", basins->basnTxt ) ;
01189         exit( -2 ) ;
01190     }
01191         /* allocate memory for array of pointers to basin atts */
01192     if ( (basn_list = 
01193           ( basnDef **) malloc( (size_t) sizeof( basnDef *) * (numBasn+1))) == NULL )
01194     {
01195         printf( "Failed to allocate memory for basin_list\n " ) ;
01196         exit( -2 ) ;
01197     };
01198 
01199 
01200     fgets( ss, 220, basInFile ); /* skip the column name header */
01201     
01202     while ( fgets( ss, 220, basInFile ) != NULL && !feof( basInFile ) )
01203     {
01204         line = ss;
01205         sscanf (line, "%d\t%s\t%d",&basnID, &basins->basnTxt,&basins->numIR);
01206         line = Scip( line, '\t' );line = Scip( line, '\t' );line = Scip( line, '\t' );
01207 /* the indicator regions within a hydrologic basin are subscripted starting at 1,
01208    with the 0'th indicator region being the hydrologic basin itself.  Flok is
01209    used to check for allowable flows among basins/indicator-regions, to determine if user configured
01210    BIRs are OK (NOT used to constrain calculated flows, but only used to verify that no unallowed interbasin
01211    overland flow is occuring via some "leak" in the vector topology) */
01212         for (ii=0; ii<basins->numIR; ii++) {
01213             sscanf (line, "%d%", &basins->IR[ii]);
01214             basins->FLok[ii] = basins->IR[ii]; /* flow is allowed among IRegions in a particular hydro basin (family) */
01215             basins->numFLok++;
01216             line = Scip( line, ',' );
01217         }
01218         basnCnt++; /* count the number of basins&IRs to check that the # in the file is same as # defined on the map */
01219 
01220 /* if there are any FlowOk Basin/Indicator-Region attached to this Basin/Indicator-Region, read them */
01221         while (1) {
01222             while ( *line != '#' && *line != '\0' ) line++;
01223             if(*line != '\0') {
01224                 ++line;
01225                 sscanf (line, "%d%", &basins->FLok[ii]);
01226                 basins->numFLok++;
01227                 ii++;
01228             }
01229             else break;
01230         }
01231 
01232         basn_list[basnID] = basins;
01233     
01234             /* Allocate memory for next basin */
01235         if ( ( basins = ( basnDef *) malloc( (size_t) sizeof(  basnDef ))) == NULL )
01236         {
01237             printf( "Failed to allocate memory for next basin (%s)\n ", basins->basnTxt ) ;
01238             exit( -2 ) ;
01239         }
01240 
01241      
01242     } /* end of reading basin lines */
01243     
01244     free ((char *)basins);
01245     fclose(basInFile);
01246 
01247     if (basnCnt != numBasn) { sprintf(msgStr, "Error - the %d basins read from basinIR does not match the %d basins in the basins map! Please fix the basinIR file.\n",
01248                                       basnCnt,numBasn); usrErr(msgStr); exit (-1); }
01249  
01250 /* count the number of cells in the Basins/Indicator-Regions */
01251     for (ibas=numBasn;ibas>=0;ibas--) numCells[ibas] = 0;
01252     for(ix=0; ix<=s0+1; ix++) 
01253         for(iy=0; iy<=s1+1; iy++)
01254             if (ON_MAP[cellLoc= T(ix,iy)]) { 
01255                 numCells[basn[cellLoc]]++; /* count the number of cells in each basin */
01256                 numCells[0]++; /* count the number of cells in each basin */
01257             }
01258         /* whole system (basin 0) is calc'd independently, while each of the hydro basins are
01259            sums of their respective Indicator Regions */
01260     for (ibas=numBasn;ibas>=0;ibas--) {
01261         basins =  basn_list[ibas];
01262         basins->family = ibas; /* set the basin to initially be it's own family; below it may find that it is a child of a diff family */
01263         basins->parent = ibas; /* set the basin to initially be a childless parent */
01264         for (ii=0; ii<basins->numIR; ii++) {
01265         
01266             basn_list[basins->IR[ii]]->family = ibas; /* the hydrologic basin family name of this IRegion */
01267             basn_list[basins->IR[ii]]->parent = 0; /* this IR is a child, not a parent */
01268             numCells[ibas] += numCells[basins->IR[ii]]; /* add the IRegion cells to the parent basin #cells */
01269         }
01270         basins->conv_m3TOcm = conv_mTOcm/(numCells[ibas]*CELL_SIZE);
01271         basins->conv_kgTOmgm2 = conv_kgTOmg/(numCells[ibas]*CELL_SIZE);
01272 
01273     }
01274 } /* end of BIRinit() */

void BIRoutfiles ( void   ) 

Open files and create headers for BIR output.

Definition at line 1282 of file BudgStats.c.

Referenced by init_static_data().

01283 {
01284     int Fnum,Fsets,ibasLow,ibasHigh,ibas;
01285 
01286 
01287     
01288 /********/
01289 /* For the budget & BIRavg files, we can have multiple sets of files, with
01290    >1 sets needed if a large (>12) number of Basins/Indicator-Regions are defined.  First,
01291    we open the files, then go to write headers for them */
01292 
01293     {/*Open the primary files for all of the budgets & BIRavgs */
01294     
01295 /* v2.8 hydro Perf Measure summaries - is a first cut, TODO is re-organize it */
01296         sprintf( modelFileName, "%s/%s/Output/Budget/BIRhydro", OutputPath, ProjName ); 
01297         if ( ( BIRhydro = fopen( modelFileName, "w" ) ) ==  NULL ) 
01298         {printf( "Can't open BIRhydro file! " );exit(-1) ;} 
01299 
01300 /* Indicator region avgs */
01301         sprintf( modelFileName, "%s/%s/Output/Budget/BIRavg1", OutputPath, ProjName ); 
01302         if ( ( BIRavg1 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01303         {printf( "Can't open BIRavg1 file! " );exit(-1) ;} 
01304 /* water budget/massCheck info - units in acre-feet */
01305         sprintf( modelFileName, "%s/%s/Output/Budget/budg_Wacr1", OutputPath, ProjName ); 
01306         if ( ( budget_Wacr1 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01307         {printf( "Can't open budg_Wacr1 file! " );exit(-1) ;} 
01308 /* water budget/massCheck info - units in cm height */
01309         sprintf( modelFileName, "%s/%s/Output/Budget/budg_Wcm1", OutputPath, ProjName ); 
01310         if ( ( budget_Wcm1 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01311         {printf( "Can't open budg_Wcm1 file! " );exit(-1) ;}
01312 /* Phosph budget/massCheck info for all P fractions (units=Mg) */
01313         sprintf( modelFileName, "%s/%s/Output/Budget/budg_P1", OutputPath, ProjName ); 
01314         if ( ( budget_P1 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01315         {printf( "Can't open budg_P1 file! " );exit(-1) ;} 
01316 /* Phosph budget/massCheck info for all P fractions (units=mg/m2) */
01317         sprintf( modelFileName, "%s/%s/Output/Budget/budg_Par1", OutputPath, ProjName ); 
01318         if ( ( budget_Par1 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01319         {printf( "Can't open budg_Par1 file! " );exit(-1) ;} 
01320 /* Salt budget/massCheck info */
01321         sprintf( modelFileName, "%s/%s/Output/Budget/budg_S1", OutputPath, ProjName ); 
01322         if ( ( budget_S1 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01323         {printf( "Can't open budg_S1 file! " );exit(-1) ;} 
01324         if (!ESPmodeON) {
01325 /* Phosph budget/massCheck info for live P fraction */
01326             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pliv1", OutputPath, ProjName ); 
01327             if ( ( budget_Plive1 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01328             {printf( "Can't open budg_Pliv1 file! " );exit(-1) ;}
01329 /* Phosph budget/massCheck info for dead P fraction */
01330             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pded1", OutputPath, ProjName ); 
01331             if ( ( budget_Pdead1 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01332             {printf( "Can't open budg_Pded1 file! " );exit(-1) ;} 
01333 /* Phosph budget/massCheck info for water-borne P fraction */
01334             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pwat1", OutputPath, ProjName ); 
01335             if ( ( budget_Pwat1 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01336             {printf( "Can't open budg_Pwat1 file! " );exit(-1) ;}
01337         }
01338 
01339 
01340         if (numBasn>=13) {
01341 /*Open the secondary files for all of the budgets & BIRavgs if we have more than 12 basins */
01342 /* Indicator region avgs */
01343             sprintf( modelFileName, "%s/%s/Output/Budget/BIRavg2", OutputPath, ProjName ); 
01344             if ( ( BIRavg2 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01345             { printf( "Can't open BIRavg2 file! " ); exit(-1) ;} 
01346 /* water budget/massCheck info - units in acre-feet */
01347             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Wacr2", OutputPath, ProjName ); 
01348             if ( ( budget_Wacr2 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01349             { printf( "Can't open budg_Wacr2 file! " ); exit(-1) ;} 
01350 /* water budget/massCheck info - units in cm height */
01351             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Wcm2", OutputPath, ProjName ); 
01352             if ( ( budget_Wcm2 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01353             {printf( "Can't open budg_Wcm2 file! " ); exit(-1) ;} 
01354 /* Phosph budget/massCheck info for all P fractions (units=Mg) */
01355             sprintf( modelFileName, "%s/%s/Output/Budget/budg_P2", OutputPath, ProjName ); 
01356             if ( ( budget_P2 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01357             {printf( "Can't open budg_P2 file! " );exit(-1) ;} 
01358 /* Phosph budget/massCheck info for all P fractions (units=mg/m2) */
01359             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Par2", OutputPath, ProjName ); 
01360             if ( ( budget_Par2 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01361             {printf( "Can't open budg_Par2 file! " );exit(-1) ;} 
01362 /* Salt budget/massCheck info */
01363             sprintf( modelFileName, "%s/%s/Output/Budget/budg_S2", OutputPath, ProjName ); 
01364             if ( ( budget_S2 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01365             {printf( "Can't open budg_S2 file! " );exit(-1) ;} 
01366 
01367             if (!ESPmodeON) {
01368 /* Phosph budget/massCheck info for live P fraction */
01369                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pliv2", OutputPath, ProjName ); 
01370                 if ( ( budget_Plive2 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01371                 {printf( "Can't open budg_Pliv2 file! " );exit(-1) ;}
01372 /* Phosph budget/massCheck info for dead P fraction */
01373                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pded2", OutputPath, ProjName ); 
01374                 if ( ( budget_Pdead2 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01375                 {printf( "Can't open budg_Pded2 file! " );exit(-1) ;} 
01376 /* Phosph budget/massCheck info for water-borne P fraction */
01377                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pwat2", OutputPath, ProjName ); 
01378                 if ( ( budget_Pwat2 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01379                 {printf( "Can't open budg_Pwat2 file! " );exit(-1) ;} 
01380             }/* end of !ESPmodeON */
01381     
01382         } /* end of opening secondary files */
01383 
01384         
01385         if (numBasn>=26) {
01386 /*Open the tertiary files for all of the budgets if we have more than 25 basins */
01387 /* Indicator region avgs */
01388             sprintf( modelFileName, "%s/%s/Output/Budget/BIRavg3", OutputPath, ProjName ); 
01389             if ( ( BIRavg3 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01390             { printf( "Can't open BIRavg3 file! " ); exit(-1) ;} 
01391 /* water budget/massCheck info - units in acre-feet */
01392             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Wacr3", OutputPath, ProjName ); 
01393             if ( ( budget_Wacr3 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01394             { printf( "Can't open budg_Wacr3 file! " ); exit(-1) ;} 
01395 /* water budget/massCheck info - units in cm height */
01396             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Wcm3", OutputPath, ProjName ); 
01397             if ( ( budget_Wcm3 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01398             {printf( "Can't open budg_Wcm3 file! " ); exit(-1) ;} 
01399 /* Phosph budget/massCheck info for all P fractions (units=Mg) */
01400             sprintf( modelFileName, "%s/%s/Output/Budget/budg_P3", OutputPath, ProjName ); 
01401             if ( ( budget_P3 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01402             {printf( "Can't open budg_P3 file! " );exit(-1) ;} 
01403 /* Phosph budget/massCheck info for all P fractions (units=mg/m2) */
01404             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Par3", OutputPath, ProjName ); 
01405             if ( ( budget_Par3 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01406             {printf( "Can't open budg_Par3 file! " );exit(-1) ;} 
01407 /* Salt budget/massCheck info */
01408             sprintf( modelFileName, "%s/%s/Output/Budget/budg_S3", OutputPath, ProjName ); 
01409             if ( ( budget_S3 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01410             {printf( "Can't open budg_S3 file! " );exit(-1) ;} 
01411 
01412             if (!ESPmodeON) {
01413 /* Phosph budget/massCheck info for live P fraction */
01414                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pliv3", OutputPath, ProjName ); 
01415                 if ( ( budget_Plive3 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01416                 {printf( "Can't open budg_Pliv3 file! " );exit(-1) ;}
01417 /* Phosph budget/massCheck info for dead P fraction */
01418                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pded3", OutputPath, ProjName ); 
01419                 if ( ( budget_Pdead3 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01420                 {printf( "Can't open budg_Pded3 file! " );exit(-1) ;} 
01421 /* Phosph budget/massCheck info for water-borne P fraction */
01422                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pwat3", OutputPath, ProjName ); 
01423                 if ( ( budget_Pwat3 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01424                 {printf( "Can't open budg_Pwat3 file! " );exit(-1) ;} 
01425             }/* end of !ESPmodeON */
01426     
01427         } /* end of opening tertiary files */
01428         
01429         if (numBasn>=39) {
01430 /*Open the fourth set of files for all of the budgets if we have more than 38 basins */
01431 /* Indicator region avgs */
01432             sprintf( modelFileName, "%s/%s/Output/Budget/BIRavg4", OutputPath, ProjName ); 
01433             if ( ( BIRavg4 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01434             { printf( "Can't open BIRavg4 file! " ); exit(-1) ;} 
01435 /* water budget/massCheck info - units in acre-feet */
01436             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Wacr4", OutputPath, ProjName ); 
01437             if ( ( budget_Wacr4 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01438             { printf( "Can't open budg_Wacr4 file! " ); exit(-1) ;} 
01439 /* water budget/massCheck info - units in cm height */
01440             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Wcm4", OutputPath, ProjName ); 
01441             if ( ( budget_Wcm4 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01442             {printf( "Can't open budg_Wcm4 file! " ); exit(-1) ;} 
01443 /* Phosph budget/massCheck info for all P fractions (units=Mg) */
01444             sprintf( modelFileName, "%s/%s/Output/Budget/budg_P4", OutputPath, ProjName ); 
01445             if ( ( budget_P4 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01446             {printf( "Can't open budg_P4 file! " );exit(-1) ;} 
01447 /* Phosph budget/massCheck info for all P fractions (units=mg/m2) */
01448             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Par4", OutputPath, ProjName ); 
01449             if ( ( budget_Par4 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01450             {printf( "Can't open budg_Par4 file! " );exit(-1) ;} 
01451 /* Salt budget/massCheck info */
01452             sprintf( modelFileName, "%s/%s/Output/Budget/budg_S4", OutputPath, ProjName ); 
01453             if ( ( budget_S4 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01454             {printf( "Can't open budg_S4 file! " );exit(-1) ;} 
01455 
01456             if (!ESPmodeON) {
01457 /* Phosph budget/massCheck info for live P fraction */
01458                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pliv4", OutputPath, ProjName ); 
01459                 if ( ( budget_Plive4 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01460                 {printf( "Can't open budg_Pliv4 file! " );exit(-1) ;}
01461 /* Phosph budget/massCheck info for dead P fraction */
01462                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pded4", OutputPath, ProjName ); 
01463                 if ( ( budget_Pdead4 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01464                 {printf( "Can't open budg_Pded4 file! " );exit(-1) ;} 
01465 /* Phosph budget/massCheck info for water-borne P fraction */
01466                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pwat4", OutputPath, ProjName ); 
01467                 if ( ( budget_Pwat4 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01468                 {printf( "Can't open budg_Pwat4 file! " );exit(-1) ;} 
01469             }/* end of !ESPmodeON */
01470     
01471         } /* end of opening fourth set of files */
01472         
01473         if (numBasn>=52) {
01474 /*Open the fifth set of files for all of the budgets if we have more than 51 basins */
01475 /* Indicator region avgs */
01476             sprintf( modelFileName, "%s/%s/Output/Budget/BIRavg5", OutputPath, ProjName ); 
01477             if ( ( BIRavg5 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01478             { printf( "Can't open BIRavg5 file! " ); exit(-1) ;} 
01479 /* water budget/massCheck info - units in acre-feet */
01480             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Wacr5", OutputPath, ProjName ); 
01481             if ( ( budget_Wacr5 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01482             { printf( "Can't open budg_Wacr5 file! " ); exit(-1) ;} 
01483 /* water budget/massCheck info - units in cm height */
01484             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Wcm5", OutputPath, ProjName ); 
01485             if ( ( budget_Wcm5 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01486             {printf( "Can't open budg_Wcm5 file! " ); exit(-1) ;} 
01487 /* Phosph budget/massCheck info for all P fractions (units=Mg) */
01488             sprintf( modelFileName, "%s/%s/Output/Budget/budg_P5", OutputPath, ProjName ); 
01489             if ( ( budget_P5 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01490             {printf( "Can't open budg_P5 file! " );exit(-1) ;} 
01491 /* Phosph budget/massCheck info for all P fractions (units=mg/m2) */
01492             sprintf( modelFileName, "%s/%s/Output/Budget/budg_Par5", OutputPath, ProjName ); 
01493             if ( ( budget_Par5 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01494             {printf( "Can't open budg_Par5 file! " );exit(-1) ;} 
01495 /* Salt budget/massCheck info */
01496             sprintf( modelFileName, "%s/%s/Output/Budget/budg_S5", OutputPath, ProjName ); 
01497             if ( ( budget_S5 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01498             {printf( "Can't open budg_S5 file! " );exit(-1) ;} 
01499 
01500             if (!ESPmodeON) {
01501 /* Phosph budget/massCheck info for live P fraction */
01502                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pliv5", OutputPath, ProjName ); 
01503                 if ( ( budget_Plive5 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01504                 {printf( "Can't open budg_Pliv5 file! " );exit(-1) ;}
01505 /* Phosph budget/massCheck info for dead P fraction */
01506                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pded5", OutputPath, ProjName ); 
01507                 if ( ( budget_Pdead5 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01508                 {printf( "Can't open budg_Pded5 file! " );exit(-1) ;} 
01509 /* Phosph budget/massCheck info for water-borne P fraction */
01510                 sprintf( modelFileName, "%s/%s/Output/Budget/budg_Pwat5", OutputPath, ProjName ); 
01511                 if ( ( budget_Pwat5 = fopen( modelFileName, "w" ) ) ==  NULL ) 
01512                 {printf( "Can't open budg_Pwat5 file! " );exit(-1) ;} 
01513             }/* end of !ESPmodeON */
01514     
01515         } /* end of opening fifth set of files */
01516         
01517     } /* end of opening all files */
01518 
01519 
01520 
01521 /********/
01522 /* Now we need to print the headers to each set(s) of basin files */
01523 /* First, figure out the number of files sets, and then loop thru that */
01524         /* there are 13 total basins printed per file (basin 0 is whole system,
01525            not counted in numBasn, but always printed out in first file) */
01526     if (numBasn>=52) { /* with more than 58 (plus whole-system basin == 59) basins: */
01527         Fsets=5;              /* we have five sets of basin files */
01528     }
01529     else if (numBasn>=39) { /* with more than 38 (plus whole-system basin == 39) basins: */
01530         Fsets=4;              /* we have four sets of basin files */
01531     }
01532     else if (numBasn>=26) { /* with more than 25 (plus whole-system basin == 26) basins: */
01533         Fsets=3;              /* we have three sets of basin files */
01534     }
01535     else if (numBasn>=13) { /* with more than 12 (plus whole-system basin == 13) basins: */
01536         Fsets=2;              /* we have two sets of basin files */
01537     }
01538     else {
01539         Fsets=1;       /* otherwise, just one set of files */
01540     }
01541 
01542     for (Fnum = 1; Fnum <= Fsets; Fnum++) { 
01543     
01544         if (Fnum == 1) { /* first file set */
01545             if (Fsets > 1) {
01546                 ibasLow = 0;        
01547                 ibasHigh = 12;
01548             }
01549             else {
01550                 ibasLow = 0;
01551                 ibasHigh = Min(12,numBasn);
01552             }
01553         }
01554 
01555         if (Fnum == 2) { /* second file set */
01556             if (Fsets > 2) {
01557                 ibasLow = 13;        
01558                 ibasHigh = 25;
01559             }
01560             else {
01561                 ibasLow = 13;
01562                 ibasHigh = Min(25,numBasn);
01563             }
01564         }
01565 
01566         if (Fnum == 3) { /* third file set */
01567             if (Fsets > 3) {
01568                 ibasLow = 26;        
01569                 ibasHigh = 38;
01570             }
01571             else {
01572                 ibasLow = 26;
01573                 ibasHigh = Min(38,numBasn);
01574             }
01575         }
01576         
01577         if (Fnum == 4) { /* fourth file set */
01578             if (Fsets > 4) {
01579                 ibasLow = 39;        
01580                 ibasHigh = 51;
01581             }
01582             else {
01583                 ibasLow = 39;
01584                 ibasHigh = Min(51,numBasn);
01585             }
01586         }
01587         
01588 
01589         else if (Fnum == 5) {
01590             ibasLow = 52;        
01591             ibasHigh = numBasn;
01592         }
01593 
01594 /*****/
01595 /* now print the 4 header lines for all of the budget & BIRavg files */
01596 
01597 /* LINE 1&2: first header line, providing scenario ID; second line is units, etc. */
01598 /* feb05 added two tabs at end of BIRavg header to accomodate sensitivity parm label & value */
01599         fprintf ( BIRhydro, 
01600                   "%s %s %s %s scenario: Basins/Indicator-Regions (BIR): daily mean attributes. \nUnits = Stage_minus_LandElev (StgMinElev) == m, Surface_Velocity (BIR_Sf_vel) = m/d, DayFire == days, CLsf_avg == CL conc. in sfwat, g/L.\n          \t ", &modelName, &modelVers, &SimAlt, &SimModif ); 
01601 
01602         fprintf ( ((Fnum==5)?(BIRavg5):
01603                    ((Fnum==4)?(BIRavg4):
01604                    ((Fnum==3)?(BIRavg3):
01605                     ((Fnum==2)?(BIRavg2):
01606                      (BIRavg1) ) ) ) ), 
01607                   "%s %s %s %s scenario: Basins/Indicator-Regions (BIR): daily mean attributes. \nUnits = Hydro depths== m, TP surface & pore water==mg/L, TP soil==mg/kg, noncalc&calc periph==gC/m2, mac==kgC/m2, LandElevation= m NGVD/NAVD+DATUM_DISTANCE(usually 6m).\n          \t\t\t ", &modelName, &modelVers, &SimAlt, &SimModif ); 
01608         fprintf ( ((Fnum==5)?(budget_Wacr5):
01609                    ((Fnum==4)?(budget_Wacr4):
01610                    ((Fnum==3)?(budget_Wacr3):
01611                     ((Fnum==2)?(budget_Wacr2):
01612                      (budget_Wacr1) ) ) ) ), 
01613                   "%s %s %s %s scenario: Basins/Indicator-Regions (BIR): water budget and mass balance check. \nUnits = thousands of acre-feet per basin, with error (and cumulative net error) reporting in mm height across basin.\n          \t ", &modelName, &modelVers, &SimAlt, &SimModif ); 
01614         fprintf ( ((Fnum==5)?(budget_Wcm5):
01615                    ((Fnum==4)?(budget_Wcm4):
01616                    ((Fnum==3)?(budget_Wcm3):
01617                     ((Fnum==2)?(budget_Wcm2):
01618                      (budget_Wcm1) ) ) ) ), 
01619                   "%s %s %s %s scenario: Basins/Indicator-Regions (BIR): water budget and mass balance check. \nUnits = cm per basin, with error (and cumulative net error) reporting in mm height across basin.\n          \t ", &modelName, &modelVers, &SimAlt, &SimModif ); 
01620         fprintf ( ((Fnum==5)?(budget_S5):
01621                    ((Fnum==4)?(budget_S4):
01622                    ((Fnum==3)?(budget_S3):
01623                     ((Fnum==2)?(budget_S2):
01624                      (budget_S1) ) ) ) ), 
01625                   "%s %s %s %s scenario: Basins/Indicator-Regions (BIR): conservative tracer budget and mass balance check. \nUnits = metric tons (Mg) per basin, with error (and cumulative net error) reporting in ug/m2 in basin.\n          \t ", &modelName, &modelVers, &SimAlt, &SimModif ); 
01626         fprintf ( ((Fnum==5)?(budget_P5):
01627                    ((Fnum==4)?(budget_P4):
01628                    ((Fnum==3)?(budget_P3):
01629                     ((Fnum==2)?(budget_P2):
01630                      (budget_P1) ) ) ) ), 
01631                   "%s %s %s %s scenario: Basins/Indicator-Regions (BIR): Total P budget and mass balance check for all fractions. \nUnits = metric tons (Mg) per basin, with error (and cumulative net error) reporting in ug/m2 in basin.\n          \t ", &modelName, &modelVers, &SimAlt, &SimModif ); 
01632         fprintf ( ((Fnum==5)?(budget_Par5):
01633                    ((Fnum==4)?(budget_Par4):
01634                    ((Fnum==3)?(budget_Par3):
01635                     ((Fnum==2)?(budget_Par2):
01636                      (budget_Par1) ) ) ) ), 
01637                   "%s %s %s %s scenario: Basins/Indicator-Regions (BIR): Total P budget and mass balance check for all fractions. \nUnits = mg/m2 in basin, with error (and cumulative net error) reporting in ug/m2 in basin.\n          \t ", &modelName, &modelVers, &SimAlt, &SimModif ); 
01638         if (!ESPmodeON) {
01639 
01640             fprintf ( ((Fnum==5)?(budget_Plive5):
01641                        ((Fnum==4)?(budget_Plive4):
01642                        ((Fnum==3)?(budget_Plive3):
01643                         ((Fnum==2)?(budget_Plive2):
01644                          (budget_Plive1) ) ) ) ), 
01645                       "%s %s %s %s scenario: Basins/Indicator-Regions (BIR): Total P budget and mass balance check for live fraction. \nUnits =  mg/m2 in basin, with error (and cumulative net error) ug/m2.\n          \t ", &modelName, &modelVers, &SimAlt, &SimModif ); 
01646             fprintf ( ((Fnum==5)?(budget_Pdead5):
01647                        ((Fnum==4)?(budget_Pdead4):
01648                        ((Fnum==3)?(budget_Pdead3):
01649                         ((Fnum==2)?(budget_Pdead2):
01650                          (budget_Pdead1) ) ) ) ), 
01651                       "%s %s %s %s scenario: Basins/Indicator-Regions (BIR): Total P budget and mass balance check for dead, non-water-borne fraction. \nUnits =  mg/m2 in basin, with error (and cumulative net error) ug/m2.\n          \t ", &modelName, &modelVers, &SimAlt, &SimModif ); 
01652             fprintf ( ((Fnum==5)?(budget_Pwat5):
01653                        ((Fnum==4)?(budget_Pwat4):
01654                        ((Fnum==3)?(budget_Pwat3):
01655                         ((Fnum==2)?(budget_Pwat2):
01656                          (budget_Pwat1) ) ) ) ), 
01657                       "%s %s %s %s scenario: Basins/Indicator-Regions (BIR): Total P budget and mass balance check for water-borne fraction (some horiz I/O not shown - see budget for all combined fractions). \nUnits =  mg/m2 in basin, with error (and cumulative net error) ug/m2.\n          \t ", &modelName, &modelVers, &SimAlt, &SimModif ); 
01658         }
01659 
01660 /* LINE 3: third header line, looping thru basins, providing basin ID and size */
01661         for (ibas = ibasHigh; ibas >= ibasLow; ibas--) 
01662         {
01663         /* v2.8 hydro Perf Measure summaries - is a first cut, TODO is re-organize it */
01664         fprintf ( BIRhydro, 
01665                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t",
01666                       ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) ); 
01667 
01668         fprintf ( ((Fnum==5)?(BIRavg5):
01669                   ((Fnum==4)?(BIRavg4):
01670                    ((Fnum==3)?(BIRavg3):
01671                     ((Fnum==2)?(BIRavg2):
01672                      (BIRavg1) ) ) ) ), 
01673                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t         \t         \t         \t         \t         \t",
01674                       ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) ); 
01675         fprintf ( ((Fnum==5)?(budget_Wacr5):
01676                    ((Fnum==4)?(budget_Wacr4):
01677                    ((Fnum==3)?(budget_Wacr3):
01678                     ((Fnum==2)?(budget_Wacr2):
01679                      (budget_Wacr1) ) ) ) ), 
01680                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t",
01681                       ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) ); 
01682         fprintf ( ((Fnum==5)?(budget_Wcm5):
01683                    ((Fnum==4)?(budget_Wcm4):
01684                    ((Fnum==3)?(budget_Wcm3):
01685                     ((Fnum==2)?(budget_Wcm2):
01686                      (budget_Wcm1) ) ) ) ), 
01687                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t",
01688                       ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) ); 
01689         fprintf ( ((Fnum==5)?(budget_S5):
01690                    ((Fnum==4)?(budget_S4):
01691                    ((Fnum==3)?(budget_S3):
01692                     ((Fnum==2)?(budget_S2):
01693                      (budget_S1) ) ) ) ), 
01694                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t",
01695                       ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) ); 
01696             if (!ESPmodeON) {
01697                 fprintf ( ((Fnum==5)?(budget_P5):
01698                           ((Fnum==4)?(budget_P4):
01699                            ((Fnum==3)?(budget_P3):
01700                             ((Fnum==2)?(budget_P2):
01701                              (budget_P1) ) ) ) ), 
01702                           "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t",
01703                           ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) );
01704                 fprintf ( ((Fnum==5)?(budget_Par5):
01705                            ((Fnum==4)?(budget_Par4):
01706                            ((Fnum==3)?(budget_Par3):
01707                             ((Fnum==2)?(budget_Par2):
01708                              (budget_Par1) ) ) ) ), 
01709                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t",
01710                           ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) );
01711                 fprintf ( ((Fnum==5)?(budget_Plive5):
01712                            ((Fnum==4)?(budget_Plive4):
01713                             ((Fnum==3)?(budget_Plive3):
01714                              ((Fnum==2)?(budget_Plive2):
01715                               (budget_Plive1) ) ) ) ), 
01716                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t",
01717                           ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) ); 
01718                 fprintf ( ((Fnum==5)?(budget_Pdead5):
01719                            ((Fnum==4)?(budget_Pdead4):
01720                             ((Fnum==3)?(budget_Pdead3):
01721                              ((Fnum==2)?(budget_Pdead2):
01722                               (budget_Pdead1) ) ) ) ), 
01723                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t          \t        \t         \t         \t         \t         \t         \t         \t         \t",
01724                           ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) ); 
01725                 fprintf ( ((Fnum==5)?(budget_Pwat5):
01726                            ((Fnum==4)?(budget_Pwat4):
01727                             ((Fnum==3)?(budget_Pwat3):
01728                              ((Fnum==2)?(budget_Pwat2):
01729                               (budget_Pwat1) ) ) ) ), 
01730                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t",
01731                           ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) ); 
01732             }
01733     
01734             else {
01735                 fprintf ( ((Fnum==5)?(budget_P5):
01736                            ((Fnum==4)?(budget_P4):
01737                            ((Fnum==3)?(budget_P3):
01738                             ((Fnum==2)?(budget_P2):
01739                              (budget_P1) ) ) ) ), 
01740                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t",
01741                           ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) );
01742                 fprintf ( ((Fnum==5)?(budget_Par5):
01743                            ((Fnum==4)?(budget_Par4):
01744                            ((Fnum==3)?(budget_Par3):
01745                             ((Fnum==2)?(budget_Par2):
01746                              (budget_Par1) ) ) ) ), 
01747                       "  BIR %2d =\t%6.1fmi^2,\t%6.1fkm^2\t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t         \t",
01748                           ibas,(numCells[ibas]*CELL_SIZE*3.8610039e-7),(numCells[ibas]*CELL_SIZE*1.0e-6) );
01749             }
01750         } /*end of loop for second header line */
01751 
01752 /* LINE 4: beginning of fourth header line */
01753 /* feb05 added two tabs prior to "Date" of BIRavg header to accomodate sensitivity parm label & value */
01754         fprintf ( BIRhydro, "\nDate\t" ); 
01755 
01756         fprintf ( ((Fnum==5)?(BIRavg5):
01757                    ((Fnum==4)?(BIRavg4):
01758                    ((Fnum==3)?(BIRavg3):
01759                     ((Fnum==2)?(BIRavg2):
01760                      (BIRavg1) ) ) ) ), "\nSParm\tSParmValu\t    Date\t" ); 
01761         fprintf ( ((Fnum==5)?(budget_Wacr5):
01762                    ((Fnum==4)?(budget_Wacr4):
01763                    ((Fnum==3)?(budget_Wacr3):
01764                     ((Fnum==2)?(budget_Wacr2):
01765                      (budget_Wacr1) ) ) ) ), "\n    Date\t" ); 
01766         fprintf ( ((Fnum==5)?(budget_Wcm5):
01767                    ((Fnum==4)?(budget_Wcm4):
01768                    ((Fnum==3)?(budget_Wcm3):
01769                     ((Fnum==2)?(budget_Wcm2):
01770                      (budget_Wcm1) ) ) ) ), "\n    Date\t" ); 
01771         fprintf ( ((Fnum==5)?(budget_S5):
01772                    ((Fnum==4)?(budget_S4):
01773                    ((Fnum==3)?(budget_S3):
01774                     ((Fnum==2)?(budget_S2):
01775                      (budget_S1) ) ) ) ), "\n    Date\t" ); 
01776         fprintf ( ((Fnum==5)?(budget_P5):
01777                    ((Fnum==4)?(budget_P4):
01778                    ((Fnum==3)?(budget_P3):
01779                     ((Fnum==2)?(budget_P2):
01780                      (budget_P1) ) ) ) ), "\n    Date\t" ); 
01781         fprintf ( ((Fnum==5)?(budget_Par5):
01782                    ((Fnum==4)?(budget_Par4):
01783                    ((Fnum==3)?(budget_Par3):
01784                     ((Fnum==2)?(budget_Par2):
01785                      (budget_Par1) ) ) ) ), "\n    Date\t" ); 
01786         if (!ESPmodeON) {
01787             fprintf ( ((Fnum==5)?(budget_Plive5):
01788                        ((Fnum==4)?(budget_Plive4):
01789                        ((Fnum==3)?(budget_Plive3):
01790                         ((Fnum==2)?(budget_Plive2):
01791                          (budget_Plive1) ) ) ) ), "\n    Date\t" ); 
01792             fprintf ( ((Fnum==5)?(budget_Pdead5):
01793                        ((Fnum==4)?(budget_Pdead4):
01794                        ((Fnum==3)?(budget_Pdead3):
01795                         ((Fnum==2)?(budget_Pdead2):
01796                          (budget_Pdead1) ) ) ) ), "\n    Date\t" ); 
01797             fprintf ( ((Fnum==5)?(budget_Pwat5):
01798                        ((Fnum==4)?(budget_Pwat4):
01799                        ((Fnum==3)?(budget_Pwat3):
01800                         ((Fnum==2)?(budget_Pwat2):
01801                          (budget_Pwat1) ) ) ) ), "\n    Date\t" ); 
01802         }
01803 
01804 /* LINE 4: remainder of fourth header line, looping thru basins, providing column/variable ID attributes */
01805         for (ibas = ibasHigh; ibas >= ibasLow; ibas--) 
01806         {
01807         
01808         fprintf ( BIRhydro, 
01809                       "   StgMinElev_%d\t   Veloc_%d\t    DayFire_%d\t    CLsf_avg_%d\t",
01810                       ibas,ibas,ibas,ibas); 
01811 
01812         fprintf ( ((Fnum==5)?(BIRavg5):
01813                   ((Fnum==4)?(BIRavg4):
01814                    ((Fnum==3)?(BIRavg3):
01815                     ((Fnum==2)?(BIRavg2):
01816                      (BIRavg1) ) ) ) ), 
01817                       "   SfWat_%d\t   Unsat_%d\t    TPsf_%d\t  TPpore_%d\t  TPsoil_%d\t  NCperi_%d\t   Cperi_%d\t     Mac_%d\t    Elev_%d\t",
01818                       ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas); 
01819         fprintf ( ((Fnum==5)?(budget_Wacr5):
01820                    ((Fnum==4)?(budget_Wacr4):
01821                    ((Fnum==3)?(budget_Wacr3):
01822                     ((Fnum==2)?(budget_Wacr2):
01823                      (budget_Wacr1) ) ) ) ), 
01824                       "  VolOld_%d\t    Atmos_%d\t    Evap_%d\t  Transp_%d\t    Rchg_%d\t   StrIn_%d\t  StrOut_%d\t   OvlIn_%d\t  OvlOut_%d\t   SpgIn_%d\t  SpgOut_%d\t    GWin_%d\t   GWout_%d\t VolTarg_%d\t  VolNew_%d\t     Err_%d\t  SumErr_%d\t   InAvg_%d\t  OutAvg_%d\t",
01825                       ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas); 
01826         fprintf ( ((Fnum==5)?(budget_Wcm5):
01827                    ((Fnum==4)?(budget_Wcm4):
01828                    ((Fnum==3)?(budget_Wcm3):
01829                     ((Fnum==2)?(budget_Wcm2):
01830                      (budget_Wcm1) ) ) ) ), 
01831                       "  VolOld_%d\t    Atmos_%d\t    Evap_%d\t  Transp_%d\t    Rchg_%d\t   StrIn_%d\t  StrOut_%d\t   OvlIn_%d\t  OvlOut_%d\t   SpgIn_%d\t  SpgOut_%d\t    GWin_%d\t   GWout_%d\t VolTarg_%d\t  VolNew_%d\t     Err_%d\t  SumErr_%d\t   InAvg_%d\t  OutAvg_%d\t",
01832                       ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas); 
01833         fprintf ( ((Fnum==5)?(budget_S5):
01834                    ((Fnum==4)?(budget_S4):
01835                    ((Fnum==3)?(budget_S3):
01836                     ((Fnum==2)?(budget_S2):
01837                      (budget_S1) ) ) ) ), 
01838                       "  MasOld_%d\t    Atmos_%d\t   StrIn_%d\t  StrOut_%d\t   OvlIn_%d\t  OvlOut_%d\t   SpgIn_%d\t  SpgOut_%d\t    GWin_%d\t   GWout_%d\t MasTarg_%d\t  MasNew_%d\t     Err_%d\t  SumErr_%d\t   InAvg_%d\t  OutAvg_%d\t",
01839                       ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas); 
01840             if (!ESPmodeON) {
01841                 fprintf ( ((Fnum==5)?(budget_P5):
01842                           ((Fnum==4)?(budget_P4):
01843                            ((Fnum==3)?(budget_P3):
01844                             ((Fnum==2)?(budget_P2):
01845                              (budget_P1) ) ) ) ), 
01846                       "  MasOld_%d\t    Atmos_%d\t   StrIn_%d\t  StrOut_%d\t   OvlIn_%d\t  OvlOut_%d\t   SpgIn_%d\t  SpgOut_%d\t    GWin_%d\t   GWout_%d\t MasTarg_%d\t  MasNew_%d\t     Err_%d\t  SumErr_%d\t   InAvg_%d\t  OutAvg_%d\t",
01847                           ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas);
01848                 fprintf ( ((Fnum==5)?(budget_Par5):
01849                            ((Fnum==4)?(budget_Par4):
01850                            ((Fnum==3)?(budget_Par3):
01851                             ((Fnum==2)?(budget_Par2):
01852                              (budget_Par1) ) ) ) ), 
01853                       "  MasOld_%d\t    Atmos_%d\t   StrIn_%d\t  StrOut_%d\t   OvlIn_%d\t  OvlOut_%d\t   SpgIn_%d\t  SpgOut_%d\t    GWin_%d\t   GWout_%d\t MasTarg_%d\t  MasNew_%d\t     Err_%d\t  SumErr_%d\t   InAvg_%d\t  OutAvg_%d\t",
01854                           ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas);
01855                 fprintf ( ((Fnum==5)?(budget_Plive5):
01856                            ((Fnum==4)?(budget_Plive4):
01857                             ((Fnum==3)?(budget_Plive3):
01858                              ((Fnum==2)?(budget_Plive2):
01859                               (budget_Plive1) ) ) ) ), 
01860                       "  MacBio_%d\t CPerBio_%d\t NCPerBio_%d\t  MacNPP_%d\t CPerGPP_%d\tNCPerGPP_%d\t MacMort_%d\t CalgMort_%d\t NCalgMort_%d\t MasTarg_%d\t  MasNew_%d\t     Err_%d\t  SumErr_%d\t   InAvg_%d\t  OutAvg_%d\t",
01861                           ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas); 
01862                 fprintf ( ((Fnum==5)?(budget_Pdead5):
01863                            ((Fnum==4)?(budget_Pdead4):
01864                             ((Fnum==3)?(budget_Pdead3):
01865                              ((Fnum==2)?(budget_Pdead2):
01866                               (budget_Pdead1) ) ) ) ), 
01867                       "  MasOld_%d\tMac-soil_%d\tPer-soil_%d\t Decomp_%d\tSettl_to_%d\t Sorb_to_%d\t  Desorb_%d\t MasTarg_%d\t  MasNew_%d\t     Err_%d\t  SumErr_%d\t   InAvg_%d\t  OutAvg_%d\t",
01868                           ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas); 
01869                 fprintf ( ((Fnum==5)?(budget_Pwat5):
01870                            ((Fnum==4)?(budget_Pwat4):
01871                             ((Fnum==3)?(budget_Pwat3):
01872                              ((Fnum==2)?(budget_Pwat2):
01873                               (budget_Pwat1) ) ) ) ), 
01874                       "  MasOld_%d\t  Atmos_%d\tSettl_fr_%d\t SfMiner_%d\tSedMiner_%d\t  AlgUpt_%d\t  MacUpt_%d\t  DeSorb_%d\t Sorb_to_%d\t   StrIn_%d\t  StrOut_%d\t MasTarg_%d\t  MasNew_%d\t     Err_%d\t  SumErr_%d\t   InAvg_%d\t  OutAvg_%d\t",
01875                           ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas); 
01876             }
01877             else {
01878                 fprintf ( ((Fnum==5)?(budget_P5):
01879                            ((Fnum==4)?(budget_P4):
01880                            ((Fnum==3)?(budget_P3):
01881                             ((Fnum==2)?(budget_P2):
01882                              (budget_P1) ) ) ) ), 
01883                       "  MasOld_%d\t    Atmos_%d\t   Settl_%d\t   StrIn_%d\t  StrOut_%d\t   OvlIn_%d\t  OvlOut_%d\t   SpgIn_%d\t  SpgOut_%d\t    GWin_%d\t   GWout_%d\t MasTarg_%d\t  MasNew_%d\t     Err_%d\t  SumErr_%d\t   InAvg_%d\t  OutAvg_%d\t",
01884                           ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas);
01885                 fprintf ( ((Fnum==5)?(budget_Par5):
01886                            ((Fnum==4)?(budget_Par4):
01887                            ((Fnum==3)?(budget_Par3):
01888                             ((Fnum==2)?(budget_Par2):
01889                              (budget_Par1) ) ) ) ), 
01890                       "  MasOld_%d\t    Atmos_%d\t   Settl_%d\t   StrIn_%d\t  StrOut_%d\t   OvlIn_%d\t  OvlOut_%d\t   SpgIn_%d\t  SpgOut_%d\t    GWin_%d\t   GWout_%d\t MasTarg_%d\t  MasNew_%d\t     Err_%d\t  SumErr_%d\t   InAvg_%d\t  OutAvg_%d\t",
01891                           ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas,ibas);
01892             }
01893         } /* end of loop for third header line */
01894 
01895     } /*end of printing all files' headers */
01896 
01897         
01898 } /* end of BIRoutfiles */

void CellAvg ( void   ) 

Generate sums, means (avgs), on cell-by-cell basis (not by Basin/IRegion here).

Definition at line 1905 of file BudgStats.c.

References ALG_LIGHT_CF, ALG_TOT, avg_Intvl, avgPrint, BCmodel_sfwat, BCmodel_sfwatAvg, C_ALG, C_ALG_MORT, C_ALG_NPP, C_ALG_NUT_CF, C_ALG_PCrep, C_ALG_RESP, C_Peri_mortAvg, C_Peri_nppAvg, C_Peri_PCAvg, C_PeriAvg, C_PeriNutCFAvg, C_PeriRespAvg, DAYJUL, DT, ETAvg, EvapAvg, Floc_fr_phBio, Floc_fr_phBioAvg, FMOD(), HYD_ET, HYD_MANNINGS_N, HYD_TRANSP, HydPerAnn, HydRelDepPosNeg, HydRelDepPosNegAvg, HydTotHd, LAI_eff, LAI_effAvg, MAC_NOPH_BIOMAS, mac_nph_PC_rep, mac_nph_PCAvg, Mac_nphBioAvg, Mac_nphMortAvg, Mac_nppAvg, MAC_NUT_CF, MAC_PH_BIOMAS, mac_ph_PC_rep, mac_ph_PCAvg, Mac_phBioAvg, Mac_phMortAvg, MAC_TOT_BIOM, Mac_totBioAvg, MAC_WATER_CF, MacNutCfAvg, MacWatCfAvg, Manning_nAvg, NC_ALG, NC_ALG_MORT, NC_ALG_NPP, NC_ALG_NUT_CF, NC_ALG_PCrep, NC_ALG_RESP, NC_Peri_mortAvg, NC_Peri_nppAvg, NC_Peri_PCAvg, NC_PeriAvg, NC_PeriNutCFAvg, NC_PeriRespAvg, NPHBIO_MORT, ON_MAP, PeriAvg, PeriLiteCFAvg, PHBIO_MORT, PHBIO_NPP, RainAvg, s0, s1, SAL_SED_WT, SAL_SF_WT, SaltSedAvg, SaltSfAvg, SED_ELEV, SedElevAvg, SF_WT_EVAP, SF_WT_FROM_RAIN, SF_WT_VEL_mag, SF_WT_VEL_magAvg, SfWatAvg, SURFACE_WAT, T, TotHeadAvg, TP_SED_MINER, TP_SEDWT_CONCACTMG, TP_SEDWT_UPTAKE, TP_settl, TP_settlAvg, TP_SFWT_CONC_MG, TP_SFWT_MINER, TP_SFWT_UPTAK, TP_SORBCONC_rep, TPSedMinAvg, TPSedUptAvg, TPSedWatAvg, TPSfMinAvg, TPSfUptAvg, TPSfWatAvg, TPSorbAvg, TPtoSOIL_rep, TPtoSOILAvg, TPtoVOL_rep, TPtoVOLAvg, TranspAvg, UNSAT_DEPTH, UNSAT_MOIST_PRP, UnsatMoistAvg, and UnsatZavg.

Referenced by stats().

01906 {
01907     int ix, iy, cellLoc;
01908     float avgStep = avg_Intvl / DT;
01909     
01910 /* sums and average (& hydroperiod) calcs, not budget related */
01911     for(ix=1; ix<=s0; ix++) {
01912         for(iy=1; iy<=s1; iy++) {
01913 
01914             if(ON_MAP[cellLoc= T(ix,iy)])  {
01915                     /* annual hydroperiod on Oct 1 = JulDay ~273 (TODO: use true date fctn) */
01916                 if ( FMOD(DAYJUL, 273.0) ) {
01917                     if (SURFACE_WAT[cellLoc] > 0.01 )  HydPerAnn[cellLoc] +=  DT; 
01918                 }
01919                 else {
01920                     HydPerAnn[cellLoc] += DT; /* TODO: (?) remove this line */
01921                 }
01922                     
01923                     SfWatAvg[cellLoc] += SURFACE_WAT[cellLoc]; 
01924                     TotHeadAvg[cellLoc] += HydTotHd[cellLoc]; 
01925                     HydRelDepPosNegAvg[cellLoc] += HydRelDepPosNeg[cellLoc]; 
01926                     UnsatZavg[cellLoc] += UNSAT_DEPTH[cellLoc]; 
01927                     UnsatMoistAvg[cellLoc] += UNSAT_MOIST_PRP[cellLoc]; 
01928                     RainAvg[cellLoc]  += SF_WT_FROM_RAIN[cellLoc];
01929                     EvapAvg[cellLoc]  += SF_WT_EVAP[cellLoc];
01930                     TranspAvg[cellLoc]  += HYD_TRANSP[cellLoc];
01931                     ETAvg[cellLoc]  += HYD_ET[cellLoc];
01932                     SF_WT_VEL_magAvg[cellLoc]  += SF_WT_VEL_mag[cellLoc];
01933                     BCmodel_sfwatAvg[cellLoc]  += BCmodel_sfwat[cellLoc];
01934 
01935                     TPSfWatAvg[cellLoc] += TP_SFWT_CONC_MG[cellLoc]; 
01936                     TPSedWatAvg[cellLoc] += TP_SEDWT_CONCACTMG[cellLoc]; 
01937                     TPSfUptAvg[cellLoc] += TP_SFWT_UPTAK[cellLoc]; 
01938                     TPSfMinAvg[cellLoc] += TP_SFWT_MINER[cellLoc]; 
01939                     TP_settlAvg[cellLoc] += TP_settl[cellLoc]; 
01940                     TPSedUptAvg[cellLoc] += TP_SEDWT_UPTAKE[cellLoc]; 
01941                     TPSedMinAvg[cellLoc] += TP_SED_MINER[cellLoc];
01942                     TPSorbAvg[cellLoc] += TP_SORBCONC_rep[cellLoc];
01943                     TPtoVOLAvg[cellLoc] +=  TPtoVOL_rep[cellLoc];
01944                     TPtoSOILAvg[cellLoc] +=  TPtoSOIL_rep[cellLoc];
01945                     SaltSfAvg[cellLoc] += SAL_SF_WT[cellLoc];
01946                     SaltSedAvg[cellLoc] += SAL_SED_WT[cellLoc];
01947 
01948                     Floc_fr_phBioAvg[cellLoc]  += Floc_fr_phBio[cellLoc];
01949                     
01950                     NC_PeriAvg[cellLoc] += NC_ALG[cellLoc];
01951                     NC_Peri_nppAvg[cellLoc]  += NC_ALG_NPP[cellLoc];
01952                     NC_Peri_mortAvg[cellLoc]  += NC_ALG_MORT[cellLoc];
01953                     NC_PeriRespAvg[cellLoc]  += NC_ALG_RESP[cellLoc];
01954                     NC_PeriNutCFAvg[cellLoc]  += NC_ALG_NUT_CF[cellLoc];
01955                     NC_Peri_PCAvg[cellLoc]  += NC_ALG_PCrep[cellLoc];
01956                     C_PeriAvg[cellLoc] += C_ALG[cellLoc]; 
01957                     C_Peri_nppAvg[cellLoc]  += C_ALG_NPP[cellLoc];
01958                     C_Peri_mortAvg[cellLoc]  += C_ALG_MORT[cellLoc];
01959                     C_PeriRespAvg[cellLoc]  += C_ALG_RESP[cellLoc];
01960                     C_PeriNutCFAvg[cellLoc]  += C_ALG_NUT_CF[cellLoc];
01961                     C_Peri_PCAvg[cellLoc]  += C_ALG_PCrep[cellLoc];
01962                     PeriLiteCFAvg[cellLoc]  += ALG_LIGHT_CF[cellLoc];
01963                     PeriAvg[cellLoc]  += ALG_TOT[cellLoc];
01964 
01965                     Mac_nphBioAvg[cellLoc]  += MAC_NOPH_BIOMAS[cellLoc];
01966                     Mac_phBioAvg[cellLoc]  += MAC_PH_BIOMAS[cellLoc];
01967                     Mac_nppAvg[cellLoc]  += PHBIO_NPP[cellLoc];
01968                     Mac_nphMortAvg[cellLoc]  += NPHBIO_MORT[cellLoc];
01969                     Mac_phMortAvg[cellLoc]  += PHBIO_MORT[cellLoc];
01970                     LAI_effAvg[cellLoc]  += LAI_eff[cellLoc];
01971                     Manning_nAvg[cellLoc]  += HYD_MANNINGS_N[cellLoc];
01972                     MacNutCfAvg[cellLoc]  += MAC_NUT_CF[cellLoc];
01973                     MacWatCfAvg[cellLoc]  += MAC_WATER_CF[cellLoc];
01974                     mac_nph_PCAvg[cellLoc]  += mac_nph_PC_rep[cellLoc];
01975                     mac_ph_PCAvg[cellLoc]  += mac_ph_PC_rep[cellLoc];
01976                     Mac_totBioAvg[cellLoc]  += MAC_TOT_BIOM[cellLoc];
01977 
01978                     SedElevAvg[cellLoc]  += SED_ELEV[cellLoc];
01979               
01980                 if (avgPrint ) /* get the mean value */
01981                         { 
01982                             SfWatAvg[cellLoc] /= avgStep;
01983                             TotHeadAvg[cellLoc] /= avgStep;
01984                             HydRelDepPosNegAvg[cellLoc] /= avgStep;
01985                             UnsatZavg[cellLoc] /= avgStep;
01986                             UnsatMoistAvg[cellLoc] /= avgStep;
01987                             RainAvg[cellLoc]  /= avgStep ;
01988                             EvapAvg[cellLoc]  /= avgStep ;
01989                             TranspAvg[cellLoc] /= avgStep ;
01990                             ETAvg[cellLoc]  /= avgStep;
01991                             SF_WT_VEL_magAvg[cellLoc]  /= avgStep;
01992                             BCmodel_sfwatAvg[cellLoc]  /= avgStep;
01993 
01994                             TPSfWatAvg[cellLoc] /= avgStep;
01995                             TPSedWatAvg[cellLoc] /= avgStep;
01996                             TPSfUptAvg[cellLoc] /= avgStep;
01997                             TPSfMinAvg[cellLoc] /= avgStep;
01998                             TP_settlAvg[cellLoc] /= avgStep;
01999                             TPSedUptAvg[cellLoc] /= avgStep;
02000                             TPSedMinAvg[cellLoc] /= avgStep;
02001                             TPSorbAvg[cellLoc] /= avgStep; 
02002                             TPtoVOLAvg[cellLoc] /= avgStep;  
02003                             TPtoSOILAvg[cellLoc] /= avgStep; 
02004                             SaltSfAvg[cellLoc] /= avgStep;
02005                             SaltSedAvg[cellLoc] /= avgStep;
02006 
02007                             Floc_fr_phBioAvg[cellLoc] /= avgStep ;
02008 
02009                             NC_PeriAvg[cellLoc] /= avgStep;
02010                             NC_Peri_nppAvg[cellLoc] /= avgStep;
02011                             NC_Peri_mortAvg[cellLoc] /= avgStep;
02012                             NC_PeriRespAvg[cellLoc] /= avgStep;
02013                             NC_PeriNutCFAvg[cellLoc] /= avgStep;
02014                             NC_Peri_PCAvg[cellLoc] /= avgStep;
02015                             C_PeriAvg[cellLoc] /= avgStep;
02016                             C_Peri_nppAvg[cellLoc] /= avgStep;
02017                             C_Peri_mortAvg[cellLoc] /= avgStep;
02018                             C_PeriRespAvg[cellLoc] /= avgStep;
02019                             C_PeriNutCFAvg[cellLoc] /= avgStep;
02020                             C_Peri_PCAvg[cellLoc] /= avgStep;
02021                             PeriLiteCFAvg[cellLoc] /= avgStep;
02022                             PeriAvg[cellLoc] /= avgStep;
02023                         
02024                             Mac_nphBioAvg[cellLoc]  /= avgStep ;
02025                             Mac_phBioAvg[cellLoc]  /= avgStep ;
02026                             Mac_nppAvg[cellLoc]  /= avgStep ;
02027                             Mac_nphMortAvg[cellLoc]  /= avgStep ;
02028                             Mac_phMortAvg[cellLoc]  /= avgStep ;
02029                             LAI_effAvg[cellLoc]  /= avgStep ;
02030                             Manning_nAvg[cellLoc]  /= avgStep ;
02031                             MacNutCfAvg[cellLoc]  /= avgStep ;
02032                             MacWatCfAvg[cellLoc]  /= avgStep ;
02033                             mac_nph_PCAvg[cellLoc]  /= avgStep ;
02034                             mac_ph_PCAvg[cellLoc]  /= avgStep ;
02035                             Mac_totBioAvg[cellLoc]  /= avgStep;
02036 
02037                             SedElevAvg[cellLoc]  /= avgStep ;
02038                         }
02039             }
02040         }
02041     } /* end spatial loop for averages */
02042 } /*end of CellAvg() */

Here is the call graph for this function:

void Cell_reset_avg ( void   ) 

Zero the arrays holding selected variable averages in cells (after printing)/.

Definition at line 2065 of file BudgStats.c.

Referenced by gen_output(), and reinitBIR().

02066 {
02067     int ix, iy, cellLoc; 
02068 
02069     for(ix=1; ix<=s0; ix++) 
02070         for(iy=1; iy<=s1; iy++) 
02071             if(ON_MAP[cellLoc= T(ix,iy)]) {
02072                 TotHeadAvg[cellLoc] = 0.0;
02073                 HydRelDepPosNegAvg[cellLoc] = 0.0;
02074                 SfWatAvg[cellLoc] = 0.0;
02075                 UnsatZavg[cellLoc] = 0.0;
02076                 UnsatMoistAvg[cellLoc] = 0.0;
02077                 RainAvg[cellLoc] = 0.0;
02078                 EvapAvg[cellLoc] = 0.0;
02079                 TranspAvg[cellLoc] = 0.0;
02080                 ETAvg[cellLoc] = 0.0;
02081                 SF_WT_VEL_magAvg[cellLoc] = 0.0;
02082                 BCmodel_sfwatAvg[cellLoc] = 0.0;
02083 
02084                 TPSfWatAvg[cellLoc] = 0.0;
02085                 TPSfUptAvg[cellLoc] = 0.0;
02086                 TPSfMinAvg[cellLoc] = 0.0;
02087                 TP_settlAvg[cellLoc] = 0.0;
02088                 TPSedWatAvg[cellLoc] = 0.0;
02089                 TPSedUptAvg[cellLoc] = 0.0;
02090                 TPSedMinAvg[cellLoc] = 0.0;
02091                 TPSorbAvg[cellLoc] = 0.0;
02092                 TPtoVOLAvg[cellLoc] = 0.0;
02093                 TPtoSOILAvg[cellLoc] = 0.0;
02094 
02095                 SaltSfAvg[cellLoc] = 0.0;
02096                 SaltSedAvg[cellLoc] = 0.0;
02097 
02098                 Floc_fr_phBioAvg[cellLoc]  = 0.0;
02099 
02100                 NC_PeriAvg[cellLoc] = 0.0;
02101                 NC_Peri_nppAvg[cellLoc] = 0.0;
02102                 NC_Peri_mortAvg[cellLoc] = 0.0;
02103                 NC_PeriRespAvg[cellLoc] = 0.0;
02104                 NC_PeriNutCFAvg[cellLoc] = 0.0;
02105                 C_Peri_PCAvg[cellLoc] = 0.0;
02106                 C_PeriAvg[cellLoc] = 0.0;
02107                 C_Peri_nppAvg[cellLoc] = 0.0;
02108                 C_Peri_mortAvg[cellLoc] = 0.0;
02109                 C_PeriRespAvg[cellLoc] = 0.0;
02110                 C_PeriNutCFAvg[cellLoc] = 0.0;
02111                 C_Peri_PCAvg[cellLoc] = 0.0;
02112                 PeriAvg[cellLoc] = 0.0;
02113                 PeriLiteCFAvg[cellLoc] = 0.0;
02114 
02115                 Mac_nphBioAvg[cellLoc]  = 0.0;
02116                 Mac_phBioAvg[cellLoc]  = 0.0;
02117                 Mac_totBioAvg[cellLoc]  = 0.0;
02118                 Mac_nppAvg[cellLoc]  = 0.0;
02119                 Mac_nphMortAvg[cellLoc]  = 0.0;
02120                 Mac_phMortAvg[cellLoc]  = 0.0;
02121                 LAI_effAvg[cellLoc]  = 0.0;
02122                 Manning_nAvg[cellLoc]  = 0.0;
02123                 MacNutCfAvg[cellLoc]  = 0.0;
02124                 MacWatCfAvg[cellLoc]  = 0.0;
02125                 mac_nph_PCAvg[cellLoc]  = 0.0;
02126                 mac_ph_PCAvg[cellLoc]  = 0.0;
02127 
02128                 SedElevAvg[cellLoc]  = 0.0;
02129             }   
02130 } /* end of Cell_reset_avg() */

void Cell_reset_hydper ( void   ) 

Zero the array holding hydroperiod data in cells (after printing).

Definition at line 2050 of file BudgStats.c.

Referenced by gen_output(), and reinitBIR().

02051 {
02052     int ix, iy, cellLoc; 
02053 
02054         for(ix=1; ix<=s0; ix++) 
02055             for(iy=1; iy<=s1; iy++) 
02056                 if(ON_MAP[cellLoc= T(ix,iy)]) {
02057                     HydPerAnn[cellLoc] = 0.0;
02058                 }
02059 } 

void alloc_mem_stats ( void   ) 

Allocate memory for the BIR-based and cell-based stats variables.

Definition at line 2137 of file BudgStats.c.

Referenced by init_static_data().

02138 {
02139     int ix,iy,cellLoc, numBasnMax=0;
02140 
02141 
02142     for(ix=0; ix<=s0+1; ix++) 
02143         for(iy=0; iy<=s1+1; iy++)
02144             if (ON_MAP[cellLoc= T(ix,iy)]) { 
02145                 if (basn[cellLoc] > numBasnMax) numBasnMax = basn[cellLoc]; 
02146             }
02147     numBasn = numBasnMax; /* total number of basins in domain */
02148     
02149     sprintf (msgStr," %d Basins/Indicator-Regions...",numBasn); usrErr0(msgStr);
02150     
02151 /* basin budget arrays (number of actual basins plus basin 0, which is whole system) */
02152     numCells = (int *) nalloc (sizeof(int)*(numBasn+1),"numCells"); /* number of cells in a basin */
02153 
02154 /* Indicator region averages (non-budget) */
02155         /* v2.8 hydro Perf Measure summaries - is a first cut, TODO is re-organize it */
02156         StgMinElev = (double *) nalloc(sizeof(double)*(numBasn+1),"StgMinElev");
02157         init_pvar(StgMinElev,NULL,'b',0.0);
02158         BIR_Sf_vel = (double *) nalloc(sizeof(double)*(numBasn+1),"BIR_Sf_vel");
02159         init_pvar(BIR_Sf_vel,NULL,'b',0.0);
02160         BIR_DayFire = (double *) nalloc(sizeof(double)*(numBasn+1),"BIR_DayFire");
02161         init_pvar(BIR_DayFire,NULL,'b',0.0);
02162         DayFire = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"DayFire");
02163         init_pvar(DayFire,NULL,'f',0.0);
02164         CLsf_avg = (double *) nalloc(sizeof(double)*(numBasn+1),"CLsf_avg");
02165         init_pvar(CLsf_avg,NULL,'b',0.0);
02166 /* end of v2.8 hydro Perf Measure summaries - is a first cut, TODO is re-organize it */
02167 
02168         Sfwat_avg = (double *) nalloc(sizeof(double)*(numBasn+1),"Sfwat_avg");
02169         init_pvar(Sfwat_avg,NULL,'b',0.0);
02170         Unsat_avg = (double *) nalloc(sizeof(double)*(numBasn+1),"Unsat_avg");
02171         init_pvar(Unsat_avg,NULL,'b',0.0);
02172         TPsf_avg = (double *) nalloc(sizeof(double)*(numBasn+1),"TPsf_avg");
02173         init_pvar(TPsf_avg,NULL,'b',0.0);
02174         TPpore_avg = (double *) nalloc(sizeof(double)*(numBasn+1),"TPpore_avg");
02175         init_pvar(TPpore_avg,NULL,'b',0.0);
02176         TPsoil_avg = (double *) nalloc(sizeof(double)*(numBasn+1),"TPsoil_avg");
02177         init_pvar(TPsoil_avg,NULL,'b',0.0);
02178         NCperi_avg = (double *) nalloc(sizeof(double)*(numBasn+1),"NCperi_avg");
02179         init_pvar(NCperi_avg,NULL,'b',0.0);
02180         Cperi_avg = (double *) nalloc(sizeof(double)*(numBasn+1),"Cperi_avg");
02181         init_pvar(Cperi_avg,NULL,'b',0.0);
02182         Mac_avg = (double *) nalloc(sizeof(double)*(numBasn+1),"Mac_avg");
02183         init_pvar(Mac_avg,NULL,'b',0.0);
02184         Elev_avg = (double *) nalloc(sizeof(double)*(numBasn+1),"Elev_avg");
02185         init_pvar(Elev_avg,NULL,'b',0.0);
02186 /* hydro mass bal vars */
02187         SUMSF = (double *) nalloc(sizeof(double)*(numBasn+1),"SUMSF");
02188         init_pvar(SUMSF,NULL,'b',0.0);
02189         SUMGW = (double *) nalloc(sizeof(double)*(numBasn+1),"SUMGW");
02190         init_pvar(SUMGW,NULL,'b',0.0);
02191         SUMUW = (double *) nalloc(sizeof(double)*(numBasn+1),"SUMUW");
02192         init_pvar(SUMUW,NULL,'b',0.0);
02193         RAIN = (double *) nalloc(sizeof(double)*(numBasn+1),"RAIN");
02194         init_pvar(RAIN,NULL,'b',0.0);
02195         EVAP = (double *) nalloc(sizeof(double)*(numBasn+1),"EVAP");
02196         init_pvar(EVAP,NULL,'b',0.0);
02197         TRANSP = (double *) nalloc(sizeof(double)*(numBasn+1),"TRANSP");
02198         init_pvar(TRANSP,NULL,'b',0.0);
02199         RCHG = (double *) nalloc(sizeof(double)*(numBasn+1),"RCHG");
02200         init_pvar(RCHG,NULL,'b',0.0);
02201 
02202         TOT_VOL = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_VOL");
02203         init_pvar(TOT_VOL,NULL,'b',0.0);
02204         TOT_VOL_OLD = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_VOL_OLD");
02205         init_pvar(TOT_VOL_OLD,NULL,'b',0.0);
02206         VOL_IN = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_IN");
02207         init_pvar(VOL_IN,NULL,'b',0.0);
02208         VOL_OUT = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_OUT");
02209         init_pvar(VOL_OUT,NULL,'b',0.0);
02210         TOT_VOL_ERR = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_VOL_ERR");
02211         init_pvar(TOT_VOL_ERR,NULL,'b',0.0);
02212         TOT_VOL_CUM_ERR = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_VOL_CUM_ERR");
02213         init_pvar(TOT_VOL_CUM_ERR,NULL,'b',0.0);
02214         TOT_VOL_AVG_ERR = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_VOL_AVG_ERR");
02215         init_pvar(TOT_VOL_AVG_ERR,NULL,'b',0.0);
02216         VOL_ERR_PER_INFL = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_ERR_PER_INFL");
02217         init_pvar(VOL_ERR_PER_INFL,NULL,'b',0.0);
02218 
02219         VOL_IN_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_IN_SUM");
02220         init_pvar(VOL_IN_SUM,NULL,'b',0.0);
02221         VOL_OUT_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_OUT_SUM");
02222         init_pvar(VOL_OUT_SUM,NULL,'b',0.0);
02223         VOL_IN_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_IN_AVG");
02224         init_pvar(VOL_IN_AVG,NULL,'b',0.0);
02225         VOL_OUT_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_OUT_AVG");
02226         init_pvar(VOL_OUT_AVG,NULL,'b',0.0);
02227 
02228         TOT_VOL_CAN = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_VOL_CAN");
02229         init_pvar(TOT_VOL_CAN,NULL,'b',0.0);
02230 
02231         VOL_IN_STR = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_IN_STR");
02232         init_pvar(VOL_IN_STR,NULL,'b',0.0);
02233         VOL_IN_OVL = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_IN_OVL");
02234         init_pvar(VOL_IN_OVL,NULL,'b',0.0);
02235         VOL_IN_SPG = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_IN_SPG");
02236         init_pvar(VOL_IN_SPG,NULL,'b',0.0);
02237         VOL_IN_GW = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_IN_GW");
02238         init_pvar(VOL_IN_GW,NULL,'b',0.0);
02239 
02240         VOL_OUT_STR = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_OUT_STR");
02241         init_pvar(VOL_OUT_STR,NULL,'b',0.0);
02242         VOL_OUT_OVL = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_OUT_OVL");
02243         init_pvar(VOL_OUT_OVL,NULL,'b',0.0);
02244         VOL_OUT_SPG = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_OUT_SPG");
02245         init_pvar(VOL_OUT_SPG,NULL,'b',0.0);
02246         VOL_OUT_GW = (double *) nalloc(sizeof(double)*(numBasn+1),"VOL_OUT_GW");
02247         init_pvar(VOL_OUT_GW,NULL,'b',0.0);
02248 
02249 /* phosph mass bal vars for all storage fractions */
02250         P_CELL = (double *) nalloc(sizeof(double)*(numBasn+1),"P_CELL");
02251         init_pvar(P_CELL,NULL,'b',0.0);
02252         P_ATMOS = (double *) nalloc(sizeof(double)*(numBasn+1),"P_ATMOS");
02253         init_pvar(P_ATMOS,NULL,'b',0.0);
02254 
02255         P = (double *) nalloc(sizeof(double)*(numBasn+1),"P");
02256         init_pvar(P,NULL,'b',0.0);
02257         P_OLD = (double *) nalloc(sizeof(double)*(numBasn+1),"P_OLD");
02258         init_pvar(P_OLD,NULL,'b',0.0);
02259         P_IN = (double *) nalloc(sizeof(double)*(numBasn+1),"P_IN");
02260         init_pvar(P_IN,NULL,'b',0.0);
02261         P_OUT = (double *) nalloc(sizeof(double)*(numBasn+1),"P_OUT");
02262         init_pvar(P_OUT,NULL,'b',0.0);
02263         P_ERR = (double *) nalloc(sizeof(double)*(numBasn+1),"P_ERR");
02264         init_pvar(P_ERR,NULL,'b',0.0);
02265         P_ERR_CUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_ERR_CUM");
02266         init_pvar(P_ERR_CUM,NULL,'b',0.0);
02267 
02268         P_IN_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_IN_SUM");
02269         init_pvar(P_IN_SUM,NULL,'b',0.0);
02270         P_OUT_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_OUT_SUM");
02271         init_pvar(P_OUT_SUM,NULL,'b',0.0);
02272         P_IN_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"P_IN_AVG");
02273         init_pvar(P_IN_AVG,NULL,'b',0.0);
02274         P_OUT_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"P_OUT_AVG");
02275         init_pvar(P_OUT_AVG,NULL,'b',0.0);
02276 
02277         TOT_P_CAN = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_P_CAN");
02278         init_pvar(TOT_P_CAN,NULL,'b',0.0);
02279 
02280         P_IN_STR = (double *) nalloc(sizeof(double)*(numBasn+1),"P_IN_STR");
02281         init_pvar(P_IN_STR,NULL,'b',0.0);
02282         P_IN_OVL = (double *) nalloc(sizeof(double)*(numBasn+1),"P_IN_OVL");
02283         init_pvar(P_IN_OVL,NULL,'b',0.0);
02284         P_IN_SPG = (double *) nalloc(sizeof(double)*(numBasn+1),"P_IN_SPG");
02285         init_pvar(P_IN_SPG,NULL,'b',0.0);
02286         P_IN_GW = (double *) nalloc(sizeof(double)*(numBasn+1),"P_IN_GW");
02287         init_pvar(P_IN_GW,NULL,'b',0.0);
02288 
02289         P_OUT_STR = (double *) nalloc(sizeof(double)*(numBasn+1),"P_OUT_STR");
02290         init_pvar(P_OUT_STR,NULL,'b',0.0);
02291         P_OUT_OVL = (double *) nalloc(sizeof(double)*(numBasn+1),"P_OUT_OVL");
02292         init_pvar(P_OUT_OVL,NULL,'b',0.0);
02293         P_OUT_SPG = (double *) nalloc(sizeof(double)*(numBasn+1),"P_OUT_SPG");
02294         init_pvar(P_OUT_SPG,NULL,'b',0.0);
02295         P_OUT_GW = (double *) nalloc(sizeof(double)*(numBasn+1),"P_OUT_GW");
02296         init_pvar(P_OUT_GW,NULL,'b',0.0);
02297 
02298 /* phosph mass bal vars for live fraction */
02299         P_LIVE_CELL = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE_CELL");
02300         init_pvar(P_LIVE_CELL,NULL,'b',0.0);
02301         P_MAC = (double *) nalloc(sizeof(double)*(numBasn+1),"P_MAC");
02302         init_pvar(P_MAC,NULL,'b',0.0);
02303         P_Calg = (double *) nalloc(sizeof(double)*(numBasn+1),"P_Calg");
02304         init_pvar(P_Calg,NULL,'b',0.0);
02305         P_NCalg = (double *) nalloc(sizeof(double)*(numBasn+1),"P_NCalg");
02306         init_pvar(P_NCalg,NULL,'b',0.0);
02307         Calg_GPP = (double *) nalloc(sizeof(double)*(numBasn+1),"Calg_GPP");
02308         init_pvar(Calg_GPP,NULL,'b',0.0);
02309         NCalg_GPP = (double *) nalloc(sizeof(double)*(numBasn+1),"NCalg_GPP");
02310         init_pvar(NCalg_GPP,NULL,'b',0.0);
02311         Calg_mort = (double *) nalloc(sizeof(double)*(numBasn+1),"Calg_mort");
02312         init_pvar(Calg_mort,NULL,'b',0.0);
02313         NCalg_mort = (double *) nalloc(sizeof(double)*(numBasn+1),"NCalg_mort");
02314         init_pvar(NCalg_mort,NULL,'b',0.0);
02315 
02316         mac_NPP = (double *) nalloc(sizeof(double)*(numBasn+1),"mac_NPP");
02317         init_pvar(mac_NPP,NULL,'b',0.0);
02318         mac_mort = (double *) nalloc(sizeof(double)*(numBasn+1),"mac_mort");
02319         init_pvar(mac_mort,NULL,'b',0.0);
02320 
02321         P_LIVE = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE");
02322         init_pvar(P_LIVE,NULL,'b',0.0);
02323 
02324         P_LIVE_OLD = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE_OLD");
02325         init_pvar(P_LIVE_OLD,NULL,'b',0.0);
02326         P_LIVE_IN = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE_IN");
02327         init_pvar(P_LIVE_IN,NULL,'b',0.0);
02328         P_LIVE_OUT = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE_OUT");
02329         init_pvar(P_LIVE_OUT,NULL,'b',0.0);
02330         P_LIVE_ERR = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE_ERR");
02331         init_pvar(P_LIVE_ERR,NULL,'b',0.0);
02332         P_LIVE_ERR_CUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE_ERR_CUM");
02333         init_pvar(P_LIVE_ERR_CUM,NULL,'b',0.0);
02334 
02335         P_LIVE_IN_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE_IN_SUM");
02336         init_pvar(P_LIVE_IN_SUM,NULL,'b',0.0);
02337         P_LIVE_OUT_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE_OUT_SUM");
02338         init_pvar(P_LIVE_OUT_SUM,NULL,'b',0.0);
02339         P_LIVE_IN_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE_IN_AVG");
02340         init_pvar(P_LIVE_IN_AVG,NULL,'b',0.0);
02341         P_LIVE_OUT_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"P_LIVE_OUT_AVG");
02342         init_pvar(P_LIVE_OUT_AVG,NULL,'b',0.0);
02343 
02344 /* phosph mass bal vars for dead fraction */
02345         P_DEAD_CELL = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD_CELL");
02346         init_pvar(P_DEAD_CELL,NULL,'b',0.0);
02347         dop_macIn = (double *) nalloc(sizeof(double)*(numBasn+1),"dop_macIn");
02348         init_pvar(dop_macIn,NULL,'b',0.0);
02349         dop_sorbIn = (double *) nalloc(sizeof(double)*(numBasn+1),"dop_sorbIn");
02350         init_pvar(dop_sorbIn,NULL,'b',0.0);
02351         dop_decomp = (double *) nalloc(sizeof(double)*(numBasn+1),"dop_decomp");
02352         init_pvar(dop_decomp,NULL,'b',0.0);
02353         dop_desorb = (double *) nalloc(sizeof(double)*(numBasn+1),"dop_desorb");
02354         init_pvar(dop_desorb,NULL,'b',0.0);
02355         floc_decomp = (double *) nalloc(sizeof(double)*(numBasn+1),"floc_decomp");
02356         init_pvar(floc_decomp,NULL,'b',0.0);
02357         floc_In = (double *) nalloc(sizeof(double)*(numBasn+1),"floc_In");
02358         init_pvar(floc_In,NULL,'b',0.0);
02359 
02360         P_DEAD = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD");
02361         init_pvar(P_DEAD,NULL,'b',0.0);
02362 
02363         P_DEAD_OLD = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD_OLD");
02364         init_pvar(P_DEAD_OLD,NULL,'b',0.0);
02365         P_DEAD_IN = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD_IN");
02366         init_pvar(P_DEAD_IN,NULL,'b',0.0);
02367         P_DEAD_OUT = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD_OUT");
02368         init_pvar(P_DEAD_OUT,NULL,'b',0.0);
02369         P_DEAD_ERR = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD_ERR");
02370         init_pvar(P_DEAD_ERR,NULL,'b',0.0);
02371         P_DEAD_ERR_CUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD_ERR_CUM");
02372         init_pvar(P_DEAD_ERR_CUM,NULL,'b',0.0);
02373 
02374         P_DEAD_IN_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD_IN_SUM");
02375         init_pvar(P_DEAD_IN_SUM,NULL,'b',0.0);
02376         P_DEAD_OUT_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD_OUT_SUM");
02377         init_pvar(P_DEAD_OUT_SUM,NULL,'b',0.0);
02378         P_DEAD_IN_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD_IN_AVG");
02379         init_pvar(P_DEAD_IN_AVG,NULL,'b',0.0);
02380         P_DEAD_OUT_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"P_DEAD_OUT_AVG");
02381         init_pvar(P_DEAD_OUT_AVG,NULL,'b',0.0);
02382 
02383 /* phosph mass bal vars for water-borne fraction */
02384         P_WAT_CELL = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT_CELL");
02385         init_pvar(P_WAT_CELL,NULL,'b',0.0);
02386         wat_sfMiner = (double *) nalloc(sizeof(double)*(numBasn+1),"wat_sfMiner");
02387         init_pvar(wat_sfMiner,NULL,'b',0.0);
02388         wat_sedMiner = (double *) nalloc(sizeof(double)*(numBasn+1),"wat_sedMiner");
02389         init_pvar(wat_sedMiner,NULL,'b',0.0);
02390         wat_sfUpt = (double *) nalloc(sizeof(double)*(numBasn+1),"wat_sfUpt");
02391         init_pvar(wat_sfUpt,NULL,'b',0.0);
02392         P_settl = (double *) nalloc(sizeof(double)*(numBasn+1),"P_settl");
02393         init_pvar(P_settl,NULL,'b',0.0);
02394         wat_sedUpt = (double *) nalloc(sizeof(double)*(numBasn+1),"wat_sedUpt");
02395         init_pvar(wat_sedUpt,NULL,'b',0.0);
02396 
02397         P_WAT = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT");
02398         init_pvar(P_WAT,NULL,'b',0.0);
02399 
02400         P_WAT_OLD = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT_OLD");
02401         init_pvar(P_WAT_OLD,NULL,'b',0.0);
02402         P_WAT_IN = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT_IN");
02403         init_pvar(P_WAT_IN,NULL,'b',0.0);
02404         P_WAT_OUT = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT_OUT");
02405         init_pvar(P_WAT_OUT,NULL,'b',0.0);
02406         P_WAT_ERR = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT_ERR");
02407         init_pvar(P_WAT_ERR,NULL,'b',0.0);
02408         P_WAT_ERR_CUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT_ERR_CUM");
02409         init_pvar(P_WAT_ERR_CUM,NULL,'b',0.0);
02410 
02411         P_WAT_IN_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT_IN_SUM");
02412         init_pvar(P_WAT_IN_SUM,NULL,'b',0.0);
02413         P_WAT_OUT_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT_OUT_SUM");
02414         init_pvar(P_WAT_OUT_SUM,NULL,'b',0.0);
02415         P_WAT_IN_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT_IN_AVG");
02416         init_pvar(P_WAT_IN_AVG,NULL,'b',0.0);
02417         P_WAT_OUT_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"P_WAT_OUT_AVG");
02418         init_pvar(P_WAT_OUT_AVG,NULL,'b',0.0);
02419 
02420 /* salt mass bal vars */
02421         TOT_S_CELL = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_S_CELL");
02422         init_pvar(TOT_S_CELL,NULL,'b',0.0);
02423         SALT_ATMOS = (double *) nalloc(sizeof(double)*(numBasn+1),"SALT_ATMOS");
02424         init_pvar(SALT_ATMOS,NULL,'b',0.0);
02425 
02426         TOT_S = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_S");
02427         init_pvar(TOT_S,NULL,'b',0.0);
02428         TOT_S_OLD = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_S_OLD");
02429         init_pvar(TOT_S_OLD,NULL,'b',0.0);
02430         S_IN = (double *) nalloc(sizeof(double)*(numBasn+1),"S_IN");
02431         init_pvar(S_IN,NULL,'b',0.0);
02432         S_OUT = (double *) nalloc(sizeof(double)*(numBasn+1),"S_OUT");
02433         init_pvar(S_OUT,NULL,'b',0.0);
02434         TOT_S_ERR = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_S_ERR");
02435         init_pvar(TOT_S_ERR,NULL,'b',0.0);
02436         S_ERR_CUM = (double *) nalloc(sizeof(double)*(numBasn+1),"S_ERR_CUM");
02437         init_pvar(S_ERR_CUM,NULL,'b',0.0);
02438 
02439         S_IN_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"S_IN_SUM");
02440         init_pvar(S_IN_SUM,NULL,'b',0.0);
02441         S_OUT_SUM = (double *) nalloc(sizeof(double)*(numBasn+1),"S_OUT_SUM");
02442         init_pvar(S_OUT_SUM,NULL,'b',0.0);
02443         S_IN_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"S_IN_AVG");
02444         init_pvar(S_IN_AVG,NULL,'b',0.0);
02445         S_OUT_AVG = (double *) nalloc(sizeof(double)*(numBasn+1),"S_OUT_AVG");
02446         init_pvar(S_OUT_AVG,NULL,'b',0.0);
02447 
02448         TOT_S_CAN = (double *) nalloc(sizeof(double)*(numBasn+1),"TOT_S_CAN");
02449         init_pvar(TOT_S_CAN,NULL,'b',0.0);
02450 
02451         S_IN_STR = (double *) nalloc(sizeof(double)*(numBasn+1),"S_IN_STR");
02452         init_pvar(S_IN_STR,NULL,'b',0.0);
02453         S_IN_OVL = (double *) nalloc(sizeof(double)*(numBasn+1),"S_IN_OVL");
02454         init_pvar(S_IN_OVL,NULL,'b',0.0);
02455         S_IN_SPG = (double *) nalloc(sizeof(double)*(numBasn+1),"S_IN_SPG");
02456         init_pvar(S_IN_SPG,NULL,'b',0.0);
02457         S_IN_GW = (double *) nalloc(sizeof(double)*(numBasn+1),"S_IN_GW");
02458         init_pvar(S_IN_GW,NULL,'b',0.0);
02459 
02460         S_OUT_STR = (double *) nalloc(sizeof(double)*(numBasn+1),"S_OUT_STR");
02461         init_pvar(S_OUT_STR,NULL,'b',0.0);
02462         S_OUT_OVL = (double *) nalloc(sizeof(double)*(numBasn+1),"S_OUT_OVL");
02463         init_pvar(S_OUT_OVL,NULL,'b',0.0);
02464         S_OUT_SPG = (double *) nalloc(sizeof(double)*(numBasn+1),"S_OUT_SPG");
02465         init_pvar(S_OUT_SPG,NULL,'b',0.0);
02466         S_OUT_GW = (double *) nalloc(sizeof(double)*(numBasn+1),"S_OUT_GW");
02467         init_pvar(S_OUT_GW,NULL,'b',0.0);
02468 
02469 /* map arrays with summary stats */
02470         HydPerAnn = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"HydPerAnn");
02471         init_pvar(HydPerAnn,NULL,'f',0.0);
02472         SfWatAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"SfWatAvg");
02473         init_pvar(SfWatAvg,NULL,'f',0.0);
02474         TotHeadAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TotHeadAvg");
02475         init_pvar(TotHeadAvg,NULL,'f',0.0);
02476         HydRelDepPosNegAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"HydRelDepPosNegAvg");
02477         init_pvar(HydRelDepPosNegAvg,NULL,'f',0.0);
02478         UnsatZavg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"UnsatZavg");
02479         init_pvar(UnsatZavg,NULL,'f',0.0);
02480 
02481         RainAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"RainAvg");
02482         init_pvar(RainAvg,NULL,'f',0.0);
02483         ETAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"ETAvg"); 
02484         init_pvar(ETAvg,NULL,'f',0.0);
02485         EvapAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"EvapAvg");
02486         init_pvar(EvapAvg,NULL,'f',0.0);
02487         TranspAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TranspAvg");
02488         init_pvar(TranspAvg,NULL,'f',0.0);
02489         UnsatMoistAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"UnsatMoistAvg");
02490         init_pvar(UnsatMoistAvg,NULL,'f',0.0);
02491         /* v2.7.0 addition */
02492         SF_WT_VEL_magAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"SF_WT_VEL_magAvg");
02493         init_pvar(SF_WT_VEL_magAvg,NULL,'f',0.0);
02494         /* v2.7.1 addition */
02495         BCmodel_sfwatAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"BCmodel_sfwatAvg");
02496         init_pvar(BCmodel_sfwatAvg,NULL,'f',0.0);
02497 
02498         TPSfWatAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TPSfWatAvg");
02499         init_pvar(TPSfWatAvg,NULL,'f',0.0);
02500         TPSfUptAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TPSfUptAvg");
02501         init_pvar(TPSfUptAvg,NULL,'f',0.0);
02502         TPSfMinAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TPSfMinAvg");
02503         init_pvar(TPSfMinAvg,NULL,'f',0.0);
02504         TP_settlAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TP_settlAvg");
02505         init_pvar(TP_settlAvg,NULL,'f',0.0);
02506         TPSedWatAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TPSedWatAvg");
02507         init_pvar(TPSedWatAvg,NULL,'f',0.0);
02508         TPSedUptAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TPSedUptAvg");
02509         init_pvar(TPSedUptAvg,NULL,'f',0.0);
02510         TPSedMinAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TPSedMinAvg");
02511         init_pvar(TPSedMinAvg,NULL,'f',0.0);
02512         TPSorbAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TPSorbAvg");
02513         init_pvar(TPSorbAvg,NULL,'f',0.0);
02514         TPtoVOLAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TPtoVOLAvg");
02515         init_pvar(TPtoVOLAvg,NULL,'f',0.0);
02516         TPtoSOILAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"TPtoSOILAvg");
02517         init_pvar(TPtoSOILAvg,NULL,'f',0.0);
02518 
02519         SaltSfAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"SaltSfAvg");
02520         init_pvar(SaltSfAvg,NULL,'f',0.0);
02521         SaltSedAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"SaltSedAvg");
02522         init_pvar(SaltSedAvg,NULL,'f',0.0);
02523 
02524         Floc_fr_phBioAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"Floc_fr_phBioAvg");
02525         init_pvar(Floc_fr_phBioAvg,NULL,'f',0.0);
02526 
02527         NC_PeriAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"NC_PeriAvg");
02528         init_pvar(NC_PeriAvg,NULL,'f',0.0);
02529         NC_Peri_nppAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"NC_Peri_nppAvg");
02530         init_pvar(NC_Peri_nppAvg,NULL,'f',0.0);
02531         NC_Peri_mortAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"NC_Peri_mortAvg");
02532         init_pvar(NC_Peri_mortAvg,NULL,'f',0.0);
02533         NC_PeriRespAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"NC_PeriRespAvg");
02534         init_pvar(NC_PeriRespAvg,NULL,'f',0.0);
02535         NC_PeriNutCFAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"NC_PeriNutCFAvg");
02536         init_pvar(NC_PeriNutCFAvg,NULL,'f',0.0);
02537         NC_Peri_PCAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"NC_Peri_PCAvg");
02538         init_pvar(NC_Peri_PCAvg,NULL,'f',0.0);
02539         C_PeriAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"C_PeriAvg");
02540         init_pvar(C_PeriAvg,NULL,'f',0.0);
02541         C_Peri_nppAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"C_Peri_nppAvg");
02542         init_pvar(C_Peri_nppAvg,NULL,'f',0.0);
02543         C_Peri_mortAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"C_Peri_mortAvg");
02544         init_pvar(C_Peri_mortAvg,NULL,'f',0.0);
02545         C_PeriRespAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"C_PeriRespAvg");
02546         init_pvar(C_PeriRespAvg,NULL,'f',0.0);
02547         C_PeriNutCFAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"C_PeriNutCFAvg");
02548         init_pvar(C_PeriNutCFAvg,NULL,'f',0.0);
02549         C_Peri_PCAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"C_Peri_PCAvg");
02550         init_pvar(C_Peri_PCAvg,NULL,'f',0.0);
02551         PeriAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"PeriAvg");
02552         init_pvar(PeriAvg,NULL,'f',0.0);
02553         PeriLiteCFAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"PeriLiteCFAvg");
02554         init_pvar(PeriLiteCFAvg,NULL,'f',0.0);
02555 
02556         Mac_nphBioAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"Mac_nphBioAvg");
02557         init_pvar(Mac_nphBioAvg,NULL,'f',0.0);
02558         Mac_phBioAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"Mac_phBioAvg");
02559         init_pvar(Mac_phBioAvg,NULL,'f',0.0);
02560         Mac_totBioAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"Mac_totBioAvg");
02561         init_pvar(Mac_totBioAvg,NULL,'f',0.0);
02562         Mac_nppAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"Mac_nppAvg");
02563         init_pvar(Mac_nppAvg,NULL,'f',0.0);
02564         Mac_nphMortAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"Mac_nphMortAvg");
02565         init_pvar(Mac_nphMortAvg,NULL,'f',0.0);
02566         Mac_phMortAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"Mac_phMortAvg");
02567         init_pvar(Mac_phMortAvg,NULL,'f',0.0);
02568         LAI_effAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"LAI_effAvg");
02569         init_pvar(LAI_effAvg,NULL,'f',0.0);
02570         Manning_nAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"Manning_nAvg");
02571         init_pvar(Manning_nAvg,NULL,'f',0.0);
02572         MacNutCfAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"MacNutCfAvg");
02573         init_pvar(MacNutCfAvg,NULL,'f',0.0);
02574         MacWatCfAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"MacWatCfAvg");
02575         init_pvar(MacWatCfAvg,NULL,'f',0.0);
02576         mac_nph_PCAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"mac_nph_PCAvg");
02577         init_pvar(mac_nph_PCAvg,NULL,'f',0.0);
02578         mac_ph_PCAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"mac_ph_PCAvg");
02579         init_pvar(mac_ph_PCAvg,NULL,'f',0.0);
02580 
02581         SedElevAvg = (float *) nalloc(sizeof(float)*(s0+2)*(s1+2),"SedElevAvg");
02582         init_pvar(SedElevAvg,NULL,'f',0.0);
02583 
02584 } /* end of alloc_mem_stats */

char* Scip ( char *  s,
char  SYM 
)

Skip ahead in a string until next field.

Parameters:
s A character array
SYM The specific symbol being used to skip over
Returns:
Location in string

Definition at line 1788 of file Driver_Utilities.c.

01789 {
01790   if(*s == SYM ) return ++s;
01791   while(*s != SYM && *s != EOS ) s++;
01792   if(*s != EOS) return ++s;
01793   else  return s;
01794 }

void init_pvar ( VOIDP  Map,
UCHAR mask,
unsigned char  Mtype,
float  iv 
)

Initialize a variable to a value.

Parameters:
Map array of data
mask data mask
Mtype the data type of the map data
iv the value used to initialize variable

Definition at line 1008 of file Driver_Utilities.c.

01009 {
01010   int i0, i1;
01011   
01012   switch(Mtype) {
01013   case 'b' :    /* added double for (non-map) basin (b) array budget calcs */
01014     for(i0=0; i0<=numBasn; i0++) {
01015         ((double*)Map)[i0] = iv;
01016       }
01017     break;
01018   case 'l' :    /* added double (l == letter "ell" ) for map arrays */
01019     for(i0=0; i0<=s0+1; i0++) 
01020       for(i1=0; i1<=s1+1; i1++) {
01021         if(mask==NULL) ((double*)Map)[T(i0,i1)] = iv;
01022         else if ( mask[T(i0,i1)] == 0 ) ((double*)Map)[T(i0,i1)] = 0;
01023         else ((double*)Map)[T(i0,i1)] = iv;
01024       }
01025     break;
01026   case 'f' :    
01027     for(i0=0; i0<=s0+1; i0++) 
01028       for(i1=0; i1<=s1+1; i1++) {
01029         if(mask==NULL) ((float*)Map)[T(i0,i1)] = iv;
01030         else if ( mask[T(i0,i1)] == 0 ) ((float*)Map)[T(i0,i1)] = 0;
01031         else ((float*)Map)[T(i0,i1)] = iv;
01032       }
01033     break;
01034   case 'i' :    case 'd' :      
01035     for(i0=0; i0<=s0+1; i0++) 
01036       for(i1=0; i1<=s1+1; i1++) {
01037         if(mask==NULL) ((int*)Map)[T(i0,i1)] = (int)iv;
01038         else if ( mask[T(i0,i1)] == 0 ) ((int*)Map)[T(i0,i1)] = 0;
01039         else ((int*)Map)[T(i0,i1)] = (int)iv;
01040       }
01041     break;
01042   case 'c' :    
01043     for(i0=0; i0<=s0+1; i0++) 
01044       for(i1=0; i1<=s1+1; i1++) {
01045         if(mask==NULL) ((unsigned char*)Map)[T(i0,i1)] = (unsigned char) '\0' + (int) iv;
01046         else if ( mask[T(i0,i1)] == 0 ) ((unsigned char*)Map)[T(i0,i1)] = '\0';
01047         else ((unsigned char*)Map)[T(i0,i1)] = (unsigned char) '\0' + (int) iv;
01048       } 
01049     break;
01050  
01051    default :
01052     printf(" in default case\n");
01053    break;
01054   }
01055 }

VOIDP nalloc ( unsigned  mem_size,
const char  var_name[] 
)

Allocate memory for a variable.

Parameters:
mem_size The size of memory space
var_name The variable's name
Returns:
Pointer to that memory

Definition at line 1857 of file Driver_Utilities.c.

01858 {
01859   VOIDP rp;
01860 
01861   
01862   if(mem_size == 0) return(NULL);
01863   rp = (VOIDP)malloc( mem_size );
01864   total_memory += mem_size;
01865   fasync(stderr);
01866   if( rp == NULL ) {
01867     fprintf(stderr,"Sorry, out of memory(%d): %s\n",mem_size,var_name);
01868     Exit(0);
01869   }
01870   fmulti(stderr);
01871   return(rp);
01872 }

float FMOD ( float  x,
float  y 
)

Modulus of a pair of (double) arguments.

Parameters:
x Numerator
y Denominator
Returns:
modulus (float) result

Definition at line 1675 of file Driver_Utilities.c.

01675                              { 
01676 return (float)fmod((double)x, (double)y); 
01677 } 


Variable Documentation

FILE* basInFile

Definition at line 17 of file budgstats.h.

Referenced by BIRinit().

FILE* budget_Wacr1

Definition at line 18 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Wacr2

Definition at line 18 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Wacr3

Definition at line 18 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Wacr4

Definition at line 18 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Wacr5

Definition at line 18 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE* budget_Wcm1

Definition at line 19 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Wcm2

Definition at line 19 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Wcm3

Definition at line 19 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Wcm4

Definition at line 19 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Wcm5

Definition at line 19 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE* budget_P1

Definition at line 20 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_P2

Definition at line 20 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_P3

Definition at line 20 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_P4

Definition at line 20 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_P5

Definition at line 20 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE* budget_Par1

Definition at line 21 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Par2

Definition at line 21 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Par3

Definition at line 21 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Par4

Definition at line 21 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Par5

Definition at line 21 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

Definition at line 22 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Plive2

Definition at line 22 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Plive3

Definition at line 22 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Plive4

Definition at line 22 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Plive5

Definition at line 22 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

Definition at line 23 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Pdead2

Definition at line 23 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Pdead3

Definition at line 23 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Pdead4

Definition at line 23 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Pdead5

Definition at line 23 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE* budget_Pwat1

Definition at line 24 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Pwat2

Definition at line 24 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Pwat3

Definition at line 24 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Pwat4

Definition at line 24 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_Pwat5

Definition at line 24 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE* budget_S1

Definition at line 25 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_S2

Definition at line 25 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_S3

Definition at line 25 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_S4

Definition at line 25 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE * budget_S5

Definition at line 25 of file budgstats.h.

Referenced by BIRbudg_date(), BIRbudg_print(), BIRbudg_reset(), and BIRoutfiles().

FILE* BIRavg1

Definition at line 26 of file budgstats.h.

Referenced by BIRoutfiles(), BIRstats_date(), BIRstats_print(), and BIRstats_reset().

FILE * BIRavg2

Definition at line 26 of file budgstats.h.

Referenced by BIRoutfiles(), BIRstats_date(), BIRstats_print(), and BIRstats_reset().

FILE * BIRavg3

Definition at line 26 of file budgstats.h.

Referenced by BIRoutfiles(), BIRstats_date(), BIRstats_print(), and BIRstats_reset().

FILE * BIRavg4

Definition at line 26 of file budgstats.h.

Referenced by BIRoutfiles(), BIRstats_date(), BIRstats_print(), and BIRstats_reset().

FILE * BIRavg5

Definition at line 26 of file budgstats.h.

Referenced by BIRoutfiles(), BIRstats_date(), BIRstats_print(), and BIRstats_reset().

FILE* BIRhydro

int numBasn

char modelFileName[300]

generic string for input/output file name

Definition at line 35 of file budgstats.h.

float DAYJUL

A "julian" day counter within a 365 day "year"

Definition at line 31 of file unitmod.h.

Referenced by cell_dyn1(), CellAvg(), gen_output(), and init_eqns().

char* ModelPath

Environment variables used in model

ModelPath environment variable, base pathname for executable and input data
ProjName environment variable, the name of the model project
DriverPath environment variable, base pathname for source code
OS_TYPE environment variable, the type of operating system being used (informational purpose only, not used in code)

Definition at line 40 of file driver_utilities.h.

char * ProjName

Definition at line 40 of file driver_utilities.h.

char* OutputPath

base pathname for all model output (user input)

Definition at line 42 of file driver_utilities.h.

char modelName[20]

Model name/version (user input)

modelName Name given to model implementation (user input)
modelVers Version given to model implementation (e.g., v.2.1) (user input)

Definition at line 48 of file driver_utilities.h.

char modelVers[10]

Definition at line 48 of file driver_utilities.h.

char SimAlt[20]

simulation scenario/alterative name

Definition at line 42 of file generic_driver.h.

char SimModif[20]

simulation scenario/alterative modifier name/note

Definition at line 43 of file generic_driver.h.

int ESPmodeON

boolean flag indicating Everglades Settling-of Phosphorus mode. A mode with all biol/chem (non-hydro) modules turned off, running only a net settling rate module that reproduces equations and data from the SFWMD's old Everglades Water Quality Model (EWQM). Done only for comparision to full ecological ELM - ESP doesn't work very well!!

Definition at line 31 of file generic_driver.h.

float budg_Intvl

time (day) interval between budget summaries

Definition at line 72 of file generic_driver.h.

Referenced by BIRbudg_print(), get_parmf(), and track_time().

float BIRavg_Intvl

time (day) interval between Basin/Indicator-Region stat summaries

Definition at line 73 of file generic_driver.h.

Referenced by BIRstats_print(), and track_time().

time (day) interval between Basin/Indicator-Region hydro stat summaries

Definition at line 74 of file generic_driver.h.

Referenced by BIRstats_hydro_print(), get_parmf(), and track_time().

float avg_Intvl

time (day) interval between recurring-average summaries

Definition at line 71 of file generic_driver.h.

Referenced by CellAvg(), get_parmf(), readViewParms(), and track_time().

int avgPrint

boolean flag to indicate if recurring-averages is to be printed at current time

Definition at line 81 of file generic_driver.h.


Generated on Sat Jan 7 14:04:20 2012 for ELM source code by  doxygen 1.5.6