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

Commit

Permalink
Clear runpath when swtiching to new iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreso committed Feb 19, 2020
1 parent 842cfb2 commit b80fac1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 56 deletions.
48 changes: 12 additions & 36 deletions lib/enkf/enkf_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1343,51 +1343,27 @@ void enkf_main_isubmit_job( enkf_main_type * enkf_main , run_arg_type * run_arg

}

void * enkf_main_icreate_run_path( enkf_main_type * enkf_main, run_arg_type * run_arg, init_mode_type init_mode) {
{
runpath_list_type * runpath_list = enkf_main_get_runpath_list(enkf_main);
runpath_list_add( runpath_list ,
run_arg_get_iens( run_arg ),
run_arg_get_iter( run_arg ),
run_arg_get_runpath( run_arg ),
run_arg_get_job_name( run_arg ));
}

/* This block accesses enkf_state - can it be removed?? */
if (init_mode != INIT_NONE) {
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type(enkf_main_get_ensemble_config(enkf_main), PARAMETER );
enkf_fs_type * init_fs = run_arg_get_sim_fs( run_arg );
rng_type * rng = rng_manager_iget( enkf_main->rng_manager, run_arg_get_iens( run_arg ));
enkf_state_type * enkf_state = enkf_main->ensemble[ run_arg_get_iens(run_arg) ];
enkf_state_initialize( enkf_state , rng, init_fs , param_list , init_mode);
stringlist_free( param_list );
}

enkf_state_init_eclipse( enkf_main->res_config,
run_arg );

runpath_list_type * runpath_list = enkf_main_get_runpath_list(enkf_main);
runpath_list_fprintf( runpath_list );
return NULL;
}


static void * enkf_main_create_run_path__( enkf_main_type * enkf_main,
static void enkf_main_write_run_path( enkf_main_type * enkf_main,
const ert_run_context_type * run_context) {

int iens;
for (iens = 0; iens < ert_run_context_get_size( run_context ); iens++) {
runpath_list_type * runpath_list = enkf_main_get_runpath_list(enkf_main);
runpath_list_clear(runpath_list);
for (int iens = 0; iens < ert_run_context_get_size( run_context ); iens++) {
if (ert_run_context_iactive( run_context , iens)) {
run_arg_type * run_arg = ert_run_context_iget_arg( run_context , iens);
enkf_main_icreate_run_path(enkf_main, run_arg, INIT_NONE);
runpath_list_add( runpath_list ,
run_arg_get_iens( run_arg ),
run_arg_get_iter( run_arg ),
run_arg_get_runpath( run_arg ),
run_arg_get_job_name( run_arg ));
enkf_state_init_eclipse( enkf_main->res_config, run_arg );
}
}
return NULL;
runpath_list_fprintf( runpath_list );
}

void enkf_main_create_run_path(enkf_main_type * enkf_main , const ert_run_context_type * run_context) {
enkf_main_init_run(enkf_main, run_context);
enkf_main_create_run_path__( enkf_main , run_context );
enkf_main_write_run_path( enkf_main , run_context );
}


Expand Down
1 change: 0 additions & 1 deletion lib/enkf/enkf_main_manage_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ static void * enkf_main_initialize_from_scratch_mt(void * void_arg) {
void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main ,
const stringlist_type * param_list ,
const ert_run_context_type * run_context) {
int num_cpu = 4;
int ens_size = enkf_main_get_ensemble_size( enkf_main );
arg_pack_type ** arg_list = (arg_pack_type **) util_calloc( ens_size , sizeof * arg_list );

Expand Down
1 change: 0 additions & 1 deletion lib/include/ert/enkf/enkf_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ extern "C" {
void enkf_main_isubmit_job( enkf_main_type * enkf_main , run_arg_type * run_arg , job_queue_type * job_queue);
const char * enkf_main_get_site_config_file( const enkf_main_type * enkf_main );
const char * enkf_main_get_schedule_prediction_file( const enkf_main_type * enkf_main );
void * enkf_main_icreate_run_path( enkf_main_type * enkf_main, run_arg_type * run_arg, init_mode_type init_mode);
void enkf_main_add_data_kw(enkf_main_type * enkf_main , const char * key , const char * value);
const res_config_type * enkf_main_get_res_config(const enkf_main_type * enkf_main);
void * enkf_main_isubmit_job__( void * arg );
Expand Down
9 changes: 2 additions & 7 deletions python/res/enkf/enkf_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ class _RealEnKFMain(BaseCClass):
_load_from_forward_model = ResPrototype("int enkf_main_load_from_forward_model_from_gui(enkf_main, int, bool_vector, enkf_fs)")
_load_from_run_context = ResPrototype("int enkf_main_load_from_run_context_from_gui(enkf_main, ert_run_context, enkf_fs)")
_create_run_path = ResPrototype("void enkf_main_create_run_path(enkf_main , ert_run_context)")
_icreate_run_path = ResPrototype("void enkf_main_icreate_run_path(enkf_main , run_arg, enkf_init_mode_enum)")
_submit_simulation = ResPrototype("void enkf_main_isubmit_job(enkf_main , run_arg, job_queue)")
_alloc_run_context_ENSEMBLE_EXPERIMENT= ResPrototype("ert_run_context_obj enkf_main_alloc_ert_run_context_ENSEMBLE_EXPERIMENT( enkf_main , enkf_fs , bool_vector , int)")
_get_runpath_list = ResPrototype("runpath_list_ref enkf_main_get_runpath_list(enkf_main)")
Expand Down Expand Up @@ -414,12 +413,8 @@ def loadFromRunContext(self, run_context, fs):
def initRun(self, run_context):
self._init_run(run_context)

def createRunpath(self , run_context, iens = None):
if iens is None:
self._create_run_path( run_context )
else:
run_arg = run_context[iens]
self._icreate_run_path( run_arg, EnkfInitModeEnum.INIT_CONDITIONAL)
def createRunpath(self , run_context):
self._create_run_path( run_context )

def submitSimulation(self , run_arg, queue):
self._submit_simulation( run_arg, queue)
Expand Down
16 changes: 5 additions & 11 deletions python/tests/res/enkf/test_runpath_list_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUp(self):
self.config_path = self.createTestPath(self.config_rel_path)


def _verify_runpath_rendering(self, itr, elementwise_runpath_creation=False):
def _verify_runpath_rendering(self, itr):
with ErtTestContext("add_all_runpath_dump", model_config=self.config_path) as ctx:
res = ctx.getErt()
fs_manager = res.getEnkfFsManager()
Expand All @@ -53,11 +53,8 @@ def _verify_runpath_rendering(self, itr, elementwise_runpath_creation=False):
for i, run_arg in enumerate(run_context):
if mask[i]:
run_arg.geo_id = 10*i
if elementwise_runpath_creation:
res.createRunpath(run_context, i)

if not elementwise_runpath_creation:
res.createRunpath(run_context)
res.createRunpath(run_context)

for i, run_arg in enumerate(run_context):
if not mask[i]:
Expand All @@ -82,9 +79,6 @@ def _verify_runpath_rendering(self, itr, elementwise_runpath_creation=False):

@tmpdir()
def test_add_all(self):
test_base = itertools.product([0, 1, 2, 17], [True, False])
for itr, elementwise_creation in test_base:
self._verify_runpath_rendering(
itr,
elementwise_runpath_creation=elementwise_creation,
)
test_base = [0, 1, 2, 17]
for itr in test_base:
self._verify_runpath_rendering(itr)

0 comments on commit b80fac1

Please sign in to comment.