1 #include <stdio.h> 2 3 #define BUF_SIZE 1024 4 5 /* file_io.c */ 6 void get_line(FILE * fp, char *buffer); 7 void read_input(void); 8 void write_output(void); 9 10 /* topmodel.c */ 11 void create_topidxstats(char *topidx, int ntopidxclasses, char *outtopidxstats); 12 double calculate_lambda(void); 13 void initialize(void); 14 void calculate_flows(void); 15 double calculate_efficiency(void); 16 void calculate_others(void); 17 void run_topmodel(void); 18 19 /* infiltration.c */ 20 double calculate_infiltration(int timestep, double R); 21 22 23 /* Parameters file */ 24 struct params 25 { 26 char *name; 27 double A; 28 double qs0; 29 double lnTe; 30 double m; 31 double Sr0; 32 double Srmax; 33 double td; 34 double vch; 35 double vr; 36 int infex; 37 double K0; 38 double psi; 39 double dtheta; 40 int nch; 41 /* params.nch's */ 42 double *d; 43 double *Ad; 44 }; 45 46 /* Topographic index statistics file */ 47 struct topidxstats 48 { 49 /* misc.ntopidxclasses */ 50 double *atb; 51 double *Aatb_r; 52 }; 53 54 /* Input file */ 55 struct input 56 { 57 int ntimesteps; 58 double dt; 59 /* input.ntimestep's */ 60 double *R; 61 double *Ep; 62 }; 63 64 /* File names */ 65 struct file 66 { 67 char *params; 68 char *topidxstats; 69 char *input; 70 char *output; 71 }; 72 73 /* Miscellaneous TOPMODEL variables */ 74 struct misc 75 { 76 /* Number of non-null cells */ 77 int ncells; 78 /* Number of topographic index classes */ 79 int ntopidxclasses; 80 int delay; 81 int tc; 82 int tcsub; 83 double lnTe; 84 double vch; 85 double vr; 86 double lambda; 87 double qss; 88 double qs0; 89 double Qt_peak; 90 double Qt_mean; 91 int tobs_peak; 92 int tt_peak; 93 /* params.nch's */ 94 double *tch; 95 /* misc.tcsub's */ 96 double *Ad; 97 /* input.ntimestep's */ 98 double *Qt; 99 double *qs; /* spatially constant? */ 100 double *S_mean; 101 double *f; 102 double *fex; 103 /* input.ntimestep * (misc.ntopidxclasses + 1)'s */ 104 double **qt; 105 double **qo; 106 double **qv; 107 /* input.ntimestep * misc.ntopidxclassess */ 108 double **Srz; 109 double **Suz; 110 double **S; 111 double **Ea; 112 double **ex; 113 /* Miscellaneous variables */ 114 int timestep; 115 int topidxclass; 116 }; 117 118 #ifdef _MAIN_C_ 119 #define GLOBAL 120 #else 121 #define GLOBAL extern 122 #endif 123 124 GLOBAL struct params params; 125 GLOBAL struct topidxstats topidxstats; 126 GLOBAL struct input input; 127 GLOBAL struct file file; 128 GLOBAL struct misc misc; 129 130 /* Miscellaneous variables */ 131 GLOBAL char buf[BUF_SIZE]; 132