00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <stdio.h>
00013 #include <string.h>
00014 #include "hydroinout.h"
00015 #include "hydroparams.h"
00016 #include "hydroalloc_mem.h"
00017
00018
00019
00020
00021 int hydroopenfiles()
00022 {
00023 int err, verbose,p;
00024 char dummystring[300];
00025 err = 0;
00026 verbose = 0;
00027
00028 strcpy(ffnameq,startname);
00029 strcat(ffnameq,fnameq);
00030 if (verbose) printf("Opening %s... \n",ffnameq);
00031 if ( (fidq = fopen(ffnameq,"w")) == NULL) {
00032 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the Q table file %s \n",ffnameq);
00033 err = 1;
00034 }
00035
00036 strcpy(ffnameqs,startname);
00037 strcat(ffnameqs,fnameqs);
00038 if (verbose) printf("Opening %s... \n",ffnameqs);
00039 if ( (fidqs = fopen(ffnameqs,"w")) == NULL) {
00040 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the Qs table file %s \n",ffnameqs);
00041 err = 1;
00042 }
00043
00044 strcpy(ffnametrend1,startname);
00045 strcat(ffnametrend1,fnametrend1);
00046 if (verbose) printf("Opening %s... \n",ffnametrend1);
00047 if ( (fidtrend1 = fopen(ffnametrend1,"w")) == NULL) {
00048 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the trend file %s \n",ffnametrend1);
00049 err = 1;
00050 }
00051
00052 strcpy(ffnametrend2,startname);
00053 strcat(ffnametrend2,fnametrend2);
00054 if (verbose) printf("Opening %s... \n",ffnametrend2);
00055 if ( (fidtrend2 = fopen(ffnametrend2,"w")) == NULL) {
00056 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the trend file %s \n",ffnametrend2);
00057 err = 1;
00058 }
00059
00060 strcpy(ffnametrend3,startname);
00061 strcat(ffnametrend3,fnametrend3);
00062 if (verbose) printf("Opening %s... \n",ffnametrend3);
00063 if ( (fidtrend3 = fopen(ffnametrend3,"w")) == NULL) {
00064 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the trend file %s \n",ffnametrend3);
00065 err = 1;
00066 }
00067
00068 strcpy(ffnamestat,startname);
00069 strcat(ffnamestat,fnamestat);
00070 if (verbose) printf("Opening %s... \n",ffnamestat);
00071 if ( (fidstat = fopen(ffnamestat,"w")) == NULL) {
00072 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the trend file %s \n",ffnamestat);
00073 err = 1;
00074 }
00075
00076 strcpy(ffnamedistot,startname);
00077 sprintf(dummystring,"%s",ffnamedistot);
00078 strcpy(ffnamedistot,dummystring);
00079 strcat(ffnamedistot,fnamedis);
00080 if (verbose) printf("Opening %s... \n",ffnamedistot);
00081 if ( (fiddistot = fopen(ffnamedistot,"wb")) == NULL) {
00082 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the discharge file %s \n",ffnamedistot);
00083 err = 1;
00084 }
00085
00086 if ( outletmodelflag == 1 )
00087 fiddis = allocate_1d_F( maxnoutlet );
00088
00089 if ( outletmodelflag == 1 )
00090 for (p=0; p<maxnoutlet; p++){
00091 strcpy(ffnamedis,startname);
00092 sprintf(dummystring,"%sOUTLET%d",ffnamedis,p+1);
00093 strcpy(ffnamedis,dummystring);
00094 strcat(ffnamedis,fnamedis);
00095 if (verbose) printf("Opening %s... \n",ffnamedis);
00096 if ( (fiddis[p] = fopen(ffnamedis,"wb")) == NULL) {
00097 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the discharge file %s \n",ffnamedis);
00098 err = 1;
00099 }
00100 }
00101
00102
00103
00104
00105 if( strncmp(asciioutput,ON,2) == 0){
00106 strcpy(ffidasc,startname);
00107 strcat(ffidasc,fidasc);
00108 if (verbose) printf("Opening %s... \n",ffidasc);
00109 if ( (outp = fopen(ffidasc,"w")) == NULL) {
00110 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the discharge file %s \n",ffidasc);
00111 err = 1;
00112 }
00113
00114 strcpy(ffidasc1,startname);
00115 strcat(ffidasc1,fidasc1);
00116 if (verbose) printf("Opening %s... \n",ffidasc1);
00117 if ( (outp1 = fopen(ffidasc1,"w")) == NULL) {
00118 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the discharge file %s \n",ffidasc1);
00119 err = 1;
00120 }
00121
00122 strcpy(ffidasc2,startname);
00123 strcat(ffidasc2,fidasc2);
00124 if (verbose) printf("Opening %s... \n",ffidasc2);
00125 if ( (outp2 = fopen(ffidasc2,"w")) == NULL) {
00126 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the discharge file %s \n",ffidasc2);
00127 err = 1;
00128 }
00129
00130 strcpy(ffidasc3,startname);
00131 strcat(ffidasc3,fidasc3);
00132 if (verbose) printf("Opening %s... \n",ffidasc3);
00133 if ( (outp3 = fopen(ffidasc3,"w")) == NULL) {
00134 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the discharge file %s \n",ffidasc3);
00135 err = 1;
00136 }
00137
00138 strcpy(ffidasc4,startname);
00139 strcat(ffidasc4,fidasc4);
00140 if (verbose) printf("Opening %s... \n",ffidasc4);
00141 if ( (outp4 = fopen(ffidasc4,"w")) == NULL) {
00142 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the discharge file %s \n",ffidasc4);
00143 err = 1;
00144 }
00145
00146 strcpy(ffidasc5,startname);
00147 strcat(ffidasc5,fidasc5);
00148 if (verbose) printf("Opening %s... \n",ffidasc5);
00149 if ( (outp5 = fopen(ffidasc5,"w")) == NULL) {
00150 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the discharge file %s \n",ffidasc5);
00151 err = 1;
00152 }
00153
00154 strcpy(ffidnival_ice,startname);
00155 strcat(ffidnival_ice,fidqnivalqice);
00156 if (verbose) printf("Opening %s... \n",ffidnival_ice);
00157 if ( (outpnival_ice = fopen(ffidnival_ice,"w")) == NULL) {
00158 fprintf(stderr, " HydroOpenFiles ERROR: Unable to open the discharge file %s \n",ffidnival_ice);
00159 err = 1;
00160 }
00161
00162 }
00163 return(err);
00164 }