Skip to content

Commit dcff0b8

Browse files
author
Joe Hamman
committed
Changes to directory structure in git repository, also added git tools directory
1 parent cf69e6a commit dcff0b8

File tree

285 files changed

+128583
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+128583
-0
lines changed

readme.txt

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

LAKE.h renamed to src/LAKE.h

File renamed without changes.

Makefile renamed to src/Makefile

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

global.h renamed to src/global.h

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

nrerror.c renamed to src/nrerror.c

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

penman.c renamed to src/penman.c

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

runoff.c renamed to src/runoff.c

File renamed without changes.
File renamed without changes.

snow.h renamed to src/snow.h

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

svp.c renamed to src/svp.c

File renamed without changes.
File renamed without changes.

vicNl.c renamed to src/vicNl.c

File renamed without changes.

vicNl.h renamed to src/vicNl.h

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

wgtpar.h renamed to src/wgtpar.h

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The following programs are found in the basin_prep.tgz tarball.
2+
3+
multiply_basin_param.c
4+
5+
This program was written to read a runfile mask and multiply
6+
parameters in the activated grid cells by the given value.
7+
8+
set_basin_param.c
9+
10+
This program was written to read a runfile mask and replaces
11+
parameters in the activated grid cells with the given value.
12+
13+
sum_basin_param.c
14+
15+
This program was written to read a runfile mask and computes
16+
the sum and average parameter values for the activated grid
17+
cells.
18+
19+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include <stdio.h>
2+
#include <math.h>
3+
4+
main(int argc, char *argv[]) {
5+
/****************************************************************
6+
multiply_basin_param.c Keith Cherkauer August 14, 1998
7+
8+
This program was written to read a runfile mask and multiply
9+
parameters in the activated grid cells by the given value.
10+
****************************************************************/
11+
12+
FILE *frun, *foldparam, *fnewparam;
13+
int i, j, ncol, nrow;
14+
int runflag;
15+
char tmpstr[512];
16+
float multfact;
17+
float param;
18+
19+
if(argc!=5) {
20+
fprintf(stderr,"Usage: %s <run mask> <old param file> <new param file> <factor>\n",argv[0]);
21+
fprintf(stderr,"\tThis program multiplies the parameters for the activated grid cells in the old parameter file by the given value, and writes the results to the new parameter file. Activated cells have values other than 0 in the run mask file.\n");
22+
exit(0);
23+
}
24+
25+
if((frun=fopen(argv[1],"r"))==NULL) {
26+
fprintf(stderr,"ERROR: Unable to open %s\n",argv[1]);
27+
exit(0);
28+
}
29+
30+
if((foldparam=fopen(argv[2],"r"))==NULL) {
31+
fprintf(stderr,"ERROR: Unable to open %s\n",argv[2]);
32+
exit(0);
33+
}
34+
35+
if((fnewparam=fopen(argv[3],"w"))==NULL) {
36+
fprintf(stderr,"ERROR: Unable to open %s\n",argv[3]);
37+
exit(0);
38+
}
39+
40+
multfact = atof(argv[4]);
41+
42+
/** Skip and copy header **/
43+
for(i=0;i<6;i++) {
44+
fgets(tmpstr,512,frun);
45+
fgets(tmpstr,512,foldparam);
46+
if(i==0) sscanf(tmpstr,"%*s %i",&ncol);
47+
if(i==1) sscanf(tmpstr,"%*s %i",&nrow);
48+
fprintf(fnewparam,"%s",tmpstr);
49+
}
50+
51+
for(i=0;i<nrow;i++) {
52+
for(j=0;j<ncol;j++) {
53+
fscanf(frun,"%i",&runflag);
54+
fscanf(foldparam,"%f",&param);
55+
if(runflag!=0) {
56+
fprintf(fnewparam,"%f",param*multfact);
57+
}
58+
else {
59+
fprintf(fnewparam,"%f",param);
60+
}
61+
if(j==ncol-1) fprintf(fnewparam,"\n");
62+
else fprintf(fnewparam," ");
63+
}
64+
}
65+
}
66+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include <stdio.h>
2+
#include <math.h>
3+
4+
main(int argc, char *argv[]) {
5+
/****************************************************************
6+
set_basin_param.c Keith Cherkauer August 14, 1998
7+
8+
This program was written to read a runfile mask and replaces
9+
parameters in the activated grid cells with the given value.
10+
****************************************************************/
11+
12+
FILE *frun, *foldparam, *fnewparam;
13+
int i, j, ncol, nrow;
14+
int runflag;
15+
char tmpstr[512];
16+
float value;
17+
float param;
18+
19+
if(argc!=5) {
20+
fprintf(stderr,"Usage: %s <run mask> <old param file> <new param file> <value>\n",argv[0]);
21+
fprintf(stderr,"\tThis program sets the activated grid cells in the old parameter file to the given value, and writes the results to the new parameter file. Activated cells have values other than 0 in the run mask file.\n");
22+
exit(0);
23+
}
24+
25+
if((frun=fopen(argv[1],"r"))==NULL) {
26+
fprintf(stderr,"ERROR: Unable to open %s\n",argv[1]);
27+
exit(0);
28+
}
29+
30+
if((foldparam=fopen(argv[2],"r"))==NULL) {
31+
fprintf(stderr,"ERROR: Unable to open %s\n",argv[2]);
32+
exit(0);
33+
}
34+
35+
if((fnewparam=fopen(argv[3],"w"))==NULL) {
36+
fprintf(stderr,"ERROR: Unable to open %s\n",argv[3]);
37+
exit(0);
38+
}
39+
40+
value = atof(argv[4]);
41+
42+
/** Skip and copy header **/
43+
for(i=0;i<6;i++) {
44+
fgets(tmpstr,512,frun);
45+
fgets(tmpstr,512,foldparam);
46+
if(i==0) sscanf(tmpstr,"%*s %i",&ncol);
47+
if(i==1) sscanf(tmpstr,"%*s %i",&nrow);
48+
fprintf(fnewparam,"%s",tmpstr);
49+
}
50+
51+
for(i=0;i<nrow;i++) {
52+
for(j=0;j<ncol;j++) {
53+
fscanf(frun,"%i",&runflag);
54+
fscanf(foldparam,"%f",&param);
55+
if(runflag!=0) {
56+
fprintf(fnewparam,"%f",value);
57+
}
58+
else {
59+
fprintf(fnewparam,"%f",param);
60+
}
61+
if(j==ncol-1) fprintf(fnewparam,"\n");
62+
else fprintf(fnewparam," ");
63+
}
64+
}
65+
}
66+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#include <stdio.h>
2+
#include <math.h>
3+
4+
main(int argc, char *argv[]) {
5+
/****************************************************************
6+
sum_basin_param.c Keith Cherkauer August 14, 1998
7+
8+
This program was written to read a runfile mask and computes
9+
the sum and average parameter values for the activated grid
10+
cells.
11+
12+
****************************************************************/
13+
14+
FILE *frun, *fparam;
15+
int i, j, ncol, nrow;
16+
int runflag;
17+
int N;
18+
char tmpstr[512];
19+
float factor;
20+
float param;
21+
float sum;
22+
23+
if(argc!=4) {
24+
fprintf(stderr,"Usage: %s <run mask> <param file> <factor>\n",argv[0]);
25+
fprintf(stderr,"\tThis program sums the parameters divided by factor in the activated grid cells, and prints the results to stdout. Activated cells have values other than 0 in the run mask file.\n");
26+
exit(0);
27+
}
28+
29+
if((frun=fopen(argv[1],"r"))==NULL) {
30+
fprintf(stderr,"ERROR: Unable to open %s\n",argv[1]);
31+
exit(0);
32+
}
33+
34+
if((fparam=fopen(argv[2],"r"))==NULL) {
35+
fprintf(stderr,"ERROR: Unable to open %s\n",argv[2]);
36+
exit(0);
37+
}
38+
39+
factor = atof(argv[3]);
40+
41+
/** Skip and copy header **/
42+
for(i=0;i<6;i++) {
43+
fgets(tmpstr,512,frun);
44+
fgets(tmpstr,512,fparam);
45+
if(i==0) sscanf(tmpstr,"%*s %i",&ncol);
46+
if(i==1) sscanf(tmpstr,"%*s %i",&nrow);
47+
}
48+
49+
sum = 0.;
50+
N = 0;
51+
for(i=0;i<nrow;i++) {
52+
for(j=0;j<ncol;j++) {
53+
fscanf(frun,"%i",&runflag);
54+
fscanf(fparam,"%f",&param);
55+
if(runflag!=0) {
56+
sum += param / factor;
57+
N ++;
58+
}
59+
}
60+
}
61+
62+
fprintf(stdout,"Parameter Sum = %f\nParameter Average = %f\n",
63+
sum,sum/(float)N);
64+
65+
}
66+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/csh
2+
3+
# This script is designed to change all of the files associated with
4+
# running the model for the current subbasin. The parameters calibrated
5+
# are b_infilt, Ws, Ds, depth2, and depth3.
6+
7+
set BASINNAME = wis
8+
set CALIBDIR = ARCINFO/
9+
set CALIBPREFIX = WIS_OPTI/
10+
11+
if ( $5 != "" ) then
12+
13+
cd $CALIBDIR
14+
15+
set_basin_param.linux $BASINNAME"_run.asc" b_infilt.upm $CALIBPREFIX/b_infilt.upm $1
16+
17+
set_basin_param.linux $BASINNAME"_run.asc" Ds.upm $CALIBPREFIX/Ds.upm $2
18+
19+
set_basin_param.linux $BASINNAME"_run.asc" Ws.upm $CALIBPREFIX/Ws.upm $3
20+
21+
set_basin_param.linux $BASINNAME"_run.asc" depth2.upm $CALIBPREFIX/depth2.upm $4
22+
23+
set_basin_param.linux $BASINNAME"_run.asc" depth3.upm $CALIBPREFIX/depth3.upm $5
24+
25+
cd ..
26+
27+
else
28+
29+
echo "Usage: $0 <b_infilt> <Ds> <Ws> <depth2> <depth3>"
30+
31+
endif
32+
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <math.h>
4+
5+
/** Define the units conversion factor between the simulated
6+
discharge (cfs), and the observed dischare (???) **/
7+
#define sim_to_obs 1
8+
9+
/** Define the conversion factor from observed simulation rate to total
10+
volume **/
11+
12+
13+
main(int argc, char *argv[]) {
14+
/************************************************************************
15+
compute_R2.c Keith Cherkauer January 10, 1999
16+
17+
This program was written to comute the R^2 value for the current
18+
simulated daily discharge.
19+
20+
************************************************************************/
21+
22+
FILE *fvic, *fobs, *fout;
23+
int startrec, endrec;
24+
int Nrecs, i;
25+
float basinfactor;
26+
float meanobs;
27+
float meanvic;
28+
float Rsqr;
29+
float tmpdata;
30+
float *vicdata;
31+
float *obsdata;
32+
float vicflow, obsflow;
33+
float numsum, densum;
34+
35+
if(argc!=7) {
36+
fprintf(stderr,"Usage: %s <VIC discharge> <observed discharge> <start rec> <end rec> <basin size factor> <R2 outfile>\n",argv[0]);
37+
exit(0);
38+
}
39+
40+
if((fvic=fopen(argv[1],"r"))==NULL) {
41+
fprintf(stderr,"ERROR: Unable to open VIC simulation file %s.\n",argv[1]);
42+
exit(1);
43+
}
44+
45+
if((fobs=fopen(argv[2],"r"))==NULL) {
46+
fprintf(stderr,"ERROR: Unable to open observed flow file %s.\n",argv[2]);
47+
exit(2);
48+
}
49+
50+
if((fout=fopen(argv[6],"w"))==NULL) {
51+
fprintf(stderr,"ERROR: Unable to open output file %s.\n","R2.out");
52+
exit(1);
53+
}
54+
55+
startrec = atoi(argv[3]);
56+
endrec = atoi(argv[4]);
57+
basinfactor = atof(argv[5]);
58+
59+
/** Process Data **/
60+
Nrecs = endrec - startrec + 1;
61+
vicdata = (float*)calloc(Nrecs,sizeof(float));
62+
obsdata = (float*)calloc(Nrecs,sizeof(float));
63+
64+
for(i=0;i<startrec;i++) {
65+
fscanf(fvic,"%*s %f\n",&tmpdata);
66+
fscanf(fobs,"%*s %f\n",&tmpdata);
67+
}
68+
69+
meanvic = meanobs = 0;
70+
vicflow = obsflow = 0;
71+
for(i=0;i<Nrecs;i++) {
72+
fscanf(fvic,"%*s %f\n",&vicdata[i]);
73+
fscanf(fobs,"%*s %f\n",&obsdata[i]);
74+
75+
/* Convert Simulated Flow to Match Observed */
76+
vicdata[i] *= sim_to_obs;
77+
78+
vicdata[i] *= basinfactor;
79+
meanvic += vicdata[i];
80+
meanobs += obsdata[i];
81+
/* Convert discharge from cubic feet per sec to cubic meters
82+
(per time step) to look at total flow volumes */
83+
vicflow += vicdata[i] * 0.02831685 * 24. * 60. * 60.;
84+
obsflow += obsdata[i] * 0.02831685 * 24. * 60. * 60.;
85+
}
86+
meanvic /= (float)Nrecs;
87+
meanobs /= (float)Nrecs;
88+
vicflow /= 1.e9;
89+
obsflow /= 1.e9;
90+
91+
numsum = densum = 0;
92+
for(i=0;i<Nrecs;i++) {
93+
numsum += pow( obsdata[i] - vicdata[i], 2. );
94+
densum += pow( obsdata[i] - meanobs, 2. );
95+
}
96+
Rsqr = -1. * ( 1. - ( numsum / densum) );
97+
98+
fprintf(fout,"Total observed flow = %f km^3.\n",obsflow);
99+
fprintf(fout,"Total simulated flow = %f km^3.\n",vicflow);
100+
fprintf(fout,"Mean observed flow = %f cfs.\n",meanobs);
101+
fprintf(fout,"Mean simulated flow = %f cfs.\n",meanvic);
102+
fprintf(fout,"R^2 model error = %f.\n",Rsqr);
103+
104+
fprintf(stdout,"%f\n", Rsqr);
105+
106+
free((char*)vicdata);
107+
free((char*)obsdata);
108+
109+
fclose(fvic);
110+
fclose(fobs);
111+
fclose(fout);
112+
113+
}

0 commit comments

Comments
 (0)