21 for(
int i=0; i < sCheck.size();i++){
22 if(!isdigit(sCheck[i]) && sCheck[i] !=
'e' && sCheck[i] !=
'E' 23 && sCheck[i] !=
'.' && sCheck[i] !=
'+' && sCheck[i] !=
'-'){
44 std::cout << comline.
LongUsage() << std::endl;
49 << std::endl << comline.
ShortUsage() << std::endl;
56 std::ostream *Out = &std::cout;
60 std::string OutFileName(comline.
GetOption(
"output"));
61 std::vector<std::string> FileNames = comline.
GetArgs();
62 std::string sverb(comline.
GetOption(
"verblevel"));
63 std::string sTolerance(comline.
GetOption(
"tolerance"));
64 std::string sNoBlank(comline.
GetOption(
"blank"));
71 if(sverb !=
".true."){
72 std::istringstream Istr(sverb);
81 if(!comline.
GetOption(
"numbers").empty()){
87 double tolerance = 1.0e-12;
88 if(!sTolerance.empty()){
90 if(sTolerance !=
".true."){
91 std::istringstream Istr(sTolerance);
101 bool noBlank =
false;
102 if(!sNoBlank.empty())
106 std::cout <<
"ix::DiffDataFiles> Starting up with the following environment:" << std::endl
107 <<
"ix::DiffDataFiles> FileName1 = " << FileNames[0] << std::endl
108 <<
"ix::DiffDataFiles> FileName2 = " << FileNames[1] << std::endl
109 <<
"ix::DiffDataFiles> Verbosity = " << verblevel << std::endl
110 <<
"ix::DiffDataFiles> OutFileName = " << OutFileName << std::endl
111 <<
"ix::DiffDataFiles> IgnoreBlank = " << noBlank << std::endl
112 <<
"ix::DiffDataFiles> NumbersOnly = " << numbers << std::endl
113 <<
"ix::DiffDataFiles> Tolerance = ";
115 std::cout << tolerance;
116 std::cout << std::endl;
120 bool keep_outfile =
false;
121 if(!OutFileName.empty()){
123 Ouf.open(OutFileName.c_str());
125 std::cout <<
"ix::DiffDataFiles> Error: Could not open output file, " 126 << OutFileName <<
" for output. Exiting (fail)." << std::endl;
133 std::ifstream InFile1;
134 std::ifstream InFile2;
136 InFile1.open(FileNames[0].c_str());
138 std::cout <<
"ix::DiffDataFiles> Error: Could not open input file, " 139 << FileNames[0] <<
" for reading. Exiting (fail)." << std::endl;
142 InFile2.open(FileNames[1].c_str());
144 std::cout <<
"ix::DiffDataFiles> Error: Could not open input file, " 145 << FileNames[1] <<
" for reading. Exiting (fail)." << std::endl;
150 std::string line1,line2, string1, string2, printString1=
"", printString2=
"";
151 std::stringstream ss1, ss2, ssPrint1, ssPrint2;
153 bool lineDiff =
false, numDiff =
false;
154 *Out <<
"File line: content" << std::endl;
155 while(!InFile1.eof() || !InFile2.eof()){
158 std::getline(InFile1,line1);
160 std::getline(InFile2,line2);
162 if(!noBlank && !useTol){
174 while(ss1 >> string1){
176 if(string1 != string2){
183 std::stringstream convert;
191 if(fabs(val1 - val2) > tolerance)
194 ssPrint1 << std::scientific << std::setw(20) << val1 <<
" ";
195 ssPrint2 << std::scientific << std::setw(20) << val2 <<
" ";
199 if(!useTol || numDiff){
202 printString1 +=
'[' + string1 +
"]";
203 printString2 +=
'[' + string2 +
"]";
204 ssPrint1 << std::setw(20) << printString1 <<
" ";
205 ssPrint2 << std::setw(20) << printString2 <<
" ";
209 ssPrint1 << std::setw(20) << string1 <<
" ";
210 ssPrint2 << std::setw(20) << string2 <<
" ";
212 string1 = string2 =
"";
213 printString1 = printString2 =
"";
216 while(ss2 >> string2){
219 printString1 +=
'[' + string1 +
"]";
220 printString2 +=
'[' + string2 +
"]";
221 ssPrint1 << std::setw(20) << printString1 <<
" ";
222 ssPrint2 << std::setw(20) << printString2 <<
" ";
226 printString1 = printString2 = string2 =
"";
229 *Out << std::setw(4) << std::right <<
"1" <<
" " << std::setw(8)
230 << lineNo <<
": " << ssPrint1.str() << std::endl
231 << std::setw(4) << std::right <<
"2" <<
" " << std::setw(8)
232 << lineNo <<
": " << ssPrint2.str() << std::endl;
244 if(InFile1.eof() != InFile2.eof()){
256 int main(
int argc,
char *argv[])
int ProcessOptions()
Processes all command line tokens.
std::string ErrorReport()
Error reporting.
std::string GetOption(const char &s)
Get the value of an option.
void Initialize()
virtual function for program specific Initialization.
Defines MPI-specific parallel global and program classes.
Implements a command-line interface for ensuring that two data files are consistent.
std::vector< std::string > GetArgs() const
Argument access.
bool isNumber(std::string sCheck)
int DiffDataFiles(int argc, char *argv[])
Compare two data files within a given tolerance.
Unix System Tools interface.
Implementation of stream object for Unix file descriptors.
std::string LongUsage()
Generate long usage string.
ComLine object for test running utility.
int main(int argc, char *argv[])
std::string ShortUsage()
Generate short usage string.