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

Go to the documentation of this file.
00001 /*
00002  *  HydroCheckInput.c
00003  *
00004  *  Checks the input parameters for HYDROTREND
00005  *
00006  *  Author:    M.D. Morehead (June 1998)
00007  *  Author2:   S.D. Peckham  (January 2002)
00008  *  Author3:   A.J. Kettner  (August-September 2002)
00009  *
00010  */
00011 #include <string.h>
00012 #include "hydroclimate.h"
00013 #include "hydroinout.h"
00014 #include "hydroparams.h"
00015 
00016 /*----------------------------
00017  *  Start of HydroCheckInput
00018  *----------------------------*/
00019 int hydrocheckinput()
00020 {
00021 /*-------------------
00022  *  Local Variables
00023  *-------------------*/
00024 double dumdbl;
00025 int jj, err, verbose;
00026 err = 0;
00027 verbose = 0;
00028 
00029 /*-------------------------------
00030  *  Verify the number of epochs
00031  *-------------------------------*/
00032 if (verbose) printf("Checking number of epochs...\n");
00033 if (nepochs <= 0 || nepochs >= maxepoch) {
00034     fprintf(stderr,"   HydroCheckInput ERROR: nepochs < 0 or > maxepoch in the input file.\n");
00035     fprintf(stderr,"      nepochs = %d \n", nepochs);
00036     err=1;
00037 }
00038 
00039 /*----------------------------------------------
00040  *  Loop through and test values of each epoch
00041  *----------------------------------------------*/
00042 for (ep=0; ep<nepochs; ep++) {
00043 
00044 /*----------------------------------------
00045  *  Check number of years for this epoch
00046  *----------------------------------------*/
00047 if (verbose) printf("Checking number of years in epoch...\n");
00048 if (nyears[ep] < 1 ) {
00049     fprintf(stderr,"   HydroCheckInput ERROR: input file line 5) \n");
00050     fprintf(stderr,"      nyears < 1 in the input file.\n");
00051     fprintf(stderr,"      nyears[ep] = %d \n", nyears[ep]);
00052     err++;
00053 }
00054 if (ep) {
00055     if( syear[ep-1]+nyears[ep-1] != syear[ep] ) {
00056         fprintf(stderr,"   HydroCheckInput ERROR: input file line 5) \n");
00057         fprintf(stderr,"      The end year of one epoch does not match the \n");
00058         fprintf(stderr,"      beginning year of the following epoch. \n");
00059         fprintf(stderr,"      epoch \t\t\t = %d \n", ep+1 );
00060         fprintf(stderr,"      syear[ep-1] \t\t = %d \n", syear[ep-1]);
00061         fprintf(stderr,"      nyears[ep-1] \t\t = %d \n", nyears[ep-1]);
00062         fprintf(stderr,"      endyear[ep-1] \t\t = %d \n", syear[ep-1]+nyears[ep-1]-1);
00063         fprintf(stderr,"      predicted syear[ep] \t = %d \n", syear[ep-1]+nyears[ep-1]);
00064         fprintf(stderr,"      syear[ep] \t\t = %d \n", syear[ep]);
00065         err++;
00066     }
00067 }
00068 
00069 /*-----------------------------------------------------------
00070  *  Check that the averaging timestep for the *.dis file is
00071  *  one of: d (day), m (month), s (season) or y (year).         
00072  *-----------------------------------------------------------*/
00073 if (verbose) printf("Checking timestep...\n");
00074 if( timestep[0] != 'd' && timestep[0] != 'm' &&
00075     timestep[0] != 's' && timestep[0] != 'y' ) {
00076     fprintf(stderr,"   HydroCheckInput ERROR: input file line 5 \n");
00077     fprintf(stderr,"      The averaging timestep is incorrect.\n");
00078     fprintf(stderr,"      It must be one of d (day), m (month), s (season), y (year).\n");
00079     fprintf(stderr,"      timestep = %s \n", timestep);
00080     err++;
00081 }
00082 
00083 /*--------------------------------------------------------------
00084  *  Ensure that table year ranges fall within epoch boundaries  
00085  *--------------------------------------------------------------*/
00086 if (verbose) printf("Checking table year ranges...\n");
00087 if (tblstart[ep] < syear[ep] || tblend[ep] < syear[ep] ||
00088     tblstart[ep] > syear[ep]+nyears[ep] || tblend[ep] > syear[ep]+nyears[ep] ) {
00089     fprintf(stderr,"   HydroCheckInput WARNING: input file line 6) \n");
00090     fprintf(stderr,"     The specified years for the table file are out of range.\n");
00091     fprintf(stderr,"     No information will be printed.\n");
00092     fprintf(stderr,"     syear[ep] \t = %d \n", syear[ep]);
00093     fprintf(stderr,"     nyears[ep] \t = %d \n", nyears[ep]);
00094     fprintf(stderr,"     tblstart[ep] \t = %d \n", tblstart[ep]);
00095     fprintf(stderr,"     tblend[ep] \t = %d \n", tblend[ep]);
00096 }
00097 
00098 /*-------------------------------
00099  *  Check number of grain sizes
00100  *-------------------------------*/
00101 if (verbose) printf("Checking number of grain sizes...\n");
00102 if (ngrain > maxgrn || ngrain < 0){
00103     fprintf(stderr,"   HydroCheckInput ERROR: input file line 7) \n");
00104     fprintf(stderr,"     The number of grainsizes is not in the range \n");
00105     fprintf(stderr,"     between 0 and %d.\n",maxgrn);
00106     err++;
00107 }
00108 
00109 /*-----------------------------------------------------------
00110  *  Check that grain size fractions sum to 1.0 (within .1%)     
00111  *-----------------------------------------------------------*/
00112 if (verbose) printf("Checking grain fraction sum...\n");
00113 dumdbl = 0.0;
00114 for (jj=0; jj<ngrain; jj++ )
00115     dumdbl += grainpct[jj][ep];
00116 if (fabs(1-dumdbl) > 0.001 ){
00117     fprintf(stderr,"   HydroCheckInput ERROR: input file line 8) \n");
00118     fprintf(stderr,"     The sum of the grain size fractions does not = 1. \n");
00119     fprintf(stderr,"     sum(grainpct[ep]) = %f \n", dumdbl);
00120     err++;
00121 }
00122 
00123 /*----------------------------------------------------
00124  *  Check that temp trend lines match between epochs
00125  *----------------------------------------------------*/
00126 if (ep) {
00127    if (verbose) printf("Checking temp trend line continuity...\n");
00128    dumdbl = 1 - Tstart[ep]/ (Tstart[ep-1]+nyears[ep-1]*Tchange[ep-1]);
00129    if (fabs(dumdbl) > 0.01 ) {
00130        fprintf(stderr,"   HydroCheckInput ERROR: input file line 9) \n");
00131        fprintf(stderr,"  The start temperature for one epoch does not match the end\n");
00132        fprintf(stderr,"  temperature of the previous epoch.\n");
00133        fprintf(stderr,"  Criteria: fabs(difference) < 0.01 \n");
00134        fprintf(stderr,"  Criteria \t = %f \n", dumdbl);
00135        fprintf(stderr,"  epoch \t\t = %d \n", ep+1 );
00136        fprintf(stderr,"  Tstart[ep] \t = %f (degC) \n", Tstart[ep]);
00137        fprintf(stderr,"  Tstart[ep-1] \t = %f (degC) \n", Tstart[ep-1]);
00138        fprintf(stderr,"  Tchange[ep-1] \t = %f (degC/a) \n", Tchange[ep-1]);
00139        fprintf(stderr,"  nyears[ep-1] \t = %d \n", nyears[ep-1]);
00140        err++;
00141         }
00142 
00143 /*------------------------------------------------------
00144  *  Check that precip trend lines match between epochs
00145  *------------------------------------------------------*/
00146    if (verbose) printf("Checking precip trend line continuity...\n");
00147    dumdbl = 1 - Pstart[ep] / (Pstart[ep-1]+nyears[ep-1]*Pchange[ep-1]);
00148    if (fabs(dumdbl) > 0.01 ) {
00149        fprintf(stderr,"   HydroCheckInput ERROR: input file line 10) \n");
00150        fprintf(stderr,"  The start precipitation for one epoch does not match the end\n");
00151        fprintf(stderr,"  precipitation of the previous epoch.\n");
00152        fprintf(stderr,"  Criteria: fabs(difference) < 0.01 \n");
00153        fprintf(stderr,"  Criteria \t = %f \n", dumdbl);
00154        fprintf(stderr,"  epoch \t\t = %d \n", ep+1 );
00155        fprintf(stderr,"  Pstart[ep] \t = %f (m/a) \n",   Pstart[ep]);
00156        fprintf(stderr,"  Pstart[ep-1] \t = %f (m/a) \n", Pstart[ep-1]);
00157        fprintf(stderr,"  Pchange[ep-1] \t = %f (m/a/a) \n", Pchange[ep-1]);
00158        fprintf(stderr,"  nyears[ep-1] \t = %d \n", nyears[ep-1]);
00159        err++;
00160     }
00161 }
00162 
00163 /*----------------------------------------------
00164  *  Check the ranges of annual temp and precip
00165  *----------------------------------------------*/
00166 if (verbose) printf("Checking temp and precip trend parameters...\n");
00167 if( -20. > Tstart[ep] || Tstart[ep] > 30. ) {
00168     fprintf(stderr,"   HydroCheckInput ERROR: input file line 9) \n");
00169     fprintf(stderr,"     The starting temperature is out of range. \n");
00170     fprintf(stderr,"     Criteria: -20 < Tstart < 30 (deg C) \n");
00171     fprintf(stderr,"     Tstart[ep] = %f \n", Tstart[ep]);
00172     err++;
00173 }
00174 if( -1 > Tchange[ep] || Tchange[ep] > 1 ) {
00175     fprintf(stderr,"   HydroCheckInput ERROR: input file line 9) \n");
00176     fprintf(stderr,"     The temperature change/year is out of range. \n");
00177     fprintf(stderr,"     Criteria: -1 < Tchange < 1 (degC/a) \n");
00178     fprintf(stderr,"     Tchange[ep] = %f \n", Tchange[ep]);
00179     err++;
00180 }
00181 if( -5 > Tstd[ep] || Tstd[ep] > 5 ) {
00182     fprintf(stderr,"   HydroCheckInput ERROR: input file line 9) \n");
00183     fprintf(stderr,"     The temperature standard deviation is out of range. \n");
00184     fprintf(stderr,"     Criteria: -5 < Tstd < 5 (degC) \n");
00185     fprintf(stderr,"     Tstd[ep] = %f \n", Tstd[ep]);
00186     err++;
00187 }
00188 if( 0 > Pstart[ep] || Pstart[ep] > 5 ) {
00189     fprintf(stderr,"   HydroCheckInput ERROR: input file line 10) \n");
00190     fprintf(stderr,"     The starting precipitation is out of range. \n");
00191     fprintf(stderr,"     Criteria: 0 < Pstart < 5 (m/a) \n");
00192     fprintf(stderr,"     Pstart[ep] = %f \n", Pstart[ep]);
00193     err++;
00194 }
00195 if( -0.5 > Pchange[ep] || Pchange[ep] > 0.5 ) {
00196     fprintf(stderr,"   HydroCheckInput ERROR: input file line 10) \n");
00197     fprintf(stderr,"     The precipitation change/year is out of range. \n");
00198     fprintf(stderr,"     Criteria: -0.5 < Pchange < 0.5 (m/a/a) \n");
00199     fprintf(stderr,"     Pchange[ep] = %f \n", Pchange[ep]);
00200     err++;
00201 }
00202 if( -2 > Pstd[ep] || Pstd[ep] > 2 ) {
00203     fprintf(stderr,"   HydroCheckInput ERROR: input file line 10) \n");
00204     fprintf(stderr,"     The precipitation standard deviation is out of range. \n");
00205     fprintf(stderr,"     Criteria: -2 < Pstd < 2 (m/a) \n");
00206     fprintf(stderr,"     Pstd[ep] = %f \n", Pstd[ep]);
00207     err++;
00208 }
00209 
00210 /*------------------------------------------------------------
00211  *  Check the range of the monthly climate variable (T P...)
00212  *  Check that some rain is specified (in any month)
00213  *------------------------------------------------------------*/
00214 if (verbose) printf("Checking monthly climate data (T & P)...\n");
00215 dumdbl = 0.0;
00216 for (jj=0; jj<12; jj++) {
00217     if( -50 > Tnominal[jj][ep] || Tnominal[jj][ep] > 50 ) {
00218         fprintf(stderr,"   HydroCheckInput ERROR: input file line %d) \n", jj+13);
00219         fprintf(stderr,"         The average monthly temperature is out of range. \n");
00220         fprintf(stderr,"         Criteria: -50 < Tnominal < 50 \n");
00221         fprintf(stderr,"         Tnominal[jj][ep] \t = %f (degC) \n", Tnominal[jj][ep]);
00222         fprintf(stderr,"         jj \t\t = %d \n", jj);
00223         fprintf(stderr,"         ep \t\t = %d \n", ep);
00224         err++;
00225     }
00226     if( 0.0 > Tnomstd[jj][ep] || Tnomstd[jj][ep] > 10 ) {
00227         fprintf(stderr,"   HydroCheckInput ERROR: input file line %d) \n", jj+13);
00228         fprintf(stderr,"         The monthly temperature standard deviation is out of range. \n");
00229         fprintf(stderr,"         Criteria: 0.0 < Tnomstd < 10 \n");
00230         fprintf(stderr,"         Tnomstd[jj][ep] \t = %f (degC) \n", Tnomstd[jj][ep]);
00231         fprintf(stderr,"         jj \t\t = %d \n", jj);
00232         fprintf(stderr,"         ep \t\t = %d \n", ep);
00233         err++;
00234     }
00235     if( 0. > Pnominal[jj][ep]*1000 || Pnominal[jj][ep]*1000 > 1000 ) {
00236         fprintf(stderr,"   HydroCheckInput ERROR: input file line %d) \n", jj+13);
00237         fprintf(stderr,"         The monthly rainfall is out of range. \n");
00238         fprintf(stderr,"         Criteria: 0 < Pnominal < 1000 \n");
00239         fprintf(stderr,"         Pnominal[jj][ep] \t = %f (mm) \n", Pnominal[jj][ep]*1000);
00240         fprintf(stderr,"         jj \t\t = %d \n", jj);
00241         fprintf(stderr,"         ep \t\t = %d \n", ep);
00242         err++;
00243     }
00244     if( 0 >= Pnomstd[jj][ep]*1000 || Pnomstd[jj][ep]*1000 > 650 ) {
00245         fprintf(stderr,"   HydroCheckInput ERROR: input file line %d) \n", jj+13);
00246         fprintf(stderr,"         The monthly rainfall standard deviation is out of range. \n");
00247         fprintf(stderr,"         Criteria: 0 < Pnomstd < 450 \n");
00248         fprintf(stderr,"         Pnomstd[jj][ep] \t = %f (mm) \n", Pnomstd[jj][ep]*1000);
00249         fprintf(stderr,"         jj \t\t = %d \n", jj);
00250         fprintf(stderr,"         ep \t\t = %d \n", ep);
00251         err++;
00252     }
00253     dumdbl+=Pnominal[jj][ep];
00254 }
00255 if( dumdbl <= 0 ) {
00256     fprintf(stderr,"   HydroCheckInput ERROR: input file lines 13-24) \n");
00257     fprintf(stderr,"     There is no precipitation specified in any month. \n");
00258     fprintf(stderr,"     Total specified rainfall = %f (m) \n", dumdbl*1000);
00259     err++;
00260 }
00261 
00262 /*-----------------------------------------------------------
00263  *  Check the bounds on the lapse rate  
00264  *  psuedoAdiabatic Lapse rate 6 degC/km in mid troposphere
00265  *  gamma_s = saturate adiabatic lapse rate == - dT/dz
00266  *  = 4 degC/km near the ground in humid air masses
00267  *  = 6-7 degC/km in the middle troposphere
00268  *-----------------------------------------------------------*/
00269 if (verbose) printf("Checking lapse rate...\n");
00270 if ((1 > lapserate[ep]*1000 && lapserate[ep] != -9999) || lapserate[ep]*1000 > 10) {
00271     fprintf(stderr,"   HydroCheckInput ERROR: input file line 25) \n");
00272     fprintf(stderr,"     The adiabatic lapse rate is out of range. \n");
00273     fprintf(stderr,"     Criteria: 1 < lapserate < 10 \n");
00274     fprintf(stderr,"     lapserate[ep] = %f (degC/km) \n", lapserate[ep]*1000);
00275     err++;
00276 }
00277 
00278 /*------------------------------
00279  *  Check latitude input value
00280  *------------------------------*/
00281 if (verbose) printf("Checking latitude...\n");
00282 if (lat > 90 || lat < -90){
00283     fprintf(stderr,"   HydroCheckInput ERROR: input file line 38) \n");
00284     fprintf(stderr,"     Latitude input is out of range, lower than -90 or  \n");
00285     fprintf(stderr,"     higher than 90 degrees. lat = %f (degrees)\n", lat);
00286     err++;
00287 }
00288 
00289 /*----------------------------------
00290  *  Check ascii file ON/OFF option
00291  *----------------------------------*/
00292 if (verbose) printf("Checking ascii file ON/OFF option...\n");
00293 if (ep == 0){
00294     if( (strncmp(asciioutput,ON,2) != 0) && ( strncmp(asciioutput,OFF,2) != 0)){
00295         fprintf(stderr,"    HydroCheckInput ERROR: input file line 2) \n");
00296         fprintf(stderr,"      The print to ASCII file option is not set  \n");
00297         fprintf(stderr,"      correctly to ON or OFF, but is set as: ");
00298         for (jj=0; jj<MAXCHAR; jj++)
00299             fprintf(stderr,"%c",asciioutput[jj]);
00300         fprintf(stderr,"\n");
00301         err++;
00302     }
00303 }
00304 
00305 /*--------------------------------------------------
00306  *  Check ELA range and values at epoch boundaries
00307  *--------------------------------------------------*/
00308 if (verbose) printf("Checking ELA info...\n");
00309 if( 0 > ELAstart[ep] || 0 > ELAstart[ep]+nyears[ep]*ELAchange[ep] ) {
00310     fprintf(stderr,"   HydroCheckInput ERROR: input file line 26) \n");
00311     fprintf(stderr,"     The ela is out of range. \n");
00312     fprintf(stderr,"     Criteria: 0 < ela \n");
00313     fprintf(stderr,"     ELAstart[ep] \t = %f (m) \n", ELAstart[ep]);
00314     fprintf(stderr,"     ela stop \t = %f (m) \n", ELAstart[ep]+nyears[ep]*ELAchange[ep]);
00315     err++;
00316 }
00317 if( ep ) {
00318     dumdbl = 1 - ELAstart[ep] / (ELAstart[ep-1]+nyears[ep-1]*ELAchange[ep-1]);
00319     if( fabs(dumdbl) > 0.01 ) {
00320         fprintf(stderr,"   HydroCheckInput ERROR: input file line 26) \n");
00321         fprintf(stderr,"      The ela at the end of one epoch does not match the \n");
00322         fprintf(stderr,"      ela at the begining of the following epoch. \n");
00323         fprintf(stderr,"      Criteria: fabs(differnce) < 0.01 \n");
00324         fprintf(stderr,"      Criteria \t = %f \n", dumdbl);
00325         fprintf(stderr,"      epoch-1 \t = %d \n", ep);
00326         fprintf(stderr,"      ELAstart[ep-1] \t = %f (m) \n", ELAstart[ep-1] );
00327         fprintf(stderr,"      ELAchange[ep-1] \t = %f (m/a) \n",ELAchange[ep-1] );
00328         fprintf(stderr,"      epoch \t = %d \n", ep+1);
00329         fprintf(stderr,"      ELAstart[ep] \t = %f (m) \n", ELAstart[ep]);
00330         fprintf(stderr,"      ela end [ep-1] \t = %f (m) \n",ELAstart[ep-1]+nyears[ep-1]*ELAchange[ep-1] );
00331         err++;
00332     }
00333 }
00334 
00335 /*---------------------------------------------------
00336  *  Check nival and ice groundwater and evaporation
00337  *  ground water fraction is 0 to .5    
00338  *---------------------------------------------------*/
00339 if (verbose) printf("Checking snow and ice parameters...\n");
00340 if (0 > dryevap[ep] || dryevap[ep] > 0.9){
00341     fprintf(stderr,"   HydroCheckInput ERROR: input file line 27) \n");
00342     fprintf(stderr,"     The snow and ice evaporation percentage is out of range. \n");
00343     fprintf(stderr,"     0 < dryevap < 0.9 \n");
00344     fprintf(stderr,"     dryevap[ep] = %f (%%) \n", dryevap[ep]);
00345     err++;
00346 }
00347 
00348 /*----------------------------
00349  *  Check river slope limits    
00350  *----------------------------*/
00351 if (verbose) printf("Checking river slope near mouth...\n");
00352 if (0.00000001 > rslope[ep] || rslope[ep] > 0.1 ) {
00353     fprintf(stderr,"   HydroCheckInput ERROR: input file line 28) \n");
00354     fprintf(stderr,"     The river slope is out of range. \n");
00355     fprintf(stderr,"     Criteria: 0.001 < rslope < 0.01 \n");
00356     fprintf(stderr,"     rslope[ep] = %f (m/m (gradient)) \n", rslope[ep]);
00357     err++;
00358 }
00359 
00360 /*----------------------------
00361  *  Check river basin length
00362  *----------------------------*/
00363 if (verbose) printf("Checking basin length...\n");
00364 if( 10 > basinlength[ep]/1000 || basinlength[ep]/1000 > 10000 ){
00365     fprintf(stderr,"   HydroCheckInput ERROR: input file line 29) \n");
00366     fprintf(stderr,"     The basin length is out of range. \n");
00367     fprintf(stderr,"     10 < basinlength < 1000 \n");
00368     fprintf(stderr,"     basinlength[ep] = %f (km) \n", basinlength[ep]/1000);
00369     err++;
00370 }
00371 
00372 /*-----------------------------
00373  *  Check volume of reservoir
00374  *-----------------------------*/
00375 if (verbose) printf("Checking volume of reservoir...\n");
00376 if(  0 > Rvol[ep] || Rvol[ep] > 8000.0){
00377     fprintf(stderr,"   HydroCheckInput ERROR: input file line 30) \n");
00378     fprintf(stderr,"     The volume of reservoirs is out of range. \n");
00379     fprintf(stderr,"     0.0 km^3 < Rvol[ep]< 8000.0 km^3 \n");
00380     fprintf(stderr,"     Rvol[ep] = 0 if there are no large reservoirs\n");
00381     fprintf(stderr,"     Rvol[ep] = %.3f (km^3) \n", Rvol[ep]);
00382     err++;
00383 }
00384 /*-------------------------------
00385  *  Check altiture of reservoir
00386  *-------------------------------*/
00387 if (verbose) printf("Checking altitude of reservoir...\n");
00388 if (Rvol[ep] != 0.0)
00389         if (Ralt[ep] < 0.0 || Ralt[ep] >= maxalt[ep]){
00390             fprintf(stderr,"   HydroCheckInput ERROR: input file line 30) \n");
00391         fprintf(stderr,"         The altitude of reservoirs is out of range. \n");
00392             fprintf(stderr,"      0 > Ralt[ep] = %.3f (km^3) > maxalt[ep] = %f \n", Ralt[ep], maxalt[ep]);
00393         err++;
00394         }
00395 
00396 /*-------------------------------------------------
00397  *  Check hydraulic geometry coeffs and exponents
00398  *-------------------------------------------------*/
00399 if (verbose) printf("Checking hydraulic geometry parameters...\n");
00400 if ((0 >= velpow[ep] && velpow[ep] != -9999) || velpow[ep] >= 1) {
00401     fprintf(stderr,"   HydroCheckInput ERROR: input file line 31) \n");
00402     fprintf(stderr,"     The river mouth velocity power is out of range. \n");
00403     fprintf(stderr,"     Criteria: 0 < velpow < 1 \n");
00404     fprintf(stderr,"     velpow[ep] = %f \n", velpow[ep]);
00405     err++;
00406 }
00407 if( 0 >= velcof[ep] ) {
00408     fprintf(stderr,"   HydroCheckInput ERROR: input file line 31) \n");
00409     fprintf(stderr,"     The river mouth velocity coefficient is out of range. \n");
00410     fprintf(stderr,"     Criteria: 0 < velcof \n");
00411     fprintf(stderr,"     velcof[ep] = %f \n", velcof[ep]);
00412     err++;
00413 }
00414 if( (0 >= widpow[ep] && widpow[ep] != -9999) || widpow[ep] >= 1 ) {
00415     fprintf(stderr,"   HydroCheckInput ERROR: input file line 32) \n");
00416     fprintf(stderr,"     The river mouth width power is out of range. \n");
00417     fprintf(stderr,"     Criteria: 0 < widpow < 1 \n");
00418     fprintf(stderr,"     widpow[ep] = %f \n", widpow[ep]);
00419     err++;
00420 }
00421 if( 0 >= widcof[ep] ) {
00422     fprintf(stderr,"   HydroCheckInput ERROR: input file line 32) \n");
00423     fprintf(stderr,"     The river mouth width coefficient is out of range. \n");
00424     fprintf(stderr,"     Criteria: 0 < widcof \n");
00425     fprintf(stderr,"     widcof[ep] = %f \n", widcof[ep]);
00426     err++;
00427 }
00428 
00429 /*--------------------------------
00430  *  Check average river velocity
00431  *--------------------------------*/
00432 if (verbose) printf("Checking average river velocity...\n");
00433 if( 0.1 > avgvel[ep] || avgvel[ep] > 5 ){
00434     fprintf(stderr,"   HydroCheckInput ERROR: input file line 33) \n");
00435     fprintf(stderr,"     The average river velocity is out of range. \n");
00436     fprintf(stderr,"     0.1 < avgvel < 5 \n");
00437     fprintf(stderr,"     avgvel[ep] = %f (m/s) \n", avgvel[ep]);
00438     err++;
00439 }
00440 
00441 /*----------------------------------------
00442  *  Check Groundwater Storage parameters                
00443  *----------------------------------------*/
00444 if (verbose) printf("Checking groundwater parameters...\n");
00445 if( 2 > gwmax[ep] || gwmax[ep] > 1e15 ){
00446     fprintf(stderr,"   HydroCheckInput ERROR: input file line 34) \n");
00447     fprintf(stderr,"     The maximum size of the groundwater pool is out of range. \n");
00448     fprintf(stderr,"     2 < gwmax < 1e15 \n");
00449     fprintf(stderr,"     gwmax[ep] = %f (m^3) \n", gwmax[ep]);
00450     err++;
00451 }
00452 if( 1 > gwmin[ep] || gwmin[ep] > gwmax[ep] ){
00453     fprintf(stderr,"   HydroCheckInput ERROR: input file line 34) \n");
00454     fprintf(stderr,"     The minimum size of the groundwater pool is out of range. \n");
00455     fprintf(stderr,"     1 < gwmin < gwmax \n");
00456     fprintf(stderr,"     gwmin[ep] = %f (m^3) \n", gwmin[ep]);
00457     fprintf(stderr,"     gwmax[ep] = %f (m^3) \n", gwmax[ep]);
00458     err++;
00459 }
00460 if( gwmin[ep] > gwinitial || gwinitial > gwmax[ep] ){
00461     fprintf(stderr,"   HydroCheckInput ERROR: input file line 35) \n");
00462     fprintf(stderr,"     The initial size of the groundwater pool is out of range. \n");
00463     fprintf(stderr,"     gwmin < gwinitial < gwmax \n");
00464     fprintf(stderr,"     gwmin[ep]  = %f (m^3) \n", gwmin[ep]);
00465     fprintf(stderr,"     gwinitial  = %f (m^3) \n", gwinitial);
00466     fprintf(stderr,"     gwmax[ep]  = %f (m^3) \n", gwmax[ep]);
00467     err++;
00468 }
00469 
00470 /*------------------------------------------------------
00471  *  Check ranges on the rain mass balance coefficients
00472  *------------------------------------------------------*/
00473 if (verbose) printf("Checking mass balance coeffs...\n");
00474 if( 0 > Pmassbal[ep] || Pmassbal[ep] > 10 ) {
00475     fprintf(stderr,"   HydroCheckInput ERROR: input file line 11) \n");
00476     fprintf(stderr,"     The rain mass balance is out of range. \n");
00477     fprintf(stderr,"     Criteria: 0 < Pmassbal < 10  \n");
00478     fprintf(stderr,"     Pmassbal[ep] = %f \n", Pmassbal[ep]);
00479     err++;
00480 }
00481 if( 1 >= Pexponent[ep] || Pexponent[ep] >= 2 ) {
00482     fprintf(stderr,"   HydroCheckInput ERROR: input file line 11) \n");
00483     fprintf(stderr,"     The rain distribution exponent is out of range. \n");
00484     fprintf(stderr,"     Criteria: 1 < Pexponent < 2 \n");
00485     fprintf(stderr,"     Pexponent[ep] = %f \n", Pexponent[ep]);
00486     err++;
00487 }
00488 if( 0 > Prange[ep] || Prange[ep] > 10 ) {
00489     fprintf(stderr,"   HydroCheckInput ERROR: input file line 11) \n");
00490     fprintf(stderr,"     The rain mass balance distribution range is out of range. \n");
00491     fprintf(stderr,"     Criteria: 0 < Prange < 10 \n");
00492     fprintf(stderr,"     Prange[ep] = %f \n", Prange[ep]);
00493     err++;
00494 }
00495 
00496 /*----------------------------------------------------------
00497  *  Check that baseflow is >= 0 and less than total precip
00498  *----------------------------------------------------------*/
00499 if (verbose) printf("Checking baseflow range...\n");
00500 if( 0. > baseflowtot[ep] || baseflowtot[ep] > Pstart[ep]*totalarea[ep]/(dTOs*365.0) ) {
00501     fprintf(stderr,"   HydroCheckInput ERROR: input file line 12) \n");
00502     fprintf(stderr,"     The baseflow is out of range. \n");
00503     fprintf(stderr,"     Criteria: 0.0 < baseflow < total Precip (m^3/s) \n");
00504     fprintf(stderr,"     baseflow[ep] = %f (m^3/s) \n", baseflowtot[ep]);
00505     fprintf(stderr,"     total Precip = Pstart*totalarea/(dTOs*365.0) \n");
00506     fprintf(stderr,"     total Precip = %f (m^3/s) \n", Pstart[ep]*totalarea[ep]/(dTOs*365.0) );
00507     fprintf(stderr,"     Pstart[ep] = %f (m) \n", Pstart[ep] );
00508     fprintf(stderr,"     totalarea[ep] = %f (km^2) \n", totalarea[ep]/1e6 );
00509     err++;
00510 }
00511 
00512 /*----------------------------------------------
00513  *  50) Check Subsurface Storm Flow parameters  
00514  *----------------------------------------------*/
00515 if (verbose) printf("Checking storm flow parameters...\n");
00516 if (1 > alphass[ep] || alphass[ep] > 1e5){
00517     fprintf(stderr,"   HydroCheckInput ERROR: input file line 36) \n");
00518     fprintf(stderr,"     The subsurface storm flow coefficient is out of range. \n");
00519     fprintf(stderr,"     1 < alphass < 1e5 \n");
00520     fprintf(stderr,"     alphass[ep] = %f (m^3/s) \n", alphass[ep]);
00521     err++;
00522 }
00523 if( 0.5 > betass[ep] || betass[ep] > 2 ){       /* betass 0:10 in river5 */
00524     fprintf(stderr,"   HydroCheckInput ERROR: input file line 36) \n");
00525     fprintf(stderr,"     The subsurface storm flow exponent is out of range. \n");
00526     fprintf(stderr,"     0.5 < betass < 2 \n");
00527     fprintf(stderr,"     betass[ep] = %f (-) \n", betass[ep]);
00528     err++;
00529 }
00530 
00531 /*---------------------------------
00532  *  Check infiltration parameters       
00533  *---------------------------------*/
00534 if (verbose) printf("Checking infiltration parameters...\n");
00535 if( 10 > Ko[ep]*1000 || Ko[ep]*1000 > pmax[ep]*1000 ){
00536     fprintf(stderr,"   HydroCheckInput ERROR: input file line 37) \n");
00537     fprintf(stderr,"     The saturated hydraulic conductivity is out of range. \n");
00538     fprintf(stderr,"     10 < Ko < pmax \n");
00539     fprintf(stderr,"     Ko[ep] = %f (mm/day) \n", Ko[ep]*1000);
00540     fprintf(stderr,"     pmax[ep] = %f (mm/day) \n", pmax[ep]*1000);
00541     err++;
00542 }
00543 
00544 /*---------------------------
00545  *  Check number of outlets
00546  *---------------------------*/
00547 if (noutletflag != 1){
00548         if (verbose) printf("Checking number of outlets...\n");
00549         if ((noutlet > maxnoutlet || noutlet < 0) ){
00550                 fprintf(stderr,"   HydroCheckInput ERROR: input file line 40) \n");
00551                 fprintf(stderr,"         The number of outlets is not in the range \n");
00552                 fprintf(stderr,"         between 0 and 10. The filled out nr. = %d.\n",noutlet);
00553                 err++;
00554         }
00555 }
00556 
00557 /*if (noutletflag == 1){
00558         if (verbose) printf("Checking number of outlets...\n");
00559         if (noutlet == != 'r' && noutletc != 'R' && noutletc != 'u' && noutletc != 'U'){
00560                 fprintf(stderr,"   HydroCheckInput ERROR: input file line 40) \n");
00561                 fprintf(stderr,"         Hydrotrend doesn't have the right information to \n");
00562                 fprintf(stderr,"         determine the number of outlets. Value should be \n");
00563                 fprintf(stderr,"         'u' / 'U' for unknown or 'r' / 'R' for a given range \n");
00564                 fprintf(stderr,"         The filled out character is: %c",noutletc );
00565                 err++;
00566         }
00567         if (noutletc == 'r' || noutletc == 'R' ){
00568                 if (verbose) printf("Checking range of outlet numbers...\n");
00569                 if (minnoutlet < 0 || maxnoutlet > 10 || minnoutlet >= maxnoutlet){
00570                         fprintf(stderr,"   HydroCheckInput ERROR: input file line 40) \n");
00571                         fprintf(stderr,"         The minimum or maximum number of outlets is not in range \n");
00572                         fprintf(stderr,"         between 1 (min) and 10 (max). The filled out min =%d and max =%d\n",minnoutlet, maxnoutlet);
00573                         err++;
00574                 }
00575         }               
00576 }*/
00577         
00578 /*-------------------------------------------------------
00579  *  Check that outlet fractions sum to 1.0 (within .1%) 
00580  *-------------------------------------------------------*/
00581 /*
00582  if ( nooutletpctflag == 0 ){
00583         if (verbose) printf("Checking outlet fraction sum...\n");
00584         dumdbl = 0.0;
00585         for (jj=0; jj<noutlet; jj++ )
00586         dumdbl += outletpctdummy[ep][jj];
00587         if (fabs(1-dumdbl) > 0.001 ){
00588                 fprintf(stderr,"   HydroCheckInput ERROR: input file line 41) \n");
00589                 fprintf(stderr,"         The sum of the outlet fractions does not = 1. \n");
00590                 fprintf(stderr,"         sum(outletpct[ep]) = %f \n", dumdbl);
00591                 err++;
00592         }
00593  }
00594 */
00595 /*-----------------------------------------------------------------------
00596  *  Check that sediment filter percentage is not out of range (0 - 0.9) 
00597  *-----------------------------------------------------------------------*/
00598 if (verbose) printf("Checking filter fraction ...\n");
00599 if (sedfilter[ep]> 0.9 || sedfilter[ep] < 0.0){
00600     fprintf(stderr,"   HydroCheckInput ERROR: input file line 42) \n");
00601     fprintf(stderr,"     The sediment filter percentage is out of range \n");
00602     fprintf(stderr,"     0.0 > %f > 0.9 \n", sedfilter[ep]);
00603     err++;
00604 }
00605 
00606 /*---------------------------------------------------------
00607  *  Check that formula flag for Qsbar is set within range       
00608  *---------------------------------------------------------*/
00609 if (verbose) printf("Checking Qsbar formula flag ...\n");
00610 if (Qsbarformulaflag[ep] < 0 || Qsbarformulaflag[ep] > 1){
00611     fprintf(stderr,"   HydroCheckInput ERROR: input file line 43) \n");
00612     fprintf(stderr,"     Hydrotrend doesn't know which formula to use to calculate \n");
00613     fprintf(stderr,"     Qsbar. Based on Area = 1, Based on Discharge = 0\n");
00614     fprintf(stderr,"     You set the input value to %d\n",Qsbarformulaflag[ep]);
00615     err++;
00616 }
00617 
00618 
00619 /*--------------------------------------------
00620  *  Write out epoch number if errors occured
00621  *--------------------------------------------*/
00622 if (err > 0) {
00623    fprintf(stderr,"  The above errors occured in epoch %d \n",ep+1);
00624    fprintf(stderr,"  ------------------------------------ \n");
00625    ep = nepochs;
00626    }
00627 } /* end of epoch loop */
00628 
00629 /*-------------------------------------------------
00630  *  Write out general messages if errors occurred
00631  *-------------------------------------------------*/
00632 if (err > 0) {
00633    fprintf(stderr,"  %d errors occured in HydroCheckInput \n", err);
00634    fprintf(stderr,"  Many of the limits are physically imposed. \n");
00635    fprintf(stderr,"  Some are artificially imposed to limit typos. \n");
00636    fprintf(stderr,"  Be careful changing the limits in HydroCheckInput.c \n");
00637    fprintf(stderr,"  ------------------------------------------- \n");
00638 }
00639 else 
00640     if (verbose) {
00641         printf("No errors found in input values. \n");
00642         printf("\n");
00643     }
00644 
00645 return(err);
00646 }  /* end of HydroCheckInput */
00647 

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