00001
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef WATMGM_H
00028 #define WATMGM_H
00029
00030 #include "globals.h"
00031
00032 #define STEP(x) ( ((x)>=0) ? 1.0 : 0.0 )
00033 #define MAX_H_STRUCT 180
00035 #define LEFT 1
00036 #define RIGHT -1
00037
00038 #define NONE 0
00039 #define EAST 1
00040 #define SOUTH 2
00041 #define ALL 3
00042
00043 FILE *schedFile;
00044 FILE *ChanInFile;
00045 FILE *CanalOutFile;
00046 FILE *CanalOutFile_P;
00047 FILE *CanalOutFile_S;
00048 FILE *WstructOutFile;
00049 FILE *WstructOutFile_P;
00050 FILE *WstructOutFile_S;
00051 FILE *canDebugFile;
00052 FILE *CanalCellInteractDebug;
00053 FILE *F_struct_wat;
00054 FILE *F_struct_TP;
00055 FILE *F_struct_TS;
00057 int CHo;
00058 int CHANNEL_MAX_ITER;
00059 int UTM_EOrigin, UTM_NOrigin;
00060 int printchan = 0;
00061 int N_c_iter = 0;
00062 int num_cell = 0;
00063 int C_Mark = 0;
00065 float C_F;
00066 float F_ERROR;
00067 float MINDEPTH;
00069 int num_chan;
00070 int num_struct_hist;
00071 int numTPser;
00072 int numTSser;
00073 int disAggNum;
00074 int IDhist[MAX_H_STRUCT];
00077 float *MCopen;
00078 char modelFileName[300];
00081 struct Chan_segm
00082 {
00083 float x0,y0,x1,y1;
00084 struct Chan_segm *next_segm;
00085 };
00086
00088 struct Chan
00089 {
00090 int number;
00091 int levee;
00092 int roil;
00093 int roir;
00094 float depth;
00095 float width;
00096 float cond;
00097 double N;
00098 double P;
00099 double S;
00100 double N_con;
00101 double P_con;
00102 double S_con;
00103 float wat_depth;
00105 float ic_N_con;
00106 float ic_P_con;
00107 float ic_S_con;
00108 float ic_depth;
00109 float edgeMann;
00111 float length;
00112 float area;
00113 float elev_start;
00114 float elev_end;
00115 float elev_drop;
00116 float elev_slope;
00117 float elev_avg;
00118 float minVol;
00119 float seg_len;
00120 float SW_flow_coef;
00121 float SPG_flow_coef;
00122 int num_of_cells;
00123 int basin;
00124 int parent;
00125 int family;
00126 double sumHistOut;
00127 double sumHistIn;
00128 double sumRuleOut;
00129 double sumRuleIn;
00130 struct Chan_segm *segments;
00131 struct Cells *cells;
00132 struct Chan *next_in_list;
00133 };
00134 struct Chan **Chan_list;
00135
00136
00138 struct Cells
00139 {
00140 int x;
00141 int y;
00142 int ind;
00143 float length;
00144 float reachElev;
00145 float reachDistDown;
00146 struct Cells *next_cell;
00147 };
00148 struct Cells *cell_last;
00149 struct Cells *cell;
00150
00151
00153 struct Structure
00154 {
00155 int flag;
00156 int histID;
00157 int aggID;
00158 char S_nam[20];
00159 int str_cell_i;
00160 int str_cell_j;
00161 int canal_fr;
00162 int canal_to;
00163 int cell_i_fr;
00164 int cell_j_fr;
00165 int cell_i_to;
00166 int cell_j_to;
00167 float HW_stage;
00168 float TW_stage;
00169 struct Schedule *HW_graph;
00170 struct Schedule *TW_graph;
00171 int flagTWsched;
00172 int flagHWsched;
00173 int flagTWtide;
00174 int flagHWtide;
00175 int cell_i_HW;
00176 int cell_j_HW;
00177 int cell_i_TW;
00178 int cell_j_TW;
00179 int cell_HW;
00180 int cell_TW;
00181 float w_coef;
00182 double flow;
00183 int TPser;
00184 int TNser;
00185 int TSser;
00186 float TP;
00187 float TN;
00188 float TS;
00189 double conc_P;
00190 double conc_N;
00191 double conc_S;
00192 double SumFlow;
00193 double Sum_P;
00194 double Sum_N;
00195 double Sum_S;
00196 int multiOut;
00197 char SrcDest[10];
00198 struct Structure *next_in_list;
00199 };
00200 struct Structure *struct_first;
00201 struct Structure *structs;
00202
00204 struct Schedule
00205 {
00206 char schedName[30];
00207 int num_point;
00208 struct Points *graph_points;
00209 };
00210
00212 struct Points
00213 {
00214 float time;
00215 float value;
00216 };
00217
00219 struct HistData
00220 {
00221 char S_nam[20];
00222 float *arrayWat;
00223 float *arrayP;
00224 float *arrayN;
00225 float *arrayS;
00226 int aggID;
00227 int aggCnt;
00228 int flag;
00229 };
00230 struct HistData Hist_data[MAX_H_STRUCT];
00233 void CanalReInit();
00234 void Canal_Network_Init(float baseDatum, float *elev );
00235 void Run_Canal_Network(float *SWH, float *ElevMap, float *MC,
00236 float *GWV, float *poros, float *GWcond,
00237 double *NA, double *PA, double *SA,
00238 double *GNA, double *GPA, double *GSA,
00239 float *Unsat, float *sp_yield);
00240 void ReadStructures(char* name, float BASE_DATUM );
00241
00242 void ReadStructFlow_PtSer(char* name);
00243 void ReadStructTP_PtSer(char* name);
00244 void ReadStructTS_PtSer(char* name);
00245
00246 void Channel_configure(float *ElevMap, struct Chan *channel_first );
00247 void getCanalElev (int chan_n);
00248 void FluxChannel(int chan_n, float *SWH, float *ElevMap, float *MC,
00249 float *GWH, float *poros, float *GWcond, double *NA,
00250 double *PA, double *SA, double *GNA, double *GPA,
00251 double *GSA, float *Unsat, float *sp_yield);
00252 void Flows_in_Structures(float *SWH, float *GW, float *poros, float *Elev,
00253 double *NA, double *PA, double *SA );
00254 void flowData_CanCan(struct Structure *structs, struct Structure *struct_hist_start, float *SWH,
00255 double *NA, double *PA, double *SA );
00256 void flowData_CelCel(struct Structure *structs, float *SWH,
00257 double *NA, double *PA, double *SA );
00258 void flowData_CanCel(struct Structure *structs, struct Structure *struct_hist_start, float *SWH,
00259 double *NA, double *PA, double *SA );
00260 void flowData_CelCan(struct Structure *structs, float *SWH,
00261 double *NA, double *PA, double *SA );
00262 void flowCalc_CanCan(struct Structure *structs, float *SWH, float *GW,
00263 float *poros, float *Elev, double *NA, double *PA, double *SA );
00264 void flowCalc_CelCel(struct Structure *structs, float *SWH, float *Elev, double *NA, double *PA, double *SA );
00265 void flowCalc_CanCel(struct Structure *structs, float *SWH, float *GW,
00266 float *poros, float *Elev, double *NA, double *PA, double *SA );
00267 void flowCalc_CelCan(struct Structure *structs, float *SWH, float *GW,
00268 float *poros, float *Elev, double *NA, double *PA, double *SA );
00269
00270 float f_Manning(float delta, float SWater, float SW_coef );
00271 float f_Ground(float dh, float height, float GW_coef, float l_Length );
00272 float GetGraph(struct Schedule *graph, float x );
00273
00274 struct Chan *ReadChanStruct(char* filename );
00275 struct Cells *MarkCell(int x, int y, int index, float length,
00276 struct Cells *cell, int ch_number, int levee,
00277 int xm, int ym, int c_num, int *marked, float distTot );
00278 struct Schedule *Read_schedule(char *sched_name, char *filename, float BASE_DATUM );
00279 int NumScheds=0;
00280
00281 int Wrdcmp(char *s, char *t );
00282 float UTM2kmx(double UTM );
00283 float UTM2kmy(double UTM );
00284
00285
00286
00287
00288
00289 extern char *ModelPath, *OutputPath, *ProjName;
00290 extern char modelName[20], modelVers[10];
00291
00292 extern double julday(int mon, int day, int year, int h, int mi, double se);
00293 extern void init_pvar(VOIDP Map, UCHAR* mask, unsigned char Mtype,float iv);
00294 extern VOIDP nalloc(unsigned mem_size, const char var_name[]);
00295 extern char *Scip(char *s, char SYM );
00296 extern int isInteger(char *target_str);
00297 extern int isFloat(char *target_str);
00298 extern float FMOD( float x, float y);
00299 extern int Round(float x);
00300
00301
00302 extern char SimAlt[20], SimModif[20];
00303 extern double Jdate_init, Jdate_end;
00304 extern int PORnumday;
00305 extern float can_Intvl;
00306 extern int canPrint;
00307
00308
00309 extern unsigned char *HAB;
00310 extern int *basn;
00311 extern float GP_DetentZ, GP_MinCheck, GP_SLRise;
00312 extern float GP_mannDepthPow, GP_mannHeadPow, GP_calibGWat;
00313
00314
00315 extern float Flux_SWcells(int i0,int i1,int j0,int j1,
00316 float *SWater,float *Elevation,float *MC);
00317 extern void Flux_SWstuff(int i0,int i1,int j0,int j1, float Flux,
00318 float *SURFACE_WAT, double *STUF1, double *STUF2, double *STUF3, float *SfWat_vel_day);
00319
00320
00321 extern int numBasn;
00322 extern basnDef **basn_list;
00323 extern basnDef *basins;
00324
00325
00326 extern double *TOT_VOL_CAN;
00327
00328
00329 extern double *VOL_IN_STR, *VOL_IN_OVL, *VOL_IN_SPG, *VOL_IN_GW;
00330 extern double *VOL_OUT_STR, *VOL_OUT_OVL, *VOL_OUT_SPG, *VOL_OUT_GW;
00331
00332 extern double *TOT_P_CAN;
00333
00334
00335 extern double *P_IN_STR, *P_IN_OVL, *P_IN_SPG, *P_IN_GW;
00336 extern double *P_OUT_STR, *P_OUT_OVL, *P_OUT_SPG, *P_OUT_GW;
00337
00338 extern double *TOT_S_CAN;
00339
00340
00341 extern double *S_IN_STR, *S_IN_OVL, *S_IN_SPG, *S_IN_GW;
00342 extern double *S_OUT_STR, *S_OUT_OVL, *S_OUT_SPG, *S_OUT_GW;
00343
00344 #endif