Skip to content

Commit

Permalink
Fix bug in smspec_cmp for NETWORK_VAR
Browse files Browse the repository at this point in the history
  • Loading branch information
Pål Grønås Drange authored and Pål Grønås Drange committed Oct 4, 2017
1 parent 2c25b4f commit 9b790cb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
26 changes: 11 additions & 15 deletions lib/ecl/ecl_smspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,24 +980,20 @@ bool ecl_smspec_needs_num( ecl_smspec_var_type var_type ) {



bool ecl_smspec_equal( const ecl_smspec_type * self , const ecl_smspec_type * other) {
bool equal = true;

if (vector_get_size( self->smspec_nodes ) == vector_get_size( other->smspec_nodes)) {
for (int i=0; i < vector_get_size( self->smspec_nodes ); i++) {
const smspec_node_type * node1 = vector_iget_const( self->smspec_nodes , i );
const smspec_node_type * node2 = vector_iget_const( other->smspec_nodes , i );
bool ecl_smspec_equal(const ecl_smspec_type * self,
const ecl_smspec_type * other) {
if (vector_get_size( self->smspec_nodes ) != vector_get_size( other->smspec_nodes))
return false;

if (!smspec_node_equal( node1,node2)) {
equal = false;
break;
}
for (int i=0; i < vector_get_size( self->smspec_nodes ); i++) {
const smspec_node_type * node1 = vector_iget_const(self->smspec_nodes, i);
const smspec_node_type * node2 = vector_iget_const(other->smspec_nodes, i);

}
} else
equal = false;
if (!smspec_node_equal(node1, node2))
return false;
}

return equal;
return true;
}


Expand Down
8 changes: 8 additions & 0 deletions lib/ecl/smspec_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,14 @@ static int smspec_node_cmp_KEYWORD( const smspec_node_type * node1, const smspec
}

static int smspec_node_cmp_key1( const smspec_node_type * node1, const smspec_node_type * node2) {
if (!node1->gen_key1) {
if (!node2->gen_key1)
return 0;
else
return -1;
} else if (!node2->gen_key1) {
return 1;
}
return util_strcmp_int( node1->gen_key1 , node2->gen_key1 );
}

Expand Down
5 changes: 5 additions & 0 deletions lib/ecl/tests/ecl_smspec_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ void test_cmp_types() {
test_assert_true( smspec_node_cmp( misc_node1, misc_node2) < 0 );
test_assert_true( smspec_node_cmp( misc_node2, misc_node1) > 0 );

smspec_node_type * net1 = smspec_node_alloc(ECL_SMSPEC_NETWORK_VAR, "Net", "FOPT", "UNIT", ":", dims, 10 , 0, 0);
smspec_node_type * net2 = smspec_node_alloc(ECL_SMSPEC_NETWORK_VAR, "Net", "FOPT", "UNIT", ":", dims, 10 , 0, 0);
test_assert_true( smspec_node_cmp( net1, net2) == 0 );

smspec_node_free( segment_node );
smspec_node_free( aquifer_node );
Expand All @@ -67,6 +70,8 @@ void test_cmp_types() {
smspec_node_free( field_node );
smspec_node_free( misc_node1 );
smspec_node_free( misc_node2 );
smspec_node_free( net1 );
smspec_node_free( net2 );
}

void test_cmp_well() {
Expand Down

0 comments on commit 9b790cb

Please sign in to comment.