log_type * log_open( const char * filename , int log_level) { log_type *logh; logh = util_malloc(sizeof *logh ); logh->log_level = log_level; logh->filename = NULL; logh->stream = NULL; #ifdef HAVE_PTHREAD pthread_mutex_init( &logh->mutex , NULL ); #endif if (filename != NULL && log_level > 0) log_reopen( logh , filename); return logh; }
static point_obs_type * point_obs_alloc( block_obs_source_type source_type , int i , int j , int k , int active_index , const char * sum_key , double value , double std) { point_obs_type * point_obs = util_malloc( sizeof * point_obs ); UTIL_TYPE_ID_INIT( point_obs , POINT_OBS_TYPE_ID ); point_obs->source_type = source_type; point_obs->i = i; point_obs->j = j; point_obs->k = k; point_obs->active_index = active_index; point_obs->value = value; point_obs->std = std; point_obs->sum_key = util_alloc_string_copy( sum_key ); return point_obs; }
void util_fread_compressed(void *__data , FILE * stream) { unsigned char * data = (unsigned char *) __data; int buffer_size; int size , offset; void * zbuffer; fread(&size , sizeof size , 1 , stream); if (size == 0) return; fread(&buffer_size , sizeof buffer_size , 1 , stream); zbuffer = util_malloc(buffer_size ); offset = 0; do { unsigned long compressed_size; unsigned long block_size = size - offset; int uncompress_result; fread(&compressed_size , sizeof compressed_size , 1 , stream); { int bytes_read = fread(zbuffer , 1 , compressed_size , stream); if (bytes_read < compressed_size) util_abort("%s: read only %d/%d bytes from compressed file - aborting \n",__func__ , bytes_read , compressed_size); } uncompress_result = uncompress(&data[offset] , &block_size , zbuffer , compressed_size); if (uncompress_result != Z_OK) { fprintf(stderr,"%s: ** Warning uncompress result:%d != Z_OK.\n" , __func__ , uncompress_result); /** According to the zlib documentation: 1. Values > 0 are not errors - just rare events? 2. The value Z_BUF_ERROR is not fatal - we let that pass?! */ if (uncompress_result < 0 && uncompress_result != Z_BUF_ERROR) util_abort("%s: fatal uncompress error: %d \n",__func__ , uncompress_result); } offset += block_size; { int file_offset; fread(&file_offset , sizeof offset , 1 , stream); if (file_offset != offset) util_abort("%s: something wrong when reding compressed stream - aborting \n",__func__); } } while (offset < size); free(zbuffer); }
custom_kw_config_type * custom_kw_config_alloc_empty(const char * key, const char * result_file, const char * output_file) { custom_kw_config_type * custom_kw_config = util_malloc(sizeof * custom_kw_config); UTIL_TYPE_ID_INIT(custom_kw_config, CUSTOM_KW_CONFIG_ID); custom_kw_config->name = NULL; custom_kw_config->result_file = util_alloc_string_copy(result_file); custom_kw_config->output_file = util_alloc_string_copy(output_file); custom_kw_config->name = util_alloc_string_copy(key); custom_kw_config->undefined = true; custom_kw_config->key_definition_file = NULL; custom_kw_config->custom_keys = hash_alloc(); custom_kw_config->custom_key_types = hash_alloc(); //types: 0 if string, 1 if double pthread_rwlock_init(& custom_kw_config->rw_lock, NULL); return custom_kw_config; }
int stringlist_select_matching(stringlist_type * names , const char * pattern) { int match_count = 0; stringlist_clear( names ); { int i; glob_t * pglob = util_malloc( sizeof * pglob ); int glob_flags = 0; glob( pattern , glob_flags , NULL , pglob); match_count = pglob->gl_pathc; for (i=0; i < pglob->gl_pathc; i++) stringlist_append_copy( names , pglob->gl_pathv[i] ); globfree( pglob ); /* Only frees the _internal_ data structures of the pglob object. */ free( pglob ); } return match_count; }
static ecl_sum_type * ecl_sum_alloc__( const char * input_arg , const char * key_join_string) { ecl_sum_type * ecl_sum = util_malloc( sizeof * ecl_sum ); UTIL_TYPE_ID_INIT( ecl_sum , ECL_SUM_ID ); ecl_sum->ecl_case = NULL; ecl_sum->path = NULL; ecl_sum->base = NULL; ecl_sum->ext = NULL; ecl_sum->abs_path = NULL; ecl_sum_set_case( ecl_sum , input_arg ); ecl_sum->key_join_string = util_alloc_string_copy( key_join_string ); ecl_sum->smspec = NULL; ecl_sum->data = NULL; return ecl_sum; }
static ert_run_context_type * ert_run_context_alloc(const bool_vector_type * iactive , run_mode_type run_mode , enkf_fs_type * init_fs , enkf_fs_type * result_fs , enkf_fs_type * update_target_fs , int iter) { ert_run_context_type * context = util_malloc( sizeof * context ); UTIL_TYPE_ID_INIT( context , ERT_RUN_CONTEXT_TYPE_ID ); context->iactive = bool_vector_alloc_copy( iactive ); context->iens_map = bool_vector_alloc_active_index_list( iactive , -1 ); context->run_args = vector_alloc_new(); context->run_mode = run_mode; context->iter = iter; ert_run_context_set_init_fs(context, init_fs); ert_run_context_set_result_fs(context, result_fs); ert_run_context_set_update_target_fs(context, update_target_fs); context->step1 = 0; context->step2 = 0; return context; }
stepwise_type * stepwise_alloc0( rng_type * rng) { stepwise_type * stepwise = util_malloc( sizeof * stepwise ); stepwise->rng = rng; stepwise->X0 = NULL; stepwise->E0 = NULL; stepwise->Y0 = NULL; stepwise->beta = NULL; stepwise->active_set = NULL; stepwise->data_owner = true; stepwise->X_mean = NULL; stepwise->X_norm = NULL; stepwise->Y_mean = 0.0; stepwise->R2 = -1.0; return stepwise; }
ecl_sum_tstep_type * ecl_sum_tstep_alloc_remap_copy( const ecl_sum_tstep_type * src , const ecl_smspec_type * new_smspec, float default_value , const int * params_map) { int params_size = ecl_smspec_get_params_size( new_smspec ); ecl_sum_tstep_type * target = util_alloc_copy(src , sizeof * src ); target->smspec = new_smspec; target->data = util_malloc( params_size * sizeof * target->data ); target->data_size = params_size; for (int i=0; i < params_size; i++) { if (params_map[i] >= 0) target->data[i] = src->data[ params_map[i] ]; else target->data[i] = default_value; } return target; }
ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occurence) { if (ecl_file_get_num_named_kw( rst_file , INTEHEAD_KW) > occurence) { const ecl_kw_type * intehead_kw = ecl_file_iget_named_kw( rst_file , INTEHEAD_KW , occurence); const ecl_kw_type * logihead_kw = ecl_file_iget_named_kw( rst_file , LOGIHEAD_KW , occurence); const ecl_kw_type * doubhead_kw = ecl_file_iget_named_kw( rst_file , DOUBHEAD_KW , occurence); ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); { const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw ); rsthead->day = data[INTEHEAD_DAY_INDEX]; rsthead->month = data[INTEHEAD_MONTH_INDEX]; rsthead->year = data[INTEHEAD_YEAR_INDEX]; rsthead->version = data[INTEHEAD_IPROG_INDEX]; rsthead->phase_sum = data[INTEHEAD_PHASE_INDEX]; rsthead->nx = data[INTEHEAD_NX_INDEX]; rsthead->ny = data[INTEHEAD_NY_INDEX]; rsthead->nz = data[INTEHEAD_NZ_INDEX]; rsthead->nactive = data[INTEHEAD_NACTIVE_INDEX]; rsthead->nwells = data[INTEHEAD_NWELLS_INDEX]; rsthead->niwelz = data[INTEHEAD_NIWELZ_INDEX]; rsthead->nzwelz = data[INTEHEAD_NZWELZ_INDEX]; rsthead->nsconz = data[INTEHEAD_NSCONZ_INDEX]; rsthead->niconz = data[INTEHEAD_NICONZ_INDEX]; rsthead->ncwmax = data[INTEHEAD_NCWMAX_INDEX]; rsthead->nisegz = data[INTEHEAD_NISEGZ_INDEX]; rsthead->nsegmx = data[INTEHEAD_NSEGMX_INDEX]; rsthead->nswlmx = data[INTEHEAD_NSWLMX_INDEX]; rsthead->nrsegz = data[INTEHEAD_NRSEGZ_INDEX]; // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); return rsthead; } else return NULL; }
plot_type * plot_alloc(const char * __driver_type , void * init_arg , bool logx , bool logy) { plot_type * plot = util_malloc(sizeof *plot ); { /* Loading the driver: */ char * driver_type = util_alloc_string_copy( __driver_type ); util_strupr( driver_type ); if (util_string_equal( driver_type , "PLPLOT")) plot->driver = plplot_driver_alloc(init_arg); else if (util_string_equal( driver_type , "TEXT")) plot->driver = text_driver_alloc(init_arg); else util_abort("%s: plot driver:%s not implemented ... \n",__func__ , __driver_type); plot_driver_assert( plot->driver ); free( driver_type ); } /* Initializing plot data which is common to all drivers. */ plot->is_histogram = false; plot->dataset = vector_alloc_new(); plot->dataset_hash = hash_alloc(); plot->range = plot_range_alloc(); plot->timefmt = NULL; plot->xlabel = NULL; plot->ylabel = NULL; plot->title = NULL; /* These functions only manipulate the internal plot_state variables, and do not call the driver functions. */ plot_set_window_size(plot , PLOT_DEFAULT_WIDTH , PLOT_DEFAULT_HEIGHT); plot_set_box_color(plot , PLOT_DEFAULT_BOX_COLOR); plot_set_label_color(plot , PLOT_DEFAULT_LABEL_COLOR); plot_set_label_fontsize(plot , 1.0); plot_set_axis_fontsize(plot , 1.0); plot_set_labels(plot , "" , "" , ""); /* Initializeing with empty labels. */ plot_set_log( plot , logx , logy); /* Default - no log on the axis. */ return plot; }
local_ministep_type * local_ministep_alloc(const char * name, analysis_module_type* analysis_module) { local_ministep_type * ministep = util_malloc( sizeof * ministep ); ministep->name = util_alloc_string_copy( name ); char* obsdata_name = "OBSDATA_"; char* result = malloc(strlen(obsdata_name)+strlen(name)+1); strcpy(result, obsdata_name); strcat(result, name); ministep->observations = local_obsdata_alloc(result); ministep->datasets = hash_alloc(); ministep->analysis_module = analysis_module; UTIL_TYPE_ID_INIT( ministep , LOCAL_MINISTEP_TYPE_ID); return ministep; }
static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type * ecl_grav , const char * name , grav_calc_type calc_type) { ecl_grav_survey_type * survey = util_malloc( sizeof * survey ); UTIL_TYPE_ID_INIT( survey , ECL_GRAV_SURVEY_ID ); survey->grid_cache = ecl_grav->grid_cache; survey->aquifer_cell = ecl_grav->aquifer_cell; survey->name = util_alloc_string_copy( name ); survey->phase_list = vector_alloc_new(); survey->phase_map = hash_alloc(); if (calc_type & GRAV_CALC_USE_PORV) survey->porv = util_calloc( ecl_grid_cache_get_size( ecl_grav->grid_cache ) , sizeof * survey->porv ); else survey->porv = NULL; return survey; }
config_content_type * config_content_alloc() { config_content_type * content = util_malloc( sizeof * content ); UTIL_TYPE_ID_INIT( content , CONFIG_CONTENT_TYPE_ID ); content->valid = false; content->items = hash_alloc(); content->nodes = vector_alloc_new(); content->parse_errors = config_error_alloc(); content->define_list = subst_list_alloc( NULL ); content->parsed_files = set_alloc_empty(); content->path_elm_storage = vector_alloc_new(); content->path_elm_stack = vector_alloc_new(); content->invoke_path = NULL; content->config_file = NULL; content->abs_path = NULL; return content; }
member_config_type * member_config_alloc(int iens , const char * casename , bool pre_clear_runpath , keep_runpath_type keep_runpath , const ecl_config_type * ecl_config , const ensemble_config_type * ensemble_config, enkf_fs_type * fs) { member_config_type * member_config = util_malloc( sizeof * member_config ); member_config->casename = util_alloc_string_copy( casename ); member_config->iens = iens; /* Can only be changed in the allocater. */ member_config->eclbase = NULL; member_config->jobname = NULL; member_config->pre_clear_runpath = pre_clear_runpath; member_config_set_keep_runpath(member_config , keep_runpath); return member_config; }
data_ranking_type * data_ranking_alloc( bool sort_increasing , int ens_size , const char * user_key , const char * key_index , enkf_fs_type * fs , const enkf_config_node_type * config_node , int step , state_enum state) { data_ranking_type * ranking = util_malloc( sizeof * ranking ); UTIL_TYPE_ID_INIT( ranking , DATA_RANKING_TYPE_ID ); ranking->ens_size = ens_size; ranking->sort_increasing = sort_increasing; if (ranking->sort_increasing) ranking->data_ensemble = double_vector_alloc( ens_size , INFINITY); // To ensure it comes last when sorting else ranking->data_ensemble = double_vector_alloc( ens_size , -INFINITY); // To ensure it comes last when sorting ranking->valid = bool_vector_alloc( ens_size , false ); ranking->sort_permutation = NULL; ranking->user_key = util_alloc_string_copy( user_key ); data_ranking_init( ranking , fs , config_node , key_index , step , state ); return ranking; }
subst_list_type * subst_list_alloc(const void * input_arg) { subst_list_type * subst_list = util_malloc(sizeof * subst_list ); UTIL_TYPE_ID_INIT( subst_list , SUBST_LIST_TYPE_ID); subst_list->parent = NULL; subst_list->func_pool = NULL; subst_list->string_data = vector_alloc_new(); subst_list->func_data = vector_alloc_new(); if (input_arg != NULL) { if (subst_list_is_instance( input_arg )) subst_list_set_parent( subst_list , input_arg ); else if (subst_func_pool_is_instance( input_arg )) subst_list->func_pool = input_arg; else util_abort("%s: run_time cast failed - invalid type on input argument.\n",__func__); } return subst_list; }
qc_module_type * qc_module_alloc( ert_workflow_list_type * workflow_list , const char * qc_path ) { qc_module_type * qc_module = util_malloc( sizeof * qc_module ); qc_module->qc_workflow = NULL; qc_module->qc_path = NULL; qc_module->workflow_list = workflow_list; qc_module->runpath_list = runpath_list_alloc(); qc_module->runpath_list_file = NULL; qc_module_set_path( qc_module , qc_path ); { char * cwd = util_alloc_cwd(); char * runpath_list_file = util_alloc_filename( cwd , RUNPATH_LIST_FILE , NULL); qc_module_set_runpath_list_file( qc_module , runpath_list_file ); free( runpath_list_file ); free( cwd ); } return qc_module; }
static int grab_string_from_file( STRING *stringPtr, BFile file, long stringOff, long stringLen ) { #define string (*stringPtr) int returnValue = 0; string = (STRING)util_malloc((size_t)(stringLen + 1)); bfile_set_off(file, stringOff); fread(string, 1, (size_t)stringLen, file->stream); string[stringLen]= 0; return returnValue; #undef string }
/** The plot_config object is instantiated with the default values from enkf_defaults.h */ plot_config_type * plot_config_alloc_default() { plot_config_type * info = util_malloc( sizeof * info ); info->plot_path = NULL; info->image_type = NULL; info->viewer = NULL; info->driver = NULL; plot_config_set_plot_refcase( info , DEFAULT_PLOT_REFCASE); plot_config_set_path(info , DEFAULT_PLOT_PATH ); plot_config_set_image_type(info , DEFAULT_IMAGE_TYPE ); plot_config_set_viewer(info , DEFAULT_IMAGE_VIEWER ); plot_config_set_driver(info , DEFAULT_PLOT_DRIVER ); plot_config_set_width(info , DEFAULT_PLOT_WIDTH ); plot_config_set_height(info , DEFAULT_PLOT_HEIGHT ); plot_config_set_errorbar_max(info , DEFAULT_PLOT_ERRORBAR_MAX); plot_config_set_plot_errorbar(info , DEFAULT_PLOT_ERRORBAR); plot_config_set_logy( info , DEFAULT_PLOT_LOGY ); return info; }
static queue_driver_type * queue_driver_alloc_empty() { queue_driver_type * driver = util_malloc(sizeof * driver); UTIL_TYPE_ID_INIT(driver, QUEUE_DRIVER_ID); driver->max_running = 0; driver->driver_type = NULL_DRIVER; driver->submit = NULL; driver->get_status = NULL; driver->kill_job = NULL; driver->free_job = NULL; driver->free_driver = NULL; driver->get_option = NULL; driver->set_option = NULL; driver->has_option = NULL; driver->name = NULL; driver->data = NULL; driver->max_running_string = NULL; driver->init_options = NULL; return driver; }
ert_test_context_type * ert_test_context_alloc( const char * test_name , const char * model_config , const char * site_config) { ert_test_context_type * test_context = util_malloc( sizeof * test_context ); UTIL_TYPE_ID_INIT( test_context , ERT_TEST_CONTEXT_TYPE_ID ); if (util_file_exists(model_config)) { test_context->work_area = test_work_area_alloc(test_name); test_work_area_set_store( test_context->work_area , false ); test_work_area_copy_parent_content(test_context->work_area , model_config ); { char * config_file = util_split_alloc_filename( model_config ); test_context->enkf_main = enkf_main_bootstrap( site_config , config_file , true , false ); free( config_file ); } test_context->rng = rng_alloc( MZRAN , INIT_DEV_URANDOM ); } else { test_context->enkf_main = NULL; test_context->work_area = NULL; test_context->rng = NULL; } return test_context; }
lsb_type * lsb_alloc() { lsb_type * lsb = util_malloc( sizeof * lsb ); lsb->ready = true; lsb->error_list = stringlist_alloc_new(); lsb_dlopen(lsb , "libnsl.so" ); lsb_dlopen(lsb , "liblsf.so" ); lsb->lib_handle = lsb_dlopen(lsb , "libbat.so"); if (lsb->lib_handle) { lsb->submit = (lsb_submit_ftype *) lsb_dlsym( lsb , "lsb_submit"); lsb->open_job = (lsb_openjobinfo_ftype *) lsb_dlsym( lsb , "lsb_openjobinfo"); lsb->read_job = (lsb_readjobinfo_ftype *) lsb_dlsym( lsb , "lsb_readjobinfo"); lsb->close_job = (lsb_closejobinfo_ftype *) lsb_dlsym( lsb , "lsb_closejobinfo"); lsb->kill_job = (lsb_forcekilljob_ftype *) lsb_dlsym( lsb , "lsb_forcekilljob"); lsb->lsb_init = (lsb_init_ftype *) lsb_dlsym( lsb , "lsb_init"); lsb->sys_msg = (lsb_sysmsg_ftype *) lsb_dlsym( lsb , "lsb_sysmsg"); } return lsb; }
static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_string) { ecl_rft_enum data_type = translate_from_sting_to_ecl_rft_enum(data_type_string); /* Can return NULL */ if (data_type == SEGMENT) { fprintf(stderr,"%s: sorry SEGMENT PLT/RFT is not supported - file a complaint. \n",__func__); return NULL; } { ecl_rft_node_type * rft_node = util_malloc(sizeof * rft_node ); UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID ); rft_node->cells = vector_alloc_new(); rft_node->data_type = data_type; rft_node->sort_perm = NULL; rft_node->sort_perm_in_sync = false; return rft_node; } }
/** The input vectors i,j,k should contain offset zero values. */ block_obs_type * block_obs_alloc(const char * obs_key, block_obs_source_type source_type , const stringlist_type * summary_keys , const void * data_config , const ecl_grid_type * grid , int size, const int * i, const int * j, const int * k, const double * obs_value, const double * obs_std) { block_obs_validate_ijk( grid , size , i,j,k); { block_obs_type * block_obs = util_malloc(sizeof * block_obs); char * sum_kw = NULL; UTIL_TYPE_ID_INIT( block_obs , BLOCK_OBS_TYPE_ID ); block_obs->obs_key = util_alloc_string_copy(obs_key); block_obs->data_config = data_config; block_obs->source_type = source_type; block_obs->size = 0; block_obs->point_list = NULL; block_obs->grid = grid; block_obs_resize( block_obs , size ); { for (int l=0; l < size; l++) { int active_index = ecl_grid_get_active_index3( block_obs->grid , i[l],j[l],k[l]); char * sum_key = NULL; if (source_type == SOURCE_SUMMARY) sum_key = stringlist_iget( summary_keys , l ); block_obs->point_list[l] = point_obs_alloc(source_type , i[l] , j[l] , k[l] , active_index , sum_key , obs_value[l] , obs_std[l]); } } return block_obs; } }
model_config_type * model_config_alloc() { model_config_type * model_config = util_malloc(sizeof * model_config ); /** There are essentially three levels of initialisation: 1. Initialize to NULL / invalid. 2. Initialize with default values. 3. Initialize with user supplied values. */ UTIL_TYPE_ID_INIT(model_config , MODEL_CONFIG_TYPE_ID); model_config->case_names = NULL; model_config->enspath = NULL; model_config->rftpath = NULL; model_config->dbase_type = INVALID_DRIVER_ID; model_config->current_runpath = NULL; model_config->current_path_key = NULL; model_config->enkf_sched = NULL; model_config->enkf_sched_file = NULL; model_config->case_table_file = NULL; model_config->select_case = NULL; model_config->history = NULL; model_config->jobname_fmt = NULL; model_config->forward_model = NULL; model_config->internalize_state = bool_vector_alloc( 0 , false ); model_config->__load_state = bool_vector_alloc( 0 , false ); model_config->history_source = HISTORY_SOURCE_INVALID; model_config->runpath_map = hash_alloc(); model_config->gen_kw_export_file_name = NULL; model_config_set_enspath( model_config , DEFAULT_ENSPATH ); model_config_set_rftpath( model_config , DEFAULT_RFTPATH ); model_config_set_dbase_type( model_config , DEFAULT_DBASE_TYPE ); model_config_set_max_internal_submit( model_config , DEFAULT_MAX_INTERNAL_SUBMIT); model_config_add_runpath( model_config , DEFAULT_RUNPATH_KEY , DEFAULT_RUNPATH); model_config_select_runpath( model_config , DEFAULT_RUNPATH_KEY ); model_config_set_gen_kw_export_file(model_config, DEFAULT_GEN_KW_EXPORT_FILE); return model_config; }
static run_arg_type * run_arg_alloc(enkf_fs_type * init_fs , enkf_fs_type * result_fs , enkf_fs_type * update_target_fs , int iens , run_mode_type run_mode , int init_step_parameters , state_enum init_state_parameter , state_enum init_state_dynamic , int step1 , int step2 , int iter , const char * runpath) { run_arg_type * run_arg = util_malloc(sizeof * run_arg ); UTIL_TYPE_ID_INIT(run_arg , RUN_ARG_TYPE_ID); run_arg->init_fs = init_fs; run_arg->result_fs = result_fs; run_arg->update_target_fs = update_target_fs; run_arg->iens = iens; run_arg->run_mode = run_mode; run_arg->init_step_parameters = init_step_parameters; run_arg->init_state_parameter = init_state_parameter; run_arg->init_state_dynamic = init_state_dynamic; run_arg->step1 = step1; run_arg->step2 = step2; run_arg->iter = iter; run_arg->run_path = util_alloc_abs_path( runpath ); run_arg->num_internal_submit = 0; run_arg->queue_index = INVALID_QUEUE_INDEX; run_arg->run_status = JOB_NOT_STARTED; if (step1 == 0) run_arg->load_start = 1; else run_arg->load_start = step1; return run_arg; }
ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_type * intehead_kw , const ecl_kw_type * doubhead_kw , const ecl_kw_type * logihead_kw ) { ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); rsthead->report_step = report_step; { const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw ); rsthead->day = data[INTEHEAD_DAY_INDEX]; rsthead->month = data[INTEHEAD_MONTH_INDEX]; rsthead->year = data[INTEHEAD_YEAR_INDEX]; rsthead->version = data[INTEHEAD_IPROG_INDEX]; rsthead->phase_sum = data[INTEHEAD_PHASE_INDEX]; rsthead->nx = data[INTEHEAD_NX_INDEX]; rsthead->ny = data[INTEHEAD_NY_INDEX]; rsthead->nz = data[INTEHEAD_NZ_INDEX]; rsthead->nactive = data[INTEHEAD_NACTIVE_INDEX]; rsthead->nwells = data[INTEHEAD_NWELLS_INDEX]; rsthead->niwelz = data[INTEHEAD_NIWELZ_INDEX]; rsthead->nzwelz = data[INTEHEAD_NZWELZ_INDEX]; rsthead->nsconz = data[INTEHEAD_NSCONZ_INDEX]; rsthead->niconz = data[INTEHEAD_NICONZ_INDEX]; rsthead->ncwmax = data[INTEHEAD_NCWMAX_INDEX]; rsthead->nisegz = data[INTEHEAD_NISEGZ_INDEX]; rsthead->nsegmx = data[INTEHEAD_NSEGMX_INDEX]; rsthead->nswlmx = data[INTEHEAD_NSWLMX_INDEX]; rsthead->nrsegz = data[INTEHEAD_NRSEGZ_INDEX]; // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } if (doubhead_kw) rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); if (logihead_kw) rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); return rsthead; }
static output_type * output_alloc( const char * file , const char * format_string) { output_type * output = util_malloc( sizeof * output ); output->keys = vector_alloc_new(); output->file = util_alloc_string_copy( file ); { format_type format; if ( util_string_equal(format_string , S3GRAPH_STRING)) format = S3GRAPH; else if ( util_string_equal( format_string , HEADER_STRING)) format = HEADER; else if ( util_string_equal( format_string , PLAIN_STRING) ) format = PLAIN; else { format = PLAIN; /* Compiler shut up. */ util_abort("%s: unrecognized format string:%s \n",__func__ , format_string); } output->format = format; } return output; }
smspec_node_type * smspec_node_alloc_new(int params_index, float default_value) { smspec_node_type * node = (smspec_node_type*)util_malloc( sizeof * node ); UTIL_TYPE_ID_INIT( node , SMSPEC_TYPE_ID); node->params_index = params_index; smspec_node_set_default( node , default_value ); node->wgname = NULL; node->ijk = NULL; node->gen_key1 = NULL; node->gen_key2 = NULL; node->var_type = ECL_SMSPEC_INVALID_VAR; node->unit = NULL; node->keyword = NULL; node->lgr_name = NULL; node->lgr_ijk = NULL; smspec_node_set_invalid_flags( node ); return node; // This is NOT usable }