Example #1
0
void ensemble_config_add_config_items(config_parser_type * config) {
  config_schema_item_type * item;

  /**
      the two fault types are just added to the config object only to
      be able to print suitable messages before exiting.
  */

  item = config_add_schema_item(config , "HAVANA_FAULT" , false  );
  config_schema_item_set_argc_minmax(item , 2 , 2);

  item = config_add_schema_item(config , "MULTFLT" , false  );
  config_schema_item_set_argc_minmax(item , 3 , 3 );
  config_schema_item_iset_type( item , 2 , CONFIG_EXISTING_PATH );


  /*****************************************************************/


  item = config_add_schema_item(config , GEN_KW_KEY , false  );
  config_schema_item_set_argc_minmax(item , 4 , 6);
  config_schema_item_iset_type( item , 1 , CONFIG_EXISTING_PATH );
  config_schema_item_iset_type( item , 3 , CONFIG_EXISTING_PATH );



  item = config_add_key_value( config , GEN_KW_TAG_FORMAT_KEY , false , CONFIG_STRING);
  item = config_add_schema_item(config , SCHEDULE_PREDICTION_FILE_KEY , false  );
  /* scedhule_prediction_file   filename  <parameters:> <init_files:> */
  config_schema_item_set_argc_minmax(item , 1 , 3 );
  config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH );



  enkf_config_node_add_GEN_PARAM_config_schema( config );
  enkf_config_node_add_GEN_DATA_config_schema( config );
  enkf_config_node_add_CUSTOM_KW_config_schema( config );

  item = config_add_schema_item(config , SUMMARY_KEY , false  );   /* can have several summary keys on each line. */
  config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX);

  item = config_add_schema_item(config , CONTAINER_KEY , false  );   /* can have several summary keys on each line. */
  config_schema_item_set_argc_minmax(item , 2 , CONFIG_DEFAULT_ARG_MAX);
  
  item = config_add_schema_item( config , SURFACE_KEY , false  );
  config_schema_item_set_argc_minmax(item , 4 , 5 );
  
  /*
     the way config info is entered for fields is unfortunate because
     it is difficult/impossible to let the config system handle run
     time validation of the input.
  */

  item = config_add_schema_item(config , FIELD_KEY , false  );
  config_schema_item_set_argc_minmax(item , 2 , CONFIG_DEFAULT_ARG_MAX);
  config_schema_item_add_required_children(item , GRID_KEY);   /* if you are using a field - you must have a grid. */
}
int main(int argc , char ** argv) {
  const char * config_file = argv[1];
  config_parser_type * config = config_alloc();
  config_content_type * content;
  ensemble_config_type * ensemble = ensemble_config_alloc();

  enkf_config_node_add_GEN_PARAM_config_schema( config );

  content = config_parse( config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true );
  test_assert_true( config_content_is_valid( content ) );

  ensemble_config_init_GEN_PARAM( ensemble, content );

  config_content_free( content );
  config_free( config );
  ensemble_config_free( ensemble );
  exit(0);
}