18 int main(
int argc,
char** argv )
21 std::string file1(
"NE4pg2_imp/run/OcnCplAftMm25.h5m" );
22 std::string file2(
"NE4pg2_imp2/run/OcnCplAftMm25.h5m" );
27 opts.
addOpt< std::string >(
"file1,f",
"first file", &file1 );
28 opts.
addOpt< std::string >(
"file2,g",
"second file", &file2 );
30 opts.
addOpt<
void>(
"global,G",
"use global id for correspondence" );
35 bool use_global_id = opts.
numOptSet(
"global") > 0;
45 std::vector< Tag > list1;
53 if( cells1.
size() == 0 )
64 vector< double > vals1, vals2;
65 vals1.resize( cells1.
size() );
66 vals2.resize( cells2.
size() );
68 std::vector<int> gids, gids2;
69 std::map<int, int> gidMap2;
72 gids.resize(cells1.
size());
74 gids2.resize(cells2.
size());
76 for (
int i=0; i<cells2.
size(); i++)
78 gidMap2[ gids2[i] ] = i;
84 std::cout <<
" compare files: " << file1 <<
" and " << file2 <<
" dimension entity: " <<
dim <<
"\n";
85 std::vector< std::string > same_fields;
86 std::vector<Tag> diffTags;
87 for(
size_t i = 0; i < list1.size(); i++ )
100 if( 1 !=
length )
continue;
105 double minv1, maxv1, minv2, maxv2;
106 if( vals1.size() > 0 )
108 minv1 = maxv1 = vals1[0];
110 if( vals2.size() > 0 )
112 minv2 = maxv2 = vals2[0];
115 double sum = 0, value1, value2;
116 for(
int j = 0; j < vals1.size(); j++ )
122 int index2 = gidMap2[ gids[j] ];
123 value2 = vals2[index2];
132 sum += fabs( value1 - value2 );
133 if( value1 < minv1 ) minv1 = value1;
134 if( value1 > maxv1 ) maxv1 = value1;
135 if( value2 < minv2 ) minv2 = value2;
136 if( value2 > maxv2 ) maxv2 = value2;
141 std::cout <<
" tag: " << name <<
" \t difference : " <<
sum <<
" \t min/max (" << minv1 <<
"/" << maxv1
142 <<
") \t (" << minv2 <<
"/" << maxv2 <<
") \n";
146 for (
int j=0; j< vals1.size(); j++)
148 int index2 = gidMap2[ gids[j] ];
149 vals1[j] -= vals2[index2];
154 for (
int j=0; j< vals1.size(); j++)
156 vals1[j] -= vals2[j];
159 std::string diffTagName = name+
"_diff";
163 diffTags.push_back(newTag);
168 same_fields.push_back( name );
176 std::cout <<
" different fields:" << k <<
" \n exactly the same fields:" << k1 <<
"\n";
177 for(
size_t i = 0; i < same_fields.size(); i++ )
179 std::cout <<
" " << same_fields[i];