mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
93
ThirdParty/Ert/devel/libecl/src/smspec_node.c
vendored
93
ThirdParty/Ert/devel/libecl/src/smspec_node.c
vendored
@@ -64,7 +64,6 @@ struct smspec_node_struct {
|
||||
int * lgr_ijk; /* The (i,j,k) coordinate, in the local grid, if this is a LGR variable. WIll be NULL for no-lgr variables. */
|
||||
bool rate_variable; /* Is this a rate variable (i.e. WOPR) or a state variable (i.e. BPR). Relevant when doing time interpolation. */
|
||||
bool total_variable; /* Is this a total variable like WOPT? */
|
||||
bool need_nums; /* Do we use the NUMS vector - relevant for storing. */
|
||||
bool historical; /* Does the name end with 'H'? */
|
||||
int params_index; /* The index of this variable (applies to all the vectors - in particular the PARAMS vectors of the summary files *.Snnnn / *.UNSMRY ). */
|
||||
float default_value; /* Default value for this variable. */
|
||||
@@ -253,7 +252,6 @@ static void smspec_node_set_keyword( smspec_node_type * smspec_node , const char
|
||||
static void smspec_node_set_invalid_flags( smspec_node_type * smspec_node) {
|
||||
smspec_node->rate_variable = false;
|
||||
smspec_node->total_variable = false;
|
||||
smspec_node->need_nums = false;
|
||||
smspec_node->historical = false;
|
||||
}
|
||||
|
||||
@@ -320,23 +318,6 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) {
|
||||
}
|
||||
smspec_node->total_variable = is_total;
|
||||
}
|
||||
|
||||
/*
|
||||
Check if this node needs the nums field; if at least one of the
|
||||
nodes need the NUMS field must be stored when writing a SMSPEC
|
||||
file.
|
||||
*/
|
||||
{
|
||||
if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR ||
|
||||
smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR ||
|
||||
smspec_node->var_type == ECL_SMSPEC_REGION_VAR ||
|
||||
smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR ||
|
||||
smspec_node->var_type == ECL_SMSPEC_BLOCK_VAR ||
|
||||
smspec_node->var_type == ECL_SMSPEC_AQUIFER_VAR)
|
||||
smspec_node->need_nums = true;
|
||||
else
|
||||
smspec_node->need_nums = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -602,13 +583,27 @@ bool smspec_node_init( smspec_node_type * smspec_node,
|
||||
break;
|
||||
case(ECL_SMSPEC_MISC_VAR):
|
||||
/* Misc variable : */
|
||||
/* Fully initialized with the smspec_common_init() function */
|
||||
|
||||
/*
|
||||
For some keywords the SMSPEC files generated by Eclipse have a
|
||||
non zero NUMS value although; it seems that value is required
|
||||
for the generatd summaryfiles to display nicely in
|
||||
e.g. S3GRAF.
|
||||
*/
|
||||
|
||||
if (util_string_equal( keyword ,SMSPEC_TIME_KEYWORD))
|
||||
smspec_node_set_num( smspec_node , grid_dims , SMSPEC_TIME_NUMS_VALUE );
|
||||
|
||||
if (util_string_equal( keyword ,SMSPEC_YEARS_KEYWORD))
|
||||
smspec_node_set_num( smspec_node , grid_dims , SMSPEC_YEARS_NUMS_VALUE );
|
||||
|
||||
break;
|
||||
default:
|
||||
/* Lots of legitimate alternatives which are not internalized. */
|
||||
initOK = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (initOK)
|
||||
smspec_node_set_gen_keys( smspec_node , key_join_string );
|
||||
return initOK;
|
||||
@@ -741,6 +736,42 @@ smspec_node_type * smspec_node_alloc_lgr( ecl_smspec_var_type var_type ,
|
||||
}
|
||||
}
|
||||
|
||||
smspec_node_type* smspec_node_alloc_copy( const smspec_node_type* node ) {
|
||||
|
||||
if( !node ) return NULL;
|
||||
|
||||
{
|
||||
smspec_node_type* copy = util_malloc( sizeof * copy );
|
||||
UTIL_TYPE_ID_INIT( copy, SMSPEC_TYPE_ID );
|
||||
copy->gen_key1 = util_alloc_string_copy( node->gen_key1 );
|
||||
copy->gen_key2 = util_alloc_string_copy( node->gen_key2 );
|
||||
copy->var_type = node->var_type;
|
||||
copy->wgname = util_alloc_string_copy( node->wgname );
|
||||
copy->keyword = util_alloc_string_copy( node->keyword );
|
||||
copy->unit = util_alloc_string_copy( node->unit );
|
||||
copy->num = node->num;
|
||||
|
||||
copy->ijk = NULL;
|
||||
if( node->ijk ) {
|
||||
copy->ijk = util_calloc( 3 , sizeof * node->ijk );
|
||||
memcpy( copy->ijk, node->ijk, 3 * sizeof( * node->ijk ) );
|
||||
}
|
||||
|
||||
copy->lgr_name = util_alloc_string_copy( node->lgr_name );
|
||||
copy->lgr_ijk = NULL;
|
||||
if( node->lgr_ijk ) {
|
||||
copy->lgr_ijk = util_calloc( 3 , sizeof * node->lgr_ijk );
|
||||
memcpy( copy->lgr_ijk, node->lgr_ijk, 3 * sizeof( * node->lgr_ijk ) );
|
||||
}
|
||||
|
||||
copy->rate_variable = node->rate_variable;
|
||||
copy->total_variable = node->total_variable;
|
||||
copy->historical = node->historical;
|
||||
copy->params_index = node->params_index;
|
||||
copy->default_value = node->default_value;
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
void smspec_node_free( smspec_node_type * index ) {
|
||||
util_safe_free( index->unit );
|
||||
@@ -830,9 +861,29 @@ void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit )
|
||||
|
||||
|
||||
bool smspec_node_need_nums( const smspec_node_type * smspec_node ) {
|
||||
return smspec_node->need_nums;
|
||||
/*
|
||||
Check if this node needs the nums field; if at least one of the
|
||||
nodes need the NUMS field must be stored when writing a SMSPEC
|
||||
file.
|
||||
*/
|
||||
{
|
||||
if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR ||
|
||||
smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR ||
|
||||
smspec_node->var_type == ECL_SMSPEC_REGION_VAR ||
|
||||
smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR ||
|
||||
smspec_node->var_type == ECL_SMSPEC_BLOCK_VAR ||
|
||||
smspec_node->var_type == ECL_SMSPEC_AQUIFER_VAR)
|
||||
return true;
|
||||
else {
|
||||
if (smspec_node->num == SMSPEC_NUMS_INVALID)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream) {
|
||||
fprintf(stream, "KEYWORD: %s \n",smspec_node->keyword);
|
||||
fprintf(stream, "WGNAME : %s \n",smspec_node->wgname);
|
||||
|
||||
Reference in New Issue
Block a user