00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <stdio.h>
00012 #include <stdlib.h>
00013 #include "hydroinout.h"
00014 #include "hydroparams.h"
00015 #define NROWS (500)
00016 #define NCOLS (130)
00017
00018
00019
00020
00021 int hydrosecurityinputcheck()
00022 {
00023
00024
00025
00026
00027 int jj, ii, err, verbose, i;
00028 char x;
00029 err = 0;
00030 verbose = 0;
00031 i=0;
00032
00033
00034
00035 if ( (fidinput = fopen(ffnameinput,"r")) == NULL) {
00036 fprintf(stderr, " HydroSecurityinputcheck.c ERROR: Unable to open the input file %s \n",ffnameinput);
00037 fprintf(stderr, " Make sure the input file name is all in capitals\n");
00038 fprintf(stderr, " program aborted \n");
00039 exit(1);
00040 }
00041 if ( (fidhyps[i] = fopen(ffnamehyps,"r")) == NULL) {
00042 fprintf(stderr, " openfiles HydroSecurityinputcheck.c ERROR: Unable to open the hypsometeric integral data file %s \n", ffnamehyps);
00043 fprintf(stderr, " Make sure the input file name is all in capitals\n");
00044 fprintf(stderr, " program aborted \n");
00045 exit(1);
00046 }
00047 if ((fidinputgw_r = fopen(ffnameinputgw_r, "r")) == NULL){
00048 fprintf(stderr, " HydroSecurityinputcheck.c MESSAGE: Unable to open input file %s \n",ffnameinputgw_r);
00049 fprintf(stderr, " Hydrotrend will generate it's own climate values based on\n");
00050 fprintf(stderr, " line 14-25 of the input values in the input file.\n\n");
00051 raindatafile = 0;
00052 }
00053
00054
00055
00056
00057
00058 for( jj=0; jj<NROWS; jj++ )
00059 for (ii=0; ii<NCOLS; ii++){
00060 fscanf( fidinput, "%c", &x);
00061 if (x != 'a' && x != 'b' && x != 'c' && x != 'd' && x != 'e' && x != 'f' && x != 'g' && x != 'h'
00062 && x != 'i' && x != 'j' && x != 'k' && x != 'l' && x != 'm' && x != 'n' && x != 'o' && x != 'p'
00063 && x != 'q' && x != 'r' && x != 's' && x != 't' && x != 'u' && x != 'v' && x != 'w' && x != 'x'
00064 && x != 'y' && x != 'z'
00065 && x != '.' && x != '/' && x != '(' && x != ')' && x != ':' && x != ';' && x != '-' && x != '_'
00066 && x != '+' && x != '=' && x != ' ' && x != ',' && x != '^' && x != '>' && x != '%'
00067 && x != '\r' && x != '\t' && x != '\0' && x != '\n'
00068 && x != 'A' && x != 'B' && x != 'C' && x != 'D' && x != 'E' && x != 'F' && x != 'G' && x != 'H'
00069 && x != 'I' && x != 'J' && x != 'K' && x != 'L' && x != 'M' && x != 'N' && x != 'O' && x != 'P'
00070 && x != 'Q' && x != 'R' && x != 'S' && x != 'T' && x != 'U' && x != 'V' && x != 'W' && x != 'X'
00071 && x != 'Y' && x != 'Z'
00072 && x != '1' && x != '2' && x != '3' && x != '4' && x != '5' && x != '6'
00073 && x != '7' && x != '8' && x != '9' && x != '0'){
00074 chrdump[err] = x;
00075 err++;
00076 }
00077 }
00078
00079 for( jj=0; jj<NROWS; jj++ )
00080 for (ii=0; ii<NCOLS; ii++){
00081 fscanf( fidhyps[i], "%c", &x);
00082 if (x != 'a' && x != 'b' && x != 'c' && x != 'd' && x != 'e' && x != 'f' && x != 'g' && x != 'h'
00083 && x != 'i' && x != 'j' && x != 'k' && x != 'l' && x != 'm' && x != 'n' && x != 'o' && x != 'p'
00084 && x != 'q' && x != 'r' && x != 's' && x != 't' && x != 'u' && x != 'v' && x != 'w' && x != 'x'
00085 && x != 'y' && x != 'z'
00086 && x != '.' && x != '/' && x != '(' && x != ')' && x != ':' && x != ';' && x != '-' && x != '_'
00087 && x != '+' && x != '=' && x != ' ' && x != ',' && x != '^' && x != '>' && x != '%'
00088 && x != '\r' && x != '\t' && x != '\0' && x != '\n'
00089 && x != 'A' && x != 'B' && x != 'C' && x != 'D' && x != 'E' && x != 'F' && x != 'G' && x != 'H'
00090 && x != 'I' && x != 'J' && x != 'K' && x != 'L' && x != 'M' && x != 'N' && x != 'O' && x != 'P'
00091 && x != 'Q' && x != 'R' && x != 'S' && x != 'T' && x != 'U' && x != 'V' && x != 'W' && x != 'X'
00092 && x != 'Y' && x != 'Z'
00093 && x != '1' && x != '2' && x != '3' && x != '4' && x != '5' && x != '6'
00094 && x != '7' && x != '8' && x != '9' && x != '0'){
00095 chrdump[err] = x;
00096 err++;
00097 }
00098 }
00099 if (raindatafile == 1)
00100 for( jj=0; jj<NROWS; jj++ )
00101 for (ii=0; ii<NCOLS; ii++){
00102 fscanf( fidinputgw_r, "%c", &x);
00103 if (x != 'a' && x != 'b' && x != 'c' && x != 'd' && x != 'e' && x != 'f' && x != 'g' && x != 'h'
00104 && x != 'i' && x != 'j' && x != 'k' && x != 'l' && x != 'm' && x != 'n' && x != 'o' && x != 'p'
00105 && x != 'q' && x != 'r' && x != 's' && x != 't' && x != 'u' && x != 'v' && x != 'w' && x != 'x'
00106 && x != 'y' && x != 'z'
00107 && x != '.' && x != '/' && x != '(' && x != ')' && x != ':' && x != ';' && x != '-' && x != '_'
00108 && x != '+' && x != '=' && x != ' ' && x != ',' && x != '^' && x != '>' && x != '%'
00109 && x != '[' && x != ']'
00110 && x != '\r' && x != '\t' && x != '\0' && x != '\n'
00111 && x != 'A' && x != 'B' && x != 'C' && x != 'D' && x != 'E' && x != 'F' && x != 'G' && x != 'H'
00112 && x != 'I' && x != 'J' && x != 'K' && x != 'L' && x != 'M' && x != 'N' && x != 'O' && x != 'P'
00113 && x != 'Q' && x != 'R' && x != 'S' && x != 'T' && x != 'U' && x != 'V' && x != 'W' && x != 'X'
00114 && x != 'Y' && x != 'Z'
00115 && x != '1' && x != '2' && x != '3' && x != '4' && x != '5' && x != '6'
00116 && x != '7' && x != '8' && x != '9' && x != '0'){
00117 chrdump[err] = x;
00118 err++;
00119 }
00120 }
00121
00122
00123
00124
00125 rewind(fidinput);
00126 rewind(fidhyps[i]);
00127 if (raindatafile == 1)
00128 fclose(fidinputgw_r);
00129 return(err);
00130 }