void obs_vector_install_node(obs_vector_type * obs_vector , int index , void * node) { obs_vector_assert_node_type( obs_vector , node ); { if (vector_iget_const( obs_vector->nodes , index ) == NULL) obs_vector->num_active++; vector_iset_owned_ref( obs_vector->nodes , index , node , obs_vector->freef ); } }
void misfit_ranking_iset( misfit_ranking_type * misfit_ranking , int iens , hash_type * obs_hash , double total_misfit) { if (iens > vector_get_size(misfit_ranking->ensemble)) vector_grow_NULL( misfit_ranking->ensemble , iens ); if (obs_hash != NULL) vector_iset_owned_ref( misfit_ranking->ensemble , iens , obs_hash , hash_free__ ); else vector_iset_ref( misfit_ranking->ensemble , iens , NULL ); double_vector_iset( misfit_ranking->total , iens , total_misfit ); }
void well_segment_collection_add( well_segment_collection_type * segment_collection , well_segment_type * segment) { int segment_id = well_segment_get_id( segment ); int current_index = int_vector_safe_iget( segment_collection->segment_index_map , segment_id ); if (current_index >= 0) vector_iset_owned_ref( segment_collection->__segment_storage , current_index , segment , well_segment_free__); else { int new_index = vector_get_size(segment_collection->__segment_storage); vector_append_owned_ref( segment_collection->__segment_storage , segment , well_segment_free__); int_vector_iset( segment_collection->segment_index_map , segment_id , new_index); } }
void obs_vector_install_node(obs_vector_type * obs_vector , int index , void * node) { obs_vector_assert_node_type( obs_vector , node ); { if (vector_iget_const( obs_vector->nodes , index ) == NULL) { obs_vector->num_active++; int_vector_append( obs_vector->step_list , index ); int_vector_sort( obs_vector->step_list ); } vector_iset_owned_ref( obs_vector->nodes , index , node , obs_vector->freef ); } }
void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes,int num_nodes, ert_ecl_unit_enum unit_set){ ecl_rft_file_type * rft_file; if(util_file_exists(rft_file_name)){ int node_index; rft_file = ecl_rft_file_alloc( rft_file_name ); for(node_index = 0; node_index < num_nodes; node_index++) { ecl_rft_node_type * new_node = nodes[node_index]; int storage_index = ecl_rft_file_get_node_index_time_rft(rft_file, ecl_rft_node_get_well_name(new_node), ecl_rft_node_get_date(new_node)); if (storage_index == -1) { ecl_rft_file_add_node(rft_file, new_node); } else { vector_iset_owned_ref(rft_file->data, storage_index, new_node,ecl_rft_node_free__); } } }else{ int node_index; rft_file = ecl_rft_file_alloc_empty( rft_file_name ); for(node_index = 0; node_index < num_nodes; node_index++) { ecl_rft_file_add_node(rft_file, nodes[node_index]); } } { bool fmt_file = false; fortio_type * fortio = fortio_open_writer( rft_file_name , fmt_file , ECL_ENDIAN_FLIP ); int node_index; /** The sorting here works directly on the internal node storage rft_file->data; that might in principle ruin the indexing of the ecl_file object - it is therefor absolutely essential that this ecl_rft_file object does not live beyond this function, and also that the ecl_rft_file api functions are avoided for the rest of this function. */ vector_sort(rft_file->data,(vector_cmp_ftype *) ecl_rft_node_cmp); for(node_index=0; node_index < vector_get_size( rft_file->data ); node_index++) { const ecl_rft_node_type *new_node = vector_iget_const(rft_file->data, node_index); ecl_rft_node_fwrite(new_node, fortio, unit_set); } fortio_fclose( fortio ); } ecl_rft_file_free(rft_file); }
void misfit_ensemble_fread( misfit_ensemble_type * misfit_ensemble , FILE * stream ) { misfit_ensemble_clear( misfit_ensemble ); { int ens_size; misfit_ensemble->history_length = util_fread_int( stream ); ens_size = util_fread_int( stream ); misfit_ensemble_set_ens_size( misfit_ensemble , ens_size ); { for (int iens = 0; iens < ens_size; iens++) { misfit_member_type * node = misfit_member_fread_alloc( stream ); vector_iset_owned_ref( misfit_ensemble->ensemble , iens , node , misfit_member_free__); } } } }
void vector_safe_iset_owned_ref(vector_type * vector , int index , const void * data, free_ftype * del) { vector_assert_size( vector , index + 1); vector_iset_owned_ref( vector , index , data , del); }
void stringlist_iset_owned_ref(stringlist_type * stringlist , int index , const char * s) { vector_iset_owned_ref(stringlist->strings , index , s , free); }
static void sched_file_update_index( sched_file_type * sched_file ) { int ikw; /* By type index */ { if (sched_file->kw_list_by_type != NULL) vector_free( sched_file->kw_list_by_type ); sched_file->kw_list_by_type = vector_alloc_NULL_initialized( NUM_SCHED_KW_TYPES ); for (ikw = 0; ikw < vector_get_size( sched_file->kw_list ); ikw++) { const sched_kw_type * kw = vector_iget_const( sched_file->kw_list , ikw ); sched_kw_type_enum type = sched_kw_get_type( kw ); { vector_type * tmp = vector_iget( sched_file->kw_list_by_type , type ); if (tmp == NULL) { tmp = vector_alloc_new(); vector_iset_owned_ref( sched_file->kw_list_by_type , type , tmp , vector_free__ ); } vector_append_ref( tmp , kw ); } } } /* Block based on restart number. */ { time_t current_time; sched_block_type * current_block; vector_clear( sched_file->blocks ); /* Adding a pseudo block at the start which runs from the start of time (i.e. EPOCH start 01/01/1970) to simulation start. */ current_block = sched_block_alloc_empty( 0 ); current_block->block_start_time = sched_file->start_time;//-1; /* Need this funny node - hhmmmmmm */ current_block->block_end_time = sched_file->start_time; sched_file_add_block( sched_file , current_block ); current_block = sched_block_alloc_empty( 0 ); current_block->block_start_time = sched_file->start_time; current_time = sched_file->start_time; for (ikw = 0; ikw < vector_get_size( sched_file->kw_list ); ikw++) { const sched_kw_type * kw = vector_iget_const( sched_file->kw_list , ikw ); sched_kw_type_enum type = sched_kw_get_type( kw ); { sched_block_add_kw( current_block , kw ); if(type == DATES || type == TSTEP || type == TIME) { /** Observe that when we enocunter a time-based keyword we do the following: 1. Finish the the current block by setting the end_time field and add this block to the sched_file structure. 2. Create a new block starting at current time. ------- Blocks are not actually added to the sched_file instance before they are terminated with a DATES/TSTEP keyword. This implies that keywords which come after the last DATES/TSTEP keyword are lost. */ current_time = sched_kw_get_new_time( kw , current_time ); /* Finishing off the current block, and adding it to the sched_file. */ current_block->block_end_time = current_time; sched_file_add_block( sched_file , current_block ); /* Creating a new block - not yet added to the sched_file. */ current_block = sched_block_alloc_empty( vector_get_size( sched_file->blocks )); current_block->block_start_time = current_time; } } } /* Free the last block, which has not been added to the sched_file object. */ sched_block_free( current_block ); } }