/** @brief Configuration initialization in libaspect */ static void aspect_config_init() { memset(&aspectworld, 0x00, sizeof(aspectworld_t)); // Just for debugging //aspectworld.profile = (void *) puts; hash_init(&aspectworld.config_hash, "configuration", CONFIG_HASH_SIZE, ASPECT_TYPE_UNKNOW); aspectworld.proflevel = PROFILE_NONE; /* XXX: should go in their respective library */ config_add_item(CONFIG_CFGDEPTH, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) CONFIG_CFGDEPTH_DEFAULT); config_add_item(CONFIG_NAME_SAFEMODE, CONFIG_TYPE_INT, CONFIG_MODE_RW, CONFIG_SAFEMODE_OFF); config_add_item(CONFIG_ASM_ENDIAN_FLAG, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) CONFIG_ASM_LITTLE_ENDIAN); config_add_item(CONFIG_ASM_ATT_MARGIN_FLAG, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) CONFIG_ASM_ATT_MARGIN_DEFAULT); config_add_item(CONFIG_ASM_SYNTHINSTRS, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) CONFIG_ASM_SYNTHINSTRS_DEFAULT); }
void config_init(config_type * config ) { config_item_type * item; config_add_key_value(config , "NUM_REALIZATIONS" , true , CONFIG_INT ); config_add_key_value(config , "SCHEDULE_FILE" , true , CONFIG_EXISTING_FILE); config_add_key_value(config , "DATA_FILE" , true , CONFIG_EXISTING_FILE); config_add_key_value(config , "TARGET" , true , CONFIG_STRING ); item = config_add_item( config , "GROUP_RATE" , false , true ); /* Group name as part of parsing */ config_item_set_argc_minmax(item , 4 , 4 , 4 , (const config_item_types[4]) { CONFIG_STRING, /* Group name */ CONFIG_STRING , /* Phase */ CONFIG_STRING , /* PRODUCER / INJECTOR */ CONFIG_EXISTING_FILE}); /* File with min / max shift */
static void config_parse_section(struct config_section *section, struct lexer *lex) { struct base_token token; while (lexer_getbasetoken(lex, &token, false)) { struct strref name, value; while (token.type == BASETOKEN_WHITESPACE) { if (!lexer_getbasetoken(lex, &token, false)) return; } if (token.type == BASETOKEN_OTHER) { if (*token.text.array == '#') { do { if (!lexer_getbasetoken(lex, &token, false)) return; } while (!is_newline(*token.text.array)); continue; } else if (*token.text.array == '[') { lex->offset--; return; } } strref_copy(&name, &token.text); if (!config_parse_string(lex, &name, '=')) continue; strref_clear(&value); config_parse_string(lex, &value, 0); config_add_item(§ion->items, &name, &value); } }
config_add_key_value(config , "DATA_FILE" , true , CONFIG_EXISTING_FILE); config_add_key_value(config , "TARGET" , true , CONFIG_STRING ); item = config_add_item( config , "GROUP_RATE" , false , true ); /* Group name as part of parsing */ config_item_set_argc_minmax(item , 4 , 4 , 4 , (const config_item_types[4]) { CONFIG_STRING, /* Group name */ CONFIG_STRING , /* Phase */ CONFIG_STRING , /* PRODUCER / INJECTOR */ CONFIG_EXISTING_FILE}); /* File with min / max shift */ config_item_set_indexed_selection_set( item , 1 , 3 , (const char *[3]) { "OIL" , "GAS" , "WATER"}); config_item_set_indexed_selection_set( item , 2 , 2 , (const char *[2]) { "PRODUCER" , "INJECTOR"}); item = config_add_item( config , "WELL_RATE" , false , true ); /* Group name as part of parsing */ config_item_set_argc_minmax(item , 4 , 4 , 4 , (const config_item_types[4]) { CONFIG_STRING, /* GROUP NAME */ CONFIG_STRING , /* Well name */ CONFIG_FLOAT , /* Corr_length (days) */ CONFIG_EXISTING_FILE});/* File with mean , std shift */ } void load_groups( const config_type * config , const sched_file_type * sched_file , hash_type * group_rates , const sched_history_type * sched_history , const time_t_vector_type * time_vector ) { int i; for (i=0; i < config_get_occurences( config , "GROUP_RATE" ); i++) { const char * group_name = config_iget( config , "GROUP_RATE" , i , 0 ); const char * phase_string = config_iget( config , "GROUP_RATE" , i , 1 ); const char * type_string = config_iget( config , "GROUP_RATE" , i , 2 ); const char * min_max_file = config_iget( config , "GROUP_RATE" , i , 3 );