Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

PARALLEL kw from eclipse .DATA file can be overridden by ert config file #455

Merged
merged 3 commits into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/enkf/enkf_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,13 +1329,17 @@ void enkf_main_isubmit_job( enkf_main_type * enkf_main , run_arg_type * run_arg
rng_manager_iget( enkf_main->rng_manager, run_arg_get_iens(run_arg)));
{
const char * argv = run_path;
int num_cpu = queue_config_get_num_cpu( queue_config );
if (num_cpu == 0)
num_cpu = ecl_config_get_num_cpu( ecl_config );

int queue_index = job_queue_add_job( job_queue ,
job_script ,
enkf_state_complete_forward_modelOK__,
enkf_state_complete_forward_modelRETRY__,
enkf_state_complete_forward_modelEXIT__,
callback_arg ,
ecl_config_get_num_cpu( ecl_config ),
num_cpu,
run_path ,
run_arg_get_job_name( run_arg ),
1,
Expand Down
14 changes: 14 additions & 0 deletions lib/enkf/queue_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct queue_config_struct {
hash_type * queue_drivers;
bool user_mode;
int max_submit;
int num_cpu;
};

static void queue_config_add_queue_driver(queue_config_type * queue_config, const char * driver_name, queue_driver_type * driver);
Expand All @@ -58,6 +59,7 @@ static queue_config_type * queue_config_alloc_empty() {
queue_config->driver_type = NULL_DRIVER;
queue_config->user_mode = false;
queue_config->max_submit = 2; // Default value
queue_config->num_cpu = 0;

return queue_config;
}
Expand Down Expand Up @@ -261,6 +263,8 @@ static bool queue_config_init(queue_config_type * queue_config, const config_con
}
}

if (config_content_has_item(config_content, NUM_CPU_KEY))
queue_config->num_cpu = config_content_get_value_as_int(config_content, NUM_CPU_KEY);

if (config_content_has_item(config_content, JOB_SCRIPT_KEY))
queue_config_set_job_script(queue_config, config_content_get_value_as_executable(config_content, JOB_SCRIPT_KEY));
Expand Down Expand Up @@ -296,6 +300,10 @@ job_driver_type queue_config_get_driver_type(const queue_config_type * queue_con
return queue_config->driver_type;
}

int queue_config_get_num_cpu(const queue_config_type * queue_config) {
return queue_config->num_cpu;
}

void queue_config_add_queue_config_items(config_parser_type * parser, bool site_mode) {

}
Expand All @@ -310,6 +318,12 @@ void queue_config_add_config_items(config_parser_type * parser, bool site_mode)
config_schema_item_iset_type(item, 0, CONFIG_INT);
}

{
config_schema_item_type * item = config_add_schema_item(parser, NUM_CPU_KEY, false);
config_schema_item_set_argc_minmax(item, 1, 1);
config_schema_item_iset_type(item, 0, CONFIG_INT);
}

{
config_schema_item_type * item = config_add_schema_item(parser, QUEUE_SYSTEM_KEY, site_mode);
config_schema_item_set_argc_minmax(item, 1, 1);
Expand Down
1 change: 1 addition & 0 deletions lib/include/ert/enkf/config_keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ extern "C" {
#define STD_SCALE_CORRELATED_OBS_KEY "STD_SCALE_CORRELATED_OBS"
#define PLOT_SETTING_KEY "PLOT_SETTINGS"
#define UPDATE_SETTING_KEY "UPDATE_SETTINGS"
#define NUM_CPU_KEY "NUM_CPU"

#define CONFIG_DIRECTORY_KEY "CONFIG_DIRECTORY"
#define RES_CONFIG_FILE_KEY "RES_CONFIG_FILE"
Expand Down
2 changes: 2 additions & 0 deletions lib/include/ert/enkf/queue_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ typedef struct queue_config_struct queue_config_type;

job_queue_type * queue_config_alloc_job_queue(const queue_config_type * queue_config);

int queue_config_get_num_cpu(const queue_config_type * queue_config);

UTIL_SAFE_CAST_HEADER(queue_config);
UTIL_IS_INSTANCE_HEADER(queue_config);

Expand Down
5 changes: 5 additions & 0 deletions python/res/enkf/queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class QueueConfig(BaseCClass):
_max_submit = ResPrototype("int queue_config_get_max_submit(queue_config)")
_queue_system = ResPrototype("char* queue_config_get_queue_system(queue_config)")
_queue_driver = ResPrototype("driver_ref queue_config_get_queue_driver(queue_config, char*)")
_get_num_cpu = ResPrototype("int queue_config_get_num_cpu(queue_config)")

def __init__(self, user_config_file=None):
c_ptr = self._alloc(user_config_file)
Expand Down Expand Up @@ -95,3 +96,7 @@ def lsf_resource(self):
def lsf_server(self):
self._assert_lsf(key=ConfigKeys.LSF_SERVER_KEY)
return self._lsf_driver.get_option(ConfigKeys.LSF_SERVER_KEY)

@property
def num_cpu(self):
return self._get_num_cpu()
2 changes: 2 additions & 0 deletions python/tests/res/enkf/test_enkf_sim_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ def test_simulation_model(self):

run_context = ErtRunContext.ensemble_experiment( result_fs, mask, runpath_fmt, jobname_fmt, subst_list, itr)
ert.getEnkfSimulationRunner().createRunPath( run_context )
queue_config = ert.get_queue_config()
self.assertEqual( queue_config.num_cpu , 5 )
os.chdir('storage/sim_kw/runpath/realisation-0/iter-0')
assert( os.path.isfile('jobs.json') )
with open("jobs.json", "r") as f:
Expand Down
1 change: 1 addition & 0 deletions test-data/local/simulation_model/sim_kw.ert
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ QUEUE_SYSTEM LOCAL
ECLBASE SIM_KW

NUM_REALIZATIONS 1
NUM_CPU 5

DEFINE <STORAGE> storage/<CONFIG_FILE_BASE>

Expand Down