/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/hydrotrend/hydroprintannual.c

Go to the documentation of this file.
00001 /*
00002  * HydroPrintAnnual.c   Prints the annually averaged data to series of
00003  *                      text files.  Used to view the long term trends.
00004  *
00005  *      Author1:                M.D. Morehead   (June 1998)
00006  *  Author2:            A.J. Kettner    (February 2003)
00007  *
00008  * Variable             Def.Location    Type    Units   Usage
00009  * --------             ------------    ----    -----   -----
00010  * err                  various         int     -       error flag, halts program
00011  * ii                   various         int     -       temporary loop counter
00012  * fef                  HydroPrintTrend int     -       maximum basin Flood Exceedance Flag
00013  * Qrt                  HydroPrintTrend double  m^3/a   total rain derived discharge per year
00014  * Qit                  HydroPrintTrend double  m^3/a   total glacial derived discharge per year
00015  * Qnt                  HydroPrintTrend double  m^3/a   total nival derived discharge per year
00016  * Qst                  HydroPrintTrend double  m^3/a   total subsurface storm flow derived discharge per year
00017  * Qbt                  HydroPrintTrend double  m^3/a   total baseflow derived discharge per year
00018  * Qet                  HydroPrintTrend double  m^3/a   total exceed groundwater derived discharge per year
00019  *
00020  */
00021 #include "hydroclimate.h"
00022 #include "hydroparams.h"
00023 #include "hydrotimeser.h"
00024 #include "hydroinout.h"
00025 
00026 /*-----------------------------
00027  *  Start of HydroPrintAnnual
00028  *-----------------------------*/
00029 int hydroprintannual()
00030 {
00031 
00032 /*-------------------
00033  *  Local Variables
00034  *-------------------*/
00035 int err, ii, fef,p;
00036 double  Qrt, Qit, Qnt, Qst, Qbt, Qet, baseflowpercentage;
00037 
00038 baseflowpercentage = ((Qbartotal[ep] - baseflowtot[ep])/Qbartotal[ep]);
00039 
00040 /*------------------------
00041  *  Initialize variables
00042  *------------------------*/
00043 err = 0;
00044 Qrt = 0.0;
00045 Qit = 0.0;
00046 Qnt = 0.0;
00047 Qst = 0.0;
00048 Qbt = 0.0;
00049 Qet = 0.0;
00050 
00051 /*----------------------------------
00052  *  Calculate the needed variables
00053  *----------------------------------*/
00054 if( Qpeak > maxflood )
00055   fef = 1;
00056 else
00057   fef = 0;
00058 
00059 for( ii=0; ii<daysiy; ii++ ) {
00060    Qrt += Qrain[ii]*baseflowpercentage;
00061    Qit += Qice[ii]*baseflowpercentage;
00062    Qnt += Qnival[ii]*baseflowpercentage;
00063    Qst += Qss[ii]*baseflowpercentage;
00064    Qbt += baseflowtot[ep];
00065    Qet += Qexceedgw[ii]*baseflowpercentage;
00066 }
00067 Qrt *= dTOs;
00068 Qit *= dTOs;
00069 Qnt *= dTOs;
00070 Qst *= dTOs;
00071 Qbt *= dTOs;
00072 Qet *= dTOs;
00073 
00074 /*----------------------
00075  *  Print trend file 1
00076  *----------------------*/
00077 if( yr == syear[ep] && ep == 0) {
00078    fprintf( fidtrend1, "%% Annual Summary for: \n" );
00079    fprintf( fidtrend1, "%% %s", title[ep] );
00080    fprintf( fidtrend1, "%% maxflood = %.1f (m^3/s) \n%%\n", maxflood );
00081 
00082 /*                        1234 \t 123456 \t 123456 \t 123456 \t 123456 \t 12345 \t 123456 \t 123456 */
00083    fprintf( fidtrend1, "%%Year \t Avg.   \t Total  \t ELA    \t Glacier\t Flood  \t Baseflw\t Qpeak  \t");
00084         if (outletmodelflag == 1)
00085                 for (p=0; p < maxnoutlet; p++)   
00086         fprintf( fidtrend1, "Qpeak   \t");
00087    fprintf( fidtrend1, "\n" );
00088    fprintf( fidtrend1, "%%     \t Temp   \t Precip \t        \t Area   \t Exceed \t Precip \t for delta\t");
00089         if (outletmodelflag == 1)
00090                 for (p=0; p < maxnoutlet; p++)   
00091         fprintf( fidtrend1, "outlet:%d\t",p+1);
00092    fprintf( fidtrend1, "\n" );
00093    fprintf( fidtrend1, "%%     \t (degC) \t  (m)   \t (m)    \t (km^2) \t Flag   \t (m)    \t (m^3/s)\t");
00094         if (outletmodelflag == 1)
00095                 for (p=0; p < maxnoutlet; p++)   
00096         fprintf( fidtrend1, "(m^3/s)  \t");
00097    fprintf( fidtrend1, "\n" );
00098    fprintf( fidtrend1, "%%---- \t ------ \t ------ \t -------\t -------\t ------ \t ---    \t -------\t");
00099         if (outletmodelflag == 1)
00100                 for (p=0; p < maxnoutlet; p++)   
00101         fprintf( fidtrend1, "--------\t");
00102    fprintf( fidtrend1, "\n");
00103 }
00104 
00105 /*                  "Year \t Avg.   \t Total  \t ELA    \t Glacier\t Flood  \t Baseflw\t  Qpeak \t*/
00106 /*                   1234 \t 123456 \t 123456 \t 123456 \t 123456 \t 12345  \t 123456 \t 123456 \t*/
00107 fprintf( fidtrend1, "%d   \t %.2f   \t %.2f   \t %.1f   \t %.1f   \t\t %d     \t\t %.1f   \t\t %.1f   \t", \
00108       yr, Tannual, Pannual, ela, (bigg+smallg)/1e6, fef, baseflowtot[ep]*dTOs*daysiy, Qpeak);
00109         if (outletmodelflag == 1)
00110                 for (p=0; p < maxnoutlet; p++)   
00111                         fprintf( fidtrend1, "%.1f\t\t",Qpeakperoutlet[p]);      
00112 fprintf( fidtrend1, "\n");
00113 
00114 /*----------------------
00115  *  Print trend file 2
00116  *----------------------*/
00117 if( yr == syear[ep] && ep == 0 ) {
00118    fprintf( fidtrend2, "%% Annual Summary for: \n" );
00119    fprintf( fidtrend2, "%% %s", title[ep] );
00120    fprintf( fidtrend2, "%% discharges in 10^6 m^3/annum, ending GW pool in 10^6 m^3\n" );
00121    fprintf( fidtrend2, "%% to convert to mean annual, divide by 1e6*86400/365 -> m^3/s \n%%\n" );
00122 
00123 /*                        1234 \t 123456 \t 123456 \t 123456 \t 123456 \t 123456 \t 123456 \t 123456 \t 123456 */
00124    fprintf( fidtrend2, "%%Year \t Qtotal \t Qrain  \t Qice   \t Qnival \t Qss    \t Qbase  \t Qexcdgw\t GWend \n");
00125    fprintf( fidtrend2, "%%---- \t ------ \t ------ \t ----   \t ------ \t ---    \t -----  \t -------\t ----- \n");
00126 }
00127 
00128 /*                   1234 \t 123456 \t 123456 \t 123456 \t 123456 \t 123456 \t 123456 \t 123456 \t 123456       */
00129 /*                "%%Year \t Qtotal \t Qrain  \t Qice   \t Qnival \t Qss    \t Qbase  \t Qexcdgw\t GWend        */
00130 fprintf( fidtrend2, "%d   \t %.1f   \t %.1f   \t %.1f   \t %.1f   \t %.1f   \t %.1f   \t %.1f   \t %.2e \n", \
00131                      yr, Qtotal/1e6, Qrt/1e6, Qit/1e6,  Qnt/1e6,  Qst/1e6,  Qbt/1e6,  Qet/1e6, gwstore[daysiy-1] );
00132 
00133 
00134 /*----------------------
00135  *  Print trend file 3
00136  *----------------------*/
00137 if( yr == syear[ep] && ep == 0) {
00138         fprintf( fidtrend3, "%% Annual Summary for: \n" );
00139         fprintf( fidtrend3, "%% %s", title[ep] );
00140         fprintf( fidtrend3, "%% discharge in 10^6 m^3/annum, Sediment load in 10^9 kg/annum \n%%\n" );
00141         fprintf( fidtrend3, "%%Year \t Qtotal \t ");
00142         if (outletmodelflag == 1)
00143                 for (p=0; p < maxnoutlet; p++)   
00144                         fprintf( fidtrend3, "Qoutlet:%d \t ",p+1);              
00145         fprintf( fidtrend3, "Qstotal\t ");
00146         if (outletmodelflag == 1)
00147                 for (p=0; p < maxnoutlet; p++)   
00148                         fprintf( fidtrend3, "Qsoutlet:%d\t ",p+1);
00149         fprintf( fidtrend3, "Qbedtotal\t ");
00150         if (outletmodelflag == 1)
00151                 for (p=0; p < maxnoutlet; p++)   
00152                         fprintf( fidtrend3, "Qbedoutlet:%d \t ",p+1);
00153         fprintf( fidtrend3, "\n");      
00154         fprintf( fidtrend3, "%%Qfrac.\t (100%%) \t" );
00155         if (outletmodelflag == 1)
00156                 for (p=0; p < maxnoutlet; p++)
00157                         fprintf( fidtrend3, " (%.0f%%)\t\t",outletpcttotevents[p][ep]*100);
00158         fprintf( fidtrend3, " (100%%)  \t ");           
00159         if (outletmodelflag == 1)
00160                 for (p=0; p < maxnoutlet; p++)
00161                         fprintf( fidtrend3, "(%.0f%%)\t\t ",outletpcttotevents[p][ep]*100);
00162         fprintf( fidtrend3, "(100%%)    \t ");          
00163         if (outletmodelflag == 1)
00164                 for (p=0; p < maxnoutlet; p++)
00165                         fprintf( fidtrend3, "(%.0f%%)\t\t     ",outletpcttotevents[p][ep]*100);
00166         fprintf( fidtrend3, "\n");
00167         fprintf( fidtrend3, "%%---- \t ------ \t" );
00168         if (outletmodelflag == 1)
00169                 for (p=0; p < maxnoutlet; p++)
00170                         fprintf( fidtrend3, " ---------- ");
00171         fprintf( fidtrend3, " -------\t ");             
00172         if (outletmodelflag == 1)
00173                 for (p=0; p < maxnoutlet; p++)
00174                         fprintf( fidtrend3, "----------- ");
00175         fprintf( fidtrend3, "---------\t ");            
00176         if (outletmodelflag == 1)
00177                 for (p=0; p < maxnoutlet; p++)
00178                         fprintf( fidtrend3, "------------- \t ");
00179         fprintf( fidtrend3, "\n");
00180 }
00181 fprintf( fidtrend3, "%d   \t %.1f   \t", yr, Qtotal/1e6);
00182 if (outletmodelflag == 1)
00183         for (p=0; p < maxnoutlet; p++)   
00184                 fprintf( fidtrend3, " %.2f   \t", Qtotaloutletannual[p]/1e6);
00185 fprintf( fidtrend3, " %.2f\t     ", Qsannual/1e9);
00186 if (outletmodelflag == 1)
00187         for (p=0; p < maxnoutlet; p++)   
00188                 fprintf( fidtrend3, "%.3f    \t ", Qsannualoutlet[p]/1e9);
00189 fprintf( fidtrend3, "%.2f  \t ", Qbedannual/1e9);
00190 if (outletmodelflag == 1)
00191         for (p=0; p < maxnoutlet; p++)   
00192                 fprintf( fidtrend3, "    %.3f  \t ", Qbedannualoutlet[p]/1e9);
00193 fprintf( fidtrend3, "\n");              
00194 
00195 return(err);
00196 }       /* end of hydroprintannual.c */

Generated on Fri Jan 4 18:04:14 2008 for sedflux by  doxygen 1.5.2