mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Updated ERT, now possible to read simplified MSW
Updated ERT to 3ac60303aa2dc58aed9420a24d9a881fec32076b
This commit is contained in:
@@ -55,6 +55,6 @@ public:
|
||||
virtual void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts) = 0;
|
||||
virtual bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values) = 0;
|
||||
|
||||
virtual void readWellData(well_info_type * well_info) = 0;
|
||||
virtual void readWellData(well_info_type * well_info, bool importCompleteMswData) = 0;
|
||||
virtual int readUnitsType() = 0;
|
||||
};
|
||||
|
||||
@@ -209,7 +209,7 @@ bool RifEclipseRestartFilesetAccess::results(const QString& resultName, size_t t
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseRestartFilesetAccess::readWellData(well_info_type* well_info)
|
||||
void RifEclipseRestartFilesetAccess::readWellData(well_info_type* well_info, bool importCompleteMswData)
|
||||
{
|
||||
if (!well_info) return;
|
||||
|
||||
@@ -221,7 +221,7 @@ void RifEclipseRestartFilesetAccess::readWellData(well_info_type* well_info)
|
||||
int reportNumber = ecl_util_filename_report_nr(fileName);
|
||||
if(reportNumber != -1)
|
||||
{
|
||||
well_info_add_wells(well_info, m_ecl_files[i], reportNumber);
|
||||
well_info_add_wells(well_info, m_ecl_files[i], reportNumber, importCompleteMswData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts);
|
||||
bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values);
|
||||
|
||||
virtual void readWellData(well_info_type* well_info);
|
||||
virtual void readWellData(well_info_type* well_info, bool importCompleteMswData);
|
||||
virtual int readUnitsType();
|
||||
|
||||
private:
|
||||
|
||||
@@ -146,13 +146,13 @@ bool RifEclipseUnifiedRestartFileAccess::results(const QString& resultName, size
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseUnifiedRestartFileAccess::readWellData(well_info_type* well_info)
|
||||
void RifEclipseUnifiedRestartFileAccess::readWellData(well_info_type* well_info, bool importCompleteMswData)
|
||||
{
|
||||
if (!well_info) return;
|
||||
|
||||
if (openFile())
|
||||
{
|
||||
well_info_add_UNRST_wells(well_info, m_ecl_file);
|
||||
well_info_add_UNRST_wells(well_info, m_ecl_file, importCompleteMswData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
void resultNames(QStringList* resultNames, std::vector<size_t>* resultDataItemCounts);
|
||||
bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector<double>* values);
|
||||
|
||||
virtual void readWellData(well_info_type * well_info);
|
||||
virtual void readWellData(well_info_type * well_info, bool importCompleteMswData);
|
||||
virtual int readUnitsType();
|
||||
|
||||
private:
|
||||
|
||||
@@ -453,10 +453,8 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigCaseData* eclipseC
|
||||
|
||||
progInfo.setNextProgressIncrement(8);
|
||||
progInfo.setProgressDescription("Reading Well information");
|
||||
if (isSimulationWellDataEnabled())
|
||||
{
|
||||
readWellCells(mainEclGrid);
|
||||
}
|
||||
|
||||
readWellCells(mainEclGrid, isSimulationWellDataEnabled());
|
||||
|
||||
progInfo.setProgressDescription("Releasing reader memory");
|
||||
ecl_grid_free( mainEclGrid );
|
||||
@@ -1057,7 +1055,7 @@ void propagatePosContribDownwards(std::map<int, std::vector<SegmentPositionContr
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
||||
void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, bool importCompleteMswData)
|
||||
{
|
||||
CVF_ASSERT(m_eclipseCase);
|
||||
|
||||
@@ -1066,7 +1064,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
||||
well_info_type* ert_well_info = well_info_alloc(mainEclGrid);
|
||||
if (!ert_well_info) return;
|
||||
|
||||
m_dynamicResultsAccess->readWellData(ert_well_info);
|
||||
m_dynamicResultsAccess->readWellData(ert_well_info, importCompleteMswData);
|
||||
|
||||
RigMainGrid* mainGrid = m_eclipseCase->mainGrid();
|
||||
std::vector<RigGridBase*> grids;
|
||||
@@ -1129,7 +1127,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
||||
wellResFrame.m_isOpen = well_state_is_open( ert_well_state );
|
||||
|
||||
|
||||
if (well_state_is_MSW(ert_well_state))
|
||||
if (importCompleteMswData && well_state_is_MSW(ert_well_state))
|
||||
{
|
||||
wellResults->setMultiSegmentWell(true);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
private:
|
||||
bool readActiveCellInfo();
|
||||
void buildMetaData();
|
||||
void readWellCells(const ecl_grid_type* mainEclGrid);
|
||||
void readWellCells(const ecl_grid_type* mainEclGrid, bool importCompleteMswData);
|
||||
|
||||
std::string ertGridName( size_t gridNr );
|
||||
|
||||
|
||||
@@ -142,7 +142,10 @@ long sqrt_enkf_get_options( void * arg , long flag ) {
|
||||
}
|
||||
|
||||
|
||||
void sqrt_enkf_init_update( void * arg ,
|
||||
|
||||
// Called from analysis_module.c: analysis_module_init_update()
|
||||
void sqrt_enkf_init_update( void * arg ,
|
||||
const bool_vector_type * ens_mask,
|
||||
const matrix_type * S ,
|
||||
const matrix_type * R ,
|
||||
const matrix_type * dObs ,
|
||||
|
||||
@@ -44,7 +44,7 @@ int main(int argc, char ** argv) {
|
||||
stream = stdout;
|
||||
|
||||
ecl_grid = ecl_grid_alloc(grid_file);
|
||||
ecl_grid_dump_ascii( ecl_grid , true , stream );
|
||||
ecl_grid_dump_ascii( ecl_grid , false , stream );
|
||||
|
||||
if (output_file != NULL)
|
||||
fclose( stream );
|
||||
|
||||
@@ -20,87 +20,65 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#include <ert/util/timer.h>
|
||||
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
|
||||
|
||||
|
||||
void test_case( const char * base , bool load_all) {
|
||||
timer_type * ti = timer_alloc(false);
|
||||
timer_type * tr = timer_alloc(false);
|
||||
timer_type * tg = timer_alloc(false);
|
||||
timer_type * ti = timer_alloc(false);
|
||||
timer_type * tr = timer_alloc(false);
|
||||
timer_type * tg = timer_alloc(false);
|
||||
|
||||
char * grid_file = NULL;
|
||||
char * init_file = NULL;
|
||||
char * restart_file = NULL;
|
||||
char * grid_file = ecl_util_alloc_filename( NULL , base , ECL_EGRID_FILE , false , 0 );
|
||||
char * init_file = ecl_util_alloc_filename( NULL , base , ECL_INIT_FILE , false , 0 );
|
||||
char * restart_file = ecl_util_alloc_filename( NULL , base , ECL_UNIFIED_RESTART_FILE , false , 0 );
|
||||
|
||||
// grid_file = ecl_util_alloc_filename( NULL , base , ECL_EGRID_FILE , false , 0 );
|
||||
// init_file = ecl_util_alloc_filename( NULL , base , ECL_INIT_FILE , false , 0 );
|
||||
restart_file = ecl_util_alloc_filename( NULL , base , ECL_UNIFIED_RESTART_FILE , false , 0 );
|
||||
ecl_grid_type * grid;
|
||||
ecl_file_type * restart;
|
||||
ecl_file_type * init;
|
||||
|
||||
|
||||
timer_start( tg );
|
||||
if (grid_file)
|
||||
{
|
||||
ecl_grid_type * grid = NULL;
|
||||
grid = ecl_grid_alloc(grid_file );
|
||||
ecl_grid_free( grid );
|
||||
}
|
||||
timer_stop( tg );
|
||||
timer_start( tg );
|
||||
grid = ecl_grid_alloc(grid_file );
|
||||
timer_stop( tg );
|
||||
|
||||
timer_start( ti );
|
||||
if (init_file)
|
||||
{
|
||||
ecl_file_type * init = NULL;
|
||||
init = ecl_file_open( init_file , 0);
|
||||
if (load_all)
|
||||
{
|
||||
ecl_file_load_all( init );
|
||||
}
|
||||
ecl_file_close( init );
|
||||
}
|
||||
timer_stop( ti );
|
||||
timer_start( ti );
|
||||
init = ecl_file_open( init_file , 0);
|
||||
if (load_all)
|
||||
ecl_file_load_all( init );
|
||||
timer_stop( ti );
|
||||
|
||||
timer_start( tr );
|
||||
if (restart_file)
|
||||
{
|
||||
ecl_file_type * restart = NULL;
|
||||
restart = ecl_file_open( restart_file , 0);
|
||||
if (load_all)
|
||||
{
|
||||
ecl_file_load_all( restart );
|
||||
}
|
||||
ecl_file_close( restart );
|
||||
}
|
||||
timer_stop( tr );
|
||||
timer_start( tr );
|
||||
restart = ecl_file_open( restart_file , 0);
|
||||
if (load_all)
|
||||
ecl_file_load_all( restart );
|
||||
timer_stop( tr );
|
||||
|
||||
|
||||
printf("%-64s Restart:%8.4f Grid:%8.4f Init:%8.4f \n",
|
||||
base,
|
||||
timer_get_total_time( tr ),
|
||||
timer_get_total_time( tg ),
|
||||
timer_get_total_time( ti ));
|
||||
printf("%-64s Restart:%8.4f Grid:%8.4f Init:%8.4f \n",
|
||||
base,
|
||||
timer_get_total_time( tr ),
|
||||
timer_get_total_time( tg ),
|
||||
timer_get_total_time( ti ));
|
||||
|
||||
timer_free( tr );
|
||||
timer_free( ti );
|
||||
timer_free( tg );
|
||||
free( grid_file );
|
||||
free( init_file );
|
||||
free( restart_file );
|
||||
timer_free( tr );
|
||||
timer_free( ti );
|
||||
timer_free( tg );
|
||||
ecl_file_close( init );
|
||||
ecl_file_close( restart );
|
||||
ecl_grid_free( grid );
|
||||
free( grid_file );
|
||||
free( init_file );
|
||||
free( restart_file );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
bool load_all = false;
|
||||
bool load_all = true;
|
||||
int i;
|
||||
|
||||
// system("pause");
|
||||
|
||||
for (i=1; i < argc; i++)
|
||||
test_case( argv[i] , load_all);
|
||||
|
||||
system("pause");
|
||||
|
||||
}
|
||||
|
||||
@@ -345,10 +345,10 @@ extern "C" {
|
||||
#define FILEHEAD_DUAL_PERMEABILITY 2
|
||||
|
||||
|
||||
#define INACTIVE 0
|
||||
#define ACTIVE_MATRIX 1
|
||||
#define ACTIVE ACTIVE_MATRIX
|
||||
#define ACTIVE_FRACTURE 2
|
||||
#define CELL_NOT_ACTIVE 0
|
||||
#define CELL_ACTIVE_MATRIX 1
|
||||
#define CELL_ACTIVE CELL_ACTIVE_MATRIX
|
||||
#define CELL_ACTIVE_FRACTURE 2
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -287,14 +287,14 @@ const int * ecl_coarse_cell_get_box_ptr( const ecl_coarse_cell_type * coarse_cel
|
||||
/*****************************************************************/
|
||||
|
||||
void ecl_coarse_cell_update_index( ecl_coarse_cell_type * coarse_cell , int global_index , int * active_index , int * active_fracture_index , int active_value) {
|
||||
if (active_value & ACTIVE_MATRIX) {
|
||||
if (active_value & CELL_ACTIVE_MATRIX) {
|
||||
if (coarse_cell->active_index == -1) {
|
||||
coarse_cell->active_index = *active_index;
|
||||
(*active_index) += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (active_value & ACTIVE_FRACTURE) {
|
||||
if (active_value & CELL_ACTIVE_FRACTURE) {
|
||||
if (coarse_cell->active_fracture_index == -1) {
|
||||
coarse_cell->active_fracture_index = *active_fracture_index;
|
||||
(*active_fracture_index) += 1;
|
||||
|
||||
48
ThirdParty/Ert/devel/libecl/src/ecl_grid.c
vendored
48
ThirdParty/Ert/devel/libecl/src/ecl_grid.c
vendored
@@ -714,10 +714,10 @@ static void ecl_cell_fwrite_GRID( const ecl_grid_type * grid , const ecl_cell_ty
|
||||
|
||||
ecl_kw_iset_int( coords_kw , 4 , 0);
|
||||
if (fracture_cell) {
|
||||
if (cell->active & ACTIVE_FRACTURE)
|
||||
if (cell->active & CELL_ACTIVE_FRACTURE)
|
||||
ecl_kw_iset_int( coords_kw , 4 , 1);
|
||||
} else {
|
||||
if (cell->active & ACTIVE_MATRIX)
|
||||
if (cell->active & CELL_ACTIVE_MATRIX)
|
||||
ecl_kw_iset_int( coords_kw , 4 , 1);
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@ static void ecl_cell_taint_cell( ecl_cell_type * cell ) {
|
||||
/*
|
||||
Second heuristic to invalidate cells.
|
||||
*/
|
||||
if (cell->active == INACTIVE) {
|
||||
if (cell->active == CELL_NOT_ACTIVE) {
|
||||
if (!GET_CELL_FLAG(cell , CELL_FLAG_TAINTED)) {
|
||||
const point_type p0 = cell->corner_list[0];
|
||||
int cell_index = 1;
|
||||
@@ -939,7 +939,7 @@ static void ecl_cell_taint_cell( ecl_cell_type * cell ) {
|
||||
*/
|
||||
|
||||
static void ecl_cell_init( ecl_cell_type * cell , bool init_valid) {
|
||||
cell->active = INACTIVE;
|
||||
cell->active = CELL_NOT_ACTIVE;
|
||||
cell->lgr = NULL;
|
||||
cell->host_cell = HOST_CELL_NONE;
|
||||
cell->coarse_group = COARSE_GROUP_NONE;
|
||||
@@ -1205,7 +1205,7 @@ static void ecl_cell_init_regular( ecl_cell_type * cell , const double * offset
|
||||
if (actnum != NULL)
|
||||
cell->active = actnum[global_index];
|
||||
else
|
||||
cell->active = ACTIVE;
|
||||
cell->active = CELL_ACTIVE;
|
||||
}
|
||||
|
||||
/* end of cell implementation */
|
||||
@@ -1375,7 +1375,7 @@ static void ecl_grid_set_cell_EGRID(ecl_grid_type * ecl_grid , int i, int j , in
|
||||
for dual porosity models it can also be 2 and 3.
|
||||
*/
|
||||
if (actnum == NULL)
|
||||
cell->active = ACTIVE;
|
||||
cell->active = CELL_ACTIVE;
|
||||
else
|
||||
cell->active = actnum[global_index];
|
||||
|
||||
@@ -1392,7 +1392,7 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size ,
|
||||
int global_index;
|
||||
ecl_cell_type * cell;
|
||||
bool matrix_cell = true;
|
||||
int active_value = ACTIVE_MATRIX;
|
||||
int active_value = CELL_ACTIVE_MATRIX;
|
||||
|
||||
/*
|
||||
This is the rather hysterical treatment of dual porosity in GRID
|
||||
@@ -1405,7 +1405,7 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size ,
|
||||
if (k >= ecl_grid->nz) {
|
||||
k -= ecl_grid->nz;
|
||||
matrix_cell = false;
|
||||
active_value = ACTIVE_FRACTURE;
|
||||
active_value = CELL_ACTIVE_FRACTURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1506,14 +1506,14 @@ static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) {
|
||||
{
|
||||
ecl_grid->index_map = util_realloc(ecl_grid->index_map , ecl_grid->size * sizeof * ecl_grid->index_map );
|
||||
ecl_grid->inv_index_map = util_realloc(ecl_grid->inv_index_map , ecl_grid->total_active * sizeof * ecl_grid->inv_index_map );
|
||||
ecl_grid_init_index_map__( ecl_grid , ecl_grid->index_map , ecl_grid->inv_index_map , ACTIVE_MATRIX , MATRIX_INDEX);
|
||||
ecl_grid_init_index_map__( ecl_grid , ecl_grid->index_map , ecl_grid->inv_index_map , CELL_ACTIVE_MATRIX , MATRIX_INDEX);
|
||||
}
|
||||
|
||||
/* Create the inverse mapping for the fractures. */
|
||||
if (ecl_grid->dualp_flag != FILEHEAD_SINGLE_POROSITY) {
|
||||
ecl_grid->fracture_index_map = util_realloc(ecl_grid->fracture_index_map , ecl_grid->size * sizeof * ecl_grid->fracture_index_map );
|
||||
ecl_grid->inv_fracture_index_map = util_realloc(ecl_grid->inv_fracture_index_map , ecl_grid->total_active_fracture * sizeof * ecl_grid->inv_fracture_index_map );
|
||||
ecl_grid_init_index_map__( ecl_grid , ecl_grid->fracture_index_map , ecl_grid->inv_fracture_index_map , ACTIVE_FRACTURE , FRACTURE_INDEX);
|
||||
ecl_grid_init_index_map__( ecl_grid , ecl_grid->fracture_index_map , ecl_grid->inv_fracture_index_map , CELL_ACTIVE_FRACTURE , FRACTURE_INDEX);
|
||||
}
|
||||
|
||||
|
||||
@@ -1531,10 +1531,10 @@ static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) {
|
||||
int active_index = ecl_coarse_cell_get_active_index( coarse_cell );
|
||||
int active_fracture_index = ecl_coarse_cell_get_active_fracture_index( coarse_cell );
|
||||
|
||||
if (active_value & ACTIVE_MATRIX)
|
||||
if (active_value & CELL_ACTIVE_MATRIX)
|
||||
ecl_grid->inv_index_map[ active_index ] = global_index; // The active -> global mapping point to one "random" cell in the coarse group
|
||||
|
||||
if (active_value & ACTIVE_FRACTURE)
|
||||
if (active_value & CELL_ACTIVE_FRACTURE)
|
||||
ecl_grid->inv_fracture_index_map[ active_fracture_index ] = global_index;
|
||||
|
||||
{
|
||||
@@ -1544,10 +1544,10 @@ static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) {
|
||||
for (ic =0; ic < coarse_size; ic++) {
|
||||
int gi = int_vector_iget( global_index_list , ic );
|
||||
|
||||
if (active_value & ACTIVE_MATRIX)
|
||||
if (active_value & CELL_ACTIVE_MATRIX)
|
||||
ecl_grid->index_map[ gi ] = active_index; // All the cells in the coarse group point to the same active index.
|
||||
|
||||
if (active_value & ACTIVE_FRACTURE)
|
||||
if (active_value & CELL_ACTIVE_FRACTURE)
|
||||
ecl_grid->fracture_index_map[ gi ] = active_fracture_index;
|
||||
}
|
||||
}
|
||||
@@ -1576,7 +1576,7 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) {
|
||||
for (global_index = 0; global_index < ecl_grid->size; global_index++) {
|
||||
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index);
|
||||
|
||||
if (cell->active & ACTIVE_MATRIX) {
|
||||
if (cell->active & CELL_ACTIVE_MATRIX) {
|
||||
cell->active_index[MATRIX_INDEX] = active_index;
|
||||
active_index++;
|
||||
}
|
||||
@@ -1586,7 +1586,7 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) {
|
||||
if (ecl_grid->dualp_flag != FILEHEAD_SINGLE_POROSITY) {
|
||||
for (global_index = 0; global_index < ecl_grid->size; global_index++) {
|
||||
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index);
|
||||
if (cell->active & ACTIVE_FRACTURE) {
|
||||
if (cell->active & CELL_ACTIVE_FRACTURE) {
|
||||
cell->active_index[FRACTURE_INDEX] = active_fracture_index;
|
||||
active_fracture_index++;
|
||||
}
|
||||
@@ -1601,15 +1601,15 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) {
|
||||
*/
|
||||
for (global_index = 0; global_index < ecl_grid->size; global_index++) {
|
||||
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index);
|
||||
if (cell->active != INACTIVE) {
|
||||
if (cell->active != CELL_NOT_ACTIVE) {
|
||||
if (cell->coarse_group == COARSE_GROUP_NONE) {
|
||||
|
||||
if (cell->active & ACTIVE_MATRIX) {
|
||||
if (cell->active & CELL_ACTIVE_MATRIX) {
|
||||
cell->active_index[MATRIX_INDEX] = active_index;
|
||||
active_index++;
|
||||
}
|
||||
|
||||
if (cell->active & ACTIVE_FRACTURE) {
|
||||
if (cell->active & CELL_ACTIVE_FRACTURE) {
|
||||
cell->active_index[FRACTURE_INDEX] = active_fracture_index;
|
||||
active_fracture_index++;
|
||||
}
|
||||
@@ -1643,11 +1643,11 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) {
|
||||
{
|
||||
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index );
|
||||
|
||||
if (cell_active_value & ACTIVE_MATRIX)
|
||||
if (cell_active_value & CELL_ACTIVE_MATRIX)
|
||||
cell->active_index[MATRIX_INDEX] = cell_active_index;
|
||||
|
||||
/* Coarse cell and dual porosity - that is probably close to zero measure. */
|
||||
if (cell_active_value & ACTIVE_FRACTURE) {
|
||||
if (cell_active_value & CELL_ACTIVE_FRACTURE) {
|
||||
int cell_active_fracture_index = ecl_coarse_cell_get_active_fracture_index( coarse_cell );
|
||||
cell->active_index[FRACTURE_INDEX] = cell_active_fracture_index;
|
||||
}
|
||||
@@ -2853,7 +2853,7 @@ ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , con
|
||||
if (actnum)
|
||||
cell->active = actnum[global_index];
|
||||
else
|
||||
cell->active = ACTIVE;
|
||||
cell->active = CELL_ACTIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2917,7 +2917,7 @@ ecl_grid_type * ecl_grid_alloc_dx_dy_dz_tops( int nx, int ny , int nz , const do
|
||||
if (actnum != NULL)
|
||||
cell->active = actnum[g];
|
||||
else
|
||||
cell->active = ACTIVE;
|
||||
cell->active = CELL_ACTIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5488,7 +5488,7 @@ void ecl_grid_init_actnum_data( const ecl_grid_type * grid , int * actnum ) {
|
||||
const int * index_ptr = ecl_coarse_cell_get_index_ptr( coarse_cell );
|
||||
int j;
|
||||
for (j=0; j < group_size; j++)
|
||||
actnum[index_ptr[j]] = INACTIVE;
|
||||
actnum[index_ptr[j]] = CELL_NOT_ACTIVE;
|
||||
}
|
||||
|
||||
/* 2: Explicitly pick up the active cells from the coarse group
|
||||
|
||||
@@ -52,13 +52,13 @@ int main(int argc , char ** argv) {
|
||||
int fracture_index = 0;
|
||||
|
||||
for (gi = 0; gi < ecl_grid_get_global_size( ecl_grid ); gi++) {
|
||||
if (ecl_kw_iget_int( actnum , gi ) & ACTIVE_MATRIX) {
|
||||
if (ecl_kw_iget_int( actnum , gi ) & CELL_ACTIVE_MATRIX) {
|
||||
test_assert_int_equal( ecl_grid_get_active_index1( ecl_grid , gi ) , matrix_index);
|
||||
test_assert_int_equal( ecl_grid_get_global_index1A( ecl_grid , matrix_index ) , gi);
|
||||
matrix_index++;
|
||||
}
|
||||
|
||||
if (ecl_kw_iget_int( actnum , gi ) & ACTIVE_FRACTURE) {
|
||||
if (ecl_kw_iget_int( actnum , gi ) & CELL_ACTIVE_FRACTURE) {
|
||||
test_assert_int_equal( ecl_grid_get_active_fracture_index1( ecl_grid , gi ) , fracture_index);
|
||||
test_assert_int_equal( ecl_grid_get_global_index1F( ecl_grid , fracture_index ) , gi);
|
||||
fracture_index++;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
//#include <unistd.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <ert/util/stringlist.h>
|
||||
@@ -57,8 +57,10 @@ int main(int argc , char ** argv) {
|
||||
{
|
||||
well_conn_collection_type * connections = well_conn_collection_alloc();
|
||||
well_segment_collection_type * segments = well_segment_collection_alloc();
|
||||
bool load_segment_information = true;
|
||||
bool is_MSW_well = false;
|
||||
|
||||
if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_loader , rst_head )) {
|
||||
if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_loader , rst_head , load_segment_information , &is_MSW_well)) {
|
||||
well_branch_collection_type * branches = well_branch_collection_alloc();
|
||||
|
||||
well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , scon_kw , well_nr , rst_head);
|
||||
|
||||
@@ -29,7 +29,7 @@ int main( int argc , char ** argv ) {
|
||||
ecl_grid_type * grid = ecl_grid_alloc( grid_file );
|
||||
well_info_type * well_info = well_info_alloc( grid );
|
||||
|
||||
well_info_load_rstfile( well_info , rst_file );
|
||||
well_info_load_rstfile( well_info , rst_file , true );
|
||||
{
|
||||
int iw;
|
||||
int ic;
|
||||
|
||||
@@ -32,10 +32,10 @@ extern "C" {
|
||||
typedef struct well_info_struct well_info_type;
|
||||
|
||||
well_info_type * well_info_alloc(const ecl_grid_type * grid);
|
||||
void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst_file);
|
||||
void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file , int report_nr );
|
||||
void well_info_load_rstfile( well_info_type * well_info , const char * filename);
|
||||
void well_info_load_rst_eclfile( well_info_type * well_info , ecl_file_type * rst_file);
|
||||
void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst_file, bool load_segment_information);
|
||||
void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file , int report_nr , bool load_segment_information);
|
||||
void well_info_load_rstfile( well_info_type * well_info , const char * filename, bool load_segment_information);
|
||||
void well_info_load_rst_eclfile( well_info_type * well_info , ecl_file_type * rst_file , bool load_segment_information);
|
||||
void well_info_free( well_info_type * well_info );
|
||||
|
||||
well_ts_type * well_info_get_ts( const well_info_type * well_info , const char *well_name);
|
||||
|
||||
@@ -47,7 +47,9 @@ extern "C" {
|
||||
const ecl_kw_type * iwel_kw ,
|
||||
const ecl_kw_type * iseg_kw ,
|
||||
const well_rseg_loader_type * rseg_loader ,
|
||||
const ecl_rsthead_type * rst_head);
|
||||
const ecl_rsthead_type * rst_head,
|
||||
bool load_segment_information , bool * is_MSW_well);
|
||||
|
||||
void well_segment_collection_link(const well_segment_collection_type * segment_collection);
|
||||
void well_segment_collection_add_connections(well_segment_collection_type * segment_collection ,
|
||||
const char * grid_name ,
|
||||
|
||||
@@ -41,7 +41,7 @@ extern "C" {
|
||||
typedef struct well_state_struct well_state_type;
|
||||
|
||||
well_state_type * well_state_alloc(const char * well_name , int global_well_nr , bool open, well_type_enum type , int report_nr, time_t valid_from);
|
||||
well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const ecl_grid_type * grid , int report_step , int well_nr);
|
||||
well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const ecl_grid_type * grid , int report_step , int well_nr , bool load_segment_information);
|
||||
|
||||
void well_state_add_connections( well_state_type * well_state ,
|
||||
const ecl_grid_type * grid ,
|
||||
@@ -50,10 +50,14 @@ extern "C" {
|
||||
|
||||
bool well_state_add_MSW( well_state_type * well_state ,
|
||||
const ecl_file_type * rst_file ,
|
||||
int well_nr);
|
||||
int well_nr,
|
||||
bool load_segment_information);
|
||||
|
||||
|
||||
bool well_state_is_MSW( const well_state_type * well_state);
|
||||
|
||||
bool well_state_has_segment_data(const well_state_type * well_state);
|
||||
|
||||
well_segment_collection_type * well_state_get_segments( const well_state_type * well_state );
|
||||
well_branch_collection_type * well_state_get_branches( const well_state_type * well_state );
|
||||
|
||||
|
||||
18
ThirdParty/Ert/devel/libecl_well/src/well_info.c
vendored
18
ThirdParty/Ert/devel/libecl_well/src/well_info.c
vendored
@@ -273,7 +273,7 @@ static void well_info_add_state( well_info_type * well_info , well_state_type *
|
||||
determine the number of wells.
|
||||
*/
|
||||
|
||||
void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file , int report_nr) {
|
||||
void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file , int report_nr, bool load_segment_information) {
|
||||
int flags = ecl_file_get_flags(rst_file);
|
||||
if (ecl_file_flags_set(rst_file, ECL_FILE_CLOSE_STREAM)) {
|
||||
int new_flags = flags & ~ECL_FILE_CLOSE_STREAM;
|
||||
@@ -284,7 +284,7 @@ void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file
|
||||
ecl_rsthead_type * global_header = ecl_rsthead_alloc( rst_file );
|
||||
int well_nr;
|
||||
for (well_nr = 0; well_nr < global_header->nwells; well_nr++) {
|
||||
well_state_type * well_state = well_state_alloc_from_file( rst_file , well_info->grid , report_nr , well_nr );
|
||||
well_state_type * well_state = well_state_alloc_from_file( rst_file , well_info->grid , report_nr , well_nr , load_segment_information );
|
||||
if (well_state != NULL)
|
||||
well_info_add_state( well_info , well_state );
|
||||
}
|
||||
@@ -300,7 +300,7 @@ void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file
|
||||
not have the SEQNUM keyword.
|
||||
*/
|
||||
|
||||
void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst_file) {
|
||||
void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst_file, bool load_segment_information) {
|
||||
{
|
||||
int num_blocks = ecl_file_get_num_named_kw( rst_file , SEQNUM_KW );
|
||||
int block_nr;
|
||||
@@ -311,7 +311,7 @@ void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst
|
||||
{ // is not changed as a side
|
||||
const ecl_kw_type * seqnum_kw = ecl_file_iget_named_kw( rst_file , SEQNUM_KW , 0); // effect.
|
||||
int report_nr = ecl_kw_iget_int( seqnum_kw , 0 ); //
|
||||
well_info_add_wells( well_info , rst_file , report_nr ); //
|
||||
well_info_add_wells( well_info , rst_file , report_nr , load_segment_information ); //
|
||||
} //
|
||||
} //
|
||||
ecl_file_pop_block( rst_file ); // <-------------------------------------------------------
|
||||
@@ -326,23 +326,23 @@ void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst
|
||||
have crash and burn.
|
||||
*/
|
||||
|
||||
void well_info_load_rstfile( well_info_type * well_info , const char * filename) {
|
||||
void well_info_load_rstfile( well_info_type * well_info , const char * filename, bool load_segment_information) {
|
||||
ecl_file_type * ecl_file = ecl_file_open( filename , 0);
|
||||
well_info_load_rst_eclfile(well_info, ecl_file);
|
||||
well_info_load_rst_eclfile(well_info, ecl_file, load_segment_information);
|
||||
ecl_file_close( ecl_file );
|
||||
}
|
||||
|
||||
|
||||
void well_info_load_rst_eclfile( well_info_type * well_info , ecl_file_type * ecl_file) {
|
||||
void well_info_load_rst_eclfile( well_info_type * well_info , ecl_file_type * ecl_file, bool load_segment_information) {
|
||||
int report_nr;
|
||||
const char* filename = ecl_file_get_src_file(ecl_file);
|
||||
ecl_file_enum file_type = ecl_util_get_file_type( filename , NULL , &report_nr);
|
||||
if ((file_type == ECL_RESTART_FILE) || (file_type == ECL_UNIFIED_RESTART_FILE))
|
||||
{
|
||||
if (file_type == ECL_RESTART_FILE)
|
||||
well_info_add_wells( well_info , ecl_file , report_nr );
|
||||
well_info_add_wells( well_info , ecl_file , report_nr , load_segment_information );
|
||||
else
|
||||
well_info_add_UNRST_wells( well_info , ecl_file );
|
||||
well_info_add_UNRST_wells( well_info , ecl_file , load_segment_information );
|
||||
|
||||
} else
|
||||
util_abort("%s: invalid file type: %s - must be a restart file\n", __func__ , filename);
|
||||
|
||||
@@ -104,23 +104,28 @@ int well_segment_collection_load_from_kw( well_segment_collection_type * segment
|
||||
const ecl_kw_type * iwel_kw ,
|
||||
const ecl_kw_type * iseg_kw ,
|
||||
const well_rseg_loader_type * rseg_loader ,
|
||||
const ecl_rsthead_type * rst_head) {
|
||||
|
||||
const ecl_rsthead_type * rst_head ,
|
||||
bool load_segments , bool * is_MSW_well) {
|
||||
|
||||
int iwel_offset = rst_head->niwelz * well_nr;
|
||||
int segment_well_nr = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_SEGMENTED_WELL_NR_ITEM) - 1;
|
||||
int segments_added = 0;
|
||||
|
||||
if (segment_well_nr != IWEL_SEGMENTED_WELL_NR_NORMAL_VALUE) {
|
||||
int segment_index;
|
||||
for (segment_index = 0; segment_index < rst_head->nsegmx; segment_index++) {
|
||||
int segment_id = segment_index + WELL_SEGMENT_OFFSET;
|
||||
well_segment_type * segment = well_segment_alloc_from_kw( iseg_kw , rseg_loader , rst_head , segment_well_nr , segment_index , segment_id );
|
||||
*is_MSW_well = true;
|
||||
|
||||
if (well_segment_active( segment )) {
|
||||
well_segment_collection_add( segment_collection , segment );
|
||||
segments_added++;
|
||||
} else
|
||||
well_segment_free( segment );
|
||||
if (load_segments) {
|
||||
for (segment_index = 0; segment_index < rst_head->nsegmx; segment_index++) {
|
||||
int segment_id = segment_index + WELL_SEGMENT_OFFSET;
|
||||
well_segment_type * segment = well_segment_alloc_from_kw( iseg_kw , rseg_loader , rst_head , segment_well_nr , segment_index , segment_id );
|
||||
|
||||
if (well_segment_active( segment )) {
|
||||
well_segment_collection_add( segment_collection , segment );
|
||||
segments_added++;
|
||||
} else
|
||||
well_segment_free( segment );
|
||||
}
|
||||
}
|
||||
}
|
||||
return segments_added;
|
||||
|
||||
@@ -168,6 +168,7 @@ struct well_state_struct {
|
||||
int global_well_nr;
|
||||
bool open;
|
||||
well_type_enum type;
|
||||
bool is_MSW_well;
|
||||
|
||||
hash_type * connections; // hash<grid_name,well_conn_collection>
|
||||
well_segment_collection_type * segments;
|
||||
@@ -199,6 +200,7 @@ well_state_type * well_state_alloc(const char * well_name , int global_well_nr ,
|
||||
well_state->connections = hash_alloc();
|
||||
well_state->segments = well_segment_collection_alloc();
|
||||
well_state->branches = well_branch_collection_alloc();
|
||||
well_state->is_MSW_well = false;
|
||||
|
||||
/* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */
|
||||
if ((type == UNDOCUMENTED_ZERO) && open)
|
||||
@@ -370,7 +372,8 @@ void well_state_add_connections( well_state_type * well_state ,
|
||||
|
||||
bool well_state_add_MSW( well_state_type * well_state ,
|
||||
const ecl_file_type * rst_file ,
|
||||
int well_nr) {
|
||||
int well_nr,
|
||||
bool load_segment_information) {
|
||||
|
||||
if (ecl_file_has_kw( rst_file , ISEG_KW)) {
|
||||
ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file );
|
||||
@@ -378,50 +381,60 @@ bool well_state_add_MSW( well_state_type * well_state ,
|
||||
const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0);
|
||||
well_rseg_loader_type * rseg_loader = NULL;
|
||||
|
||||
int segments;
|
||||
int segment_count;
|
||||
|
||||
if (ecl_file_has_kw( rst_file , RSEG_KW ))
|
||||
if (ecl_file_has_kw( rst_file , RSEG_KW )) {
|
||||
if (load_segment_information)
|
||||
rseg_loader = well_rseg_loader_alloc(rst_file);
|
||||
|
||||
segment_count = well_segment_collection_load_from_kw( well_state->segments ,
|
||||
well_nr ,
|
||||
iwel_kw ,
|
||||
iseg_kw ,
|
||||
rseg_loader ,
|
||||
rst_head,
|
||||
load_segment_information ,
|
||||
&well_state->is_MSW_well);
|
||||
|
||||
|
||||
if (segment_count > 0) {
|
||||
hash_iter_type * grid_iter = hash_iter_alloc( well_state->connections );
|
||||
while (!hash_iter_is_complete( grid_iter )) {
|
||||
const char * grid_name = hash_iter_get_next_key( grid_iter );
|
||||
const well_conn_collection_type * connections = hash_get( well_state->connections , grid_name );
|
||||
well_segment_collection_add_connections( well_state->segments , grid_name , connections );
|
||||
}
|
||||
hash_iter_free( grid_iter );
|
||||
|
||||
segments = well_segment_collection_load_from_kw( well_state->segments ,
|
||||
well_nr ,
|
||||
iwel_kw ,
|
||||
iseg_kw ,
|
||||
rseg_loader ,
|
||||
rst_head);
|
||||
|
||||
if (segments) {
|
||||
hash_iter_type * grid_iter = hash_iter_alloc( well_state->connections );
|
||||
while (!hash_iter_is_complete( grid_iter )) {
|
||||
const char * grid_name = hash_iter_get_next_key( grid_iter );
|
||||
const well_conn_collection_type * connections = hash_get( well_state->connections , grid_name );
|
||||
well_segment_collection_add_connections( well_state->segments , grid_name , connections );
|
||||
well_segment_collection_link( well_state->segments );
|
||||
well_segment_collection_add_branches( well_state->segments , well_state->branches );
|
||||
}
|
||||
hash_iter_free( grid_iter );
|
||||
well_segment_collection_link( well_state->segments );
|
||||
well_segment_collection_add_branches( well_state->segments , well_state->branches );
|
||||
}
|
||||
ecl_rsthead_free( rst_head );
|
||||
|
||||
if(rseg_loader != NULL) {
|
||||
ecl_rsthead_free( rst_head );
|
||||
|
||||
if (rseg_loader != NULL) {
|
||||
well_rseg_loader_free(rseg_loader);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool well_state_is_MSW( const well_state_type * well_state) {
|
||||
if (well_segment_collection_get_size( well_state->segments ) > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return well_state->is_MSW_well;
|
||||
}
|
||||
|
||||
bool well_state_has_segment_data(const well_state_type * well_state){
|
||||
if (well_segment_collection_get_size( well_state->segments ) > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const ecl_grid_type * grid , int report_nr , int global_well_nr) {
|
||||
well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const ecl_grid_type * grid , int report_nr , int global_well_nr ,bool load_segment_information) {
|
||||
if (ecl_file_has_kw( ecl_file , IWEL_KW)) {
|
||||
well_state_type * well_state = NULL;
|
||||
ecl_rsthead_type * global_header = ecl_rsthead_alloc( ecl_file );
|
||||
@@ -456,7 +469,9 @@ well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const e
|
||||
|
||||
well_state_add_connections( well_state , grid , ecl_file , global_well_nr);
|
||||
if (ecl_file_has_kw( ecl_file , ISEG_KW))
|
||||
well_state_add_MSW( well_state , ecl_file , global_well_nr );
|
||||
well_state_add_MSW( well_state , ecl_file , global_well_nr , load_segment_information);
|
||||
|
||||
|
||||
}
|
||||
ecl_rsthead_free( global_header );
|
||||
return well_state;
|
||||
|
||||
@@ -44,7 +44,7 @@ int main( int argc , char ** argv) {
|
||||
ecl_grid_type * grid = ecl_grid_alloc( argv[1] );
|
||||
well_info_type * well_info = well_info_alloc( grid );
|
||||
|
||||
well_info_load_rstfile( well_info , argv[2]);
|
||||
well_info_load_rstfile( well_info , argv[2] , true);
|
||||
|
||||
// List all wells:
|
||||
{
|
||||
|
||||
@@ -56,8 +56,10 @@ int main(int argc , char ** argv) {
|
||||
well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , scon_kw , well_nr , rst_head);
|
||||
{
|
||||
well_segment_collection_type * segments = well_segment_collection_alloc();
|
||||
bool load_segment_information = true;
|
||||
bool is_MSW_well = false;
|
||||
|
||||
if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_loader , rst_head )) {
|
||||
if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_loader , rst_head , load_segment_information , &is_MSW_well)) {
|
||||
well_branch_collection_type * branches = well_branch_collection_alloc();
|
||||
|
||||
test_assert_true( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head));
|
||||
|
||||
@@ -74,9 +74,17 @@ int main(int argc , char ** argv) {
|
||||
|
||||
{
|
||||
well_segment_collection_type * segments2 = well_segment_collection_alloc();
|
||||
test_assert_int_equal( well_segment_collection_load_from_kw( segments2 , well_nr , iwel_kw , iseg_kw , rseg_loader , rst_head ) ,
|
||||
bool load_segments = true;
|
||||
bool is_MSW_well = false;
|
||||
test_assert_int_equal( well_segment_collection_load_from_kw( segments2 , well_nr , iwel_kw , iseg_kw , rseg_loader , rst_head , load_segments , &is_MSW_well ) ,
|
||||
well_segment_collection_get_size( segments));
|
||||
|
||||
if (well_segment_collection_get_size( segments ) > 0)
|
||||
test_assert_true( is_MSW_well );
|
||||
else
|
||||
test_assert_false( is_MSW_well );
|
||||
|
||||
|
||||
well_segment_collection_link( segments );
|
||||
well_segment_collection_link( segments2 );
|
||||
well_segment_collection_free( segments );
|
||||
|
||||
@@ -45,7 +45,8 @@ int main(int argc , char ** argv) {
|
||||
bool open = false;
|
||||
well_type_enum type = GAS_INJECTOR;
|
||||
int global_well_nr = 0;
|
||||
|
||||
bool load_segment_information = true;
|
||||
|
||||
for (global_well_nr = 0; global_well_nr < header->nwells; global_well_nr++) {
|
||||
well_state_type * well_state = well_state_alloc(well_name , global_well_nr , open , type , report_nr , valid_from);
|
||||
test_assert_true( well_state_is_instance( well_state) );
|
||||
@@ -55,7 +56,7 @@ int main(int argc , char ** argv) {
|
||||
test_assert_false( well_state_has_grid_connections( well_state , "???" ));
|
||||
test_assert_true( well_state_has_global_connections( well_state ));
|
||||
|
||||
well_state_add_MSW( well_state , rst_file , global_well_nr );
|
||||
well_state_add_MSW( well_state , rst_file , global_well_nr , load_segment_information );
|
||||
{
|
||||
const well_segment_collection_type * segments = well_state_get_segments( well_state );
|
||||
const well_branch_collection_type * branches = well_state_get_branches( well_state );
|
||||
|
||||
@@ -45,12 +45,13 @@ int main(int argc , char ** argv) {
|
||||
bool open = false;
|
||||
well_type_enum type = GAS_INJECTOR;
|
||||
int global_well_nr = 0;
|
||||
bool load_segment_information = false;
|
||||
|
||||
for (global_well_nr = 0; global_well_nr < header->nwells; global_well_nr++) {
|
||||
well_state_type * well_state = well_state_alloc(well_name , global_well_nr , open , type , report_nr , valid_from);
|
||||
test_assert_true( well_state_is_instance( well_state) );
|
||||
well_state_add_connections( well_state , grid , rst_file , 0 );
|
||||
well_state_add_MSW( well_state , rst_file , global_well_nr );
|
||||
well_state_add_MSW( well_state , rst_file , global_well_nr , load_segment_information );
|
||||
|
||||
{
|
||||
const well_segment_collection_type * segments = well_state_get_segments( well_state );
|
||||
|
||||
@@ -57,7 +57,7 @@ int main(int argc , char ** argv) {
|
||||
int i;
|
||||
for (i=0; i < stringlist_get_size( file_list ); i++) {
|
||||
printf("Loading file:%s \n",stringlist_iget( file_list , i ));
|
||||
well_info_load_rstfile( well_info , stringlist_iget(file_list , i));
|
||||
well_info_load_rstfile( well_info , stringlist_iget(file_list , i) , true);
|
||||
}
|
||||
well_info_free( well_info );
|
||||
}
|
||||
@@ -67,7 +67,7 @@ int main(int argc , char ** argv) {
|
||||
int i;
|
||||
stringlist_reverse( file_list );
|
||||
for (i=0; i < stringlist_get_size( file_list ); i++)
|
||||
well_info_load_rstfile( well_info , stringlist_iget(file_list , i));
|
||||
well_info_load_rstfile( well_info , stringlist_iget(file_list , i), true);
|
||||
well_info_free( well_info );
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ void enkf_tui_init(enkf_main_type * enkf_main, bool all_members , bool all_param
|
||||
const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
|
||||
int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
int iens1, iens2;
|
||||
init_mode_enum init_mode = INIT_FORCE;
|
||||
init_mode_type init_mode = INIT_FORCE;
|
||||
bool iens_valid = false;
|
||||
|
||||
/* iens2 should be interpreted as __inclusive__ */
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <ert/enkf/ensemble_config.h>
|
||||
#include <ert/enkf/enkf_analysis.h>
|
||||
#include <ert/enkf/ecl_config.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
#include <enkf_tui_util.h>
|
||||
#include <enkf_tui_fs.h>
|
||||
@@ -138,10 +139,6 @@ void enkf_tui_run_exp(void * enkf_main) {
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iactive = bool_vector_alloc(0,false);
|
||||
|
||||
state_enum init_state = ANALYZED;
|
||||
int start_report = 0;
|
||||
int init_step_parameters = 0;
|
||||
|
||||
{
|
||||
|
||||
char * prompt = util_alloc_sprintf("Which realizations to simulate (Ex: 1,3-5) <Enter for all> [M to return to menu] : " , ens_size);
|
||||
@@ -155,7 +152,7 @@ void enkf_tui_run_exp(void * enkf_main) {
|
||||
free( prompt );
|
||||
}
|
||||
if (bool_vector_count_equal(iactive , true))
|
||||
enkf_main_run_exp(enkf_main , iactive , true , init_step_parameters , start_report , init_state);
|
||||
enkf_main_run_exp(enkf_main , iactive , true );
|
||||
|
||||
bool_vector_free(iactive);
|
||||
}
|
||||
@@ -167,9 +164,6 @@ void enkf_tui_run_create_runpath__(void * __enkf_main) {
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iactive = bool_vector_alloc(0,false);
|
||||
|
||||
state_enum init_state = ANALYZED;
|
||||
int start_report = 0;
|
||||
int init_step_parameters = 0;
|
||||
{
|
||||
char * prompt = util_alloc_sprintf("Which realizations to create[ensemble size:%d] : " , ens_size);
|
||||
char * select_string;
|
||||
@@ -181,7 +175,7 @@ void enkf_tui_run_create_runpath__(void * __enkf_main) {
|
||||
util_safe_free( select_string );
|
||||
free( prompt );
|
||||
}
|
||||
enkf_main_run_exp(enkf_main , iactive , false , init_step_parameters , start_report , init_state);
|
||||
enkf_main_run_exp(enkf_main , iactive , false );
|
||||
bool_vector_free(iactive);
|
||||
}
|
||||
|
||||
@@ -197,11 +191,8 @@ void enkf_tui_run_manual_load__( void * arg ) {
|
||||
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iactive = bool_vector_alloc( 0 , false );
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
int iter = 0;
|
||||
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
|
||||
{
|
||||
char * prompt = util_alloc_sprintf("Which realizations to load (Ex: 1,3-5) <Enter for all> [M to return to menu] : [ensemble size:%d] : " , ens_size);
|
||||
char * select_string;
|
||||
@@ -243,20 +234,7 @@ void enkf_tui_run_manual_load__( void * arg ) {
|
||||
}
|
||||
|
||||
enkf_main_load_from_forward_model(enkf_main, iter , iactive, realizations_msg_list);
|
||||
|
||||
{
|
||||
qc_module_type * qc_module = enkf_main_get_qc_module( enkf_main );
|
||||
runpath_list_type * runpath_list = qc_module_get_runpath_list( qc_module );
|
||||
|
||||
for (iens = 0; iens < ens_size; ++iens) {
|
||||
if (bool_vector_iget(iactive , iens)) {
|
||||
const enkf_state_type * state = enkf_main_iget_state( enkf_main , iens );
|
||||
runpath_list_add( runpath_list , iens , iter, enkf_state_get_run_path( state ) , enkf_state_get_eclbase( state ));
|
||||
}
|
||||
}
|
||||
qc_module_export_runpath_list( qc_module );
|
||||
}
|
||||
|
||||
|
||||
for (iens = 0; iens < ens_size; ++iens) {
|
||||
stringlist_type * msg_list = realizations_msg_list[iens];
|
||||
if (bool_vector_iget(iactive, iens)) {
|
||||
|
||||
@@ -81,7 +81,7 @@ extern "C" {
|
||||
|
||||
void enkf_fs_debug_fprintf( const enkf_fs_type * fs);
|
||||
|
||||
void enkf_fs_create_fs( const char * mount_point , fs_driver_impl driver_id , void * arg);
|
||||
enkf_fs_type * enkf_fs_create_fs( const char * mount_point , fs_driver_impl driver_id , void * arg, bool mount);
|
||||
|
||||
char * enkf_fs_alloc_case_filename( const enkf_fs_type * fs , const char * input_name);
|
||||
char * enkf_fs_alloc_case_member_filename( const enkf_fs_type * fs , int iens , const char * input_name);
|
||||
|
||||
@@ -61,6 +61,7 @@ extern "C" {
|
||||
#include <ert/enkf/rng_config.h>
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
#include <ert/enkf/field_config.h>
|
||||
#include <ert/enkf/ert_run_context.h>
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
@@ -100,7 +101,7 @@ extern "C" {
|
||||
void enkf_main_free(enkf_main_type * );
|
||||
void enkf_main_exit(enkf_main_type * enkf_main);
|
||||
void enkf_main_init_eclipse(enkf_main_type * , int , int );
|
||||
void enkf_main_init_run( enkf_main_type * enkf_main, const bool_vector_type * iactive , run_mode_type run_mode , init_mode_enum init_mode);
|
||||
void enkf_main_init_run( enkf_main_type * enkf_main, const ert_run_context_type * run_context);
|
||||
void enkf_main_load_ecl_init_mt(enkf_main_type * enkf_main , int );
|
||||
void enkf_main_load_ecl_complete_mt(enkf_main_type *);
|
||||
void enkf_main_iload_ecl_mt(enkf_main_type *enkf_main , int );
|
||||
@@ -110,14 +111,11 @@ extern "C" {
|
||||
bool enkf_main_smoother_update(enkf_main_type * enkf_main , enkf_fs_type * target_fs);
|
||||
|
||||
void enkf_main_run_post_workflow( enkf_main_type * enkf_main );
|
||||
bool enkf_main_run_simple_step(enkf_main_type * enkf_main , bool_vector_type * iactive , init_mode_enum init_mode, int iter);
|
||||
bool enkf_main_run_simple_step(enkf_main_type * enkf_main , bool_vector_type * iactive , init_mode_type init_mode, int iter);
|
||||
|
||||
void enkf_main_run_exp(enkf_main_type * enkf_main ,
|
||||
bool_vector_type * iactive ,
|
||||
bool simulate ,
|
||||
int init_step_parameters ,
|
||||
int start_report ,
|
||||
state_enum start_state);
|
||||
void enkf_main_run_exp(enkf_main_type * enkf_main ,
|
||||
bool_vector_type * iactive ,
|
||||
bool simulate);
|
||||
|
||||
|
||||
void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
|
||||
@@ -256,9 +254,8 @@ pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_
|
||||
enkf_fs_type * fs);
|
||||
|
||||
|
||||
void enkf_main_load_from_forward_model_with_fs(enkf_main_type * enkf_main, int iter , bool_vector_type * iactive, stringlist_type ** realizations_msg_list, enkf_fs_type * fs);
|
||||
void enkf_main_load_from_forward_model(enkf_main_type * enkf_main, int iter , bool_vector_type * iactive, stringlist_type ** realizations_msg_list);
|
||||
|
||||
void enkf_main_load_from_forward_model_with_fs(enkf_main_type * enkf_main, int iter , const bool_vector_type * iactive, stringlist_type ** realizations_msg_list, enkf_fs_type * fs);
|
||||
void enkf_main_load_from_forward_model(enkf_main_type * enkf_main, int iter , const bool_vector_type * iactive, stringlist_type ** realizations_msg_list);
|
||||
void enkf_main_load_from_forward_model_from_gui(enkf_main_type * enkf_main, int iter , bool_vector_type * iactive, enkf_fs_type * fs);
|
||||
|
||||
void enkf_main_rank_on_observations(enkf_main_type * enkf_main,
|
||||
@@ -296,12 +293,12 @@ pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_
|
||||
const stringlist_type * param_list ,
|
||||
int iens1 ,
|
||||
int iens2,
|
||||
init_mode_enum init_mode);
|
||||
init_mode_type init_mode);
|
||||
|
||||
void enkf_main_initialize_from_scratch_with_bool_vector(enkf_main_type * enkf_main ,
|
||||
const stringlist_type * param_list ,
|
||||
const bool_vector_type * iens_mask ,
|
||||
init_mode_enum init_mode);
|
||||
init_mode_type init_mode);
|
||||
|
||||
void enkf_main_init_current_case_from_existing(enkf_main_type * enkf_main,
|
||||
enkf_fs_type * source_case_fs,
|
||||
@@ -351,6 +348,20 @@ pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_
|
||||
state_map_type * enkf_main_alloc_readonly_state_map( const enkf_main_type * enkf_main , const char * case_path);
|
||||
time_map_type * enkf_main_alloc_readonly_time_map( const enkf_main_type * enkf_main , const char * case_path );
|
||||
|
||||
ert_run_context_type * enkf_main_alloc_ert_run_context_ENSEMBLE_EXPERIMENT(const enkf_main_type * enkf_main , enkf_fs_type * fs , const bool_vector_type * iactive , init_mode_type init_mode , int iter);
|
||||
ert_run_context_type * enkf_main_alloc_ert_run_context_INIT_ONLY(const enkf_main_type * enkf_main , enkf_fs_type * fs , const bool_vector_type * iactive , init_mode_type init_mode , int iter);
|
||||
ert_run_context_type * enkf_main_alloc_ert_run_context_ENKF_ASSIMILATION( const enkf_main_type * enkf_main ,
|
||||
enkf_fs_type * fs ,
|
||||
const bool_vector_type * iactive ,
|
||||
init_mode_type init_mode ,
|
||||
state_enum init_state_parameter ,
|
||||
state_enum init_state_dynamic ,
|
||||
int step1 ,
|
||||
int step2 ,
|
||||
int iter);
|
||||
|
||||
|
||||
|
||||
|
||||
UTIL_SAFE_CAST_HEADER(enkf_main);
|
||||
UTIL_IS_INSTANCE_HEADER(enkf_main);
|
||||
|
||||
@@ -51,6 +51,7 @@ extern "C" {
|
||||
#include <ert/enkf/enkf_node.h>
|
||||
#include <ert/enkf/enkf_util.h>
|
||||
#include <ert/enkf/enkf_serialize.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
typedef struct enkf_state_struct enkf_state_type;
|
||||
|
||||
@@ -61,13 +62,8 @@ typedef struct enkf_state_struct enkf_state_type;
|
||||
void enkf_state_set_keep_runpath( enkf_state_type * enkf_state , keep_runpath_type keep_runpath);
|
||||
keep_runpath_type member_config_get_keep_runpath(const member_config_type * member_config);
|
||||
//void * enkf_state_complete_forward_model__(void * arg );
|
||||
job_status_type enkf_state_get_run_status( const enkf_state_type * enkf_state );
|
||||
time_t enkf_state_get_start_time( const enkf_state_type * enkf_state );
|
||||
time_t enkf_state_get_submit_time( const enkf_state_type * enkf_state );
|
||||
bool enkf_state_resubmit_simulation( enkf_state_type * enkf_state , enkf_fs_type * fs , bool resample);
|
||||
bool enkf_state_kill_simulation( const enkf_state_type * enkf_state );
|
||||
void * enkf_state_load_from_forward_model_mt( void * arg );
|
||||
void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs, const stringlist_type * param_list , init_mode_enum init_mode);
|
||||
void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs, const stringlist_type * param_list , init_mode_type init_mode);
|
||||
void enkf_state_fread(enkf_state_type * , enkf_fs_type * fs , int , int , state_enum );
|
||||
bool enkf_state_get_analyzed(const enkf_state_type * );
|
||||
void enkf_state_set_analyzed(enkf_state_type * , bool );
|
||||
@@ -75,20 +71,23 @@ typedef struct enkf_state_struct enkf_state_type;
|
||||
void enkf_state_swapin_node(const enkf_state_type * , const char *);
|
||||
void enkf_state_iset_eclpath(enkf_state_type * , int , const char *);
|
||||
enkf_node_type * enkf_state_get_node(const enkf_state_type * , const char * );
|
||||
bool enkf_state_has_node(const enkf_state_type * enkf_state , const char * node_key);
|
||||
void enkf_state_del_node(enkf_state_type * , const char * );
|
||||
void enkf_state_load_ecl_summary(enkf_state_type * , bool , int );
|
||||
void * enkf_state_run_eclipse__(void * );
|
||||
void * enkf_state_start_forward_model__(void * );
|
||||
|
||||
void enkf_state_load_from_forward_model(enkf_state_type * enkf_state ,
|
||||
enkf_fs_type * fs ,
|
||||
int * result ,
|
||||
bool interactive ,
|
||||
stringlist_type * msg_list);
|
||||
run_arg_type * run_arg ,
|
||||
int * result ,
|
||||
bool interactive ,
|
||||
stringlist_type * msg_list);
|
||||
|
||||
void enkf_state_forward_init(enkf_state_type * enkf_state ,
|
||||
enkf_fs_type * fs ,
|
||||
run_arg_type * run_arg ,
|
||||
int * result );
|
||||
|
||||
void enkf_state_init_eclipse(enkf_state_type *enkf_state, const run_arg_type * run_arg );
|
||||
|
||||
enkf_state_type * enkf_state_alloc(int ,
|
||||
rng_type * main_rng ,
|
||||
@@ -111,7 +110,7 @@ typedef struct enkf_state_struct enkf_state_type;
|
||||
void enkf_state_sample(enkf_state_type * , int);
|
||||
void enkf_state_fwrite(const enkf_state_type * , enkf_fs_type * fs , int , int , state_enum );
|
||||
void enkf_state_ens_read( enkf_state_type * , const char * , int);
|
||||
void enkf_state_ecl_write(enkf_state_type *, enkf_fs_type * fs);
|
||||
void enkf_state_ecl_write(enkf_state_type *, const run_arg_type * run_arg , enkf_fs_type * fs);
|
||||
void enkf_state_free(enkf_state_type * );
|
||||
void enkf_state_apply(enkf_state_type * , enkf_node_ftype1 * , int );
|
||||
void enkf_state_serialize(enkf_state_type * , size_t);
|
||||
@@ -124,25 +123,15 @@ typedef struct enkf_state_struct enkf_state_type;
|
||||
|
||||
rng_type * enkf_state_get_rng( const enkf_state_type * enkf_state );
|
||||
unsigned int enkf_state_get_random( enkf_state_type * enkf_state );
|
||||
|
||||
/*****************************************************************/
|
||||
void enkf_state_set_inactive(enkf_state_type * state);
|
||||
|
||||
void enkf_state_init_run(enkf_state_type * state ,
|
||||
run_mode_type ,
|
||||
bool active ,
|
||||
int max_internal_submit ,
|
||||
int init_step_parameter ,
|
||||
state_enum init_state_parameter ,
|
||||
state_enum init_state_dynamic ,
|
||||
int load_start ,
|
||||
int iter ,
|
||||
int step1 ,
|
||||
int step2 );
|
||||
int enkf_state_get_queue_index(const enkf_state_type * enkf_state);
|
||||
|
||||
|
||||
run_status_type enkf_state_get_simple_run_status(const enkf_state_type * state);
|
||||
|
||||
/******************************************************************/
|
||||
/* Forward model callbacks: */
|
||||
|
||||
bool enkf_state_complete_forward_modelOK__(void * arg );
|
||||
bool enkf_state_complete_forward_modelRETRY__(void * arg );
|
||||
bool enkf_state_complete_forward_modelEXIT__(void * arg );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -225,7 +225,7 @@ typedef enum {
|
||||
PARTLY_ACTIVE = 3 /* Partly active - must supply additonal type spesific information on what is active.*/
|
||||
} active_mode_type;
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
int report_step;
|
||||
int iens;
|
||||
@@ -249,7 +249,7 @@ typedef enum {
|
||||
INIT_NONE = 0,
|
||||
INIT_CONDITIONAL = 1,
|
||||
INIT_FORCE = 2
|
||||
} init_mode_enum;
|
||||
} init_mode_type;
|
||||
|
||||
|
||||
|
||||
|
||||
95
ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_run_context.h
vendored
Normal file
95
ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_run_context.h
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
Copyright (C) 2014 Statoil ASA, Norway.
|
||||
|
||||
The file 'run_info.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef __ERT_RUN_CONTEXT_H__
|
||||
#define __ERT_RUN_CONTEXT_H__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/bool_vector.h>
|
||||
#include <ert/util/path_fmt.h>
|
||||
#include <ert/util/subst_list.h>
|
||||
|
||||
#include <ert/enkf/enkf_types.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
#include <ert/enkf/enkf_fs.h>
|
||||
|
||||
typedef struct ert_run_context_struct ert_run_context_type;
|
||||
|
||||
|
||||
ert_run_context_type * ert_run_context_alloc_ENSEMBLE_EXPERIMENT(enkf_fs_type * fs ,
|
||||
const bool_vector_type * iactive ,
|
||||
path_fmt_type * runpath_fmt ,
|
||||
subst_list_type * subst_list ,
|
||||
init_mode_type init_mode ,
|
||||
int iter);
|
||||
|
||||
|
||||
ert_run_context_type * ert_run_context_alloc_INIT_ONLY(enkf_fs_type * init_fs , const bool_vector_type * iactive ,
|
||||
path_fmt_type * runpath_fmt ,
|
||||
subst_list_type * subst_list ,
|
||||
init_mode_type init_mode ,
|
||||
int iter);
|
||||
|
||||
ert_run_context_type * ert_run_context_alloc_ENKF_ASSIMILATION(enkf_fs_type * fs ,
|
||||
const bool_vector_type * iactive ,
|
||||
path_fmt_type * runpath_fmt ,
|
||||
subst_list_type * subst_list ,
|
||||
init_mode_type init_mode ,
|
||||
state_enum init_state_parameter ,
|
||||
state_enum init_state_dynamic ,
|
||||
int step1 ,
|
||||
int step2 ,
|
||||
int iter);
|
||||
|
||||
|
||||
|
||||
ert_run_context_type * ert_run_context_alloc_SMOOTHER_RUN(enkf_fs_type * simulate_fs , enkf_fs_type * target_update_fs ,
|
||||
const bool_vector_type * iactive ,
|
||||
path_fmt_type * runpath_fmt ,
|
||||
subst_list_type * subst_list ,
|
||||
init_mode_type init_mode ,
|
||||
int iter);
|
||||
|
||||
void ert_run_context_free( ert_run_context_type * );
|
||||
int ert_run_context_get_size( const ert_run_context_type * context );
|
||||
run_mode_type ert_run_context_get_mode( const ert_run_context_type * context );
|
||||
init_mode_type ert_run_context_get_init_mode( const ert_run_context_type * context );
|
||||
bool_vector_type * ert_run_context_get_iactive( const ert_run_context_type * context );
|
||||
int ert_run_context_get_iter( const ert_run_context_type * context );
|
||||
int ert_run_context_get_step1( const ert_run_context_type * context );
|
||||
int ert_run_context_get_step2( const ert_run_context_type * context );
|
||||
int ert_run_context_get_load_start( const ert_run_context_type * context );
|
||||
run_arg_type * ert_run_context_iget_arg( const ert_run_context_type * context , int index);
|
||||
run_arg_type * ert_run_context_iens_get_arg( const ert_run_context_type * context , int iens);
|
||||
|
||||
enkf_fs_type * ert_run_context_get_init_fs(const ert_run_context_type * run_context);
|
||||
enkf_fs_type * ert_run_context_get_result_fs(const ert_run_context_type * run_context);
|
||||
enkf_fs_type * ert_run_context_get_update_target_fs(const ert_run_context_type * run_context);
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( ert_run_context );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ extern "C" {
|
||||
const config_error_type * ert_workflow_list_get_last_error( const ert_workflow_list_type * workflow_list);
|
||||
void ert_workflow_list_set_verbose( ert_workflow_list_type * workflow_list , bool verbose);
|
||||
bool ert_workflow_list_run_workflow_blocking(ert_workflow_list_type * workflow_list , const char * workflow_name , void * self);
|
||||
subst_list_type * ert_workflow_list_get_context(const ert_workflow_list_type * workflow_list);
|
||||
const subst_list_type * ert_workflow_list_get_context(const ert_workflow_list_type * workflow_list);
|
||||
int ert_workflow_list_get_size( const ert_workflow_list_type * workflow_list);
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( ert_workflow_list );
|
||||
|
||||
@@ -43,6 +43,7 @@ const bool_vector_type * gen_data_get_forward_mask( const gen_data_type * gen_d
|
||||
int gen_data_get_size(const gen_data_type * );
|
||||
double gen_data_iget_double(const gen_data_type * , int );
|
||||
void gen_data_export(const gen_data_type * gen_data , const char * full_path , gen_data_file_format_type export_type , fortio_type * fortio);
|
||||
void gen_data_export_data(const gen_data_type * gen_data , double_vector_type * export_data);
|
||||
gen_data_file_format_type gen_data_guess_export_type( const gen_data_type * gen_data );
|
||||
const char * gen_data_get_key( const gen_data_type * gen_data);
|
||||
void gen_data_upgrade_103(const char * filename);
|
||||
|
||||
@@ -23,6 +23,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/subst_list.h>
|
||||
#include <ert/util/double_vector.h>
|
||||
|
||||
#include <ert/enkf/gen_kw_config.h>
|
||||
#include <ert/enkf/enkf_util.h>
|
||||
@@ -42,6 +43,7 @@ void gen_kw_free(gen_kw_type *);
|
||||
int gen_kw_data_size( gen_kw_type * );
|
||||
double gen_kw_data_iget( gen_kw_type * , int , bool );
|
||||
void gen_kw_data_iset( gen_kw_type * , int , double );
|
||||
void gen_kw_data_set_vector( gen_kw_type * gen_kw, const double_vector_type * values );
|
||||
double gen_kw_data_get( gen_kw_type * , const char * , bool );
|
||||
void gen_kw_data_set( gen_kw_type *, const char *, double );
|
||||
bool gen_kw_data_has_key( gen_kw_type *, const char *);
|
||||
|
||||
@@ -41,7 +41,7 @@ extern "C" {
|
||||
void qc_module_export_runpath_list( const qc_module_type * qc_module );
|
||||
void qc_module_add_config_items( config_type * config );
|
||||
void qc_module_set_runpath_list_file( qc_module_type * qc_module , const char * path, const char * filename);
|
||||
const char * qc_module_get_runpath_list_file( qc_module_type * qc_module);
|
||||
const char * qc_module_get_runpath_list_file(const qc_module_type * qc_module);
|
||||
|
||||
|
||||
|
||||
|
||||
89
ThirdParty/Ert/devel/libenkf/include/ert/enkf/run_arg.h
vendored
Normal file
89
ThirdParty/Ert/devel/libenkf/include/ert/enkf/run_arg.h
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright (C) 2014 Statoil ASA, Norway.
|
||||
|
||||
The file 'run_arg.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef __RUN_ARG_H__
|
||||
#define __RUN_ARG_H__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/path_fmt.h>
|
||||
#include <ert/util/subst_list.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/enkf/enkf_types.h>
|
||||
#include <ert/enkf/enkf_fs.h>
|
||||
|
||||
|
||||
typedef struct run_arg_struct run_arg_type;
|
||||
|
||||
|
||||
UTIL_SAFE_CAST_HEADER( run_arg );
|
||||
UTIL_IS_INSTANCE_HEADER( run_arg );
|
||||
|
||||
|
||||
run_arg_type * run_arg_alloc_ENSEMBLE_EXPERIMENT(enkf_fs_type * fs , int iens , int iter , const char * runpath);
|
||||
run_arg_type * run_arg_alloc_INIT_ONLY(enkf_fs_type * init_fs , int iens , int iter , const char * runpath);
|
||||
run_arg_type * run_arg_alloc_SMOOTHER_RUN(enkf_fs_type * simulate_fs , enkf_fs_type * update_target_fs , int iens , int iter , const char * runpath);
|
||||
run_arg_type * run_arg_alloc_ENKF_ASSIMILATION(enkf_fs_type * fs ,
|
||||
int iens ,
|
||||
state_enum init_state_parameter ,
|
||||
state_enum init_state_dynamic ,
|
||||
int step1 ,
|
||||
int step2 ,
|
||||
const char * runpath);
|
||||
|
||||
|
||||
|
||||
state_enum run_arg_get_dynamic_init_state( const run_arg_type * run_arg );
|
||||
state_enum run_arg_get_parameter_init_state( const run_arg_type * run_arg );
|
||||
int run_arg_get_parameter_init_step( const run_arg_type * run_arg );
|
||||
bool run_arg_is_ready( const run_arg_type * run_arg);
|
||||
int run_arg_get_step1( const run_arg_type * run_arg );
|
||||
int run_arg_get_step2( const run_arg_type * run_arg );
|
||||
run_mode_type run_arg_get_run_mode( const run_arg_type * run_arg );
|
||||
int run_arg_get_load_start( const run_arg_type * run_arg );
|
||||
int run_arg_get_iens( const run_arg_type * run_arg );
|
||||
int run_arg_get_iter( const run_arg_type * run_arg );
|
||||
void run_arg_increase_submit_count( run_arg_type * run_arg );
|
||||
void run_arg_set_queue_index( run_arg_type * run_arg , int queue_index);
|
||||
|
||||
void run_arg_set_ready( run_arg_type * run_arg , bool ready);
|
||||
|
||||
void run_arg_free(run_arg_type * run_arg);
|
||||
void run_arg_free__(void * arg);
|
||||
const char * run_arg_get_runpath( const run_arg_type * run_arg);
|
||||
void run_arg_complete_run(run_arg_type * run_arg);
|
||||
run_status_type run_arg_get_run_status( const run_arg_type * run_arg );
|
||||
|
||||
void run_arg_set_inactive( run_arg_type * run_arg );
|
||||
int run_arg_get_queue_index( const run_arg_type * run_arg );
|
||||
|
||||
bool run_arg_can_retry( const run_arg_type * run_arg );
|
||||
|
||||
run_status_type run_arg_get_run_status( const run_arg_type * run_arg);
|
||||
void run_arg_set_run_status( run_arg_type * run_arg , run_status_type run_status);
|
||||
|
||||
enkf_fs_type * run_arg_get_init_fs(const run_arg_type * run_arg);
|
||||
enkf_fs_type * run_arg_get_update_target_fs(const run_arg_type * run_arg);
|
||||
enkf_fs_type * run_arg_get_result_fs(const run_arg_type * run_arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -28,7 +28,7 @@ extern "C" {
|
||||
typedef struct runpath_list_struct runpath_list_type;
|
||||
|
||||
void runpath_list_free( runpath_list_type * list );
|
||||
runpath_list_type * runpath_list_alloc();
|
||||
runpath_list_type * runpath_list_alloc(const char * export_file );
|
||||
int runpath_list_size( const runpath_list_type * list );
|
||||
void runpath_list_add( runpath_list_type * list , int iens , int iter, const char * runpath , const char * basename);
|
||||
void runpath_list_clear( runpath_list_type * list );
|
||||
@@ -37,7 +37,10 @@ extern "C" {
|
||||
int runpath_list_iget_iter( runpath_list_type * list , int index);
|
||||
void runpath_list_set_line_fmt( runpath_list_type * list , const char * line_fmt );
|
||||
const char * runpath_list_get_line_fmt( const runpath_list_type * list );
|
||||
void runpath_list_fprintf( runpath_list_type * list , FILE * stream);
|
||||
void runpath_list_fprintf( runpath_list_type * list);
|
||||
const char * runpath_list_get_export_file( const runpath_list_type * list );
|
||||
void runpath_list_set_export_file( runpath_list_type * list , const char * export_file );
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -83,7 +83,9 @@ set( source_files
|
||||
cases_config.c
|
||||
state_map.c
|
||||
ert_test_context.c
|
||||
ert_log.c)
|
||||
ert_log.c
|
||||
run_arg.c
|
||||
ert_run_context.c)
|
||||
|
||||
set( header_files
|
||||
ert_report.h
|
||||
@@ -178,7 +180,9 @@ set( header_files
|
||||
cases_config.h
|
||||
state_map.h
|
||||
ert_test_context.h
|
||||
ert_log.h)
|
||||
ert_log.h
|
||||
run_arg.h
|
||||
ert_run_context.h)
|
||||
|
||||
|
||||
add_library( enkf ${LIBRARY_TYPE} ${source_files} )
|
||||
|
||||
@@ -173,10 +173,11 @@ void ecl_refcase_list_free( ecl_refcase_list_type * refcase_list ) {
|
||||
|
||||
|
||||
const ecl_sum_type * ecl_refcase_list_get_default( ecl_refcase_list_type * refcase_list ) {
|
||||
const ecl_sum_type * return_value = NULL;
|
||||
if (refcase_list->default_case)
|
||||
return sum_pair_get_ecl_sum( refcase_list->default_case );
|
||||
else
|
||||
return NULL;
|
||||
return_value = sum_pair_get_ecl_sum( refcase_list->default_case );
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
7
ThirdParty/Ert/devel/libenkf/src/enkf_fs.c
vendored
7
ThirdParty/Ert/devel/libenkf/src/enkf_fs.c
vendored
@@ -462,7 +462,7 @@ static enkf_fs_type * enkf_fs_mount_plain( FILE * fstab_stream , const char * m
|
||||
|
||||
|
||||
|
||||
void enkf_fs_create_fs( const char * mount_point, fs_driver_impl driver_id , void * arg) {
|
||||
enkf_fs_type * enkf_fs_create_fs( const char * mount_point, fs_driver_impl driver_id , void * arg , bool mount) {
|
||||
const int num_drivers = 32;
|
||||
FILE * stream = fs_driver_open_fstab( mount_point , true );
|
||||
if (stream != NULL) {
|
||||
@@ -481,6 +481,11 @@ void enkf_fs_create_fs( const char * mount_point, fs_driver_impl driver_id , voi
|
||||
}
|
||||
fclose( stream );
|
||||
}
|
||||
|
||||
if (mount)
|
||||
return enkf_fs_mount( mount_point );
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
584
ThirdParty/Ert/devel/libenkf/src/enkf_main.c
vendored
584
ThirdParty/Ert/devel/libenkf/src/enkf_main.c
vendored
@@ -55,6 +55,7 @@
|
||||
#include <ert/ecl/ecl_io_config.h>
|
||||
|
||||
#include <ert/job_queue/job_queue.h>
|
||||
#include <ert/job_queue/job_queue_manager.h>
|
||||
#include <ert/job_queue/local_driver.h>
|
||||
#include <ert/job_queue/rsh_driver.h>
|
||||
#include <ert/job_queue/lsf_driver.h>
|
||||
@@ -105,6 +106,7 @@
|
||||
#include <ert/enkf/analysis_iter_config.h>
|
||||
#include <ert/enkf/field.h>
|
||||
#include <ert/enkf/ert_log.h>
|
||||
#include <ert/enkf/ert_run_context.h>
|
||||
|
||||
/**/
|
||||
|
||||
@@ -1430,59 +1432,65 @@ bool enkf_main_smoother_update(enkf_main_type * enkf_main , enkf_fs_type * targe
|
||||
|
||||
|
||||
|
||||
static void enkf_main_report_run_failure( const enkf_main_type * enkf_main , int iens) {
|
||||
static void enkf_main_report_run_failure( const enkf_main_type * enkf_main , const run_arg_type * run_arg) {
|
||||
job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config);
|
||||
const enkf_state_type * enkf_state = enkf_main_iget_state( enkf_main , iens );
|
||||
int queue_index = enkf_state_get_queue_index( enkf_state );
|
||||
int queue_index = run_arg_get_queue_index( run_arg );
|
||||
|
||||
const char * stderr_file = job_queue_iget_stderr_file( job_queue , queue_index );
|
||||
if (stderr_file == NULL)
|
||||
ert_log_add_fmt_message( 1 , stderr , "** ERROR ** path:%s job:%s reason:%s" ,
|
||||
job_queue_iget_run_path( job_queue , queue_index),
|
||||
job_queue_iget_failed_job( job_queue , queue_index),
|
||||
job_queue_iget_error_reason( job_queue , queue_index ));
|
||||
job_queue_iget_run_path( job_queue , queue_index),
|
||||
job_queue_iget_failed_job( job_queue , queue_index),
|
||||
job_queue_iget_error_reason( job_queue , queue_index ));
|
||||
else
|
||||
ert_log_add_fmt_message( 1 , stderr , "** ERROR ** path:%s job:%s reason:%s Check file:%s" ,
|
||||
job_queue_iget_run_path( job_queue , queue_index),
|
||||
job_queue_iget_failed_job( job_queue , queue_index),
|
||||
job_queue_iget_error_reason( job_queue , queue_index ),
|
||||
job_queue_iget_stderr_file( job_queue , queue_index ));
|
||||
job_queue_iget_run_path( job_queue , queue_index),
|
||||
job_queue_iget_failed_job( job_queue , queue_index),
|
||||
job_queue_iget_error_reason( job_queue , queue_index ),
|
||||
job_queue_iget_stderr_file( job_queue , queue_index ));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void enkf_main_report_load_failure( const enkf_main_type * enkf_main , int iens) {
|
||||
static void enkf_main_report_load_failure( const enkf_main_type * enkf_main , run_arg_type * run_arg ) {
|
||||
job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config);
|
||||
const enkf_state_type * enkf_state = enkf_main_iget_state( enkf_main , iens );
|
||||
int queue_index = enkf_state_get_queue_index( enkf_state );
|
||||
|
||||
int queue_index = run_arg_get_queue_index( run_arg );
|
||||
|
||||
ert_log_add_fmt_message( 1 , stderr , "** ERROR ** path:%s - Could not load all required data",
|
||||
job_queue_iget_run_path( job_queue , queue_index));
|
||||
job_queue_iget_run_path( job_queue , queue_index));
|
||||
}
|
||||
|
||||
|
||||
static void enkf_main_monitor_job_queue ( const enkf_main_type * enkf_main) {
|
||||
job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config);
|
||||
int min_realisations = analysis_config_get_min_realisations(enkf_main->analysis_config);
|
||||
|
||||
bool cont = true;
|
||||
if (0 >= min_realisations)
|
||||
cont = false;
|
||||
if (analysis_config_get_stop_long_running(enkf_main_get_analysis_config( enkf_main ))) {
|
||||
|
||||
while (cont) {
|
||||
//Check if minimum number of realizations have run, and if so, kill the rest after a certain time
|
||||
if ((job_queue_get_num_complete(job_queue) >= min_realisations)) {
|
||||
job_queue_set_auto_job_stop_time(job_queue);
|
||||
job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config);
|
||||
int min_realisations = analysis_config_get_min_realisations(enkf_main->analysis_config);
|
||||
|
||||
bool cont = true;
|
||||
if (0 >= min_realisations)
|
||||
cont = false;
|
||||
}
|
||||
|
||||
//Check if minimum number of realizations is not possible. If so, it is time to give up
|
||||
int possible_sucesses = job_queue_get_num_running(job_queue) + job_queue_get_num_waiting(job_queue) + job_queue_get_num_pending(job_queue) + job_queue_get_num_complete(job_queue);
|
||||
if (possible_sucesses < min_realisations) {
|
||||
cont = false;
|
||||
}
|
||||
|
||||
if (cont) {
|
||||
util_usleep(10000);
|
||||
while (cont) {
|
||||
//Check if minimum number of realizations have run, and if so, kill the rest after a certain time
|
||||
if ((job_queue_get_num_complete(job_queue) >= min_realisations)) {
|
||||
job_queue_set_auto_job_stop_time(job_queue);
|
||||
cont = false;
|
||||
}
|
||||
|
||||
//Check if minimum number of realizations is not possible. If so, it is time to give up
|
||||
int possible_sucesses = job_queue_get_num_running(job_queue) +
|
||||
job_queue_get_num_waiting(job_queue) +
|
||||
job_queue_get_num_pending(job_queue) +
|
||||
job_queue_get_num_complete(job_queue);
|
||||
|
||||
if (possible_sucesses < min_realisations) {
|
||||
cont = false;
|
||||
}
|
||||
|
||||
if (cont) {
|
||||
util_usleep(10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1492,6 +1500,109 @@ void enkf_main_run_post_workflow( enkf_main_type * enkf_main ) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
void enkf_main_isubmit_job( enkf_main_type * enkf_main , run_arg_type * run_arg ) {
|
||||
const ecl_config_type * ecl_config = enkf_main_get_ecl_config( enkf_main );
|
||||
enkf_state_type * enkf_state = enkf_main->ensemble[ run_arg_get_iens(run_arg) ];
|
||||
const member_config_type * member_config = enkf_state_get_member_config( enkf_state );
|
||||
const site_config_type * site_config = enkf_main_get_site_config( enkf_main );
|
||||
const char * job_script = site_config_get_job_script( site_config );
|
||||
job_queue_type * job_queue = site_config_get_job_queue( site_config );
|
||||
const char * run_path = run_arg_get_runpath( run_arg );
|
||||
|
||||
{
|
||||
runpath_list_type * runpath_list = qc_module_get_runpath_list( enkf_main->qc_module );
|
||||
runpath_list_add( runpath_list ,
|
||||
run_arg_get_iens( run_arg ),
|
||||
run_arg_get_iter( run_arg ),
|
||||
run_arg_get_runpath( run_arg ),
|
||||
enkf_state_get_eclbase( enkf_state ));
|
||||
}
|
||||
|
||||
enkf_state_init_eclipse( enkf_state , run_arg );
|
||||
if (run_arg_get_run_mode(run_arg) != INIT_ONLY) {
|
||||
// The job_queue_node will take ownership of this arg_pack; and destroy it when
|
||||
// the job_queue_node is discarded.
|
||||
arg_pack_type * load_arg = arg_pack_alloc();
|
||||
|
||||
/*
|
||||
Prepare the job and submit it to the queue
|
||||
*/
|
||||
arg_pack_append_ptr( load_arg , enkf_state );
|
||||
arg_pack_append_ptr( load_arg , run_arg );
|
||||
|
||||
{
|
||||
int queue_index = job_queue_add_job_mt( job_queue ,
|
||||
job_script ,
|
||||
enkf_state_complete_forward_modelOK__ ,
|
||||
enkf_state_complete_forward_modelRETRY__ ,
|
||||
enkf_state_complete_forward_modelEXIT__,
|
||||
load_arg ,
|
||||
ecl_config_get_num_cpu( ecl_config ),
|
||||
run_path ,
|
||||
member_config_get_jobname( member_config ) ,
|
||||
1,
|
||||
(const char *[1]) { run_path } );
|
||||
|
||||
run_arg_set_queue_index( run_arg , queue_index );
|
||||
run_arg_increase_submit_count( run_arg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void * enkf_main_isubmit_job__( void * arg ) {
|
||||
arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
|
||||
enkf_main_type * enkf_main = enkf_main_safe_cast( arg_pack_iget_ptr( arg_pack , 0 ));
|
||||
run_arg_type * run_arg = run_arg_safe_cast( arg_pack_iget_ptr( arg_pack , 1));
|
||||
|
||||
enkf_main_isubmit_job( enkf_main , run_arg );
|
||||
arg_pack_free( arg_pack );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void enkf_main_submit_jobs( enkf_main_type * enkf_main ,
|
||||
const ert_run_context_type * run_context ) {
|
||||
runpath_list_type * runpath_list = qc_module_get_runpath_list( enkf_main->qc_module );
|
||||
|
||||
runpath_list_clear( runpath_list );
|
||||
{
|
||||
int iens;
|
||||
const bool_vector_type * iactive = ert_run_context_get_iactive( run_context );
|
||||
const int active_ens_size = util_int_min( bool_vector_size( iactive ) , enkf_main_get_ensemble_size( enkf_main ));
|
||||
thread_pool_type * submit_threads = thread_pool_alloc( 4 , true );
|
||||
|
||||
for (iens = 0; iens < active_ens_size; iens++) {
|
||||
if (bool_vector_iget(iactive , iens)) {
|
||||
run_arg_type * run_arg = ert_run_context_iens_get_arg( run_context , iens);
|
||||
arg_pack_type * arg_pack = arg_pack_alloc( ); // This is discarded by the enkf_main_isubmit_job__()
|
||||
|
||||
arg_pack_append_ptr( arg_pack , enkf_main );
|
||||
arg_pack_append_ptr( arg_pack , run_arg);
|
||||
|
||||
thread_pool_add_job(submit_threads , enkf_main_isubmit_job__ , arg_pack);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
After this join all directories/files for the simulations
|
||||
have been set up correctly, and all the jobs have been added
|
||||
to the job_queue manager.
|
||||
*/
|
||||
|
||||
thread_pool_join(submit_threads);
|
||||
thread_pool_free(submit_threads);
|
||||
}
|
||||
runpath_list_fprintf( runpath_list );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
If all simulations have completed successfully the function will
|
||||
return true, otherwise it will return false.
|
||||
@@ -1499,145 +1610,110 @@ void enkf_main_run_post_workflow( enkf_main_type * enkf_main ) {
|
||||
|
||||
|
||||
static bool enkf_main_run_step(enkf_main_type * enkf_main ,
|
||||
run_mode_type run_mode ,
|
||||
bool_vector_type * iactive ,
|
||||
int load_start , /* For internalizing results, and the first step in the update when merging. */
|
||||
int init_step_parameter ,
|
||||
state_enum init_state_parameter ,
|
||||
state_enum init_state_dynamic ,
|
||||
int iter ,
|
||||
int step1 ,
|
||||
int step2) {
|
||||
|
||||
|
||||
|
||||
const ert_run_context_type * run_context) {
|
||||
// run_mode_type run_mode ,
|
||||
// bool_vector_type * iactive ,
|
||||
// int load_start , /* For internalizing results, and the first step in the update when merging. */
|
||||
// int init_step_parameter ,
|
||||
// state_enum init_state_parameter ,
|
||||
// state_enum init_state_dynamic ,
|
||||
// int iter ,
|
||||
// int step1 ,
|
||||
// int step2) {
|
||||
|
||||
if (step1 > 0)
|
||||
|
||||
if (ert_run_context_get_step1(run_context))
|
||||
ecl_config_assert_restart( enkf_main_get_ecl_config( enkf_main ) );
|
||||
|
||||
{
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
int job_size , iens;
|
||||
bool verbose_queue = enkf_main->verbose;
|
||||
int max_internal_submit = model_config_get_max_internal_submit(enkf_main->model_config);
|
||||
const int active_ens_size = util_int_min( bool_vector_size( iactive ) , enkf_main_get_ensemble_size( enkf_main ));
|
||||
int job_size;
|
||||
int iens;
|
||||
|
||||
state_map_deselect_matching( enkf_fs_get_state_map( fs ) , iactive , STATE_LOAD_FAILURE | STATE_PARENT_FAILURE);
|
||||
|
||||
if (enkf_main->verbose) {
|
||||
if (run_mode == ENKF_ASSIMILATION)
|
||||
printf("Starting forward step: %d -> %d\n",step1 , step2);
|
||||
}
|
||||
const int active_ens_size = util_int_min( bool_vector_size( ert_run_context_get_iactive( run_context )) , enkf_main_get_ensemble_size( enkf_main ));
|
||||
|
||||
//enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
//enkf_fs_type * target_fs = fs; // ERRORE
|
||||
//path_fmt_type * runpath_fmt = model_config_get_runpath_fmt( enkf_main->model_config );
|
||||
|
||||
//
|
||||
//ert_run_context_type * run_context;
|
||||
//int job_size;
|
||||
//int iens;
|
||||
//
|
||||
//switch (run_mode) {
|
||||
//case(INIT_ONLY):
|
||||
// run_context = ert_run_context_alloc_INIT_ONLY( fs , iactive , runpath_fmt , enkf_main->subst_list , iter );
|
||||
// break;
|
||||
//case(ENSEMBLE_EXPERIMENT):
|
||||
// run_context = ert_run_context_alloc_ENSEMBLE_EXPERIMENT( fs , iactive , runpath_fmt , enkf_main->subst_list , iter );
|
||||
// break;
|
||||
//case(SMOOTHER_UPDATE):
|
||||
// run_context = ert_run_context_alloc_SMOOTHER_RUN( fs , fs , iactive , runpath_fmt , enkf_main->subst_list , iter);
|
||||
// break;
|
||||
//case(ENKF_ASSIMILATION):
|
||||
// run_context = ert_run_context_alloc_ENKF_ASSIMILATION( fs , iactive , runpath_fmt , enkf_main->subst_list , init_state_parameter , init_state_dynamic , step1 , step2 , iter);
|
||||
// break;
|
||||
//default:
|
||||
// util_abort("%s: what the fuck? \n",__func__);
|
||||
//}
|
||||
|
||||
state_map_deselect_matching( enkf_fs_get_state_map( ert_run_context_get_init_fs( run_context )) ,
|
||||
ert_run_context_get_iactive( run_context ), STATE_LOAD_FAILURE | STATE_PARENT_FAILURE);
|
||||
|
||||
ert_log_add_fmt_message( 1 , NULL , "===================================================================", false);
|
||||
if (run_mode == ENKF_ASSIMILATION)
|
||||
if (ert_run_context_get_mode( run_context ) == ENKF_ASSIMILATION) {
|
||||
int step1 = ert_run_context_get_step1(run_context);
|
||||
int step2 = ert_run_context_get_step2(run_context);
|
||||
printf("Starting forward step: %d -> %d\n", step1 , step2 );
|
||||
ert_log_add_fmt_message( 1 , NULL , "Forward model: %d -> %d ",step1,step2);
|
||||
else
|
||||
ert_log_add_fmt_message( 1 , NULL , "Forward model: %d -> ??? ",step1);
|
||||
|
||||
job_size = bool_vector_count_equal( iactive , true );
|
||||
}
|
||||
|
||||
job_size = bool_vector_count_equal( ert_run_context_get_iactive(run_context) , true );
|
||||
{
|
||||
pthread_t queue_thread;
|
||||
job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config);
|
||||
|
||||
job_queue_manager_type * queue_manager = job_queue_manager_alloc( job_queue );
|
||||
|
||||
/* Start the queue */
|
||||
if (run_mode != INIT_ONLY) {
|
||||
if (site_config_has_job_script( enkf_main->site_config )) {
|
||||
arg_pack_type * queue_args = arg_pack_alloc(); /* This arg_pack will be freed() in the job_que_run_jobs__() */
|
||||
arg_pack_append_ptr(queue_args , job_queue);
|
||||
arg_pack_append_int(queue_args , job_size);
|
||||
arg_pack_append_bool(queue_args , verbose_queue);
|
||||
job_queue_reset(job_queue);
|
||||
pthread_create( &queue_thread , NULL , job_queue_run_jobs__ , queue_args);
|
||||
} else
|
||||
if (ert_run_context_get_mode( run_context ) != INIT_ONLY) {
|
||||
if (site_config_has_job_script( enkf_main->site_config ))
|
||||
job_queue_manager_start_queue( queue_manager , job_size , verbose_queue );
|
||||
else
|
||||
util_exit("No job script specified, can not start any jobs. Use the key JOB_SCRIPT in the config file\n");
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
thread_pool_type * submit_threads = thread_pool_alloc( 4 , true );
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
runpath_list_type * runpath_list = qc_module_get_runpath_list( enkf_main->qc_module );
|
||||
runpath_list_clear( runpath_list );
|
||||
|
||||
for (iens = 0; iens < active_ens_size; iens++) {
|
||||
enkf_state_type * enkf_state = enkf_main->ensemble[iens];
|
||||
if (bool_vector_iget(iactive , iens)) {
|
||||
int load_start = step1;
|
||||
if (step1 > 0)
|
||||
load_start++;
|
||||
|
||||
enkf_state_init_run(enkf_state ,
|
||||
run_mode ,
|
||||
true ,
|
||||
max_internal_submit ,
|
||||
init_step_parameter ,
|
||||
init_state_parameter,
|
||||
init_state_dynamic ,
|
||||
load_start ,
|
||||
iter ,
|
||||
step1 ,
|
||||
step2 );
|
||||
|
||||
runpath_list_add( runpath_list ,
|
||||
iens ,
|
||||
iter ,
|
||||
enkf_state_get_run_path( enkf_state ) ,
|
||||
enkf_state_get_eclbase( enkf_state ));
|
||||
{
|
||||
arg_pack_type * arg_pack = arg_pack_alloc( ); // This is discarded by the enkf_state_start_forward_model__() function. */
|
||||
|
||||
arg_pack_append_ptr( arg_pack , enkf_state );
|
||||
arg_pack_append_ptr( arg_pack , fs );
|
||||
|
||||
thread_pool_add_job(submit_threads , enkf_state_start_forward_model__ , arg_pack);
|
||||
}
|
||||
} else
|
||||
enkf_state_set_inactive( enkf_state );
|
||||
}
|
||||
/*
|
||||
After this join all directories/files for the simulations
|
||||
have been set up correctly, and all the jobs have been added
|
||||
to the job_queue manager.
|
||||
*/
|
||||
qc_module_export_runpath_list( enkf_main->qc_module );
|
||||
thread_pool_join(submit_threads);
|
||||
thread_pool_free(submit_threads);
|
||||
}
|
||||
if (run_mode != INIT_ONLY) {
|
||||
enkf_main_submit_jobs( enkf_main , run_context );
|
||||
|
||||
if (ert_run_context_get_mode(run_context) != INIT_ONLY) {
|
||||
job_queue_submit_complete( job_queue );
|
||||
ert_log_add_message( 1 , NULL , "All jobs submitted to internal queue - waiting for completion" , false);
|
||||
|
||||
int max_runtime = analysis_config_get_max_runtime(enkf_main_get_analysis_config( enkf_main ));
|
||||
job_queue_set_max_job_duration(job_queue, max_runtime);
|
||||
|
||||
if (analysis_config_get_stop_long_running(enkf_main_get_analysis_config( enkf_main ))) {
|
||||
enkf_main_monitor_job_queue( enkf_main );
|
||||
}
|
||||
|
||||
pthread_join( queue_thread , NULL ); /* Wait for the job_queue_run_jobs() function to complete. */
|
||||
enkf_main_monitor_job_queue( enkf_main );
|
||||
|
||||
job_queue_manager_wait( queue_manager );
|
||||
}
|
||||
job_queue_manager_free( queue_manager );
|
||||
}
|
||||
|
||||
|
||||
/* This should be carefully checked for the situation where only a
|
||||
subset (with offset > 0) of realisations are simulated. */
|
||||
if (run_mode != INIT_ONLY) {
|
||||
bool totalOK = true;
|
||||
|
||||
bool totalOK = true;
|
||||
if (ert_run_context_get_mode( run_context ) != INIT_ONLY) {
|
||||
for (iens = 0; iens < active_ens_size; iens++) {
|
||||
if (bool_vector_iget(iactive , iens)) {
|
||||
run_status_type run_status = enkf_state_get_simple_run_status( enkf_main->ensemble[iens] );
|
||||
if (bool_vector_iget(ert_run_context_get_iactive(run_context) , iens)) {
|
||||
run_arg_type * run_arg = ert_run_context_iens_get_arg( run_context , iens );
|
||||
run_status_type run_status = run_arg_get_run_status( run_arg );
|
||||
|
||||
switch (run_status) {
|
||||
case JOB_RUN_FAILURE:
|
||||
enkf_main_report_run_failure( enkf_main , iens );
|
||||
bool_vector_iset(iactive, iens, false);
|
||||
enkf_main_report_run_failure( enkf_main , run_arg );
|
||||
bool_vector_iset(ert_run_context_get_iactive( run_context ), iens, false);
|
||||
break;
|
||||
case JOB_LOAD_FAILURE:
|
||||
enkf_main_report_load_failure( enkf_main , iens );
|
||||
bool_vector_iset(iactive, iens, false);
|
||||
enkf_main_report_load_failure( enkf_main , run_arg );
|
||||
bool_vector_iset(ert_run_context_get_iactive( run_context ), iens, false);
|
||||
break;
|
||||
case JOB_RUN_OK:
|
||||
break;
|
||||
@@ -1646,14 +1722,15 @@ static bool enkf_main_run_step(enkf_main_type * enkf_main ,
|
||||
}
|
||||
totalOK = totalOK && ( run_status == JOB_RUN_OK );
|
||||
}
|
||||
|
||||
}
|
||||
enkf_fs_fsync( enkf_main->dbase );
|
||||
enkf_fs_fsync( ert_run_context_get_result_fs( run_context ) );
|
||||
if (totalOK)
|
||||
ert_log_add_fmt_message( 1 , NULL , "All jobs complete and data loaded.");
|
||||
|
||||
return totalOK;
|
||||
} else
|
||||
return false;
|
||||
totalOK = false;
|
||||
|
||||
return totalOK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1709,17 +1786,16 @@ void * enkf_main_get_enkf_config_node_type(const ensemble_config_type * ensemble
|
||||
*/
|
||||
|
||||
|
||||
void enkf_main_init_run( enkf_main_type * enkf_main, const bool_vector_type * iactive , run_mode_type run_mode , init_mode_enum init_mode) {
|
||||
void enkf_main_init_run( enkf_main_type * enkf_main, const ert_run_context_type * run_context) {
|
||||
{
|
||||
const ext_joblist_type * joblist = site_config_get_installed_jobs( enkf_main->site_config);
|
||||
model_config_set_enkf_sched( enkf_main->model_config , joblist , run_mode );
|
||||
model_config_set_enkf_sched( enkf_main->model_config , joblist , ert_run_context_get_mode( run_context ));
|
||||
}
|
||||
|
||||
enkf_main_init_internalization(enkf_main , run_mode);
|
||||
|
||||
enkf_main_init_internalization(enkf_main , ert_run_context_get_mode( run_context ));
|
||||
{
|
||||
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
|
||||
enkf_main_initialize_from_scratch_with_bool_vector(enkf_main , param_list , iactive , init_mode );
|
||||
enkf_main_initialize_from_scratch_with_bool_vector(enkf_main , param_list , ert_run_context_get_iactive( run_context ) , ert_run_context_get_init_mode( run_context ));
|
||||
stringlist_free( param_list );
|
||||
}
|
||||
}
|
||||
@@ -1727,24 +1803,32 @@ void enkf_main_init_run( enkf_main_type * enkf_main, const bool_vector_type * ia
|
||||
|
||||
|
||||
|
||||
void enkf_main_run_exp(enkf_main_type * enkf_main ,
|
||||
bool_vector_type * iactive ,
|
||||
bool simulate ,
|
||||
int init_step_parameters ,
|
||||
int start_report ,
|
||||
state_enum start_state) {
|
||||
|
||||
init_mode_enum init_mode = INIT_CONDITIONAL;
|
||||
run_mode_type run_mode = simulate ? ENSEMBLE_EXPERIMENT : INIT_ONLY;
|
||||
void enkf_main_run_exp(enkf_main_type * enkf_main ,
|
||||
bool_vector_type * iactive ,
|
||||
bool simulate ) {
|
||||
|
||||
enkf_main_init_run( enkf_main , iactive , run_mode , init_mode);
|
||||
{
|
||||
int load_start = start_report;
|
||||
state_enum init_state_parameter = start_state;
|
||||
state_enum init_state_dynamic = start_state;
|
||||
if (enkf_main_run_step(enkf_main , run_mode , iactive , load_start , init_step_parameters , init_state_parameter , init_state_dynamic , 0, start_report , -1))
|
||||
enkf_main_run_post_workflow(enkf_main);
|
||||
}
|
||||
ert_run_context_type * run_context;
|
||||
init_mode_type init_mode = INIT_CONDITIONAL;
|
||||
int iter = 0;
|
||||
|
||||
if (simulate)
|
||||
run_context = enkf_main_alloc_ert_run_context_ENSEMBLE_EXPERIMENT(enkf_main ,
|
||||
enkf_main_get_fs( enkf_main ) ,
|
||||
iactive ,
|
||||
init_mode ,
|
||||
iter );
|
||||
else
|
||||
run_context = enkf_main_alloc_ert_run_context_INIT_ONLY( enkf_main ,
|
||||
enkf_main_get_fs( enkf_main ) ,
|
||||
iactive ,
|
||||
init_mode ,
|
||||
iter );
|
||||
|
||||
enkf_main_init_run( enkf_main , run_context );
|
||||
if (enkf_main_run_step(enkf_main , run_context))
|
||||
enkf_main_run_post_workflow(enkf_main);
|
||||
|
||||
ert_run_context_free( run_context );
|
||||
}
|
||||
|
||||
|
||||
@@ -1757,10 +1841,9 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
|
||||
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
if (!analysis_config_get_module_option( analysis_config , ANALYSIS_ITERABLE)) {
|
||||
init_mode_enum init_mode = INIT_CONDITIONAL;
|
||||
init_mode_type init_mode = INIT_CONDITIONAL;
|
||||
bool rerun = analysis_config_get_rerun( enkf_main->analysis_config );
|
||||
int rerun_start = analysis_config_get_rerun_start( enkf_main->analysis_config );
|
||||
enkf_main_init_run( enkf_main , iactive , ENKF_ASSIMILATION , init_mode);
|
||||
{
|
||||
bool analyzed_start = false;
|
||||
bool prev_enkf_on;
|
||||
@@ -1768,6 +1851,8 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
|
||||
const int num_nodes = enkf_sched_get_num_nodes(enkf_sched);
|
||||
const int start_inode = enkf_sched_get_node_index(enkf_sched , start_report);
|
||||
int inode;
|
||||
ert_run_context_type * run_context;
|
||||
|
||||
|
||||
if (start_state == ANALYZED)
|
||||
analyzed_start = true;
|
||||
@@ -1779,6 +1864,7 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
|
||||
prev_enkf_on = analyzed_start;
|
||||
for (inode = start_inode; inode < num_nodes; inode++) {
|
||||
const enkf_sched_node_type * node = enkf_sched_iget_node(enkf_sched , inode);
|
||||
int iter = 0;
|
||||
state_enum init_state_parameter;
|
||||
state_enum init_state_dynamic;
|
||||
int init_step_parameter;
|
||||
@@ -1813,14 +1899,21 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
|
||||
load_start = report_step1;
|
||||
}
|
||||
|
||||
if (load_start > 0)
|
||||
load_start++;
|
||||
|
||||
enkf_main_run_step(enkf_main , ENKF_ASSIMILATION , iactive , load_start , init_step_parameter ,
|
||||
init_state_parameter , init_state_dynamic , 0, report_step1 , report_step2);
|
||||
run_context = enkf_main_alloc_ert_run_context_ENKF_ASSIMILATION( enkf_main,
|
||||
enkf_main_get_fs( enkf_main ) ,
|
||||
iactive ,
|
||||
init_mode ,
|
||||
init_state_parameter,
|
||||
init_state_dynamic ,
|
||||
report_step1 , // init_step parameter
|
||||
report_step2 ,
|
||||
iter );
|
||||
|
||||
enkf_main_init_run( enkf_main , run_context );
|
||||
enkf_main_run_step(enkf_main , run_context);
|
||||
{
|
||||
enkf_fs_type * fs = enkf_main_get_fs(enkf_main);
|
||||
state_map_type * state_map = enkf_fs_get_state_map(fs);
|
||||
enkf_fs_type * result_fs = ert_run_context_get_result_fs( run_context );
|
||||
state_map_type * state_map = enkf_fs_get_state_map(result_fs);
|
||||
const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
|
||||
int active_ens_size = state_map_count_matching(state_map , STATE_HAS_DATA);
|
||||
|
||||
@@ -1835,7 +1928,7 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
|
||||
else
|
||||
stride = 0;
|
||||
|
||||
step_list = enkf_main_update_alloc_step_list( enkf_main , load_start , report_step2 , stride );
|
||||
step_list = enkf_main_update_alloc_step_list( enkf_main , ert_run_context_get_load_start(run_context) , report_step2 , stride );
|
||||
|
||||
enkf_main_assimilation_update(enkf_main , step_list);
|
||||
int_vector_free( step_list );
|
||||
@@ -1856,9 +1949,18 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
|
||||
}
|
||||
|
||||
|
||||
bool enkf_main_run_simple_step(enkf_main_type * enkf_main , bool_vector_type * iactive , init_mode_enum init_mode, int iter) {
|
||||
enkf_main_init_run( enkf_main , iactive , ENSEMBLE_EXPERIMENT , init_mode);
|
||||
return enkf_main_run_step( enkf_main , ENSEMBLE_EXPERIMENT , iactive , 0 , 0 , ANALYZED , UNDEFINED , iter, 0 , 0 );
|
||||
bool enkf_main_run_simple_step(enkf_main_type * enkf_main , bool_vector_type * iactive , init_mode_type init_mode, int iter) {
|
||||
bool run_ok;
|
||||
ert_run_context_type * run_context = enkf_main_alloc_ert_run_context_ENSEMBLE_EXPERIMENT( enkf_main ,
|
||||
enkf_main_get_fs( enkf_main ) ,
|
||||
iactive ,
|
||||
init_mode ,
|
||||
iter );
|
||||
enkf_main_init_run( enkf_main , run_context );
|
||||
run_ok = enkf_main_run_step( enkf_main , run_context );
|
||||
ert_run_context_free( run_context );
|
||||
|
||||
return run_ok;
|
||||
}
|
||||
|
||||
|
||||
@@ -1887,22 +1989,21 @@ void enkf_main_run_smoother(enkf_main_type * enkf_main , const char * target_fs_
|
||||
fprintf(stderr,"** ERROR: The normal smoother should not be combined with an iterable analysis module\n");
|
||||
}
|
||||
|
||||
|
||||
static bool enkf_main_run_simulation_and_postworkflow(enkf_main_type * enkf_main, int iteration_number, bool_vector_type * iactive) {
|
||||
|
||||
static bool enkf_main_run_simulation_and_postworkflow(enkf_main_type * enkf_main, const ert_run_context_type * run_context) {
|
||||
bool ret = true;
|
||||
const int step1 = 0;
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
|
||||
const int min_realizations = analysis_config_get_min_realisations(analysis_config);
|
||||
|
||||
printf("Running simulation iteration %d\n", iteration_number);
|
||||
bool total_ok = enkf_main_run_step(enkf_main, ENSEMBLE_EXPERIMENT , iactive , step1 , step1 , FORECAST , FORECAST , iteration_number, step1 , -1);
|
||||
|
||||
if (total_ok || (bool_vector_count_equal(iactive, true) >= min_realizations))
|
||||
|
||||
bool total_ok = enkf_main_run_step(enkf_main , run_context);
|
||||
|
||||
if (total_ok || (bool_vector_count_equal(ert_run_context_get_iactive( run_context ), true) >= min_realizations))
|
||||
enkf_main_run_post_workflow(enkf_main);
|
||||
else {
|
||||
fprintf(stderr,"Simulation in iteration %d failed, stopping Iterated Ensemble Smoother\n", iteration_number);
|
||||
fprintf(stderr,"Simulation in iteration %d failed, stopping Iterated Ensemble Smoother\n", ert_run_context_get_iter( run_context ));
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1958,8 +2059,10 @@ void enkf_main_run_iterated_ES(enkf_main_type * enkf_main, int num_iterations_to
|
||||
}
|
||||
|
||||
{ //Iteration 0
|
||||
enkf_main_init_run(enkf_main , iactive , ENSEMBLE_EXPERIMENT , INIT_FORCE);
|
||||
enkf_main_run_simulation_and_postworkflow(enkf_main, current_iteration, iactive);
|
||||
ert_run_context_type * run_context = NULL;
|
||||
enkf_main_init_run(enkf_main , run_context);
|
||||
enkf_main_run_simulation_and_postworkflow(enkf_main, run_context);
|
||||
ert_run_context_free( run_context );
|
||||
}
|
||||
|
||||
{ // Iteration 1 - num_iterations [iteration 1, num iterations]
|
||||
@@ -1968,11 +2071,13 @@ void enkf_main_run_iterated_ES(enkf_main_type * enkf_main, int num_iterations_to
|
||||
current_iteration = 1;
|
||||
|
||||
while ((current_iteration <= num_iterations_to_run) && (num_tries < num_retries_per_iteration)) {
|
||||
ert_run_context_type * run_context = NULL;
|
||||
|
||||
const char * target_fs_name = analysis_iter_config_iget_case( iter_config , current_iteration );
|
||||
|
||||
if (enkf_main_run_analysis(enkf_main, target_fs_name, current_iteration)) {
|
||||
enkf_main_select_fs(enkf_main, target_fs_name);
|
||||
if (!enkf_main_run_simulation_and_postworkflow(enkf_main, current_iteration, iactive))
|
||||
if (!enkf_main_run_simulation_and_postworkflow(enkf_main, run_context ))
|
||||
break;
|
||||
num_tries = 0;
|
||||
++current_iteration;
|
||||
@@ -1983,9 +2088,12 @@ void enkf_main_run_iterated_ES(enkf_main_type * enkf_main, int num_iterations_to
|
||||
enkf_fs_decref(target_fs);
|
||||
++num_tries;
|
||||
|
||||
if (!enkf_main_run_simulation_and_postworkflow(enkf_main, current_iteration-1, iactive))
|
||||
if (!enkf_main_run_simulation_and_postworkflow(enkf_main, run_context ))
|
||||
//if (!enkf_main_run_simulation_and_postworkflow(enkf_main, current_iteration-1, iactive))
|
||||
break;
|
||||
}
|
||||
|
||||
ert_run_context_free( run_context );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1995,6 +2103,39 @@ void enkf_main_run_iterated_ES(enkf_main_type * enkf_main, int num_iterations_to
|
||||
}
|
||||
|
||||
|
||||
ert_run_context_type * enkf_main_alloc_ert_run_context_ENSEMBLE_EXPERIMENT(const enkf_main_type * enkf_main , enkf_fs_type * fs , const bool_vector_type * iactive , init_mode_type init_mode , int iter) {
|
||||
return ert_run_context_alloc_ENSEMBLE_EXPERIMENT( fs , iactive , model_config_get_runpath_fmt( enkf_main->model_config ) , enkf_main->subst_list , init_mode , iter );
|
||||
}
|
||||
|
||||
|
||||
ert_run_context_type * enkf_main_alloc_ert_run_context_INIT_ONLY(const enkf_main_type * enkf_main , enkf_fs_type * fs , const bool_vector_type * iactive , init_mode_type init_mode , int iter) {
|
||||
return ert_run_context_alloc_INIT_ONLY( fs , iactive , model_config_get_runpath_fmt( enkf_main->model_config ) , enkf_main->subst_list , init_mode , iter );
|
||||
}
|
||||
|
||||
ert_run_context_type * enkf_main_alloc_ert_run_context_ENKF_ASSIMILATION( const enkf_main_type * enkf_main ,
|
||||
enkf_fs_type * fs ,
|
||||
const bool_vector_type * iactive ,
|
||||
init_mode_type init_mode ,
|
||||
state_enum init_state_parameter ,
|
||||
state_enum init_state_dynamic ,
|
||||
int step1 ,
|
||||
int step2 ,
|
||||
int iter) {
|
||||
|
||||
return ert_run_context_alloc_ENKF_ASSIMILATION( enkf_main_get_fs( enkf_main ) ,
|
||||
iactive ,
|
||||
model_config_get_runpath_fmt( enkf_main->model_config ) ,
|
||||
enkf_main->subst_list ,
|
||||
init_mode ,
|
||||
init_state_parameter,
|
||||
init_state_dynamic ,
|
||||
step1 , // init_step parameter
|
||||
step2 ,
|
||||
iter );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
This function creates a local_config file corresponding to the
|
||||
@@ -2489,14 +2630,6 @@ static void enkf_main_invalidate_cache( enkf_main_type * enkf_main ) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void enkf_main_create_fs( enkf_main_type * enkf_main , const char * fs_path) {
|
||||
fs_driver_impl driver_id = model_config_get_dbase_type( enkf_main->model_config );
|
||||
void * arg = NULL;
|
||||
|
||||
enkf_fs_create_fs( fs_path , driver_id , arg );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -3367,34 +3500,32 @@ void enkf_main_run_workflows( enkf_main_type * enkf_main , const stringlist_type
|
||||
|
||||
|
||||
void enkf_main_load_from_forward_model_from_gui(enkf_main_type * enkf_main, int iter , bool_vector_type * iactive, enkf_fs_type * fs){
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
stringlist_type ** realizations_msg_list = util_calloc( ens_size , sizeof * realizations_msg_list );
|
||||
int iens = 0;
|
||||
for (; iens < ens_size; ++iens) {
|
||||
realizations_msg_list[iens] = stringlist_alloc_new();
|
||||
}
|
||||
enkf_main_load_from_forward_model_with_fs(enkf_main, iter , iactive, realizations_msg_list, fs);
|
||||
free(realizations_msg_list);
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
stringlist_type ** realizations_msg_list = util_calloc( ens_size , sizeof * realizations_msg_list );
|
||||
int iens = 0;
|
||||
for (; iens < ens_size; ++iens) {
|
||||
realizations_msg_list[iens] = stringlist_alloc_new();
|
||||
}
|
||||
enkf_main_load_from_forward_model_with_fs(enkf_main, iter , iactive, realizations_msg_list, fs);
|
||||
free(realizations_msg_list);
|
||||
}
|
||||
|
||||
void enkf_main_load_from_forward_model(enkf_main_type * enkf_main, int iter , bool_vector_type * iactive, stringlist_type ** realizations_msg_list){
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
enkf_main_load_from_forward_model_with_fs(enkf_main, iter, iactive, realizations_msg_list, fs);
|
||||
void enkf_main_load_from_forward_model(enkf_main_type * enkf_main, int iter , const bool_vector_type * iactive, stringlist_type ** realizations_msg_list){
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
enkf_main_load_from_forward_model_with_fs(enkf_main, iter, iactive, realizations_msg_list, fs);
|
||||
}
|
||||
|
||||
void enkf_main_load_from_forward_model_with_fs(enkf_main_type * enkf_main, int iter , bool_vector_type * iactive, stringlist_type ** realizations_msg_list, enkf_fs_type * fs) {
|
||||
|
||||
void enkf_main_load_from_forward_model_with_fs(enkf_main_type * enkf_main, int iter , const bool_vector_type * iactive, stringlist_type ** realizations_msg_list, enkf_fs_type * fs) {
|
||||
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
int step1 = 0;
|
||||
int step2 = -1; /** Observe that for the summary data it will load all the available data anyway. */
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
int result[ens_size];
|
||||
model_config_type * model_config = enkf_main->model_config;
|
||||
|
||||
ert_run_context_type * run_context = ert_run_context_alloc_ENSEMBLE_EXPERIMENT( fs , iactive , model_config_get_runpath_fmt( model_config ) , enkf_main->subst_list , INIT_NONE , iter );
|
||||
arg_pack_type ** arg_list = util_calloc( ens_size , sizeof * arg_list );
|
||||
thread_pool_type * tp = thread_pool_alloc( 4 , true ); /* num_cpu - HARD coded. */
|
||||
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
|
||||
int iens = 0;
|
||||
for (; iens < ens_size; ++iens) {
|
||||
result[iens] = 0;
|
||||
@@ -3403,16 +3534,12 @@ void enkf_main_load_from_forward_model_with_fs(enkf_main_type * enkf_main, int i
|
||||
|
||||
if (bool_vector_iget(iactive, iens)) {
|
||||
enkf_state_type * enkf_state = enkf_main_iget_state( enkf_main , iens );
|
||||
arg_pack_append_ptr( arg_pack , enkf_state); /* 0: */
|
||||
arg_pack_append_ptr( arg_pack , fs ); /* 1: */
|
||||
arg_pack_append_int( arg_pack , step1 ); /* 2: This will be the load start parameter for the run_info struct. */
|
||||
arg_pack_append_int( arg_pack , step1 ); /* 3: Step1 */
|
||||
arg_pack_append_int( arg_pack , step2 ); /* 4: Step2 For summary data it will load the whole goddamn thing anyway.*/
|
||||
arg_pack_append_bool( arg_pack , true ); /* 5: Interactive */
|
||||
arg_pack_append_ptr(arg_pack, realizations_msg_list[iens]); /* 6: List of interactive mode messages. */
|
||||
arg_pack_append_bool( arg_pack, true ); /* 7: Manual load */
|
||||
arg_pack_append_int( arg_pack , iter ); /* 8: Iteration number */
|
||||
arg_pack_append_ptr(arg_pack, &result[iens]); /* 9: Result */
|
||||
arg_pack_append_ptr( arg_pack , enkf_state); /* 0: */
|
||||
arg_pack_append_ptr( arg_pack , ert_run_context_iens_get_arg( run_context , iens )); /* 1: */
|
||||
arg_pack_append_bool( arg_pack , true ); /* 2: Interactive */
|
||||
arg_pack_append_ptr(arg_pack, realizations_msg_list[iens]); /* 3: List of interactive mode messages. */
|
||||
arg_pack_append_bool( arg_pack, true ); /* 4: Manual load */
|
||||
arg_pack_append_ptr(arg_pack, &result[iens]); /* 5: Result */
|
||||
|
||||
thread_pool_add_job( tp , enkf_state_load_from_forward_model_mt , arg_pack);
|
||||
}
|
||||
@@ -3432,6 +3559,7 @@ void enkf_main_load_from_forward_model_with_fs(enkf_main_type * enkf_main, int i
|
||||
arg_pack_free(arg_list[iens]);
|
||||
}
|
||||
free( arg_list );
|
||||
ert_run_context_free( run_context );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ void * enkf_main_ensemble_run_JOB( void * self , const stringlist_type * args )
|
||||
bool_vector_type * iactive = alloc_iactive_vector_from_range(args, 0, stringlist_get_size(args), ens_size);
|
||||
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
enkf_main_run_exp( enkf_main , iactive , true , 0 , 0 , ANALYZED);
|
||||
enkf_main_run_exp( enkf_main , iactive , true );
|
||||
bool_vector_free(iactive);
|
||||
return NULL;
|
||||
}
|
||||
@@ -536,43 +536,34 @@ static void enkf_main_export_runpath_file(enkf_main_type * enkf_main,
|
||||
const model_config_type * model_config = enkf_main_get_model_config(enkf_main);
|
||||
const char * basename_fmt = ecl_config_get_eclbase(ecl_config);
|
||||
const char * runpath_fmt = model_config_get_runpath_as_char(model_config);
|
||||
const qc_module_type * qc_module = enkf_main_get_qc_module( enkf_main );
|
||||
|
||||
|
||||
runpath_list_type * runpath_list = runpath_list_alloc();
|
||||
char * cwd = util_alloc_cwd();
|
||||
runpath_list_type * runpath_list = runpath_list_alloc( qc_module_get_runpath_list_file( qc_module ));
|
||||
|
||||
for (int iter = 0; iter < int_vector_size(iterations); ++iter) {
|
||||
for (int iens = 0; iens < int_vector_size(realizations); ++iens) {
|
||||
int iter_value = int_vector_iget(iterations, iter);
|
||||
int iens_value = int_vector_iget(realizations, iens);
|
||||
char * basename = NULL;
|
||||
char * basename;
|
||||
char * runpath;
|
||||
|
||||
if (basename_fmt)
|
||||
basename = util_alloc_sprintf(basename_fmt, iens_value);
|
||||
else
|
||||
basename = util_alloc_sprintf("--%d", iens_value);
|
||||
char * runpath = NULL;
|
||||
if (model_config_runpath_requires_iter(model_config)) {
|
||||
|
||||
if (model_config_runpath_requires_iter(model_config))
|
||||
runpath = util_alloc_sprintf(runpath_fmt, iens_value, iter_value);
|
||||
}
|
||||
else
|
||||
runpath = util_alloc_sprintf(runpath_fmt, iens_value);
|
||||
|
||||
|
||||
runpath_list_add(runpath_list, iens_value, iter_value, runpath, basename);
|
||||
|
||||
free(basename);
|
||||
free(runpath);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
qc_module_type * qc_module = enkf_main_get_qc_module( enkf_main );
|
||||
const char * runpath_file_name = qc_module_get_runpath_list_file(qc_module);
|
||||
FILE * file_stream = util_mkdir_fopen(runpath_file_name, "w");
|
||||
runpath_list_fprintf(runpath_list, file_stream);
|
||||
fclose(file_stream);
|
||||
}
|
||||
|
||||
free(cwd);
|
||||
runpath_list_fprintf(runpath_list);
|
||||
runpath_list_free(runpath_list);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,13 +95,13 @@ static void * enkf_main_initialize_from_scratch_mt(void * void_arg) {
|
||||
enkf_main_type * enkf_main = arg_pack_iget_ptr( arg_pack , 0);
|
||||
const stringlist_type * param_list = arg_pack_iget_const_ptr( arg_pack , 1 );
|
||||
int iens = arg_pack_iget_int( arg_pack , 2 );
|
||||
init_mode_enum init_mode = arg_pack_iget_int( arg_pack , 3 );
|
||||
init_mode_type init_mode = arg_pack_iget_int( arg_pack , 3 );
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , iens);
|
||||
enkf_state_initialize( state , enkf_main_get_fs( enkf_main ) , param_list , init_mode);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void enkf_main_initialize_from_scratch_with_bool_vector(enkf_main_type * enkf_main , const stringlist_type * param_list ,const bool_vector_type * iens_mask , init_mode_enum init_mode) {
|
||||
void enkf_main_initialize_from_scratch_with_bool_vector(enkf_main_type * enkf_main , const stringlist_type * param_list ,const bool_vector_type * iens_mask , init_mode_type init_mode) {
|
||||
int num_cpu = 4;
|
||||
int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
thread_pool_type * tp = thread_pool_alloc( num_cpu , true );
|
||||
@@ -129,7 +129,7 @@ void enkf_main_initialize_from_scratch_with_bool_vector(enkf_main_type * enkf_ma
|
||||
thread_pool_free( tp );
|
||||
}
|
||||
|
||||
void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const stringlist_type * param_list , int iens1 , int iens2, init_mode_enum init_mode) {
|
||||
void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const stringlist_type * param_list , int iens1 , int iens2, init_mode_type init_mode) {
|
||||
int iens;
|
||||
int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iens_mask = bool_vector_alloc(ens_size,false);
|
||||
@@ -422,7 +422,8 @@ static void enkf_main_create_fs( const enkf_main_type * enkf_main , const char *
|
||||
|
||||
enkf_fs_create_fs( new_mount_point,
|
||||
model_config_get_dbase_type( enkf_main->model_config ) ,
|
||||
model_config_get_dbase_args( enkf_main->model_config ));
|
||||
model_config_get_dbase_args( enkf_main->model_config ) ,
|
||||
false );
|
||||
|
||||
free( new_mount_point );
|
||||
}
|
||||
|
||||
681
ThirdParty/Ert/devel/libenkf/src/enkf_state.c
vendored
681
ThirdParty/Ert/devel/libenkf/src/enkf_state.c
vendored
File diff suppressed because it is too large
Load Diff
363
ThirdParty/Ert/devel/libenkf/src/ert_run_context.c
vendored
Normal file
363
ThirdParty/Ert/devel/libenkf/src/ert_run_context.c
vendored
Normal file
@@ -0,0 +1,363 @@
|
||||
/*
|
||||
Copyright (C) 2014 Statoil ASA, Norway.
|
||||
|
||||
The file 'ert_run_context.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/vector.h>
|
||||
#include <ert/util/path_fmt.h>
|
||||
#include <ert/util/subst_list.h>
|
||||
#include <ert/util/int_vector.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/type_vector_functions.h>
|
||||
|
||||
#include <ert/enkf/enkf_types.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
#include <ert/enkf/ert_run_context.h>
|
||||
|
||||
|
||||
#define ERT_RUN_CONTEXT_TYPE_ID 55534132
|
||||
|
||||
|
||||
struct ert_run_context_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
vector_type * run_args;
|
||||
bool_vector_type * iactive; // This can be updated ....
|
||||
run_mode_type run_mode;
|
||||
init_mode_type init_mode;
|
||||
int iter;
|
||||
int step1;
|
||||
int step2;
|
||||
int load_start;
|
||||
int_vector_type * iens_map;
|
||||
|
||||
enkf_fs_type * init_fs;
|
||||
enkf_fs_type * result_fs;
|
||||
enkf_fs_type * update_target_fs;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
run_mode_type run_mode ,
|
||||
bool_vector_type * iactive ,
|
||||
int load_start ,
|
||||
int init_step_parameter ,
|
||||
state_enum init_state_parameter ,
|
||||
state_enum init_state_dynamic ,
|
||||
int iter ,
|
||||
int step1 ,
|
||||
int step2)
|
||||
*/
|
||||
|
||||
//ert_run_context_type * ert_run_context_alloc(enkf_fs_type * init_fs ,
|
||||
// enkf_fs_type * result_fs,
|
||||
// enkf_fs_type * update_target_fs ,
|
||||
// const bool_vector_type * iactive ,
|
||||
// path_fmt_type * runpath_fmt ,
|
||||
// subst_list_type * subst_list ,
|
||||
// run_mode_type run_mode ,
|
||||
// int init_step_parameter ,
|
||||
// state_enum init_state_parameter,
|
||||
// state_enum init_state_dynamic ,
|
||||
// int iter ,
|
||||
// int step1 ,
|
||||
// int step2 ) {
|
||||
//
|
||||
// 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->step1 = step1;
|
||||
// context->step2 = step2;
|
||||
//
|
||||
//
|
||||
// for (int iens = 0; iens < bool_vector_size( iactive ); iens++) {
|
||||
// if (bool_vector_iget( iactive , iens )) {
|
||||
// char * tmp1 = path_fmt_alloc_path(runpath_fmt , false , iens, iter); /* 1: Replace first %d with iens, if a second %d replace with iter */
|
||||
// char * tmp2 = tmp1;
|
||||
//
|
||||
// if (subst_list)
|
||||
// tmp2 = subst_list_alloc_filtered_string( subst_list , tmp1 ); /* 2: Filter out various magic strings like <CASE> and <CWD>. */
|
||||
// {
|
||||
// run_arg_type * arg;
|
||||
//
|
||||
// switch (run_mode) {
|
||||
// case(ENSEMBLE_EXPERIMENT):
|
||||
// arg = run_arg_alloc_ENSEMBLE_EXPERIMENT( init_fs , iens , iter , tmp2);
|
||||
// break;
|
||||
// case(INIT_ONLY):
|
||||
// arg = run_arg_alloc_INIT_ONLY( init_fs , iens , iter , tmp2);
|
||||
// break;
|
||||
// default:
|
||||
// arg = run_arg_alloc( init_fs , result_fs , update_target_fs , iens , run_mode , init_step_parameter , init_state_parameter , init_state_dynamic , step1 , step2 , iter , tmp2);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// vector_append_owned_ref( context->run_args , arg , run_arg_free__);
|
||||
// }
|
||||
//
|
||||
// if (subst_list)
|
||||
// free( tmp2 );
|
||||
// free( tmp1 );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return context;
|
||||
//}
|
||||
|
||||
|
||||
static stringlist_type * ert_run_context_alloc_runpath_list(const bool_vector_type * iactive , path_fmt_type * runpath_fmt , subst_list_type * subst_list , int iter) {
|
||||
stringlist_type * runpath_list = stringlist_alloc_new();
|
||||
for (int iens = 0; iens < bool_vector_size( iactive ); iens++) {
|
||||
if (bool_vector_iget( iactive , iens )) {
|
||||
char * tmp1 = path_fmt_alloc_path(runpath_fmt , false , iens, iter); /* 1: Replace first %d with iens, if a second %d replace with iter */
|
||||
char * tmp2 = tmp1;
|
||||
|
||||
if (subst_list)
|
||||
tmp2 = subst_list_alloc_filtered_string( subst_list , tmp1 ); /* 2: Filter out various magic strings like <CASE> and <CWD>. */
|
||||
|
||||
stringlist_append_copy( runpath_list , tmp2 );
|
||||
|
||||
if (subst_list)
|
||||
free( tmp2 );
|
||||
free( tmp1 );
|
||||
} else
|
||||
stringlist_append_ref( runpath_list , NULL );
|
||||
}
|
||||
return runpath_list;
|
||||
}
|
||||
|
||||
|
||||
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 , init_mode_type init_mode, 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->init_mode = init_mode;
|
||||
context->iter = iter;
|
||||
|
||||
context->init_fs = init_fs;
|
||||
context->result_fs = result_fs;
|
||||
context->update_target_fs = update_target_fs;
|
||||
|
||||
context->step1 = 0;
|
||||
context->step2 = 0;
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
ert_run_context_type * ert_run_context_alloc_INIT_ONLY(enkf_fs_type * init_fs , const bool_vector_type * iactive ,
|
||||
path_fmt_type * runpath_fmt ,
|
||||
subst_list_type * subst_list ,
|
||||
init_mode_type init_mode ,
|
||||
int iter) {
|
||||
|
||||
ert_run_context_type * context = ert_run_context_alloc( iactive , INIT_ONLY , init_fs , NULL , NULL , init_mode , iter );
|
||||
{
|
||||
stringlist_type * runpath_list = ert_run_context_alloc_runpath_list( iactive , runpath_fmt , subst_list , iter );
|
||||
for (int iens = 0; iens < bool_vector_size( iactive ); iens++) {
|
||||
if (bool_vector_iget( iactive , iens )) {
|
||||
run_arg_type * arg = run_arg_alloc_INIT_ONLY( init_fs , iens , iter , stringlist_iget( runpath_list , iens));
|
||||
vector_append_owned_ref( context->run_args , arg , run_arg_free__);
|
||||
}
|
||||
}
|
||||
stringlist_free( runpath_list );
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ert_run_context_type * ert_run_context_alloc_ENSEMBLE_EXPERIMENT(enkf_fs_type * fs , const bool_vector_type * iactive ,
|
||||
path_fmt_type * runpath_fmt ,
|
||||
subst_list_type * subst_list ,
|
||||
init_mode_type init_mode ,
|
||||
int iter) {
|
||||
|
||||
ert_run_context_type * context = ert_run_context_alloc( iactive , ENSEMBLE_EXPERIMENT , fs , fs , NULL , init_mode , iter);
|
||||
{
|
||||
stringlist_type * runpath_list = ert_run_context_alloc_runpath_list( iactive , runpath_fmt , subst_list , iter );
|
||||
for (int iens = 0; iens < bool_vector_size( iactive ); iens++) {
|
||||
if (bool_vector_iget( iactive , iens )) {
|
||||
run_arg_type * arg = run_arg_alloc_ENSEMBLE_EXPERIMENT( fs , iens , iter , stringlist_iget( runpath_list , iens));
|
||||
vector_append_owned_ref( context->run_args , arg , run_arg_free__);
|
||||
}
|
||||
}
|
||||
stringlist_free( runpath_list );
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ert_run_context_type * ert_run_context_alloc_SMOOTHER_RUN(enkf_fs_type * simulate_fs , enkf_fs_type * target_update_fs ,
|
||||
const bool_vector_type * iactive ,
|
||||
path_fmt_type * runpath_fmt ,
|
||||
subst_list_type * subst_list ,
|
||||
init_mode_type init_mode ,
|
||||
int iter) {
|
||||
|
||||
ert_run_context_type * context = ert_run_context_alloc( iactive , SMOOTHER_UPDATE , simulate_fs , simulate_fs , target_update_fs , init_mode , iter);
|
||||
{
|
||||
stringlist_type * runpath_list = ert_run_context_alloc_runpath_list( iactive , runpath_fmt , subst_list , iter );
|
||||
for (int iens = 0; iens < bool_vector_size( iactive ); iens++) {
|
||||
if (bool_vector_iget( iactive , iens )) {
|
||||
run_arg_type * arg = run_arg_alloc_SMOOTHER_RUN( simulate_fs , target_update_fs , iens , iter , stringlist_iget( runpath_list , iens));
|
||||
vector_append_owned_ref( context->run_args , arg , run_arg_free__);
|
||||
}
|
||||
}
|
||||
stringlist_free( runpath_list );
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
ert_run_context_type * ert_run_context_alloc_ENKF_ASSIMILATION(enkf_fs_type * fs ,
|
||||
const bool_vector_type * iactive ,
|
||||
path_fmt_type * runpath_fmt ,
|
||||
subst_list_type * subst_list ,
|
||||
init_mode_type init_mode ,
|
||||
state_enum init_state_parameter ,
|
||||
state_enum init_state_dynamic ,
|
||||
int step1 ,
|
||||
int step2 ,
|
||||
int iter) {
|
||||
|
||||
ert_run_context_type * context = ert_run_context_alloc( iactive , SMOOTHER_UPDATE , fs , fs , fs , init_mode , iter);
|
||||
{
|
||||
stringlist_type * runpath_list = ert_run_context_alloc_runpath_list( iactive , runpath_fmt , subst_list , iter );
|
||||
for (int iens = 0; iens < bool_vector_size( iactive ); iens++) {
|
||||
if (bool_vector_iget( iactive , iens )) {
|
||||
run_arg_type * arg = run_arg_alloc_ENKF_ASSIMILATION( fs , iens , init_state_parameter , init_state_dynamic , step1 , step2 , stringlist_iget( runpath_list , iens));
|
||||
vector_append_owned_ref( context->run_args , arg , run_arg_free__);
|
||||
}
|
||||
}
|
||||
stringlist_free( runpath_list );
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( ert_run_context , ERT_RUN_CONTEXT_TYPE_ID );
|
||||
|
||||
|
||||
|
||||
void ert_run_context_free( ert_run_context_type * context ) {
|
||||
vector_free( context->run_args );
|
||||
bool_vector_free( context->iactive );
|
||||
int_vector_free( context->iens_map );
|
||||
free( context );
|
||||
}
|
||||
|
||||
|
||||
int ert_run_context_get_size( const ert_run_context_type * context ) {
|
||||
return vector_get_size( context->run_args );
|
||||
}
|
||||
|
||||
|
||||
|
||||
run_mode_type ert_run_context_get_mode( const ert_run_context_type * context ) {
|
||||
return context->run_mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
init_mode_type ert_run_context_get_init_mode( const ert_run_context_type * context ) {
|
||||
return context->init_mode;
|
||||
}
|
||||
|
||||
|
||||
int ert_run_context_get_iter( const ert_run_context_type * context ) {
|
||||
return context->iter;
|
||||
}
|
||||
|
||||
int ert_run_context_get_step1( const ert_run_context_type * context ) {
|
||||
return context->step1;
|
||||
}
|
||||
|
||||
|
||||
int ert_run_context_get_load_start( const ert_run_context_type * context ) {
|
||||
if (context->step1 == 0)
|
||||
return 1;
|
||||
else
|
||||
return context->step1;
|
||||
}
|
||||
|
||||
|
||||
int ert_run_context_get_step2( const ert_run_context_type * context ) {
|
||||
return context->step2;
|
||||
}
|
||||
|
||||
|
||||
bool_vector_type * ert_run_context_get_iactive( const ert_run_context_type * context ) {
|
||||
return context->iactive;
|
||||
}
|
||||
|
||||
|
||||
run_arg_type * ert_run_context_iget_arg( const ert_run_context_type * context , int index) {
|
||||
return vector_iget( context->run_args , index );
|
||||
}
|
||||
|
||||
|
||||
run_arg_type * ert_run_context_iens_get_arg( const ert_run_context_type * context , int iens) {
|
||||
int index = int_vector_iget( context->iens_map , iens );
|
||||
if (index >= 0)
|
||||
return vector_iget( context->run_args , index );
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
enkf_fs_type * ert_run_context_get_init_fs(const ert_run_context_type * run_context) {
|
||||
if (run_context->init_fs)
|
||||
return run_context->init_fs;
|
||||
else {
|
||||
util_abort("%s: internal error - tried to access run_context->init_fs when init_fs == NULL\n",__func__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enkf_fs_type * ert_run_context_get_result_fs(const ert_run_context_type * run_context) {
|
||||
if (run_context->result_fs)
|
||||
return run_context->result_fs;
|
||||
else {
|
||||
util_abort("%s: internal error - tried to access run_context->result_fs when result_fs == NULL\n",__func__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enkf_fs_type * ert_run_context_get_update_target_fs(const ert_run_context_type * run_context) {
|
||||
if (run_context->update_target_fs)
|
||||
return run_context->update_target_fs;
|
||||
else {
|
||||
util_abort("%s: internal error - tried to access run_context->update_target_fs when update_target_fs == NULL\n",__func__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ void ert_workflow_list_set_verbose( ert_workflow_list_type * workflow_list , boo
|
||||
}
|
||||
|
||||
|
||||
subst_list_type * ert_workflow_list_get_context(const ert_workflow_list_type * workflow_list) {
|
||||
const subst_list_type * ert_workflow_list_get_context(const ert_workflow_list_type * workflow_list) {
|
||||
return workflow_list->context;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ workflow_type * ert_workflow_list_add_workflow( ert_workflow_list_type * workflo
|
||||
if (workflow_name == NULL)
|
||||
util_alloc_file_components( workflow_file , NULL , &name , NULL );
|
||||
else
|
||||
name = workflow_name;
|
||||
name = (char *) workflow_name;
|
||||
|
||||
|
||||
hash_insert_hash_owned_ref( workflow_list->workflows , name , workflow , workflow_free__);
|
||||
|
||||
114
ThirdParty/Ert/devel/libenkf/src/gen_data.c
vendored
114
ThirdParty/Ert/devel/libenkf/src/gen_data.c
vendored
@@ -213,7 +213,7 @@ void gen_data_deserialize(gen_data_type * gen_data , node_id_type node_id , cons
|
||||
static void gen_data_set_data__(gen_data_type * gen_data , int size, int report_step , ecl_type_enum load_type , const void * data) {
|
||||
gen_data_assert_size(gen_data , size, report_step);
|
||||
|
||||
if (gen_data_config_is_dynamic( gen_data->config ))
|
||||
if (gen_data_config_is_dynamic( gen_data->config ))
|
||||
gen_data_config_update_active( gen_data->config , report_step , gen_data->active_mask);
|
||||
|
||||
gen_data_realloc_data(gen_data);
|
||||
@@ -231,9 +231,51 @@ static void gen_data_set_data__(gen_data_type * gen_data , int size, int report_
|
||||
util_double_to_float((float *) gen_data->data , data , size);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool gen_data_fload_active__(gen_data_type * gen_data, const char * filename, int size) {
|
||||
/*
|
||||
Look for file @filename_active - if that file is found it is
|
||||
interpreted as a an active|inactive mask created by the forward
|
||||
model.
|
||||
|
||||
The file is assumed to be an ASCII file with integers, 0
|
||||
indicates inactive elements and 1 active elements. The file
|
||||
should of course be as long as @filename.
|
||||
|
||||
If the file is not found the gen_data->active_mask is set to
|
||||
all-true (i.e. the default true value is invoked).
|
||||
*/
|
||||
bool file_exists = false;
|
||||
if (gen_data_config_is_dynamic( gen_data->config )) {
|
||||
bool_vector_reset( gen_data->active_mask );
|
||||
bool_vector_iset( gen_data->active_mask , size - 1, true );
|
||||
{
|
||||
char * active_file = util_alloc_sprintf("%s_active" , filename );
|
||||
if (util_file_exists( active_file )) {
|
||||
file_exists = true;
|
||||
FILE * stream = util_fopen( active_file , "r");
|
||||
int active_int;
|
||||
for (int index=0; index < size; index++) {
|
||||
if (fscanf( stream , "%d" , &active_int) == 1) {
|
||||
if (active_int == 1)
|
||||
bool_vector_iset( gen_data->active_mask , index , true);
|
||||
else if (active_int == 0)
|
||||
bool_vector_iset( gen_data->active_mask , index , false);
|
||||
else
|
||||
util_abort("%s: error when loading active mask from:%s only 0 and 1 allowed \n",__func__ , active_file);
|
||||
} else
|
||||
util_abort("%s: error when loading active mask from:%s - file not long enough.\n",__func__ , active_file );
|
||||
}
|
||||
fclose( stream );
|
||||
}
|
||||
free( active_file );
|
||||
}
|
||||
}
|
||||
return file_exists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -249,64 +291,34 @@ static void gen_data_set_data__(gen_data_type * gen_data , int size, int report_
|
||||
other members; it is perfectly OK for the file to not exist. In
|
||||
which case a size of zero is set, for this report step.
|
||||
|
||||
Return value is whether file was found - might have to check this
|
||||
in calling scope.
|
||||
Return value is whether file was found or was empty
|
||||
- might have to check this in calling scope.
|
||||
*/
|
||||
|
||||
bool gen_data_fload_with_report_step( gen_data_type * gen_data , const char * filename , int report_step) {
|
||||
bool has_file = util_file_exists(filename);
|
||||
bool file_exists = util_file_exists(filename);
|
||||
void * buffer = NULL;
|
||||
int size = 0;
|
||||
ecl_type_enum load_type;
|
||||
|
||||
if ( has_file ) {
|
||||
if ( file_exists ) {
|
||||
ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data->config);
|
||||
gen_data_file_format_type input_format = gen_data_config_get_input_format( gen_data->config );
|
||||
buffer = gen_common_fload_alloc( filename , input_format , internal_type , &load_type , &size);
|
||||
|
||||
/*
|
||||
Look for file @filename_active - if that file is found it is
|
||||
interpreted as a an active|inactive mask created by the forward
|
||||
model.
|
||||
|
||||
The file is assumed to be an ASCII file with integers, 0
|
||||
indicates inactive elements and 1 active elements. The file
|
||||
should of course be as long as @filename.
|
||||
|
||||
If the file is not found the gen_data->active_mask is set to
|
||||
all-true (i.e. the default true value is invoked).
|
||||
*/
|
||||
if (gen_data_config_is_dynamic( gen_data->config )) {
|
||||
bool_vector_reset( gen_data->active_mask );
|
||||
bool_vector_iset( gen_data->active_mask , size - 1, true );
|
||||
{
|
||||
char * active_file = util_alloc_sprintf("%s_active" , filename );
|
||||
if (util_file_exists( active_file )) {
|
||||
FILE * stream = util_fopen( active_file , "r");
|
||||
int active_int;
|
||||
for (int index=0; index < size; index++) {
|
||||
if (fscanf( stream , "%d" , &active_int) == 1) {
|
||||
if (active_int == 1)
|
||||
bool_vector_iset( gen_data->active_mask , index , true);
|
||||
else if (active_int == 0)
|
||||
bool_vector_iset( gen_data->active_mask , index , false);
|
||||
else
|
||||
util_abort("%s: error when loading active mask from:%s only 0 and 1 allowed \n",__func__ , active_file);
|
||||
} else
|
||||
util_abort("%s: error when loading active mask from:%s - file not long enough.\n",__func__ , active_file );
|
||||
}
|
||||
fclose( stream );
|
||||
}
|
||||
free( active_file );
|
||||
}
|
||||
if (size > 0) {
|
||||
gen_data_fload_active__(gen_data, filename, size);
|
||||
} else {
|
||||
bool_vector_reset( gen_data->active_mask );
|
||||
}
|
||||
gen_data_set_data__(gen_data , size , report_step , load_type , buffer );
|
||||
util_safe_free(buffer);
|
||||
}
|
||||
util_safe_free(buffer);
|
||||
return has_file;
|
||||
return file_exists;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool gen_data_fload( gen_data_type * gen_data , const char * filename) {
|
||||
return gen_data_fload_with_report_step( gen_data , filename , 0);
|
||||
}
|
||||
@@ -349,7 +361,6 @@ bool gen_data_initialize(gen_data_type * gen_data , int iens , const char * init
|
||||
|
||||
|
||||
|
||||
|
||||
static void gen_data_ecl_write_ASCII(const gen_data_type * gen_data , const char * file , gen_data_file_format_type export_format) {
|
||||
FILE * stream = util_fopen(file , "w");
|
||||
char * template_buffer;
|
||||
@@ -464,6 +475,19 @@ double gen_data_iget_double(const gen_data_type * gen_data, int index) {
|
||||
}
|
||||
|
||||
|
||||
void gen_data_export_data(const gen_data_type * gen_data , double_vector_type * export_data) {
|
||||
ecl_type_enum internal_type = gen_data_config_get_internal_type(gen_data->config);
|
||||
if (internal_type == ECL_DOUBLE_TYPE)
|
||||
double_vector_memcpy_from_data( export_data , (const double *) gen_data->data , gen_data_get_size( gen_data ));
|
||||
else {
|
||||
double_vector_reset( export_data );
|
||||
float * float_data = (float *) gen_data->data;
|
||||
for (int i = 0; i < gen_data_get_size( gen_data ); i++)
|
||||
double_vector_iset( export_data , i , float_data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The filesystem will (currently) store gen_data instances which do
|
||||
|
||||
27
ThirdParty/Ert/devel/libenkf/src/gen_kw.c
vendored
27
ThirdParty/Ert/devel/libenkf/src/gen_kw.c
vendored
@@ -112,6 +112,17 @@ double gen_kw_data_iget( gen_kw_type * gen_kw, int index , bool do_transform )
|
||||
}
|
||||
|
||||
|
||||
void gen_kw_data_set_vector( gen_kw_type * gen_kw, const double_vector_type * values ) {
|
||||
int size = gen_kw_config_get_data_size( gen_kw->config );
|
||||
if (size == double_vector_size( values )) {
|
||||
for (int index = 0; index < size; index++)
|
||||
gen_kw->data[index] = double_vector_iget( values , index);
|
||||
} else
|
||||
util_abort( "%s: Invalid size for vector:%d gen_Kw:%d \n",__func__ , double_vector_size( values ) , size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void gen_kw_data_iset( gen_kw_type * gen_kw, int index , double value )
|
||||
{
|
||||
int size = gen_kw_config_get_data_size( gen_kw->config );
|
||||
@@ -265,11 +276,19 @@ void gen_kw_ecl_write(const gen_kw_type * gen_kw , const char * run_path , const
|
||||
if (fortio_is_instance(filestream)) {
|
||||
util_abort("%s: Called with fortio instance, aborting\n", __func__);
|
||||
} else {
|
||||
gen_kw_write_export_file(gen_kw, filestream);
|
||||
if (filestream)
|
||||
gen_kw_write_export_file(gen_kw, filestream);
|
||||
{
|
||||
char * target_file;
|
||||
if (run_path)
|
||||
target_file = util_alloc_filename( run_path , base_file , NULL);
|
||||
else
|
||||
target_file = util_alloc_string_copy( base_file );
|
||||
|
||||
char * target_file = util_alloc_filename( run_path , base_file , NULL);
|
||||
gen_kw_filter_file(gen_kw , target_file);
|
||||
free( target_file );
|
||||
gen_kw_filter_file(gen_kw , target_file);
|
||||
|
||||
free( target_file );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
23
ThirdParty/Ert/devel/libenkf/src/qc_module.c
vendored
23
ThirdParty/Ert/devel/libenkf/src/qc_module.c
vendored
@@ -40,7 +40,6 @@ struct qc_module_struct {
|
||||
workflow_type * qc_workflow;
|
||||
ert_workflow_list_type * workflow_list;
|
||||
runpath_list_type * runpath_list;
|
||||
char * runpath_list_file;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,18 +50,16 @@ qc_module_type * qc_module_alloc( ert_workflow_list_type * workflow_list , const
|
||||
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->runpath_list = runpath_list_alloc( NULL );
|
||||
qc_module_set_path( qc_module , qc_path );
|
||||
qc_module_set_runpath_list_file( qc_module , NULL, RUNPATH_LIST_FILE );
|
||||
|
||||
|
||||
return qc_module;
|
||||
}
|
||||
|
||||
|
||||
void qc_module_free( qc_module_type * qc_module ) {
|
||||
util_safe_free( qc_module->qc_path );
|
||||
util_safe_free( qc_module->runpath_list_file);
|
||||
runpath_list_free( qc_module->runpath_list );
|
||||
free( qc_module );
|
||||
}
|
||||
@@ -73,14 +70,11 @@ runpath_list_type * qc_module_get_runpath_list( qc_module_type * qc_module ) {
|
||||
|
||||
|
||||
void qc_module_export_runpath_list( const qc_module_type * qc_module ) {
|
||||
FILE * stream = util_fopen( qc_module->runpath_list_file , "w");
|
||||
runpath_list_fprintf( qc_module->runpath_list , stream );
|
||||
fclose( stream );
|
||||
runpath_list_fprintf( qc_module->runpath_list );
|
||||
}
|
||||
|
||||
static void qc_module_set_runpath_list_file__( qc_module_type * qc_module , const char * runpath_list_file) {
|
||||
util_safe_free( qc_module->runpath_list_file );
|
||||
qc_module->runpath_list_file = util_alloc_string_copy( runpath_list_file );
|
||||
runpath_list_set_export_file( qc_module->runpath_list , runpath_list_file );
|
||||
}
|
||||
|
||||
|
||||
@@ -111,8 +105,8 @@ void qc_module_set_runpath_list_file( qc_module_type * qc_module , const char *
|
||||
}
|
||||
}
|
||||
|
||||
const char * qc_module_get_runpath_list_file( qc_module_type * qc_module) {
|
||||
return qc_module->runpath_list_file;
|
||||
const char * qc_module_get_runpath_list_file( const qc_module_type * qc_module) {
|
||||
return runpath_list_get_export_file( qc_module->runpath_list );
|
||||
}
|
||||
|
||||
|
||||
@@ -143,8 +137,9 @@ void qc_module_set_workflow( qc_module_type * qc_module , const char * qc_workfl
|
||||
bool qc_module_run_workflow( const qc_module_type * qc_module , void * self) {
|
||||
bool verbose = false;
|
||||
if (qc_module->qc_workflow != NULL ) {
|
||||
if (!util_file_exists( qc_module->runpath_list_file ))
|
||||
fprintf(stderr,"** Warning: the file:%s with a list of runpath directories was not found - QC workflow wil probably fail.\n" , qc_module->runpath_list_file);
|
||||
const char * export_file = runpath_list_get_export_file( qc_module->runpath_list );
|
||||
if (!util_file_exists( export_file ))
|
||||
fprintf(stderr,"** Warning: the file:%s with a list of runpath directories was not found - QC workflow wil probably fail.\n" , export_file);
|
||||
|
||||
bool result = ert_workflow_list_run_workflow__( qc_module->workflow_list, qc_module->qc_workflow , verbose , self);
|
||||
return result;
|
||||
|
||||
284
ThirdParty/Ert/devel/libenkf/src/run_arg.c
vendored
Normal file
284
ThirdParty/Ert/devel/libenkf/src/run_arg.c
vendored
Normal file
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
Copyright (C) 2014 Statoil ASA, Norway.
|
||||
|
||||
The file 'run_arg.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <ert/util/path_fmt.h>
|
||||
#include <ert/util/subst_list.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/enkf/enkf_types.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
#include <ert/enkf/enkf_fs.h>
|
||||
|
||||
|
||||
#define RUN_ARG_TYPE_ID 66143287
|
||||
|
||||
|
||||
|
||||
struct run_arg_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
bool __ready; /* An attempt to check the internal state - not really used. */
|
||||
int iens;
|
||||
bool active; /* Is this state object active at all - used for instance in ensemble experiments where only some of the members are integrated. */
|
||||
int init_step_parameters; /* The report step we initialize parameters from - will often be equal to step1, but can be different. */
|
||||
state_enum init_state_parameter; /* Whether we should init from a forecast or an analyzed state - parameters. */
|
||||
state_enum init_state_dynamic; /* Whether we should init from a forecast or an analyzed state - dynamic state variables. */
|
||||
int max_internal_submit; /* How many times the enkf_state object should try to resubmit when the queueu has said everything is OK - but the load fails. */
|
||||
int num_internal_submit;
|
||||
int load_start; /* When loading back results - start at this step. */
|
||||
int step1; /* The forward model is integrated: step1 -> step2 */
|
||||
int step2;
|
||||
int iter;
|
||||
char * run_path; /* The currently used runpath - is realloced / freed for every step. */
|
||||
run_mode_type run_mode; /* What type of run this is */
|
||||
int queue_index; /* The job will in general have a different index in the queue than the iens number. */
|
||||
|
||||
enkf_fs_type * init_fs;
|
||||
enkf_fs_type * result_fs;
|
||||
enkf_fs_type * update_target_fs;
|
||||
|
||||
/******************************************************************/
|
||||
/* Return value - set by the called routine!! */
|
||||
run_status_type run_status;
|
||||
};
|
||||
|
||||
|
||||
UTIL_SAFE_CAST_FUNCTION( run_arg , RUN_ARG_TYPE_ID )
|
||||
UTIL_IS_INSTANCE_FUNCTION( run_arg , RUN_ARG_TYPE_ID )
|
||||
|
||||
|
||||
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;
|
||||
|
||||
if (step1 == 0)
|
||||
run_arg->load_start = 1;
|
||||
else
|
||||
run_arg->load_start = step1;
|
||||
|
||||
return run_arg;
|
||||
}
|
||||
|
||||
|
||||
run_arg_type * run_arg_alloc_ENKF_ASSIMILATION(enkf_fs_type * fs ,
|
||||
int iens ,
|
||||
state_enum init_state_parameter ,
|
||||
state_enum init_state_dynamic ,
|
||||
int step1 ,
|
||||
int step2 ,
|
||||
const char * runpath) {
|
||||
|
||||
return run_arg_alloc(fs,fs,fs,iens,ENKF_ASSIMILATION,step1 , init_state_parameter, init_state_dynamic , step1 , step2 , 0 , runpath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
run_arg_type * run_arg_alloc_ENSEMBLE_EXPERIMENT(enkf_fs_type * fs , int iens , int iter , const char * runpath) {
|
||||
return run_arg_alloc(fs , fs , NULL , iens , ENSEMBLE_EXPERIMENT , 0 , ANALYZED , ANALYZED , 0 , 0 , iter , runpath);
|
||||
}
|
||||
|
||||
|
||||
run_arg_type * run_arg_alloc_INIT_ONLY(enkf_fs_type * init_fs , int iens , int iter , const char * runpath) {
|
||||
return run_arg_alloc(init_fs , NULL , NULL , iens , INIT_ONLY , 0 , ANALYZED , ANALYZED , 0 , 0 , iter , runpath);
|
||||
}
|
||||
|
||||
|
||||
run_arg_type * run_arg_alloc_SMOOTHER_RUN(enkf_fs_type * simulate_fs , enkf_fs_type * update_target_fs , int iens , int iter , const char * runpath) {
|
||||
return run_arg_alloc(simulate_fs , simulate_fs , update_target_fs , iens , ENSEMBLE_EXPERIMENT , 0 , ANALYZED , ANALYZED , 0 , 0 , iter , runpath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void run_arg_free(run_arg_type * run_arg) {
|
||||
util_safe_free(run_arg->run_path);
|
||||
free(run_arg);
|
||||
}
|
||||
|
||||
|
||||
void run_arg_free__(void * arg) {
|
||||
run_arg_type * run_arg = run_arg_safe_cast( arg );
|
||||
run_arg_free( run_arg );
|
||||
}
|
||||
|
||||
|
||||
void run_arg_complete_run(run_arg_type * run_arg) {
|
||||
if (run_arg->run_status == JOB_RUN_OK) {
|
||||
util_safe_free(run_arg->run_path);
|
||||
run_arg->run_path = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void run_arg_increase_submit_count( run_arg_type * run_arg ) {
|
||||
run_arg->num_internal_submit++;
|
||||
}
|
||||
|
||||
|
||||
void run_arg_set_queue_index( run_arg_type * run_arg , int queue_index) {
|
||||
run_arg->queue_index = queue_index;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * run_arg_get_runpath( const run_arg_type * run_arg) {
|
||||
return run_arg->run_path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int run_arg_get_iter( const run_arg_type * run_arg ) {
|
||||
return run_arg->iter;
|
||||
}
|
||||
|
||||
|
||||
int run_arg_get_iens( const run_arg_type * run_arg ) {
|
||||
return run_arg->iens;
|
||||
}
|
||||
|
||||
|
||||
int run_arg_get_load_start( const run_arg_type * run_arg ) {
|
||||
return run_arg->load_start;
|
||||
}
|
||||
|
||||
|
||||
bool run_arg_is_ready( const run_arg_type * run_arg) {
|
||||
return run_arg->__ready;
|
||||
}
|
||||
|
||||
|
||||
void run_arg_set_ready( run_arg_type * run_arg , bool ready) {
|
||||
run_arg->__ready = ready;
|
||||
}
|
||||
|
||||
|
||||
int run_arg_get_step2( const run_arg_type * run_arg ) {
|
||||
return run_arg->step2;
|
||||
}
|
||||
|
||||
bool run_arg_can_retry( const run_arg_type * run_arg ) {
|
||||
if (run_arg->num_internal_submit < run_arg->max_internal_submit)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int run_arg_get_step1( const run_arg_type * run_arg ) {
|
||||
return run_arg->step1;
|
||||
}
|
||||
|
||||
|
||||
run_mode_type run_arg_get_run_mode( const run_arg_type * run_arg ) {
|
||||
return run_arg->run_mode;
|
||||
}
|
||||
|
||||
state_enum run_arg_get_dynamic_init_state( const run_arg_type * run_arg ) {
|
||||
return run_arg->init_state_dynamic;
|
||||
}
|
||||
|
||||
|
||||
state_enum run_arg_get_parameter_init_state( const run_arg_type * run_arg ) {
|
||||
return run_arg->init_state_parameter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int run_arg_get_parameter_init_step( const run_arg_type * run_arg ) {
|
||||
return run_arg->init_step_parameters;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void run_arg_set_inactive( run_arg_type * run_arg ) {
|
||||
run_arg->active = false;
|
||||
}
|
||||
|
||||
|
||||
int run_arg_get_queue_index( const run_arg_type * run_arg ) {
|
||||
return run_arg->queue_index;
|
||||
}
|
||||
|
||||
|
||||
run_status_type run_arg_get_run_status( const run_arg_type * run_arg) {
|
||||
return run_arg->run_status;
|
||||
}
|
||||
|
||||
|
||||
void run_arg_set_run_status( run_arg_type * run_arg , run_status_type run_status) {
|
||||
run_arg->run_status = run_status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
enkf_fs_type * run_arg_get_init_fs(const run_arg_type * run_arg) {
|
||||
if (run_arg->init_fs)
|
||||
return run_arg->init_fs;
|
||||
else {
|
||||
util_abort("%s: internal error - tried to access run_arg->init_fs when init_fs == NULL\n",__func__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enkf_fs_type * run_arg_get_result_fs(const run_arg_type * run_arg) {
|
||||
if (run_arg->result_fs)
|
||||
return run_arg->result_fs;
|
||||
else {
|
||||
util_abort("%s: internal error - tried to access run_arg->result_fs when result_fs == NULL\n",__func__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enkf_fs_type * run_arg_get_update_target_fs(const run_arg_type * run_arg) {
|
||||
if (run_arg->update_target_fs)
|
||||
return run_arg->update_target_fs;
|
||||
else {
|
||||
util_abort("%s: internal error - tried to access run_arg->update_target_fs when update_target_fs == NULL\n",__func__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
19
ThirdParty/Ert/devel/libenkf/src/runpath_list.c
vendored
19
ThirdParty/Ert/devel/libenkf/src/runpath_list.c
vendored
@@ -34,6 +34,7 @@ struct runpath_list_struct {
|
||||
pthread_rwlock_t lock;
|
||||
vector_type * list;
|
||||
char * line_fmt; // Format string : Values are in the order: (iens , runpath , basename)
|
||||
char * export_file;
|
||||
};
|
||||
|
||||
|
||||
@@ -103,10 +104,11 @@ static void runpath_node_fprintf( const runpath_node_type * node , const char *
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
runpath_list_type * runpath_list_alloc() {
|
||||
runpath_list_type * runpath_list_alloc(const char * export_file) {
|
||||
runpath_list_type * list = util_malloc( sizeof * list );
|
||||
list->list = vector_alloc_new();
|
||||
list->line_fmt = NULL;
|
||||
list->export_file = util_alloc_string_copy( export_file );
|
||||
pthread_rwlock_init( &list->lock , NULL );
|
||||
return list;
|
||||
}
|
||||
@@ -115,6 +117,7 @@ runpath_list_type * runpath_list_alloc() {
|
||||
void runpath_list_free( runpath_list_type * list ) {
|
||||
vector_free( list->list );
|
||||
util_safe_free( list->line_fmt );
|
||||
util_safe_free( list->export_file);
|
||||
free( list );
|
||||
}
|
||||
|
||||
@@ -196,15 +199,27 @@ int runpath_list_iget_iter( runpath_list_type * list , int index) {
|
||||
return node->iter;
|
||||
}
|
||||
|
||||
void runpath_list_fprintf(runpath_list_type * list , FILE * stream) {
|
||||
void runpath_list_fprintf(runpath_list_type * list ) {
|
||||
pthread_rwlock_rdlock( &list->lock );
|
||||
{
|
||||
FILE * stream = util_fopen( list->export_file , "w");
|
||||
const char * line_fmt = runpath_list_get_line_fmt( list );
|
||||
int index;
|
||||
for (index =0; index < vector_get_size( list->list ); index++) {
|
||||
const runpath_node_type * node = runpath_list_iget_node__( list , index );
|
||||
runpath_node_fprintf( node , line_fmt , stream );
|
||||
}
|
||||
fclose( stream );
|
||||
}
|
||||
pthread_rwlock_unlock( &list->lock );
|
||||
}
|
||||
|
||||
|
||||
const char * runpath_list_get_export_file( const runpath_list_type * list ) {
|
||||
return list->export_file;
|
||||
}
|
||||
|
||||
|
||||
void runpath_list_set_export_file( runpath_list_type * list , const char * export_file ) {
|
||||
list->export_file = util_realloc_string_copy( list->export_file , export_file );
|
||||
}
|
||||
|
||||
2
ThirdParty/Ert/devel/libenkf/src/time_map.c
vendored
2
ThirdParty/Ert/devel/libenkf/src/time_map.c
vendored
@@ -592,7 +592,7 @@ int_vector_type * time_map_alloc_index_map( time_map_type * map , const ecl_sum_
|
||||
time_t sum_time;
|
||||
|
||||
while (true) {
|
||||
sum_time = ecl_sum_iget_sim_time( ecl_sum , sum_index );
|
||||
sum_time = ecl_sum_get_report_time( ecl_sum , sum_index );
|
||||
|
||||
if (sum_time > map_time) {
|
||||
int day,month,year;
|
||||
|
||||
12
ThirdParty/Ert/devel/libenkf/src/trans_func.c
vendored
12
ThirdParty/Ert/devel/libenkf/src/trans_func.c
vendored
@@ -78,6 +78,12 @@ static double trans_const(double x , const arg_pack_type * arg) {
|
||||
}
|
||||
|
||||
|
||||
static double trans_raw(double x , const arg_pack_type * arg) {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Observe that the argument of the shift should be "+" */
|
||||
static double trans_derrf(double x , const arg_pack_type * arg) {
|
||||
int steps = arg_pack_iget_int(arg , 0);
|
||||
@@ -364,8 +370,10 @@ trans_func_type * trans_func_alloc( const char * func_name ) {
|
||||
trans_func->func = trans_const;
|
||||
}
|
||||
|
||||
if (util_string_equal( func_name , "NONE"))
|
||||
trans_func->func = trans_const;
|
||||
|
||||
if (util_string_equal( func_name , "RAW")) {
|
||||
trans_func->func = trans_raw;
|
||||
}
|
||||
|
||||
|
||||
if (trans_func->func == NULL)
|
||||
|
||||
@@ -14,7 +14,17 @@ add_test( enkf_plot_data ${EXECUTABLE_OUTPUT_PATH}/enkf_plot_data)
|
||||
|
||||
add_executable( enkf_gen_data_config enkf_gen_data_config.c )
|
||||
target_link_libraries( enkf_gen_data_config enkf test_util )
|
||||
add_test( enkf_gen_data_config ${EXECUTABLE_OUTPUT_PATH}/enkf_gen_data_config)
|
||||
add_test( enkf_gen_data_config ${EXECUTABLE_OUTPUT_PATH}/enkf_gen_data_config
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/config/gendata_test/RFT_E-3H_21
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/config/gendata_test/RFT_E-3H_21_empty)
|
||||
|
||||
add_executable( enkf_ert_run_context enkf_ert_run_context.c )
|
||||
target_link_libraries( enkf_ert_run_context enkf test_util )
|
||||
add_test( enkf_ert_run_context ${EXECUTABLE_OUTPUT_PATH}/enkf_ert_run_context)
|
||||
|
||||
add_executable( enkf_run_arg enkf_run_arg.c )
|
||||
target_link_libraries( enkf_run_arg enkf test_util )
|
||||
add_test( enkf_run_arg ${EXECUTABLE_OUTPUT_PATH}/enkf_run_arg)
|
||||
|
||||
add_executable( enkf_gen_obs_load enkf_gen_obs_load.c )
|
||||
target_link_libraries( enkf_gen_obs_load enkf test_util )
|
||||
@@ -370,14 +380,6 @@ target_link_libraries( enkf_iter_config enkf test_util )
|
||||
add_test( enkf_iter_config ${EXECUTABLE_OUTPUT_PATH}/enkf_iter_config )
|
||||
|
||||
|
||||
add_executable( enkf_state_runpath_test enkf_state_runpath_test.c )
|
||||
target_link_libraries( enkf_state_runpath_test enkf test_util )
|
||||
add_test( enkf_state_runpath_test ${EXECUTABLE_OUTPUT_PATH}/enkf_state_runpath_test
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/config/enkf_state_runpath
|
||||
config_runpath_single_run
|
||||
config_runpath_multiple_iterations )
|
||||
|
||||
|
||||
add_executable( enkf_model_config enkf_model_config.c )
|
||||
target_link_libraries( enkf_model_config enkf test_util )
|
||||
add_test( enkf_model_config ${EXECUTABLE_OUTPUT_PATH}/enkf_model_config )
|
||||
@@ -446,7 +448,6 @@ set_property( TEST enkf_export_field_test PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_workflow_job_test PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_select_case_job PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_main_fs_current_file_test PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_state_runpath_test PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_state_manual_load_test PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_analysis_update_job PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_analysis_enkf_update_job PROPERTY LABELS StatoilData )
|
||||
@@ -457,3 +458,4 @@ set_property( TEST enkf_fs_invalidate_cache PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_obs_fs PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_obs_vector_fs PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_magic_string_in_workflows PROPERTY LABELS StatoilData )
|
||||
set_property( TEST enkf_gen_data_config PROPERTY LABELS StatoilData )
|
||||
|
||||
104
ThirdParty/Ert/devel/libenkf/tests/enkf_ert_run_context.c
vendored
Normal file
104
ThirdParty/Ert/devel/libenkf/tests/enkf_ert_run_context.c
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
Copyright (C) 2014 Statoil ASA, Norway.
|
||||
|
||||
The file 'ert_run_context.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/path_fmt.h>
|
||||
#include <ert/util/subst_list.h>
|
||||
|
||||
#include <ert/enkf/ert_run_context.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
void test_create() {
|
||||
bool_vector_type * iactive = bool_vector_alloc(10,true);
|
||||
bool_vector_iset( iactive , 6 , false );
|
||||
bool_vector_iset( iactive , 8 , false );
|
||||
{
|
||||
enkf_fs_type * init_fs = NULL;
|
||||
enkf_fs_type * result_fs = NULL;
|
||||
enkf_fs_type * update_target_fs = NULL;
|
||||
subst_list_type * subst_list = subst_list_alloc( NULL );
|
||||
path_fmt_type * runpath_fmt = path_fmt_alloc_directory_fmt("/tmp/path/%04d");
|
||||
ert_run_context_type * context = ert_run_context_alloc_INIT_ONLY( init_fs , iactive , runpath_fmt , subst_list , INIT_CONDITIONAL , 13 );
|
||||
|
||||
test_assert_true( ert_run_context_is_instance( context ));
|
||||
test_assert_int_equal( 8 , ert_run_context_get_size( context ));
|
||||
|
||||
{
|
||||
run_arg_type * run_arg0 = ert_run_context_iget_arg( context , 0 );
|
||||
|
||||
test_assert_int_equal( 13 , run_arg_get_iter( run_arg0 ));
|
||||
test_assert_string_equal( "/tmp/path/0000" , run_arg_get_runpath( run_arg0 ));
|
||||
|
||||
test_assert_true( run_arg_is_instance( run_arg0 ));
|
||||
}
|
||||
ert_run_context_free( context );
|
||||
path_fmt_free( runpath_fmt );
|
||||
}
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
|
||||
void test_create_ENSEMBLE_EXPERIMENT() {
|
||||
bool_vector_type * iactive = bool_vector_alloc(10,true);
|
||||
bool_vector_iset( iactive , 0 , false );
|
||||
bool_vector_iset( iactive , 8 , false );
|
||||
{
|
||||
subst_list_type * subst_list = subst_list_alloc( NULL );
|
||||
path_fmt_type * runpath_fmt = path_fmt_alloc_directory_fmt("/tmp/path/%04d/%d");
|
||||
enkf_fs_type * fs = NULL;
|
||||
ert_run_context_type * context = ert_run_context_alloc_ENSEMBLE_EXPERIMENT( fs, iactive , runpath_fmt , subst_list , INIT_CONDITIONAL , 7 );
|
||||
|
||||
test_assert_true( ert_run_context_is_instance( context ));
|
||||
test_assert_int_equal( 8 , ert_run_context_get_size( context ));
|
||||
|
||||
{
|
||||
run_arg_type * run_arg0 = ert_run_context_iens_get_arg( context , 0 );
|
||||
run_arg_type * run_arg2 = ert_run_context_iens_get_arg( context , 2 );
|
||||
run_arg_type * run_argi = ert_run_context_iget_arg( context , 1 );
|
||||
|
||||
test_assert_NULL( run_arg0 );
|
||||
test_assert_true( run_arg_is_instance( run_argi ));
|
||||
test_assert_ptr_equal( run_arg2 , run_argi);
|
||||
}
|
||||
|
||||
{
|
||||
run_arg_type * run_arg1 = ert_run_context_iget_arg( context , 1 );
|
||||
|
||||
test_assert_int_equal( 7 , run_arg_get_iter( run_arg1 ));
|
||||
test_assert_string_equal( "/tmp/path/0002/7" , run_arg_get_runpath( run_arg1 ));
|
||||
|
||||
test_assert_true( run_arg_is_instance( run_arg1 ));
|
||||
}
|
||||
ert_run_context_free( context );
|
||||
path_fmt_free( runpath_fmt );
|
||||
}
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
test_create();
|
||||
test_create_ENSEMBLE_EXPERIMENT();
|
||||
exit(0);
|
||||
}
|
||||
@@ -24,12 +24,17 @@
|
||||
#include <ert/enkf/ert_test_context.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
|
||||
#include <ert/rms/rms_util.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/field.h>
|
||||
#include <ert/enkf/enkf_config_node.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/rms/rms_util.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
|
||||
|
||||
|
||||
void check_exported_data(const char * exported_file,
|
||||
@@ -118,11 +123,8 @@ void forward_initialize_node(enkf_main_type * enkf_main, const char * init_file,
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iactive = bool_vector_alloc(0, false);
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
state_enum init_state = ANALYZED;
|
||||
int start_report = 0;
|
||||
int init_step_parameters = 0;
|
||||
|
||||
enkf_main_run_exp(enkf_main , iactive , false , init_step_parameters , start_report , init_state);
|
||||
enkf_main_run_exp(enkf_main , iactive , false);
|
||||
bool_vector_free(iactive);
|
||||
}
|
||||
|
||||
@@ -131,8 +133,9 @@ void forward_initialize_node(enkf_main_type * enkf_main, const char * init_file,
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , iens );
|
||||
enkf_fs_type * fs = enkf_main_get_fs(enkf_main);
|
||||
int error = 0;
|
||||
run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT( fs , 0 ,0 , "simulations/run0");
|
||||
|
||||
enkf_state_forward_init( state , fs , &error );
|
||||
enkf_state_forward_init( state , run_arg , &error );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,8 @@ void create_runpath(enkf_main_type * enkf_main ) {
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iactive = bool_vector_alloc(0,false);
|
||||
|
||||
state_enum init_state = ANALYZED;
|
||||
int start_report = 0;
|
||||
int init_step_parameters = 0;
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
enkf_main_run_exp(enkf_main , iactive , false , init_step_parameters , start_report , init_state);
|
||||
enkf_main_run_exp(enkf_main , iactive , false );
|
||||
bool_vector_free(iactive);
|
||||
}
|
||||
|
||||
@@ -88,6 +85,7 @@ int main(int argc , char ** argv) {
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
enkf_node_type * field_node = enkf_state_get_node( state , "PORO" );
|
||||
run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT( fs , 0 ,0 , "simulations/run0");
|
||||
node_id_type node_id = {.report_step = 0 ,
|
||||
.iens = 0,
|
||||
.state = ANALYZED };
|
||||
@@ -99,20 +97,13 @@ int main(int argc , char ** argv) {
|
||||
int error = 0;
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size(enkf_main) , true);
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
|
||||
test_assert_false( enkf_node_has_data( field_node , fs, node_id ));
|
||||
|
||||
util_unlink_existing( "simulations/run0/petro.grdecl" );
|
||||
|
||||
test_assert_false(enkf_node_forward_init(field_node, "simulations/run0", 0));
|
||||
enkf_state_forward_init(state, fs, &error);
|
||||
enkf_state_forward_init(state, run_arg , &error);
|
||||
test_assert_true(LOAD_FAILURE & error);
|
||||
|
||||
error = 0;
|
||||
@@ -121,7 +112,7 @@ int main(int argc , char ** argv) {
|
||||
state_map_type * state_map = enkf_fs_get_state_map(fs);
|
||||
state_map_iset(state_map, 0, STATE_INITIALIZED);
|
||||
}
|
||||
enkf_state_load_from_forward_model(state, fs, &error, false, msg_list);
|
||||
enkf_state_load_from_forward_model(state, run_arg , &error, false, msg_list);
|
||||
stringlist_free(msg_list);
|
||||
test_assert_true(LOAD_FAILURE & error);
|
||||
}
|
||||
@@ -132,18 +123,10 @@ int main(int argc , char ** argv) {
|
||||
int error = 0;
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size( enkf_main ) , true);
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
|
||||
test_assert_true( enkf_node_forward_init( field_node , "simulations/run0" , 0));
|
||||
enkf_state_forward_init( state , fs , &error );
|
||||
enkf_state_forward_init( state , run_arg , &error );
|
||||
test_assert_int_equal( error, 0 );
|
||||
enkf_state_load_from_forward_model( state , fs , &error , false , msg_list );
|
||||
enkf_state_load_from_forward_model( state , run_arg , &error , false , msg_list );
|
||||
|
||||
stringlist_free( msg_list );
|
||||
test_assert_int_equal(error, 0);
|
||||
@@ -165,6 +148,7 @@ int main(int argc , char ** argv) {
|
||||
test_assert_double_equal( 0.130251303315 , value);
|
||||
}
|
||||
util_clear_directory( "simulations" , true , true );
|
||||
run_arg_free( run_arg );
|
||||
}
|
||||
enkf_main_free( enkf_main );
|
||||
}
|
||||
|
||||
@@ -27,17 +27,15 @@
|
||||
#include <ert/util/arg_pack.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
|
||||
void create_runpath(enkf_main_type * enkf_main ) {
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iactive = bool_vector_alloc(0,false);
|
||||
|
||||
state_enum init_state = ANALYZED;
|
||||
int start_report = 0;
|
||||
int init_step_parameters = 0;
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
enkf_main_run_exp(enkf_main , iactive , false , init_step_parameters , start_report , init_state);
|
||||
enkf_main_run_exp(enkf_main , iactive , false );
|
||||
bool_vector_free(iactive);
|
||||
}
|
||||
|
||||
@@ -85,6 +83,7 @@ int main(int argc , char ** argv) {
|
||||
if (forward_init) {
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT( fs , 0 , 0 , "simulations/run0");
|
||||
enkf_node_type * gen_kw_node = enkf_state_get_node( state , "MULTFLT" );
|
||||
node_id_type node_id = {.report_step = 0 ,
|
||||
.iens = 0,
|
||||
@@ -98,18 +97,12 @@ int main(int argc , char ** argv) {
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size( enkf_main ) , true);
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
}
|
||||
|
||||
|
||||
test_assert_false( enkf_node_has_data( gen_kw_node , fs, node_id ));
|
||||
util_unlink_existing( "simulations/run0/MULTFLT_INIT" );
|
||||
|
||||
|
||||
test_assert_false( enkf_node_forward_init( gen_kw_node , "simulations/run0" , 0 ));
|
||||
enkf_state_forward_init( state , fs , &error );
|
||||
enkf_state_forward_init( state , run_arg , &error );
|
||||
test_assert_true(LOAD_FAILURE & error);
|
||||
|
||||
error = 0;
|
||||
@@ -118,7 +111,7 @@ int main(int argc , char ** argv) {
|
||||
state_map_type * state_map = enkf_fs_get_state_map(fs);
|
||||
state_map_iset(state_map , 0 , STATE_INITIALIZED);
|
||||
}
|
||||
enkf_state_load_from_forward_model( state , fs , &error , false , msg_list );
|
||||
enkf_state_load_from_forward_model( state , run_arg , &error , false , msg_list );
|
||||
stringlist_free( msg_list );
|
||||
bool_vector_free( iactive );
|
||||
test_assert_true(LOAD_FAILURE & error);
|
||||
@@ -136,18 +129,10 @@ int main(int argc , char ** argv) {
|
||||
int error = 0;
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size( enkf_main ) , true);
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE ); /* This is ugly */
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
|
||||
test_assert_true( enkf_node_forward_init( gen_kw_node , "simulations/run0" , 0 ));
|
||||
enkf_state_forward_init( state , fs , &error );
|
||||
enkf_state_forward_init( state , run_arg , &error );
|
||||
test_assert_int_equal(0, error);
|
||||
enkf_state_load_from_forward_model( state , fs , &error , false , msg_list );
|
||||
enkf_state_load_from_forward_model( state , run_arg , &error , false , msg_list );
|
||||
|
||||
stringlist_free( msg_list );
|
||||
test_assert_int_equal(0, error);
|
||||
@@ -173,6 +158,7 @@ int main(int argc , char ** argv) {
|
||||
test_assert_double_equal( 123456.0 , value);
|
||||
}
|
||||
util_clear_directory( "simulations" , true , true );
|
||||
run_arg_free( run_arg );
|
||||
}
|
||||
enkf_main_free( enkf_main );
|
||||
}
|
||||
|
||||
@@ -27,17 +27,15 @@
|
||||
#include <ert/util/arg_pack.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
|
||||
void create_runpath(enkf_main_type * enkf_main ) {
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iactive = bool_vector_alloc(0,false);
|
||||
|
||||
state_enum init_state = ANALYZED;
|
||||
int start_report = 0;
|
||||
int init_step_parameters = 0;
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
enkf_main_run_exp(enkf_main , iactive , false , init_step_parameters , start_report , init_state);
|
||||
enkf_main_run_exp(enkf_main , iactive , false );
|
||||
bool_vector_free(iactive);
|
||||
}
|
||||
|
||||
@@ -85,6 +83,7 @@ int main(int argc , char ** argv) {
|
||||
if (forward_init) {
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT( fs , 0 , 0 , "simulations/run0");
|
||||
enkf_node_type * gen_param_node = enkf_state_get_node( state , "PARAM" );
|
||||
node_id_type node_id = {.report_step = 0 ,
|
||||
.iens = 0,
|
||||
@@ -93,16 +92,8 @@ int main(int argc , char ** argv) {
|
||||
create_runpath( enkf_main );
|
||||
test_assert_true( util_is_directory( "simulations/run0" ));
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size( enkf_main ) , true);
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
test_assert_false( enkf_node_has_data( gen_param_node , fs, node_id ));
|
||||
util_unlink_existing( "simulations/run0/PARAM_INIT" );
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
|
||||
test_assert_false( enkf_node_has_data( gen_param_node , fs, node_id ));
|
||||
util_unlink_existing( "simulations/run0/PARAM_INIT" );
|
||||
|
||||
{
|
||||
FILE * stream = util_fopen("simulations/run0/PARAM_INIT" , "w");
|
||||
@@ -114,23 +105,16 @@ int main(int argc , char ** argv) {
|
||||
int error = 0;
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size(enkf_main) , true);
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE ); /* This is ugly */
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
test_assert_true( enkf_node_forward_init( gen_param_node , "simulations/run0" , 0 ));
|
||||
|
||||
enkf_state_forward_init( state , fs , &error );
|
||||
enkf_state_forward_init( state , run_arg , &error );
|
||||
test_assert_int_equal(0, error);
|
||||
{
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
state_map_type * state_map = enkf_fs_get_state_map(fs);
|
||||
state_map_iset(state_map , 0 , STATE_INITIALIZED);
|
||||
}
|
||||
enkf_state_load_from_forward_model( state , fs , &error , false , msg_list );
|
||||
enkf_state_load_from_forward_model( state , run_arg , &error , false , msg_list );
|
||||
|
||||
stringlist_free( msg_list );
|
||||
test_assert_int_equal(0, error);
|
||||
@@ -162,6 +146,7 @@ int main(int argc , char ** argv) {
|
||||
test_assert_double_equal( 3 , v3);
|
||||
}
|
||||
util_clear_directory( "simulations" , true , true );
|
||||
run_arg_free( run_arg );
|
||||
}
|
||||
enkf_main_free( enkf_main );
|
||||
}
|
||||
|
||||
@@ -27,17 +27,14 @@
|
||||
#include <ert/util/arg_pack.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
void create_runpath(enkf_main_type * enkf_main ) {
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iactive = bool_vector_alloc(0,false);
|
||||
|
||||
state_enum init_state = ANALYZED;
|
||||
int start_report = 0;
|
||||
int init_step_parameters = 0;
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
enkf_main_run_exp(enkf_main , iactive , false , init_step_parameters , start_report , init_state);
|
||||
enkf_main_run_exp(enkf_main , iactive , false );
|
||||
bool_vector_free(iactive);
|
||||
}
|
||||
|
||||
@@ -89,6 +86,7 @@ int main(int argc , char ** argv) {
|
||||
if (forward_init) {
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT( fs , 0 ,0 , "simulations/run0");
|
||||
enkf_node_type * surface_node = enkf_state_get_node( state , "SURFACE" );
|
||||
node_id_type node_id = {.report_step = 0 ,
|
||||
.iens = 0,
|
||||
@@ -101,20 +99,13 @@ int main(int argc , char ** argv) {
|
||||
int error = 0;
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size(enkf_main) , true);
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
|
||||
|
||||
test_assert_false( enkf_node_has_data( surface_node , fs, node_id ));
|
||||
|
||||
util_unlink_existing( "simulations/run0/Surface.irap" );
|
||||
|
||||
test_assert_false( enkf_node_forward_init( surface_node , "simulations/run0" , 0 ));
|
||||
enkf_state_forward_init( state , fs , &error );
|
||||
enkf_state_forward_init( state , run_arg , &error );
|
||||
test_assert_true(LOAD_FAILURE & error);
|
||||
|
||||
error = 0;
|
||||
@@ -123,7 +114,7 @@ int main(int argc , char ** argv) {
|
||||
state_map_type * state_map = enkf_fs_get_state_map(fs);
|
||||
state_map_iset(state_map, 0, STATE_INITIALIZED);
|
||||
}
|
||||
enkf_state_load_from_forward_model(state, fs, &error, false, msg_list);
|
||||
enkf_state_load_from_forward_model(state, run_arg , &error, false, msg_list);
|
||||
|
||||
stringlist_free( msg_list );
|
||||
test_assert_true(LOAD_FAILURE & error);
|
||||
@@ -135,17 +126,11 @@ int main(int argc , char ** argv) {
|
||||
int error = 0;
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size( enkf_main ) , true);
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE ); /* This is ugly */
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
test_assert_true( enkf_node_forward_init( surface_node , "simulations/run0" , 0 ));
|
||||
enkf_state_forward_init( state , fs , &error );
|
||||
enkf_state_forward_init( state , run_arg , &error );
|
||||
test_assert_int_equal(0, error);
|
||||
enkf_state_load_from_forward_model( state , fs , &error , false , msg_list );
|
||||
enkf_state_load_from_forward_model( state , run_arg , &error , false , msg_list );
|
||||
stringlist_free( msg_list );
|
||||
test_assert_int_equal(0, error);
|
||||
|
||||
|
||||
@@ -24,20 +24,23 @@
|
||||
#include <ert/util/test_work_area.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/enkf_config_node.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
#include <ert/enkf/enkf_config_node.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void create_runpath(enkf_main_type * enkf_main ) {
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iactive = bool_vector_alloc(0,false);
|
||||
|
||||
state_enum init_state = ANALYZED;
|
||||
int start_report = 0;
|
||||
int init_step_parameters = 0;
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
enkf_main_run_exp(enkf_main , iactive , false , init_step_parameters , start_report , init_state);
|
||||
enkf_main_run_exp(enkf_main , iactive , false );
|
||||
bool_vector_free(iactive);
|
||||
}
|
||||
|
||||
@@ -75,7 +78,9 @@ int main(int argc , char ** argv) {
|
||||
|
||||
bool strict = true;
|
||||
enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true );
|
||||
enkf_fs_type * init_fs = enkf_main_get_fs(enkf_main);
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT( init_fs , 0 ,0 , "simulations/run0");
|
||||
enkf_node_type * field_node = enkf_state_get_node( state , "PORO" );
|
||||
|
||||
bool forward_init;
|
||||
@@ -92,13 +97,10 @@ int main(int argc , char ** argv) {
|
||||
util_copy_file( init_file , "simulations/run0/petro.grdecl");
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size(enkf_main) , true);
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
int error = 0;
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
enkf_state_load_from_forward_model( state , fs , &error , false , msg_list );
|
||||
enkf_state_load_from_forward_model( state , run_arg , &error , false , msg_list );
|
||||
stringlist_free( msg_list );
|
||||
bool_vector_free( iactive );
|
||||
test_assert_int_equal(error, 0);
|
||||
@@ -106,6 +108,7 @@ int main(int argc , char ** argv) {
|
||||
|
||||
test_assert_true(check_original_exported_data_equal(field_node));
|
||||
|
||||
run_arg_free( run_arg );
|
||||
enkf_main_free(enkf_main);
|
||||
test_work_area_free(work_area);
|
||||
}
|
||||
|
||||
12
ThirdParty/Ert/devel/libenkf/tests/enkf_fs.c
vendored
12
ThirdParty/Ert/devel/libenkf/tests/enkf_fs.c
vendored
@@ -37,7 +37,7 @@ void test_mount() {
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf_fs/mount");
|
||||
|
||||
test_assert_false( enkf_fs_exists( "mnt" ));
|
||||
enkf_fs_create_fs("mnt" , BLOCK_FS_DRIVER_ID , NULL );
|
||||
test_assert_NULL( enkf_fs_create_fs("mnt" , BLOCK_FS_DRIVER_ID , NULL , false));
|
||||
test_assert_true( enkf_fs_exists( "mnt" ));
|
||||
{
|
||||
enkf_fs_type * fs = enkf_fs_mount( "mnt" );
|
||||
@@ -46,7 +46,13 @@ void test_mount() {
|
||||
enkf_fs_decref( fs );
|
||||
test_assert_false( util_file_exists("mnt/mnt.lock"));
|
||||
}
|
||||
{
|
||||
enkf_fs_type * fs = enkf_fs_create_fs( "mnt2" , BLOCK_FS_DRIVER_ID , NULL , true);
|
||||
test_assert_true( enkf_fs_is_instance( fs ));
|
||||
enkf_fs_decref( fs );
|
||||
}
|
||||
|
||||
|
||||
test_work_area_free( work_area );
|
||||
}
|
||||
|
||||
@@ -54,7 +60,7 @@ void test_mount() {
|
||||
void test_refcount() {
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf_fs/refcount");
|
||||
|
||||
enkf_fs_create_fs("mnt" , BLOCK_FS_DRIVER_ID , NULL );
|
||||
enkf_fs_create_fs("mnt" , BLOCK_FS_DRIVER_ID , NULL , false);
|
||||
{
|
||||
enkf_fs_type * fs = enkf_fs_mount( "mnt" );
|
||||
test_assert_int_equal( 1 , enkf_fs_get_refcount( fs ));
|
||||
@@ -111,7 +117,7 @@ void test_fwrite_readonly( void * arg ) {
|
||||
*/
|
||||
void test_read_only2() {
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf_fs/read_only2");
|
||||
enkf_fs_create_fs("mnt" , BLOCK_FS_DRIVER_ID , NULL );
|
||||
enkf_fs_create_fs("mnt" , BLOCK_FS_DRIVER_ID , NULL , false);
|
||||
createFS();
|
||||
|
||||
while (true) {
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
#include <ert/util/test_work_area.h>
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/enkf/gen_data.h>
|
||||
#include <ert/enkf/gen_data_config.h>
|
||||
#include <ert/enkf/enkf_fs.h>
|
||||
|
||||
|
||||
void test_report_steps_param() {
|
||||
@@ -90,7 +92,42 @@ void test_report_steps_dynamic() {
|
||||
}
|
||||
|
||||
|
||||
void test_gendata_fload(const char * filename) {
|
||||
test_work_area_type * work_area = test_work_area_alloc( "test_gendata_fload");
|
||||
gen_data_config_type * config = gen_data_config_alloc_GEN_DATA_result("KEY" , ASCII);
|
||||
gen_data_type * gen_data = gen_data_alloc(config);
|
||||
|
||||
const char * cwd = test_work_area_get_cwd(work_area);
|
||||
enkf_fs_type * write_fs = enkf_fs_create_fs(cwd, BLOCK_FS_DRIVER_ID, NULL , true);
|
||||
gen_data_config_set_write_fs(config, write_fs);
|
||||
gen_data_fload(gen_data, filename);
|
||||
int data_size = gen_data_config_get_data_size(config, 0);
|
||||
test_assert_true(data_size > 0);
|
||||
enkf_fs_decref( write_fs );
|
||||
|
||||
gen_data_free(gen_data);
|
||||
gen_data_config_free( config );
|
||||
test_work_area_free(work_area);
|
||||
}
|
||||
|
||||
|
||||
void test_gendata_fload_empty_file(const char * filename) {
|
||||
test_work_area_type * work_area = test_work_area_alloc( "test_gendata_fload_empty_file" );
|
||||
gen_data_config_type * config = gen_data_config_alloc_GEN_DATA_result("KEY" , ASCII);
|
||||
gen_data_type * gen_data = gen_data_alloc(config);
|
||||
|
||||
const char * cwd = test_work_area_get_cwd(work_area);
|
||||
enkf_fs_type * write_fs = enkf_fs_create_fs(cwd, BLOCK_FS_DRIVER_ID, NULL , true);
|
||||
gen_data_config_set_write_fs(config, write_fs);
|
||||
gen_data_fload(gen_data, filename);
|
||||
int data_size = gen_data_config_get_data_size(config, 0);
|
||||
test_assert_true(data_size == 0);
|
||||
enkf_fs_decref( write_fs );
|
||||
|
||||
gen_data_free(gen_data);
|
||||
gen_data_config_free( config );
|
||||
test_work_area_free(work_area);
|
||||
}
|
||||
|
||||
|
||||
void test_result_format() {
|
||||
@@ -304,6 +341,9 @@ void test_set_template() {
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
|
||||
const char * gendata_file = argv[1];
|
||||
const char * gendata_file_empty = argv[2];
|
||||
|
||||
test_report_steps_param();
|
||||
test_report_steps_dynamic();
|
||||
test_result_format();
|
||||
@@ -311,6 +351,8 @@ int main(int argc , char ** argv) {
|
||||
test_set_template_invalid();
|
||||
test_set_invalid_format();
|
||||
test_format_check();
|
||||
test_gendata_fload(gendata_file);
|
||||
test_gendata_fload_empty_file(gendata_file_empty);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void test_case_initialized() {
|
||||
model_config_type * model_config = enkf_main_get_model_config(enkf_main);
|
||||
const char * new_case = "fs/case";
|
||||
char * mount_point = util_alloc_sprintf("%s/%s" , model_config_get_enspath(model_config) , new_case);
|
||||
enkf_fs_create_fs(mount_point , BLOCK_FS_DRIVER_ID , NULL);
|
||||
enkf_fs_create_fs(mount_point , BLOCK_FS_DRIVER_ID , NULL , false);
|
||||
|
||||
test_assert_false(enkf_main_case_is_initialized(enkf_main , "does/not/exist" , NULL));
|
||||
test_assert_true(enkf_main_case_is_initialized(enkf_main , new_case , NULL));
|
||||
|
||||
110
ThirdParty/Ert/devel/libenkf/tests/enkf_run_arg.c
vendored
Normal file
110
ThirdParty/Ert/devel/libenkf/tests/enkf_run_arg.c
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
Copyright (C) 2014 Statoil ASA, Norway.
|
||||
|
||||
The file 'ert_run_context.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/path_fmt.h>
|
||||
#include <ert/util/subst_list.h>
|
||||
#include <ert/util/test_work_area.h>
|
||||
|
||||
#include <ert/enkf/ert_run_context.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
#include <ert/enkf/enkf_fs.h>
|
||||
|
||||
void call_get_result_fs( void * arg ) {
|
||||
run_arg_type * run_arg = run_arg_safe_cast( arg );
|
||||
run_arg_get_result_fs( run_arg );
|
||||
}
|
||||
|
||||
|
||||
void call_get_update_target_fs( void * arg ) {
|
||||
run_arg_type * run_arg = run_arg_safe_cast( arg );
|
||||
run_arg_get_update_target_fs( run_arg );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_SMOOTHER_RUN( ) {
|
||||
test_work_area_type * test_area = test_work_area_alloc("run_arg/SMOOTHER");
|
||||
{
|
||||
enkf_fs_type * sim_fs = enkf_fs_create_fs("sim" , BLOCK_FS_DRIVER_ID , NULL , true);
|
||||
enkf_fs_type * target_fs = enkf_fs_create_fs("target" , BLOCK_FS_DRIVER_ID , NULL , true);
|
||||
|
||||
run_arg_type * run_arg = run_arg_alloc_SMOOTHER_RUN(sim_fs , target_fs , 0 , 6 , "path");
|
||||
test_assert_true( run_arg_is_instance( run_arg ));
|
||||
test_assert_ptr_equal( run_arg_get_init_fs( run_arg ) , sim_fs );
|
||||
test_assert_ptr_equal( run_arg_get_result_fs( run_arg ) , sim_fs );
|
||||
test_assert_ptr_equal( run_arg_get_update_target_fs( run_arg ) , target_fs );
|
||||
run_arg_free( run_arg );
|
||||
|
||||
enkf_fs_decref( sim_fs );
|
||||
enkf_fs_decref( target_fs );
|
||||
}
|
||||
test_work_area_free( test_area );
|
||||
}
|
||||
|
||||
|
||||
void test_INIT_ONLY( ) {
|
||||
test_work_area_type * test_area = test_work_area_alloc("run_arg/INIT");
|
||||
{
|
||||
enkf_fs_type * init_fs = enkf_fs_create_fs("sim" , BLOCK_FS_DRIVER_ID , NULL , true);
|
||||
|
||||
run_arg_type * run_arg = run_arg_alloc_INIT_ONLY(init_fs , 0 , 6 , "path");
|
||||
test_assert_true( run_arg_is_instance( run_arg ));
|
||||
test_assert_ptr_equal( run_arg_get_init_fs( run_arg ) , init_fs );
|
||||
|
||||
test_assert_util_abort( "run_arg_get_result_fs" , call_get_result_fs , run_arg );
|
||||
test_assert_util_abort( "run_arg_get_update_target_fs" , call_get_update_target_fs , run_arg );
|
||||
run_arg_free( run_arg );
|
||||
|
||||
enkf_fs_decref( init_fs );
|
||||
}
|
||||
test_work_area_free( test_area );
|
||||
}
|
||||
|
||||
|
||||
void test_ENSEMBLE_EXPERIMENT( ) {
|
||||
test_work_area_type * test_area = test_work_area_alloc("run_arg/ENS");
|
||||
{
|
||||
enkf_fs_type * fs = enkf_fs_create_fs("sim" , BLOCK_FS_DRIVER_ID , NULL , true);
|
||||
|
||||
run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT(fs , 0 , 6 , "path");
|
||||
test_assert_true( run_arg_is_instance( run_arg ));
|
||||
|
||||
test_assert_ptr_equal( run_arg_get_init_fs( run_arg ) , fs );
|
||||
test_assert_ptr_equal( run_arg_get_result_fs( run_arg ) , fs );
|
||||
test_assert_util_abort( "run_arg_get_update_target_fs" , call_get_update_target_fs , run_arg );
|
||||
|
||||
run_arg_free( run_arg );
|
||||
enkf_fs_decref( fs );
|
||||
}
|
||||
test_work_area_free( test_area );
|
||||
}
|
||||
|
||||
void test_ENKF_ASSIMILATION( ) {
|
||||
test_work_area_type * test_area = test_work_area_alloc("run_arg/ENS");
|
||||
test_work_area_free( test_area );
|
||||
}
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_SMOOTHER_RUN();
|
||||
test_INIT_ONLY();
|
||||
test_ENSEMBLE_EXPERIMENT();
|
||||
test_ENKF_ASSIMILATION();
|
||||
exit(0);
|
||||
}
|
||||
@@ -43,7 +43,7 @@ void * add_pathlist( void * arg ) {
|
||||
}
|
||||
|
||||
void test_runpath_list() {
|
||||
runpath_list_type * list = runpath_list_alloc();
|
||||
runpath_list_type * list = runpath_list_alloc("DefaultFile");
|
||||
|
||||
test_assert_int_equal( runpath_list_size( list ) , 0 );
|
||||
|
||||
@@ -102,20 +102,14 @@ void test_runpath_list() {
|
||||
|
||||
{
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf_runpath_list" );
|
||||
const char *filename = "runpath_list.txt";
|
||||
{
|
||||
FILE * stream = util_fopen( filename, "w");
|
||||
runpath_list_fprintf( list , stream );
|
||||
fclose( stream );
|
||||
}
|
||||
|
||||
runpath_list_fprintf( list );
|
||||
{
|
||||
int file_iens;
|
||||
int file_iter;
|
||||
char file_path[256];
|
||||
char file_base[256];
|
||||
int iens;
|
||||
FILE * stream = util_fopen( filename, "r");
|
||||
FILE * stream = util_fopen( runpath_list_get_export_file(list) , "r");
|
||||
for (iens = 0; iens < threads * block_size; iens++) {
|
||||
int fscanf_return = fscanf( stream , "%d %s %s %d" , &file_iens , file_path , file_base, &file_iter);
|
||||
test_assert_int_equal(fscanf_return, 4 );
|
||||
@@ -136,7 +130,7 @@ void test_config( const char * config_file ) {
|
||||
ert_test_context_type * test_context = ert_test_context_alloc( "RUNPATH_FILE" , config_file , NULL );
|
||||
enkf_main_type * enkf_main = ert_test_context_get_main( test_context );
|
||||
qc_module_type * qc_module = enkf_main_get_qc_module( enkf_main );
|
||||
|
||||
|
||||
ert_test_context_run_worklow( test_context , "ARGECHO_WF");
|
||||
{
|
||||
FILE * stream = util_fopen("runpath_list.txt" , "r");
|
||||
@@ -150,11 +144,18 @@ void test_config( const char * config_file ) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_filename() {
|
||||
runpath_list_type * list = runpath_list_alloc("DefaultFile");
|
||||
test_assert_string_equal( "DefaultFile" , runpath_list_get_export_file(list));
|
||||
runpath_list_set_export_file( list , "/tmp/file.txt");
|
||||
test_assert_string_equal( "/tmp/file.txt" , runpath_list_get_export_file(list));
|
||||
runpath_list_free( list );
|
||||
}
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_runpath_list();
|
||||
test_config( argv[1] );
|
||||
test_filename();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,60 +26,38 @@
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
|
||||
int test_load_manually_to_new_case(enkf_main_type * enkf_main) {
|
||||
const char * casename = "new_case";
|
||||
enkf_main_select_fs( enkf_main , casename );
|
||||
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
int result = 0;
|
||||
int step1 = 1;
|
||||
int step2 = 1;
|
||||
|
||||
int result = 0;
|
||||
int iens = 0;
|
||||
int iter = 0;
|
||||
const char * casename = "new_case";
|
||||
enkf_main_select_fs( enkf_main , casename );
|
||||
|
||||
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT(fs , iens , iter , "simulations/run0");
|
||||
{
|
||||
arg_pack_type * arg_pack = arg_pack_alloc();
|
||||
arg_pack_append_ptr( arg_pack , enkf_main_iget_state(enkf_main, 0)); /* 0: */
|
||||
arg_pack_append_ptr( arg_pack , fs ); /* 1: */
|
||||
arg_pack_append_int( arg_pack , step1 ); /* 2: This will be the load start parameter for the run_info struct. */
|
||||
arg_pack_append_int( arg_pack , step1 ); /* 3: Step1 */
|
||||
arg_pack_append_int( arg_pack , step2 ); /* 4: Step2 For summary data it will load the whole goddamn thing anyway.*/
|
||||
arg_pack_append_bool( arg_pack , true ); /* 5: Interactive */
|
||||
arg_pack_append_owned_ptr( arg_pack , stringlist_alloc_new() , stringlist_free__); /* 6: List of interactive mode messages. */
|
||||
arg_pack_append_bool( arg_pack, true ); /* 7: Manual load */
|
||||
arg_pack_append_int( arg_pack , 0 ); /* 8: iter */
|
||||
arg_pack_append_ptr( arg_pack, &result ); /* 9: Result */
|
||||
arg_pack_append_ptr( arg_pack , enkf_main_iget_state(enkf_main, 0));
|
||||
arg_pack_append_ptr( arg_pack , run_arg );
|
||||
arg_pack_append_bool( arg_pack , true );
|
||||
arg_pack_append_owned_ptr( arg_pack , stringlist_alloc_new() , stringlist_free__);
|
||||
arg_pack_append_bool( arg_pack, true );
|
||||
arg_pack_append_ptr( arg_pack, &result );
|
||||
|
||||
enkf_state_load_from_forward_model_mt(arg_pack);
|
||||
|
||||
arg_pack_free(arg_pack);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void initialize(enkf_main_type * enkf_main) {
|
||||
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size(enkf_main) , true);
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
|
||||
int step1 = 1;
|
||||
int step2 = 1;
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
bool active = true;
|
||||
int max_internal_sumbit = 1;
|
||||
int init_step_parameter = 1;
|
||||
state_enum init_state_parameter = FORECAST;
|
||||
state_enum init_state_dynamic = FORECAST;
|
||||
int load_start = 1;
|
||||
|
||||
enkf_state_init_run(state, run_mode, active, max_internal_sumbit, init_step_parameter, init_state_parameter, init_state_dynamic, load_start, 0, step1, step2);
|
||||
}
|
||||
|
||||
bool_vector_free( iactive );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
enkf_main_install_SIGNALS();
|
||||
const char * root_path = argv[1];
|
||||
@@ -87,17 +65,16 @@ int main(int argc , char ** argv) {
|
||||
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file);
|
||||
test_work_area_copy_directory_content( work_area , root_path );
|
||||
|
||||
bool strict = true;
|
||||
enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true );
|
||||
|
||||
initialize(enkf_main);
|
||||
|
||||
test_assert_int_equal(test_load_manually_to_new_case(enkf_main), 0);
|
||||
|
||||
enkf_main_free( enkf_main );
|
||||
{
|
||||
bool strict = true;
|
||||
enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true );
|
||||
|
||||
test_assert_int_equal( 0 , test_load_manually_to_new_case(enkf_main));
|
||||
|
||||
enkf_main_free( enkf_main );
|
||||
}
|
||||
test_work_area_free(work_area);
|
||||
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
|
||||
bool check_ecl_sum_compatible(const enkf_main_type * enkf_main)
|
||||
@@ -32,13 +33,14 @@ bool check_ecl_sum_compatible(const enkf_main_type * enkf_main)
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
|
||||
run_arg_type * run_arg = run_arg_alloc_ENSEMBLE_EXPERIMENT(fs , 0 , 0 , "simulations/run0");
|
||||
|
||||
state_map_type * state_map = enkf_fs_get_state_map(fs);
|
||||
state_map_iset(state_map, 0, STATE_INITIALIZED);
|
||||
|
||||
int error = 0;
|
||||
|
||||
enkf_state_load_from_forward_model( state , fs , &error , false , msg_list );
|
||||
enkf_state_load_from_forward_model( state , run_arg , &error , false , msg_list );
|
||||
|
||||
stringlist_free( msg_list );
|
||||
return (REPORT_STEP_INCOMPATIBLE & error) ? false : true;
|
||||
@@ -61,26 +63,8 @@ int main(int argc , char ** argv) {
|
||||
bool strict = true;
|
||||
enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true );
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size( enkf_main ) , true );
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
bool active = true;
|
||||
int max_internal_sumbit = 1;
|
||||
int init_step_parameter = 1;
|
||||
state_enum init_state_parameter = FORECAST;
|
||||
state_enum init_state_dynamic = FORECAST;
|
||||
int load_start = 1;
|
||||
int step1 = 1;
|
||||
int step2 = 1;
|
||||
|
||||
enkf_state_init_run(state, run_mode, active, max_internal_sumbit, init_step_parameter, init_state_parameter, init_state_dynamic, load_start, 0, step1, step2);
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
test_assert_bool_equal(check_compatible, check_ecl_sum_compatible(enkf_main));
|
||||
|
||||
test_assert_bool_equal(check_compatible , check_ecl_sum_compatible(enkf_main));
|
||||
|
||||
enkf_main_free( enkf_main );
|
||||
test_work_area_free(work_area);
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'enkf_state_runpath_test.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/test_work_area.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
|
||||
enkf_main_install_SIGNALS();
|
||||
const char * root_path = argv[1];
|
||||
const char * config_file_single_run = argv[2];
|
||||
const char * config_file_multiple_iter = argv[3];
|
||||
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf_state_runpath_test");
|
||||
test_work_area_copy_directory_content( work_area , root_path );
|
||||
test_work_area_set_store(work_area, true);
|
||||
|
||||
|
||||
{
|
||||
enkf_state_type * state = NULL;
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool strict = true;
|
||||
|
||||
bool active = true;
|
||||
int max_internal_sumbit = 1;
|
||||
int init_step_parameter = 1;
|
||||
state_enum init_state_parameter = FORECAST;
|
||||
state_enum init_state_dynamic = FORECAST;
|
||||
int load_start = 1;
|
||||
int step1 = 1;
|
||||
int step2 = 1;
|
||||
|
||||
const char * cwd = test_work_area_get_cwd(work_area);
|
||||
|
||||
{
|
||||
enkf_main_type * enkf_main_single_run = enkf_main_bootstrap( NULL , config_file_single_run , strict , true );
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size( enkf_main_single_run ) , true );
|
||||
enkf_main_init_run(enkf_main_single_run , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
|
||||
state = enkf_main_iget_state( enkf_main_single_run , 0 );
|
||||
enkf_state_init_run(state, run_mode, active, max_internal_sumbit, init_step_parameter, init_state_parameter, init_state_dynamic, load_start, 0, step1, step2);
|
||||
char * path_single_run0 = util_alloc_sprintf("%s/sim/run0", cwd);
|
||||
test_assert_string_equal(enkf_state_get_run_path(state), path_single_run0);
|
||||
|
||||
state = enkf_main_iget_state( enkf_main_single_run, 1);
|
||||
enkf_state_init_run(state, run_mode, active, max_internal_sumbit, init_step_parameter, init_state_parameter, init_state_dynamic, load_start, 0, step1, step2);
|
||||
char * path_single_run1 = util_alloc_sprintf("%s/sim/run1", cwd);
|
||||
test_assert_string_equal(enkf_state_get_run_path(state), path_single_run1);
|
||||
|
||||
free(path_single_run0);
|
||||
free(path_single_run1);
|
||||
bool_vector_free( iactive );
|
||||
enkf_main_free(enkf_main_single_run);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
enkf_main_type * enkf_main_iter = enkf_main_bootstrap( NULL , config_file_multiple_iter , strict , true );
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size( enkf_main_iter ) , true );
|
||||
enkf_main_init_run(enkf_main_iter , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
state = enkf_main_iget_state( enkf_main_iter , 0 );
|
||||
|
||||
enkf_state_init_run(state, run_mode, active, max_internal_sumbit, init_step_parameter, init_state_parameter, init_state_dynamic, load_start, 0, step1, step2);
|
||||
char * path_iter0_run0 = util_alloc_sprintf("%s/sim/run0/iter0", cwd);
|
||||
test_assert_string_equal(enkf_state_get_run_path(state), path_iter0_run0);
|
||||
|
||||
state = enkf_main_iget_state( enkf_main_iter , 1 );
|
||||
enkf_state_init_run(state, run_mode, active, max_internal_sumbit, init_step_parameter, init_state_parameter, init_state_dynamic, load_start, 1, step1, step2);
|
||||
char * path_iter1_run1 = util_alloc_sprintf("%s/sim/run1/iter1", cwd);
|
||||
test_assert_string_equal(enkf_state_get_run_path(state), path_iter1_run1);
|
||||
|
||||
free(path_iter0_run0);
|
||||
free(path_iter1_run1);
|
||||
bool_vector_free( iactive );
|
||||
enkf_main_free(enkf_main_iter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
test_work_area_free(work_area);
|
||||
exit(0);
|
||||
}
|
||||
@@ -25,23 +25,27 @@
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
|
||||
bool check_ecl_sum_loaded(const enkf_main_type * enkf_main)
|
||||
{
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
enkf_state_type * state2 = enkf_main_iget_state( enkf_main , 1 );
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
stringlist_type * msg_list = stringlist_alloc_new();
|
||||
enkf_state_type * state1 = enkf_main_iget_state( enkf_main , 0 );
|
||||
run_arg_type * run_arg1 = run_arg_alloc_ENSEMBLE_EXPERIMENT( fs , 0 , 0 , "simulations/run0");
|
||||
enkf_state_type * state2 = enkf_main_iget_state( enkf_main , 1 );
|
||||
run_arg_type * run_arg2 = run_arg_alloc_ENSEMBLE_EXPERIMENT( fs , 0 , 0 , "simulations/run1");
|
||||
|
||||
|
||||
state_map_type * state_map = enkf_fs_get_state_map(fs);
|
||||
state_map_iset(state_map, 0, STATE_INITIALIZED);
|
||||
|
||||
int error = 0;
|
||||
|
||||
enkf_state_load_from_forward_model( state , fs , &error , false , msg_list );
|
||||
enkf_state_load_from_forward_model( state1 , run_arg1 , &error , false , msg_list );
|
||||
state_map_iset(state_map, 1, STATE_INITIALIZED);
|
||||
enkf_state_load_from_forward_model( state2 , fs , &error , false , msg_list );
|
||||
enkf_state_load_from_forward_model( state2 , run_arg2 , &error , false , msg_list );
|
||||
|
||||
stringlist_free( msg_list );
|
||||
return (0 == error);
|
||||
@@ -60,28 +64,7 @@ int main(int argc , char ** argv) {
|
||||
bool strict = true;
|
||||
enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , strict , true );
|
||||
|
||||
{
|
||||
run_mode_type run_mode = ENSEMBLE_EXPERIMENT;
|
||||
bool_vector_type * iactive = bool_vector_alloc( enkf_main_get_ensemble_size(enkf_main) , true);
|
||||
enkf_main_init_run(enkf_main , iactive , run_mode , INIT_NONE); /* This is ugly */
|
||||
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
enkf_state_type * state2 = enkf_main_iget_state( enkf_main , 1 );
|
||||
bool active = true;
|
||||
int max_internal_sumbit = 1;
|
||||
int init_step_parameter = 1;
|
||||
state_enum init_state_parameter = FORECAST;
|
||||
state_enum init_state_dynamic = FORECAST;
|
||||
int load_start = 1;
|
||||
int step1 = 1;
|
||||
int step2 = 1;
|
||||
|
||||
enkf_state_init_run(state, run_mode, active, max_internal_sumbit, init_step_parameter, init_state_parameter, init_state_dynamic, load_start, 0, step1, step2);
|
||||
enkf_state_init_run(state2, run_mode, active, max_internal_sumbit, init_step_parameter, init_state_parameter, init_state_dynamic, load_start, 0, step1, step2);
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
test_assert_true(check_ecl_sum_loaded(enkf_main));
|
||||
test_assert_true( check_ecl_sum_loaded(enkf_main) );
|
||||
|
||||
enkf_main_free( enkf_main );
|
||||
test_work_area_free(work_area);
|
||||
|
||||
17
ThirdParty/Ert/devel/libenkf/tests/gen_kw_test.c
vendored
17
ThirdParty/Ert/devel/libenkf/tests/gen_kw_test.c
vendored
@@ -24,14 +24,15 @@
|
||||
#include <ert/enkf/ert_test_context.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/enkf_node.h>
|
||||
#include <ert/enkf/enkf_state.h>
|
||||
|
||||
#include <ert/ecl/fortio.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/ecl/ecl_endian_flip.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/enkf_node.h>
|
||||
#include <ert/enkf/enkf_state.h>
|
||||
#include <ert/enkf/run_arg.h>
|
||||
|
||||
|
||||
|
||||
void test_send_fortio_to_gen_kw_ecl_write(void * arg) {
|
||||
@@ -57,7 +58,9 @@ void test_send_fortio_to_gen_kw_ecl_write(void * arg) {
|
||||
void test_write_gen_kw_export_file(enkf_main_type * enkf_main)
|
||||
{
|
||||
test_assert_not_NULL(enkf_main);
|
||||
enkf_fs_type * init_fs = enkf_main_get_fs( enkf_main );
|
||||
enkf_state_type * state = enkf_main_iget_state( enkf_main , 0 );
|
||||
run_arg_type * run_arg = run_arg_alloc_INIT_ONLY( init_fs , 0 ,0 , "simulations/run0");
|
||||
test_assert_not_NULL(state);
|
||||
enkf_node_type * enkf_node = enkf_state_get_node( state , "MULTFLT" );
|
||||
test_assert_not_NULL(enkf_node);
|
||||
@@ -65,10 +68,10 @@ void test_write_gen_kw_export_file(enkf_main_type * enkf_main)
|
||||
test_assert_not_NULL(config_node);
|
||||
|
||||
if (GEN_KW == enkf_config_node_get_impl_type(config_node)) {
|
||||
enkf_fs_type * fs = enkf_main_get_fs(enkf_main);
|
||||
enkf_state_ecl_write(state, fs);
|
||||
test_assert_true(util_file_exists("parameters.txt"));
|
||||
enkf_state_ecl_write(state, run_arg , init_fs);
|
||||
test_assert_true(util_file_exists("simulations/run0/parameters.txt"));
|
||||
}
|
||||
run_arg_free( run_arg );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,17 +28,23 @@ extern "C" {
|
||||
typedef struct lookup_table_struct lookup_table_type;
|
||||
|
||||
|
||||
void lookup_table_set_data( lookup_table_type * lt , double_vector_type * x , double_vector_type * y , bool data_owner );
|
||||
lookup_table_type * lookup_table_alloc( double_vector_type * x , double_vector_type * y , bool data_owner);
|
||||
lookup_table_type * lookup_table_alloc_empty();
|
||||
void lookup_table_append( lookup_table_type * lt , double x , double y);
|
||||
void lookup_table_free( lookup_table_type * lt );
|
||||
double lookup_table_interp( lookup_table_type * lt , double x);
|
||||
double lookup_table_get_max_value( lookup_table_type * lookup_table );
|
||||
double lookup_table_get_min_value( lookup_table_type * lookup_table );
|
||||
double lookup_table_get_max_arg( lookup_table_type * lookup_table );
|
||||
double lookup_table_get_max_arg( lookup_table_type * lookup_table );
|
||||
int lookup_table_get_size( const lookup_table_type * lt );
|
||||
void lookup_table_set_data( lookup_table_type * lt , double_vector_type * x , double_vector_type * y , bool data_owner );
|
||||
lookup_table_type * lookup_table_alloc( double_vector_type * x , double_vector_type * y , bool data_owner);
|
||||
lookup_table_type * lookup_table_alloc_empty();
|
||||
void lookup_table_append( lookup_table_type * lt , double x , double y);
|
||||
void lookup_table_free( lookup_table_type * lt );
|
||||
double lookup_table_interp( lookup_table_type * lt , double x);
|
||||
double lookup_table_get_max_value( lookup_table_type * lookup_table );
|
||||
double lookup_table_get_min_value( lookup_table_type * lookup_table );
|
||||
double lookup_table_get_max_arg( lookup_table_type * lookup_table );
|
||||
double lookup_table_get_max_arg( lookup_table_type * lookup_table );
|
||||
int lookup_table_get_size( const lookup_table_type * lt );
|
||||
void lookup_table_set_low_limit( lookup_table_type * lt , double limit);
|
||||
bool lookup_table_has_low_limit(const lookup_table_type * lt );
|
||||
void lookup_table_set_high_limit( lookup_table_type * lt , double limit);
|
||||
bool lookup_table_has_high_limit(const lookup_table_type * lt );
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ extern "C" {
|
||||
char * subst_list_alloc_filtered_string(const subst_list_type * , const char * );
|
||||
void subst_list_filtered_fprintf(const subst_list_type * , const char * , FILE * );
|
||||
int subst_list_get_size( const subst_list_type *);
|
||||
const char * subst_list_get_value( subst_list_type * subst_list , const char * key);
|
||||
const char * subst_list_get_value( const subst_list_type * subst_list , const char * key);
|
||||
const char * subst_list_iget_value( const subst_list_type * subst_list , int index);
|
||||
const char * subst_list_iget_key( const subst_list_type * subst_list , int index);
|
||||
const char * subst_list_iget_doc_string( const subst_list_type * subst_list , int index);
|
||||
|
||||
@@ -72,7 +72,7 @@ type ## _type * type ## _safe_cast( void * __arg ) {
|
||||
if ( arg->__type_id == TYPE_ID) \
|
||||
return arg; \
|
||||
else { \
|
||||
util_abort("%s: runtime cast failed: Got ID:%d Expected: ID%d \n", __func__ , arg->__type_id , TYPE_ID); \
|
||||
util_abort("%s: runtime cast failed: Got ID:%d Expected ID:%d \n", __func__ , arg->__type_id , TYPE_ID); \
|
||||
return NULL; \
|
||||
} \
|
||||
} \
|
||||
@@ -91,7 +91,7 @@ const type ## _type * type ## _safe_cast_const( const void * __arg ) {
|
||||
if ( arg->__type_id == TYPE_ID) \
|
||||
return arg; \
|
||||
else { \
|
||||
util_abort("%s: runtime cast failed: Got ID:%d Expected: ID%d \n", __func__ , arg->__type_id , TYPE_ID); \
|
||||
util_abort("%s: runtime cast failed: Got ID:%d Expected ID:%d \n", __func__ , arg->__type_id , TYPE_ID); \
|
||||
return NULL; \
|
||||
} \
|
||||
} \
|
||||
|
||||
@@ -33,7 +33,12 @@ struct lookup_table_struct {
|
||||
double xmin,ymin;
|
||||
double xmax,ymax;
|
||||
int prev_index;
|
||||
|
||||
bool sorted;
|
||||
bool has_low_limit;
|
||||
bool has_high_limit;
|
||||
double low_limit;
|
||||
double high_limit;
|
||||
};
|
||||
|
||||
|
||||
@@ -84,6 +89,25 @@ void lookup_table_set_data( lookup_table_type * lt , double_vector_type * x , do
|
||||
}
|
||||
|
||||
|
||||
void lookup_table_set_low_limit( lookup_table_type * lt , double limit ) {
|
||||
lt->low_limit = limit;
|
||||
lt->has_low_limit = true;
|
||||
}
|
||||
|
||||
bool lookup_table_has_low_limit(const lookup_table_type * lt ) {
|
||||
return lt->has_low_limit;
|
||||
}
|
||||
|
||||
void lookup_table_set_high_limit( lookup_table_type * lt , double limit ) {
|
||||
lt->high_limit = limit;
|
||||
lt->has_high_limit = true;
|
||||
}
|
||||
|
||||
bool lookup_table_has_high_limit(const lookup_table_type * lt ) {
|
||||
return lt->has_high_limit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
lookup_table_type * lookup_table_alloc( double_vector_type * x , double_vector_type * y , bool data_owner) {
|
||||
lookup_table_type * lt = util_malloc( sizeof * lt);
|
||||
@@ -95,6 +119,8 @@ lookup_table_type * lookup_table_alloc( double_vector_type * x , double_vector_t
|
||||
}
|
||||
lookup_table_set_data( lt , x , y , false );
|
||||
lt->data_owner = data_owner;
|
||||
lt->has_low_limit = false;
|
||||
lt->has_high_limit = false;
|
||||
|
||||
return lt;
|
||||
}
|
||||
@@ -146,12 +172,22 @@ double lookup_table_interp( lookup_table_type * lt , double x) {
|
||||
return (( x - x1 ) * y2 + (x2 - x) * y1) / (x2 - x1 );
|
||||
}
|
||||
} else {
|
||||
util_abort("%s: out of bounds \n",__func__);
|
||||
return -1;
|
||||
if (x == lt->xmax)
|
||||
return double_vector_get_last( lt->y_vector );
|
||||
else {
|
||||
if (lt->has_low_limit && x < lt->xmin)
|
||||
return lt->low_limit;
|
||||
else if (lt->has_high_limit && x > lt->xmax)
|
||||
return lt->high_limit;
|
||||
else {
|
||||
util_abort("%s: out of bounds \n",__func__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
double lookup_table_get_max_value( lookup_table_type * lookup_table ) {
|
||||
|
||||
@@ -819,7 +819,7 @@ const char * subst_list_iget_value( const subst_list_type * subst_list , int ind
|
||||
}
|
||||
}
|
||||
|
||||
const char * subst_list_get_value( subst_list_type * subst_list , const char * key) {
|
||||
const char * subst_list_get_value( const subst_list_type * subst_list , const char * key) {
|
||||
const subst_list_string_type * node = hash_get( subst_list->map , key );
|
||||
return node->value;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ extern "C" {
|
||||
void job_queue_run_jobs(job_queue_type * queue, int num_total_run, bool verbose);
|
||||
void job_queue_run_jobs_threaded(job_queue_type * queue , int num_total_run, bool verbose);
|
||||
void * job_queue_run_jobs__(void * );
|
||||
void job_queue_start_manager_thread( job_queue_type * job_queue , pthread_t * queue_thread , int job_size , bool verbose);
|
||||
|
||||
job_status_type job_queue_iget_job_status(const job_queue_type * , int );
|
||||
const char * job_queue_status_name( job_status_type status );
|
||||
|
||||
|
||||
41
ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/job_queue_manager.h
vendored
Normal file
41
ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/job_queue_manager.h
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'job_queue.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef __JOB_QUEUE_MANAGER_H__
|
||||
#define __JOB_QUEUE_MANAGER_H__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/job_queue/job_queue.h>
|
||||
|
||||
typedef struct job_queue_manager_struct job_queue_manager_type;
|
||||
|
||||
job_queue_manager_type * job_queue_manager_alloc( job_queue_type * job_queue );
|
||||
void job_queue_manager_free( job_queue_manager_type * manager );
|
||||
void job_queue_manager_start_queue( job_queue_manager_type * manager , int num_total_run , bool verbose);
|
||||
void job_queue_manager_wait( job_queue_manager_type * manager);
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( job_queue_manager );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -43,8 +43,8 @@ extern "C" {
|
||||
char * workflow_job_get_executable( workflow_job_type * workflow_job);
|
||||
|
||||
void workflow_job_set_internal_script( workflow_job_type * workflow_job , const char * script_path);
|
||||
char* workflow_job_get_internal_script_path( workflow_job_type * workflow_job);
|
||||
bool workflow_job_is_internal_script( workflow_job_type * workflow_job);
|
||||
char* workflow_job_get_internal_script_path( const workflow_job_type * workflow_job);
|
||||
bool workflow_job_is_internal_script( const workflow_job_type * workflow_job);
|
||||
|
||||
void workflow_job_set_function( workflow_job_type * workflow_job , const char * function);
|
||||
char * workflow_job_get_function( workflow_job_type * workflow_job);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#configure_file (${CMAKE_CURRENT_SOURCE_DIR}/CMake/include/libjob_queue_build_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/libjob_queue_build_config.h)
|
||||
|
||||
set(source_files forward_model.c queue_driver.c job_queue.c local_driver.c rsh_driver.c torque_driver.c ext_job.c ext_joblist.c workflow_job.c workflow.c workflow_joblist.c)
|
||||
set(header_files job_queue.h queue_driver.h local_driver.h rsh_driver.h torque_driver.h ext_job.h ext_joblist.h forward_model.h workflow_job.h workflow.h workflow_joblist.h)
|
||||
set(source_files forward_model.c queue_driver.c job_queue.c local_driver.c rsh_driver.c torque_driver.c ext_job.c ext_joblist.c workflow_job.c workflow.c workflow_joblist.c job_queue_manager.c)
|
||||
set(header_files job_queue.h queue_driver.h local_driver.h rsh_driver.h torque_driver.h ext_job.h ext_joblist.h forward_model.h workflow_job.h workflow.h workflow_joblist.h job_queue_manager.h)
|
||||
set_property(SOURCE rsh_driver.c PROPERTY COMPILE_FLAGS "-Wno-error")
|
||||
|
||||
list( APPEND source_files lsf_driver.c)
|
||||
|
||||
@@ -455,17 +455,19 @@ static void job_queue_node_free_error_info( job_queue_node_type * node ) {
|
||||
|
||||
static void job_queue_node_fscanf_EXIT( job_queue_node_type * node ) {
|
||||
job_queue_node_free_error_info( node );
|
||||
if (util_file_exists( node->exit_file )) {
|
||||
char * xml_buffer = util_fread_alloc_file_content( node->exit_file, NULL);
|
||||
|
||||
node->failed_job = __alloc_tag_content( xml_buffer , "job" );
|
||||
node->error_reason = __alloc_tag_content( xml_buffer , "reason" );
|
||||
node->stderr_capture = __alloc_tag_content( xml_buffer , "stderr");
|
||||
node->stderr_file = __alloc_tag_content( xml_buffer , "stderr_file");
|
||||
|
||||
free( xml_buffer );
|
||||
} else
|
||||
node->failed_job = util_alloc_sprintf("EXIT file:%s not found - load failure?" , node->exit_file);
|
||||
if (node->exit_file) {
|
||||
if (util_file_exists( node->exit_file )) {
|
||||
char * xml_buffer = util_fread_alloc_file_content( node->exit_file, NULL);
|
||||
|
||||
node->failed_job = __alloc_tag_content( xml_buffer , "job" );
|
||||
node->error_reason = __alloc_tag_content( xml_buffer , "reason" );
|
||||
node->stderr_capture = __alloc_tag_content( xml_buffer , "stderr");
|
||||
node->stderr_file = __alloc_tag_content( xml_buffer , "stderr_file");
|
||||
|
||||
free( xml_buffer );
|
||||
} else
|
||||
node->failed_job = util_alloc_sprintf("EXIT file:%s not found - load failure?" , node->exit_file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1519,6 +1521,18 @@ void * job_queue_run_jobs__(void * __arg_pack) {
|
||||
}
|
||||
|
||||
|
||||
void job_queue_start_manager_thread( job_queue_type * job_queue , pthread_t * queue_thread , int job_size , bool verbose) {
|
||||
|
||||
arg_pack_type * queue_args = arg_pack_alloc(); /* This arg_pack will be freed() in the job_que_run_jobs__() */
|
||||
arg_pack_append_ptr(queue_args , job_queue);
|
||||
arg_pack_append_int(queue_args , job_size);
|
||||
arg_pack_append_bool(queue_args , verbose);
|
||||
job_queue_reset(job_queue);
|
||||
pthread_create( queue_thread , NULL , job_queue_run_jobs__ , queue_args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The most flexible use scenario is as follows:
|
||||
@@ -1537,17 +1551,12 @@ void * job_queue_run_jobs__(void * __arg_pack) {
|
||||
job_queue_run_jobs() function.
|
||||
*/
|
||||
|
||||
|
||||
void job_queue_run_jobs_threaded(job_queue_type * queue , int num_total_run, bool verbose) {
|
||||
arg_pack_type * arg_pack = arg_pack_alloc(); /* The arg_pack will be freed in the job_queue_run_jobs__() function. */
|
||||
arg_pack_append_ptr( arg_pack , queue );
|
||||
arg_pack_append_int( arg_pack , num_total_run );
|
||||
arg_pack_append_bool( arg_pack , verbose );
|
||||
{
|
||||
pthread_t queue_thread;
|
||||
pthread_create( &queue_thread , NULL , job_queue_run_jobs__ , arg_pack);
|
||||
pthread_detach( queue_thread ); /* Signal that the thread resources should be cleaned up when
|
||||
the thread has exited. */
|
||||
}
|
||||
pthread_t queue_thread;
|
||||
job_queue_start_manager_thread( queue , &queue_thread , num_total_run , verbose );
|
||||
pthread_detach( queue_thread ); /* Signal that the thread resources should be cleaned up when
|
||||
the thread has exited. */
|
||||
}
|
||||
|
||||
|
||||
|
||||
68
ThirdParty/Ert/devel/libjob_queue/src/job_queue_manager.c
vendored
Normal file
68
ThirdParty/Ert/devel/libjob_queue/src/job_queue_manager.c
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright (C) 2014 Statoil ASA, Norway.
|
||||
|
||||
The file 'job_queue_manager.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE /* Must define this to get access to pthread_rwlock_t */
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/job_queue/job_queue.h>
|
||||
#include <ert/job_queue/job_queue_manager.h>
|
||||
|
||||
#define JOB_QUEUE_MANAGER_TYPE_ID 81626006
|
||||
|
||||
|
||||
|
||||
struct job_queue_manager_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
pthread_t queue_thread;
|
||||
job_queue_type * job_queue;
|
||||
};
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( job_queue_manager , JOB_QUEUE_MANAGER_TYPE_ID )
|
||||
|
||||
|
||||
job_queue_manager_type * job_queue_manager_alloc( job_queue_type * job_queue ) {
|
||||
job_queue_manager_type * manager = util_malloc( sizeof * manager );
|
||||
UTIL_TYPE_ID_INIT( manager , JOB_QUEUE_MANAGER_TYPE_ID );
|
||||
manager->job_queue = job_queue;
|
||||
return manager;
|
||||
}
|
||||
|
||||
|
||||
void job_queue_manager_free( job_queue_manager_type * manager) {
|
||||
free( manager );
|
||||
}
|
||||
|
||||
|
||||
void job_queue_manager_start_queue( job_queue_manager_type * manager , int num_total_run , bool verbose) {
|
||||
job_queue_start_manager_thread( manager->job_queue , &manager->queue_thread , num_total_run , verbose );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void job_queue_manager_wait( job_queue_manager_type * manager) {
|
||||
pthread_join( manager->queue_thread , NULL );
|
||||
}
|
||||
|
||||
@@ -180,11 +180,11 @@ void workflow_job_set_internal_script( workflow_job_type * workflow_job , const
|
||||
workflow_job->internal_script_path = util_realloc_string_copy( workflow_job->internal_script_path , script_path );
|
||||
}
|
||||
|
||||
char* workflow_job_get_internal_script_path( workflow_job_type * workflow_job) {
|
||||
char* workflow_job_get_internal_script_path( const workflow_job_type * workflow_job) {
|
||||
return workflow_job->internal_script_path;
|
||||
}
|
||||
|
||||
bool workflow_job_is_internal_script( workflow_job_type * workflow_job) {
|
||||
bool workflow_job_is_internal_script( const workflow_job_type * workflow_job) {
|
||||
return workflow_job->internal && workflow_job->internal_script_path != NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,10 @@ add_executable( job_torque_test job_torque_test.c )
|
||||
target_link_libraries( job_torque_test job_queue util test_util )
|
||||
add_test( job_torque_test ${EXECUTABLE_OUTPUT_PATH}/job_torque_test )
|
||||
|
||||
add_executable( job_queue_manager job_queue_manager.c )
|
||||
target_link_libraries( job_queue_manager job_queue util test_util )
|
||||
add_test( job_queue_manager ${EXECUTABLE_OUTPUT_PATH}/job_queue_manager )
|
||||
|
||||
add_executable( job_torque_submit_test job_torque_submit_test.c )
|
||||
target_link_libraries( job_torque_submit_test job_queue util test_util )
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/qsub_emulators/ DESTINATION ${EXECUTABLE_OUTPUT_PATH})
|
||||
|
||||
@@ -27,26 +27,27 @@
|
||||
|
||||
|
||||
void test_submit(lsf_driver_type * driver , const char * server , const char * bsub_cmd , const char * bjobs_cmd , const char * bkill_cmd , const char * cmd) {
|
||||
lsf_driver_set_option(driver , LSF_SERVER , server );
|
||||
|
||||
test_assert_true( lsf_driver_set_option(driver , LSF_SERVER , server ) );
|
||||
|
||||
if (bsub_cmd != NULL)
|
||||
lsf_driver_set_option(driver , LSF_BSUB_CMD , server );
|
||||
test_assert_true( lsf_driver_set_option(driver , LSF_BSUB_CMD , server ));
|
||||
|
||||
if (bjobs_cmd != NULL)
|
||||
lsf_driver_set_option(driver , LSF_BJOBS_CMD , server );
|
||||
test_assert_true( lsf_driver_set_option(driver , LSF_BJOBS_CMD , server ) );
|
||||
|
||||
if (bkill_cmd != NULL)
|
||||
lsf_driver_set_option(driver , LSF_BKILL_CMD , server );
|
||||
|
||||
test_assert_true( lsf_driver_set_option(driver , LSF_BKILL_CMD , server ));
|
||||
|
||||
{
|
||||
char * run_path = util_alloc_cwd();
|
||||
lsf_job_type * job = lsf_driver_submit_job( driver , cmd , 1 , run_path , "NAME" , 0 , NULL );
|
||||
|
||||
if (job != NULL) {
|
||||
if (job) {
|
||||
{
|
||||
int lsf_status = lsf_driver_get_job_status_lsf( driver , job );
|
||||
if (!((lsf_status == JOB_STAT_RUN) || (lsf_status == JOB_STAT_PEND)))
|
||||
exit(1);
|
||||
if (!((lsf_status == JOB_STAT_RUN) || (lsf_status == JOB_STAT_PEND)))
|
||||
test_error_exit("Got lsf_status:%d expected: %d or %d \n",lsf_status , JOB_STAT_RUN , JOB_STAT_PEND);
|
||||
}
|
||||
|
||||
lsf_driver_kill_job( driver , job );
|
||||
@@ -56,10 +57,11 @@ void test_submit(lsf_driver_type * driver , const char * server , const char * b
|
||||
{
|
||||
int lsf_status = lsf_driver_get_job_status_lsf( driver , job );
|
||||
if (lsf_status != JOB_STAT_EXIT)
|
||||
exit(1);
|
||||
test_error_exit("Got lsf_status:%d expected: %d \n",lsf_status , JOB_STAT_EXIT );
|
||||
}
|
||||
} else
|
||||
exit(1);
|
||||
} else
|
||||
test_error_exit("lsf_driver_submit_job() returned NULL \n");
|
||||
|
||||
|
||||
free( run_path );
|
||||
}
|
||||
|
||||
48
ThirdParty/Ert/devel/libjob_queue/tests/job_queue_manager.c
vendored
Normal file
48
ThirdParty/Ert/devel/libjob_queue/tests/job_queue_manager.c
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'job_queue_test.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/job_queue/job_queue.h>
|
||||
#include <ert/job_queue/job_queue_manager.h>
|
||||
|
||||
|
||||
|
||||
|
||||
void test_create() {
|
||||
job_queue_type * job_queue = job_queue_alloc( 100 , "OK" , "ERROR");
|
||||
job_queue_manager_type * manager = job_queue_manager_alloc( job_queue );
|
||||
|
||||
test_assert_true( job_queue_manager_is_instance( manager ));
|
||||
|
||||
job_queue_manager_free( manager );
|
||||
job_queue_free( job_queue );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
test_create();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -44,19 +44,22 @@ class BaseCClass(object):
|
||||
|
||||
@classmethod
|
||||
def createPythonObject(cls, c_pointer):
|
||||
if not c_pointer == 0:
|
||||
if c_pointer is not None:
|
||||
new_obj = cls.__new__(cls)
|
||||
BaseCClass.__init__(new_obj, c_pointer=c_pointer, parent=None, is_reference=False)
|
||||
return new_obj
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def createCReference(cls, c_pointer, parent=None):
|
||||
if not c_pointer == 0:
|
||||
if c_pointer is not None:
|
||||
new_obj = cls.__new__(cls)
|
||||
BaseCClass.__init__(new_obj, c_pointer=c_pointer, parent=parent, is_reference=True)
|
||||
return new_obj
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def convertToCReference(self, parent):
|
||||
self.__is_reference = True
|
||||
|
||||
@@ -83,7 +83,7 @@ from .ecl_util import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclTypeEnum, E
|
||||
from .ecl_default import EclDefault
|
||||
from .ecl_rft_cell import EclPLTCell, EclRFTCell
|
||||
from .ecl_rft import EclRFT, EclRFTFile
|
||||
from .fortio import FortIO
|
||||
from .fortio import FortIO, openFortIO
|
||||
from .ecl_kw import EclKW
|
||||
from .ecl_file import EclFile
|
||||
from .ecl_grid import EclGrid
|
||||
|
||||
@@ -730,6 +730,9 @@ class EclKW(CClass):
|
||||
else:
|
||||
raise TypeError("Can only compare with another EclKW")
|
||||
|
||||
def __eq__(self , other):
|
||||
return self.equal( other )
|
||||
|
||||
|
||||
def equal_numeric(self , other , epsilon = 1e-6):
|
||||
"""
|
||||
|
||||
@@ -816,14 +816,6 @@ ime_index.
|
||||
return CTime( EclSum.cNamespace().get_data_start( self ) ).datetime()
|
||||
|
||||
|
||||
@property
|
||||
def start_time(self):
|
||||
"""
|
||||
A Python datetime instance with the start time.
|
||||
|
||||
See start_date() for further details.
|
||||
"""
|
||||
return CTime( EclSum.cNamespace().get_start_date( self ) ).datetime()
|
||||
|
||||
@property
|
||||
def end_time(self):
|
||||
@@ -831,7 +823,23 @@ ime_index.
|
||||
The time of the last (loaded) time step.
|
||||
"""
|
||||
return CTime(EclSum.cNamespace().get_end_date( self )).datetime()
|
||||
|
||||
|
||||
@property
|
||||
def start_time(self):
|
||||
return self.getStartTime()
|
||||
|
||||
|
||||
def getStartTime(self):
|
||||
"""
|
||||
A Python datetime instance with the start time.
|
||||
|
||||
See start_date() for further details.
|
||||
"""
|
||||
return CTime( EclSum.cNamespace().get_start_date( self ) ).datetime()
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def last_report(self):
|
||||
"""
|
||||
@@ -916,7 +924,8 @@ ime_index.
|
||||
@classmethod
|
||||
def createCReference(cls, c_pointer, parent=None):
|
||||
result = super(EclSum, cls).createCReference(c_pointer, parent)
|
||||
result._initialize()
|
||||
if not result is None:
|
||||
result._initialize()
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -107,6 +107,24 @@ class FortIO(BaseCClass):
|
||||
self.close()
|
||||
|
||||
|
||||
class FortIOContextManager(object):
|
||||
|
||||
def __init__(self , fortio):
|
||||
self.__fortio = fortio
|
||||
|
||||
def __enter__(self):
|
||||
return self.__fortio
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self.__fortio.close()
|
||||
return False
|
||||
|
||||
|
||||
def openFortIO( file_name , mode = FortIO.READ_MODE , fmt_file = False , endian_flip_header = True):
|
||||
return FortIOContextManager( FortIO( file_name , mode = mode , fmt_file = fmt_file , endian_flip_header = endian_flip_header ))
|
||||
|
||||
|
||||
|
||||
|
||||
cwrapper = CWrapper(ECL_LIB)
|
||||
cwrapper.registerObjectType("fortio", FortIO)
|
||||
|
||||
@@ -15,7 +15,6 @@ set(PYTHON_SOURCES
|
||||
ert_template.py
|
||||
ert_templates.py
|
||||
ert_workflow_list.py
|
||||
gen_data.py
|
||||
local_config.py
|
||||
local_obsdata.py
|
||||
local_obsdata_node.py
|
||||
@@ -27,6 +26,8 @@ set(PYTHON_SOURCES
|
||||
post_simulation_hook.py
|
||||
site_config.py
|
||||
state_map.py
|
||||
run_arg.py
|
||||
ert_run_context.py
|
||||
)
|
||||
|
||||
add_python_package("python.ert.enkf" ${PYTHON_INSTALL_PREFIX}/ert/enkf "${PYTHON_SOURCES}" True)
|
||||
|
||||
@@ -23,7 +23,6 @@ from .enums import *
|
||||
|
||||
from .node_id import NodeId
|
||||
|
||||
from .gen_data import GenData
|
||||
from .enkf_linalg import EnkfLinalg
|
||||
from .util import TimeMap
|
||||
from .state_map import StateMap
|
||||
@@ -57,9 +56,10 @@ from .post_simulation_hook import PostSimulationHook
|
||||
|
||||
from .enkf_simulation_runner import EnkfSimulationRunner
|
||||
from .enkf_fs_manager import EnkfFsManager
|
||||
|
||||
from .run_arg import RunArg
|
||||
from .ert_run_context import ErtRunContext
|
||||
from .enkf_main import EnKFMain
|
||||
from .ert_log import ErtLog
|
||||
|
||||
|
||||
from ert.job_queue import ErtScript as ErtScript
|
||||
from ert.job_queue import ErtScript as ErtScript
|
||||
|
||||
@@ -3,6 +3,7 @@ set(PYTHON_SOURCES
|
||||
enkf_config_node.py
|
||||
enkf_node.py
|
||||
gen_kw.py
|
||||
gen_data.py
|
||||
field.py
|
||||
field_config.py
|
||||
gen_data_config.py
|
||||
|
||||
@@ -5,8 +5,9 @@ from .summary_config import SummaryConfig
|
||||
from .field import Field
|
||||
|
||||
from .enkf_config_node import EnkfConfigNode
|
||||
from .enkf_node import EnkfNode
|
||||
from .gen_kw import GenKw
|
||||
from .gen_data import GenData
|
||||
from .enkf_node import EnkfNode
|
||||
|
||||
__all__ = ["GenDataConfig",
|
||||
"GenKwConfig",
|
||||
@@ -15,4 +16,5 @@ __all__ = ["GenDataConfig",
|
||||
"Field",
|
||||
"EnkfConfigNode",
|
||||
"EnkfNode",
|
||||
"GenKw"]
|
||||
"GenKw",
|
||||
"GenData"]
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
from ert.cwrap import BaseCClass, CWrapper
|
||||
from ert.enkf import ENKF_LIB, EnkfFs, NodeId, GenData
|
||||
from ert.enkf.data import EnkfConfigNode
|
||||
from ert.enkf import ENKF_LIB, EnkfFs, NodeId
|
||||
from ert.enkf.data import EnkfConfigNode , GenKw , GenData
|
||||
from ert.enkf.data.gen_data_config import GenDataConfig
|
||||
from ert.enkf.enums import EnkfStateType
|
||||
from ert.enkf.enums.ert_impl_type_enum import ErtImplType
|
||||
@@ -50,6 +50,14 @@ class EnkfNode(BaseCClass):
|
||||
return GenData.createCReference(self.valuePointer(), self)
|
||||
|
||||
|
||||
def asGenKw(self):
|
||||
impl_type = EnkfNode.cNamespace().get_impl_type(self)
|
||||
assert impl_type == ErtImplType.GEN_KW
|
||||
|
||||
return GenKw.createCReference(self.valuePointer(), self)
|
||||
|
||||
|
||||
|
||||
# def vector_storage(self):
|
||||
# return EnkfNode.cNamespace().vector_storage(self)
|
||||
|
||||
@@ -70,6 +78,9 @@ class EnkfNode(BaseCClass):
|
||||
|
||||
return EnkfNode.cNamespace().try_load(self, fs, node_id)
|
||||
|
||||
def save(self , fs , node_id ):
|
||||
EnkfNode.cNamespace().store(self , fs , True , node_id)
|
||||
|
||||
|
||||
def free(self):
|
||||
EnkfNode.cNamespace().free(self)
|
||||
@@ -89,6 +100,6 @@ EnkfNode.cNamespace().value_ptr = cwrapper.prototype("c_void_p enkf_node_value_p
|
||||
|
||||
EnkfNode.cNamespace().try_load = cwrapper.prototype("bool enkf_node_try_load(enkf_node, enkf_fs, node_id)")
|
||||
EnkfNode.cNamespace().get_impl_type = cwrapper.prototype("ert_impl_type_enum enkf_node_get_impl_type(enkf_node)")
|
||||
|
||||
EnkfNode.cNamespace().store = cwrapper.prototype("void enkf_node_store(enkf_node, enkf_fs , bool , node_id)")
|
||||
#todo fix this
|
||||
# EnkfNode.cNamespace().get_config = cwrapper.prototype("c_void_p enkf_node_get_config(enkf_node)")
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user