mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Update libecl to 2e36798b43. For better memory usage reading wells
This commit is contained in:
parent
a362891d7e
commit
c8b329ddc3
@ -67,7 +67,7 @@ bool RifReaderEclipseSummary::open(const std::string& headerFileName, const std:
|
||||
}
|
||||
|
||||
std::string itemSeparatorInVariableNames = ":";
|
||||
m_ecl_sum = ecl_sum_fread_alloc(headerFileName.data(), dataFiles, itemSeparatorInVariableNames.data());
|
||||
m_ecl_sum = ecl_sum_fread_alloc(headerFileName.data(), dataFiles, itemSeparatorInVariableNames.data(), false);
|
||||
|
||||
stringlist_free(dataFiles);
|
||||
|
||||
|
@ -8,8 +8,7 @@ set(RESINSIGHT_INCREMENT_VERSION "2-dev.06")
|
||||
set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f")
|
||||
|
||||
# https://github.com/Statoil/libecl
|
||||
set(ERT_GITHUB_SHA "b17c5ffbf2f82594b01037d39ca9440252a10536")
|
||||
# Not completely shure this is the correct one. it might be db2b7317c instead or ...
|
||||
set(ERT_GITHUB_SHA "2e36798b43daf18c112b91aa3febbf2fccd4a95f")
|
||||
|
||||
# https://github.com/OPM/opm-flowdiagnostics
|
||||
set(OPM_FLOWDIAGNOSTICS_SHA "b6e59ddcd2feba450c8612a7402c9239e442c0d4")
|
||||
|
@ -8,4 +8,3 @@ _Short description of the approach_
|
||||
|
||||
**Pre un-WIP checklist**
|
||||
- [ ] Statoil tests pass locally
|
||||
- [ ] Have completed graphical integration test steps
|
||||
|
10
ThirdParty/Ert/.travis.yml
vendored
10
ThirdParty/Ert/.travis.yml
vendored
@ -16,13 +16,15 @@ env:
|
||||
global:
|
||||
- ERT_SHOW_BACKTRACE=1
|
||||
matrix:
|
||||
- PYTHON_VERSION=2.7; TEST_SUITE="-LE SLOW" # Run all tests not labeled as slow
|
||||
- PYTHON_VERSION=2.7; TEST_SUITE="-L SLOW_1" # Run all tests labeled as SLOW in group 1
|
||||
- PYTHON_VERSION=2.7; TEST_SUITE="-L SLOW_2" # Run all tests labeled as SLOW in group 2
|
||||
- PYTHON_VERSION=3.6; TEST_SUITE="-LE SLOW" # Run all tests not labeled as slow
|
||||
- PYTHON_VERSION=2.7 TEST_SUITE="-LE SLOW" # Run all tests not labeled as slow
|
||||
- PYTHON_VERSION=2.7 TEST_SUITE="-L SLOW_1" # Run all tests labeled as SLOW in group 1
|
||||
- PYTHON_VERSION=2.7 TEST_SUITE="-L SLOW_2" # Run all tests labeled as SLOW in group 2
|
||||
- PYTHON_VERSION=3.6 # Run all tests
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- env: PYTHON_VERSION=3.6
|
||||
exclude:
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
|
7
ThirdParty/Ert/CMakeLists.txt
vendored
7
ThirdParty/Ert/CMakeLists.txt
vendored
@ -10,7 +10,7 @@ endif()
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
set( ECL_VERSION_MAJOR 2 ) # Remember to update release notes whenever
|
||||
set( ECL_VERSION_MINOR 2 ) # you change the ERT_VERSION_MINOR or MAJOR
|
||||
set( ECL_VERSION_MINOR 3 ) # you change the ERT_VERSION_MINOR or MAJOR
|
||||
set( ECL_VERSION_MICRO git ) # with "new in Ert Version X.X.X"!
|
||||
|
||||
# If the micro version is not integer, that should be interpreted as a
|
||||
@ -357,9 +357,6 @@ if (BUILD_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)
|
||||
|
4
ThirdParty/Ert/README.md
vendored
4
ThirdParty/Ert/README.md
vendored
@ -25,8 +25,8 @@ functionality.
|
||||
*libecl* uses CMake as build system:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Statoil/*libecl*.git
|
||||
cd *libecl*
|
||||
git clone https://github.com/Statoil/libecl.git
|
||||
cd libecl
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
|
135
ThirdParty/Ert/applications/CMakeLists.txt
vendored
135
ThirdParty/Ert/applications/CMakeLists.txt
vendored
@ -1,59 +1,72 @@
|
||||
project(libecl-applications)
|
||||
|
||||
if (NOT BUILD_APPLICATIONS)
|
||||
return ()
|
||||
endif ()
|
||||
if (BUILD_APPLICATIONS)
|
||||
add_executable(sum_write ecl/sum_write.c)
|
||||
add_executable(make_grid ecl/make_grid.c)
|
||||
add_executable(grdecl_grid ecl/grdecl_grid.c)
|
||||
add_executable(summary ecl/view_summary.c)
|
||||
target_link_libraries(sum_write ecl)
|
||||
target_link_libraries(make_grid ecl)
|
||||
target_link_libraries(grdecl_grid ecl)
|
||||
target_link_libraries(summary ecl)
|
||||
|
||||
add_executable(sum_write ecl/sum_write.c)
|
||||
add_executable(make_grid ecl/make_grid.c)
|
||||
add_executable(grdecl_grid ecl/grdecl_grid.c)
|
||||
add_executable(summary ecl/view_summary.c)
|
||||
target_link_libraries(sum_write ecl)
|
||||
target_link_libraries(make_grid ecl)
|
||||
target_link_libraries(grdecl_grid ecl)
|
||||
target_link_libraries(summary ecl)
|
||||
list(APPEND apps make_grid grdecl_grid summary)
|
||||
|
||||
list(APPEND apps make_grid grdecl_grid summary)
|
||||
|
||||
foreach (app ecl_pack
|
||||
ecl_unpack
|
||||
kw_extract
|
||||
grid_info
|
||||
grid_dump
|
||||
grid_dump_ascii
|
||||
select_test
|
||||
load_test
|
||||
)
|
||||
add_executable(${app} ecl/${app}.c)
|
||||
target_link_libraries(${app} ecl)
|
||||
list(APPEND apps ${app})
|
||||
if (ERT_LINUX)
|
||||
# The stupid .x extension creates problems on windows
|
||||
set_target_properties(${app} PROPERTIES SUFFIX ".x")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
|
||||
if (ERT_LINUX)
|
||||
foreach (app convert esummary grdecl_test kw_list)
|
||||
foreach (app ecl_pack
|
||||
ecl_unpack
|
||||
kw_extract
|
||||
grid_info
|
||||
grid_dump
|
||||
grid_dump_ascii
|
||||
select_test
|
||||
load_test
|
||||
)
|
||||
add_executable(${app} ecl/${app}.c)
|
||||
target_link_libraries(${app} ecl)
|
||||
# The stupid .x extension creates problems on windows
|
||||
set_target_properties(${app} PROPERTIES SUFFIX ".x")
|
||||
list(APPEND apps ${app})
|
||||
if (ERT_LINUX)
|
||||
# The stupid .x extension creates problems on windows
|
||||
set_target_properties(${app} PROPERTIES SUFFIX ".x")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
set_target_properties(summary PROPERTIES SUFFIX ".x")
|
||||
endif ()
|
||||
|
||||
if (ERT_LINUX)
|
||||
foreach (app convert esummary grdecl_test kw_list)
|
||||
add_executable(${app} ecl/${app}.c)
|
||||
target_link_libraries(${app} ecl)
|
||||
# The stupid .x extension creates problems on windows
|
||||
set_target_properties(${app} PROPERTIES SUFFIX ".x")
|
||||
list(APPEND apps ${app})
|
||||
endforeach ()
|
||||
|
||||
set_target_properties(summary PROPERTIES SUFFIX ".x")
|
||||
endif ()
|
||||
|
||||
|
||||
# This minor eclipse application depends on the config parser library
|
||||
# and should be moved to the libres repository - it can not be
|
||||
# built here.
|
||||
if (BUILD_ERT)
|
||||
add_executable( ecl_quantile ecl/ecl_quantile.c )
|
||||
target_link_libraries( ecl_quantile config )
|
||||
list(APPEND apps ecl_quantile)
|
||||
# This minor eclipse application depends on the config parser library
|
||||
# and should be moved to the libres repository - it can not be
|
||||
# built here.
|
||||
if (BUILD_ERT)
|
||||
add_executable( ecl_quantile ecl/ecl_quantile.c )
|
||||
target_link_libraries( ecl_quantile config )
|
||||
list(APPEND apps ecl_quantile)
|
||||
endif()
|
||||
if (PTHREAD_LIBRARY)
|
||||
add_executable(bls block_fs/bls.c)
|
||||
target_link_libraries(bls ecl)
|
||||
list(APPEND apps bls)
|
||||
endif ()
|
||||
|
||||
add_executable(segment_info well/segment_info.c)
|
||||
add_executable(CF_dump well/well_CF_dump.c)
|
||||
add_executable(ri_well_test well/ri_well_test.c)
|
||||
|
||||
target_link_libraries(segment_info ecl)
|
||||
target_link_libraries(CF_dump ecl)
|
||||
target_link_libraries(ri_well_test ecl)
|
||||
|
||||
list(APPEND apps segment_info CF_dump ri_well_test)
|
||||
endif()
|
||||
|
||||
if (BUILD_ECL_SUMMARY)
|
||||
@ -65,23 +78,15 @@ if (BUILD_ECL_SUMMARY)
|
||||
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
||||
endif()
|
||||
|
||||
if (PTHREAD_LIBRARY)
|
||||
add_executable(bls block_fs/bls.c)
|
||||
target_link_libraries(bls ecl)
|
||||
list(APPEND apps bls)
|
||||
endif ()
|
||||
|
||||
add_executable(segment_info well/segment_info.c)
|
||||
add_executable(CF_dump well/well_CF_dump.c)
|
||||
add_executable(ri_well_test well/ri_well_test.c)
|
||||
|
||||
target_link_libraries(segment_info ecl)
|
||||
target_link_libraries(CF_dump ecl)
|
||||
target_link_libraries(ri_well_test ecl)
|
||||
|
||||
list(APPEND apps segment_info CF_dump ri_well_test)
|
||||
|
||||
install(TARGETS ${apps}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
if(apps)
|
||||
if (ERT_USE_OPENMP)
|
||||
foreach(app ${apps})
|
||||
target_compile_options(${app} PUBLIC ${OpenMP_C_FLAGS})
|
||||
set_property(TARGET ${app} APPEND PROPERTY LINK_FLAGS ${OpenMP_C_FLAGS})
|
||||
endforeach()
|
||||
endif()
|
||||
install(TARGETS ${apps}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
16
ThirdParty/Ert/debian/changelog
vendored
16
ThirdParty/Ert/debian/changelog
vendored
@ -1,17 +1,5 @@
|
||||
ert.ecl (1.0-4) precise; urgency=low
|
||||
ecl (2017.09-test1-1~xenial) xenial; urgency=low
|
||||
|
||||
* Unmark -dev package as architecture independent due to library symlink
|
||||
* New release
|
||||
|
||||
-- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Wed, 03 Apr 2013 17:49:24 +0200
|
||||
|
||||
ert.ecl (1.0-2) precise; urgency=low
|
||||
|
||||
* Mark -dev package as architecture independent
|
||||
|
||||
-- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Tue, 19 Feb 2013 10:03:04 +0100
|
||||
|
||||
ert.ecl (1.0-1) unstable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
||||
-- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Wed, 16 Jan 2013 11:21:17 +0100
|
||||
|
32
ThirdParty/Ert/debian/control
vendored
32
ThirdParty/Ert/debian/control
vendored
@ -1,4 +1,4 @@
|
||||
Source: ert.ecl
|
||||
Source: ecl
|
||||
Priority: extra
|
||||
Maintainer: Arne Morten Kvarving <arne.morten.kvarving@sintef.no>
|
||||
Build-Depends: debhelper (>= 8.0.0), cmake, liblapack-dev, libquadmath0,
|
||||
@ -9,33 +9,23 @@ Homepage: http://ert.nr.no
|
||||
Vcs-Git: git://github.com/Ensembles/ert.git
|
||||
Vcs-Browser: https://github.com/Ensembles/ert
|
||||
|
||||
Package: libert.ecl-dev
|
||||
Package: libecl-dev
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Depends: libert.ecl1 (= ${binary:Version})
|
||||
Description: The Ensemble based Reservoir Tool -- Development files
|
||||
ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble
|
||||
of reservoir models.
|
||||
Depends: libecl1 (= ${binary:Version}), libblas-dev, liblapack-dev
|
||||
Description: libecl Eclipse IO library -- Development files
|
||||
libecl is a package for reading and writing the result files from the Eclipse reservoir simulator.
|
||||
|
||||
Package: libert.ecl1
|
||||
Package: libecl1
|
||||
Section: libs
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: The Ensemble based Reservoir Tool
|
||||
ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble
|
||||
of reservoir models.
|
||||
Description: libecl Eclipse IO library
|
||||
libecl is a package for reading and writing the result files from the Eclipse reservoir simulator.
|
||||
|
||||
Package: python-ert.ecl
|
||||
Package: python-ecl
|
||||
Section: python
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, libert.ecl1, python-cwrap
|
||||
Description: The Ensemble based Reservoir Tool - Python bindings
|
||||
ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble
|
||||
of reservoir models.
|
||||
|
||||
Package: python-cwrap
|
||||
Section: python
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: Package to simplify ctypes based wrapping of C code.
|
||||
Package to simplify ctypes based wrapping of C code.
|
||||
Description: libecl Eclipse IO library - Python bindings
|
||||
libecl is a package for reading and writing the result files from the Eclipse reservoir simulator.
|
||||
|
@ -1,2 +1,3 @@
|
||||
usr/include/*
|
||||
usr/lib/*/*.so
|
||||
usr/share/cmake/ecl/*
|
1
ThirdParty/Ert/debian/python-cwrap.install
vendored
1
ThirdParty/Ert/debian/python-cwrap.install
vendored
@ -1 +0,0 @@
|
||||
usr/lib/python2.7/*/cwrap/*
|
1
ThirdParty/Ert/debian/python-ecl.install
vendored
Normal file
1
ThirdParty/Ert/debian/python-ecl.install
vendored
Normal file
@ -0,0 +1 @@
|
||||
usr/lib/python2.7/*/ecl/*
|
1
ThirdParty/Ert/debian/python-ert.ecl.install
vendored
1
ThirdParty/Ert/debian/python-ert.ecl.install
vendored
@ -1 +0,0 @@
|
||||
usr/lib/python2.7/*/ert/*
|
2
ThirdParty/Ert/debian/rules
vendored
2
ThirdParty/Ert/debian/rules
vendored
@ -13,4 +13,4 @@
|
||||
dh $@
|
||||
|
||||
override_dh_auto_configure:
|
||||
DESTDIR=$$(pwd)/debian/tmp dh_auto_configure -- -DBUILD_SHARED_LIBS=1 -DBUILD_ECL_SUMMARY=1 -DCMAKE_BUILD_TYPE=Release
|
||||
DESTDIR=$$(pwd)/debian/tmp dh_auto_configure -- -DBUILD_SHARED_LIBS=1 -DBUILD_ECL_SUMMARY=1 -DBUILD_PYTHON=1 -DCMAKE_BUILD_TYPE=Release
|
||||
|
51
ThirdParty/Ert/lib/CMakeLists.txt
vendored
51
ThirdParty/Ert/lib/CMakeLists.txt
vendored
@ -208,6 +208,7 @@ endif()
|
||||
|
||||
if (ERT_USE_OPENMP)
|
||||
target_compile_options(ecl PUBLIC ${OpenMP_C_FLAGS})
|
||||
set_property(TARGET ecl APPEND PROPERTY LINK_FLAGS ${OpenMP_C_FLAGS})
|
||||
target_link_libraries( ecl PUBLIC ${OpenMP_EXE_LINKER_FLAGS})
|
||||
endif ()
|
||||
|
||||
@ -215,32 +216,30 @@ 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}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(DIRECTORY include/
|
||||
DESTINATION include
|
||||
PATTERN *.h
|
||||
)
|
||||
install(DIRECTORY include/
|
||||
DESTINATION include
|
||||
PATTERN *.hpp EXCLUDE
|
||||
)
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
|
||||
DESTINATION include
|
||||
PATTERN *.h
|
||||
)
|
||||
install(TARGETS ecl
|
||||
EXPORT ecl-config
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(DIRECTORY include/
|
||||
DESTINATION include
|
||||
PATTERN *.h
|
||||
)
|
||||
install(DIRECTORY include/
|
||||
DESTINATION include
|
||||
PATTERN *.hpp EXCLUDE
|
||||
)
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
|
||||
DESTINATION include
|
||||
PATTERN *.h
|
||||
)
|
||||
|
||||
if (ERT_BUILD_CXX)
|
||||
install(DIRECTORY include/
|
||||
DESTINATION include
|
||||
PATTERN *.hpp
|
||||
)
|
||||
endif ()
|
||||
endif()
|
||||
if (ERT_BUILD_CXX)
|
||||
install(DIRECTORY include/
|
||||
DESTINATION include
|
||||
PATTERN *.hpp
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (NOT BUILD_TESTS)
|
||||
return ()
|
||||
@ -253,6 +252,7 @@ foreach (name ert_util_alloc_file_components
|
||||
ert_util_binary_split
|
||||
ert_util_buffer
|
||||
ert_util_clamp
|
||||
ert_util_chdir
|
||||
ert_util_filename
|
||||
ert_util_hash_test
|
||||
ert_util_logh
|
||||
@ -385,6 +385,7 @@ foreach (name ecl_alloc_cpgrid
|
||||
ecl_rft_cell
|
||||
ecl_file_view
|
||||
test_ecl_file_index
|
||||
test_transactions
|
||||
ecl_rst_file
|
||||
ecl_sum_writer
|
||||
ecl_util_make_date_no_shift
|
||||
|
4
ThirdParty/Ert/lib/ecl/ecl_file.c
vendored
4
ThirdParty/Ert/lib/ecl/ecl_file.c
vendored
@ -527,10 +527,8 @@ static bool ecl_file_scan( ecl_file_type * ecl_file ) {
|
||||
{
|
||||
offset_type current_offset = fortio_ftell( ecl_file->fortio );
|
||||
ecl_read_status_enum read_status = ecl_kw_fread_header( work_kw , ecl_file->fortio);
|
||||
if (read_status == ECL_KW_READ_FAIL) {
|
||||
printf("Skipping on read:%s \n", ecl_kw_get_header( work_kw ));
|
||||
if (read_status == ECL_KW_READ_FAIL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (read_status == ECL_KW_READ_OK) {
|
||||
ecl_file_kw_type * file_kw = ecl_file_kw_alloc( work_kw , current_offset);
|
||||
|
33
ThirdParty/Ert/lib/ecl/ecl_file_kw.c
vendored
33
ThirdParty/Ert/lib/ecl/ecl_file_kw.c
vendored
@ -59,6 +59,7 @@ struct ecl_file_kw_struct {
|
||||
offset_type file_offset;
|
||||
ecl_data_type data_type;
|
||||
int kw_size;
|
||||
int ref_count;
|
||||
char * header;
|
||||
ecl_kw_type * kw;
|
||||
};
|
||||
@ -143,6 +144,7 @@ ecl_file_kw_type * ecl_file_kw_alloc0( const char * header , ecl_data_type data_
|
||||
memcpy(&file_kw->data_type, &data_type, sizeof data_type);
|
||||
file_kw->kw_size = size;
|
||||
file_kw->file_offset = offset;
|
||||
file_kw->ref_count = 0;
|
||||
file_kw->kw = NULL;
|
||||
|
||||
return file_kw;
|
||||
@ -244,7 +246,17 @@ static void ecl_file_kw_load_kw( ecl_file_kw_type * file_kw , fortio_type * fort
|
||||
}
|
||||
}
|
||||
|
||||
ecl_kw_type * ecl_file_kw_get_kw_ptr( ecl_file_kw_type * file_kw , fortio_type * fortio , inv_map_type * inv_map ) {
|
||||
/*
|
||||
Calling scope will handle the NULL return value, and (optionally)
|
||||
reopen the fortio stream and then call the ecl_file_kw_get_kw()
|
||||
function.
|
||||
*/
|
||||
|
||||
ecl_kw_type * ecl_file_kw_get_kw_ptr( ecl_file_kw_type * file_kw) {
|
||||
if (file_kw->ref_count == 0)
|
||||
return NULL;
|
||||
|
||||
file_kw->ref_count++;
|
||||
return file_kw->kw;
|
||||
}
|
||||
|
||||
@ -264,9 +276,12 @@ ecl_kw_type * ecl_file_kw_get_kw_ptr( ecl_file_kw_type * file_kw , fortio_type *
|
||||
|
||||
|
||||
ecl_kw_type * ecl_file_kw_get_kw( ecl_file_kw_type * file_kw , fortio_type * fortio , inv_map_type * inv_map ) {
|
||||
if (file_kw->kw == NULL)
|
||||
if (file_kw->ref_count == 0)
|
||||
ecl_file_kw_load_kw( file_kw , fortio , inv_map);
|
||||
|
||||
if(file_kw->kw)
|
||||
file_kw->ref_count++;
|
||||
|
||||
return file_kw->kw;
|
||||
}
|
||||
|
||||
@ -422,3 +437,17 @@ ecl_file_kw_type * ecl_file_kw_fread_alloc( FILE * stream ) {
|
||||
|
||||
return file_kw;
|
||||
}
|
||||
|
||||
|
||||
void ecl_file_kw_start_transaction(const ecl_file_kw_type * file_kw, int * ref_count) {
|
||||
*ref_count = file_kw->ref_count;
|
||||
}
|
||||
|
||||
|
||||
void ecl_file_kw_end_transaction(ecl_file_kw_type * file_kw, int ref_count) {
|
||||
if (ref_count == 0 && file_kw->ref_count > 0) {
|
||||
ecl_kw_free(file_kw->kw);
|
||||
file_kw->kw = NULL;
|
||||
}
|
||||
file_kw->ref_count = ref_count;
|
||||
}
|
||||
|
55
ThirdParty/Ert/lib/ecl/ecl_file_view.c
vendored
55
ThirdParty/Ert/lib/ecl/ecl_file_view.c
vendored
@ -41,6 +41,10 @@ struct ecl_file_view_struct {
|
||||
int * flags;
|
||||
};
|
||||
|
||||
struct ecl_file_transaction_struct {
|
||||
const ecl_file_view_type * file_view;
|
||||
int * ref_count;
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
@ -146,10 +150,8 @@ void ecl_file_view_add_flag( ecl_file_view_type * file_view , int flag) {
|
||||
*file_view->flags |= flag;
|
||||
}
|
||||
|
||||
|
||||
ecl_kw_type * ecl_file_view_iget_kw( const ecl_file_view_type * ecl_file_view , int index) {
|
||||
ecl_file_kw_type * file_kw = ecl_file_view_iget_file_kw( ecl_file_view , index );
|
||||
ecl_kw_type * ecl_kw = ecl_file_kw_get_kw_ptr( file_kw , ecl_file_view->fortio , ecl_file_view->inv_map);
|
||||
static ecl_kw_type * ecl_file_view_get_kw(const ecl_file_view_type * ecl_file_view, ecl_file_kw_type * file_kw) {
|
||||
ecl_kw_type * ecl_kw = ecl_file_kw_get_kw_ptr( file_kw );
|
||||
if (!ecl_kw) {
|
||||
if (fortio_assert_stream_open( ecl_file_view->fortio )) {
|
||||
|
||||
@ -162,6 +164,11 @@ ecl_kw_type * ecl_file_view_iget_kw( const ecl_file_view_type * ecl_file_view ,
|
||||
return ecl_kw;
|
||||
}
|
||||
|
||||
ecl_kw_type * ecl_file_view_iget_kw( const ecl_file_view_type * ecl_file_view , int index) {
|
||||
ecl_file_kw_type * file_kw = ecl_file_view_iget_file_kw( ecl_file_view , index );
|
||||
return ecl_file_view_get_kw(ecl_file_view, file_kw);
|
||||
}
|
||||
|
||||
void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, const char* kw, int index, const int_vector_type * index_map, char* buffer) {
|
||||
ecl_file_kw_type * file_kw = ecl_file_view_iget_named_file_kw( ecl_file_view , kw , index);
|
||||
|
||||
@ -223,17 +230,7 @@ const char * ecl_file_view_iget_header( const ecl_file_view_type * ecl_file_view
|
||||
|
||||
ecl_kw_type * ecl_file_view_iget_named_kw( const ecl_file_view_type * ecl_file_view , const char * kw, int ith) {
|
||||
ecl_file_kw_type * file_kw = ecl_file_view_iget_named_file_kw( ecl_file_view , kw , ith);
|
||||
ecl_kw_type * ecl_kw = ecl_file_kw_get_kw_ptr( file_kw , ecl_file_view->fortio , ecl_file_view->inv_map );
|
||||
if (!ecl_kw) {
|
||||
if (fortio_assert_stream_open( ecl_file_view->fortio )) {
|
||||
|
||||
ecl_kw = ecl_file_kw_get_kw( file_kw , ecl_file_view->fortio , ecl_file_view->inv_map);
|
||||
|
||||
if (ecl_file_view_flags_set( ecl_file_view , ECL_FILE_CLOSE_STREAM))
|
||||
fortio_fclose_stream( ecl_file_view->fortio );
|
||||
}
|
||||
}
|
||||
return ecl_kw;
|
||||
return ecl_file_view_get_kw(ecl_file_view, file_kw);
|
||||
}
|
||||
|
||||
ecl_data_type ecl_file_view_iget_named_data_type( const ecl_file_view_type * ecl_file_view , const char * kw , int ith) {
|
||||
@ -806,6 +803,32 @@ ecl_file_view_type * ecl_file_view_fread_alloc( fortio_type * fortio , int * fla
|
||||
fprintf(stderr, "%s: error reading ecl_file_type index file.\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ecl_file_transaction_type * ecl_file_view_start_transaction(ecl_file_view_type * file_view) {
|
||||
ecl_file_transaction_type * t = util_malloc(sizeof * t);
|
||||
int size = ecl_file_view_get_size(file_view);
|
||||
t->file_view = file_view;
|
||||
t->ref_count = util_malloc( size * sizeof * t->ref_count );
|
||||
for (int i = 0; i < size; i++) {
|
||||
ecl_file_kw_type * file_kw = ecl_file_view_iget_file_kw(file_view, i);
|
||||
ecl_file_kw_start_transaction(file_kw, &t->ref_count[i]);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
void ecl_file_view_end_transaction( ecl_file_view_type * file_view, ecl_file_transaction_type * transaction) {
|
||||
if (transaction->file_view != file_view)
|
||||
util_abort("%s: internal error - file_view / transaction mismatch\n",__func__);
|
||||
|
||||
const int * ref_count = transaction->ref_count;
|
||||
for (int i = 0; i < ecl_file_view_get_size(file_view); i++) {
|
||||
ecl_file_kw_type * file_kw = ecl_file_view_iget_file_kw(file_view, i);
|
||||
ecl_file_kw_end_transaction(file_kw, ref_count[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
283
ThirdParty/Ert/lib/ecl/ecl_grid.c
vendored
283
ThirdParty/Ert/lib/ecl/ecl_grid.c
vendored
@ -806,7 +806,11 @@ static void ecl_cell_dump( const ecl_cell_type * cell , FILE * stream) {
|
||||
static void ecl_cell_assert_center( ecl_cell_type * cell);
|
||||
|
||||
static void ecl_cell_dump_ascii( ecl_cell_type * cell , int i , int j , int k , FILE * stream , const double * offset) {
|
||||
fprintf(stream , "Cell: i:%3d j:%3d k:%3d host_cell:%d CoarseGroup:%4d active_nr:%6d active:%d \nCorners:\n",i,j,k,cell->host_cell, cell->coarse_group , cell->active_index[MATRIX_INDEX], cell->active);
|
||||
fprintf(stream, "Cell: i:%3d j:%3d k:%3d host_cell:%d CoarseGroup:%4d active_nr:%6d active:%d \nCorners:\n",
|
||||
i, j, k,
|
||||
cell->host_cell, cell->coarse_group,
|
||||
cell->active_index[MATRIX_INDEX],
|
||||
cell->active);
|
||||
|
||||
ecl_cell_assert_center( cell );
|
||||
fprintf(stream , "Center : ");
|
||||
@ -825,7 +829,17 @@ static void ecl_cell_dump_ascii( ecl_cell_type * cell , int i , int j , int k ,
|
||||
}
|
||||
|
||||
|
||||
static void ecl_cell_fwrite_GRID( const ecl_grid_type * grid , const ecl_cell_type * cell , bool fracture_cell , int coords_size , int i, int j , int k , int global_index , ecl_kw_type * coords_kw , ecl_kw_type * corners_kw, fortio_type * fortio) {
|
||||
static void ecl_cell_fwrite_GRID(const ecl_grid_type * grid,
|
||||
const ecl_cell_type * cell,
|
||||
bool fracture_cell,
|
||||
int coords_size,
|
||||
int i,
|
||||
int j,
|
||||
int k,
|
||||
int global_index,
|
||||
ecl_kw_type * coords_kw,
|
||||
ecl_kw_type * corners_kw,
|
||||
fortio_type * fortio) {
|
||||
ecl_kw_iset_int( coords_kw , 0 , i + 1);
|
||||
ecl_kw_iset_int( coords_kw , 1 , j + 1);
|
||||
ecl_kw_iset_int( coords_kw , 2 , k + 1);
|
||||
@ -1330,12 +1344,17 @@ static double ecl_cell_get_volume( ecl_cell_type * cell ) {
|
||||
|
||||
|
||||
|
||||
static double triangle_area(double x1 , double y1 , double x2 , double y2 , double x3 ,double y3) {
|
||||
static double triangle_area(double x1, double y1,
|
||||
double x2, double y2,
|
||||
double x3, double y3) {
|
||||
return fabs(x1*y2 + x2*y3 + x3*y1 - x1*y3 - x3*y2 - x2*y1)*0.5;
|
||||
}
|
||||
|
||||
|
||||
static bool triangle_contains(const point_type *p0 , const point_type * p1 , const point_type *p2 , double x , double y) {
|
||||
static bool triangle_contains(const point_type *p0,
|
||||
const point_type *p1,
|
||||
const point_type *p2,
|
||||
double x, double y) {
|
||||
double epsilon = 1e-10;
|
||||
|
||||
double vt = triangle_area(p0->x , p0->y,
|
||||
@ -1381,7 +1400,10 @@ static double parallelogram_area3d(const point_type * p0, const point_type * p1,
|
||||
* p0, p1 and p2. Note that if the triangle is a line, the function will still
|
||||
* return true if the point lies on the line segment.
|
||||
*/
|
||||
static bool triangle_contains3d(const point_type *p0 , const point_type * p1 , const point_type *p2 , const point_type *p) {
|
||||
static bool triangle_contains3d(const point_type *p0,
|
||||
const point_type *p1,
|
||||
const point_type *p2,
|
||||
const point_type *p) {
|
||||
double epsilon = 1e-10;
|
||||
double vt = parallelogram_area3d(p0, p1, p2);
|
||||
|
||||
@ -1425,7 +1447,10 @@ static bool triangle_contains3d(const point_type *p0 , const point_type * p1 , c
|
||||
*/
|
||||
|
||||
|
||||
static bool ecl_cell_layer_contains_xy( const ecl_cell_type * cell , bool lower_layer , double x , double y) {
|
||||
static bool ecl_cell_layer_contains_xy(const ecl_cell_type * cell,
|
||||
bool lower_layer,
|
||||
double x,
|
||||
double y) {
|
||||
if (GET_CELL_FLAG(cell,CELL_FLAG_TAINTED))
|
||||
return false;
|
||||
{
|
||||
@ -1459,7 +1484,16 @@ static bool ecl_cell_layer_contains_xy( const ecl_cell_type * cell , bool lower_
|
||||
| | | |
|
||||
0---1 4---5
|
||||
*/
|
||||
static void ecl_cell_init_regular( ecl_cell_type * cell , const double * offset , int i , int j , int k , int global_index , const double * ivec , const double * jvec , const double * kvec , const int * actnum ) {
|
||||
static void ecl_cell_init_regular(ecl_cell_type * cell,
|
||||
const double * offset,
|
||||
int i,
|
||||
int j,
|
||||
int k,
|
||||
int global_index,
|
||||
const double * ivec,
|
||||
const double * jvec,
|
||||
const double * kvec,
|
||||
const int * actnum) {
|
||||
point_set(&cell->corner_list[0] , offset[0] , offset[1] , offset[2] ); // Point 0
|
||||
|
||||
cell->corner_list[1] = cell->corner_list[0]; // Point 1
|
||||
@ -1498,7 +1532,8 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_grid , ECL_GRID_ID);
|
||||
|
||||
|
||||
|
||||
static ecl_cell_type * ecl_grid_get_cell(const ecl_grid_type * grid , int global_index) {
|
||||
static ecl_cell_type * ecl_grid_get_cell(const ecl_grid_type * grid,
|
||||
int global_index) {
|
||||
return &grid->cells[global_index];
|
||||
}
|
||||
|
||||
@ -1558,7 +1593,13 @@ static bool ecl_grid_alloc_cells( ecl_grid_type * grid , bool init_valid) {
|
||||
is performed.
|
||||
*/
|
||||
|
||||
static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int dualp_flag , int nx , int ny , int nz, int lgr_nr, bool init_valid) {
|
||||
static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid,
|
||||
int dualp_flag,
|
||||
int nx,
|
||||
int ny,
|
||||
int nz,
|
||||
int lgr_nr,
|
||||
bool init_valid) {
|
||||
ecl_grid_type * grid = util_malloc(sizeof * grid );
|
||||
UTIL_TYPE_ID_INIT(grid , ECL_GRID_ID);
|
||||
grid->total_active = 0;
|
||||
@ -1635,7 +1676,10 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int du
|
||||
|
||||
|
||||
|
||||
static int ecl_grid_get_global_index__(const ecl_grid_type * ecl_grid , int i , int j , int k) {
|
||||
static int ecl_grid_get_global_index__(const ecl_grid_type * ecl_grid,
|
||||
int i,
|
||||
int j,
|
||||
int k) {
|
||||
return i + j * ecl_grid->nx + k * ecl_grid->nx * ecl_grid->ny;
|
||||
}
|
||||
|
||||
@ -1677,7 +1721,10 @@ static void ecl_grid_set_cell_EGRID(ecl_grid_type * ecl_grid , int i, int j , in
|
||||
}
|
||||
|
||||
|
||||
static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size , const int * coords , const float * corners) {
|
||||
static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid,
|
||||
int coords_size,
|
||||
const int * coords,
|
||||
const float * corners) {
|
||||
|
||||
const int i = coords[0] - 1; /* eclipse 1 offset */
|
||||
const int j = coords[1] - 1;
|
||||
@ -1776,10 +1823,12 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size ,
|
||||
ecl_grid->total_active is correct.
|
||||
*/
|
||||
|
||||
static void ecl_grid_init_index_map__( ecl_grid_type * ecl_grid , int * index_map , int * inv_index_map , int active_mask, int type_index) {
|
||||
int global_index;
|
||||
|
||||
for (global_index = 0; global_index < ecl_grid->size; global_index++) {
|
||||
static void ecl_grid_init_index_map__(ecl_grid_type * ecl_grid,
|
||||
int * index_map,
|
||||
int * inv_index_map,
|
||||
int active_mask,
|
||||
int type_index) {
|
||||
for (int global_index = 0; global_index < ecl_grid->size; global_index++) {
|
||||
const ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index);
|
||||
if (cell->active & active_mask) {
|
||||
index_map[global_index] = cell->active_index[type_index];
|
||||
@ -1796,56 +1845,63 @@ static void ecl_grid_init_index_map__( ecl_grid_type * ecl_grid , int * index_ma
|
||||
|
||||
static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) {
|
||||
/* Creating the inverse mapping for the matrix cells. */
|
||||
{
|
||||
ecl_grid->index_map = util_realloc(ecl_grid->index_map , ecl_grid->size * sizeof * ecl_grid->index_map );
|
||||
ecl_grid->inv_index_map = util_realloc(ecl_grid->inv_index_map , ecl_grid->total_active * sizeof * ecl_grid->inv_index_map );
|
||||
ecl_grid_init_index_map__( ecl_grid , ecl_grid->index_map , ecl_grid->inv_index_map , CELL_ACTIVE_MATRIX , MATRIX_INDEX);
|
||||
}
|
||||
ecl_grid->index_map = util_realloc(ecl_grid->index_map,
|
||||
ecl_grid->size * sizeof * ecl_grid->index_map);
|
||||
ecl_grid->inv_index_map = util_realloc(ecl_grid->inv_index_map,
|
||||
ecl_grid->total_active * sizeof * ecl_grid->inv_index_map);
|
||||
ecl_grid_init_index_map__(ecl_grid,
|
||||
ecl_grid->index_map,
|
||||
ecl_grid->inv_index_map,
|
||||
CELL_ACTIVE_MATRIX,
|
||||
MATRIX_INDEX);
|
||||
|
||||
|
||||
/* Create the inverse mapping for the fractures. */
|
||||
if (ecl_grid->dualp_flag != FILEHEAD_SINGLE_POROSITY) {
|
||||
ecl_grid->fracture_index_map = util_realloc(ecl_grid->fracture_index_map , ecl_grid->size * sizeof * ecl_grid->fracture_index_map );
|
||||
ecl_grid->inv_fracture_index_map = util_realloc(ecl_grid->inv_fracture_index_map , ecl_grid->total_active_fracture * sizeof * ecl_grid->inv_fracture_index_map );
|
||||
ecl_grid_init_index_map__( ecl_grid , ecl_grid->fracture_index_map , ecl_grid->inv_fracture_index_map , CELL_ACTIVE_FRACTURE , FRACTURE_INDEX);
|
||||
ecl_grid->fracture_index_map = util_realloc(ecl_grid->fracture_index_map,
|
||||
ecl_grid->size * sizeof * ecl_grid->fracture_index_map);
|
||||
ecl_grid->inv_fracture_index_map = util_realloc(ecl_grid->inv_fracture_index_map,
|
||||
ecl_grid->total_active_fracture * sizeof * ecl_grid->inv_fracture_index_map);
|
||||
ecl_grid_init_index_map__(ecl_grid,
|
||||
ecl_grid->fracture_index_map,
|
||||
ecl_grid->inv_fracture_index_map,
|
||||
CELL_ACTIVE_FRACTURE,
|
||||
FRACTURE_INDEX);
|
||||
}
|
||||
|
||||
|
||||
/* Update the inverse map in the case of coarse cells. Observe that
|
||||
in the case of coarse cells with more than one active cell in the
|
||||
main grid, the inverse active -> global mapping will map to the
|
||||
first active cell in the coarse cell. */
|
||||
{
|
||||
int coarse_group;
|
||||
for (coarse_group = 0; coarse_group < ecl_grid_get_num_coarse_groups( ecl_grid ); coarse_group++) {
|
||||
ecl_coarse_cell_type * coarse_cell = ecl_grid_iget_coarse_group( ecl_grid , coarse_group );
|
||||
if (ecl_coarse_cell_get_num_active( coarse_cell ) > 0) {
|
||||
int global_index = ecl_coarse_cell_iget_active_cell_index( coarse_cell , 0 );
|
||||
int active_value = ecl_coarse_cell_iget_active_value( coarse_cell , 0 );
|
||||
int active_index = ecl_coarse_cell_get_active_index( coarse_cell );
|
||||
int active_fracture_index = ecl_coarse_cell_get_active_fracture_index( coarse_cell );
|
||||
first active cell in the coarse cell.
|
||||
*/
|
||||
int size = ecl_grid_get_num_coarse_groups(ecl_grid);
|
||||
for (int coarse_group = 0; coarse_group < size; coarse_group++) {
|
||||
ecl_coarse_cell_type * coarse_cell = ecl_grid_iget_coarse_group(ecl_grid, coarse_group);
|
||||
if (ecl_coarse_cell_get_num_active(coarse_cell) > 0) {
|
||||
int global_index = ecl_coarse_cell_iget_active_cell_index(coarse_cell, 0);
|
||||
int active_value = ecl_coarse_cell_iget_active_value(coarse_cell, 0);
|
||||
int active_index = ecl_coarse_cell_get_active_index(coarse_cell);
|
||||
int active_fracture_index = ecl_coarse_cell_get_active_fracture_index(coarse_cell);
|
||||
|
||||
if (active_value & CELL_ACTIVE_MATRIX)
|
||||
ecl_grid->inv_index_map[ active_index ] = global_index; // The active -> global mapping point to one "random" cell in the coarse group
|
||||
if (active_value & CELL_ACTIVE_MATRIX) // active->global mapping point to one "random" cell in the coarse group
|
||||
ecl_grid->inv_index_map[active_index] = global_index;
|
||||
|
||||
if (active_value & CELL_ACTIVE_FRACTURE)
|
||||
ecl_grid->inv_fracture_index_map[active_fracture_index] = global_index;
|
||||
|
||||
int coarse_size = ecl_coarse_cell_get_size(coarse_cell);
|
||||
const int_vector_type * global_index_list = ecl_coarse_cell_get_index_vector(coarse_cell);
|
||||
for (int ic = 0; ic < coarse_size; ic++) {
|
||||
int gi = int_vector_iget(global_index_list, ic);
|
||||
|
||||
if (active_value & CELL_ACTIVE_MATRIX) // All cells in the coarse group point to the same active index.
|
||||
ecl_grid->index_map[gi] = active_index;
|
||||
|
||||
if (active_value & CELL_ACTIVE_FRACTURE)
|
||||
ecl_grid->inv_fracture_index_map[ active_fracture_index ] = global_index;
|
||||
|
||||
{
|
||||
int coarse_size = ecl_coarse_cell_get_size( coarse_cell );
|
||||
const int_vector_type * global_index_list = ecl_coarse_cell_get_index_vector( coarse_cell );
|
||||
int ic;
|
||||
for (ic =0; ic < coarse_size; ic++) {
|
||||
int gi = int_vector_iget( global_index_list , ic );
|
||||
|
||||
if (active_value & CELL_ACTIVE_MATRIX)
|
||||
ecl_grid->index_map[ gi ] = active_index; // All the cells in the coarse group point to the same active index.
|
||||
|
||||
if (active_value & CELL_ACTIVE_FRACTURE)
|
||||
ecl_grid->fracture_index_map[ gi ] = active_fracture_index;
|
||||
}
|
||||
}
|
||||
} // else the coarse cell does not have any active cells.
|
||||
}
|
||||
ecl_grid->fracture_index_map[gi] = active_fracture_index;
|
||||
}
|
||||
} // else the coarse cell does not have any active cells.
|
||||
}
|
||||
}
|
||||
|
||||
@ -1865,14 +1921,12 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) {
|
||||
if (!ecl_grid_have_coarse_cells( ecl_grid )) {
|
||||
/* Keeping a fast path for the 99% most common case of no coarse
|
||||
groups and single porosity. */
|
||||
{
|
||||
for (global_index = 0; global_index < ecl_grid->size; global_index++) {
|
||||
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index);
|
||||
for (global_index = 0; global_index < ecl_grid->size; global_index++) {
|
||||
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index);
|
||||
|
||||
if (cell->active & CELL_ACTIVE_MATRIX) {
|
||||
cell->active_index[MATRIX_INDEX] = active_index;
|
||||
active_index++;
|
||||
}
|
||||
if (cell->active & CELL_ACTIVE_MATRIX) {
|
||||
cell->active_index[MATRIX_INDEX] = active_index;
|
||||
active_index++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1909,7 +1963,11 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) {
|
||||
|
||||
} else {
|
||||
ecl_coarse_cell_type * coarse_cell = ecl_grid_iget_coarse_group( ecl_grid , cell->coarse_group );
|
||||
ecl_coarse_cell_update_index( coarse_cell , global_index , &active_index , &active_fracture_index , cell->active);
|
||||
ecl_coarse_cell_update_index(coarse_cell,
|
||||
global_index,
|
||||
&active_index,
|
||||
&active_fracture_index,
|
||||
cell->active);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1920,33 +1978,29 @@ static void ecl_grid_set_active_index(ecl_grid_type * ecl_grid) {
|
||||
active value of all the cells in the coarse cell to the
|
||||
common value for the coarse cell.
|
||||
*/
|
||||
{
|
||||
int coarse_group;
|
||||
for (coarse_group = 0; coarse_group < ecl_grid_get_num_coarse_groups( ecl_grid ); coarse_group++) {
|
||||
ecl_coarse_cell_type * coarse_cell = ecl_grid_iget_coarse_group( ecl_grid , coarse_group );
|
||||
if (ecl_coarse_cell_get_num_active(coarse_cell) > 0) {
|
||||
int cell_active_index = ecl_coarse_cell_get_active_index( coarse_cell );
|
||||
int cell_active_value = ecl_coarse_cell_iget_active_value( coarse_cell , 0);
|
||||
int group_size = ecl_coarse_cell_get_size( coarse_cell );
|
||||
const int * coarse_cell_list = ecl_coarse_cell_get_index_ptr( coarse_cell );
|
||||
int i;
|
||||
|
||||
for (i=0; i < group_size; i++) {
|
||||
global_index = coarse_cell_list[i];
|
||||
{
|
||||
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index );
|
||||
int size = ecl_grid_get_num_coarse_groups(ecl_grid);
|
||||
for (int coarse_group = 0; coarse_group < size; coarse_group++) {
|
||||
ecl_coarse_cell_type * coarse_cell = ecl_grid_iget_coarse_group( ecl_grid , coarse_group );
|
||||
if (ecl_coarse_cell_get_num_active(coarse_cell) > 0) {
|
||||
int cell_active_index = ecl_coarse_cell_get_active_index( coarse_cell );
|
||||
int cell_active_value = ecl_coarse_cell_iget_active_value( coarse_cell , 0);
|
||||
int group_size = ecl_coarse_cell_get_size( coarse_cell );
|
||||
const int * coarse_cell_list = ecl_coarse_cell_get_index_ptr( coarse_cell );
|
||||
|
||||
if (cell_active_value & CELL_ACTIVE_MATRIX)
|
||||
cell->active_index[MATRIX_INDEX] = cell_active_index;
|
||||
for (int i=0; i < group_size; i++) {
|
||||
global_index = coarse_cell_list[i];
|
||||
|
||||
/* Coarse cell and dual porosity - that is probably close to zero measure. */
|
||||
if (cell_active_value & CELL_ACTIVE_FRACTURE) {
|
||||
int cell_active_fracture_index = ecl_coarse_cell_get_active_fracture_index( coarse_cell );
|
||||
cell->active_index[FRACTURE_INDEX] = cell_active_fracture_index;
|
||||
}
|
||||
}
|
||||
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index );
|
||||
|
||||
if (cell_active_value & CELL_ACTIVE_MATRIX)
|
||||
cell->active_index[MATRIX_INDEX] = cell_active_index;
|
||||
|
||||
/* Coarse cell and dual porosity - that is probably close to zero measure. */
|
||||
if (cell_active_value & CELL_ACTIVE_FRACTURE) {
|
||||
int cell_active_fracture_index = ecl_coarse_cell_get_active_fracture_index( coarse_cell );
|
||||
cell->active_index[FRACTURE_INDEX] = cell_active_fracture_index;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2246,7 +2300,12 @@ int ecl_grid_zcorn_index(const ecl_grid_type * grid , int i, int j , int k , int
|
||||
}
|
||||
|
||||
|
||||
static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type * ecl_grid , const float * zcorn , const float * coord , const int * actnum, const int * corsnum , int j) {
|
||||
static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type * ecl_grid,
|
||||
const float * zcorn,
|
||||
const float * coord,
|
||||
const int * actnum,
|
||||
const int * corsnum,
|
||||
int j) {
|
||||
const int nx = ecl_grid->nx;
|
||||
const int ny = ecl_grid->ny;
|
||||
const int nz = ecl_grid->nz;
|
||||
@ -2316,7 +2375,11 @@ static void ecl_grid_init_GRDECL_data_jslice(ecl_grid_type * ecl_grid , const f
|
||||
}
|
||||
|
||||
|
||||
void ecl_grid_init_GRDECL_data(ecl_grid_type * ecl_grid , const float * zcorn , const float * coord , const int * actnum, const int * corsnum) {
|
||||
void ecl_grid_init_GRDECL_data(ecl_grid_type * ecl_grid,
|
||||
const float * zcorn,
|
||||
const float * coord,
|
||||
const int * actnum,
|
||||
const int * corsnum) {
|
||||
const int ny = ecl_grid->ny;
|
||||
int j;
|
||||
#pragma omp parallel for
|
||||
@ -2332,9 +2395,17 @@ void ecl_grid_init_GRDECL_data(ecl_grid_type * ecl_grid , const float * zcorn ,
|
||||
0---1
|
||||
*/
|
||||
|
||||
static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid ,
|
||||
int dualp_flag , bool apply_mapaxes, int nx , int ny , int nz ,
|
||||
const float * zcorn , const float * coord , const int * actnum, const float * mapaxes, const int * corsnum,
|
||||
static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid,
|
||||
int dualp_flag,
|
||||
bool apply_mapaxes,
|
||||
int nx,
|
||||
int ny,
|
||||
int nz,
|
||||
const float * zcorn,
|
||||
const float * coord,
|
||||
const int * actnum,
|
||||
const float * mapaxes,
|
||||
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);
|
||||
@ -2488,8 +2559,26 @@ ecl_grid_type * ecl_grid_alloc_processed_copy( const ecl_grid_type * src_grid ,
|
||||
a lgr hierarchy - or cell coarsening.
|
||||
*/
|
||||
|
||||
ecl_grid_type * ecl_grid_alloc_GRDECL_data(int nx , int ny , int nz , const float * zcorn , const float * coord , const int * actnum, bool apply_mapaxes , const float * mapaxes) {
|
||||
return ecl_grid_alloc_GRDECL_data__(NULL , FILEHEAD_SINGLE_POROSITY , apply_mapaxes , nx , ny , nz , zcorn , coord , actnum , mapaxes , NULL , 0);
|
||||
ecl_grid_type * ecl_grid_alloc_GRDECL_data(int nx,
|
||||
int ny,
|
||||
int nz,
|
||||
const float * zcorn,
|
||||
const float * coord,
|
||||
const int * actnum,
|
||||
bool apply_mapaxes,
|
||||
const float * mapaxes) {
|
||||
return ecl_grid_alloc_GRDECL_data__(NULL,
|
||||
FILEHEAD_SINGLE_POROSITY,
|
||||
apply_mapaxes,
|
||||
nx,
|
||||
ny,
|
||||
nz,
|
||||
zcorn,
|
||||
coord,
|
||||
actnum,
|
||||
mapaxes,
|
||||
NULL,
|
||||
0);
|
||||
}
|
||||
|
||||
|
||||
@ -2581,8 +2670,16 @@ ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz ,
|
||||
const ecl_kw_type * mapaxes_kw ) { /* Can be NULL */
|
||||
|
||||
bool apply_mapaxes = true;
|
||||
ecl_kw_type * gridhead_kw = ecl_grid_alloc_gridhead_kw( nx , ny , nz , 0);
|
||||
ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__(NULL , FILEHEAD_SINGLE_POROSITY , apply_mapaxes , gridhead_kw , zcorn_kw , coord_kw , actnum_kw , mapaxes_kw , NULL);
|
||||
ecl_kw_type * gridhead_kw = ecl_grid_alloc_gridhead_kw( nx, ny, nz, 0);
|
||||
ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__(NULL,
|
||||
FILEHEAD_SINGLE_POROSITY,
|
||||
apply_mapaxes,
|
||||
gridhead_kw,
|
||||
zcorn_kw,
|
||||
coord_kw,
|
||||
actnum_kw,
|
||||
mapaxes_kw,
|
||||
NULL);
|
||||
ecl_kw_free( gridhead_kw );
|
||||
return ecl_grid;
|
||||
|
||||
|
6
ThirdParty/Ert/lib/ecl/ecl_kw.c
vendored
6
ThirdParty/Ert/lib/ecl/ecl_kw.c
vendored
@ -1321,9 +1321,11 @@ ecl_read_status_enum ecl_kw_fread_header(ecl_kw_type *ecl_kw , fortio_type * for
|
||||
|
||||
int read_count = fscanf(stream , "%d" , &size);
|
||||
if (read_count != 1)
|
||||
util_abort("%s: reading failed - at end of file?\n",__func__);
|
||||
return ECL_KW_READ_FAIL;
|
||||
|
||||
if (!ecl_kw_fscanf_qstring(ecl_type_str , "%4c" , 4 , stream))
|
||||
return ECL_KW_READ_FAIL;
|
||||
|
||||
ecl_kw_fscanf_qstring(ecl_type_str , "%4c" , 4 , stream);
|
||||
fgetc(stream); /* Reading the trailing newline ... */
|
||||
}
|
||||
else {
|
||||
|
18
ThirdParty/Ert/lib/ecl/ecl_sum.c
vendored
18
ThirdParty/Ert/lib/ecl/ecl_sum.c
vendored
@ -172,13 +172,7 @@ static bool ecl_sum_fread_data( ecl_sum_type * ecl_sum , const stringlist_type *
|
||||
ecl_sum_free_data( ecl_sum );
|
||||
|
||||
ecl_sum->data = ecl_sum_data_alloc( ecl_sum->smspec );
|
||||
if (ecl_sum_data_fread( ecl_sum->data , data_files )) {
|
||||
if (include_restart) {
|
||||
|
||||
}
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
return ecl_sum_data_fread( ecl_sum->data , data_files);
|
||||
}
|
||||
|
||||
|
||||
@ -248,9 +242,12 @@ static bool ecl_sum_fread_case( ecl_sum_type * ecl_sum , bool include_restart) {
|
||||
*/
|
||||
|
||||
|
||||
ecl_sum_type * ecl_sum_fread_alloc(const char *header_file , const stringlist_type *data_files , const char * key_join_string) {
|
||||
ecl_sum_type * ecl_sum_fread_alloc(const char *header_file , const stringlist_type *data_files , const char * key_join_string, bool include_restart) {
|
||||
ecl_sum_type * ecl_sum = ecl_sum_alloc__( header_file , key_join_string );
|
||||
ecl_sum_fread( ecl_sum , header_file , data_files , false );
|
||||
if (!ecl_sum_fread( ecl_sum , header_file , data_files , include_restart)) {
|
||||
ecl_sum_free( ecl_sum );
|
||||
ecl_sum = NULL;
|
||||
}
|
||||
return ecl_sum;
|
||||
}
|
||||
|
||||
@ -665,6 +662,9 @@ double ecl_sum_get_general_var(const ecl_sum_type * ecl_sum , int time_index , c
|
||||
return ecl_sum_data_iget( ecl_sum->data , time_index , params_index);
|
||||
}
|
||||
|
||||
void ecl_sum_get_interp_vector(const ecl_sum_type * ecl_sum, time_t sim_time, const ecl_sum_vector_type * key_words, double_vector_type * data){
|
||||
ecl_sum_data_get_interp_vector(ecl_sum->data, sim_time, key_words, data);
|
||||
}
|
||||
|
||||
void ecl_sum_fwrite_interp_csv_line(const ecl_sum_type * ecl_sum, time_t sim_time, const ecl_sum_vector_type * key_words, FILE *fp){
|
||||
ecl_sum_data_fwrite_interp_csv_line(ecl_sum->data, sim_time, key_words, fp);
|
||||
|
46
ThirdParty/Ert/lib/ecl/ecl_sum_data.c
vendored
46
ThirdParty/Ert/lib/ecl/ecl_sum_data.c
vendored
@ -1017,10 +1017,10 @@ static bool ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , c
|
||||
}
|
||||
ecl_file_close( ecl_file );
|
||||
}
|
||||
} else
|
||||
util_abort("%s: invalid file type:%s \n",__func__ , ecl_util_file_type_name(file_type ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ecl_sum_data_get_length( data ) > 0) {
|
||||
ecl_sum_data_build_index( data );
|
||||
return true;
|
||||
@ -1180,6 +1180,23 @@ double ecl_sum_data_interp_get(const ecl_sum_data_type * data , int time_index1
|
||||
}
|
||||
|
||||
|
||||
static double ecl_sum_data_vector_iget(const ecl_sum_data_type * data, time_t sim_time, const ecl_sum_vector_type * keylist, int key_index,
|
||||
int time_index1 , int time_index2 , double weight1 , double weight2 ) {
|
||||
|
||||
int params_index = ecl_sum_vector_iget_param_index(keylist, key_index);
|
||||
double value = 0.0;
|
||||
bool is_rate = ecl_sum_vector_iget_is_rate(keylist, key_index);
|
||||
if (is_rate) {
|
||||
int time_index = ecl_sum_data_get_index_from_sim_time(data, sim_time);
|
||||
// uses step function since it is a rate
|
||||
value = ecl_sum_data_iget(data, time_index, params_index);
|
||||
} else {
|
||||
// uses interpolation between timesteps
|
||||
value = ecl_sum_data_interp_get(data, time_index1, time_index2, weight1, weight2, params_index);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type * data, time_t sim_time, const ecl_sum_vector_type * keylist, FILE *fp){
|
||||
int num_keywords = ecl_sum_vector_get_size(keylist);
|
||||
double weight1, weight2;
|
||||
@ -1188,18 +1205,7 @@ void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type * data, time_t
|
||||
ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, &time_index2, &weight1, &weight2);
|
||||
|
||||
for (int i = 0; i < num_keywords; i++) {
|
||||
int params_index = ecl_sum_vector_iget_param_index(keylist, i);
|
||||
|
||||
double value = 0.0;
|
||||
bool is_rate = ecl_sum_vector_iget_is_rate(keylist, i);
|
||||
if (is_rate) {
|
||||
int time_index = ecl_sum_data_get_index_from_sim_time(data, sim_time);
|
||||
// uses step function since it is a rate
|
||||
value = ecl_sum_data_iget(data, time_index, params_index);
|
||||
} else {
|
||||
// uses interpolation between timesteps
|
||||
value = ecl_sum_data_interp_get(data, time_index1, time_index2, weight1, weight2, params_index);
|
||||
}
|
||||
double value = ecl_sum_data_vector_iget( data, sim_time, keylist , i , time_index1, time_index2, weight1, weight2);
|
||||
|
||||
if (i == 0)
|
||||
fprintf(fp, "%f", value);
|
||||
@ -1208,8 +1214,18 @@ void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type * data, time_t
|
||||
}
|
||||
}
|
||||
|
||||
void ecl_sum_data_get_interp_vector( const ecl_sum_data_type * data , time_t sim_time, const ecl_sum_vector_type * keylist, double_vector_type * results){
|
||||
int num_keywords = ecl_sum_vector_get_size(keylist);
|
||||
double weight1, weight2;
|
||||
int time_index1, time_index2;
|
||||
|
||||
|
||||
ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, &time_index2, &weight1, &weight2);
|
||||
double_vector_reset( results );
|
||||
for (int i = 0; i < num_keywords; i++) {
|
||||
double value = ecl_sum_data_vector_iget( data, sim_time, keylist , i , time_index1, time_index2, weight1, weight2);
|
||||
double_vector_iset( results, i , value );
|
||||
}
|
||||
}
|
||||
|
||||
double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , const smspec_node_type * smspec_node) {
|
||||
int params_index = smspec_node_get_params_index( smspec_node );
|
||||
|
10
ThirdParty/Ert/lib/ecl/ecl_sum_vector.c
vendored
10
ThirdParty/Ert/lib/ecl/ecl_sum_vector.c
vendored
@ -33,6 +33,7 @@ struct ecl_sum_vector_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
int_vector_type * node_index_list;
|
||||
bool_vector_type * is_rate_list;
|
||||
stringlist_type * key_list;
|
||||
const ecl_sum_type * ecl_sum;
|
||||
};
|
||||
|
||||
@ -40,6 +41,7 @@ struct ecl_sum_vector_struct {
|
||||
void ecl_sum_vector_free( ecl_sum_vector_type * ecl_sum_vector ){
|
||||
int_vector_free(ecl_sum_vector->node_index_list);
|
||||
bool_vector_free(ecl_sum_vector->is_rate_list);
|
||||
stringlist_free(ecl_sum_vector->key_list);
|
||||
}
|
||||
|
||||
|
||||
@ -52,6 +54,7 @@ ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum){
|
||||
ecl_sum_vector->ecl_sum = ecl_sum;
|
||||
ecl_sum_vector->node_index_list = int_vector_alloc(0,0);
|
||||
ecl_sum_vector->is_rate_list = bool_vector_alloc(0,false);
|
||||
ecl_sum_vector->key_list = stringlist_alloc_new( );
|
||||
return ecl_sum_vector;
|
||||
}
|
||||
|
||||
@ -64,6 +67,7 @@ bool ecl_sum_vector_add_key( ecl_sum_vector_type * ecl_sum_vector, const char *
|
||||
|
||||
int_vector_append(ecl_sum_vector->node_index_list, params_index);
|
||||
bool_vector_append(ecl_sum_vector->is_rate_list, is_rate_key);
|
||||
stringlist_append_copy( ecl_sum_vector->key_list, key );
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
@ -84,6 +88,7 @@ void ecl_sum_vector_add_keys( ecl_sum_vector_type * ecl_sum_vector, const char *
|
||||
|
||||
int_vector_append(ecl_sum_vector->node_index_list, params_index);
|
||||
bool_vector_append(ecl_sum_vector->is_rate_list, is_rate_key);
|
||||
stringlist_append_copy( ecl_sum_vector->key_list, key );
|
||||
}
|
||||
stringlist_free(keylist);
|
||||
}
|
||||
@ -99,3 +104,8 @@ bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type * ecl_sum_vector, int
|
||||
int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type * ecl_sum_vector, int index){
|
||||
return int_vector_iget(ecl_sum_vector->node_index_list, index);
|
||||
}
|
||||
|
||||
|
||||
const char* ecl_sum_vector_iget_key(const ecl_sum_vector_type * ecl_sum_vector, int index){
|
||||
return stringlist_iget( ecl_sum_vector->key_list , index);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ int find_index(ecl_nnc_geometry_type * nnc_geo, int grid1, int grid2, int indx1,
|
||||
int index = -1;
|
||||
int nnc_size = ecl_nnc_geometry_size( nnc_geo );
|
||||
for (int n = 0; n < nnc_size; n++) {
|
||||
ecl_nnc_pair_type * pair = ecl_nnc_geometry_iget( nnc_geo, n );
|
||||
const ecl_nnc_pair_type * pair = ecl_nnc_geometry_iget( nnc_geo, n );
|
||||
if (pair->grid_nr1 == grid1 && pair->grid_nr2 == grid2)
|
||||
if (pair->global_index1 == indx1 && pair->global_index2 ==indx2) {
|
||||
index = n;
|
||||
|
113
ThirdParty/Ert/lib/ecl/tests/test_transactions.c
vendored
Normal file
113
ThirdParty/Ert/lib/ecl/tests/test_transactions.c
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
|
||||
/*
|
||||
Copyright (C) 2017 Statoil ASA, Norway.
|
||||
|
||||
The file 'test_transactions.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/test_work_area.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/fortio.h>
|
||||
#include <ert/ecl/ecl_endian_flip.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_file_view.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
|
||||
|
||||
/*
|
||||
This test is slightly awkward beacuse it tests quite internal implementation details.
|
||||
*/
|
||||
|
||||
void test_transaction() {
|
||||
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_file_index_testing");
|
||||
{
|
||||
char * file_name = "data_file";
|
||||
fortio_type * fortio = fortio_open_writer(file_name, false, ECL_ENDIAN_FLIP);
|
||||
|
||||
//creating the data file
|
||||
size_t data_size = 10;
|
||||
ecl_kw_type * kw1 = ecl_kw_alloc("TEST1_KW", data_size, ECL_INT);
|
||||
for(int i = 0; i < data_size; ++i)
|
||||
ecl_kw_iset_int(kw1, i, 537 + i);
|
||||
ecl_kw_fwrite(kw1, fortio);
|
||||
|
||||
data_size = 5;
|
||||
ecl_kw_type * kw2 = ecl_kw_alloc("TEST2_KW", data_size, ECL_FLOAT);
|
||||
for(int i = 0; i < data_size; ++i)
|
||||
ecl_kw_iset_float(kw2, i, 0.15 * i);
|
||||
ecl_kw_fwrite(kw2, fortio);
|
||||
|
||||
data_size = 3;
|
||||
ecl_kw_type * kw3 = ecl_kw_alloc("TEST3_KW", data_size, ECL_FLOAT);
|
||||
for(int i = 0; i < data_size; i++)
|
||||
ecl_kw_iset_float(kw3, i, 0.45 * i);
|
||||
ecl_kw_fwrite(kw3, fortio);
|
||||
|
||||
fortio_fclose(fortio);
|
||||
//finished creating data file
|
||||
|
||||
ecl_file_type * file = ecl_file_open(file_name, 0);
|
||||
ecl_file_view_type * file_view = ecl_file_get_global_view(file);
|
||||
ecl_file_kw_type * file_kw0 = ecl_file_view_iget_file_kw( file_view , 0);
|
||||
ecl_file_kw_type * file_kw1 = ecl_file_view_iget_file_kw( file_view , 1);
|
||||
ecl_file_kw_type * file_kw2 = ecl_file_view_iget_file_kw( file_view , 2);
|
||||
|
||||
ecl_file_view_iget_kw( file_view, 0);
|
||||
test_assert_true( ecl_file_kw_get_kw_ptr(file_kw0));
|
||||
test_assert_false( ecl_file_kw_get_kw_ptr(file_kw1) );
|
||||
test_assert_false( ecl_file_kw_get_kw_ptr(file_kw2) );
|
||||
ecl_file_transaction_type * t1 = ecl_file_view_start_transaction( file_view );
|
||||
|
||||
ecl_file_view_iget_kw(file_view, 0);
|
||||
ecl_file_view_iget_kw(file_view, 1);
|
||||
ecl_file_transaction_type * t2 = ecl_file_view_start_transaction( file_view );
|
||||
|
||||
ecl_file_view_iget_kw(file_view, 0);
|
||||
ecl_file_view_iget_kw(file_view, 1);
|
||||
ecl_file_view_iget_kw(file_view, 1);
|
||||
ecl_file_view_iget_kw(file_view, 2);
|
||||
|
||||
ecl_file_view_end_transaction( file_view , t2 );
|
||||
|
||||
test_assert_true( ecl_file_kw_get_kw_ptr(file_kw0) );
|
||||
test_assert_true( ecl_file_kw_get_kw_ptr(file_kw1) );
|
||||
test_assert_false( ecl_file_kw_get_kw_ptr(file_kw2) );
|
||||
ecl_file_view_iget_kw(file_view, 2);
|
||||
|
||||
ecl_file_view_end_transaction(file_view, t1);
|
||||
test_assert_true( ecl_file_kw_get_kw_ptr(file_kw0 ) );
|
||||
test_assert_false( ecl_file_kw_get_kw_ptr(file_kw1) );
|
||||
test_assert_false( ecl_file_kw_get_kw_ptr(file_kw2) );
|
||||
|
||||
ecl_file_close(file);
|
||||
|
||||
}
|
||||
test_work_area_free( work_area );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
util_install_signals();
|
||||
test_transaction();
|
||||
exit(0);
|
||||
}
|
58
ThirdParty/Ert/lib/ecl/tests/well_lgr_load.c
vendored
58
ThirdParty/Ert/lib/ecl/tests/well_lgr_load.c
vendored
@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_lgr_load.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_lgr_load.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
@ -36,29 +36,27 @@
|
||||
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */
|
||||
signal(SIGTERM , util_abort_signal); /* If killing the enkf program with SIGTERM (the default kill signal) you will get a backtrace.
|
||||
Killing with SIGKILL (-9) will not give a backtrace.*/
|
||||
signal(SIGABRT , util_abort_signal); /* Signal abort. */
|
||||
signal(SIGSEGV , util_abort_signal); /* Segmentation violation,
|
||||
i.e. overwriting memory ... */
|
||||
signal(SIGTERM , util_abort_signal); /* If killing the enkf program with
|
||||
SIGTERM (the default kill signal)
|
||||
you will get a backtrace. Killing
|
||||
with SIGKILL (-9) will not give a
|
||||
backtrace.*/
|
||||
signal(SIGABRT , util_abort_signal); /* Signal abort. */
|
||||
{
|
||||
ecl_grid_type * grid = ecl_grid_alloc( argv[1] );
|
||||
well_info_type * well_info = well_info_alloc( grid );
|
||||
|
||||
well_info_load_rstfile( well_info , argv[2] , true);
|
||||
|
||||
|
||||
// List all wells:
|
||||
{
|
||||
int iwell;
|
||||
for (iwell = 0; iwell < well_info_get_num_wells( well_info ); iwell++) {
|
||||
well_ts_type * well_ts = well_info_get_ts( well_info , well_info_iget_well_name( well_info , iwell));
|
||||
well_state_type * well_state = well_ts_get_last_state( well_ts );
|
||||
|
||||
well_state_summarize( well_state , stdout );
|
||||
printf("\n");
|
||||
}
|
||||
for (int iwell = 0; iwell < well_info_get_num_wells( well_info ); iwell++) {
|
||||
well_ts_type * well_ts = well_info_get_ts( well_info , well_info_iget_well_name( well_info , iwell));
|
||||
well_state_type * well_state = well_ts_get_last_state( well_ts );
|
||||
}
|
||||
well_info_free( well_info );
|
||||
}
|
||||
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
6
ThirdParty/Ert/lib/ecl/well_info.c
vendored
6
ThirdParty/Ert/lib/ecl/well_info.c
vendored
@ -304,10 +304,14 @@ void well_info_add_UNRST_wells2( well_info_type * well_info , ecl_file_view_type
|
||||
int num_blocks = ecl_file_view_get_num_named_kw( rst_view , SEQNUM_KW );
|
||||
int block_nr;
|
||||
for (block_nr = 0; block_nr < num_blocks; block_nr++) {
|
||||
|
||||
ecl_file_view_type * step_view = ecl_file_view_add_restart_view(rst_view, block_nr , -1 , -1 , -1 );
|
||||
const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( step_view , SEQNUM_KW , 0);
|
||||
int report_nr = ecl_kw_iget_int( seqnum_kw , 0 );
|
||||
well_info_add_wells2( well_info , step_view , report_nr , load_segment_information );
|
||||
|
||||
ecl_file_transaction_type * t = ecl_file_view_start_transaction(rst_view);
|
||||
well_info_add_wells2( well_info , step_view , report_nr , load_segment_information );
|
||||
ecl_file_view_end_transaction(rst_view, t);
|
||||
}
|
||||
}
|
||||
|
||||
|
14
ThirdParty/Ert/lib/ecl/well_state.c
vendored
14
ThirdParty/Ert/lib/ecl/well_state.c
vendored
@ -438,13 +438,14 @@ static void well_state_add_global_connections( well_state_type * well_state ,
|
||||
well_state_add_connections__( well_state , rst_view , ECL_GRID_GLOBAL_GRID , 0 , well_nr );
|
||||
}
|
||||
|
||||
static void well_state_add_LGR_connections( well_state_type * well_state , const ecl_grid_type * grid , ecl_file_view_type * file_view , int global_well_nr ) {
|
||||
static void well_state_add_LGR_connections(well_state_type * well_state,
|
||||
const ecl_grid_type * grid,
|
||||
ecl_file_view_type * file_view) {
|
||||
// Go through all the LGRs and add connections; both in the bulk
|
||||
// grid and as wellhead.
|
||||
|
||||
int num_lgr = ecl_grid_get_num_lgr( grid );
|
||||
int lgr_index;
|
||||
for (lgr_index = 0; lgr_index < num_lgr; lgr_index++) {
|
||||
for (int lgr_index = 0; lgr_index < num_lgr; lgr_index++) {
|
||||
ecl_file_view_type * lgr_view = ecl_file_view_add_blockview(file_view , LGR_KW , lgr_index);
|
||||
const char * grid_name = ecl_grid_iget_lgr_name( grid , lgr_index );
|
||||
int well_nr = well_state_get_lgr_well_nr( well_state , lgr_view );
|
||||
@ -471,7 +472,7 @@ void well_state_add_connections2( well_state_type * well_state ,
|
||||
int well_nr) {
|
||||
|
||||
well_state_add_global_connections( well_state , rst_view , well_nr );
|
||||
well_state_add_LGR_connections( well_state , grid , rst_view , well_nr );
|
||||
well_state_add_LGR_connections( well_state , grid , rst_view);
|
||||
|
||||
}
|
||||
|
||||
@ -669,10 +670,6 @@ const char * well_state_get_name( const well_state_type * well_state ) {
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
void well_state_summarize( const well_state_type * well_state , FILE * stream ) {
|
||||
}
|
||||
|
||||
|
||||
const well_conn_collection_type * well_state_get_grid_connections( const well_state_type * well_state , const char * grid_name) {
|
||||
if (hash_has_key( well_state->connections , grid_name))
|
||||
return hash_get( well_state->connections , grid_name);
|
||||
@ -707,4 +704,3 @@ well_segment_collection_type * well_state_get_segments( const well_state_type *
|
||||
well_branch_collection_type * well_state_get_branches( const well_state_type * well_state ) {
|
||||
return well_state->branches;
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright (c) 2012 statoil asa, norway.
|
||||
|
||||
The file 'ecl_coarse_cell.h' is part of ert - ensemble based reservoir tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the gnu general public license as published by
|
||||
the free software foundation, either version 3 of the license, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but without any
|
||||
warranty; without even the implied warranty of merchantability or
|
||||
fitness for a particular purpose.
|
||||
|
||||
See the gnu general public license at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
This file is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef ERT_ECL_COARSE_CELL_H
|
||||
@ -24,33 +24,47 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ecl_coarse_cell_struct ecl_coarse_cell_type;
|
||||
typedef struct ecl_coarse_cell_struct ecl_coarse_cell_type;
|
||||
|
||||
bool ecl_coarse_cell_equal( const ecl_coarse_cell_type * coarse_cell1 , const ecl_coarse_cell_type * coarse_cell2);
|
||||
ecl_coarse_cell_type * ecl_coarse_cell_alloc( void );
|
||||
void ecl_coarse_cell_update( ecl_coarse_cell_type * coarse_cell , int i , int j , int k , int global_index );
|
||||
void ecl_coarse_cell_free( ecl_coarse_cell_type * coarse_cell );
|
||||
void ecl_coarse_cell_free__( void * arg );
|
||||
bool ecl_coarse_cell_equal(const ecl_coarse_cell_type * coarse_cell1,
|
||||
const ecl_coarse_cell_type * coarse_cell2);
|
||||
ecl_coarse_cell_type * ecl_coarse_cell_alloc(void);
|
||||
void ecl_coarse_cell_update(ecl_coarse_cell_type * coarse_cell,
|
||||
int i,
|
||||
int j,
|
||||
int k,
|
||||
int global_index);
|
||||
void ecl_coarse_cell_free(ecl_coarse_cell_type * coarse_cell);
|
||||
void ecl_coarse_cell_free__(void * arg);
|
||||
|
||||
int ecl_coarse_cell_get_i1( const ecl_coarse_cell_type * coarse_cell );
|
||||
int ecl_coarse_cell_get_j1( const ecl_coarse_cell_type * coarse_cell );
|
||||
int ecl_coarse_cell_get_k1( const ecl_coarse_cell_type * coarse_cell );
|
||||
int ecl_coarse_cell_get_i2( const ecl_coarse_cell_type * coarse_cell );
|
||||
int ecl_coarse_cell_get_j2( const ecl_coarse_cell_type * coarse_cell );
|
||||
int ecl_coarse_cell_get_k2( const ecl_coarse_cell_type * coarse_cell );
|
||||
const int * ecl_coarse_cell_get_box_ptr( const ecl_coarse_cell_type * coarse_cell );
|
||||
int ecl_coarse_cell_get_i1(const ecl_coarse_cell_type * coarse_cell);
|
||||
int ecl_coarse_cell_get_j1(const ecl_coarse_cell_type * coarse_cell);
|
||||
int ecl_coarse_cell_get_k1(const ecl_coarse_cell_type * coarse_cell);
|
||||
int ecl_coarse_cell_get_i2(const ecl_coarse_cell_type * coarse_cell);
|
||||
int ecl_coarse_cell_get_j2(const ecl_coarse_cell_type * coarse_cell);
|
||||
int ecl_coarse_cell_get_k2(const ecl_coarse_cell_type * coarse_cell);
|
||||
const int * ecl_coarse_cell_get_box_ptr(const ecl_coarse_cell_type * coarse_cell);
|
||||
|
||||
int ecl_coarse_cell_get_size( const ecl_coarse_cell_type * coarse_cell );
|
||||
int ecl_coarse_cell_iget_cell_index( ecl_coarse_cell_type * coarse_cell , int group_index);
|
||||
const int * ecl_coarse_cell_get_index_ptr( ecl_coarse_cell_type * coarse_cell );
|
||||
const int_vector_type * ecl_coarse_cell_get_index_vector( ecl_coarse_cell_type * coarse_cell );
|
||||
int ecl_coarse_cell_get_size(const ecl_coarse_cell_type * coarse_cell);
|
||||
int ecl_coarse_cell_iget_cell_index(ecl_coarse_cell_type * coarse_cell,
|
||||
int group_index);
|
||||
const int * ecl_coarse_cell_get_index_ptr(ecl_coarse_cell_type * coarse_cell);
|
||||
const int_vector_type * ecl_coarse_cell_get_index_vector(ecl_coarse_cell_type * coarse_cell);
|
||||
|
||||
void ecl_coarse_cell_update_index( ecl_coarse_cell_type * coarse_cell , int global_index , int * active_index , int * active_fracture_index , int active_value); int ecl_coarse_cell_get_active_index( const ecl_coarse_cell_type * coarse_cell );
|
||||
int ecl_coarse_cell_get_active_fracture_index( const ecl_coarse_cell_type * coarse_cell );
|
||||
int ecl_coarse_cell_iget_active_cell_index( const ecl_coarse_cell_type * coarse_cell , int index);
|
||||
int ecl_coarse_cell_iget_active_value( const ecl_coarse_cell_type * coarse_cell , int index);
|
||||
int ecl_coarse_cell_get_num_active( const ecl_coarse_cell_type * coarse_cell);
|
||||
void ecl_coarse_cell_fprintf( const ecl_coarse_cell_type * coarse_cell , FILE * stream );
|
||||
void ecl_coarse_cell_update_index(ecl_coarse_cell_type * coarse_cell,
|
||||
int global_index,
|
||||
int * active_index,
|
||||
int * active_fracture_index,
|
||||
int active_value);
|
||||
int ecl_coarse_cell_get_active_index(const ecl_coarse_cell_type * coarse_cell);
|
||||
int ecl_coarse_cell_get_active_fracture_index(const ecl_coarse_cell_type * coarse_cell);
|
||||
int ecl_coarse_cell_iget_active_cell_index(const ecl_coarse_cell_type * coarse_cell,
|
||||
int index);
|
||||
int ecl_coarse_cell_iget_active_value(const ecl_coarse_cell_type * coarse_cell,
|
||||
int index);
|
||||
int ecl_coarse_cell_get_num_active(const ecl_coarse_cell_type * coarse_cell);
|
||||
void ecl_coarse_cell_fprintf(const ecl_coarse_cell_type * coarse_cell,
|
||||
FILE * stream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ typedef struct inv_map_struct inv_map_type;
|
||||
void ecl_file_kw_free( ecl_file_kw_type * file_kw );
|
||||
void ecl_file_kw_free__( void * arg );
|
||||
ecl_kw_type * ecl_file_kw_get_kw( ecl_file_kw_type * file_kw , fortio_type * fortio, inv_map_type * inv_map);
|
||||
ecl_kw_type * ecl_file_kw_get_kw_ptr( ecl_file_kw_type * file_kw , fortio_type * fortio , inv_map_type * inv_map );
|
||||
ecl_kw_type * ecl_file_kw_get_kw_ptr( ecl_file_kw_type * file_kw );
|
||||
ecl_file_kw_type * ecl_file_kw_alloc_copy( const ecl_file_kw_type * src );
|
||||
const char * ecl_file_kw_get_header( const ecl_file_kw_type * file_kw );
|
||||
int ecl_file_kw_get_size( const ecl_file_kw_type * file_kw );
|
||||
@ -56,7 +56,10 @@ typedef struct inv_map_struct inv_map_type;
|
||||
void ecl_file_kw_fwrite( const ecl_file_kw_type * file_kw , FILE * stream );
|
||||
ecl_file_kw_type ** ecl_file_kw_fread_alloc_multiple( FILE * stream , int num);
|
||||
ecl_file_kw_type * ecl_file_kw_fread_alloc( FILE * stream );
|
||||
|
||||
|
||||
void ecl_file_kw_start_transaction(const ecl_file_kw_type * file_kw, int * ref_count);
|
||||
void ecl_file_kw_end_transaction(ecl_file_kw_type * file_kw, int ref_count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -48,6 +48,8 @@ typedef enum {
|
||||
|
||||
|
||||
typedef struct ecl_file_view_struct ecl_file_view_type;
|
||||
typedef struct ecl_file_transaction_struct ecl_file_transaction_type;
|
||||
|
||||
|
||||
bool ecl_file_view_flags_set( const ecl_file_view_type * file_view, int query_flags);
|
||||
bool ecl_file_view_check_flags( int state_flags , int query_flags);
|
||||
@ -103,6 +105,9 @@ typedef struct ecl_file_view_struct ecl_file_view_type;
|
||||
void ecl_file_view_write_index(const ecl_file_view_type * file_view, FILE * ostream);
|
||||
ecl_file_view_type * ecl_file_view_fread_alloc( fortio_type * fortio , int * flags , inv_map_type * inv_map, FILE * istream );
|
||||
|
||||
ecl_file_transaction_type * ecl_file_view_start_transaction(ecl_file_view_type * file_view);
|
||||
void ecl_file_view_end_transaction( ecl_file_view_type * file_view, ecl_file_transaction_type * transaction);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -28,9 +28,26 @@ extern "C" {
|
||||
#include <ert/ecl/ecl_grid_cache.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
|
||||
bool * ecl_grav_common_alloc_aquifer_cell( const ecl_grid_cache_type * grid_cache , const ecl_file_type * init_file);
|
||||
double ecl_grav_common_eval_biot_savart( const ecl_grid_cache_type * grid_cache , ecl_region_type * region , const bool * aquifer , const double * weight , double utm_x , double utm_y , double depth);
|
||||
double ecl_grav_common_eval_geertsma( const ecl_grid_cache_type * grid_cache , ecl_region_type * region , const bool * aquifer , const double * weight , double utm_x , double utm_y , double depth, double poisson_ratio, double seabed);
|
||||
bool * ecl_grav_common_alloc_aquifer_cell(const ecl_grid_cache_type * grid_cache,
|
||||
const ecl_file_type * init_file);
|
||||
|
||||
double ecl_grav_common_eval_biot_savart(const ecl_grid_cache_type * grid_cache,
|
||||
ecl_region_type * region,
|
||||
const bool * aquifer,
|
||||
const double * weight,
|
||||
double utm_x,
|
||||
double utm_y,
|
||||
double depth);
|
||||
|
||||
double ecl_grav_common_eval_geertsma(const ecl_grid_cache_type * grid_cache,
|
||||
ecl_region_type * region,
|
||||
const bool * aquifer,
|
||||
const double * weight,
|
||||
double utm_x,
|
||||
double utm_y,
|
||||
double depth,
|
||||
double poisson_ratio,
|
||||
double seabed);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
59
ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h
vendored
59
ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h
vendored
@ -91,7 +91,7 @@ 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);
|
||||
ecl_sum_type * ecl_sum_fread_alloc(const char * , const stringlist_type * data_files, const char * key_join_string, bool include_restart);
|
||||
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 * , const char * key_join_string , bool include_restart);
|
||||
bool ecl_sum_case_exists( const char * input_file );
|
||||
@ -156,7 +156,10 @@ typedef struct ecl_sum_struct ecl_sum_type;
|
||||
double ecl_sum_iget_general_var(const ecl_sum_type * ecl_sum , int internal_index , const char * lookup_kw);
|
||||
|
||||
|
||||
void ecl_sum_init_data_vector( const ecl_sum_type * ecl_sum , double_vector_type * data_vector , int data_index , bool report_only );
|
||||
void ecl_sum_init_data_vector(const ecl_sum_type * ecl_sum ,
|
||||
double_vector_type * data_vector ,
|
||||
int data_index ,
|
||||
bool report_only );
|
||||
double_vector_type * ecl_sum_alloc_data_vector( const ecl_sum_type * ecl_sum , int data_index , bool report_only);
|
||||
time_t_vector_type * ecl_sum_alloc_time_vector( const ecl_sum_type * ecl_sum , bool report_only);
|
||||
time_t ecl_sum_get_data_start( const ecl_sum_type * ecl_sum );
|
||||
@ -170,8 +173,14 @@ typedef struct ecl_sum_struct ecl_sum_type;
|
||||
const char * ecl_sum_get_case(const ecl_sum_type * );
|
||||
bool ecl_sum_same_case( const ecl_sum_type * ecl_sum , const char * input_file );
|
||||
|
||||
void ecl_sum_resample_from_sim_days( const ecl_sum_type * ecl_sum , const double_vector_type * sim_days , double_vector_type * value , const char * gen_key);
|
||||
void ecl_sum_resample_from_sim_time( const ecl_sum_type * ecl_sum , const time_t_vector_type * sim_time , double_vector_type * value , const char * gen_key);
|
||||
void ecl_sum_resample_from_sim_days(const ecl_sum_type * ecl_sum ,
|
||||
const double_vector_type * sim_days ,
|
||||
double_vector_type * value ,
|
||||
const char * gen_key);
|
||||
void ecl_sum_resample_from_sim_time(const ecl_sum_type * ecl_sum ,
|
||||
const time_t_vector_type * sim_time ,
|
||||
double_vector_type * value ,
|
||||
const char * gen_key);
|
||||
time_t ecl_sum_time_from_days( const ecl_sum_type * ecl_sum , double sim_days );
|
||||
double ecl_sum_days_from_time( const ecl_sum_type * ecl_sum , time_t sim_time );
|
||||
double ecl_sum_get_sim_length( const ecl_sum_type * ecl_sum ) ;
|
||||
@ -192,14 +201,40 @@ typedef struct ecl_sum_struct ecl_sum_type;
|
||||
int ecl_sum_iget_report_end( const ecl_sum_type * ecl_sum , int report_step );
|
||||
int ecl_sum_iget_report_start( const ecl_sum_type * ecl_sum , int report_step );
|
||||
|
||||
ecl_sum_type * ecl_sum_alloc_restart_writer( const char * ecl_case , const char * restart_case , bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz);
|
||||
ecl_sum_type * ecl_sum_alloc_writer( const char * ecl_case , bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz);
|
||||
ecl_sum_type * ecl_sum_alloc_restart_writer(const char * ecl_case ,
|
||||
const char * restart_case ,
|
||||
bool fmt_output ,
|
||||
bool unified ,
|
||||
const char * key_join_string ,
|
||||
time_t sim_start ,
|
||||
bool time_in_days ,
|
||||
int nx ,
|
||||
int ny ,
|
||||
int nz);
|
||||
ecl_sum_type * ecl_sum_alloc_writer(const char * ecl_case ,
|
||||
bool fmt_output ,
|
||||
bool unified ,
|
||||
const char * key_join_string ,
|
||||
time_t sim_start ,
|
||||
bool time_in_days ,
|
||||
int nx , int ny , int nz);
|
||||
void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case);
|
||||
void ecl_sum_fwrite( const ecl_sum_type * ecl_sum );
|
||||
void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum );
|
||||
smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , int num , const char * unit , float default_value);
|
||||
smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default_value);
|
||||
void ecl_sum_init_var( ecl_sum_type * ecl_sum , smspec_node_type * smspec_node , const char * keyword , const char * wgname , int num , const char * unit);
|
||||
smspec_node_type * ecl_sum_add_var(ecl_sum_type * ecl_sum ,
|
||||
const char * keyword ,
|
||||
const char * wgname ,
|
||||
int num ,
|
||||
const char * unit ,
|
||||
float default_value);
|
||||
smspec_node_type * ecl_sum_add_blank_var(ecl_sum_type * ecl_sum ,
|
||||
float default_value);
|
||||
void ecl_sum_init_var(ecl_sum_type * ecl_sum ,
|
||||
smspec_node_type * smspec_node ,
|
||||
const char * keyword ,
|
||||
const char * wgname ,
|
||||
int num ,
|
||||
const char * unit);
|
||||
ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_seconds);
|
||||
void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname );
|
||||
|
||||
@ -207,7 +242,11 @@ typedef struct ecl_sum_struct ecl_sum_type;
|
||||
char * ecl_sum_alloc_well_key( const ecl_sum_type * ecl_sum , const char * keyword , const char * wgname);
|
||||
bool ecl_sum_report_step_equal( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2);
|
||||
bool ecl_sum_report_step_compatible( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2);
|
||||
void ecl_sum_export_csv(const ecl_sum_type * ecl_sum , const char * filename , const stringlist_type * var_list , const char * date_format , const char * sep);
|
||||
void ecl_sum_export_csv(const ecl_sum_type * ecl_sum ,
|
||||
const char * filename ,
|
||||
const stringlist_type * var_list ,
|
||||
const char * date_format ,
|
||||
const char * sep);
|
||||
|
||||
|
||||
double_vector_type * ecl_sum_alloc_seconds_solution( const ecl_sum_type * ecl_sum , const char * gen_key , double cmp_value , bool rates_clamp_lower);
|
||||
|
@ -66,7 +66,7 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ;
|
||||
|
||||
double ecl_sum_data_iget_sim_days( const ecl_sum_data_type * , int );
|
||||
time_t ecl_sum_data_iget_sim_time( const ecl_sum_data_type * , int );
|
||||
|
||||
void ecl_sum_data_get_interp_vector( const ecl_sum_data_type * data , time_t sim_time, const ecl_sum_vector_type * keylist, double_vector_type * results);
|
||||
|
||||
bool ecl_sum_data_has_report_step(const ecl_sum_data_type * , int );
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_conn_collection.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_conn_collection.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
@ -27,23 +27,33 @@ extern "C" {
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
typedef struct well_conn_collection_struct well_conn_collection_type;
|
||||
typedef struct well_conn_collection_struct well_conn_collection_type;
|
||||
|
||||
well_conn_collection_type * well_conn_collection_alloc(void);
|
||||
void well_conn_collection_free( well_conn_collection_type * wellcc );
|
||||
void well_conn_collection_free__( void * arg );
|
||||
int well_conn_collection_get_size( const well_conn_collection_type * wellcc );
|
||||
const well_conn_type * well_conn_collection_iget_const( const well_conn_collection_type * wellcc , int index);
|
||||
well_conn_type * well_conn_collection_iget(const well_conn_collection_type * wellcc , int index);
|
||||
void well_conn_collection_add( well_conn_collection_type * wellcc , well_conn_type * conn);
|
||||
void well_conn_collection_add_ref( well_conn_collection_type * wellcc , well_conn_type * conn);
|
||||
int well_conn_collection_load_from_kw( well_conn_collection_type * wellcc , const ecl_kw_type * iwel_kw , const ecl_kw_type * icon_kw , const ecl_kw_type * scon_kw , const ecl_kw_type * xcon_kw , int iwell , const ecl_rsthead_type * rst_head);
|
||||
well_conn_collection_type * well_conn_collection_alloc(void);
|
||||
void well_conn_collection_free(well_conn_collection_type * wellcc);
|
||||
void well_conn_collection_free__(void * arg);
|
||||
int well_conn_collection_get_size(const well_conn_collection_type * wellcc);
|
||||
const well_conn_type * well_conn_collection_iget_const(const well_conn_collection_type * wellcc,
|
||||
int index);
|
||||
well_conn_type * well_conn_collection_iget(const well_conn_collection_type * wellcc,
|
||||
int index);
|
||||
void well_conn_collection_add(well_conn_collection_type * wellcc,
|
||||
well_conn_type * conn);
|
||||
void well_conn_collection_add_ref(well_conn_collection_type * wellcc,
|
||||
well_conn_type * conn);
|
||||
int well_conn_collection_load_from_kw(well_conn_collection_type * wellcc,
|
||||
const ecl_kw_type * iwel_kw,
|
||||
const ecl_kw_type * icon_kw,
|
||||
const ecl_kw_type * scon_kw,
|
||||
const ecl_kw_type * xcon_kw,
|
||||
int iwell,
|
||||
const ecl_rsthead_type * rst_head);
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( well_conn_collection );
|
||||
UTIL_IS_INSTANCE_HEADER(well_conn_collection);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_state.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_state.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ extern "C" {
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
@ -49,13 +49,13 @@ extern "C" {
|
||||
ecl_file_view_type * rst_view ,
|
||||
int well_nr);
|
||||
|
||||
void well_state_add_connections( well_state_type * well_state ,
|
||||
const ecl_grid_type * grid ,
|
||||
ecl_file_type * rst_file ,
|
||||
void well_state_add_connections( well_state_type * well_state ,
|
||||
const ecl_grid_type * grid ,
|
||||
ecl_file_type * rst_file ,
|
||||
int well_nr);
|
||||
|
||||
bool well_state_add_MSW( well_state_type * well_state ,
|
||||
ecl_file_type * rst_file ,
|
||||
bool well_state_add_MSW( well_state_type * well_state ,
|
||||
ecl_file_type * rst_file ,
|
||||
int well_nr,
|
||||
bool load_segment_information);
|
||||
|
||||
@ -79,14 +79,13 @@ extern "C" {
|
||||
int well_state_get_report_nr( const well_state_type * well_state );
|
||||
time_t well_state_get_sim_time( const well_state_type * well_state );
|
||||
well_type_enum well_state_get_type( const well_state_type * well_state);
|
||||
bool well_state_is_open( const well_state_type * well_state );
|
||||
bool well_state_is_open( const well_state_type * well_state );
|
||||
int well_state_get_well_nr( const well_state_type * well_state );
|
||||
|
||||
const well_conn_type * well_state_get_global_wellhead( const well_state_type * well_state );
|
||||
const well_conn_type * well_state_iget_wellhead( const well_state_type * well_state , int grid_nr);
|
||||
const well_conn_type * well_state_get_wellhead( const well_state_type * well_state , const char * grid_name);
|
||||
|
||||
void well_state_summarize( const well_state_type * well_state , FILE * stream );
|
||||
|
||||
well_type_enum well_state_translate_ecl_type_int(int int_type);
|
||||
|
||||
const well_conn_collection_type * well_state_get_grid_connections( const well_state_type * well_state , const char * grid_name);
|
||||
@ -99,9 +98,9 @@ extern "C" {
|
||||
double well_state_get_water_rate( const well_state_type * well_state);
|
||||
double well_state_get_volume_rate( const well_state_type * well_state);
|
||||
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( well_state );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
1
ThirdParty/Ert/lib/include/ert/util/buffer.h
vendored
1
ThirdParty/Ert/lib/include/ert/util/buffer.h
vendored
@ -91,6 +91,7 @@ extern "C" {
|
||||
void buffer_stream_fread( buffer_type * buffer , size_t byte_size , FILE * stream);
|
||||
buffer_type * buffer_fread_alloc(const char * filename);
|
||||
void buffer_fread_realloc(buffer_type * buffer , const char * filename);
|
||||
void buffer_fprintf(const buffer_type * buffer, const char * fmt, FILE * stream);
|
||||
|
||||
#ifdef ERT_HAVE_ZLIB
|
||||
size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size);
|
||||
|
32
ThirdParty/Ert/lib/include/ert/util/log.h
vendored
32
ThirdParty/Ert/lib/include/ert/util/log.h
vendored
@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'log.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'log.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef ERT_LOG_H
|
||||
@ -54,7 +54,7 @@ typedef struct log_struct log_type;
|
||||
void log_set_level( log_type * logh , int log_level);
|
||||
bool log_is_open( const log_type * logh);
|
||||
bool log_include_message(const log_type *logh , int message_level);
|
||||
|
||||
int log_get_msg_count(const log_type * logh);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
57
ThirdParty/Ert/lib/include/ert/util/stringlist.h
vendored
57
ThirdParty/Ert/lib/include/ert/util/stringlist.h
vendored
@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'stringlist.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'stringlist.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef ERT_STRINGLIST_H
|
||||
@ -40,18 +40,19 @@ typedef int ( string_cmp_ftype) (const void * , const void *);
|
||||
void stringlist_deep_copy( stringlist_type * target , const stringlist_type * src);
|
||||
stringlist_type * stringlist_alloc_deep_copy_with_limits(const stringlist_type * src , int offset, int num_strings);
|
||||
stringlist_type * stringlist_alloc_deep_copy_with_offset(const stringlist_type * src , int offset);
|
||||
stringlist_type * stringlist_alloc_deep_copy( const stringlist_type * src );
|
||||
stringlist_type * stringlist_alloc_deep_copy( const stringlist_type * src );
|
||||
|
||||
stringlist_type * stringlist_alloc_new(void);
|
||||
void stringlist_free__(void * );
|
||||
void stringlist_free(stringlist_type *);
|
||||
void stringlist_clear(stringlist_type * );
|
||||
|
||||
|
||||
void stringlist_append_copy(stringlist_type * , const char *);
|
||||
void stringlist_append_ref(stringlist_type * , const char *);
|
||||
void stringlist_append_owned_ref(stringlist_type * , const char *);
|
||||
|
||||
|
||||
const char * stringlist_safe_iget( const stringlist_type * stringlist , int index);
|
||||
bool stringlist_unique(const stringlist_type * stringlist );
|
||||
bool stringlist_iequal( const stringlist_type * stringlist , int index, const char * s );
|
||||
const char * stringlist_iget(const stringlist_type * , int);
|
||||
int stringlist_iget_as_int( const stringlist_type * stringlist , int index , bool * valid);
|
||||
@ -64,21 +65,21 @@ typedef int ( string_cmp_ftype) (const void * , const void *);
|
||||
const char * stringlist_back(const stringlist_type * stringlist);
|
||||
|
||||
|
||||
|
||||
|
||||
void stringlist_iset_copy(stringlist_type *, int index , const char *);
|
||||
void stringlist_iset_ref(stringlist_type *, int index , const char *);
|
||||
void stringlist_iset_owned_ref(stringlist_type *, int index , const char *);
|
||||
|
||||
|
||||
void stringlist_insert_copy(stringlist_type *, int index , const char *);
|
||||
void stringlist_insert_ref(stringlist_type *, int index , const char *);
|
||||
void stringlist_insert_owned_ref(stringlist_type *, int index , const char *);
|
||||
|
||||
|
||||
void stringlist_idel(stringlist_type * stringlist , int index);
|
||||
|
||||
|
||||
int stringlist_get_size(const stringlist_type * );
|
||||
void stringlist_fprintf(const stringlist_type * , const char * , FILE *);
|
||||
void stringlist_fprintf_fmt(const stringlist_type * stringlist, const stringlist_type * fmt_list , FILE * stream);
|
||||
|
||||
|
||||
|
||||
stringlist_type * stringlist_alloc_argv_copy(const char ** , int );
|
||||
stringlist_type * stringlist_alloc_argv_ref (const char ** , int );
|
||||
@ -87,12 +88,12 @@ typedef int ( string_cmp_ftype) (const void * , const void *);
|
||||
stringlist_type * stringlist_alloc_shallow_copy_with_offset(const stringlist_type * stringlist, int offset);
|
||||
stringlist_type * stringlist_alloc_shallow_copy_with_limits(const stringlist_type * stringlist, int offset , int num_strings);
|
||||
stringlist_type * stringlist_alloc_from_split( const char * input_string , const char * sep );
|
||||
stringlist_type * stringlist_fread_alloc(FILE * );
|
||||
|
||||
stringlist_type * stringlist_fread_alloc(FILE * );
|
||||
|
||||
void stringlist_append_stringlist_copy(stringlist_type * , const stringlist_type * );
|
||||
void stringlist_append_stringlist_ref(stringlist_type * , const stringlist_type * );
|
||||
void stringlist_insert_stringlist_copy(stringlist_type * , const stringlist_type *, int);
|
||||
|
||||
|
||||
bool stringlist_equal(const stringlist_type * , const stringlist_type *);
|
||||
bool stringlist_contains(const stringlist_type * , const char * );
|
||||
int_vector_type * stringlist_find(const stringlist_type *, const char *);
|
||||
@ -107,7 +108,7 @@ typedef int ( string_cmp_ftype) (const void * , const void *);
|
||||
void stringlist_sort(stringlist_type * , string_cmp_ftype * string_cmp);
|
||||
void stringlist_reverse( stringlist_type * s );
|
||||
void stringlist_python_sort( stringlist_type * s , int cmp_flag);
|
||||
|
||||
|
||||
#ifdef ERT_HAVE_GLOB
|
||||
int stringlist_select_matching(stringlist_type * names , const char * pattern);
|
||||
#endif
|
||||
@ -119,4 +120,4 @@ typedef int ( string_cmp_ftype) (const void * , const void *);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
3
ThirdParty/Ert/lib/include/ert/util/util.h
vendored
3
ThirdParty/Ert/lib/include/ert/util/util.h
vendored
@ -197,6 +197,7 @@ typedef enum {left_pad = 0,
|
||||
|
||||
#ifdef ERT_HAVE_GETUID
|
||||
uid_t util_get_entry_uid( const char * file );
|
||||
mode_t util_getmode( const char * filename);
|
||||
bool util_addmode_if_owner( const char * filename , mode_t add_mode );
|
||||
bool util_delmode_if_owner( const char * filename , mode_t del_mode);
|
||||
bool util_chmod_if_owner( const char * filename , mode_t new_mode);
|
||||
@ -390,7 +391,7 @@ typedef enum {left_pad = 0,
|
||||
char * util_alloc_envvar( const char * value );
|
||||
bool util_is_link(const char * ); // Will always return false on windows
|
||||
int util_chdir(const char * path);
|
||||
|
||||
bool util_chdir_file( const char * filename );
|
||||
|
||||
#define UTIL_FWRITE_SCALAR(s,stream) { if (fwrite(&s , sizeof s , 1 , stream) != 1) util_abort("%s: write failed: %s\n",__func__ , strerror(errno)); }
|
||||
|
||||
|
53
ThirdParty/Ert/lib/util/buffer.c
vendored
53
ThirdParty/Ert/lib/util/buffer.c
vendored
@ -816,6 +816,59 @@ void buffer_fwrite_string(buffer_type * buffer , const char * string) {
|
||||
buffer_fwrite(buffer , string , 1 , strlen( string ) + 1); /* Writing the string content ** WITH ** the terminating \0 */
|
||||
}
|
||||
|
||||
/*
|
||||
This is function mainly created for debugging. It will write
|
||||
elements from the buffer according to the fmt string where:
|
||||
|
||||
'c' : char
|
||||
'i' : int
|
||||
't' : time_t
|
||||
'd' : double
|
||||
|
||||
Will write elements from the beginning of the buffer until either
|
||||
the buffer or the fmt string is exhausted.
|
||||
*/
|
||||
|
||||
#define buffer_fprintf_scalar(T,format) { \
|
||||
T value; \
|
||||
memcpy(&value, &buffer->data[offset], sizeof value); \
|
||||
offset += sizeof value; \
|
||||
\
|
||||
fprintf(stream, format, value); \
|
||||
} \
|
||||
|
||||
|
||||
void buffer_fprintf(const buffer_type * buffer, const char * fmt, FILE * stream) {
|
||||
int index=0;
|
||||
size_t offset = 0;
|
||||
while (true) {
|
||||
char fmt_char = fmt[index];
|
||||
switch (fmt_char) {
|
||||
case('d'):
|
||||
buffer_fprintf_scalar( double, "%g ");
|
||||
break;
|
||||
case('i'):
|
||||
buffer_fprintf_scalar( int, "%d ");
|
||||
break;
|
||||
case('c'):
|
||||
buffer_fprintf_scalar( char, "%c ");
|
||||
break;
|
||||
case('t'):
|
||||
buffer_fprintf_scalar( time_t, "%ld ");
|
||||
break;
|
||||
default:
|
||||
util_abort("%s: format character: %c not recognized \n",__func__, fmt_char );
|
||||
}
|
||||
|
||||
index++;
|
||||
if (index == strlen(fmt))
|
||||
break;
|
||||
|
||||
if (offset >= buffer->content_size)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ERT_HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
|
||||
|
65
ThirdParty/Ert/lib/util/log.c
vendored
65
ThirdParty/Ert/lib/util/log.c
vendored
@ -1,22 +1,22 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'log.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'log.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
@ -42,9 +42,10 @@
|
||||
|
||||
struct log_struct {
|
||||
char * filename;
|
||||
FILE * stream;
|
||||
int fd;
|
||||
FILE * stream;
|
||||
int fd;
|
||||
int log_level;
|
||||
int msg_count;
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_t mutex;
|
||||
#endif
|
||||
@ -58,9 +59,9 @@ void log_reopen(log_type *logh , const char *filename) {
|
||||
fclose( logh->stream );
|
||||
file_size = util_file_size( logh->filename );
|
||||
if (file_size == 0)
|
||||
remove( logh->filename ); /* Unlink the old log file if it had zero size. */
|
||||
remove( logh->filename ); /* Unlink the old log file if it had zero size. */
|
||||
}
|
||||
|
||||
|
||||
logh->filename = util_realloc_string_copy( logh->filename , filename );
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock( &logh->mutex );
|
||||
@ -75,7 +76,7 @@ void log_reopen(log_type *logh , const char *filename) {
|
||||
logh->stream = NULL;
|
||||
logh->fd = -1;
|
||||
}
|
||||
|
||||
logh->msg_count = 0;
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock( &logh->mutex );
|
||||
#endif
|
||||
@ -86,6 +87,10 @@ const char * log_get_filename( const log_type * logh ) {
|
||||
return logh->filename;
|
||||
}
|
||||
|
||||
int log_get_msg_count( const log_type * logh) {
|
||||
return logh->msg_count;
|
||||
}
|
||||
|
||||
int log_get_level( const log_type * logh) {
|
||||
return logh->log_level;
|
||||
}
|
||||
@ -104,7 +109,8 @@ log_type * log_open( const char * filename , int log_level) {
|
||||
log_type *logh;
|
||||
|
||||
logh = (log_type*)util_malloc(sizeof *logh );
|
||||
|
||||
|
||||
logh->msg_count = 0;
|
||||
logh->log_level = log_level;
|
||||
logh->filename = NULL;
|
||||
logh->stream = NULL;
|
||||
@ -113,7 +119,7 @@ log_type * log_open( const char * filename , int log_level) {
|
||||
#endif
|
||||
if (filename != NULL && log_level > 0)
|
||||
log_reopen( logh , filename);
|
||||
|
||||
|
||||
return logh;
|
||||
}
|
||||
|
||||
@ -146,14 +152,14 @@ void log_add_message(log_type *logh, int message_level , FILE * dup_stream , cha
|
||||
|
||||
if (logh->stream == NULL)
|
||||
util_abort("%s: logh->stream == NULL - must call log_reset_filename() first \n",__func__);
|
||||
|
||||
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_lock( &logh->mutex );
|
||||
#endif
|
||||
{
|
||||
struct tm time_fields;
|
||||
time_t epoch_time;
|
||||
|
||||
|
||||
time(&epoch_time);
|
||||
util_time_utc(&epoch_time , &time_fields);
|
||||
|
||||
@ -161,12 +167,13 @@ void log_add_message(log_type *logh, int message_level , FILE * dup_stream , cha
|
||||
fprintf(logh->stream,"%02d/%02d - %02d:%02d:%02d %s\n",time_fields.tm_mday, time_fields.tm_mon + 1, time_fields.tm_hour , time_fields.tm_min , time_fields.tm_sec , message);
|
||||
else
|
||||
fprintf(logh->stream,"%02d/%02d - %02d:%02d:%02d \n",time_fields.tm_mday, time_fields.tm_mon + 1, time_fields.tm_hour , time_fields.tm_min , time_fields.tm_sec);
|
||||
|
||||
|
||||
/** We duplicate the message to the stream 'dup_stream'. */
|
||||
if ((dup_stream != NULL) && (message != NULL))
|
||||
fprintf(dup_stream , "%s\n", message);
|
||||
|
||||
|
||||
log_sync( logh );
|
||||
logh->msg_count++;
|
||||
}
|
||||
#ifdef HAVE_PTHREAD
|
||||
pthread_mutex_unlock( &logh->mutex );
|
||||
@ -224,9 +231,9 @@ void log_sync(log_type * logh) {
|
||||
|
||||
|
||||
void log_close( log_type * logh ) {
|
||||
if ((logh->stream != stdout) && (logh->stream != stderr) && (logh->stream != NULL))
|
||||
if ((logh->stream != stdout) && (logh->stream != stderr) && (logh->stream != NULL))
|
||||
fclose( logh->stream ); /* This closes BOTH the FILE * stream and the integer file descriptor. */
|
||||
|
||||
|
||||
util_safe_free( logh->filename );
|
||||
free( logh );
|
||||
}
|
||||
|
87
ThirdParty/Ert/lib/util/matrix_lapack.c
vendored
87
ThirdParty/Ert/lib/util/matrix_lapack.c
vendored
@ -30,14 +30,85 @@ extern "C" {
|
||||
The external lapack routines
|
||||
*/
|
||||
/*****************************************************************/
|
||||
void dgesv_(int * n, int * nrhs , double * A , int * lda , long int * ipivot , double * B , int * ldb , int * info);
|
||||
void dgesvd_(char * jobu , char * jobvt , int * m , int * n , double * A, int * lda , double * S , double * U , int * ldu , double * VT , int * ldvt, double * work , int * worksize , int * info);
|
||||
void dsyevx_(char * jobz, char * range , char * uplo , int *n , double * A , int * lda , double * vl , double * vu , int * il , int * iu , double * abstol , int * m , double * w , double *z , int * ldz , double * work, int * lwork , int * iwork , int * ifail , int * info);
|
||||
void dgeqrf_(int * m , int * n , double * A , int * lda , double * tau , double * work , int * lwork, int * info);
|
||||
void dorgqr_(int * m, int * n , int * k , double * A , int * lda , double * tau , double * work , int * lwork, int * info);
|
||||
void dgetrf_(int * M , int * n , double * A , int * lda , int * ipiv, int * info);
|
||||
void dgedi_(double * A , int * lda , int * n , int * ipiv , double * det , double * work , int * job);
|
||||
void dgetri_( int * n , double * A , int * lda , int * ipiv , double * work , int * work_size , int * info);
|
||||
void dgesv_(int * n,
|
||||
int * nrhs,
|
||||
double * A,
|
||||
int * lda,
|
||||
long int * ipivot,
|
||||
double * B,
|
||||
int * ldb,
|
||||
int * info);
|
||||
void dgesvd_(char * jobu,
|
||||
char * jobvt,
|
||||
int * m,
|
||||
int * n,
|
||||
double * A,
|
||||
int * lda,
|
||||
double * S,
|
||||
double * U,
|
||||
int * ldu,
|
||||
double * VT,
|
||||
int * ldvt,
|
||||
double * work,
|
||||
int * worksize,
|
||||
int * info);
|
||||
void dsyevx_(char * jobz,
|
||||
char * range,
|
||||
char * uplo,
|
||||
int *n,
|
||||
double * A,
|
||||
int * lda,
|
||||
double * vl,
|
||||
double * vu,
|
||||
int * il,
|
||||
int * iu,
|
||||
double * abstol,
|
||||
int * m,
|
||||
double * w,
|
||||
double *z,
|
||||
int * ldz,
|
||||
double * work,
|
||||
int * lwork,
|
||||
int * iwork,
|
||||
int * ifail,
|
||||
int * info);
|
||||
void dgeqrf_(int * m,
|
||||
int * n,
|
||||
double * A,
|
||||
int * lda,
|
||||
double * tau,
|
||||
double * work,
|
||||
int * lwork,
|
||||
int * info);
|
||||
void dorgqr_(int * m,
|
||||
int * n,
|
||||
int * k,
|
||||
double * A,
|
||||
int * lda,
|
||||
double * tau,
|
||||
double * work,
|
||||
int * lwork,
|
||||
int * info);
|
||||
void dgetrf_(int * M,
|
||||
int * n,
|
||||
double * A,
|
||||
int * lda,
|
||||
int * ipiv,
|
||||
int * info);
|
||||
void dgedi_(double * A,
|
||||
int * lda,
|
||||
int * n,
|
||||
int * ipiv,
|
||||
double * det,
|
||||
double * work,
|
||||
int * job);
|
||||
void dgetri_(int * n,
|
||||
double * A,
|
||||
int * lda,
|
||||
int * ipiv,
|
||||
double * work,
|
||||
int * work_size,
|
||||
int * info);
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
|
19
ThirdParty/Ert/lib/util/stringlist.c
vendored
19
ThirdParty/Ert/lib/util/stringlist.c
vendored
@ -790,6 +790,25 @@ int stringlist_append_matching_elements(stringlist_type * target , const stringl
|
||||
return stringlist_append_matching_elements( target , src , pattern );
|
||||
}
|
||||
|
||||
bool stringlist_unique(const stringlist_type * stringlist )
|
||||
{
|
||||
bool unique = true;
|
||||
stringlist_type * cpy = stringlist_alloc_shallow_copy(stringlist);
|
||||
|
||||
stringlist_sort(cpy, strcmp);
|
||||
for (int i = 0; i < stringlist_get_size(cpy) - 1; i++) {
|
||||
const char* s1 = stringlist_iget(cpy, i);
|
||||
const char* s2 = stringlist_iget(cpy, i+1);
|
||||
if (strcmp(s1,s2) == 0) {
|
||||
unique = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
stringlist_free(cpy);
|
||||
return unique;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
45
ThirdParty/Ert/lib/util/tests/ert_util_chdir.c
vendored
Normal file
45
ThirdParty/Ert/lib/util/tests/ert_util_chdir.c
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright (C) 2017 Statoil ASA, Norway.
|
||||
|
||||
The file 'ert_util_chdir.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/test_work_area.h>
|
||||
|
||||
|
||||
void test_chdir() {
|
||||
test_work_area_type * work_area = test_work_area_alloc("test-area");
|
||||
const char * cwd = test_work_area_get_cwd( work_area );
|
||||
|
||||
test_assert_false( util_chdir_file( "/file/does/not/exist"));
|
||||
test_assert_false( util_chdir_file( cwd ));
|
||||
{
|
||||
FILE * stream = util_mkdir_fopen("path/FILE","w");
|
||||
fclose( stream );
|
||||
}
|
||||
test_assert_true( util_chdir_file( "path/FILE" ));
|
||||
test_assert_string_equal( util_alloc_cwd() , util_alloc_filename( cwd, "path", NULL));
|
||||
test_work_area_free( work_area );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_chdir( );
|
||||
exit(0);
|
||||
}
|
38
ThirdParty/Ert/lib/util/tests/ert_util_logh.c
vendored
38
ThirdParty/Ert/lib/util/tests/ert_util_logh.c
vendored
@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ert_util_logh.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ert_util_logh.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
@ -29,14 +29,14 @@ int main(int argc , char ** argv) {
|
||||
test_work_area_type * work_area = test_work_area_alloc("util/logh");
|
||||
{
|
||||
log_type * logh = log_open( NULL , 0 );
|
||||
|
||||
test_assert_int_equal( 0 , log_get_msg_count( logh ));
|
||||
test_assert_false( log_is_open( logh ));
|
||||
log_reopen( logh , LOG_FILE );
|
||||
test_assert_true( log_is_open( logh ));
|
||||
|
||||
|
||||
log_close( logh );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
log_type * logh = log_open( LOG_FILE , 0 );
|
||||
test_assert_not_NULL(logh);
|
||||
@ -46,6 +46,8 @@ int main(int argc , char ** argv) {
|
||||
{
|
||||
log_type * logh = log_open( LOG_FILE , 1 );
|
||||
test_assert_true( log_is_open( logh ));
|
||||
log_add_message( logh , 1 , NULL , "Message" , false);
|
||||
test_assert_int_equal( 1 , log_get_msg_count( logh ));
|
||||
log_close( logh );
|
||||
}
|
||||
|
||||
|
87
ThirdParty/Ert/lib/util/tests/ert_util_spawn.c
vendored
87
ThirdParty/Ert/lib/util/tests/ert_util_spawn.c
vendored
@ -21,12 +21,19 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/rng.h>
|
||||
#include <ert/util/test_work_area.h>
|
||||
#include <ert/util/thread_pool.h>
|
||||
|
||||
|
||||
static const char * stdout_msg = "stdout_xxx";
|
||||
static const char * stderr_msg = "stderr_123";
|
||||
|
||||
|
||||
|
||||
void make_script(const char * name , const char * stdout_msg, const char * stderr_msg) {
|
||||
FILE * stream = util_fopen(name , "w");
|
||||
fprintf(stream,"#!/usr/bin/env python\n");
|
||||
@ -37,17 +44,29 @@ void make_script(const char * name , const char * stdout_msg, const char * stder
|
||||
fprintf(stream,"sys.stderr.flush()\n");
|
||||
fclose( stream );
|
||||
|
||||
util_addmode_if_owner( name , S_IRUSR + S_IWUSR + S_IXUSR + S_IRGRP + S_IWGRP + S_IXGRP + S_IROTH + S_IXOTH); /* u:rwx g:rwx o:rx */
|
||||
|
||||
usleep(100000); // Seems to be required to ensure that the script is actually found on disk. NFS?
|
||||
// Check that the file is actually there (may take a while before it appears on some file systems)
|
||||
for(int attempt = 0; attempt < 10; ++attempt) {
|
||||
if(util_file_exists(name))
|
||||
break;
|
||||
usleep(1 * 1e6);
|
||||
}
|
||||
}
|
||||
|
||||
/// Check that the given script exists and is executable
|
||||
bool check_script(const char* script) {
|
||||
if( ! util_file_exists(script) )
|
||||
return false;
|
||||
mode_t mode = util_getmode( script );
|
||||
return (mode & S_IXUSR) && (mode & S_IXGRP) && (mode & S_IXOTH);
|
||||
}
|
||||
|
||||
void test_spawn_no_redirect() {
|
||||
test_work_area_type * test_area = test_work_area_alloc("spawn1");
|
||||
{
|
||||
int status;
|
||||
make_script("script" , "stdout" , "stderr");
|
||||
make_script("script" , stdout_msg , stderr_msg);
|
||||
util_addmode_if_owner( "script" , S_IRUSR + S_IWUSR + S_IXUSR + S_IRGRP + S_IWGRP + S_IXGRP + S_IROTH + S_IXOTH); /* u:rwx g:rwx o:rx */
|
||||
test_assert_true(check_script("script"));
|
||||
|
||||
/* Blocking */
|
||||
status = util_spawn_blocking("script" , 0 , NULL , NULL , NULL);
|
||||
@ -65,9 +84,6 @@ void test_spawn_no_redirect() {
|
||||
|
||||
|
||||
void * test_spawn_redirect__( void * path ) {
|
||||
const char * stdout_msg = "stdout_xxx";
|
||||
const char * stderr_msg = "stderr_123";
|
||||
|
||||
char * stdout_file;
|
||||
char * stderr_file;
|
||||
char * script;
|
||||
@ -82,8 +98,6 @@ void * test_spawn_redirect__( void * path ) {
|
||||
script = util_alloc_string_copy("script");
|
||||
}
|
||||
|
||||
make_script(script , stdout_msg , stderr_msg);
|
||||
|
||||
/* Blocking */
|
||||
while (true) {
|
||||
int status;
|
||||
@ -116,9 +130,9 @@ void * test_spawn_redirect__( void * path ) {
|
||||
test_assert_file_content( stdout_file , stdout_msg );
|
||||
test_assert_file_content( stderr_file , stderr_msg );
|
||||
|
||||
free( stdout_file );
|
||||
free( stderr_file );
|
||||
free( script );
|
||||
util_free( stdout_file );
|
||||
util_free( stderr_file );
|
||||
util_free( script );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -126,26 +140,63 @@ void * test_spawn_redirect__( void * path ) {
|
||||
void test_spawn_redirect() {
|
||||
test_work_area_type * test_area = test_work_area_alloc("spawn1");
|
||||
{
|
||||
make_script("script" , stdout_msg , stderr_msg);
|
||||
util_addmode_if_owner( "script" , S_IRUSR + S_IWUSR + S_IXUSR + S_IRGRP + S_IWGRP + S_IXGRP + S_IROTH + S_IXOTH); /* u:rwx g:rwx o:rx */
|
||||
test_assert_true(check_script("script"));
|
||||
|
||||
test_spawn_redirect__( NULL );
|
||||
}
|
||||
test_work_area_free( test_area );
|
||||
}
|
||||
|
||||
void test_spawn_redirect_threaded() {
|
||||
void test_spawn_redirect_threaded() {
|
||||
rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT );
|
||||
const int num = 128;
|
||||
|
||||
// Generate the scripts on disk first
|
||||
test_work_area_type * test_area = test_work_area_alloc("spawn1_threaded");
|
||||
thread_pool_type * tp = thread_pool_alloc( 8 , true );
|
||||
int * path_codes = (int *)util_calloc(num, sizeof *path_codes);
|
||||
stringlist_type * script_fullpaths = stringlist_alloc_new();
|
||||
for (int i=0; i < num; i++) {
|
||||
char * path = util_alloc_sprintf("%06d" , rng_get_int( rng , 1000000));
|
||||
util_make_path( path );
|
||||
thread_pool_add_job( tp , test_spawn_redirect__ , path );
|
||||
path_codes[i] = rng_get_int( rng , 1000000);
|
||||
|
||||
char * path = util_alloc_sprintf("%06d" , path_codes[i]);
|
||||
util_make_path( path );
|
||||
char * script = util_alloc_filename( path , "script" , NULL);
|
||||
make_script(script, stdout_msg, stderr_msg);
|
||||
stringlist_append_owned_ref(script_fullpaths, script);
|
||||
util_free(path);
|
||||
}
|
||||
|
||||
// Set file access permissions
|
||||
for(int i = 0; i < num; i++) {
|
||||
char const * script = stringlist_iget(script_fullpaths, i);
|
||||
util_addmode_if_owner( script , S_IRUSR + S_IWUSR + S_IXUSR + S_IRGRP + S_IWGRP + S_IXGRP + S_IROTH + S_IXOTH); /* u:rwx g:rwx o:rx */
|
||||
}
|
||||
|
||||
// Double check that the scripts are present and executable
|
||||
for(int i = 0; i < num; i++) {
|
||||
char const * script = stringlist_iget(script_fullpaths, i);
|
||||
test_assert_true(check_script(script));
|
||||
}
|
||||
|
||||
// Run the scripts in parallel
|
||||
stringlist_type * script_paths = stringlist_alloc_new(); // free the paths after threads have completed
|
||||
thread_pool_type * tp = thread_pool_alloc( 8 , true );
|
||||
for(int i = 0; i < num; i++) {
|
||||
char * path = util_alloc_sprintf("%06d" , path_codes[i]);
|
||||
stringlist_append_owned_ref(script_paths, path);
|
||||
thread_pool_add_job( tp , test_spawn_redirect__ , path );
|
||||
}
|
||||
thread_pool_join( tp );
|
||||
thread_pool_free( tp );
|
||||
stringlist_free(script_paths);
|
||||
|
||||
stringlist_free(script_fullpaths);
|
||||
util_free(path_codes);
|
||||
test_work_area_free( test_area );
|
||||
rng_free( rng );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'ert_util_stringlist_test.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'ert_util_stringlist_test.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
@ -102,7 +102,7 @@ void test_reverse() {
|
||||
const char *s0 = "AAA";
|
||||
const char *s1 = "BBB";
|
||||
const char *s2 = "CCC";
|
||||
|
||||
|
||||
stringlist_type * s = stringlist_alloc_new();
|
||||
stringlist_append_ref( s , s0 );
|
||||
stringlist_append_ref( s , s1 );
|
||||
@ -129,7 +129,7 @@ void test_iget_as_int() {
|
||||
value = stringlist_iget_as_int( s , 0 , &valid);
|
||||
test_assert_int_equal( value , 1000);
|
||||
test_assert_true( valid );
|
||||
|
||||
|
||||
value = stringlist_iget_as_int( s , 1 , &valid);
|
||||
test_assert_int_equal( value , -1);
|
||||
test_assert_false( valid );
|
||||
@ -268,7 +268,7 @@ void test_split() {
|
||||
test_assert_string_equal( "Hove" , stringlist_iget( s1 , 4 ));
|
||||
stringlist_free( s1 );
|
||||
|
||||
|
||||
|
||||
s1 = stringlist_alloc_from_split("StringWithNoSPlit" , " ");
|
||||
test_assert_int_equal( 1 , stringlist_get_size( s1 ));
|
||||
test_assert_string_equal( "StringWithNoSPlit" , stringlist_iget( s1 , 0 ));
|
||||
@ -314,7 +314,7 @@ void test_matching() {
|
||||
test_assert_string_equal( "ABC" , stringlist_iget( s2 , 1 ));
|
||||
test_assert_string_equal( "123" , stringlist_iget( s2 , 2 ));
|
||||
test_assert_string_equal( "ABC:123" , stringlist_iget( s2 , 3 ));
|
||||
|
||||
|
||||
|
||||
stringlist_append_matching_elements( s2 , s1 , "*");
|
||||
test_assert_int_equal( 8 , stringlist_get_size( s2 ));
|
||||
@ -327,7 +327,7 @@ void test_matching() {
|
||||
test_assert_string_equal( "ABC" , stringlist_iget( s2 , 5 ));
|
||||
test_assert_string_equal( "123" , stringlist_iget( s2 , 6 ));
|
||||
test_assert_string_equal( "ABC:123" , stringlist_iget( s2 , 7 ));
|
||||
|
||||
|
||||
stringlist_select_matching_elements( s2 , s1 , "*B*");
|
||||
test_assert_int_equal( 2 , stringlist_get_size( s2 ));
|
||||
test_assert_string_equal( "ABC" , stringlist_iget( s2 , 0 ));
|
||||
@ -338,6 +338,22 @@ void test_matching() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_unique() {
|
||||
stringlist_type * s = stringlist_alloc_new();
|
||||
|
||||
test_assert_true( stringlist_unique( s ));
|
||||
|
||||
stringlist_append_ref( s, "S1");
|
||||
test_assert_true( stringlist_unique( s ));
|
||||
|
||||
stringlist_append_ref( s, "S2");
|
||||
test_assert_true( stringlist_unique( s ));
|
||||
|
||||
stringlist_append_ref( s, "S2");
|
||||
test_assert_false( stringlist_unique( s ));
|
||||
}
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
test_empty();
|
||||
test_char();
|
||||
@ -348,5 +364,6 @@ int main( int argc , char ** argv) {
|
||||
test_iget_as_double();
|
||||
test_split();
|
||||
test_matching();
|
||||
test_unique();
|
||||
exit(0);
|
||||
}
|
||||
|
19
ThirdParty/Ert/lib/util/util.c
vendored
19
ThirdParty/Ert/lib/util/util.c
vendored
@ -5500,3 +5500,22 @@ int util_chdir(const char * path) {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
bool util_chdir_file( const char * filename ) {
|
||||
if (!util_is_file( filename ))
|
||||
return false;
|
||||
|
||||
bool chdir_OK = false;
|
||||
char * path;
|
||||
char * abs_path;
|
||||
util_alloc_file_components( filename , &path, NULL , NULL );
|
||||
abs_path = util_alloc_abs_path( path );
|
||||
if (util_is_directory( abs_path ))
|
||||
chdir_OK = (0 == util_chdir( abs_path ));
|
||||
|
||||
free( abs_path );
|
||||
free( path );
|
||||
return chdir_OK;
|
||||
}
|
||||
|
6
ThirdParty/Ert/lib/util/util_getuid.c
vendored
6
ThirdParty/Ert/lib/util/util_getuid.c
vendored
@ -13,6 +13,12 @@ uid_t util_get_entry_uid( const char * file ) {
|
||||
return buffer.st_uid;
|
||||
}
|
||||
|
||||
mode_t util_getmode( const char * file ) {
|
||||
stat_type buffer;
|
||||
util_stat( file , &buffer);
|
||||
return buffer.st_mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool util_chmod_if_owner( const char * filename , mode_t new_mode) {
|
||||
|
12
ThirdParty/Ert/python/python/cwrap/prototype.py
vendored
12
ThirdParty/Ert/python/python/cwrap/prototype.py
vendored
@ -71,7 +71,7 @@ class PrototypeError(Exception):
|
||||
class Prototype(object):
|
||||
pattern = re.compile(PROTOTYPE_PATTERN)
|
||||
|
||||
def __init__(self, lib, prototype, bind=False):
|
||||
def __init__(self, lib, prototype, bind=False, allow_attribute_error=False):
|
||||
super(Prototype, self).__init__()
|
||||
self._lib = lib
|
||||
self._prototype = prototype
|
||||
@ -79,6 +79,8 @@ class Prototype(object):
|
||||
self._func = None
|
||||
self.__name__ = prototype
|
||||
self._resolved = False
|
||||
self._allow_attribute_error = allow_attribute_error
|
||||
|
||||
|
||||
|
||||
def _parseType(self, type_name):
|
||||
@ -107,6 +109,8 @@ class Prototype(object):
|
||||
try:
|
||||
func = getattr(self._lib, function_name)
|
||||
except AttributeError:
|
||||
if self._allow_attribute_error:
|
||||
return
|
||||
raise PrototypeError("Can not find function: %s in library: %s" % (function_name , self._lib))
|
||||
|
||||
if not restype in REGISTERED_TYPES or not REGISTERED_TYPES[restype].is_return_type:
|
||||
@ -148,7 +152,11 @@ class Prototype(object):
|
||||
self._resolved = True
|
||||
|
||||
if self._func is None:
|
||||
raise PrototypeError("Prototype has not been properly resolved!")
|
||||
if self._allow_attribute_error:
|
||||
raise NotImplementedError("Function:%s has not been properly resolved - missing library symbol?" % self.__name__)
|
||||
else:
|
||||
raise PrototypeError("Prototype has not been properly resolved")
|
||||
|
||||
return self._func(*args)
|
||||
|
||||
def __repr__(self):
|
||||
|
38
ThirdParty/Ert/python/python/ecl/ecl/ecl_sum.py
vendored
38
ThirdParty/Ert/python/python/ecl/ecl/ecl_sum.py
vendored
@ -86,7 +86,8 @@ def date2num(dt):
|
||||
|
||||
class EclSum(BaseCClass):
|
||||
TYPE_NAME = "ecl_sum"
|
||||
_fread_alloc = EclPrototype("void* ecl_sum_fread_alloc_case__(char*, char*, bool)", bind=False)
|
||||
_fread_alloc_case = EclPrototype("void* ecl_sum_fread_alloc_case__(char*, char*, bool)", 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_writer(char*, char*, bool, bool, char*, time_t, bool, int, int, int)", bind = False)
|
||||
_iiget = EclPrototype("double ecl_sum_iget(ecl_sum, int, int)")
|
||||
_free = EclPrototype("void ecl_sum_free(ecl_sum)")
|
||||
@ -159,15 +160,33 @@ class EclSum(BaseCClass):
|
||||
"""
|
||||
if not load_case:
|
||||
raise ValueError('load_case must be the basename of the simulation')
|
||||
c_pointer = self._fread_alloc(load_case, join_string, include_restart)
|
||||
c_pointer = self._fread_alloc_case(load_case, join_string, include_restart)
|
||||
if c_pointer is None:
|
||||
raise IOError("Failed to create summary instance from argument:%s" % load_case)
|
||||
else:
|
||||
super(EclSum, self).__init__(c_pointer)
|
||||
self.__private_init()
|
||||
|
||||
super(EclSum, self).__init__(c_pointer)
|
||||
self.__private_init()
|
||||
self._load_case = load_case
|
||||
|
||||
|
||||
@classmethod
|
||||
def load(cls, smspec_file, unsmry_file, key_join_string = ":", include_restart = True):
|
||||
if not os.path.isfile( smspec_file ):
|
||||
raise IOError("No such file: %s" % smspec_file)
|
||||
|
||||
if not os.path.isfile( unsmry_file ):
|
||||
raise IOError("No such file: %s" % unsmry_file )
|
||||
|
||||
data_files = StringList( )
|
||||
data_files.append( unsmry_file )
|
||||
c_ptr = cls._fread_alloc(smspec_file, data_files, key_join_string, include_restart)
|
||||
if c_ptr is None:
|
||||
raise IOError("Failed to create summary instance")
|
||||
|
||||
ecl_sum = cls.createPythonObject( c_ptr )
|
||||
ecl_sum._load_case = smspec_file
|
||||
return ecl_sum
|
||||
|
||||
|
||||
@classmethod
|
||||
def createCReference(cls, c_pointer, parent=None):
|
||||
@ -519,6 +538,13 @@ class EclSum(BaseCClass):
|
||||
raise ValueError("Must supply either days or date")
|
||||
|
||||
|
||||
def get_interp_row(self, key_list, sim_time):
|
||||
ctime = CTime(sim_time)
|
||||
data = DoubleVector( initial_size = len(key_list) )
|
||||
EclSum._get_interp_vector(self, ctime, key_list, data)
|
||||
return data
|
||||
|
||||
|
||||
def time_range(self, start=None, end=None, interval="1Y", extend_end=True):
|
||||
(num, timeUnit) = TimeVector.parseTimeUnit(interval)
|
||||
|
||||
@ -1227,6 +1253,7 @@ class EclSum(BaseCClass):
|
||||
EclSum._dump_csv_line(self, ctime, keywords, cfile)
|
||||
|
||||
|
||||
|
||||
def export_csv(self, filename, keys=None, date_format="%Y-%m-%d", sep=";"):
|
||||
"""Will create a CSV file with summary data.
|
||||
|
||||
@ -1254,6 +1281,7 @@ class EclSum(BaseCClass):
|
||||
|
||||
import ecl.ecl.ecl_sum_keyword_vector
|
||||
EclSum._dump_csv_line = EclPrototype("void ecl_sum_fwrite_interp_csv_line(ecl_sum, time_t, ecl_sum_vector, FILE)", bind=False)
|
||||
EclSum._get_interp_vector = EclPrototype("void ecl_sum_get_interp_vector(ecl_sum, time_t, ecl_sum_vector, double_vector)", bind=False)
|
||||
|
||||
monkey_the_camel(EclSum, 'varType', EclSum.var_type, classmethod)
|
||||
monkey_the_camel(EclSum, 'addVariable', EclSum.add_variable)
|
||||
|
@ -36,12 +36,21 @@ class EclSumKeyWordVector(BaseCClass):
|
||||
_add = EclPrototype("bool ecl_sum_vector_add_key(ecl_sum_vector, char*)")
|
||||
_add_multiple = EclPrototype("void ecl_sum_vector_add_keys(ecl_sum_vector, char*)")
|
||||
_get_size = EclPrototype("int ecl_sum_vector_get_size(ecl_sum_vector)")
|
||||
|
||||
_iget_key = EclPrototype("char* ecl_sum_vector_iget_key(ecl_sum_vector, int)")
|
||||
|
||||
def __init__(self, ecl_sum):
|
||||
c_pointer = self._alloc(ecl_sum)
|
||||
super(EclSumKeyWordVector, self).__init__(c_pointer)
|
||||
|
||||
def __getitem__(self, index):
|
||||
if index < 0:
|
||||
index += len(self)
|
||||
|
||||
if index >= len(self):
|
||||
raise IndexError("Out of range")
|
||||
|
||||
return self._iget_key( index )
|
||||
|
||||
def __len__(self):
|
||||
return self._get_size()
|
||||
|
||||
|
@ -3,5 +3,4 @@ set(PYTHON_SOURCES
|
||||
ecl_sum_mock.py
|
||||
)
|
||||
|
||||
# The ecl_mock package is not installed.
|
||||
add_python_package("python.ecl.test.ecl_mock" ${PYTHON_INSTALL_PREFIX}/ecl/test/ecl_mock "${PYTHON_SOURCES}" False)
|
||||
add_python_package("python.ecl.test.ecl_mock" ${PYTHON_INSTALL_PREFIX}/ecl/test/ecl_mock "${PYTHON_SOURCES}" True)
|
||||
|
@ -46,8 +46,8 @@ from cwrap import Prototype
|
||||
class UtilPrototype(Prototype):
|
||||
lib = ecl.load("libecl")
|
||||
|
||||
def __init__(self, prototype, bind=True):
|
||||
super(UtilPrototype, self).__init__(UtilPrototype.lib, prototype, bind=bind)
|
||||
def __init__(self, prototype, bind=True, allow_attribute_error=False):
|
||||
super(UtilPrototype, self).__init__(UtilPrototype.lib, prototype, bind=bind, allow_attribute_error=allow_attribute_error)
|
||||
|
||||
|
||||
|
||||
|
59
ThirdParty/Ert/python/python/ecl/util/matrix.py
vendored
59
ThirdParty/Ert/python/python/ecl/util/matrix.py
vendored
@ -1,19 +1,19 @@
|
||||
|
||||
# Copyright (C) 2011 Statoil ASA, Norway.
|
||||
#
|
||||
# The file 'matrix.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 <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
# Copyright (C) 2011 Statoil ASA, Norway.
|
||||
#
|
||||
# The file 'matrix.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 <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
|
||||
|
||||
# The Matrix class implemented here wraps the C matrix implementation
|
||||
@ -53,10 +53,12 @@ class Matrix(BaseCClass):
|
||||
_fprint = UtilPrototype("void matrix_fprintf(matrix, char*, FILE)")
|
||||
_random_init = UtilPrototype("void matrix_random_init(matrix, rng)")
|
||||
_dump_csv = UtilPrototype("void matrix_dump_csv(matrix, char*)")
|
||||
|
||||
# Requires BLAS!
|
||||
_alloc_matmul = UtilPrototype("matrix_obj matrix_alloc_matmul(matrix, matrix)" , bind = False)
|
||||
|
||||
# Requires BLAS. If the library does not have the
|
||||
# matrix_alloc_matmul() function the prototype will have _func =
|
||||
# None, and NotImplementedError( ) will be raised int the
|
||||
# __call__() method if we try to use this function.
|
||||
_alloc_matmul = UtilPrototype("matrix_obj matrix_alloc_matmul(matrix, matrix)" , bind = False, allow_attribute_error = True)
|
||||
|
||||
# Requires BLAS!
|
||||
@classmethod
|
||||
@ -67,9 +69,9 @@ class Matrix(BaseCClass):
|
||||
if m1.columns( ) == m2.rows( ):
|
||||
return cls._alloc_matmul( m1, m2)
|
||||
else:
|
||||
raise ValueError("Matrix size mismathc")
|
||||
|
||||
|
||||
raise ValueError("Matrix size mismatch")
|
||||
|
||||
|
||||
def __init__(self, rows, columns, value=0):
|
||||
c_ptr = self._matrix_alloc(rows, columns)
|
||||
super(Matrix, self).__init__(c_ptr)
|
||||
@ -100,7 +102,7 @@ class Matrix(BaseCClass):
|
||||
|
||||
return self._sub_copy( row_offset , column_offset , rows , columns)
|
||||
|
||||
|
||||
|
||||
def __str__(self):
|
||||
s = ""
|
||||
for i in range(self.rows()):
|
||||
@ -145,7 +147,7 @@ class Matrix(BaseCClass):
|
||||
return self
|
||||
else:
|
||||
return self._alloc_transpose( )
|
||||
|
||||
|
||||
|
||||
def columns(self):
|
||||
""" @rtype: int """
|
||||
@ -183,7 +185,7 @@ class Matrix(BaseCClass):
|
||||
|
||||
def dumpCSV(self , filename):
|
||||
self._dump_csv( filename )
|
||||
|
||||
|
||||
|
||||
def prettyPrint(self, name, fmt="%6.3g"):
|
||||
self._pretty_print(name, fmt)
|
||||
@ -201,22 +203,25 @@ class Matrix(BaseCClass):
|
||||
[6 7 8]
|
||||
|
||||
The code:
|
||||
|
||||
|
||||
with open("matrix.txt" , "w") as f:
|
||||
m.fprintf( f )
|
||||
|
||||
The file 'matrix.txt' will look like:
|
||||
|
||||
0 1 2
|
||||
0 1 2
|
||||
3 4 5
|
||||
6 7 8
|
||||
|
||||
"""
|
||||
self._fprint( fmt , CFILE( fileH))
|
||||
|
||||
|
||||
|
||||
def randomInit(self, rng):
|
||||
self._random_init(rng)
|
||||
|
||||
def free(self):
|
||||
self._free()
|
||||
|
||||
|
||||
|
||||
|
@ -179,6 +179,15 @@ class EclFileTest(ExtendedTestCase):
|
||||
self.assertEqual( kw1, kw2 )
|
||||
|
||||
|
||||
def test_broken_file(self):
|
||||
with TestAreaContext("test_broken_file"):
|
||||
with open("CASE.FINIT", "w") as f:
|
||||
f.write("This - is not a ECLISPE file\nsdlcblhcdbjlwhc\naschscbasjhcasc\nascasck c s s aiasic asc")
|
||||
|
||||
|
||||
with self.assertRaises(IOError):
|
||||
f = EclFile("CASE.FINIT")
|
||||
|
||||
|
||||
def test_block_view(self):
|
||||
with TestAreaContext("python/ecl_file/view"):
|
||||
|
@ -33,7 +33,6 @@ class EclSumVectorTest(ExtendedTestCase):
|
||||
self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.SMSPEC")
|
||||
self.ecl_sum = EclSum(self.test_file)
|
||||
|
||||
|
||||
def test_reportOnly_warns(self):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always")
|
||||
|
147
ThirdParty/Ert/python/tests/ecl/test_sum.py
vendored
147
ThirdParty/Ert/python/tests/ecl/test_sum.py
vendored
@ -1,26 +1,26 @@
|
||||
#!/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 <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
# 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
|
||||
import os
|
||||
import datetime
|
||||
import csv
|
||||
import shutil
|
||||
from unittest import skipIf, skipUnless, skipIf
|
||||
|
||||
from ecl.ecl import EclSum, EclSumVarType
|
||||
from ecl.ecl import EclSum, EclSumVarType, FortIO, openFortIO, EclKW, EclDataType, EclSumKeyWordVector
|
||||
from ecl.test import ExtendedTestCase, TestAreaContext
|
||||
from ecl.test.ecl_mock import createEclSum
|
||||
|
||||
@ -38,7 +38,7 @@ def fgpt(days):
|
||||
|
||||
class SumTest(ExtendedTestCase):
|
||||
|
||||
|
||||
|
||||
def test_mock(self):
|
||||
case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)])
|
||||
self.assertTrue("FOPT" in case)
|
||||
@ -86,10 +86,10 @@ class SumTest(ExtendedTestCase):
|
||||
self.assertGreater( node2, node3 )
|
||||
self.assertEqual( node1, node1 )
|
||||
self.assertNotEqual( node1, node2 )
|
||||
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
a = node1 < 1
|
||||
|
||||
|
||||
def test_csv_export(self):
|
||||
case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)])
|
||||
sep = ";"
|
||||
@ -104,8 +104,8 @@ class SumTest(ExtendedTestCase):
|
||||
self.assertIn("FOPR", row)
|
||||
self.assertEqual( len(row) , 4 )
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
with TestAreaContext("ecl/csv"):
|
||||
case.exportCSV( "file.csv" , keys = ["FOPT"] , sep = sep)
|
||||
@ -117,8 +117,8 @@ class SumTest(ExtendedTestCase):
|
||||
self.assertIn("FOPT", row)
|
||||
self.assertEqual( len(row) , 3 )
|
||||
break
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
with TestAreaContext("ecl/csv"):
|
||||
date_format = "%y-%m-%d"
|
||||
@ -136,8 +136,8 @@ class SumTest(ExtendedTestCase):
|
||||
self.assertEqual( case.iget_date( time_index ) , d )
|
||||
|
||||
time_index += 1
|
||||
|
||||
|
||||
|
||||
|
||||
def test_solve(self):
|
||||
length = 100
|
||||
case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)],
|
||||
@ -147,10 +147,13 @@ class SumTest(ExtendedTestCase):
|
||||
func_table = {"FOPT" : fopt,
|
||||
"FOPR" : fopr ,
|
||||
"FGPT" : fgpt })
|
||||
|
||||
|
||||
self.assert_solve( case )
|
||||
|
||||
def assert_solve(self, case):
|
||||
with self.assertRaises( KeyError ):
|
||||
case.solveDays( "MISSING:KEY" , 0.56)
|
||||
|
||||
|
||||
sol = case.solveDays( "FOPT" , 150 )
|
||||
self.assertEqual( len(sol) , 0 )
|
||||
|
||||
@ -172,7 +175,7 @@ class SumTest(ExtendedTestCase):
|
||||
sol = case.solveDates("FOPR" , 50.90)
|
||||
t = case.getDataStartTime( ) + datetime.timedelta( days = 50 ) + datetime.timedelta( seconds = 1 )
|
||||
self.assertEqual( sol[0] , t )
|
||||
|
||||
|
||||
sol = case.solveDays( "FOPR" , 50.90 , rates_clamp_lower = False)
|
||||
self.assertEqual( len(sol) , 1 )
|
||||
self.assertFloatEqual( sol[0] , 51.00 )
|
||||
@ -190,6 +193,7 @@ class SumTest(ExtendedTestCase):
|
||||
self.assertEqual( sol[0] , t1 )
|
||||
self.assertEqual( sol[1] , t2 )
|
||||
|
||||
|
||||
def test_ecl_sum_vector_algebra(self):
|
||||
scalar = 0.78
|
||||
addend = 2.718281828459045
|
||||
@ -224,3 +228,88 @@ class SumTest(ExtendedTestCase):
|
||||
x = x + addend # numpy vector shifting
|
||||
for i in range(len(x)):
|
||||
self.assertFloatEqual(x[i], y[i])
|
||||
|
||||
|
||||
def test_different_names(self):
|
||||
length = 100
|
||||
case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)],
|
||||
sim_length_days = length,
|
||||
num_report_step = 10,
|
||||
num_mini_step = 10,
|
||||
func_table = {"FOPT" : fopt,
|
||||
"FOPR" : fopr ,
|
||||
"FGPT" : fgpt })
|
||||
|
||||
with TestAreaContext("sum_different"):
|
||||
case.fwrite( )
|
||||
shutil.move("CSV.SMSPEC" , "CSVX.SMSPEC")
|
||||
with self.assertRaises(IOError):
|
||||
case2 = EclSum.load( "Does/not/exist" , "CSV.UNSMRY")
|
||||
|
||||
with self.assertRaises(IOError):
|
||||
case2 = EclSum.load( "CSVX.SMSPEC" , "CSVX.UNSMRY")
|
||||
|
||||
case2 = EclSum.load( "CSVX.SMSPEC" , "CSV.UNSMRY" )
|
||||
self.assert_solve( case2 )
|
||||
|
||||
def test_invalid(self):
|
||||
case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)],
|
||||
sim_length_days = 100,
|
||||
num_report_step = 10,
|
||||
num_mini_step = 10,
|
||||
func_table = {"FOPT" : fopt,
|
||||
"FOPR" : fopr ,
|
||||
"FGPT" : fgpt })
|
||||
|
||||
with TestAreaContext("sum_invalid"):
|
||||
case.fwrite( )
|
||||
with open("CASE.txt", "w") as f:
|
||||
f.write("No - this is not EclKW file ....")
|
||||
|
||||
with self.assertRaises( IOError ):
|
||||
case2 = EclSum.load( "CSV.SMSPEC" , "CASE.txt" )
|
||||
|
||||
with self.assertRaises( IOError ):
|
||||
case2 = EclSum.load( "CASE.txt" , "CSV.UNSMRY" )
|
||||
|
||||
kw1 = EclKW("TEST1", 30, EclDataType.ECL_INT)
|
||||
kw2 = EclKW("TEST2", 30, EclDataType.ECL_INT)
|
||||
|
||||
with openFortIO( "CASE.KW" , FortIO.WRITE_MODE) as f:
|
||||
kw1.fwrite( f )
|
||||
kw2.fwrite( f )
|
||||
|
||||
with self.assertRaises( IOError ):
|
||||
case2 = EclSum.load( "CSV.SMSPEC" , "CASE.KW")
|
||||
|
||||
with self.assertRaises( IOError ):
|
||||
case2 = EclSum.load( "CASE.KW" , "CSV.UNSMRY" )
|
||||
|
||||
|
||||
def test_kw_vector(self):
|
||||
case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)],
|
||||
sim_length_days = 100,
|
||||
num_report_step = 10,
|
||||
num_mini_step = 10,
|
||||
func_table = {"FOPT" : fopt,
|
||||
"FOPR" : fopr ,
|
||||
"FGPT" : fgpt })
|
||||
kw_list = EclSumKeyWordVector( case )
|
||||
kw_list.add_keyword("FOPT")
|
||||
kw_list.add_keyword("FOPR")
|
||||
kw_list.add_keyword("FGPT")
|
||||
|
||||
t = case.getDataStartTime( ) + datetime.timedelta( days = 43 );
|
||||
data = case.get_interp_row( kw_list , t )
|
||||
for d1,d2 in zip(data, [ case.get_interp("FOPT", date = t),
|
||||
case.get_interp("FOPT", date = t),
|
||||
case.get_interp("FOPT", date = t) ]):
|
||||
|
||||
self.assertFloatEqual(d1,d2)
|
||||
|
||||
tmp = []
|
||||
for key in kw_list:
|
||||
tmp.append(key)
|
||||
|
||||
for (k1,k2) in zip(kw_list,tmp):
|
||||
self.assertEqual(k1,k2)
|
||||
|
Loading…
Reference in New Issue
Block a user