00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <stdio.h>
00014 #include <math.h>
00015 #include <ctype.h>
00016 #include <time.h>
00017
00018
00019
00020
00021 #define rho_water (1000.0)
00022 #define rho_sed (2670.0)
00023
00024
00025
00026
00027 #define PI (3.1415926535)
00028
00029
00030
00031
00032 #define dTOs (86400.0)
00033 #define degTOr (1.745329252e-2)
00034
00035
00036
00037
00038 #define FLAflag (9999)
00039 #define TMLEN (100)
00040 #define DAYSINYEAR (365)
00041
00042
00043
00044
00045 #define sq(a) ((a)*(a))
00046 #define mn(a,b) ((a)<(b)?(a):(b))
00047 #define mx(a,b) ((a)>(b)?(a):(b))
00048 #define rnd(a) ((fmod(a,1.0)>(0.5)?((double)((int)(a)+1)):((double)((int)(a)))))
00049
00050
00051
00052
00053 #define maxepoch (110)
00054 int nepochs, ep;
00055 int yr, total_yr;
00056 int nyears[maxepoch], syear[maxepoch];
00057 int tblstart[maxepoch], tblend[maxepoch];
00058 char timestep[2];
00059
00060
00061
00062
00063 #define maxgrn (10)
00064 int ngrain;
00065 double grainpct[maxgrn][maxepoch];
00066
00067
00068
00069
00070 int eventcounter;
00071 long *numberday;
00072 int eventsperyear;
00073 int eventsnr[maxepoch];
00074 double floodvalue[maxepoch];
00075 int floodcounter;
00076 int eventnrflag;
00077
00078
00079
00080
00081 int noutlet;
00082 int minnoutlet;
00083 int maxnoutlet;
00084 double ***outletpct;
00085 double sedfilter[maxepoch];
00086 double totpercentageQ[maxepoch];
00087 double **outletpcttotevents;
00088 int *nroutlets;
00089 int outletmodelflag;
00090 int nooutletpctflag;
00091 int noutletflag;
00092 int steadyoutletpctflag;
00093 double **outletpctdummy;
00094
00095
00096
00097
00098 double threshbed[maxepoch];
00099 #define alphabed (0.9)
00100 #define trneff (0.1)
00101 #define anglerep (32.21)
00102 double *C;
00103
00104
00105
00106
00107 double depcof[maxepoch], deppow[maxepoch];
00108 double velcof[maxepoch], velpow[maxepoch];
00109 double widcof[maxepoch], widpow[maxepoch];
00110 double avgvel[maxepoch];
00111 double rslope[maxepoch];
00112
00113
00114
00115
00116 double elevbinsize;
00117 int nhypts[maxepoch];
00118 double *areabins;
00119 double *elevbins;
00120 double hypspow[maxepoch];
00121 double **hypsarea;
00122 double **hypselev;
00123 double basinlength[maxepoch];
00124 double maxalt[maxepoch];
00125 double totalarea[maxepoch];
00126 double basin_relief[maxepoch];
00127 double basin_area[maxepoch];
00128
00129
00130
00131
00132 int *distbins;
00133 int exceedflood;
00134 int floodtry;
00135 double maxflood;
00136 double Rvol[maxepoch];
00137 double Ralt[maxepoch];
00138 double Rarea[maxepoch];
00139 double TE[maxepoch];
00140 double TEsubbasin[maxepoch];
00141 char Rparamcheck[maxepoch];
00142 double alphac[maxepoch];
00143 double betac[maxepoch];
00144 double rhosed[maxepoch];
00145 double rhowater[maxepoch];
00146
00147
00148
00149
00150 double alphag[maxepoch];
00151 double betag[maxepoch];
00152 double pcr[maxepoch];
00153 double pmax[maxepoch];
00154 double MPrain;
00155
00156
00157
00158
00159 double Ko[maxepoch];
00160 double alphass[maxepoch];
00161 double betass[maxepoch];
00162 double gwinitial;
00163 double gwlast;
00164 double gwmin[maxepoch], gwmax[maxepoch];
00165 double percentgw[maxepoch];
00166 double alphagwe[maxepoch];
00167 double betagwe[maxepoch];
00168
00169
00170
00171
00172 double dryevap[maxepoch];
00173 double Meltrate[maxepoch];
00174 double lapserate[maxepoch];
00175 double Msnowstart, Msnowend;
00176 double MPnival;
00177
00178
00179
00180
00181 int ELAindex;
00182 double bigg, smallg, lastarea, initiallastarea;
00183 double ela, lastela, initiallastela;
00184 double Gmass;
00185 double MPglacial;
00186 double bethaexpo, bethaglacier;
00187
00188
00189
00190
00191 #define maxran 2200
00192 #define INIT_RAN_NUM_SEED (850)
00193 int nran;
00194 double *ranarray;
00195 double rmin, rmax;
00196
00197
00198
00199
00200 #define masscheck (1e-5)
00201 double maxerr;
00202 double totalmass;
00203
00204
00205
00206
00207 double lat, lon;
00208 double alpha3, alpha4, alpha5;
00209 double alpha6, alpha7, alpha8;
00210 double k1,k2;
00211 int Qsbarformulaflag[maxepoch];
00212
00213
00214
00215
00216 int raindatafile;
00217
00218
00219
00220
00221 int setstartmeanQandQs;
00222
00223
00224
00225
00226 #define MAXCHAR (5)
00227 #define ON "ON"
00228 #define OFF "OFF"
00229 char asciioutput[MAXCHAR];
00230
00231
00232
00233
00234 #define DUMMY "HYDRO"
00235 char startname[80];
00236 char directory[100];
00237 char chrdump[80];
00238 char commandlinearg[2][20];
00239 int webflag;
00240 int globalparflag;
00241 int lapserateflag, velpowflag, widpowflag;
00242
00243 double *Qgrandtotaltotoutlet, Qgrandtotaltot, **Qdummy, **Qgrandtotalperepoch;
00244 double Qsgrandtotaltot, *Qsgrandtotaltotoutlet, Qpeakmax, TEtot, yeartot;
00245 double Qsoutletdummy;
00246 double **Qsbartotoutlet;
00247