From 90a25f67bb2c702549ef2867cbee6e80b005770c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 22 Aug 2018 13:33:11 +0200 Subject: [PATCH] #3235 Update ecllib from statoil master repo. Commit 1f051833c8ed819185fd334dfc7e05511ee35d5f --- ResInsightVersion.cmake | 2 +- ThirdParty/Ert/CMakeLists.txt | 5 +- .../Ert/applications/ecl/view_summary.c | 2 +- ThirdParty/Ert/lib/CMakeLists.txt | 14 +- ThirdParty/Ert/lib/ecl/ecl_grid.cpp | 151 +++- ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp | 20 +- ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp | 42 +- ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp | 10 +- ThirdParty/Ert/lib/ecl/ecl_sum.cpp | 32 +- ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp | 8 +- ThirdParty/Ert/lib/ecl/ecl_sum_file_data.cpp | 4 +- ThirdParty/Ert/lib/ecl/ecl_unsmry_loader.cpp | 5 +- ThirdParty/Ert/lib/ecl/fault_block.cpp | 13 +- ThirdParty/Ert/lib/ecl/fortio.c | 16 +- ThirdParty/Ert/lib/ecl/layer.cpp | 17 +- .../Ert/lib/ecl/tests/ecl_grid_ext_actnum.cpp | 64 ++ .../lib/ecl/tests/ecl_grid_unit_system.cpp | 63 ++ ThirdParty/Ert/lib/ecl/tests/ecl_layer.cpp | 37 +- .../Ert/lib/ecl/tests/ecl_layer_statoil.cpp | 8 +- .../tests/ecl_sum_data_intermediate_test.cpp | 4 +- .../lib/ecl/tests/ecl_unsmry_loader_test.cpp | 2 +- .../Ert/lib/include/ert/ecl/ecl_grid.hpp | 1 + .../Ert/lib/include/ert/ecl/ecl_sum.hpp | 4 +- .../Ert/lib/include/ert/ecl/ecl_sum_data.hpp | 2 +- ThirdParty/Ert/lib/include/ert/ecl/layer.hpp | 2 - .../Ert/lib/include/ert/util/arg_pack.h | 9 - .../Ert/lib/include/ert/util/arg_pack.hpp | 98 --- .../Ert/lib/include/ert/util/struct_vector.h | 9 - .../lib/include/ert/util/struct_vector.hpp | 47 -- .../detail/ecl/ecl_sum_file_data.hpp | 2 +- .../detail/ecl/ecl_unsmry_loader.hpp | 2 +- .../private-include/detail/ecl/layer_cxx.hpp | 9 + ThirdParty/Ert/lib/util/arg_pack.cpp | 661 ------------------ ThirdParty/Ert/lib/util/struct_vector.cpp | 128 ---- ThirdParty/Ert/lib/util/test_util.cpp | 7 - .../Ert/lib/util/tests/ert_util_arg_pack.cpp | 49 -- .../Ert/lib/util/tests/ert_util_datetime.cpp | 3 +- .../lib/util/tests/ert_util_struct_vector.cpp | 139 ---- ThirdParty/Ert/python/ecl/grid/ecl_grid.py | 16 +- ThirdParty/Ert/python/ecl/summary/ecl_sum.py | 10 +- .../Ert/python/ecl/util/util/CMakeLists.txt | 1 - .../Ert/python/ecl/util/util/__init__.py | 1 - ThirdParty/Ert/python/ert/util/__init__.py | 1 - .../Ert/python/tests/ecl_tests/CMakeLists.txt | 2 + .../Ert/python/tests/ecl_tests/test_grdecl.py | 120 +--- .../tests/ecl_tests/test_grdecl_statoil.py | 125 ++++ .../tests/ecl_tests/test_grid_statoil.py | 2 +- .../python/tests/legacy_tests/test_util.py | 1 - .../python/tests/util_tests/CMakeLists.txt | 2 - .../python/tests/util_tests/test_arg_pack.py | 36 - 50 files changed, 536 insertions(+), 1472 deletions(-) create mode 100644 ThirdParty/Ert/lib/ecl/tests/ecl_grid_ext_actnum.cpp create mode 100644 ThirdParty/Ert/lib/ecl/tests/ecl_grid_unit_system.cpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/arg_pack.h delete mode 100644 ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp delete mode 100644 ThirdParty/Ert/lib/include/ert/util/struct_vector.h delete mode 100644 ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp create mode 100644 ThirdParty/Ert/lib/private-include/detail/ecl/layer_cxx.hpp delete mode 100644 ThirdParty/Ert/lib/util/arg_pack.cpp delete mode 100644 ThirdParty/Ert/lib/util/struct_vector.cpp delete mode 100644 ThirdParty/Ert/lib/util/tests/ert_util_arg_pack.cpp delete mode 100644 ThirdParty/Ert/lib/util/tests/ert_util_struct_vector.cpp create mode 100644 ThirdParty/Ert/python/tests/ecl_tests/test_grdecl_statoil.py delete mode 100644 ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 6ec784b826..a8000a7a49 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -18,7 +18,7 @@ set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") # https://github.com/Statoil/libecl # Note: # Apply patches fix-synthetic-odb-cases.patch and install-ert.patch after update -set(ECL_GITHUB_SHA "a165d636552fa0c0f96219d341f7f2c17c08dc9d") +set(ECL_GITHUB_SHA "1f051833c8ed819185fd334dfc7e05511ee35d5f") # https://github.com/OPM/opm-flowdiagnostics set(OPM_FLOWDIAGNOSTICS_SHA "f8af0914f8b1ddcda41f040f539c945a6057f5e4") diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 5e2e1e42b4..332b1696e8 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -352,9 +352,6 @@ if (ENABLE_PYTHON) endif() endif() -if (INSTALL_ERT) - install(EXPORT ecl-config DESTINATION share/cmake/ecl) -endif() - +install(EXPORT ecl-config DESTINATION share/cmake/ecl) export(TARGETS ecl FILE eclConfig.cmake) export(PACKAGE ecl) diff --git a/ThirdParty/Ert/applications/ecl/view_summary.c b/ThirdParty/Ert/applications/ecl/view_summary.c index ff76151363..986f390db4 100644 --- a/ThirdParty/Ert/applications/ecl/view_summary.c +++ b/ThirdParty/Ert/applications/ecl/view_summary.c @@ -201,7 +201,7 @@ int main(int argc , char ** argv) { const char ** arg_list = (const char **) &argv[arg_offset + 1]; - ecl_sum = ecl_sum_fread_alloc_case2__( data_file , ":" , include_restart, true); + ecl_sum = ecl_sum_fread_alloc_case2__( data_file , ":" , include_restart, true, 0); /** If no keys have been presented the function will list available keys. */ if (num_keys == 0) list_mode = true; diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt index d8799e3b5f..74d689a1c6 100644 --- a/ThirdParty/Ert/lib/CMakeLists.txt +++ b/ThirdParty/Ert/lib/CMakeLists.txt @@ -80,7 +80,6 @@ add_library(ecl util/rng.cpp util/util_symlink.cpp util/util_lfs.c util/util_unlink.cpp - util/arg_pack.cpp util/vector.cpp util/parser.cpp util/stringlist.cpp @@ -89,7 +88,6 @@ add_library(ecl util/rng.cpp util/string_util.cpp util/type_vector_functions.cpp util/ecl_version.cpp - util/struct_vector.cpp util/perm_vector.cpp util/test_util.cpp ${opt_srcs} @@ -205,7 +203,7 @@ endif () set_target_properties(ecl PROPERTIES VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} SOVERSION ${ECL_VERSION_MAJOR}) -if (INSTALL_ERT) + install(TARGETS ecl EXPORT ecl-config ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -230,7 +228,6 @@ if (ERT_BUILD_CXX) PATTERN *.hpp ) endif () -endif() if (NOT BUILD_TESTS) return () @@ -248,7 +245,6 @@ add_test(NAME ecl3 COMMAND ecl3-testsuite) foreach (name ert_util_alloc_file_components ert_util_approx_equal - ert_util_arg_pack ert_util_before_after ert_util_binary_split ert_util_buffer @@ -323,10 +319,6 @@ if (HAVE_BACKTRACE) endif() if (HAVE_UTIL_ABORT_INTERCEPT) - add_executable(ert_util_struct_vector util/tests/ert_util_struct_vector.cpp) - target_link_libraries(ert_util_struct_vector ecl) - add_test(NAME ert_util_struct_vector COMMAND ert_util_struct_vector) - add_executable(ert_util_type_vector_test util/tests/ert_util_type_vector_test.cpp) target_link_libraries(ert_util_type_vector_test ecl) add_test(NAME ert_util_type_vector_test COMMAND ert_util_type_vector_test) @@ -350,9 +342,11 @@ foreach (name ecl_alloc_cpgrid ecl_grid_copy ecl_grid_create ecl_grid_DEPTHZ + ecl_grid_unit_system ecl_grid_export ecl_grid_init_fwrite ecl_grid_reset_actnum + ecl_grid_ext_actnum ecl_init_file ecl_kw_cmp_string ecl_kw_equal @@ -409,6 +403,7 @@ if (HAVE_UTIL_ABORT_INTERCEPT) add_executable(ecl_layer ecl/tests/ecl_layer.cpp) target_link_libraries(ecl_layer ecl) + target_include_directories(ecl_layer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private-include) add_test(NAME ecl_layer COMMAND ecl_layer) endif() @@ -594,6 +589,7 @@ add_test(NAME ecl_nnc_test4 COMMAND ecl_nnc_test ${_eclpath}/DualPoro/DUAL_DIFF. add_test(NAME ecl_nnc_test5 COMMAND ecl_nnc_test ${_eclpath}/nestedLGRcase/TESTCASE_NESTEDLGR.EGRID) add_executable(ecl_layer_statoil ecl/tests/ecl_layer_statoil.cpp) +target_include_directories(ecl_layer_statoil PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private-include) target_link_libraries(ecl_layer_statoil ecl) add_test(NAME ecl_layer_statoil COMMAND ecl_layer_statoil ${_eclpath}/Mariner/MARINER.EGRID diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid.cpp b/ThirdParty/Ert/lib/ecl/ecl_grid.cpp index 902e09aa76..4469d153f7 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_grid.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -698,7 +699,7 @@ struct ecl_cell_struct { }; - +static ert_ecl_unit_enum ecl_grid_check_unit_system(const ecl_kw_type * gridunit_kw); static void ecl_grid_init_mapaxes_data_float( const ecl_grid_type * grid , float * mapaxes); float * ecl_grid_alloc_coord_data( const ecl_grid_type * grid ); static const float * ecl_grid_get_mapaxes( const ecl_grid_type * grid ); @@ -1526,6 +1527,7 @@ static bool ecl_grid_alloc_cells( ecl_grid_type * grid , bool init_valid) { */ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid, + ert_ecl_unit_enum unit_system, int dualp_flag, int nx, int ny, @@ -1552,7 +1554,7 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid, grid->index_map = NULL; grid->fracture_index_map = NULL; grid->inv_fracture_index_map = NULL; - grid->unit_system = ECL_METRIC_UNITS; + grid->unit_system = unit_system; if (global_grid != NULL) { @@ -2415,6 +2417,7 @@ void ecl_grid_init_GRDECL_data(ecl_grid_type * ecl_grid, */ static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid, + ert_ecl_unit_enum unit_system, int dualp_flag, bool apply_mapaxes, int nx, @@ -2427,7 +2430,7 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid, const int * corsnum, int lgr_nr) { - ecl_grid_type * ecl_grid = ecl_grid_alloc_empty(global_grid , dualp_flag , nx,ny,nz,lgr_nr,true); + ecl_grid_type * ecl_grid = ecl_grid_alloc_empty(global_grid , unit_system, dualp_flag , nx,ny,nz,lgr_nr,true); if (ecl_grid) { if (mapaxes != NULL) ecl_grid_init_mapaxes( ecl_grid , apply_mapaxes, mapaxes ); @@ -2451,6 +2454,7 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid, } static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid, + ert_ecl_unit_enum unit_system, int dualp_flag, bool apply_mapaxes, int nx, @@ -2463,7 +2467,7 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid, const int * corsnum, int lgr_nr) { - ecl_grid_type * ecl_grid = ecl_grid_alloc_empty(global_grid , dualp_flag , nx,ny,nz,lgr_nr,true); + ecl_grid_type * ecl_grid = ecl_grid_alloc_empty(global_grid, unit_system, dualp_flag , nx,ny,nz,lgr_nr,true); if (ecl_grid) { if (mapaxes != NULL) ecl_grid_init_mapaxes( ecl_grid , apply_mapaxes, mapaxes ); @@ -2520,6 +2524,7 @@ static void ecl_grid_copy_content( ecl_grid_type * target_grid , const ecl_grid_ static ecl_grid_type * ecl_grid_alloc_copy__( const ecl_grid_type * src_grid, ecl_grid_type * main_grid ) { ecl_grid_type * copy_grid = ecl_grid_alloc_empty( main_grid , + src_grid->unit_system, src_grid->dualp_flag , ecl_grid_get_nx( src_grid ) , ecl_grid_get_ny( src_grid ) , @@ -2624,7 +2629,10 @@ ecl_grid_type * ecl_grid_alloc_GRDECL_data(int nx, const int * actnum, bool apply_mapaxes, const float * mapaxes) { + + ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; return ecl_grid_alloc_GRDECL_data__(NULL, + unit_system, FILEHEAD_SINGLE_POROSITY, apply_mapaxes, nx, @@ -2648,8 +2656,9 @@ namespace ecl { const int * actnum, bool apply_mapaxes, const float * mapaxes) { - + ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; return ecl_grid_alloc_GRDECL_data__(NULL, + unit_system, FILEHEAD_SINGLE_POROSITY, apply_mapaxes, nx, @@ -2689,11 +2698,12 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid , const ecl_kw_type * gridhead_kw , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , - const ecl_kw_type * actnum_kw , /* Can be NULL */ + const ecl_kw_type * gridunit_kw, /* Can be NULL */ const ecl_kw_type * mapaxes_kw , /* Can be NULL */ - const ecl_kw_type * corsnum_kw) { /* Can be NULL */ - int gtype, nx,ny,nz, lgr_nr; - + const ecl_kw_type * corsnum_kw, /* Can be NULL */ + const int * actnum_data) { /* Can be NULL */ + int gtype, nx,ny,nz, lgr_nr; + ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; gtype = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_TYPE_INDEX); nx = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_NX_INDEX); ny = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_NY_INDEX); @@ -2714,19 +2724,19 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid , { const float * mapaxes_data = NULL; - const int * actnum_data = NULL; const int * corsnum_data = NULL; - if (mapaxes_kw != NULL) + if (mapaxes_kw) mapaxes_data = ecl_grid_get_mapaxes_from_kw__(mapaxes_kw); - if (actnum_kw != NULL) - actnum_data = ecl_kw_get_int_ptr(actnum_kw); - - if (corsnum_kw != NULL) + if (corsnum_kw) corsnum_data = ecl_kw_get_int_ptr( corsnum_kw ); + if (gridunit_kw) + unit_system = ecl_grid_check_unit_system(gridunit_kw); + return ecl_grid_alloc_GRDECL_data__(global_grid , + unit_system, dualp_flag , apply_mapaxes, nx , ny , nz , @@ -2753,17 +2763,23 @@ ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * actnum_kw , /* Can be NULL */ const ecl_kw_type * mapaxes_kw ) { /* Can be NULL */ + const int * actnum_data = NULL; + if (actnum_kw) + actnum_data = ecl_kw_get_int_ptr(actnum_kw); + bool apply_mapaxes = true; ecl_kw_type * gridhead_kw = ecl_grid_alloc_gridhead_kw( nx, ny, nz, 0); + ecl_kw_type * gridunit_kw = NULL; ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__(NULL, FILEHEAD_SINGLE_POROSITY, apply_mapaxes, gridhead_kw, zcorn_kw, coord_kw, - actnum_kw, + gridunit_kw, mapaxes_kw, - NULL); + NULL, + actnum_data); ecl_kw_free( gridhead_kw ); return ecl_grid; @@ -2986,12 +3002,13 @@ static void ecl_grid_init_nnc_amalgamated(ecl_grid_type * main_grid, ecl_file_ty */ -static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const ecl_file_type * ecl_file , int grid_nr, bool apply_mapaxes) { +static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const ecl_file_type * ecl_file , int grid_nr, bool apply_mapaxes, const int * ext_actnum) { ecl_kw_type * gridhead_kw = ecl_file_iget_named_kw( ecl_file , GRIDHEAD_KW , grid_nr); ecl_kw_type * zcorn_kw = ecl_file_iget_named_kw( ecl_file , ZCORN_KW , grid_nr); ecl_kw_type * coord_kw = ecl_file_iget_named_kw( ecl_file , COORD_KW , grid_nr); ecl_kw_type * corsnum_kw = NULL; ecl_kw_type * actnum_kw = NULL; + ecl_kw_type * gridunit_kw = NULL; ecl_kw_type * mapaxes_kw = NULL; int dualp_flag; int eclipse_version; @@ -3004,10 +3021,23 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const eclipse_version = main_grid->eclipse_version; } - - /** If ACTNUM is not present - that is is interpreted as - all active. */ - if (ecl_file_get_num_named_kw(ecl_file , ACTNUM_KW) > grid_nr) + // If ACTNUM and ext_actnum are not present - that is is interpreted as all active. + const int * actnum_data; + std::vector actnum_product; + if (ecl_file_get_num_named_kw(ecl_file , ACTNUM_KW) > grid_nr) { actnum_kw = ecl_file_iget_named_kw( ecl_file , ACTNUM_KW , grid_nr); + actnum_data = ecl_kw_get_int_ptr(actnum_kw); + if (ext_actnum) { + int size = ecl_kw_get_size(actnum_kw); + actnum_product.resize(size); + for (int i = 0; i < size; i++) + actnum_product[i] = actnum_data[i] * ext_actnum[i]; + actnum_data = actnum_product.data(); + } + } + else + actnum_data = ext_actnum; + if (grid_nr == 0) { /* MAPAXES and COARSENING only apply to the global grid. */ @@ -3016,10 +3046,11 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const if (ecl_file_has_kw( ecl_file , CORSNUM_KW)) corsnum_kw = ecl_file_iget_named_kw( ecl_file , CORSNUM_KW , 0); + + if (ecl_file_has_kw(ecl_file, GRIDUNIT_KW)) + gridunit_kw = ecl_file_iget_named_kw( ecl_file, GRIDUNIT_KW, 0); } - - { ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__( main_grid , dualp_flag , @@ -3027,9 +3058,10 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const gridhead_kw , zcorn_kw , coord_kw , - actnum_kw , + gridunit_kw, mapaxes_kw , - corsnum_kw ); + corsnum_kw, + actnum_data); if (ECL_GRID_MAINGRID_LGR_NR != grid_nr) ecl_grid_set_lgr_name_EGRID(ecl_grid , ecl_file , grid_nr); ecl_grid->eclipse_version = eclipse_version; @@ -3038,8 +3070,13 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const } +static ecl_grid_type * ecl_grid_alloc_GRID_all_grids(const char * filename) { + util_abort("%s .GRID files - %s - not supported \n", __func__ , filename); + return NULL; +} -ecl_grid_type * ecl_grid_alloc_EGRID(const char * grid_file, bool apply_mapaxes) { + +static ecl_grid_type * ecl_grid_alloc_EGRID_all_grids(const char * grid_file, bool apply_mapaxes, const int * ext_actnum) { ecl_file_enum file_type; file_type = ecl_util_get_file_type(grid_file , NULL , NULL); if (file_type != ECL_EGRID_FILE) @@ -3048,11 +3085,13 @@ ecl_grid_type * ecl_grid_alloc_EGRID(const char * grid_file, bool apply_mapaxes) ecl_file_type * ecl_file = ecl_file_open( grid_file , 0); if (ecl_file) { int num_grid = ecl_file_get_num_named_kw( ecl_file , GRIDHEAD_KW ); - ecl_grid_type * main_grid = ecl_grid_alloc_EGRID__( NULL , ecl_file , 0 , apply_mapaxes); + ecl_grid_type * main_grid = ecl_grid_alloc_EGRID__( NULL , ecl_file , 0 , apply_mapaxes, ext_actnum ); int grid_nr; for ( grid_nr = 1; grid_nr < num_grid; grid_nr++) { - ecl_grid_type * lgr_grid = ecl_grid_alloc_EGRID__( main_grid , ecl_file , grid_nr , false); /* The apply_mapaxes argument is ignored for LGR - it inherits from parent anyway. */ + // The apply_mapaxes argument is ignored for LGR - + // it inherits from parent anyway. + ecl_grid_type * lgr_grid = ecl_grid_alloc_EGRID__( main_grid , ecl_file , grid_nr , false, NULL ); ecl_grid_add_lgr( main_grid , lgr_grid ); { ecl_grid_type * host_grid; @@ -3077,14 +3116,19 @@ ecl_grid_type * ecl_grid_alloc_EGRID(const char * grid_file, bool apply_mapaxes) } +ecl_grid_type * ecl_grid_alloc_EGRID(const char * grid_file, bool apply_mapaxes) { + return ecl_grid_alloc_EGRID_all_grids(grid_file, apply_mapaxes, NULL); +} -static ecl_grid_type * ecl_grid_alloc_GRID_data__(ecl_grid_type * global_grid , int num_coords , int dualp_flag , bool apply_mapaxes, int nx, int ny , int nz , int grid_nr , int coords_size , int ** coords , float ** corners , const float * mapaxes) { + + +static ecl_grid_type * ecl_grid_alloc_GRID_data__(ecl_grid_type * global_grid , int num_coords , ert_ecl_unit_enum unit_system, int dualp_flag , bool apply_mapaxes, int nx, int ny , int nz , int grid_nr , int coords_size , int ** coords , float ** corners , const float * mapaxes) { if (dualp_flag != FILEHEAD_SINGLE_POROSITY) nz = nz / 2; { - ecl_grid_type * grid = ecl_grid_alloc_empty( global_grid , dualp_flag , nx , ny , nz , grid_nr, false); + ecl_grid_type * grid = ecl_grid_alloc_empty( global_grid , unit_system, dualp_flag , nx , ny , nz , grid_nr, false); if (grid) { if (mapaxes != NULL) ecl_grid_init_mapaxes( grid , apply_mapaxes , mapaxes); @@ -3110,8 +3154,10 @@ static ecl_grid_type * ecl_grid_alloc_GRID_data__(ecl_grid_type * global_grid , */ ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx , int ny , int nz , int coords_size , int ** coords , float ** corners , bool apply_mapaxes, const float * mapaxes) { + ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; return ecl_grid_alloc_GRID_data__( NULL , num_coords , + unit_system, FILEHEAD_SINGLE_POROSITY , /* Does currently not support to determine dualp_flag from inspection. */ apply_mapaxes, nx , ny , nz , 0 , coords_size , coords , corners , mapaxes); @@ -3165,6 +3211,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const int nx,ny,nz; const float * mapaxes_data = NULL; ecl_grid_type * grid; + ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; // 1: Fetching header data from the DIMENS keyword. { @@ -3184,6 +3231,8 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const } } + if ((grid_nr == 0) && (ecl_file_has_kw( ecl_file , GRIDUNIT_KW))) + unit_system = ecl_grid_check_unit_system( ecl_file_iget_named_kw(ecl_file, GRIDUNIT_KW, 0)); /* The number of COORDS/CORNERS blocks depends on the GRIDFILE option @@ -3256,7 +3305,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const coords_size = ecl_kw_get_size( coords_kw ); } // Create the grid: - grid = ecl_grid_alloc_GRID_data__( global_grid , num_coords , dualp_flag , apply_mapaxes, nx , ny , nz , grid_nr , coords_size , coords , corners , mapaxes_data ); + grid = ecl_grid_alloc_GRID_data__( global_grid , num_coords , unit_system, dualp_flag , apply_mapaxes, nx , ny , nz , grid_nr , coords_size , coords , corners , mapaxes_data ); free( coords ); free( corners ); @@ -3323,7 +3372,8 @@ ecl_grid_type * ecl_grid_alloc_GRID(const char * grid_file, bool apply_mapaxes) which case all cells will be active. */ ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum) { - ecl_grid_type * grid = ecl_grid_alloc_empty(NULL , FILEHEAD_SINGLE_POROSITY , nx , ny , nz , 0, true); + ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; + ecl_grid_type * grid = ecl_grid_alloc_empty(NULL , unit_system, FILEHEAD_SINGLE_POROSITY , nx , ny , nz , 0, true); if (grid) { const double grid_offset[3] = {0,0,0}; @@ -3380,7 +3430,9 @@ ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx all cells will be active. */ ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv( int nx, int ny , int nz , const double * dxv , const double * dyv , const double * dzv , const int * actnum) { + ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; ecl_grid_type* grid = ecl_grid_alloc_empty(NULL, + unit_system, FILEHEAD_SINGLE_POROSITY, nx, ny, nz, /*lgr_nr=*/0, /*init_valid=*/true); @@ -3423,7 +3475,9 @@ ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv( int nx, int ny , int nz , const doub ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , const double * dxv , const double * dyv , const double * dzv , const double * depthz , const int * actnum) { + ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; ecl_grid_type* grid = ecl_grid_alloc_empty(NULL, + unit_system, FILEHEAD_SINGLE_POROSITY, nx, ny, nz, /*lgr_nr=*/0, /*init_valid=*/true); @@ -3526,8 +3580,9 @@ ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , con */ ecl_grid_type * ecl_grid_alloc_dx_dy_dz_tops( int nx, int ny , int nz , const double * dx , const double * dy , const double * dz , const double * tops , const int * actnum) { - + ert_ecl_unit_enum unit_system = ECL_METRIC_UNITS; ecl_grid_type* grid = ecl_grid_alloc_empty(NULL, + unit_system, FILEHEAD_SINGLE_POROSITY, nx, ny, nz, 0, true); @@ -3607,6 +3662,23 @@ ecl_grid_type * ecl_grid_alloc(const char * grid_file ) { } +// This function is used to override use of the keyword ACTNUM from the EGRID file. +// ext_actnum must have size equal to the number of cells in the main grid +// if ext_actnum = NULL, actnum is taken from file, otherwise ext_actnums +// determines which cells are active. +ecl_grid_type * ecl_grid_alloc_ext_actnum(const char * grid_file, const int * ext_actnum) { + ecl_file_enum file_type = ecl_util_get_file_type(grid_file , NULL , NULL); + if (file_type == ECL_EGRID_FILE) + return ecl_grid_alloc_EGRID_all_grids(grid_file, true, ext_actnum); + else if (file_type == ECL_GRID_FILE) + ecl_grid_alloc_GRID_all_grids(grid_file); + else + util_abort("%s must have .EGRID file - %s not recognized \n", __func__ , grid_file); + + return NULL; +} + + static void ecl_grid_file_nactive_dims( fortio_type * data_fortio , int * dims) { if (data_fortio) { if (ecl_kw_fseek_kw( INTEHEAD_KW , false , false , data_fortio )) { @@ -6010,6 +6082,19 @@ static ecl_kw_type * ecl_grid_alloc_gridunits_kw( ert_ecl_unit_enum output_unit return gridunits_kw; } +static ert_ecl_unit_enum ecl_grid_check_unit_system(const ecl_kw_type * gridunit_kw) { + const char * length_unit = ecl_kw_iget_char_ptr(gridunit_kw, 0); + + if (strncmp(length_unit, "FEET", 4) == 0) + return ECL_FIELD_UNITS; + + if (strncmp(length_unit, "CM", 2) == 0) + return ECL_LAB_UNITS; + + return ECL_METRIC_UNITS; +} + + /*****************************************************************/ static float ecl_grid_output_scaling( const ecl_grid_type * grid , ert_ecl_unit_enum output_unit) { diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp index fd5db1f134..5d76c7f36d 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp @@ -215,11 +215,13 @@ bool ecl_kw_grdecl_fseek_kw(const char * kw , bool rewind , FILE * stream) { which (might) have been used in the input. */ - -static void iset_range( char * data , int data_offset , int sizeof_ctype , void * value_ptr , int multiplier) { - int index; - for ( index =0; index < multiplier; index++) - memcpy( &data[ (index + data_offset) * sizeof_ctype ] , value_ptr , sizeof_ctype); +static void iset_range( char * data , int data_index, int sizeof_ctype , void * value_ptr , int multiplier) { + size_t byte_offset; + for (int index =0; index < multiplier; index++) { + byte_offset = static_cast(data_index) + static_cast(index); + byte_offset *= sizeof_ctype; + memcpy( &data[ byte_offset ] , value_ptr , sizeof_ctype); + } } @@ -255,9 +257,9 @@ static void iset_range( char * data , int data_offset , int sizeof_ctype , void static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_data_type data_type , int * kw_size , FILE * stream ) { char newline = '\n'; bool atEOF = false; - int init_size = 32; - int buffer_size = 64; - int data_index = 0; + size_t init_size = 32; + size_t buffer_size = 64; + size_t data_index = 0; int sizeof_ctype = ecl_type_get_sizeof_ctype( data_type ); size_t data_size = init_size; char * buffer = (char*)util_calloc( (buffer_size + 1) , sizeof * buffer ); @@ -347,7 +349,7 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ data_size = util_size_t_min( ECL_KW_MAX_SIZE , 2*(data_index + multiplier)); byte_size *= data_size; - data = (char*)util_realloc( data , byte_size ); + data = (char*) util_realloc( data , byte_size ); } else { /* We are asking for more elements than can possible be adressed in diff --git a/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp b/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp index 735c8e29a5..b1e1996de4 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp @@ -16,7 +16,8 @@ for more details. */ -#include +#include +#include #include @@ -24,7 +25,7 @@ struct ecl_nnc_geometry_struct { UTIL_TYPE_ID_DECLARATION; - struct_vector_type * data; + std::vector * data; }; @@ -32,7 +33,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_nnc_geometry, ECL_NNC_GEOMETRY_TYPE_ID ) int ecl_nnc_geometry_size( const ecl_nnc_geometry_type * nnc_geo ) { - return struct_vector_get_size( nnc_geo->data ); + return nnc_geo->data->size(); } /* @@ -71,30 +72,27 @@ static void ecl_nnc_geometry_add_pairs( const ecl_nnc_geometry_type * nnc_geo , pair.grid_nr2 = lgr_nr2; pair.global_index2 = int_vector_iget( grid2_index_list , index2 ); pair.input_index = int_vector_iget( nnc_index_list, index2 ); - struct_vector_append( nnc_geo->data , &pair); + nnc_geo->data->push_back(pair); } } } } -static int ecl_nnc_cmp(const void * _nnc1 , const void * _nnc2) { - const ecl_nnc_pair_type * nnc1 = (const ecl_nnc_pair_type * ) _nnc1; - const ecl_nnc_pair_type * nnc2 = (const ecl_nnc_pair_type * ) _nnc2; +static bool ecl_nnc_cmp(const ecl_nnc_pair_type& nnc1, const ecl_nnc_pair_type& nnc2) { + if (nnc1.grid_nr1 != nnc2.grid_nr1) + return nnc1.grid_nr1 < nnc2.grid_nr1; - if (nnc1->grid_nr1 != nnc2->grid_nr1) - return nnc1->grid_nr1 - nnc2->grid_nr1; + if (nnc1.grid_nr2 != nnc2.grid_nr2) + return nnc1.grid_nr2 < nnc2.grid_nr2; - if (nnc1->grid_nr2 != nnc2->grid_nr2) - return nnc1->grid_nr2 - nnc2->grid_nr2; + if (nnc1.global_index1 != nnc2.global_index1) + return nnc1.global_index1 < nnc2.global_index1; - if (nnc1->global_index1 != nnc2->global_index1) - return nnc1->global_index1 - nnc2->global_index1; + if (nnc1.global_index2 != nnc2.global_index2) + return nnc1.global_index2 < nnc2.global_index2; - if (nnc1->global_index2 != nnc2->global_index2) - return nnc1->global_index2 - nnc2->global_index2; - - return 0; + return true; } @@ -102,27 +100,27 @@ static int ecl_nnc_cmp(const void * _nnc1 , const void * _nnc2) { ecl_nnc_geometry_type * ecl_nnc_geometry_alloc( const ecl_grid_type * grid ) { ecl_nnc_geometry_type * nnc_geo = (ecl_nnc_geometry_type*)util_malloc( sizeof * nnc_geo ); UTIL_TYPE_ID_INIT( nnc_geo , ECL_NNC_GEOMETRY_TYPE_ID ); - nnc_geo->data = struct_vector_alloc( sizeof( struct ecl_nnc_pair_struct )); + nnc_geo->data = new std::vector(); ecl_nnc_geometry_add_pairs( nnc_geo , grid ); for (int lgr_index = 0; lgr_index < ecl_grid_get_num_lgr(grid); lgr_index++) { ecl_grid_type * igrid = ecl_grid_iget_lgr( grid , lgr_index ); ecl_nnc_geometry_add_pairs( nnc_geo, igrid ); } - struct_vector_sort( nnc_geo->data , ecl_nnc_cmp ); + std::sort(nnc_geo->data->begin(), nnc_geo->data->end(), ecl_nnc_cmp); return nnc_geo; } void ecl_nnc_geometry_free( ecl_nnc_geometry_type * nnc_geo) { - struct_vector_free( nnc_geo->data ); + delete nnc_geo->data; free( nnc_geo ); } const ecl_nnc_pair_type * ecl_nnc_geometry_iget( const ecl_nnc_geometry_type * nnc_geo , int index) { - return (const ecl_nnc_pair_type*)struct_vector_iget_ptr( nnc_geo->data , index ); - + const std::vector& nnc_data = *nnc_geo->data; + return &nnc_data[index]; } diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp index 3c002cb9c5..491edb508c 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp @@ -88,10 +88,7 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } - - if (doubhead_kw) - rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); - + rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); if (logihead_kw) rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); @@ -112,15 +109,12 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int report_step) { const ecl_kw_type * intehead_kw = ecl_file_view_iget_named_kw( rst_view , INTEHEAD_KW , 0); - const ecl_kw_type * doubhead_kw = NULL; + const ecl_kw_type * doubhead_kw = ecl_file_view_iget_named_kw( rst_view , DOUBHEAD_KW , 0); const ecl_kw_type * logihead_kw = NULL; if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW)) logihead_kw = ecl_file_view_iget_named_kw( rst_view , LOGIHEAD_KW , 0); - if (ecl_file_view_has_kw(rst_view, DOUBHEAD_KW)) - doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0); - if (ecl_file_view_has_kw( rst_view , SEQNUM_KW)) { const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( rst_view , SEQNUM_KW , 0); report_step = ecl_kw_iget_int( seqnum_kw , 0); diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum.cpp index 7cb2924946..49488a6005 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_sum.cpp @@ -174,22 +174,22 @@ static ecl_sum_type * ecl_sum_alloc__( const char * input_arg , const char * key } -static bool ecl_sum_fread_data( ecl_sum_type * ecl_sum , const stringlist_type * data_files , bool include_restart, bool lazy_load) { +static bool ecl_sum_fread_data( ecl_sum_type * ecl_sum , const stringlist_type * data_files , bool include_restart, bool lazy_load, int file_options) { if (ecl_sum->data != NULL) ecl_sum_free_data( ecl_sum ); ecl_sum->data = ecl_sum_data_alloc( ecl_sum->smspec ); - return ecl_sum_data_fread( ecl_sum->data , data_files, lazy_load); + return ecl_sum_data_fread( ecl_sum->data , data_files, lazy_load, file_options); } -static void ecl_sum_fread_history( ecl_sum_type * ecl_sum, bool lazy_load) { +static void ecl_sum_fread_history( ecl_sum_type * ecl_sum, bool lazy_load, int file_options) { char * restart_header = ecl_util_alloc_filename(NULL, ecl_smspec_get_restart_case(ecl_sum->smspec), ECL_SUMMARY_HEADER_FILE, ecl_smspec_get_formatted(ecl_sum->smspec), -1); - ecl_sum_type * restart_case = ecl_sum_fread_alloc_case2__(restart_header, ":" , true, lazy_load); + ecl_sum_type * restart_case = ecl_sum_fread_alloc_case2__(restart_header, ":" , true, lazy_load, file_options); if (restart_case) { ecl_sum->restart_case = restart_case; ecl_sum_data_add_case(ecl_sum->data , restart_case->data ); @@ -199,7 +199,7 @@ static void ecl_sum_fread_history( ecl_sum_type * ecl_sum, bool lazy_load) { -static bool ecl_sum_fread(ecl_sum_type * ecl_sum , const char *header_file , const stringlist_type *data_files , bool include_restart, bool lazy_load) { +static bool ecl_sum_fread(ecl_sum_type * ecl_sum , const char *header_file , const stringlist_type *data_files , bool include_restart, bool lazy_load, int file_options) { ecl_sum->smspec = ecl_smspec_fread_alloc( header_file , ecl_sum->key_join_string , include_restart); if (ecl_sum->smspec) { bool fmt_file; @@ -208,7 +208,7 @@ static bool ecl_sum_fread(ecl_sum_type * ecl_sum , const char *header_file , con } else return false; - if (ecl_sum_fread_data( ecl_sum , data_files , include_restart, lazy_load )) { + if (ecl_sum_fread_data( ecl_sum , data_files , include_restart, lazy_load, file_options )) { ecl_file_enum file_type = ecl_util_get_file_type( stringlist_iget( data_files , 0 ) , NULL , NULL); if (file_type == ECL_SUMMARY_FILE) @@ -221,13 +221,13 @@ static bool ecl_sum_fread(ecl_sum_type * ecl_sum , const char *header_file , con return false; if (include_restart && ecl_smspec_get_restart_case( ecl_sum->smspec )) - ecl_sum_fread_history( ecl_sum, lazy_load); + ecl_sum_fread_history( ecl_sum, lazy_load, file_options); return true; } -static bool ecl_sum_fread_case( ecl_sum_type * ecl_sum , bool include_restart, bool lazy_load) { +static bool ecl_sum_fread_case( ecl_sum_type * ecl_sum , bool include_restart, bool lazy_load, int file_options) { char * header_file; stringlist_type * summary_file_list = stringlist_alloc_new(); @@ -235,7 +235,7 @@ static bool ecl_sum_fread_case( ecl_sum_type * ecl_sum , bool include_restart, b ecl_util_alloc_summary_files( ecl_sum->path , ecl_sum->base , ecl_sum->ext , &header_file , summary_file_list ); if ((header_file != NULL) && (stringlist_get_size( summary_file_list ) > 0)) { - caseOK = ecl_sum_fread( ecl_sum , header_file , summary_file_list , include_restart, lazy_load ); + caseOK = ecl_sum_fread( ecl_sum , header_file , summary_file_list , include_restart, lazy_load, file_options ); } free( header_file ); stringlist_free( summary_file_list ); @@ -255,10 +255,10 @@ static bool ecl_sum_fread_case( ecl_sum_type * ecl_sum , bool include_restart, b */ -ecl_sum_type * ecl_sum_fread_alloc(const char *header_file , const stringlist_type *data_files , const char * key_join_string, bool include_restart, bool lazy_load) { +ecl_sum_type * ecl_sum_fread_alloc(const char *header_file , const stringlist_type *data_files , const char * key_join_string, bool include_restart, bool lazy_load, int file_options) { ecl_sum_type * ecl_sum = ecl_sum_alloc__( header_file , key_join_string ); if (ecl_sum) { - if (!ecl_sum_fread( ecl_sum , header_file , data_files , include_restart, lazy_load)) { + if (!ecl_sum_fread( ecl_sum , header_file , data_files , include_restart, lazy_load, file_options)) { ecl_sum_free( ecl_sum ); ecl_sum = NULL; } @@ -451,12 +451,12 @@ void ecl_sum_free__(void * __ecl_sum) { */ -ecl_sum_type * ecl_sum_fread_alloc_case2__(const char * input_file , const char * key_join_string , bool include_restart, bool lazy_load){ +ecl_sum_type * ecl_sum_fread_alloc_case2__(const char * input_file , const char * key_join_string , bool include_restart, bool lazy_load, int file_options){ ecl_sum_type * ecl_sum = ecl_sum_alloc__(input_file , key_join_string); if (!ecl_sum) return NULL; - if (ecl_sum_fread_case( ecl_sum , include_restart, lazy_load)) + if (ecl_sum_fread_case( ecl_sum , include_restart, lazy_load, file_options)) return ecl_sum; else { /* @@ -470,14 +470,16 @@ ecl_sum_type * ecl_sum_fread_alloc_case2__(const char * input_file , const char ecl_sum_type * ecl_sum_fread_alloc_case__(const char * input_file , const char * key_join_string , bool include_restart) { bool lazy_load = true; - return ecl_sum_fread_alloc_case2__(input_file, key_join_string, include_restart, lazy_load); + int file_options = 0; + return ecl_sum_fread_alloc_case2__(input_file, key_join_string, include_restart, lazy_load, file_options); } ecl_sum_type * ecl_sum_fread_alloc_case(const char * input_file , const char * key_join_string){ bool include_restart = true; bool lazy_load = true; - return ecl_sum_fread_alloc_case2__( input_file , key_join_string , include_restart, lazy_load ); + int file_options = 0; + return ecl_sum_fread_alloc_case2__( input_file , key_join_string , include_restart, lazy_load, file_options ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp index 25596392c9..7cf72a309c 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp @@ -696,9 +696,9 @@ void ecl_sum_data_add_case(ecl_sum_data_type * self, const ecl_sum_data_type * o call to ecl_sum_data_build_index(). */ -bool ecl_sum_data_fread(ecl_sum_data_type * data , const stringlist_type * filelist, bool lazy_load) { +bool ecl_sum_data_fread(ecl_sum_data_type * data , const stringlist_type * filelist, bool lazy_load, int file_options) { ecl::ecl_sum_file_data * file_data = new ecl::ecl_sum_file_data( data->smspec ); - if (file_data->fread( filelist, lazy_load)) { + if (file_data->fread( filelist, lazy_load, file_options)) { ecl_sum_data_append_file_data( data, file_data ); ecl_sum_data_build_index(data); return true; @@ -722,9 +722,9 @@ bool ecl_sum_data_fread(ecl_sum_data_type * data , const stringlist_type * filel (manually) changed from the historical part. */ -ecl_sum_data_type * ecl_sum_data_fread_alloc( ecl_smspec_type * smspec , const stringlist_type * filelist , bool include_restart, bool lazy_load) { +ecl_sum_data_type * ecl_sum_data_fread_alloc( ecl_smspec_type * smspec , const stringlist_type * filelist , bool include_restart, bool lazy_load, int file_options) { ecl_sum_data_type * data = ecl_sum_data_alloc( smspec ); - ecl_sum_data_fread( data , filelist, lazy_load ); + ecl_sum_data_fread( data , filelist, lazy_load, file_options ); /*****************************************************************/ /* OK - now we have loaded all the data. Must sort the internal diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_file_data.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum_file_data.cpp index 6c7875a98f..b0367e2ec5 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_file_data.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_file_data.cpp @@ -579,7 +579,7 @@ void ecl_sum_file_data::add_ecl_file(int report_step, const ecl_file_view_type * } -bool ecl_sum_file_data::fread(const stringlist_type * filelist, bool lazy_load) { +bool ecl_sum_file_data::fread(const stringlist_type * filelist, bool lazy_load, int file_options) { if (stringlist_get_size( filelist ) == 0) return false; @@ -608,7 +608,7 @@ bool ecl_sum_file_data::fread(const stringlist_type * filelist, bool lazy_load) } else if (file_type == ECL_UNIFIED_SUMMARY_FILE) { if (lazy_load) { try { - this->loader.reset( new unsmry_loader( this->ecl_smspec, stringlist_iget(filelist, 0)) ); + this->loader.reset( new unsmry_loader( this->ecl_smspec, stringlist_iget(filelist, 0), file_options) ); } catch(const std::bad_alloc& e) { diff --git a/ThirdParty/Ert/lib/ecl/ecl_unsmry_loader.cpp b/ThirdParty/Ert/lib/ecl/ecl_unsmry_loader.cpp index 2568a0a1f5..7363b5cd68 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_unsmry_loader.cpp +++ b/ThirdParty/Ert/lib/ecl/ecl_unsmry_loader.cpp @@ -12,14 +12,13 @@ namespace ecl { -unsmry_loader::unsmry_loader(const ecl_smspec_type * smspec, const std::string& filename) : +unsmry_loader::unsmry_loader(const ecl_smspec_type * smspec, const std::string& filename, int file_options) : size(ecl_smspec_get_params_size(smspec)), time_index(ecl_smspec_get_time_index(smspec)), time_seconds(ecl_smspec_get_time_seconds(smspec)), sim_start(ecl_smspec_get_start_time(smspec)) { - int options = ECL_FILE_CLOSE_STREAM; - ecl_file_type * file = ecl_file_open(filename.c_str(), options); + ecl_file_type * file = ecl_file_open(filename.c_str(), file_options); if (!file) throw std::bad_alloc(); diff --git a/ThirdParty/Ert/lib/ecl/fault_block.cpp b/ThirdParty/Ert/lib/ecl/fault_block.cpp index 62d5af6785..8ea051204b 100644 --- a/ThirdParty/Ert/lib/ecl/fault_block.cpp +++ b/ThirdParty/Ert/lib/ecl/fault_block.cpp @@ -15,6 +15,7 @@ See the GNU General Public License at for more details. */ +#include #include #include @@ -29,6 +30,8 @@ #include #include +#include "detail/ecl/layer_cxx.hpp" + #define FAULT_BLOCK_ID 3297376 @@ -182,8 +185,7 @@ const int_vector_type * fault_block_get_global_index_list( const fault_block_typ bool fault_block_trace_edge( const fault_block_type * block , double_vector_type * x_list , double_vector_type * y_list, int_vector_type * cell_list) { if (fault_block_get_size( block ) > 0) { - struct_vector_type * corner_list = struct_vector_alloc( sizeof(int_point2d_type) ); - int c; + std::vector corner_list; { int start_i = fault_block_iget_i( block , 0 ); int start_j = fault_block_iget_j( block , 0 ); @@ -194,18 +196,15 @@ bool fault_block_trace_edge( const fault_block_type * block , double_vector_type if (x_list && y_list) { double_vector_reset( x_list ); double_vector_reset( y_list ); - for (c=0; c < struct_vector_get_size( corner_list ); c++) { + for (const auto& p : corner_list) { double x,y,z; - int_point2d_type ij; - struct_vector_iget( corner_list , c , &ij ); - ecl_grid_get_corner_xyz( block->grid , ij.i , ij.j , block->k , &x , &y , &z); + ecl_grid_get_corner_xyz( block->grid , p.i, p.j , block->k , &x , &y , &z); double_vector_append( x_list , x); double_vector_append( y_list , y); } } - struct_vector_free( corner_list ); return true; } else return false; diff --git a/ThirdParty/Ert/lib/ecl/fortio.c b/ThirdParty/Ert/lib/ecl/fortio.c index ebd341f19e..bf62340816 100644 --- a/ThirdParty/Ert/lib/ecl/fortio.c +++ b/ThirdParty/Ert/lib/ecl/fortio.c @@ -452,16 +452,14 @@ void fortio_data_fseek(fortio_type* fortio, offset_type data_offset, size_t data if(data_element >= element_count) { util_abort("%s: Element index is out of range: 0 <= %d < %d \n", __func__, data_element, element_count); } + { + int block_index = data_element / block_size; + int headers = (block_index + 1) * 4; + int trailers = block_index * 4; + offset_type offset = data_offset + headers + trailers + (data_element * element_size); - fseek( fortio->stream, data_offset, SEEK_SET ); - int block_index = data_element / block_size; - int err = eclfio_skip( fortio->stream, fortio->opts, block_index ); - if( err ) util_abort( "%s: error skipping %d sub reords\n", - __func__, - block_index ); - int item_index = (data_element % block_size) * element_size; - int header_size = sizeof( int32_t ); - fseek( fortio->stream, header_size + item_index, SEEK_CUR ); + fortio_fseek(fortio, offset, SEEK_SET); + } } int fortio_fclean(fortio_type * fortio) { diff --git a/ThirdParty/Ert/lib/ecl/layer.cpp b/ThirdParty/Ert/lib/ecl/layer.cpp index 7a79809f31..07fe65f50e 100644 --- a/ThirdParty/Ert/lib/ecl/layer.cpp +++ b/ThirdParty/Ert/lib/ecl/layer.cpp @@ -18,6 +18,8 @@ #include #include +#include + #include #include @@ -300,7 +302,14 @@ static bool point_equal(int_point2d_type * p1 , int_point2d_type *p2) { */ -static void layer_trace_block_edge__( const layer_type * layer , int_point2d_type start_point , int i , int j , int value , edge_dir_enum dir , struct_vector_type * corner_list, int_vector_type * cell_list) { +static void layer_trace_block_edge__( const layer_type * layer , + int_point2d_type start_point , + int i, + int j, + int value, + edge_dir_enum dir , + std::vector& corner_list, + int_vector_type * cell_list) { int_point2d_type current_point; int_point2d_type next_point; current_point.i = i; @@ -318,7 +327,7 @@ static void layer_trace_block_edge__( const layer_type * layer , int_point2d_typ } else if (dir == LEFT_EDGE) point_shift( ¤t_point , 0 , 1 ); - struct_vector_append( corner_list , ¤t_point ); + corner_list.push_back(current_point); { int cell_index = i + j*layer->nx; int_vector_append( cell_list , cell_index ); @@ -449,7 +458,7 @@ static bool layer_find_edge( const layer_type * layer , int *i , int *j , int va } -bool layer_trace_block_edge( const layer_type * layer , int start_i , int start_j , int value , struct_vector_type * corner_list , int_vector_type * cell_list) { +bool layer_trace_block_edge( const layer_type * layer , int start_i , int start_j , int value , std::vector& corner_list, int_vector_type * cell_list) { int g = layer_get_global_cell_index( layer , start_i , start_j); cell_type * cell = &layer->data[g]; if (cell->cell_value == value) { @@ -464,7 +473,7 @@ bool layer_trace_block_edge( const layer_type * layer , int start_i , int start_ start_corner.i = i; start_corner.j = j; - struct_vector_reset( corner_list ); + corner_list.clear(); int_vector_reset( cell_list ); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_ext_actnum.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_ext_actnum.cpp new file mode 100644 index 0000000000..75c497189a --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_ext_actnum.cpp @@ -0,0 +1,64 @@ +#include + +#include +#include + +#include +#include +#include +#include +#include + + +void test_1() { + + test_work_area_type * work_area = test_work_area_alloc("ext_actnum_main_grid"); + { + const char * filename = "FILE.EGRID"; + + ecl_grid_type * grid_write = ecl_grid_alloc_rectangular(2,3,1, 1,1,1,NULL); + ecl_grid_fwrite_EGRID( grid_write , filename, true); + ecl_grid_free(grid_write); + + ecl_file_type * ecl_file = ecl_file_open(filename, 0); + ecl_kw_type * filehead_kw = ecl_file_iget_named_kw( ecl_file , FILEHEAD_KW , 0); + int * filehead_data = ecl_kw_get_int_ptr(filehead_kw); + filehead_data[FILEHEAD_DUALP_INDEX] = FILEHEAD_DUAL_POROSITY; + + ecl_kw_type * actnum_kw = ecl_file_iget_named_kw( ecl_file, ACTNUM_KW, 0); + int * actnum_data = ecl_kw_get_int_ptr(actnum_kw); + actnum_data[0] = 1; + actnum_data[1] = 2; + actnum_data[2] = 2; + actnum_data[3] = 0; + actnum_data[4] = 1; + actnum_data[5] = 1; + const char * filename1 = "FILE1.EGRID"; + fortio_type * f = fortio_open_writer( filename1, false, ECL_ENDIAN_FLIP ); + ecl_file_fwrite_fortio(ecl_file, f, 0); + fortio_fclose( f ); + ecl_file_close(ecl_file); + + std::vector ext_actnum = {0, 1, 0, 1, 1, 1}; + ecl_grid_type * grid = ecl_grid_alloc_ext_actnum(filename1, ext_actnum.data()); + test_assert_int_equal( 2, ecl_grid_get_nactive(grid) ); + test_assert_int_equal( 1, ecl_grid_get_nactive_fracture(grid) ); + test_assert_true( !ecl_grid_cell_active1(grid, 0) ); + + test_assert_true( !ecl_grid_cell_active1(grid, 2) ); + test_assert_true( !ecl_grid_cell_active1(grid, 3) ); + test_assert_true( ecl_grid_cell_active1(grid, 4) ); + test_assert_true( ecl_grid_cell_active1(grid, 5) ); + + ecl_grid_free( grid ); + + } + test_work_area_free( work_area ); + + +} + + +int main() { + test_1(); +} diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_unit_system.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_unit_system.cpp new file mode 100644 index 0000000000..2e75a1c59b --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_unit_system.cpp @@ -0,0 +1,63 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + The file 'ecl_grid_unit_system.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 + for more details. +*/ +#include +#include + +#include +#include + +#include +#include +#include + + +void test_EGRID(const char * filename, ert_ecl_unit_enum unit_system) { + ecl_grid_type * grid = ecl_grid_alloc_rectangular(4,4,2,1,1,1,NULL); + ecl_grid_fwrite_EGRID2( grid , filename, unit_system); + ecl_grid_free( grid ); + + + ecl_grid_type * grid2 = ecl_grid_alloc(filename); + test_assert_int_equal( ecl_grid_get_unit_system(grid2), unit_system); + ecl_grid_free(grid2); +} + + + +void test_GRID(const char * filename, ert_ecl_unit_enum unit_system) { + ecl_grid_type * grid = ecl_grid_alloc_rectangular(4,4,2,1,1,1,NULL); + ecl_grid_fwrite_GRID2( grid , filename, unit_system); + ecl_grid_free( grid ); + + + ecl_grid_type * grid2 = ecl_grid_alloc(filename); + test_assert_int_equal( ecl_grid_get_unit_system(grid2), unit_system); + ecl_grid_free(grid2); +} + + +int main(int argc, char **argv) { + test_work_area_type * work_area = test_work_area_alloc("grid_export"); + + test_EGRID("METRIC.EGRID", ECL_METRIC_UNITS); + test_EGRID("FIELD.EGRID", ECL_FIELD_UNITS); + test_GRID("METRIC.GRID", ECL_METRIC_UNITS); + test_GRID("FIELD.GRID", ECL_FIELD_UNITS); + + test_work_area_free(work_area); +} diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_layer.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_layer.cpp index 5bedeb4bc4..ab5d85c6d5 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_layer.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_layer.cpp @@ -18,12 +18,13 @@ #include #include +#include + #include #include -#include #include - +#include "detail/ecl/layer_cxx.hpp" void test_create() { layer_type * layer = layer_alloc(10,20); @@ -199,7 +200,7 @@ void test_edge() { void test_walk() { layer_type * layer = layer_alloc(10,10); - struct_vector_type * corner_list = struct_vector_alloc( sizeof(int_point2d_type)); + std::vector corner_list; int_vector_type * cell_list = int_vector_alloc(0,0); test_assert_false( layer_trace_block_edge( layer , 4 , 4 , 100 , corner_list , cell_list)); @@ -207,26 +208,20 @@ void test_walk() { test_assert_false( layer_trace_block_edge( layer , 4 , 4 , 200 , corner_list , cell_list)); test_assert_true( layer_trace_block_edge( layer , 4 , 4 , 100 , corner_list , cell_list)); - test_assert_int_equal( struct_vector_get_size( corner_list ) , 4); + test_assert_int_equal( corner_list.size(), 4); test_assert_int_equal( int_vector_size( cell_list ) , 1 ); { - int_point2d_type point; + test_assert_int_equal( 4 , corner_list[0].i ); + test_assert_int_equal( 4 , corner_list[0].j ); - struct_vector_iget( corner_list , 0 , &point); - test_assert_int_equal( 4 , point.i ); - test_assert_int_equal( 4 , point.j ); + test_assert_int_equal( 5 , corner_list[1].i ); + test_assert_int_equal( 4 , corner_list[1].j ); - struct_vector_iget( corner_list , 1 , &point); - test_assert_int_equal( 5 , point.i ); - test_assert_int_equal( 4 , point.j ); + test_assert_int_equal( 5 , corner_list[2].i ); + test_assert_int_equal( 5 , corner_list[2].j ); - struct_vector_iget( corner_list , 2 , &point); - test_assert_int_equal( 5 , point.i ); - test_assert_int_equal( 5 , point.j ); - - struct_vector_iget( corner_list , 3 , &point); - test_assert_int_equal( 4 , point.i ); - test_assert_int_equal( 5 , point.j ); + test_assert_int_equal( 4 , corner_list[3].i ); + test_assert_int_equal( 5 , corner_list[3].j ); } { @@ -247,7 +242,7 @@ void test_walk() { int_vector_select_unique( true_cell_list ); test_assert_true( layer_trace_block_edge( layer , 3 , 3 , 100 , corner_list , cell_list)); - test_assert_int_equal( 16 , struct_vector_get_size( corner_list )); + test_assert_int_equal( 16 , corner_list.size()); test_assert_int_equal( 12 , int_vector_size( cell_list )); int_vector_fprintf( cell_list , stdout , " cell_list" , "%3d"); @@ -258,7 +253,6 @@ void test_walk() { } int_vector_free( cell_list ); - struct_vector_free( corner_list ); layer_free( layer ); } @@ -320,7 +314,7 @@ void test_content2() { int_vector_type * i_list = int_vector_alloc(0,0); int_vector_type * j_list = int_vector_alloc(0,0); int_vector_type * cell_list = int_vector_alloc(0,0); - struct_vector_type * corner_list = struct_vector_alloc( sizeof(int_point2d_type) ); + std::vector corner_list; for (j=0; j < 5; j++) { @@ -335,7 +329,6 @@ void test_content2() { } } - struct_vector_free( corner_list ); int_vector_free( i_list ); int_vector_free( j_list ); int_vector_free( cell_list ); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_layer_statoil.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_layer_statoil.cpp index 55e4487376..912248dfd4 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_layer_statoil.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_layer_statoil.cpp @@ -18,13 +18,16 @@ #include #include +#include + #include #include -#include #include #include +#include +#include "detail/ecl/layer_cxx.hpp" ecl_kw_type * alloc_faultblock_kw( const char * filename, int grid_size) { FILE * stream = util_fopen( filename , "r"); @@ -49,7 +52,7 @@ void test_layer( const ecl_grid_type * ecl_grid , const ecl_kw_type * faultblock } { - struct_vector_type * corner_list = struct_vector_alloc( sizeof(int_point2d_type) ); + std::vector corner_list; int_vector_type * i_list = int_vector_alloc(0,0); int_vector_type * j_list = int_vector_alloc(0,0); int_vector_type * cell_list = int_vector_alloc(0,0); @@ -64,7 +67,6 @@ void test_layer( const ecl_grid_type * ecl_grid , const ecl_kw_type * faultblock } } test_assert_int_equal( 0 , layer_get_cell_sum( layer )); - struct_vector_free( corner_list ); int_vector_free( i_list ); int_vector_free( j_list ); int_vector_free( cell_list ); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_data_intermediate_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_data_intermediate_test.cpp index 184556c6ea..b9eda7fe52 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_data_intermediate_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_data_intermediate_test.cpp @@ -96,7 +96,7 @@ void write_CASE1(bool unified) { void verify_CASE2() { - ecl_sum_type * sum = ecl_sum_fread_alloc_case2__("CASE2", ":", false, true); + ecl_sum_type * sum = ecl_sum_fread_alloc_case2__("CASE2", ":", false, true, 0); for (int i=0; i < 2; i++) { double_vector_type * d = ecl_sum_alloc_data_vector(sum, i+1, false); @@ -154,7 +154,7 @@ void write_CASE2(bool unified) { } void verify_CASE3() { - ecl_sum_type * sum = ecl_sum_fread_alloc_case2__("CASE3", ":", false, true); + ecl_sum_type * sum = ecl_sum_fread_alloc_case2__("CASE3", ":", false, true, 0); for (int i=0; i < 3; i++) { double_vector_type * d = ecl_sum_alloc_data_vector(sum, i+1, false); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_unsmry_loader_test.cpp b/ThirdParty/Ert/lib/ecl/tests/ecl_unsmry_loader_test.cpp index 4eae07e393..d224c7dc75 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_unsmry_loader_test.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_unsmry_loader_test.cpp @@ -40,7 +40,7 @@ void test_load() { ecl_sum_type * ecl_sum = write_ecl_sum(); test_assert_true( util_file_exists("CASE.SMSPEC") ); test_assert_true( util_file_exists("CASE.UNSMRY") ); - ecl::unsmry_loader * loader = new ecl::unsmry_loader(ecl_sum_get_smspec(ecl_sum), "CASE.UNSMRY"); + ecl::unsmry_loader * loader = new ecl::unsmry_loader(ecl_sum_get_smspec(ecl_sum), "CASE.UNSMRY", 0); const std::vector FOPT_value = loader->get_vector(1); const std::vector BPR_value = loader->get_vector(2); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp index 461df881ff..3f97f38d18 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp @@ -112,6 +112,7 @@ extern "C" { ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , bool apply_mapaxes , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , bool apply_mapaxes, const float * mapaxes); ecl_grid_type * ecl_grid_alloc(const char * ); + ecl_grid_type * ecl_grid_alloc_ext_actnum(const char * , const int * ext_actnum); ecl_grid_type * ecl_grid_load_case( const char * case_input ); ecl_grid_type * ecl_grid_load_case__( const char * case_input , bool apply_mapaxes); ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx , double dy , double dz , const int * actnum); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp index 512e86352f..a66529fb45 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp @@ -89,10 +89,10 @@ typedef struct ecl_sum_struct ecl_sum_type; void ecl_sum_free_data(ecl_sum_type * ); void ecl_sum_free__(void * ); void ecl_sum_free(ecl_sum_type * ); - ecl_sum_type * ecl_sum_fread_alloc(const char * , const stringlist_type * data_files, const char * key_join_string, bool include_restart, bool lazy_load); + ecl_sum_type * ecl_sum_fread_alloc(const char * , const stringlist_type * data_files, const char * key_join_string, bool include_restart, bool lazy_load, int file_options); ecl_sum_type * ecl_sum_fread_alloc_case(const char * , const char * key_join_string); ecl_sum_type * ecl_sum_fread_alloc_case__(const char * input_file , const char * key_join_string , bool include_restart); - ecl_sum_type * ecl_sum_fread_alloc_case2__(const char * , const char * key_join_string , bool include_restart, bool lazy_load); + ecl_sum_type * ecl_sum_fread_alloc_case2__(const char * , const char * key_join_string , bool include_restart, bool lazy_load, int file_options); ecl_sum_type * ecl_sum_alloc_resample(const ecl_sum_type * ecl_sum, const char * ecl_case, const time_t_vector_type * times); bool ecl_sum_case_exists( const char * input_file ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp index e464e41106..0c6fdbc0b1 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp @@ -43,7 +43,7 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; void ecl_sum_data_fwrite_step( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , bool unified, int report_step); void ecl_sum_data_fwrite( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , bool unified); bool ecl_sum_data_can_write(const ecl_sum_data_type * data); - bool ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist, bool lazy_load); + bool ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist, bool lazy_load, int file_options); ecl_sum_data_type * ecl_sum_data_alloc_writer( ecl_smspec_type * smspec ); ecl_sum_data_type * ecl_sum_data_alloc( ecl_smspec_type * smspec); double ecl_sum_data_time2days( const ecl_sum_data_type * data , time_t sim_time); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp b/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp index 760134de58..450ee240d3 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp @@ -21,7 +21,6 @@ #include -#include #include #include @@ -70,7 +69,6 @@ extern "C" { int layer_get_nx( const layer_type * layer); int layer_get_cell_sum( const layer_type * layer ); bool layer_trace_block_content( layer_type * layer , bool erase , int start_i , int start_j , int value , int_vector_type * i_list , int_vector_type * j_list); - bool layer_trace_block_edge( const layer_type * layer , int i , int j , int value , struct_vector_type * corner_list , int_vector_type * cell_list); bool layer_cell_contact( const layer_type * layer , int i1 , int j1 , int i2 , int j2); void layer_add_interp_barrier( layer_type * layer , int c1 , int c2); void layer_add_ijbarrier( layer_type * layer , int i1 , int j1 , int i2 , int j2 ); diff --git a/ThirdParty/Ert/lib/include/ert/util/arg_pack.h b/ThirdParty/Ert/lib/include/ert/util/arg_pack.h deleted file mode 100644 index d73e9566b5..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/arg_pack.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - Warning: The libecl code has changed to be compiled as a C++ project. This - header file is retained for a period for compatibility, but you are encouraged - to switch to include the new hpp header directly in your code. -*/ - -#include - - diff --git a/ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp b/ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp deleted file mode 100644 index 55a498a9b8..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'arg_pack.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 - for more details. -*/ - -#ifndef ERT_ARG_PACK_H -#define ERT_ARG_PACK_H -#ifdef __cplusplus -extern "C" { -#endif -#include -#include - -#include -#include - -typedef struct arg_pack_struct arg_pack_type; -typedef void (arg_node_free_ftype) (void *); -typedef void * (arg_node_copyc_ftype) (const void *); - - arg_pack_type * arg_pack_alloc(); - UTIL_SAFE_CAST_HEADER( arg_pack ); - UTIL_SAFE_CAST_HEADER_CONST( arg_pack ); - UTIL_IS_INSTANCE_HEADER( arg_pack ); - - void arg_pack_free(arg_pack_type * ); - void arg_pack_free__(void *); - void arg_pack_clear(arg_pack_type *); - void arg_pack_lock(arg_pack_type *); - void arg_pack_fscanf(arg_pack_type * arg , FILE * stream, const char * filename); - void arg_pack_fprintf(const arg_pack_type * , FILE * ); - - void arg_pack_append_ptr(arg_pack_type * , void *); - void arg_pack_append_const_ptr(arg_pack_type * , const void *); - void arg_pack_append_owned_ptr(arg_pack_type * , void * , arg_node_free_ftype *); - void arg_pack_append_copy(arg_pack_type * , void * , arg_node_copyc_ftype * , arg_node_free_ftype *); - - /* - void arg_pack_iset_copy(arg_pack_type * arg_pack , int index , void * ptr, arg_node_copyc_ftype * copyc , arg_node_free_ftype * freef); - void arg_pack_iset_ptr(arg_pack_type * arg_pack, int index , void * ptr); - void arg_pack_iset_owned_ptr(arg_pack_type * arg_pack, int index , void * ptr, arg_node_free_ftype * freef); - */ - const void * arg_pack_iget_const_ptr( const arg_pack_type * arg_pack , int index); - void * arg_pack_iget_ptr(const arg_pack_type * , int); - void * arg_pack_iget_adress(const arg_pack_type * , int); - node_ctype arg_pack_iget_ctype(const arg_pack_type * arg_pack ,int index); - - int arg_pack_size( const arg_pack_type * arg_pack ); - - /*****************************************************************/ - -#define APPEND_TYPED_HEADER(type) void arg_pack_append_ ## type (arg_pack_type * , type); -#define IGET_TYPED_HEADER(type) type arg_pack_iget_ ## type( const arg_pack_type * , int ); -#define ISET_TYPED_HEADER(type) void arg_pack_iset_ ## type( arg_pack_type * , int , type value); - -APPEND_TYPED_HEADER(int) -APPEND_TYPED_HEADER(bool) -APPEND_TYPED_HEADER(char) -APPEND_TYPED_HEADER(float) -APPEND_TYPED_HEADER(double) -APPEND_TYPED_HEADER(size_t) - -IGET_TYPED_HEADER(int) -IGET_TYPED_HEADER(bool) -IGET_TYPED_HEADER(char) -IGET_TYPED_HEADER(float) -IGET_TYPED_HEADER(double) -IGET_TYPED_HEADER(size_t) - -ISET_TYPED_HEADER(int) -ISET_TYPED_HEADER(bool) -ISET_TYPED_HEADER(char) -ISET_TYPED_HEADER(float) -ISET_TYPED_HEADER(double) -ISET_TYPED_HEADER(size_t) - -#undef APPEND_TYPED_HEADER -#undef GET_TYPED_HEADER - - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/ThirdParty/Ert/lib/include/ert/util/struct_vector.h b/ThirdParty/Ert/lib/include/ert/util/struct_vector.h deleted file mode 100644 index b76466c591..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/struct_vector.h +++ /dev/null @@ -1,9 +0,0 @@ -/* - Warning: The libecl code has changed to be compiled as a C++ project. This - header file is retained for a period for compatibility, but you are encouraged - to switch to include the new hpp header directly in your code. -*/ - -#include - - diff --git a/ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp b/ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp deleted file mode 100644 index a24f9cb285..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'struct_vector.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 - for more details. -*/ - -#ifndef ERT_STRUCT_VECTOR_H -#define ERT_STRUCT_VECTOR_H - -#ifdef __cplusplus -extern "C" { -#endif -#include - - -typedef struct struct_vector_struct struct_vector_type; -typedef int ( struct_vector_cmp_ftype ) (const void * , const void *); - - struct_vector_type * struct_vector_alloc( int element_size ); - void struct_vector_free( struct_vector_type * struct_vector ); - int struct_vector_get_size( const struct_vector_type * struct_vector ); - void struct_vector_append( struct_vector_type * struct_vector , void * value); - void struct_vector_iget( const struct_vector_type * struct_vector , int index , void * value); - void * struct_vector_iget_ptr( const struct_vector_type * struct_vector , int index); - void struct_vector_reset( struct_vector_type * struct_vector ); - void struct_vector_reserve( struct_vector_type * struct_vector , int reserve_size); - void * struct_vector_get_data( const struct_vector_type * struct_vector ); - void struct_vector_sort( struct_vector_type * struct_vector , struct_vector_cmp_ftype * cmp); - - UTIL_IS_INSTANCE_HEADER( struct_vector ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_sum_file_data.hpp b/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_sum_file_data.hpp index 1e060fa395..3435cc6017 100644 --- a/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_sum_file_data.hpp +++ b/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_sum_file_data.hpp @@ -127,7 +127,7 @@ public: bool can_write() const; void fwrite_unified( fortio_type * fortio ) const; void fwrite_multiple( const char * ecl_case , bool fmt_case ) const; - bool fread(const stringlist_type * filelist, bool lazy_load); + bool fread(const stringlist_type * filelist, bool lazy_load, int file_options); private: const ecl_smspec_type * ecl_smspec; diff --git a/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_unsmry_loader.hpp b/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_unsmry_loader.hpp index 3602cd20f1..741373bbed 100644 --- a/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_unsmry_loader.hpp +++ b/ThirdParty/Ert/lib/private-include/detail/ecl/ecl_unsmry_loader.hpp @@ -10,7 +10,7 @@ namespace ecl { class unsmry_loader { public: - unsmry_loader(const ecl_smspec_type * smspec, const std::string& filename); + unsmry_loader(const ecl_smspec_type * smspec, const std::string& filename, int file_options); ~unsmry_loader(); std::vector get_vector(int pos) const; diff --git a/ThirdParty/Ert/lib/private-include/detail/ecl/layer_cxx.hpp b/ThirdParty/Ert/lib/private-include/detail/ecl/layer_cxx.hpp new file mode 100644 index 0000000000..bd19f36b0f --- /dev/null +++ b/ThirdParty/Ert/lib/private-include/detail/ecl/layer_cxx.hpp @@ -0,0 +1,9 @@ +#ifndef LAYER_CXX_HPP +#define LAYER_CXX_HPP + +#include +#include + +bool layer_trace_block_edge( const layer_type * layer , int i , int j , int value , std::vector& corner_list, int_vector_type * cell_list); + +#endif diff --git a/ThirdParty/Ert/lib/util/arg_pack.cpp b/ThirdParty/Ert/lib/util/arg_pack.cpp deleted file mode 100644 index 805a4febc9..0000000000 --- a/ThirdParty/Ert/lib/util/arg_pack.cpp +++ /dev/null @@ -1,661 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'arg_pack.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 - for more details. -*/ - -#include -#include -#include -#include - -#include -#include -#include - - -/** - This file implements an arg_pack structure which is a small - convienence utility to pack several arguments into one - argument. The generic use situtation is when calling functions like - e.g. pthread_create() which take one (void *) as argument. You can - then pack several arguments into one arg_pack instance, and then - unpack them at the other end. - - The content of the arg_pack is mainly inserted by appending, in - addition it is possible to insert new items by using _iset() - functions, however these functions will fail hard if the resulting - call sequence will lead to holes in the structure, i.e. - - arg_pack_type * arg_pack = arg_pack_alloc() - arg_pack_append_int( arg_pack , 1); - arg_pack_iset_int( arg_pack , 3 , 0); <--- Will fail hard because - elements 1,2,3 have not been set. - - - When you take them out again that is done with indexed get. - - When elements are inserted into the arg_pack, they are inserted - with a (limited) type information (implictly given by the function - invoked to insert the argument), and the corresponding typed get - must be used to unpack the argument again afterwards. The - excepetion is with the function arg_pack_iget_adress() which can be - used to extract the reference of a scalar. - - - - Example: - -------- - - void some_function(const char * arg1 , int arg2 , double arg3) { - ..... - } - - - void some_function__(void * __arg_pack) { - arg_pack_type * arg_pack = arg_pack_safe_cast( __arg_pack ); - const char * arg1 = arg_pack_iget_ptr( arg_pack , 0); - int arg2 = arg_pack_iget_int( arg_pack , 1); - double arg3 = arg_pack_iget_double(arg_pack , 2); - - some_function( arg1 , arg2 , arg3 ); - } - - - ..... - arg_pack_type * arg_pack = arg_pack_alloc(); - arg_pack_append_ptr(arg_pack , "ARG1"); - arg_pack_append_int(arg_pack , 1); - arg_pack_append_double(arg_pack , 3.14159265); - - pthread_create( , , some_function__ , arg_pack); - -*/ - - - - -#define ARG_PACK_TYPE_ID 668268 - - -typedef struct { - void * buffer; /* This is the actual content - can either point to a remote object, or to storage managed by the arg_pack instance. */ - node_ctype ctype; /* The type of the data which is stored. */ - arg_node_free_ftype * destructor; /* destructor called on buffer - can be NULL. */ - arg_node_copyc_ftype * copyc; /* copy constructor - will typically be NULL. */ -} arg_node_type; - - - -struct arg_pack_struct { - UTIL_TYPE_ID_DECLARATION; - int size; /* The number of arguments appended to this arg_pack instance. */ - int alloc_size; /* The number of nodes allocated to this arg_pack - will in general be greater than size. */ - bool locked; /* To insure against unwaranted modifictaions - you can explicitly lock the arg_pack instance. This only */ - arg_node_type **nodes; /* Vector of nodes */ -}; - - -/*****************************************************************/ -/* First comes the arg_node functions. These are all fully static.*/ - -static arg_node_type * arg_node_alloc_empty() { - arg_node_type * node = (arg_node_type*)util_malloc( sizeof * node ); - node->buffer = NULL; - node->destructor = NULL; - node->ctype = CTYPE_INVALID; - return node; -} - - -static void arg_node_realloc_buffer(arg_node_type * node , int new_size) { - node->buffer = util_realloc(node->buffer , new_size ); -} - - -static void __arg_node_assert_type(const arg_node_type * node , node_ctype arg_type) { - if (arg_type != node->ctype) - util_abort("%s: asked for type:\'%s\' inserted as:\'%s\' - aborting \n" , __func__ , node_ctype_name(arg_type) , node_ctype_name(node->ctype)); -} - - - -/*****************************************************************/ -#define ARG_NODE_GET_RETURN(type) \ -{ \ - type value; \ - memcpy(&value , node->buffer , sizeof value); \ - return value; \ -} - - -static int arg_node_get_int( const arg_node_type * node) { - __arg_node_assert_type( node , CTYPE_INT_VALUE ); - ARG_NODE_GET_RETURN( int ) -} - -static char arg_node_get_char( const arg_node_type * node) { - __arg_node_assert_type( node , CTYPE_CHAR_VALUE ); - ARG_NODE_GET_RETURN( char ) -} - -static double arg_node_get_double( const arg_node_type * node) { - __arg_node_assert_type( node , CTYPE_DOUBLE_VALUE ); - ARG_NODE_GET_RETURN( double ) -} - -static float arg_node_get_float( const arg_node_type * node) { - __arg_node_assert_type( node , CTYPE_FLOAT_VALUE ); - ARG_NODE_GET_RETURN( float ) -} - -static bool arg_node_get_bool( const arg_node_type * node) { - __arg_node_assert_type( node , CTYPE_BOOL_VALUE ); - ARG_NODE_GET_RETURN( bool ) -} - -static size_t arg_node_get_size_t( const arg_node_type * node) { - __arg_node_assert_type( node , CTYPE_SIZE_T_VALUE ); - ARG_NODE_GET_RETURN( size_t ) -} -#undef ARG_NODE_GET_RETURN - -/** - If the argument is inserted as a pointer, you must use get_ptr == - true, otherwise you must use get_ptr == false, and this will give - you the adress of the scalar. - - Observe that if you call XX_get_ptr() on a pointer which is still - owned by the arg_pack, you must be careful when freeing the - arg_pack, as that will delete the pointer you are using as well. -*/ - - -static void * arg_node_get_ptr(const arg_node_type * node , bool get_ptr) { - if (get_ptr) { - if (node->ctype != CTYPE_VOID_POINTER) - util_abort("%s: tried to get pointer from something not a pointer\n",__func__); - } else { - if (node->ctype == CTYPE_VOID_POINTER) - util_abort("%s: tried to get adress to something already a ponter\n",__func__); - } - return node->buffer; -} - - -static node_ctype arg_node_get_ctype( const arg_node_type * arg_node ) { - return arg_node->ctype; -} - -/*****************************************************************/ -/* SET functions. */ - - -#define ARG_NODE_SET(node , value) \ - arg_node_realloc_buffer(node , sizeof value); \ - memcpy(node->buffer , &value , sizeof value); \ - node->destructor = NULL; - - -static void arg_node_set_int( arg_node_type * node , int value) { - ARG_NODE_SET( node , value ); - node->ctype = CTYPE_INT_VALUE; -} - - -static void arg_node_set_char( arg_node_type * node , char value) { - ARG_NODE_SET( node , value ); - node->ctype = CTYPE_CHAR_VALUE; -} - - -static void arg_node_set_float( arg_node_type * node , float value) { - ARG_NODE_SET( node , value ); - node->ctype = CTYPE_FLOAT_VALUE; -} - - -static void arg_node_set_double( arg_node_type * node , double value) { - ARG_NODE_SET( node , value ); - node->ctype = CTYPE_DOUBLE_VALUE; -} - - -static void arg_node_set_bool( arg_node_type * node , bool value) { - ARG_NODE_SET( node , value ); - node->ctype = CTYPE_BOOL_VALUE; -} - - -static void arg_node_set_size_t( arg_node_type * node , size_t value) { - ARG_NODE_SET( node , value ); - node->ctype = CTYPE_SIZE_T_VALUE; -} - -#undef ARG_NODE_SET - - -static void arg_node_set_ptr(arg_node_type * node , const void * ptr , arg_node_copyc_ftype * copyc , arg_node_free_ftype * destructor) { - node->ctype = CTYPE_VOID_POINTER; - node->destructor = destructor; - node->copyc = copyc; - if (copyc != NULL) - node->buffer = copyc( ptr ); - else - node->buffer = (void *) ptr; -} - - - -/*****************************************************************/ - - -static void arg_node_clear(arg_node_type * node) { - if (node->ctype == CTYPE_VOID_POINTER) { - if (node->destructor != NULL) - node->destructor( node->buffer ); - /* When you have cleared - must not reuse the thing. */ - node->destructor = NULL; - node->buffer = NULL; - node->copyc = NULL; - } -} - - -static void arg_node_free(arg_node_type * node) { - arg_node_clear(node); - free(node->buffer); - free(node); -} - - - -static const char * arg_node_fmt(const arg_node_type *node) { - switch (node->ctype) { - case(CTYPE_INT_VALUE): - return " %d"; - break; - case(CTYPE_DOUBLE_VALUE): - return " %lg"; - break; - case(CTYPE_FLOAT_VALUE): - return " %g"; - break; - case(CTYPE_BOOL_VALUE): - return " %d"; - break; - case(CTYPE_CHAR_VALUE): - return " %d"; - break; - case(CTYPE_SIZE_T_VALUE): - return " %d"; - break; - default: - util_abort("%s: arg_type:%d not recognized for scanning \n",__func__ , node->ctype); - return ""; /* Dummy to shut up compiler */ - } -} - - -static void arg_node_fprintf(const arg_node_type * node , FILE * stream) { - switch (node->ctype) { - case(CTYPE_INT_VALUE): - fprintf(stream , "int:%d",arg_node_get_int(node)); - break; - case(CTYPE_DOUBLE_VALUE): - fprintf(stream , "double:%g",arg_node_get_double(node)); - break; - case(CTYPE_VOID_POINTER): - fprintf(stream , "pointer:<%p>",arg_node_get_ptr( node , true )); - break; - case(CTYPE_BOOL_VALUE): - fprintf(stream , "bool:%d", arg_node_get_bool( node )); - break; - default: - util_abort("%s: - not implemented for type:%d \n",__func__ , node->ctype); - } -} - - -/*****************************************************************/ -/* Ending node node functions - starting on functons for the whole pack. */ -/*****************************************************************/ - -UTIL_SAFE_CAST_FUNCTION( arg_pack , ARG_PACK_TYPE_ID) -UTIL_SAFE_CAST_FUNCTION_CONST( arg_pack , ARG_PACK_TYPE_ID) -UTIL_IS_INSTANCE_FUNCTION(arg_pack , ARG_PACK_TYPE_ID) - -static void __arg_pack_assert_index(const arg_pack_type * arg , int iarg) { - if (iarg < 0 || iarg >= arg->size) - util_abort("%s: arg_pack() object filled with %d arguments - %d invalid argument number - aborting \n",__func__ , arg->size , iarg); -} - - -static void arg_pack_realloc_nodes(arg_pack_type * arg_pack , int new_size) { - arg_pack->nodes = (arg_node_type**) util_realloc(arg_pack->nodes , new_size * sizeof * arg_pack->nodes ); - { - int i; - for (i = arg_pack->alloc_size; i < new_size; i++) - arg_pack->nodes[i] = arg_node_alloc_empty(); - } - arg_pack->alloc_size = new_size; -} - - -/** - The name of this function is QUITE MISLEADING; the function will - create a new node, with index @index, and return it possibly - freeing the existing with this index. If index == arg_pack->size a - new node will be created at the end of the arg_pack; if index > - arg_pack->size the function will fail hard. -*/ -static arg_node_type * arg_pack_iget_new_node( arg_pack_type * arg_pack , int index) { - if (index < 0 || index > arg_pack->size) - util_abort("%s: index:%d invalid. Valid interval: [0,%d) \n",__func__ , index , arg_pack->size); - { - if (index < arg_pack->size) { - arg_node_free( arg_pack->nodes[index] ); /* Free the existing current node. */ - arg_pack->nodes[index] = arg_node_alloc_empty( ); /* Allocate a new fresh instance. */ - } - - if (arg_pack->size == arg_pack->alloc_size) - arg_pack_realloc_nodes(arg_pack , 1 + arg_pack->alloc_size * 2); /* We have to grow the vector of nodes. */ - - if (index == arg_pack->size) - arg_pack->size++; /* We are asking for the first element beyond the current length of the vector, i.e. append. */ - return arg_pack->nodes[index]; - } -} - - - -static arg_node_type * arg_pack_get_append_node(arg_pack_type * arg_pack) { - if (arg_pack->locked) { - util_abort("%s: tryng to append to a locked arg_pack instance \n",__func__); - return NULL; - } - { - arg_node_type * new_node = arg_pack_iget_new_node( arg_pack , arg_pack->size ); - return new_node; - } -} - - -void arg_pack_lock(arg_pack_type * arg_pack) { - arg_pack->locked = true; -} - - - -arg_pack_type * arg_pack_alloc() { - arg_pack_type * arg_pack = (arg_pack_type*)util_malloc(sizeof * arg_pack ); - UTIL_TYPE_ID_INIT( arg_pack , ARG_PACK_TYPE_ID); - arg_pack->nodes = NULL; - arg_pack->alloc_size = 0; - arg_pack->locked = false; - arg_pack_realloc_nodes(arg_pack , 4); - arg_pack_clear(arg_pack); - return arg_pack; -} - - -void arg_pack_free(arg_pack_type * arg_pack) { - int i; - - for (i=0; i < arg_pack->alloc_size; i++) - arg_node_free( arg_pack->nodes[i] ); - - free(arg_pack->nodes); - free(arg_pack); -} - - -void arg_pack_free__(void * __arg_pack) { - arg_pack_type * arg_pack = arg_pack_safe_cast( __arg_pack ); - arg_pack_free( arg_pack ); -} - - - -void arg_pack_clear(arg_pack_type * arg_pack) { - if (arg_pack->locked) - util_abort("%s: arg_pack has been locked - abortng \n",__func__); - { - int i; - for ( i=0; i < arg_pack->size; i++) - arg_node_clear(arg_pack->nodes[i]); - arg_pack->size = 0; - } -} - - -/******************************************************************/ -/* Access functions: - - 1. Append - 2. iget - 3. iset (can NOT create holes in the vector) - -******************************************************************/ - -#define APPEND_TYPED(type) \ -void arg_pack_append_ ## type (arg_pack_type *pack , type value) { \ - arg_node_type * node = arg_pack_get_append_node( pack ); \ - arg_node_set_ ## type(node , value); \ -} - - -#define ISET_TYPED(type)\ -void arg_pack_iset_ ## type(arg_pack_type * pack, int index, type value) { \ - arg_node_type * node = arg_pack_iget_new_node( pack , index); \ - arg_node_set_ ## type(node , value); \ -} - - -#define IGET_TYPED(type)\ -type arg_pack_iget_ ## type(const arg_pack_type * pack, int index) { \ - __arg_pack_assert_index( pack , index); \ - { \ - arg_node_type * node = pack->nodes[index]; \ - return arg_node_get_ ## type ( node ); \ - } \ -} - - -APPEND_TYPED(int); -APPEND_TYPED(bool); -APPEND_TYPED(float); -APPEND_TYPED(double); -APPEND_TYPED(char); -APPEND_TYPED(size_t); - -IGET_TYPED(int); -IGET_TYPED(bool); -IGET_TYPED(float); -IGET_TYPED(double); -IGET_TYPED(char); -IGET_TYPED(size_t); - -ISET_TYPED(int); -ISET_TYPED(bool); -ISET_TYPED(float); -ISET_TYPED(double); -ISET_TYPED(char); -ISET_TYPED(size_t); - -#undef APPEND_TYPED -#undef IGET_TYPED -#undef ISET_TYPED - - -void * arg_pack_iget_ptr(const arg_pack_type * arg , int iarg) { - __arg_pack_assert_index(arg , iarg); - return arg_node_get_ptr(arg->nodes[iarg] , true); -} - - -const void * arg_pack_iget_const_ptr(const arg_pack_type * arg , int iarg) { - __arg_pack_assert_index(arg , iarg); - return arg_node_get_ptr(arg->nodes[iarg] , true); -} - - -void * arg_pack_iget_adress(const arg_pack_type * arg , int iarg) { - __arg_pack_assert_index(arg , iarg); - return arg_node_get_ptr(arg->nodes[iarg] , false); -} - - -node_ctype arg_pack_iget_ctype(const arg_pack_type * arg_pack ,int index) { - __arg_pack_assert_index(arg_pack , index); - return arg_node_get_ctype( arg_pack->nodes[index] ); -} - -/*****************************************************************/ - - -void arg_pack_iset_copy(arg_pack_type * arg_pack , int index , const void * ptr, arg_node_copyc_ftype * copyc , arg_node_free_ftype * freef) { - arg_node_type * node = arg_pack_iget_new_node( arg_pack , index ); - arg_node_set_ptr(node , ptr , copyc , freef); -} - - -void arg_pack_iset_ptr(arg_pack_type * arg_pack, int index , const void * ptr) { - arg_pack_iset_copy(arg_pack , index , ptr , NULL , NULL); -} - -void arg_pack_iset_owned_ptr(arg_pack_type * arg_pack, int index , void * ptr, arg_node_free_ftype * freef) { - arg_pack_iset_copy(arg_pack , index , ptr , NULL , freef ); -} - - -void arg_pack_append_copy(arg_pack_type * arg_pack , void * ptr, arg_node_copyc_ftype * copyc , arg_node_free_ftype * freef) { - arg_pack_iset_copy( arg_pack , arg_pack->size , ptr , copyc , freef); -} - - -void arg_pack_append_ptr(arg_pack_type * arg_pack, void * ptr) { - arg_pack_iset_ptr( arg_pack , arg_pack->size , ptr ); -} - -void arg_pack_append_const_ptr(arg_pack_type * arg_pack, const void * ptr) { - arg_pack_iset_ptr( arg_pack , arg_pack->size , ptr ); -} - - -void arg_pack_append_owned_ptr(arg_pack_type * arg_pack, void * ptr, arg_node_free_ftype * freef) { - arg_pack_iset_owned_ptr( arg_pack , arg_pack->size , ptr , freef); -} - -int arg_pack_size( const arg_pack_type * arg_pack ) { - return arg_pack->size; -} - -/******************************************************************/ -/* Functions for formatted reading/writing of arg_pack instances. */ - - - -void arg_pack_fscanf(arg_pack_type * arg , FILE * stream, const char * filename) { - - int scan_count = 0; - int iarg; - char * fmt = NULL; - for (iarg = 0; iarg < arg->size; iarg++) { - arg_node_type * node = arg->nodes[iarg]; - fmt = util_strcat_realloc(fmt , arg_node_fmt(node)); - } - - switch(arg->size) { - case(0): - break; - case(1): - { - void *arg0; - arg0 = arg_pack_iget_adress(arg , 0); - scan_count = fscanf(stream , fmt , arg0); - break; - } - case(2): - { - void *arg0, *arg1; - arg0 = arg_pack_iget_adress(arg , 0); - arg1 = arg_pack_iget_adress(arg , 1); - - scan_count = fscanf(stream , fmt , arg0 , arg1); - break; - } - case(3): - { - void *arg0, *arg1 , *arg2; - arg0 = arg_pack_iget_adress(arg , 0); - arg1 = arg_pack_iget_adress(arg , 1); - arg2 = arg_pack_iget_adress(arg , 2); - - scan_count = fscanf(stream , fmt , arg0 , arg1 , arg2); - break; - } - case(4): - { - void *arg0, *arg1 , *arg2 , *arg3; - arg0 = arg_pack_iget_adress(arg , 0); - arg1 = arg_pack_iget_adress(arg , 1); - arg2 = arg_pack_iget_adress(arg , 2); - arg3 = arg_pack_iget_adress(arg , 3); - - scan_count = fscanf(stream , fmt , arg0 , arg1 , arg2 , arg3); - break; - } - case(5): - { - void *arg0, *arg1 , *arg2 , *arg3, *arg4; - arg0 = arg_pack_iget_adress(arg , 0); - arg1 = arg_pack_iget_adress(arg , 1); - arg2 = arg_pack_iget_adress(arg , 2); - arg3 = arg_pack_iget_adress(arg , 3); - arg4 = arg_pack_iget_adress(arg , 4); - - scan_count = fscanf(stream , fmt , arg0 , arg1 , arg2 , arg3 , arg4); - break; - } - - default: - util_abort("%s: sorry %s not allocated for %d arguments from file %s\n",__func__ , __func__ , arg->size, filename); - - } - - if (scan_count != arg->size) { - util_abort("%s: wanted %d arguments - only found: %d in file %s \n", __func__ , arg->size , scan_count, filename); - } - - free(fmt); -} - - -void arg_pack_fprintf(const arg_pack_type * arg_pack , FILE * stream) { - int iarg; - fprintf(stream," ["); - for (iarg = 0; iarg < arg_pack->size; iarg++) { - arg_node_type * node = arg_pack->nodes[iarg]; - arg_node_fprintf(node , stream); - if (iarg < (arg_pack->size - 1)) - fprintf(stream,", "); - } - fprintf(stream, "]\n"); -} - - - - diff --git a/ThirdParty/Ert/lib/util/struct_vector.cpp b/ThirdParty/Ert/lib/util/struct_vector.cpp deleted file mode 100644 index c79891b810..0000000000 --- a/ThirdParty/Ert/lib/util/struct_vector.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'struct_vector.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 - for more details. -*/ - -#include -#include - -#include -#include - - -#define STRUCT_VECTOR_TYPE_ID 772562097 - -struct struct_vector_struct { - UTIL_TYPE_ID_DECLARATION; - int size; - int element_size; - int alloc_size; - - char * data; -}; - -UTIL_IS_INSTANCE_FUNCTION( struct_vector , STRUCT_VECTOR_TYPE_ID) - - -static void struct_vector_resize( struct_vector_type * struct_vector , int new_alloc_size) { - struct_vector->data = (char*)util_realloc( struct_vector->data , struct_vector->element_size * new_alloc_size ); - struct_vector->alloc_size = new_alloc_size; -} - - -void struct_vector_reserve( struct_vector_type * struct_vector , int reserve_size) { - if (reserve_size > struct_vector->alloc_size) - struct_vector_resize( struct_vector , reserve_size ); -} - - - -struct_vector_type * struct_vector_alloc( int element_size ) { - if (element_size <= 0) { - util_abort("%s: fatal error - can not create container for zero size objects\n",__func__); - return NULL; - } - - { - struct_vector_type * vector = (struct_vector_type*)util_malloc( sizeof * vector ); - UTIL_TYPE_ID_INIT( vector , STRUCT_VECTOR_TYPE_ID ); - vector->size = 0; - vector->alloc_size = 0; - vector->element_size = element_size; - vector->data = NULL; - - struct_vector_resize( vector , 10 ); - - return vector; - } -} - -void struct_vector_free( struct_vector_type * struct_vector) { - free( struct_vector->data ); - free( struct_vector ); -} - - -int struct_vector_get_size( const struct_vector_type * struct_vector) { - return struct_vector->size; -} - - - -void struct_vector_append( struct_vector_type * struct_vector , void * value) { - if (struct_vector->size == struct_vector->alloc_size) - struct_vector_resize( struct_vector , 2*struct_vector->alloc_size + 1); - - { - size_t offset = struct_vector->size * struct_vector->element_size; - memcpy( &struct_vector->data[offset] , value , struct_vector->element_size); - struct_vector->size++; - } -} - - -void * struct_vector_get_data( const struct_vector_type * struct_vector ) { - return struct_vector->data; -} - - -void struct_vector_iget( const struct_vector_type * struct_vector , int index , void * value) { - if (index < struct_vector->size) { - size_t offset = index * struct_vector->element_size; - memcpy( value , &struct_vector->data[offset] , struct_vector->element_size); - } else - util_abort("%s: fatal error - invalid index:%d size:%d\n",__func__ , index , struct_vector->size); -} - - -void * struct_vector_iget_ptr( const struct_vector_type * struct_vector , int index ) { - if (index < struct_vector->size) { - size_t offset = index * struct_vector->element_size; - return &struct_vector->data[offset]; - } else - util_abort("%s: fatal error - invalid index:%d size:%d\n",__func__ , index , struct_vector->size); - return NULL; -} - - -void struct_vector_reset( struct_vector_type * struct_vector ) { - struct_vector->size = 0; -} - - -void struct_vector_sort( struct_vector_type * struct_vector , struct_vector_cmp_ftype * cmp) { - qsort(struct_vector->data , struct_vector->size , struct_vector->element_size , cmp); -} diff --git a/ThirdParty/Ert/lib/util/test_util.cpp b/ThirdParty/Ert/lib/util/test_util.cpp index 249ed6164d..0e4349f7e0 100644 --- a/ThirdParty/Ert/lib/util/test_util.cpp +++ b/ThirdParty/Ert/lib/util/test_util.cpp @@ -26,7 +26,6 @@ #include "ert/util/build_config.hpp" #include -#include #include #include #include @@ -373,9 +372,3 @@ void * thread_pool_test_func1( void * arg ) { #endif -void * test_argpack_is_stringlist( void * arg ) { - arg_pack_type * arg_pack = arg_pack_safe_cast( arg ); - void * arg0 = arg_pack_iget_ptr( arg_pack , 0 ); - test_assert_true( stringlist_is_instance( arg0 ) ); - return NULL; -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_arg_pack.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_arg_pack.cpp deleted file mode 100644 index 752ca4c40e..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_arg_pack.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ert_util_arg_pack.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 - for more details. -*/ -#include -#include -#include -#include - -#include -#include - - - -/* - This test must be compiled with -Werror; an important part of the test - is that we should get no warnings related to the const pointers. -*/ - -int main( int argc , char ** argv) { - const char * ptr1 = "Pointer1"; - const char * ptr2 = "Pointer2"; - - arg_pack_type * arg_pack = arg_pack_alloc(); - test_assert_int_equal( 0 , arg_pack_size( arg_pack )); - arg_pack_append_const_ptr( arg_pack , ptr1 ); - arg_pack_append_const_ptr( arg_pack , ptr2 ); - - test_assert_int_equal( 2 , arg_pack_size( arg_pack )); - test_assert_ptr_equal( ptr1 , arg_pack_iget_const_ptr( arg_pack , 0 )); - test_assert_ptr_equal( ptr2 , arg_pack_iget_const_ptr( arg_pack , 1 )); - - - - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_datetime.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_datetime.cpp index 2aec85faf6..2564784ee0 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_datetime.cpp +++ b/ThirdParty/Ert/lib/util/tests/ert_util_datetime.cpp @@ -21,8 +21,7 @@ #include #include -#include - +#include int main( int argc , char ** argv) { diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_struct_vector.cpp b/ThirdParty/Ert/lib/util/tests/ert_util_struct_vector.cpp deleted file mode 100644 index e0e63e5724..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_struct_vector.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'ert_util_struct_vector.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 - for more details. -*/ -#include -#include - -#include "ert/util/build_config.h" -#include -#include -#include - - - -struct test_struct { - int x; - double y; - int z; -}; - - - -void test_create() { - struct test_struct d; - struct_vector_type * struct_vector = struct_vector_alloc( sizeof d ); - test_assert_true( struct_vector_is_instance( struct_vector )); - test_assert_int_equal( struct_vector_get_size( struct_vector ) , 0 ); - struct_vector_reserve( struct_vector , 1000 ); - test_assert_int_equal( struct_vector_get_size( struct_vector ) , 0 ); - struct_vector_free( struct_vector ); -} - -void alloc_invalid(void * ) { - struct_vector_alloc( 0 ); -} - - -void test_create_invalid() { - test_assert_util_abort( "struct_vector_alloc" , alloc_invalid , NULL ); -} - -void test_append_iget() { - struct test_struct d1 = (struct test_struct) {.x = 100, .y = 99, .z = 234}; - struct test_struct d2 = (struct test_struct) {.x = 0, .y = 0, .z = 0}; - - struct_vector_type * struct_vector = struct_vector_alloc( sizeof d1 ); - - struct_vector_append( struct_vector , &d1 ); - test_assert_int_equal( struct_vector_get_size( struct_vector ) , 1 ); - struct_vector_reserve( struct_vector , 0 ); - test_assert_int_equal( struct_vector_get_size( struct_vector ) , 1 ); - - test_assert_false( d1.x == d2.x ); - test_assert_false( d1.y == d2.y ); - test_assert_false( d1.z == d2.z ); - - struct_vector_iget( struct_vector , 0 , &d2); - test_assert_true( d1.x == d2.x ); - test_assert_true( d1.y == d2.y ); - test_assert_true( d1.z == d2.z ); - - { - struct test_struct * d = (struct test_struct *) struct_vector_get_data( struct_vector ); - struct test_struct d3 = d[0]; - test_assert_true( d1.x == d3.x ); - test_assert_true( d1.y == d3.y ); - test_assert_true( d1.z == d3.z ); - } - struct_vector_reset( struct_vector ); - test_assert_int_equal( struct_vector_get_size( struct_vector ) , 0 ); - - struct_vector_free( struct_vector ); -} - - - -int cmp( const void * _d1, const void * _d2) { - const struct test_struct * d1 = (const struct test_struct *) _d1; - const struct test_struct * d2 = (const struct test_struct *) _d2; - - return d1->x - d2->x; -} - - -int rcmp( const void * _d1, const void * _d2) { - return cmp(_d2 , _d1); -} - - - -void test_sort() { - struct test_struct d; - struct_vector_type * struct_vector = struct_vector_alloc( sizeof d ); - for (int i = 0; i < 10; i++) { - struct test_struct d = {.x = 9 - i, - .y = 9.0 - i, - .z = 9 - i }; - struct_vector_append( struct_vector , &d ); - } - struct_vector_sort( struct_vector , cmp ); - for (int i = 0; i < 9; i++) { - struct test_struct d1; - struct test_struct d2; - struct_vector_iget( struct_vector , i ,&d1 ); - struct_vector_iget( struct_vector , i + 1,&d2 ); - test_assert_true( cmp(&d1 , &d2) <= 0); - } - - struct_vector_sort( struct_vector , rcmp ); - for (int i = 0; i < 9; i++) { - struct test_struct d1; - struct test_struct d2; - struct_vector_iget( struct_vector , i ,&d1 ); - struct_vector_iget( struct_vector , i + 1,&d2 ); - test_assert_true( cmp(&d1 , &d2) >= 0); - } -} - - - -int main(int argc , char ** argv) { - test_create(); - test_create_invalid(); - test_append_iget(); - test_sort(); -} diff --git a/ThirdParty/Ert/python/ecl/grid/ecl_grid.py b/ThirdParty/Ert/python/ecl/grid/ecl_grid.py index 1a923140ac..f6bedea44b 100644 --- a/ThirdParty/Ert/python/ecl/grid/ecl_grid.py +++ b/ThirdParty/Ert/python/ecl/grid/ecl_grid.py @@ -115,6 +115,7 @@ class EclGrid(BaseCClass): _export_zcorn = EclPrototype("ecl_kw_obj ecl_grid_alloc_zcorn_kw(ecl_grid)") _export_actnum = EclPrototype("ecl_kw_obj ecl_grid_alloc_actnum_kw(ecl_grid)") _export_mapaxes = EclPrototype("ecl_kw_obj ecl_grid_alloc_mapaxes_kw(ecl_grid)") + _get_unit_system = EclPrototype("ecl_unit_enum ecl_grid_get_unit_system(ecl_grid)") @@ -1147,15 +1148,14 @@ class EclGrid(BaseCClass): cfile = CFILE(pyfile) self._fprintf_grdecl2(cfile, output_unit) - def save_EGRID(self, filename, output_unit=EclUnitTypeEnum.ECL_METRIC_UNITS): - """ - Will save the current grid as a EGRID file. - """ - self._fwrite_EGRID2(filename, output_unit) + def save_EGRID(self, filename, output_unit=None): + if output_unit is None: + output_unit = self.unit_system + self._fwrite_EGRID2(filename, output_unit) def save_GRID(self, filename, output_unit=EclUnitTypeEnum.ECL_METRIC_UNITS): """ - Will save the current grid as a EGRID file. + Will save the current grid as a GRID file. """ self._fwrite_GRID2( filename, output_unit) @@ -1269,6 +1269,10 @@ class EclGrid(BaseCClass): return self._export_mapaxes() + @property + def unit_system(self): + return self._get_unit_system() + monkey_the_camel(EclGrid, 'loadFromGrdecl', EclGrid.load_from_grdecl, classmethod) monkey_the_camel(EclGrid, 'loadFromFile', EclGrid.load_from_file, classmethod) monkey_the_camel(EclGrid, 'createRectangular', EclGrid.create_rectangular, classmethod) diff --git a/ThirdParty/Ert/python/ecl/summary/ecl_sum.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum.py index 6e973dc1bc..029334836a 100644 --- a/ThirdParty/Ert/python/ecl/summary/ecl_sum.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum.py @@ -86,7 +86,7 @@ def date2num(dt): class EclSum(BaseCClass): TYPE_NAME = "ecl_sum" - _fread_alloc_case2 = EclPrototype("void* ecl_sum_fread_alloc_case2__(char*, char*, bool, bool)", bind=False) + _fread_alloc_case2 = EclPrototype("void* ecl_sum_fread_alloc_case2__(char*, char*, bool, bool, int)", bind=False) _fread_alloc = EclPrototype("void* ecl_sum_fread_alloc(char*, stringlist, char*, bool)", bind=False) _create_restart_writer = EclPrototype("ecl_sum_obj ecl_sum_alloc_restart_writer2(char*, char*, int, bool, bool, char*, time_t, bool, int, int, int)", bind = False) _create_writer = EclPrototype("ecl_sum_obj ecl_sum_alloc_writer(char*, bool, bool, char*, time_t, bool, int, int, int)", bind = False) @@ -149,7 +149,7 @@ class EclSum(BaseCClass): _init_numpy_datetime64 = EclPrototype("void ecl_sum_init_datetime64_vector(ecl_sum, int64*, int)") - def __init__(self, load_case, join_string=":", include_restart=True, lazy_load=True): + def __init__(self, load_case, join_string=":", include_restart=True, lazy_load=True, file_options=0): """Loads a new EclSum instance with summary data. Loads a new summary results from the ECLIPSE case given by @@ -171,12 +171,14 @@ class EclSum(BaseCClass): is actually requested. This will reduce startup time and memory usage, whereas getting a vector will be slower. When the summary data is split over multiple CASE.Snnn files all the data will be loaded at - construction time, and the @lazy_load option is ignored. + construction time, and the @lazy_load option is ignored. If the + lazy_load functionality is used the file_options intege flag is passed + when opening the UNSMRY file. """ if not load_case: raise ValueError('load_case must be the basename of the simulation') - c_pointer = self._fread_alloc_case2(load_case, join_string, include_restart, lazy_load) + c_pointer = self._fread_alloc_case2(load_case, join_string, include_restart, lazy_load, file_options) if c_pointer is None: raise IOError("Failed to create summary instance from argument:%s" % load_case) diff --git a/ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt index 8374950ce2..c3b4cf13d7 100644 --- a/ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt +++ b/ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt @@ -16,7 +16,6 @@ set(PYTHON_SOURCES vector_template.py permutation_vector.py version.py - arg_pack.py cwd_context.py ) diff --git a/ThirdParty/Ert/python/ecl/util/util/__init__.py b/ThirdParty/Ert/python/ecl/util/util/__init__.py index feccb678d1..aa5edf30b6 100644 --- a/ThirdParty/Ert/python/ecl/util/util/__init__.py +++ b/ThirdParty/Ert/python/ecl/util/util/__init__.py @@ -62,7 +62,6 @@ from .lookup_table import LookupTable from .hash import Hash, StringHash, DoubleHash, IntegerHash from .thread_pool import ThreadPool from .install_abort_signals import installAbortSignals, updateAbortSignals -from .arg_pack import ArgPack from .cwd_context import CWDContext diff --git a/ThirdParty/Ert/python/ert/util/__init__.py b/ThirdParty/Ert/python/ert/util/__init__.py index 48e2d7bff7..be7a5f4310 100644 --- a/ThirdParty/Ert/python/ert/util/__init__.py +++ b/ThirdParty/Ert/python/ert/util/__init__.py @@ -13,7 +13,6 @@ from ecl.util.util import LookupTable from ecl.util.util import Hash, StringHash, DoubleHash, IntegerHash from ecl.util.util import ThreadPool from ecl.util.util import installAbortSignals, updateAbortSignals -from ecl.util.util import ArgPack try: from res.util import SubstitutionList diff --git a/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt index 6444b8bfe3..ea6a3d2673 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt +++ b/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt @@ -14,6 +14,7 @@ set(TEST_SOURCES test_fault_blocks_statoil.py test_faults.py test_fortio.py + test_grdecl_statoil.py test_grdecl.py test_grid.py test_cell.py @@ -73,6 +74,7 @@ addPythonTest(tests.ecl_tests.test_debug.DebugTest) addPythonTest(tests.ecl_tests.test_ecl_file_statoil.EclFileStatoilTest) +addPythonTest(tests.ecl_tests.test_grdecl_statoil.GRDECLStatoilTest) addPythonTest(tests.ecl_tests.test_grdecl.GRDECLTest) addPythonTest(tests.ecl_tests.test_grid_statoil.GridTest) addPythonTest(tests.ecl_tests.test_ecl_kw_statoil.KWTest) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py index 6063c109e0..58337e00ef 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py @@ -1,7 +1,6 @@ -#!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. +# Copyright (C) 2018 Statoil ASA, Norway. # -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# The file 'test_grdecl.py' 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 @@ -16,110 +15,23 @@ # for more details. import os -from ecl.eclfile import EclKW, Ecl3DKW -from ecl.grid import EclGrid -from tests import EclTest, statoil_test +from ecl.eclfile import EclKW +from ecl.util.test import TestAreaContext +from tests import EclTest +import cwrap -from cwrap import open as copen - - -@statoil_test() class GRDECLTest(EclTest): - def setUp(self): - self.src_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/include/example_permx.GRDECL") - self.file_list = [] - def addFile(self, filename): - self.file_list.append(filename) + def test_64bit_memory(self): + with TestAreaContext("large_memory"): + block_size = 10**6 + with open("test.grdecl","w") as f: + f.write("COORD\n") + for i in range(1000): + f.write("%d*0.15 \n" % block_size) + f.write("/\n") - def tearDown(self): - for f in self.file_list: - if os.path.exists(f): - os.unlink(f) + with cwrap.open("test.grdecl") as f: + kw = EclKW.read_grdecl(f,"COORD") - def test_Load( self ): - kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") - self.assertTrue(kw) - - grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE" )) - kw = Ecl3DKW.read_grdecl(grid , copen(self.src_file, "r"), "PERMX") - self.assertTrue( isinstance( kw , Ecl3DKW )) - - - - def test_reload( self ): - kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") - tmp_file1 = "/tmp/permx1.grdecl" - tmp_file2 = "/tmp/permx2.grdecl" - self.addFile(tmp_file1) - self.addFile(tmp_file2) - - fileH = copen(tmp_file1, "w") - kw.write_grdecl(fileH) - fileH.close() - - kw1 = EclKW.read_grdecl(copen(tmp_file1, "r"), "PERMX") - - fileH = copen(tmp_file2, "w") - kw1.write_grdecl(fileH) - fileH.close() - - self.assertFilesAreEqual(tmp_file1, tmp_file2) - - - def test_fseek( self ): - file = copen(self.src_file, "r") - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) - file.close() - - file = copen(self.src_file, "r") - kw1 = EclKW.read_grdecl(file, "PERMX") - self.assertFalse(EclKW.fseek_grdecl(file, "PERMX")) - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) - file.close() - - - def test_fseek2(self): - test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl") - # Test kw at the the very start - file = copen(test_src, "r") - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) - - # Test commented out kw: - self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMZ")) - - # Test ignore not start of line: - self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) - - # Test rewind - self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) - - # Test multiline comments + blanks - self.assertTrue(EclKW.fseek_grdecl(file, "LASTKW")) - - - def test_fseek_dos(self): - test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl_dos") # File formatted with \r\n line endings. - # Test kw at the the very start - file = copen(test_src, "r") - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) - - # Test commented out kw: - self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMZ")) - - # Test ignore not start of line: - self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) - self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) - - # Test rewind - self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) - self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) - - # Test multiline comments + blanks - self.assertTrue(EclKW.fseek_grdecl(file, "LASTKW")) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl_statoil.py new file mode 100644 index 0000000000..a627d84cd9 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl_statoil.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' 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 +# for more details. + +import os +from ecl.eclfile import EclKW, Ecl3DKW +from ecl.grid import EclGrid +from tests import EclTest, statoil_test + +from cwrap import open as copen + + +@statoil_test() +class GRDECLStatoilTest(EclTest): + def setUp(self): + self.src_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/include/example_permx.GRDECL") + self.file_list = [] + + def addFile(self, filename): + self.file_list.append(filename) + + def tearDown(self): + for f in self.file_list: + if os.path.exists(f): + os.unlink(f) + + + def test_Load( self ): + kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") + self.assertTrue(kw) + + grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE" )) + kw = Ecl3DKW.read_grdecl(grid , copen(self.src_file, "r"), "PERMX") + self.assertTrue( isinstance( kw , Ecl3DKW )) + + + + def test_reload( self ): + kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") + tmp_file1 = "/tmp/permx1.grdecl" + tmp_file2 = "/tmp/permx2.grdecl" + self.addFile(tmp_file1) + self.addFile(tmp_file2) + + fileH = copen(tmp_file1, "w") + kw.write_grdecl(fileH) + fileH.close() + + kw1 = EclKW.read_grdecl(copen(tmp_file1, "r"), "PERMX") + + fileH = copen(tmp_file2, "w") + kw1.write_grdecl(fileH) + fileH.close() + + self.assertFilesAreEqual(tmp_file1, tmp_file2) + + + def test_fseek( self ): + file = copen(self.src_file, "r") + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) + self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) + file.close() + + file = copen(self.src_file, "r") + kw1 = EclKW.read_grdecl(file, "PERMX") + self.assertFalse(EclKW.fseek_grdecl(file, "PERMX")) + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) + file.close() + + + def test_fseek2(self): + test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl") + # Test kw at the the very start + file = copen(test_src, "r") + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) + + # Test commented out kw: + self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) + self.assertFalse(EclKW.fseek_grdecl(file, "PERMZ")) + + # Test ignore not start of line: + self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) + self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) + + # Test rewind + self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) + + # Test multiline comments + blanks + self.assertTrue(EclKW.fseek_grdecl(file, "LASTKW")) + + + def test_fseek_dos(self): + test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl_dos") # File formatted with \r\n line endings. + # Test kw at the the very start + file = copen(test_src, "r") + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) + + # Test commented out kw: + self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) + self.assertFalse(EclKW.fseek_grdecl(file, "PERMZ")) + + # Test ignore not start of line: + self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) + self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) + + # Test rewind + self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) + self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) + + # Test multiline comments + blanks + self.assertTrue(EclKW.fseek_grdecl(file, "LASTKW")) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py index 19f6be7295..04ee50a6c6 100644 --- a/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py @@ -25,7 +25,7 @@ from cwrap import Prototype from cwrap import open as copen import time -from ecl import EclDataType +from ecl import EclDataType, EclUnitTypeEnum from ecl.eclfile import EclKW, EclFile, openEclFile from ecl.grid import EclGrid from ecl.util.util import DoubleVector, IntVector diff --git a/ThirdParty/Ert/python/tests/legacy_tests/test_util.py b/ThirdParty/Ert/python/tests/legacy_tests/test_util.py index a52dd8f442..90d2d60df7 100644 --- a/ThirdParty/Ert/python/tests/legacy_tests/test_util.py +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_util.py @@ -13,7 +13,6 @@ from ert.util import LookupTable from ert.util import Hash, StringHash, DoubleHash, IntegerHash from ert.util import ThreadPool from ert.util import installAbortSignals, updateAbortSignals -from ert.util import ArgPack from tests import EclTest diff --git a/ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt index a14e586e39..cd68a8f3be 100644 --- a/ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt +++ b/ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt @@ -11,7 +11,6 @@ set(TEST_SOURCES test_version.py test_work_area.py test_path_context.py - test_arg_pack.py test_spawn.py ) @@ -27,6 +26,5 @@ addPythonTest(tests.util_tests.test_work_area.WorkAreaTest) addPythonTest(tests.util_tests.test_version.VersionTest) addPythonTest(tests.util_tests.test_path_context.PathContextTest) addPythonTest(tests.util_tests.test_thread_pool.ThreadPoolTest) -addPythonTest(tests.util_tests.test_arg_pack.ArgPackTest) addPythonTest(tests.util_tests.test_spawn.SpawnTest) #addPythonTest(tests.util.test_substitution_list.SubstitutionListTest) diff --git a/ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py b/ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py deleted file mode 100644 index 69f77c68b5..0000000000 --- a/ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py +++ /dev/null @@ -1,36 +0,0 @@ -import ecl -from ecl import EclPrototype -from tests import EclTest -from ecl.util.util import ArgPack, StringList - -TEST_LIB = EclPrototype.lib - - -class ArgPackTest(EclTest): - def test_create(self): - arg = ArgPack() - self.assertEqual(len(arg), 0) - - arg.append(StringList()) - self.assertEqual(len(arg), 1) - - arg.append(3.14) - self.assertEqual(len(arg), 2) - - o = object() - with self.assertRaises(TypeError): - arg.append(o) - - def test_args(self): - arg = ArgPack(1, 2, 3) - self.assertEqual(len(arg), 3) - - def test_append_ptr(self): - arg = ArgPack(StringList()) - self.assertEqual(len(arg), 1) - - func = getattr(TEST_LIB, "test_argpack_is_stringlist") - func.restype = None - func.argtypes = [ArgPack] - - func(arg)