mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1641 Update libecl to latest revision from master
This commit is contained in:
parent
faf225d8c3
commit
956798afd6
11
ThirdParty/Ert/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
11
ThirdParty/Ert/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
**Task**
|
||||
_Short description of the task_
|
||||
|
||||
|
||||
**Approach**
|
||||
_Short description of the approach_
|
||||
|
||||
|
||||
**Pre un-WIP checklist**
|
||||
- [ ] Statoil tests pass locally
|
||||
- [ ] Have completed graphical integration test steps
|
36
ThirdParty/Ert/.travis.yml
vendored
36
ThirdParty/Ert/.travis.yml
vendored
@ -1,7 +1,16 @@
|
||||
dist: trusty
|
||||
sudo: false
|
||||
language: c
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
compiler: clang
|
||||
- os: linux
|
||||
sudo: false
|
||||
compiler: gcc
|
||||
dist: trusty
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
@ -11,6 +20,9 @@ addons:
|
||||
- valgrind
|
||||
- gcc-4.8
|
||||
- g++-4.8
|
||||
- clang
|
||||
- cmake
|
||||
- cmake-data
|
||||
|
||||
env:
|
||||
global:
|
||||
@ -18,7 +30,18 @@ env:
|
||||
|
||||
install:
|
||||
- if [[ "$CC" == "gcc" ]]; then export CXX="g++-4.8"; fi
|
||||
- wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
export CONDA_OS=MacOSX;
|
||||
else
|
||||
export CONDA_OS=Linux;
|
||||
fi
|
||||
- export TRAVIS_PYTHON_VERSION="2.7"
|
||||
# We do this conditionally because it saves us some downloading if the version is the same.
|
||||
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
|
||||
wget https://repo.continuum.io/miniconda/Miniconda2-latest-${CONDA_OS}-x86_64.sh -O miniconda.sh;
|
||||
else
|
||||
wget https://repo.continuum.io/miniconda/Miniconda3-latest-${CONDA_OS}-x86_64.sh -O miniconda.sh;
|
||||
fi
|
||||
- bash miniconda.sh -b -p $HOME/miniconda
|
||||
- export CONDA_HOME="$HOME/miniconda"
|
||||
- export PATH="$CONDA_HOME/bin:$PATH"
|
||||
@ -29,10 +52,7 @@ install:
|
||||
- conda install pylint numpy pandas
|
||||
|
||||
before_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -DBUILD_TESTS=ON -DBUILD_PYTHON=ON -DERT_BUILD_CXX=ON -DBUILD_APPLICATIONS=ON ..
|
||||
- wget https://raw.githubusercontent.com/Statoil/ert/master/travis/build_total.py
|
||||
|
||||
script:
|
||||
- make
|
||||
- ctest --output-on-failure -E ert_util_ping
|
||||
- python build_total.py ecl
|
||||
|
285
ThirdParty/Ert/CMakeLists.txt
vendored
285
ThirdParty/Ert/CMakeLists.txt
vendored
@ -1,6 +1,8 @@
|
||||
cmake_minimum_required( VERSION 2.8 )
|
||||
cmake_minimum_required( VERSION 2.8.12 )
|
||||
project( ERT C CXX )
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
if(POLICY CMP0042)
|
||||
cmake_policy(SET CMP0042 OLD)
|
||||
endif()
|
||||
@ -19,15 +21,13 @@ set( ERT_VERSION_MICRO git ) # with "new in Ert Version X.X.X"!
|
||||
option( BUILD_TESTS "Should the tests be built" OFF)
|
||||
option( BUILD_APPLICATIONS "Should we build small utility applications" OFF)
|
||||
option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF)
|
||||
option( BUILD_PYTHON "Run py_compile on the python wrappers" ON )
|
||||
option( BUILD_PYTHON "Run py_compile on the python wrappers" OFF)
|
||||
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
|
||||
option( INSTALL_ERT "Should anything be installed when issuing make install?" ON )
|
||||
option( ERT_USE_OPENMP "Use OpenMP" OFF )
|
||||
option( ERT_DOC "Build ERT documantation" OFF)
|
||||
option( RST_DOC "Build RST documentation" OFF)
|
||||
option( ERT_BUILD_CXX "Build some CXX wrappers" ON)
|
||||
|
||||
|
||||
|
||||
option( USE_RPATH "Don't strip RPATH from libraries and binaries" OFF)
|
||||
option( INSTALL_ERT_LEGACY "Add ert legacy wrappers" OFF)
|
||||
|
||||
|
||||
set(STATOIL_TESTDATA_ROOT "" CACHE PATH "Root to Statoil internal testdata")
|
||||
@ -39,12 +39,22 @@ if (EXISTS ${STATOIL_TESTDATA_ROOT})
|
||||
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${STATOIL_TESTDATA_ROOT}" "${LINK}")
|
||||
message(STATUS "Linking testdata: ${LINK} -> ${STATOIL_TESTDATA_ROOT}")
|
||||
|
||||
set(_statoil_test_data ${CMAKE_SOURCE_DIR}/test-data/Statoil)
|
||||
set(_eclpath ${_statoil_test_data}/ECLIPSE)
|
||||
set(_geopath ${_statoil_test_data}/Geometry)
|
||||
endif()
|
||||
|
||||
|
||||
# output libs to some lib/ path for testing
|
||||
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
|
||||
if (USE_RPATH)
|
||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
endif ()
|
||||
|
||||
include( CheckFunctionExists )
|
||||
include( CheckTypeSize )
|
||||
ENABLE_TESTING()
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
@ -66,7 +76,7 @@ endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
|
||||
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
|
||||
@ -84,90 +94,221 @@ if (MSVC)
|
||||
endif()
|
||||
|
||||
|
||||
if (ERT_USE_OPENMP)
|
||||
find_package(OpenMP)
|
||||
if (OPENMP_FOUND)
|
||||
message(STATUS "Enabling OpenMP support")
|
||||
# The actual use of OpenMP is only in the libecl library - the compile flags is only applied there.
|
||||
else()
|
||||
set( ERT_USE_OPENMP OFF )
|
||||
message(STATUS "OpenMP package not found - OpenMP disabled")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
||||
find_package(CXX11Features)
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
# create targets for (required and optional) dependencies to link to
|
||||
|
||||
find_package(OpenMP)
|
||||
if (NOT OPENMP_FOUND)
|
||||
message(STATUS "OpenMP package not found")
|
||||
set(ERT_USE_OPENMP OFF)
|
||||
endif ()
|
||||
|
||||
if (NOT ERT_USE_OPENMP)
|
||||
message(STATUS "OpenMP disabled")
|
||||
endif ()
|
||||
|
||||
# when cmake can be upgraded to >= 3.0, dependencies should be implemented
|
||||
# either via target-providing FindLib.cmake:
|
||||
# ```
|
||||
# find_package(Threads)
|
||||
# target_link_libraries(lib Threads::Threads)
|
||||
# ```
|
||||
#
|
||||
# or via INTERFACE libraries:
|
||||
# add_library(m INTERFACE)
|
||||
# find_library(M_LIBRARY NAMES m)
|
||||
# if (M_LIBRARY)
|
||||
# target_link_libraries(m ${M_LIBRARY})
|
||||
# endif ()
|
||||
# target_link_libraries(m ${M_LIBRARY})
|
||||
#
|
||||
# These targets can then be exported along with targets provided by this
|
||||
# project. Linking against cmake interface targets will handle include
|
||||
# directories better than raw names given to target_link_libraries
|
||||
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads)
|
||||
if (CMAKE_USE_PTHREADS_INIT)
|
||||
set(HAVE_PTHREAD TRUE)
|
||||
set(ERT_HAVE_THREAD_POOL ON)
|
||||
|
||||
set(pthread "${CMAKE_THREAD_LIBS_INIT}")
|
||||
|
||||
if (THREADS_HAVE_PTHREAD_ARG)
|
||||
set(pthreadarg "-pthread")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set(dl "${CMAKE_DL_LIBS}")
|
||||
|
||||
find_library(M_LIBRARY NAMES m)
|
||||
if(M_LIBRARY)
|
||||
set(m m)
|
||||
endif ()
|
||||
|
||||
find_package(BLAS)
|
||||
if (BLAS_FOUND)
|
||||
set(blas "${BLAS_LIBRARIES}")
|
||||
endif ()
|
||||
|
||||
set(ERT_HAVE_LAPACK OFF)
|
||||
find_package(LAPACK)
|
||||
if (LAPACK_FOUND)
|
||||
set(ERT_HAVE_LAPACK ON)
|
||||
list(APPEND lapack ${LAPACK_LIBRARIES} ${LAPACK_LINKER_FLAGS})
|
||||
endif()
|
||||
|
||||
find_package(ZLIB)
|
||||
if (ZLIB_FOUND)
|
||||
set(ERT_HAVE_ZLIB ON)
|
||||
set(zlib "${ZLIB_LIBRARIES}")
|
||||
endif ()
|
||||
|
||||
find_library(SHLWAPI_LIBRARY NAMES Shlwapi)
|
||||
if (SHLWAPI_LIBRARY)
|
||||
set(shlwapi ${SHLWAPI_LIBRARY})
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
# Checking based on compiling. Some of the code generates warnings, so we just cut down to bare-bone compiler flags.
|
||||
# feature tests
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckTypeSize)
|
||||
|
||||
set( CMAKE_C_FLAGS_main ${CMAKE_C_FLAGS} )
|
||||
set( CMAKE_CXX_FLAGS_main ${CMAKE_CXX_FLAGS} )
|
||||
check_function_exists( chdir HAVE_POSIX_CHDIR )
|
||||
check_function_exists( _chdir HAVE_WINDOWS_CHDIR )
|
||||
check_function_exists( chmod HAVE_CHMOD )
|
||||
check_function_exists( fnmatch HAVE_FNMATCH )
|
||||
check_function_exists( fork HAVE_FORK )
|
||||
check_function_exists( fseeko HAVE_FSEEKO )
|
||||
check_function_exists( fsync HAVE_FSYNC )
|
||||
check_function_exists( ftruncate HAVE_FTRUNCATE )
|
||||
check_function_exists( getcwd HAVE_POSIX_GETCWD)
|
||||
check_function_exists( _getcwd HAVE_WINDOWS_GETCWD)
|
||||
check_function_exists( getpwuid HAVE_GETPWUID )
|
||||
check_function_exists( GetTempPath HAVE_WINDOWS_GET_TEMP_PATH )
|
||||
check_function_exists( getuid ERT_HAVE_GETUID )
|
||||
check_function_exists( glob ERT_HAVE_GLOB )
|
||||
check_function_exists( gmtime_r HAVE_GMTIME_R )
|
||||
check_function_exists( localtime_r HAVE_LOCALTIME_R )
|
||||
check_function_exists( lockf ERT_HAVE_LOCKF )
|
||||
check_function_exists( mkdir HAVE_POSIX_MKDIR)
|
||||
check_function_exists( _mkdir HAVE_WINDOWS_MKDIR)
|
||||
check_function_exists( opendir ERT_HAVE_OPENDIR )
|
||||
check_function_exists( posix_spawn ERT_HAVE_SPAWN )
|
||||
check_function_exists( pthread_timedjoin_np HAVE_TIMEDJOIN)
|
||||
check_function_exists( pthread_yield HAVE_YIELD)
|
||||
check_function_exists( pthread_yield_np HAVE_YIELD_NP)
|
||||
check_function_exists( readlinkat ERT_HAVE_READLINKAT )
|
||||
check_function_exists( realpath HAVE_REALPATH )
|
||||
check_function_exists( regexec ERT_HAVE_REGEXP )
|
||||
check_function_exists( round HAVE_ROUND )
|
||||
check_function_exists( setenv HAVE_POSIX_SETENV )
|
||||
check_function_exists( symlink ERT_HAVE_SYMLINK )
|
||||
check_function_exists( timegm HAVE_TIMEGM )
|
||||
check_function_exists( usleep HAVE__USLEEP )
|
||||
|
||||
if (NOT ERT_WINDOWS)
|
||||
set( CMAKE_C_FLAGS_main "${CMAKE_C_FLAGS} -std=gnu99" )
|
||||
check_symbol_exists(_tzname time.h HAVE_WINDOWS_TZNAME)
|
||||
check_symbol_exists( tzname time.h HAVE_TZNAME)
|
||||
|
||||
check_include_file(execinfo.h HAVE_EXECINFO)
|
||||
check_include_file(getopt.h ERT_HAVE_GETOPT)
|
||||
check_include_file(unistd.h ERT_HAVE_UNISTD)
|
||||
|
||||
check_type_size(time_t SIZE_OF_TIME_T)
|
||||
if (${SIZE_OF_TIME_T} EQUAL 8)
|
||||
try_run(RUN_RESULT COMPILE_RESULT ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mktime_before1970.c)
|
||||
if (${COMPILE_RESULT})
|
||||
if (${RUN_RESULT} EQUAL 0)
|
||||
set( ERT_TIME_T_64BIT_ACCEPT_PRE1970 ON )
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set( ERT_EXTERNAL_UTIL_LIBS "" )
|
||||
include(cmake/ert_build_check.cmake)
|
||||
include(cmake/ert_api_check.cmake)
|
||||
include(cmake/ert_lib_check.cmake)
|
||||
try_compile( HAVE_VA_COPY ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_va_copy.c )
|
||||
try_compile( HAVE_SIGBUS ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_have_sigbus.c )
|
||||
try_compile( HAVE_PID_T ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_pid_t.c )
|
||||
try_compile( HAVE_MODE_T ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mode_t.c )
|
||||
try_compile( ERT_HAVE_ISFINITE ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_isfinite.c)
|
||||
|
||||
set( CMAKE_C_FLAGS ${CMAKE_C_FLAGS_main} )
|
||||
set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_main} )
|
||||
set( BUILD_CXX ON )
|
||||
try_compile( HAVE_CXX_SHARED_PTR ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_shared_ptr.cpp )
|
||||
if (NOT HAVE_CXX_SHARED_PTR)
|
||||
set( BUILD_CXX OFF )
|
||||
endif()
|
||||
|
||||
include(cmake/Modules/UseMultiArch.cmake)
|
||||
include(cmake/ert_link.cmake)
|
||||
if (HAVE_FORK AND HAVE_PTHREAD AND HAVE_EXECINFO AND HAVE_GETPWUID)
|
||||
set( HAVE_UTIL_ABORT_INTERCEPT ON)
|
||||
set( HAVE_BACKTRACE ON)
|
||||
endif()
|
||||
|
||||
if (ERT_WINDOWS)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set( ERT_WINDOWS_LFS ON )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_program(PING_PATH NAMES ping)
|
||||
if (PING_PATH)
|
||||
set(ERT_HAVE_PING ON)
|
||||
endif()
|
||||
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_SHORT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
else()
|
||||
set( GIT_COMMIT "unknown (git not found!)")
|
||||
set( GIT_COMMIT_SHORT "unknown (git not found!)")
|
||||
message( WARNING "Git not found. Build will not contain git revision info." )
|
||||
endif()
|
||||
|
||||
if (ERT_WINDOWS)
|
||||
execute_process(COMMAND cmd.exe /c "echo %date% %time%" OUTPUT_VARIABLE BUILD_TIME)
|
||||
else() # Linux or Darwin
|
||||
execute_process(COMMAND date "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE BUILD_TIME)
|
||||
endif()
|
||||
string(STRIP ${BUILD_TIME} BUILD_TIME)
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
set(INSTALL_GROUP "" CACHE STRING "Group to install as - blank to install as current group")
|
||||
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
|
||||
|
||||
|
||||
if (MSVC)
|
||||
add_definitions( -D__func__="\\"????\\"")
|
||||
endif()
|
||||
|
||||
if (ERT_WINDOWS)
|
||||
message(WARNING "Python is not supported on Windows")
|
||||
set( BUILD_PYTHON OFF )
|
||||
endif ()
|
||||
|
||||
if (ERT_LINUX)
|
||||
set( NEED_LIBM TRUE )
|
||||
set( LINK_STATIC FALSE )
|
||||
add_definitions( -DHAVE_PROC )
|
||||
else()
|
||||
set( NEED_LIBM FALSE )
|
||||
set( LINK_STATIC TRUE )
|
||||
endif()
|
||||
|
||||
include_directories( ${PROJECT_SOURCE_DIR}/libert_util/include )
|
||||
include_directories( ${PROJECT_BINARY_DIR}/libert_util/include )
|
||||
if (MSVC)
|
||||
include_directories( ${PROJECT_BINARY_DIR}/libert_util/include/ert/util )
|
||||
endif()
|
||||
add_subdirectory( libert_util )
|
||||
add_subdirectory( lib )
|
||||
add_subdirectory( applications )
|
||||
|
||||
|
||||
include_directories( ${PROJECT_SOURCE_DIR}/libgeometry/include )
|
||||
add_subdirectory( libgeometry )
|
||||
|
||||
include_directories( ${PROJECT_SOURCE_DIR}/libecl/include )
|
||||
add_subdirectory( libecl )
|
||||
|
||||
if (ERT_BUILD_CXX)
|
||||
include_directories( ${PROJECT_SOURCE_DIR}/libert_utilxx/include )
|
||||
include_directories( ${PROJECT_SOURCE_DIR}/libeclxx/include )
|
||||
|
||||
add_subdirectory( libert_utilxx )
|
||||
add_subdirectory( libeclxx )
|
||||
endif()
|
||||
|
||||
include_directories( ${PROJECT_SOURCE_DIR}/libecl_well/include )
|
||||
add_subdirectory( libecl_well )
|
||||
|
||||
if (BUILD_PYTHON)
|
||||
if (ERT_WINDOWS)
|
||||
message(WARNING "Python is not supported on Windows")
|
||||
@ -178,7 +319,7 @@ if (BUILD_PYTHON)
|
||||
# will be set to OFF.
|
||||
add_subdirectory( python )
|
||||
|
||||
if(ERT_DOC)
|
||||
if(RST_DOC)
|
||||
add_subdirectory( docs )
|
||||
endif()
|
||||
endif()
|
||||
@ -190,10 +331,6 @@ if (BUILD_PYTHON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
configure_file( cmake/libecl-config.cmake.in libecl-config.cmake @ONLY)
|
||||
configure_file( cmake/libecl-config-version.cmake.in libecl-config-version.cmake @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libecl-config.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libecl-config-version.cmake
|
||||
DESTINATION lib/libecl )
|
||||
install(EXPORT ecl-config DESTINATION share/cmake/ecl)
|
||||
export(TARGETS ecl FILE eclConfig.cmake)
|
||||
export(PACKAGE ecl)
|
||||
|
87
ThirdParty/Ert/applications/CMakeLists.txt
vendored
Normal file
87
ThirdParty/Ert/applications/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
project(libecl-applications)
|
||||
|
||||
if (NOT BUILD_APPLICATIONS)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
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)
|
||||
endif()
|
||||
|
||||
if (BUILD_ECL_SUMMARY)
|
||||
add_executable(ecl_summary ecl/view_summary.c)
|
||||
target_link_libraries(ecl_summary ecl)
|
||||
list(APPEND apps ecl_summary)
|
||||
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/man/man1/ecl_summary.1
|
||||
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})
|
@ -72,13 +72,13 @@ void unpack_file(const char * filename) {
|
||||
break;
|
||||
|
||||
if (target_type == ECL_SUMMARY_FILE) {
|
||||
active_view = ecl_file_alloc_global_blockview(src_file, SEQHDR_KW, block_index);
|
||||
active_view = ecl_file_get_global_blockview(src_file, SEQHDR_KW, block_index);
|
||||
report_step += 1;
|
||||
offset = 0;
|
||||
} else {
|
||||
ecl_kw_type * seqnum_kw;
|
||||
active_view = ecl_file_alloc_global_blockview(src_file, SEQNUM_KW, block_index);
|
||||
seqnum_kw = ecl_file_iget_named_kw( src_file , SEQNUM_KW , 0);
|
||||
active_view = ecl_file_get_global_blockview(src_file, SEQNUM_KW, block_index);
|
||||
seqnum_kw = ecl_file_view_iget_named_kw( active_view , SEQNUM_KW , 0);
|
||||
report_step = ecl_kw_iget_int( seqnum_kw , 0);
|
||||
offset = 1;
|
||||
}
|
||||
@ -100,7 +100,6 @@ void unpack_file(const char * filename) {
|
||||
free(target_file);
|
||||
}
|
||||
block_index++;
|
||||
ecl_file_view_free( active_view );
|
||||
}
|
||||
ecl_file_close( src_file );
|
||||
util_safe_free(path);
|
@ -65,7 +65,7 @@ int main(int argc, char ** argv) {
|
||||
{
|
||||
ecl_kw_type * ecl_kw = ecl_kw_alloc_empty();
|
||||
while (true) {
|
||||
if (ecl_kw_fread_header( ecl_kw , fortio_src )) {
|
||||
if (ecl_kw_fread_header( ecl_kw , fortio_src ) == ECL_KW_READ_OK) {
|
||||
const char * header = ecl_kw_get_header( ecl_kw );
|
||||
if (set_has_key( kw_set , header )) {
|
||||
ecl_kw_fread_realloc_data(ecl_kw , fortio_src );
|
@ -1,19 +1,22 @@
|
||||
#
|
||||
# Module that checks for supported C++11 (former C++0x) features.
|
||||
#
|
||||
if(CMAKE_VERSION VERSION_LESS 3.1)
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
endif()
|
||||
if(NOT ERT_WINDOWS)
|
||||
set( CMAKE_CXX_FLAGS_main "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
endif()
|
||||
else()
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
if (NOT MSVC)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
else()
|
||||
message(SEND_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
set(CXX11FEATURES_FOUND TRUE)
|
||||
|
67
ThirdParty/Ert/cmake/ert_api_check.cmake
vendored
67
ThirdParty/Ert/cmake/ert_api_check.cmake
vendored
@ -8,72 +8,5 @@
|
||||
# have a ERT_ prefix. The generated header is part of the api and can be
|
||||
# included by other header files in the ert source.
|
||||
|
||||
find_library( BLAS_LIBRARY NAMES blas)
|
||||
if (BLAS_LIBRARY)
|
||||
set(ERT_HAVE_BLAS ON)
|
||||
endif()
|
||||
|
||||
find_library( LAPACK_LIBRARY NAMES lapack)
|
||||
if (LAPACK_LIBRARY)
|
||||
set(ERT_HAVE_LAPACK ON)
|
||||
else()
|
||||
set(ERT_HAVE_LAPACK OFF)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
find_library( ZLIB_LIBRARY NAMES z )
|
||||
find_path( ZLIB_HEADER zlib.h /usr/include )
|
||||
if (ZLIB_LIBRARY AND ZLIB_HEADER)
|
||||
set( ERT_HAVE_ZLIB ON )
|
||||
else()
|
||||
if(NOT DEFINED ZLIB_LIBRARY)
|
||||
message(STATUS "ZLib library not found - zlib support will not be included." )
|
||||
endif()
|
||||
if(NOT DEFINED ZLIB_HEADER)
|
||||
message(STATUS "zlib.h not found - zlib support will not be included.")
|
||||
endif()
|
||||
endif()
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
try_compile( ERT_HAVE_ISFINITE ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_isfinite.c )
|
||||
find_path( ERT_HAVE_GETOPT getopt.h /usr/include )
|
||||
find_path( ERT_HAVE_UNISTD unistd.h /usr/include )
|
||||
|
||||
check_function_exists( posix_spawn ERT_HAVE_SPAWN )
|
||||
check_function_exists( opendir ERT_HAVE_OPENDIR )
|
||||
check_function_exists( symlink ERT_HAVE_SYMLINK )
|
||||
check_function_exists( readlinkat ERT_HAVE_READLINKAT )
|
||||
check_function_exists( glob ERT_HAVE_GLOB )
|
||||
check_function_exists( getuid ERT_HAVE_GETUID )
|
||||
check_function_exists( regexec ERT_HAVE_REGEXP )
|
||||
check_function_exists( lockf ERT_HAVE_LOCKF )
|
||||
|
||||
|
||||
check_type_size(time_t SIZE_OF_TIME_T)
|
||||
if (${SIZE_OF_TIME_T} EQUAL 8)
|
||||
try_run( RUN_RESULT COMPILE_RESULT ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mktime_before1970.c )
|
||||
if (${COMPILE_RESULT})
|
||||
if (${RUN_RESULT} EQUAL 0)
|
||||
set( ERT_TIME_T_64BIT_ACCEPT_PRE1970 ON )
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if (ERT_WINDOWS)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set( ERT_WINDOWS_LFS ON )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if (HAVE_PTHREAD)
|
||||
set( ERT_HAVE_THREAD_POOL ON )
|
||||
endif()
|
||||
|
||||
|
||||
find_program(PING_PATH NAMES ping)
|
||||
if (PING_PATH)
|
||||
set( ERT_HAVE_PING ON )
|
||||
endif()
|
||||
|
72
ThirdParty/Ert/cmake/ert_build_check.cmake
vendored
72
ThirdParty/Ert/cmake/ert_build_check.cmake
vendored
@ -6,75 +6,3 @@
|
||||
#
|
||||
# Check which affect the final api are implemented in the
|
||||
# ert_api_check.cmake file.
|
||||
|
||||
find_library( PTHREAD_LIBRARY NAMES pthread )
|
||||
if (PTHREAD_LIBRARY)
|
||||
set( HAVE_PTHREAD ON )
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} pthread)
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m )
|
||||
set( ERT_EXTERNAL_UTIL_LIBS ${ERT_EXTERNAL_UTIL_LIBS} m )
|
||||
endif(UNIX)
|
||||
|
||||
|
||||
check_function_exists( localtime_r HAVE_LOCALTIME_R )
|
||||
check_function_exists( gmtime_r HAVE_GMTIME_R )
|
||||
check_function_exists( realpath HAVE_REALPATH )
|
||||
check_function_exists( usleep HAVE__USLEEP )
|
||||
check_function_exists( fnmatch HAVE_FNMATCH )
|
||||
check_function_exists( ftruncate HAVE_FTRUNCATE )
|
||||
check_function_exists( round HAVE_ROUND )
|
||||
check_function_exists( GetTempPath HAVE_WINDOWS_GET_TEMP_PATH )
|
||||
check_function_exists( fork HAVE_FORK )
|
||||
check_function_exists( getpwuid HAVE_GETPWUID )
|
||||
check_function_exists( fsync HAVE_FSYNC )
|
||||
check_function_exists( setenv HAVE_POSIX_SETENV )
|
||||
check_function_exists( chmod HAVE_CHMOD )
|
||||
check_function_exists( pthread_timedjoin_np HAVE_TIMEDJOIN)
|
||||
check_function_exists( pthread_yield_np HAVE_YIELD_NP)
|
||||
check_function_exists( pthread_yield HAVE_YIELD)
|
||||
check_function_exists( fseeko HAVE_FSEEKO )
|
||||
check_function_exists( timegm HAVE_TIMEGM )
|
||||
|
||||
check_function_exists( _mkdir HAVE_WINDOWS_MKDIR)
|
||||
if (NOT HAVE_WINDOWS_MKDIR)
|
||||
check_function_exists( mkdir HAVE_POSIX_MKDIR)
|
||||
endif()
|
||||
|
||||
|
||||
check_function_exists( _chdir HAVE_WINDOWS_CHDIR)
|
||||
if (NOT HAVE_WINDOWS_CHDIR)
|
||||
check_function_exists( chdir HAVE_POSIX_CHDIR)
|
||||
endif()
|
||||
|
||||
check_function_exists( _getcwd HAVE_WINDOWS_GETCWD)
|
||||
if (NOT HAVE_WINDOWS_GETCWD)
|
||||
check_function_exists( getcwd HAVE_POSIX_GETCWD)
|
||||
endif()
|
||||
|
||||
|
||||
include(CheckSymbolExists)
|
||||
check_symbol_exists(_tzname time.h HAVE_WINDOWS_TZNAME)
|
||||
check_symbol_exists( tzname time.h HAVE_TZNAME)
|
||||
|
||||
find_path( HAVE_EXECINFO execinfo.h /usr/include )
|
||||
|
||||
try_compile( HAVE_VA_COPY ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_va_copy.c )
|
||||
try_compile( HAVE_SIGBUS ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_have_sigbus.c )
|
||||
try_compile( HAVE_PID_T ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_pid_t.c )
|
||||
try_compile( HAVE_MODE_T ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mode_t.c )
|
||||
|
||||
|
||||
set( BUILD_CXX ON )
|
||||
try_compile( HAVE_CXX_SHARED_PTR ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_shared_ptr.cpp )
|
||||
if (NOT HAVE_CXX_SHARED_PTR)
|
||||
set( BUILD_CXX OFF )
|
||||
endif()
|
||||
|
||||
if (HAVE_FORK AND HAVE_PTHREAD AND HAVE_EXECINFO AND HAVE_GETPWUID)
|
||||
set( HAVE_UTIL_ABORT_INTERCEPT ON)
|
||||
set( HAVE_BACKTRACE ON)
|
||||
endif()
|
||||
|
||||
|
27
ThirdParty/Ert/cmake/ert_lib_check.cmake
vendored
27
ThirdParty/Ert/cmake/ert_lib_check.cmake
vendored
@ -1,30 +1,3 @@
|
||||
# This file contains various checks which will append to the list
|
||||
# $ERT_EXTERNAL_UTIL_LIBS which should contain all the external library
|
||||
# dependencies. Observe that all library dependencies go transitively
|
||||
# through the ert_util library.
|
||||
|
||||
if (ERT_HAVE_LAPACK)
|
||||
set( ERT_EXTERNAL_UTIL_LIBS ${ERT_EXTERNAL_UTIL_LIBS} ${LAPACK_LIBRARY} ${BLAS_LIBRARY})
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LAPACK_LIBRARY} ${BLAS_LIBRARY})
|
||||
endif()
|
||||
|
||||
|
||||
if (ERT_WINDOWS)
|
||||
find_library( SHLWAPI_LIBRARY NAMES Shlwapi )
|
||||
set( ERT_EXTERNAL_UTIL_LIBS ${ERT_EXTERNAL_UTIL_LIBS} Shlwapi )
|
||||
endif()
|
||||
|
||||
|
||||
if (ERT_HAVE_ZLIB)
|
||||
set( ERT_EXTERNAL_UTIL_LIBS ${ERT_EXTERNAL_UTIL_LIBS} ${ZLIB_LIBRARY} )
|
||||
endif()
|
||||
|
||||
if (HAVE_PTHREAD)
|
||||
set( ERT_EXTERNAL_UTIL_LIBS ${ERT_EXTERNAL_UTIL_LIBS} ${PTHREAD_LIBRARY} )
|
||||
endif()
|
||||
|
||||
find_library( DL_LIBRARY NAMES dl )
|
||||
find_path( DLFUNC_HEADER dlfcn.h )
|
||||
if (DL_LIBRARY AND DLFUNC_HEADER)
|
||||
set( ERT_EXTERNAL_UTIL_LIBS ${ERT_EXTERNAL_UTIL_LIBS} ${DL_LIBRARY} )
|
||||
endif()
|
104
ThirdParty/Ert/docs/CMakeLists.txt
vendored
104
ThirdParty/Ert/docs/CMakeLists.txt
vendored
@ -1,85 +1,39 @@
|
||||
option( ERT_RST_DOC "Build RST based documentation" ON)
|
||||
option( ERT_DOXY_DOC "Build doxygen documentation" ON)
|
||||
option( ERT_DOXY_GRAPHICAL "Add graphics to doxygen documentation" OFF)
|
||||
find_package(Sphinx REQUIRED)
|
||||
if (SPHINX_FOUND)
|
||||
set( ERT_DOC_INSTALL_PATH "" CACHE PATH "Absolute path to install documentation *in addition* to $PREFIX/documentation")
|
||||
set( ERT_DOC_EXTERNAL_ROOT "" CACHE PATH "Path to site local ERT documentation")
|
||||
|
||||
if (NOT BUILD_ERT)
|
||||
if (ERT_RST_DOC)
|
||||
message(WARNING "Turning off ERT_RST_DOC. Depends on BUILD_ERT.")
|
||||
set (ERT_RST_DOC OFF)
|
||||
endif()
|
||||
if (ERT_DOXY_DOC)
|
||||
message(WARNING "Turning off ERT_DOXY_DOC. Depends on BUILD_ERT.")
|
||||
set (ERT_DOXY_DOC OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ERT_RST_DOC)
|
||||
find_package(Sphinx REQUIRED)
|
||||
if (SPHINX_FOUND)
|
||||
set( ERT_DOC_INSTALL_PATH "" CACHE PATH "Absolute path to install documentation *in addition* to $PREFIX/documentation")
|
||||
set( ERT_DOC_EXTERNAL_ROOT "" CACHE PATH "Path to site local ERT documentation")
|
||||
|
||||
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/doc-src")
|
||||
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/doc-src/_static")
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/user" "${PROJECT_BINARY_DIR}/doc-src/user")
|
||||
|
||||
if (ERT_DOC_EXTERNAL_ROOT)
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${ERT_DOC_EXTERNAL_ROOT}" "${PROJECT_BINARY_DIR}/doc-src/external-doc")
|
||||
message(STATUS "Adding documentation link ${PROJECT_BINARY_DIR}/doc-src/external-doc -> ${ERT_DOC_EXTERNAL_ROOT}")
|
||||
set( ERT_DOC_LINK external-doc/index )
|
||||
else()
|
||||
set( ERT_DOC_LINK "" )
|
||||
endif()
|
||||
|
||||
configure_file(index.rst.in ${PROJECT_BINARY_DIR}/doc-src/index.rst)
|
||||
configure_file(conf.py.in ${PROJECT_BINARY_DIR}/doc-src/conf.py)
|
||||
|
||||
if (BUILD_PYTHON)
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/code" "${PROJECT_BINARY_DIR}/doc-src/code")
|
||||
add_custom_target(api-doc ALL
|
||||
COMMAND sphinx-apidoc -e -o doc-src/API/python ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}
|
||||
DEPENDS enkf
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
add_custom_target(rst-doc ALL
|
||||
COMMAND sphinx-build -b html -d doc-src/doctrees doc-src documentation/rst
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
DEPENDS api-doc
|
||||
)
|
||||
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/doc-src")
|
||||
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/doc-src/_static")
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/user" "${PROJECT_BINARY_DIR}/doc-src/user")
|
||||
|
||||
if (ERT_DOC_EXTERNAL_ROOT)
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${ERT_DOC_EXTERNAL_ROOT}" "${PROJECT_BINARY_DIR}/doc-src/external-doc")
|
||||
message(STATUS "Adding documentation link ${PROJECT_BINARY_DIR}/doc-src/external-doc -> ${ERT_DOC_EXTERNAL_ROOT}")
|
||||
set( ERT_DOC_LINK external-doc/index )
|
||||
else()
|
||||
message(STATUS "Sphinx documentation tool not found - documentation not generated")
|
||||
set( ERT_DOC_LINK "" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
configure_file(index.rst.in ${PROJECT_BINARY_DIR}/doc-src/index.rst)
|
||||
configure_file(conf.py.in ${PROJECT_BINARY_DIR}/doc-src/conf.py)
|
||||
|
||||
if (ERT_DOXY_DOC)
|
||||
find_package(Doxygen)
|
||||
if (DOXYGEN_FOUND)
|
||||
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/documentation/doxy")
|
||||
set( DOXYGEN_HAVE_DOT "NO" )
|
||||
if ( ERT_DOXY_GRAPHICAL)
|
||||
if (DOXYGEN_DOT_FOUND)
|
||||
set( DOXYGEN_HAVE_DOT "YES" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (BUILD_ERT)
|
||||
SET( DOXYGEN_INPUT "${PROJECT_SOURCE_DIR}/libanalysis ${PROJECT_SOURCE_DIR}/libconfig ${PROJECT_SOURCE_DIR}/libecl ${PROJECT_SOURCE_DIR}/libecl_well ${PROJECT_SOURCE_DIR}/libeclxx ${PROJECT_SOURCE_DIR}/libenkf ${PROJECT_SOURCE_DIR}/libert_util ${PROJECT_SOURCE_DIR}/libert_utilxx ${PROJECT_SOURCE_DIR}/libgeometry ${PROJECT_SOURCE_DIR}/libjob_queue ${PROJECT_SOURCE_DIR}/librms ${PROJECT_SOURCE_DIR}/libsched")
|
||||
else()
|
||||
SET( DOXYGEN_INPUT "${PROJECT_SOURCE_DIR}/libecl ${PROJECT_SOURCE_DIR}/libecl_well ${PROJECT_SOURCE_DIR}/libeclxx ${PROJECT_SOURCE_DIR}/libert_util ${PROJECT_SOURCE_DIR}/libert_utilxx ${PROJECT_SOURCE_DIR}/libgeometry")
|
||||
endif()
|
||||
|
||||
configure_file(doxygen.cfg.in ${PROJECT_BINARY_DIR}/doxygen.cfg)
|
||||
add_custom_target(doxy ALL
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/doxygen.cfg
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/../
|
||||
COMMENT "Generating doxygen documentation"
|
||||
DEPENDS enkf)
|
||||
|
||||
if (BUILD_PYTHON)
|
||||
add_custom_target(api-doc ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/code" "${PROJECT_BINARY_DIR}/doc-src/code"
|
||||
COMMAND sphinx-apidoc -e -o doc-src/API/python ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}
|
||||
DEPENDS ecl
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_custom_target(rst-doc ALL
|
||||
COMMAND sphinx-build -b html -d doc-src/doctrees doc-src documentation/rst
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
DEPENDS api-doc
|
||||
)
|
||||
|
||||
else()
|
||||
message(STATUS "Sphinx documentation tool not found - documentation not generated")
|
||||
endif()
|
||||
|
||||
INSTALL( DIRECTORY ${PROJECT_BINARY_DIR}/documentation DESTINATION ${CMAKE_INSTALL_PREFIX} )
|
||||
|
766
ThirdParty/Ert/lib/CMakeLists.txt
vendored
Normal file
766
ThirdParty/Ert/lib/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,766 @@
|
||||
project(libecl-ecl C CXX)
|
||||
|
||||
if (HAVE_PTHREAD)
|
||||
# The block_fs filesystem is so heavily dependant on pthreads that it is
|
||||
# not built if de not have pthreads.
|
||||
list(APPEND opt_srcs util/thread_pool.c util/block_fs.c)
|
||||
endif ()
|
||||
|
||||
if (LAPACK_FOUND)
|
||||
list(APPEND opt_srcs util/matrix_lapack.c
|
||||
util/matrix_blas.c
|
||||
util/matrix_stat.c
|
||||
util/regression.c
|
||||
util/lars.c
|
||||
util/stepwise.c
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (HAVE_BACKTRACE)
|
||||
list(APPEND opt_srcs util/util_abort_gnu.c)
|
||||
else()
|
||||
list(APPEND opt_srcs util/util_abort_simple.c)
|
||||
endif()
|
||||
|
||||
if (ERT_HAVE_GETUID AND ERT_HAVE_OPENDIR)
|
||||
list(APPEND opt_srcs util/test_work_area.c util/util_getuid.c)
|
||||
endif()
|
||||
|
||||
if (ERT_HAVE_OPENDIR)
|
||||
list(APPEND opt_srcs util/util_opendir.c)
|
||||
endif()
|
||||
|
||||
if (ERT_HAVE_SPAWN)
|
||||
list(APPEND opt_srcs util/util_spawn.c)
|
||||
endif()
|
||||
|
||||
if (ERT_HAVE_LOCKF)
|
||||
list(APPEND opt_srcs util/util_lockf.c)
|
||||
endif ()
|
||||
|
||||
if (ERT_HAVE_REGEXP)
|
||||
list(APPEND opt_srcs util/template_loop.c)
|
||||
endif ()
|
||||
|
||||
if (ERT_HAVE_UNISTD)
|
||||
list(APPEND opt_srcs util/path_stack.c)
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
configure_file(include/ert/util/msvc_stdbool.h ert/util/stdbool.h)
|
||||
endif ()
|
||||
|
||||
foreach (type int double bool long time_t size_t float)
|
||||
set(TYPE ${type})
|
||||
configure_file(vector_template.h.in include/ert/util/${type}_vector.h)
|
||||
configure_file(util/vector_template.c ${type}_vector.c)
|
||||
list(APPEND opt_srcs ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.c)
|
||||
endforeach ()
|
||||
|
||||
if (ZLIB_FOUND)
|
||||
list(APPEND opt_srcs util/util_zlib.c)
|
||||
endif ()
|
||||
|
||||
if (ERT_BUILD_CXX)
|
||||
list(APPEND opt_srcs util/TestArea.cpp
|
||||
ecl/FortIO.cpp
|
||||
ecl/Smspec.cpp
|
||||
ecl/EclFilename.cpp
|
||||
)
|
||||
endif ()
|
||||
|
||||
configure_file(build_config.h.in include/ert/util/build_config.h)
|
||||
configure_file(ert_api_config.h.in include/ert/util/ert_api_config.h)
|
||||
|
||||
add_library(ecl util/rng.c
|
||||
util/lookup_table.c
|
||||
util/statistics.c
|
||||
util/mzran.c
|
||||
util/set.c
|
||||
util/hash_node.c
|
||||
util/hash_sll.c
|
||||
util/hash.c
|
||||
util/node_data.c
|
||||
util/node_ctype.c
|
||||
util/util.c
|
||||
util/util_env.c
|
||||
util/util_symlink.c
|
||||
util/util_lfs.c
|
||||
util/msg.c
|
||||
util/arg_pack.c
|
||||
util/path_fmt.c
|
||||
util/menu.c
|
||||
util/subst_list.c
|
||||
util/subst_func.c
|
||||
util/vector.c
|
||||
util/parser.c
|
||||
util/stringlist.c
|
||||
util/matrix.c
|
||||
util/buffer.c
|
||||
util/log.c
|
||||
util/template.c
|
||||
util/timer.c
|
||||
util/time_interval.c
|
||||
util/string_util.c
|
||||
util/type_vector_functions.c
|
||||
util/ui_return.c
|
||||
util/ert_version.c
|
||||
util/struct_vector.c
|
||||
util/perm_vector.c
|
||||
util/test_util.c
|
||||
${opt_srcs}
|
||||
|
||||
ecl/ecl_rsthead.c
|
||||
ecl/ecl_sum_tstep.c
|
||||
ecl/ecl_rst_file.c
|
||||
ecl/ecl_init_file.c
|
||||
ecl/ecl_grid_cache.c
|
||||
ecl/smspec_node.c
|
||||
ecl/ecl_kw_grdecl.c
|
||||
ecl/ecl_file_kw.c
|
||||
ecl/ecl_file_view.c
|
||||
ecl/ecl_grav.c
|
||||
ecl/ecl_grav_calc.c
|
||||
ecl/ecl_smspec.c
|
||||
ecl/ecl_sum_data.c
|
||||
ecl/ecl_util.c
|
||||
ecl/ecl_kw.c
|
||||
ecl/ecl_sum.c
|
||||
ecl/ecl_sum_vector.c
|
||||
ecl/fortio.c
|
||||
ecl/ecl_rft_file.c
|
||||
ecl/ecl_rft_node.c
|
||||
ecl/ecl_rft_cell.c
|
||||
ecl/ecl_grid.c
|
||||
ecl/ecl_coarse_cell.c
|
||||
ecl/ecl_box.c
|
||||
ecl/ecl_io_config.c
|
||||
ecl/ecl_file.c
|
||||
ecl/ecl_region.c
|
||||
ecl/ecl_subsidence.c
|
||||
ecl/ecl_grid_dims.c
|
||||
ecl/grid_dims.c
|
||||
ecl/nnc_info.c
|
||||
ecl/ecl_grav_common.c
|
||||
ecl/nnc_vector.c
|
||||
ecl/ecl_nnc_export.c
|
||||
ecl/ecl_nnc_data.c
|
||||
ecl/ecl_nnc_geometry.c
|
||||
ecl/layer.c
|
||||
ecl/fault_block.c
|
||||
ecl/fault_block_layer.c
|
||||
ecl/ecl_type.c
|
||||
ecl/ecl_type_python.c
|
||||
ecl/well_state.c
|
||||
ecl/well_conn.c
|
||||
ecl/well_info.c
|
||||
ecl/well_ts.c
|
||||
ecl/well_conn_collection.c
|
||||
ecl/well_segment.c
|
||||
ecl/well_segment_collection.c
|
||||
ecl/well_branch_collection.c
|
||||
ecl/well_rseg_loader.c
|
||||
|
||||
geometry/geo_surface.c
|
||||
geometry/geo_util.c
|
||||
geometry/geo_pointset.c
|
||||
geometry/geo_region.c
|
||||
geometry/geo_polygon.c
|
||||
geometry/geo_polygon_collection.c
|
||||
)
|
||||
|
||||
target_link_libraries(ecl PUBLIC ${m}
|
||||
${dl}
|
||||
${pthread}
|
||||
${blas}
|
||||
${lapack}
|
||||
${zlib}
|
||||
${shlwapi}
|
||||
)
|
||||
|
||||
target_include_directories(ecl
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
PRIVATE ${ZLIB_INCLUDE_DIRS}
|
||||
util
|
||||
include
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
)
|
||||
|
||||
target_compile_definitions(ecl PRIVATE
|
||||
-DGIT_COMMIT=${GIT_COMMIT}
|
||||
-DGIT_COMMIT_SHORT=${GIT_COMMIT_SHORT}
|
||||
-DERT_VERSION_MAJOR=${ERT_VERSION_MAJOR}
|
||||
-DERT_VERSION_MINOR=${ERT_VERSION_MINOR}
|
||||
-DERT_VERSION_MICRO=${ERT_VERSION_MICRO}
|
||||
)
|
||||
|
||||
target_compile_options(ecl PUBLIC ${pthreadarg})
|
||||
|
||||
if (PING_PATH)
|
||||
target_compile_definitions(ecl PRIVATE -DPING_CMD=${PING_PATH})
|
||||
endif()
|
||||
|
||||
if (ERT_USE_OPENMP)
|
||||
target_compile_options(ecl PUBLIC ${OpenMP_C_FLAGS})
|
||||
target_link_libraries( ecl PUBLIC ${OpenMP_C_FLAGS})
|
||||
target_link_libraries( ecl PUBLIC ${OpenMP_EXE_LINKER_FLAGS})
|
||||
endif ()
|
||||
|
||||
set_target_properties(ecl PROPERTIES
|
||||
VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR}
|
||||
SOVERSION ${ERT_VERSION_MAJOR})
|
||||
|
||||
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 ()
|
||||
|
||||
if (NOT BUILD_TESTS)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
foreach (name ert_util_alloc_file_components
|
||||
ert_util_approx_equal
|
||||
ert_util_arg_pack
|
||||
ert_util_before_after
|
||||
ert_util_binary_split
|
||||
ert_util_buffer
|
||||
ert_util_clamp
|
||||
ert_util_filename
|
||||
ert_util_hash_test
|
||||
ert_util_logh
|
||||
ert_util_matrix
|
||||
ert_util_parent_path
|
||||
ert_util_PATH_test
|
||||
ert_util_realpath
|
||||
ert_util_relpath_test
|
||||
ert_util_rng
|
||||
ert_util_sprintf_escape
|
||||
ert_util_sscan_test
|
||||
ert_util_statistics
|
||||
ert_util_strcat_test
|
||||
ert_util_stringlist_test
|
||||
ert_util_string_util
|
||||
ert_util_strstr_int_format
|
||||
ert_util_subst_list
|
||||
ert_util_time_interval
|
||||
ert_util_type_vector_functions
|
||||
ert_util_ui_return
|
||||
ert_util_vector_test
|
||||
ert_util_datetime
|
||||
)
|
||||
|
||||
add_executable(${name} util/tests/${name}.c)
|
||||
target_link_libraries(${name} ecl)
|
||||
add_test(NAME ${name} COMMAND ${name})
|
||||
endforeach ()
|
||||
|
||||
add_executable(ert_util_work_area util/tests/ert_util_work_area.c)
|
||||
target_link_libraries(ert_util_work_area ecl)
|
||||
add_test(NAME ert_util_work_area
|
||||
COMMAND ert_util_work_area data2/file1
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/util/tests/data2/file2
|
||||
data2
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/util/tests
|
||||
)
|
||||
|
||||
find_library( VALGRIND NAMES valgr )
|
||||
if (VALGRIND)
|
||||
set(valgrind_cmd valgrind --error-exitcode=1 --tool=memcheck)
|
||||
endif ()
|
||||
|
||||
add_executable(test_thread_pool util/tests/test_thread_pool.c)
|
||||
target_link_libraries(test_thread_pool ecl)
|
||||
add_test(NAME test_thread_pool COMMAND ${valgrind_cmd} test_thread_pool)
|
||||
|
||||
add_executable(ert_util_cwd_test util/tests/ert_util_cwd_test.c)
|
||||
target_link_libraries(ert_util_cwd_test ecl)
|
||||
add_test(NAME ert_util_cwd_test COMMAND ert_util_cwd_test ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
add_executable(ert_util_copy_file util/tests/ert_util_copy_file.c)
|
||||
target_link_libraries(ert_util_copy_file ecl)
|
||||
add_test(NAME ert_util_copy_file
|
||||
COMMAND ert_util_copy_file
|
||||
$<TARGET_FILE:ert_util_copy_file>)
|
||||
|
||||
add_executable(ert_util_file_readable util/tests/ert_util_file_readable.c)
|
||||
target_link_libraries(ert_util_file_readable ecl)
|
||||
add_test(NAME ert_util_file_readable COMMAND ert_util_file_readable)
|
||||
|
||||
add_executable(ert_util_path_stack_test util/tests/ert_util_path_stack_test.c)
|
||||
target_link_libraries(ert_util_path_stack_test ecl)
|
||||
add_test(NAME ert_util_path_stack_test COMMAND ert_util_path_stack_test
|
||||
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if (LAPACK_FOUND)
|
||||
add_executable(ert_util_matrix_lapack util/tests/ert_util_matrix_lapack.c)
|
||||
target_link_libraries(ert_util_matrix_lapack ecl)
|
||||
add_test(NAME ert_util_matrix_lapack COMMAND ert_util_matrix_lapack)
|
||||
|
||||
add_executable(ert_util_matrix_stat util/tests/ert_util_matrix_stat.c)
|
||||
target_link_libraries(ert_util_matrix_stat ecl)
|
||||
add_test(NAME ert_util_matrix_stat COMMAND ert_util_matrix_stat)
|
||||
endif()
|
||||
|
||||
if (HAVE_BACKTRACE)
|
||||
add_executable(ert_util_abort_gnu_tests util/tests/ert_util_abort_gnu_tests.c)
|
||||
target_link_libraries(ert_util_abort_gnu_tests ecl)
|
||||
add_test(NAME ert_util_abort_gnu_tests COMMAND ert_util_abort_gnu_tests)
|
||||
|
||||
add_executable(ert_util_addr2line util/tests/ert_util_addr2line.c)
|
||||
target_link_libraries(ert_util_addr2line ecl)
|
||||
add_test(NAME ert_util_addr2line COMMAND ert_util_addr2line)
|
||||
endif()
|
||||
|
||||
if (HAVE_UTIL_ABORT_INTERCEPT)
|
||||
add_executable(ert_util_block_fs util/tests/ert_util_block_fs.c)
|
||||
target_link_libraries(ert_util_block_fs ecl)
|
||||
add_test(NAME ert_util_block_fs COMMAND ert_util_block_fs)
|
||||
|
||||
add_executable(ert_util_struct_vector util/tests/ert_util_struct_vector.c)
|
||||
target_link_libraries(ert_util_struct_vector ecl)
|
||||
add_test(NAME ert_util_struct_vector COMMAND ert_util_struct_vector)
|
||||
|
||||
add_executable(ert_util_type_vector_test util/tests/ert_util_type_vector_test.c)
|
||||
target_link_libraries(ert_util_type_vector_test ecl)
|
||||
add_test(NAME ert_util_type_vector_test COMMAND ert_util_type_vector_test)
|
||||
endif()
|
||||
|
||||
if (ERT_HAVE_SPAWN)
|
||||
add_executable(ert_util_spawn util/tests/ert_util_spawn.c)
|
||||
target_link_libraries(ert_util_spawn ecl)
|
||||
add_test(NAME ert_util_spawn COMMAND ert_util_spawn)
|
||||
endif()
|
||||
|
||||
#
|
||||
# ecl
|
||||
#
|
||||
|
||||
foreach (name ecl_alloc_cpgrid
|
||||
ecl_alloc_grid_dxv_dyv_dzv
|
||||
ecl_fault_block_layer
|
||||
ecl_grid_add_nnc
|
||||
ecl_grid_copy
|
||||
ecl_grid_create
|
||||
ecl_grid_DEPTHZ
|
||||
ecl_grid_export
|
||||
ecl_grid_init_fwrite
|
||||
ecl_grid_reset_actnum
|
||||
ecl_init_file
|
||||
ecl_kw_cmp_string
|
||||
ecl_kw_equal
|
||||
ecl_kw_fread
|
||||
ecl_kw_grdecl
|
||||
ecl_kw_init
|
||||
ecl_nnc_geometry
|
||||
ecl_nnc_info_test
|
||||
ecl_nnc_vector
|
||||
ecl_rft_cell
|
||||
ecl_rst_file
|
||||
ecl_sum_writer
|
||||
ecl_util_make_date_no_shift
|
||||
ecl_util_month_range
|
||||
ecl_valid_basename
|
||||
test_ecl_nnc_data
|
||||
ecl_nnc_pair
|
||||
well_conn_collection
|
||||
well_branch_collection
|
||||
well_conn
|
||||
well_state
|
||||
well_segment
|
||||
well_segment_conn
|
||||
well_segment_collection
|
||||
ecl_file
|
||||
)
|
||||
add_executable(${name} ecl/tests/${name}.c)
|
||||
target_link_libraries(${name} ecl)
|
||||
add_test(NAME ${name} COMMAND ${name})
|
||||
endforeach ()
|
||||
|
||||
add_executable(ecl_grid_cell_contains ecl/tests/ecl_grid_cell_contains.c)
|
||||
target_link_libraries(ecl_grid_cell_contains ecl)
|
||||
add_test(NAME ecl_grid_cell_contains1 COMMAND ecl_grid_cell_contains)
|
||||
|
||||
if (HAVE_UTIL_ABORT_INTERCEPT)
|
||||
add_executable(ecl_grid_corner ecl/tests/ecl_grid_corner.c)
|
||||
target_link_libraries(ecl_grid_corner ecl)
|
||||
add_test(NAME ecl_grid_corner COMMAND ecl_grid_corner)
|
||||
|
||||
add_executable(ecl_layer ecl/tests/ecl_layer.c)
|
||||
target_link_libraries(ecl_layer ecl)
|
||||
add_test(NAME ecl_layer COMMAND ecl_layer)
|
||||
endif()
|
||||
|
||||
add_executable(ecl_get_num_cpu ecl/tests/ecl_get_num_cpu_test.c)
|
||||
target_link_libraries(ecl_get_num_cpu ecl)
|
||||
add_test(NAME ecl_get_num_cpu COMMAND ecl_get_num_cpu
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu1
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu2
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu3
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ecl/tests/data/num_cpu4)
|
||||
|
||||
# The ecl_win64 application is not built as a proper test integrated
|
||||
# into the CTEST system. Should be invoked manually on Windows.
|
||||
if (ERT_WINDOWS)
|
||||
add_executable(ecl_lfs ecl/tests/ecl_lfs.c)
|
||||
target_link_libraries(ecl_lfs ecl)
|
||||
endif()
|
||||
|
||||
#
|
||||
# geometry
|
||||
#
|
||||
|
||||
|
||||
foreach (name geo_util_xlines geo_polygon geo_polygon_collection)
|
||||
add_executable(${name} geometry/tests/${name}.c)
|
||||
target_link_libraries(${name} ecl)
|
||||
add_test(NAME ${name} COMMAND ${name})
|
||||
endforeach ()
|
||||
|
||||
if (ERT_BUILD_CXX)
|
||||
foreach (test ert_util_unique_ptr ert_util_test_area_xx)
|
||||
add_executable(${test} util/tests/${test}.cpp)
|
||||
target_link_libraries(${test} ecl)
|
||||
add_test(NAME ${test} COMMAND ${test})
|
||||
endforeach()
|
||||
|
||||
foreach (test eclxx_kw eclxx_fortio eclxx_smspec eclxx_filename eclxx_types)
|
||||
add_executable(${test} ecl/tests/${test}.cpp)
|
||||
target_link_libraries(${test} ecl)
|
||||
add_test(NAME ${test} COMMAND ${test})
|
||||
endforeach ()
|
||||
endif ()
|
||||
|
||||
if (NOT STATOIL_TESTDATA_ROOT)
|
||||
return ()
|
||||
endif()
|
||||
|
||||
#
|
||||
# ecl
|
||||
#
|
||||
|
||||
if (PING_PATH)
|
||||
add_executable(ert_util_ping util/tests/ert_util_ping.c)
|
||||
target_link_libraries(ert_util_ping ecl)
|
||||
add_test(NAME ert_util_ping COMMAND ert_util_ping)
|
||||
endif ()
|
||||
|
||||
|
||||
add_executable(ecl_coarse_test ecl/tests/ecl_coarse_test.c)
|
||||
target_link_libraries(ecl_coarse_test ecl)
|
||||
add_test(NAME ecl_coarse_test COMMAND ecl_coarse_test
|
||||
${_eclpath}/LGCcase/LGC_TESTCASE2)
|
||||
|
||||
add_executable(ecl_grid_layer_contains ecl/tests/ecl_grid_layer_contains.c)
|
||||
target_link_libraries(ecl_grid_layer_contains ecl)
|
||||
add_test(NAME ecl_grid_layer_contains1 COMMAND ecl_grid_layer_contains
|
||||
${_eclpath}/Gurbat/ECLIPSE.EGRID)
|
||||
add_test(NAME ecl_grid_layer_contains2 COMMAND ecl_grid_layer_contains
|
||||
${_eclpath}/Mariner/MARINER.EGRID)
|
||||
|
||||
add_executable(ecl_restart_test ecl/tests/ecl_restart_test.c)
|
||||
target_link_libraries(ecl_restart_test ecl)
|
||||
add_test(NAME ecl_restart_test COMMAND ecl_restart_test
|
||||
${_eclpath}/Gurbat/ECLIPSE.UNRST)
|
||||
|
||||
add_executable(ecl_nnc_export ecl/tests/ecl_nnc_export.c)
|
||||
target_link_libraries(ecl_nnc_export ecl)
|
||||
add_test(NAME ecl_nnc_export1 COMMAND ecl_nnc_export ${_eclpath}/Gurbat/ECLIPSE TRUE)
|
||||
add_test(NAME ecl_nnc_export2 COMMAND ecl_nnc_export ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC TRUE)
|
||||
add_test(NAME ecl_nnc_export3 COMMAND ecl_nnc_export ${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3 TRUE)
|
||||
add_test(NAME ecl_nnc_export4 COMMAND ecl_nnc_export ${_eclpath}/DualPoro/DUAL_DIFF TRUE)
|
||||
add_test(NAME ecl_nnc_export5 COMMAND ecl_nnc_export ${_eclpath}/DualPoro/DUALPORO TRUE)
|
||||
add_test(NAME ecl_nnc_export6 COMMAND ecl_nnc_export ${_eclpath}/nestedLGRcase/TESTCASE_NESTEDLGR TRUE)
|
||||
add_test(NAME ecl_nnc_export7 COMMAND ecl_nnc_export ${_eclpath}/TYRIHANS/BASE20150218_MULTFLT FALSE)
|
||||
|
||||
add_executable(ecl_nnc_export_get_tran ecl/tests/ecl_nnc_export_get_tran.c)
|
||||
target_link_libraries(ecl_nnc_export_get_tran ecl)
|
||||
add_test(NAME ecl_nnc_export_get_tran COMMAND ecl_nnc_export_get_tran
|
||||
${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3)
|
||||
|
||||
add_executable(ecl_nnc_data_statoil_root ecl/tests/test_ecl_nnc_data_statoil_root.c)
|
||||
target_link_libraries(ecl_nnc_data_statoil_root ecl)
|
||||
add_test(NAME ecl_nnc_data_statoil_root COMMAND ecl_nnc_data_statoil_root
|
||||
${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3
|
||||
${_eclpath}/flow-nnc/Simple4/SIMPLE_SUMMARY4
|
||||
${_eclpath}/flow-nnc/Gullfaks/GF_ACT_NEW_TEMP)
|
||||
|
||||
add_executable(ecl_util_make_date_shift ecl/tests/ecl_util_make_date_shift.c)
|
||||
target_link_libraries(ecl_util_make_date_shift ecl)
|
||||
add_test(NAME ecl_util_make_date_shift COMMAND ecl_util_make_date_shift)
|
||||
|
||||
add_executable(ecl_sum_case_exists ecl/tests/ecl_sum_case_exists.c)
|
||||
target_link_libraries(ecl_sum_case_exists ecl)
|
||||
add_test(NAME ecl_sum_case_exists COMMAND ecl_sum_case_exists
|
||||
${_eclpath}/Gurbat/ECLIPSE
|
||||
${_eclpath}/GurbatSummary/missingHeader/ECLIPSE
|
||||
${_eclpath}/GurbatSummary/missingData/ECLIPSE)
|
||||
|
||||
|
||||
add_executable(ecl_grid_lgr_name ecl/tests/ecl_grid_lgr_name.c)
|
||||
target_link_libraries(ecl_grid_lgr_name ecl)
|
||||
add_test(NAME ecl_grid_lgr_name COMMAND ecl_grid_lgr_name
|
||||
${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID)
|
||||
|
||||
add_executable(ecl_region ecl/tests/ecl_region.c)
|
||||
target_link_libraries(ecl_region ecl)
|
||||
add_test(NAME ecl_region COMMAND ecl_region ${_eclpath}/Gurbat/ECLIPSE.EGRID)
|
||||
|
||||
add_test(NAME ecl_grid_cell_contains2 COMMAND ecl_grid_cell_contains ${_eclpath}/Gurbat/ECLIPSE.EGRID)
|
||||
add_test(NAME ecl_grid_cell_contains3 COMMAND ecl_grid_cell_contains ${_eclpath}/FF12/FF12_2013B2.EGRID)
|
||||
add_test(NAME ecl_grid_cell_contains4 COMMAND ecl_grid_cell_contains ${_eclpath}/Brazil/R3_ICD.EGRID)
|
||||
|
||||
add_executable(ecl_grid_cell_contains_wellpath ecl/tests/ecl_grid_cell_contains_wellpath.c)
|
||||
target_link_libraries(ecl_grid_cell_contains_wellpath ecl)
|
||||
add_test(NAME ecl_grid_cell_contains_wellpath1
|
||||
COMMAND ecl_grid_cell_contains_wellpath
|
||||
${_eclpath}/CellContains/model/SMS-0.EGRID
|
||||
${_eclpath}/CellContains/R_PB-4H.jira)
|
||||
|
||||
add_executable(ecl_grid_cell_volume ecl/tests/ecl_grid_cell_volume.c)
|
||||
target_link_libraries(ecl_grid_cell_volume ecl)
|
||||
add_test(NAME ecl_grid_cell_volume1 COMMAND ecl_grid_cell_volume)
|
||||
add_test(NAME ecl_grid_cell_volume2 COMMAND ecl_grid_cell_volume ${_eclpath}/Gurbat/ECLIPSE.EGRID)
|
||||
add_test(NAME ecl_grid_cell_volume3 COMMAND ecl_grid_cell_volume ${_eclpath}/Heidrun/Summary/FF12_2013B3_CLEAN_RS.EGRID)
|
||||
|
||||
add_executable(ecl_region2region ecl/tests/ecl_region2region_test.c)
|
||||
target_link_libraries(ecl_region2region ecl)
|
||||
add_test(NAME ecl_region2region COMMAND ecl_region2region ${_eclpath}/R2R/R2R.SMSPEC)
|
||||
|
||||
add_executable(ecl_grid_case ecl/tests/ecl_grid_case.c)
|
||||
target_link_libraries(ecl_grid_case ecl)
|
||||
add_test(NAME ecl_grid_case COMMAND ecl_grid_case
|
||||
${_eclpath}/Gurbat/ECLIPSE.EGRID
|
||||
${_eclpath}/Gurbat/ECLIPSE)
|
||||
|
||||
add_executable(ecl_lgr_test ecl/tests/ecl_lgr_test.c)
|
||||
target_link_libraries(ecl_lgr_test ecl)
|
||||
add_test(NAME ecl_lgr_test1 COMMAND ecl_lgr_test ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID)
|
||||
add_test(NAME ecl_lgr_test2 COMMAND ecl_lgr_test ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.GRID)
|
||||
add_test(NAME ecl_lgr_test3 COMMAND ecl_lgr_test ${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID)
|
||||
|
||||
add_executable(ecl_grid_simple ecl/tests/ecl_grid_simple.c)
|
||||
target_link_libraries(ecl_grid_simple ecl)
|
||||
add_test(NAME ecl_grid_simple COMMAND ecl_grid_simple ${_eclpath}/Gurbat/ECLIPSE.EGRID)
|
||||
|
||||
add_test(NAME ecl_grid_ecl2015_2 COMMAND ecl_grid_simple
|
||||
${_eclpath}/Eclipse2015_NNC_BUG/FF15_2015B2_LGRM_RDI15_HIST_RDIREAL1_20142.EGRID)
|
||||
|
||||
add_executable(ecl_grid_export_statoil ecl/tests/ecl_grid_export.c)
|
||||
target_link_libraries(ecl_grid_export_statoil ecl)
|
||||
add_test(NAME ecl_grid_export_statoil
|
||||
COMMAND ecl_grid_export_statoil ${_eclpath}/Gurbat/ECLIPSE.EGRID)
|
||||
|
||||
add_executable(ecl_grid_volume ecl/tests/ecl_grid_volume.c)
|
||||
target_link_libraries(ecl_grid_volume ecl)
|
||||
add_test(NAME ecl_grid_volume1 COMMAND ecl_grid_volume ${_eclpath}/Gurbat/ECLIPSE)
|
||||
add_test(NAME ecl_grid_volume2 COMMAND ecl_grid_volume ${_eclpath}/VolumeTest/TEST1)
|
||||
add_test(NAME ecl_grid_volume3 COMMAND ecl_grid_volume ${_eclpath}/OsebergSyd/Omega/OMEGA-0)
|
||||
add_test(NAME ecl_grid_volume4 COMMAND ecl_grid_volume ${_eclpath}/Norne/reservoir_models/Norne_ATW2013/NORNE_ATW2013)
|
||||
|
||||
# The grid volume test fails miserably on the test case given as example five; looking at
|
||||
# the failures one could actually suspect that the ECLIPSE algorithm for PORV calculations
|
||||
# has been different in this file - i.e. that the absolute value of the individual
|
||||
# tetrahedron parts have been taken during the sum, and not at the end. At least the ert
|
||||
# algorithm gets volumes ~ 0 whereas ECLIPSE reports ~10^9 for the same cell.
|
||||
# add_test( ecl_grid_volume5 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_volume ${_eclpath}/Heidrun/Summary/FF12_2013B3_CLEAN_RS)
|
||||
|
||||
add_executable(ecl_grid_dims ecl/tests/ecl_grid_dims.c)
|
||||
target_link_libraries(ecl_grid_dims ecl)
|
||||
add_test(NAME ecl_grid_dims0 COMMAND ecl_grid_dims)
|
||||
add_test(NAME ecl_grid_dims1 COMMAND ecl_grid_dims ${_eclpath}/Gurbat/ECLIPSE.EGRID ${_eclpath}/Gurbat/ECLIPSE.INIT)
|
||||
add_test(NAME ecl_grid_dims2 COMMAND ecl_grid_dims ${_eclpath}/Gurbat/ECLIPSE.GRID ${_eclpath}/Gurbat/ECLIPSE.INIT)
|
||||
add_test(NAME ecl_grid_dims3 COMMAND ecl_grid_dims ${_eclpath}/Gurbat/ECLIPSE.EGRID)
|
||||
add_test(NAME ecl_grid_dims4 COMMAND ecl_grid_dims ${_eclpath}/Gurbat/ECLIPSE.GRID )
|
||||
add_test(NAME ecl_grid_dims5 COMMAND ecl_grid_dims ${_eclpath}/AmalgLGRcase/TESTCASE_AMALG_LGR.EGRID)
|
||||
|
||||
add_executable(ecl_nnc_test ecl/tests/ecl_nnc_test.c)
|
||||
target_link_libraries(ecl_nnc_test ecl)
|
||||
add_test(NAME ecl_nnc_test1 COMMAND ecl_nnc_test ${_eclpath}/Gurbat/ECLIPSE.EGRID )
|
||||
add_test(NAME ecl_nnc_test2 COMMAND ecl_nnc_test ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID )
|
||||
add_test(NAME ecl_nnc_test3 COMMAND ecl_nnc_test ${_eclpath}/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID)
|
||||
add_test(NAME ecl_nnc_test4 COMMAND ecl_nnc_test ${_eclpath}/DualPoro/DUAL_DIFF.EGRID )
|
||||
add_test(NAME ecl_nnc_test5 COMMAND ecl_nnc_test ${_eclpath}/nestedLGRcase/TESTCASE_NESTEDLGR.EGRID)
|
||||
|
||||
add_executable(ecl_layer_statoil ecl/tests/ecl_layer_statoil.c)
|
||||
target_link_libraries(ecl_layer_statoil ecl)
|
||||
add_test(NAME ecl_layer_statoil COMMAND ecl_layer_statoil
|
||||
${_eclpath}/Mariner/MARINER.EGRID
|
||||
${_eclpath}/Mariner/faultblock.grdecl)
|
||||
|
||||
add_executable(ecl_dualp ecl/tests/ecl_dualp.c)
|
||||
target_link_libraries(ecl_dualp ecl)
|
||||
add_test(NAME ecl_dualp COMMAND ecl_dualp ${_eclpath}/LGCcase/LGC_TESTCASE2)
|
||||
|
||||
add_executable(ecl_sum_test ecl/tests/ecl_sum_test.c)
|
||||
target_link_libraries(ecl_sum_test ecl)
|
||||
add_test(NAME ecl_sum_test COMMAND ecl_sum_test ${_eclpath}/Gurbat/ECLIPSE)
|
||||
|
||||
add_executable(ecl_sum_report_step_equal ecl/tests/ecl_sum_report_step_equal.c)
|
||||
target_link_libraries(ecl_sum_report_step_equal ecl)
|
||||
add_test(NAME ecl_sum_report_step_equal1 COMMAND ecl_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/Snorre/SNORRE FALSE)
|
||||
add_test(NAME ecl_sum_report_step_equal2 COMMAND ecl_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/Gurbat/ECLIPSE TRUE)
|
||||
add_test(NAME ecl_sum_report_step_equal3 COMMAND ecl_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/extraMinistep/ECLIPSE TRUE)
|
||||
add_test(NAME ecl_sum_report_step_equal4 COMMAND ecl_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/short/ECLIPSE FALSE)
|
||||
add_test(NAME ecl_sum_report_step_equal5 COMMAND ecl_sum_report_step_equal ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/enkf/ECLIPSE FALSE)
|
||||
add_test(NAME ecl_sum_report_step_equal6 COMMAND ecl_sum_report_step_equal ${_eclpath}/Snorre/SNORRE ${_eclpath}/Snorre2/SNORRE2 FALSE)
|
||||
|
||||
add_executable(ecl_sum_report_step_compatible ecl/tests/ecl_sum_report_step_compatible.c)
|
||||
target_link_libraries(ecl_sum_report_step_compatible ecl)
|
||||
add_test(NAME ecl_sum_report_step_compatible1 COMMAND ecl_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/Snorre/SNORRE FALSE)
|
||||
add_test(NAME ecl_sum_report_step_compatible2 COMMAND ecl_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/Gurbat/ECLIPSE TRUE)
|
||||
add_test(NAME ecl_sum_report_step_compatible3 COMMAND ecl_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/extraMinistep/ECLIPSE TRUE)
|
||||
add_test(NAME ecl_sum_report_step_compatible4 COMMAND ecl_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/short/ECLIPSE TRUE)
|
||||
add_test(NAME ecl_sum_report_step_compatible5 COMMAND ecl_sum_report_step_compatible ${_eclpath}/Gurbat/ECLIPSE ${_eclpath}/modGurbat/enkf/ECLIPSE TRUE)
|
||||
add_test(NAME ecl_sum_report_step_compatible6 COMMAND ecl_sum_report_step_equal ${_eclpath}/Snorre/SNORRE ${_eclpath}/Snorre2/SNORRE2 FALSE)
|
||||
|
||||
add_executable(ecl_file_statoil ecl/tests/ecl_file_statoil.c)
|
||||
target_link_libraries(ecl_file_statoil ecl)
|
||||
add_test(NAME ecl_file_statoil
|
||||
COMMAND ecl_file_statoil ${_eclpath}/Gurbat/ECLIPSE.UNRST ECLIPSE.UNRST)
|
||||
|
||||
add_executable(ecl_fmt ecl/tests/ecl_fmt.c)
|
||||
target_link_libraries(ecl_fmt ecl)
|
||||
add_test(NAME ecl_fmt COMMAND ecl_fmt
|
||||
${_eclpath}/Gurbat/ECLIPSE.UNRST
|
||||
${_eclpath}/Gurbat/ECLIPSE.DATA)
|
||||
|
||||
|
||||
add_executable(ecl_rsthead ecl/tests/ecl_rsthead.c)
|
||||
target_link_libraries(ecl_rsthead ecl)
|
||||
add_test(NAME ecl_rsthead COMMAND ecl_rsthead
|
||||
${_eclpath}/Gurbat/ECLIPSE.UNRST
|
||||
${_eclpath}/DualPoro/DUALPORO.X0005)
|
||||
|
||||
add_executable(ecl_smspec ecl/tests/ecl_smspec.c)
|
||||
target_link_libraries(ecl_smspec ecl)
|
||||
add_test(NAME ecl_smspec COMMAND ecl_smspec
|
||||
${_eclpath}/Gurbat/ECLIPSE.SMSPEC
|
||||
${_eclpath}/Heidrun/Summary/FF12_2013B3_CLEAN_RS.SMSPEC)
|
||||
|
||||
|
||||
add_executable(ecl_rft ecl/tests/ecl_rft.c)
|
||||
target_link_libraries(ecl_rft ecl)
|
||||
add_test(NAME ecl_rft_rft COMMAND ecl_rft ${_eclpath}/Gurbat/ECLIPSE.RFT RFT)
|
||||
add_test(NAME ecl_rft_rft_rw COMMAND ecl_rft ${_eclpath}/Gurbat/ECLIPSE.RFT RFT_RW)
|
||||
add_test(NAME ecl_rft_plt COMMAND ecl_rft ${_eclpath}/RFT/TEST1_1A.RFT PLT)
|
||||
add_test(NAME ecl_rft_mswplt COMMAND ecl_rft ${_eclpath}/RFT/RFT2.RFT MSW-PLT)
|
||||
|
||||
add_executable(ecl_grid_copy_statoil ecl/tests/ecl_grid_copy_statoil.c)
|
||||
target_link_libraries(ecl_grid_copy_statoil ecl)
|
||||
|
||||
add_test(NAME ecl_grid_copy_statoil1 COMMAND ecl_grid_copy_statoil ${_eclpath}/Gurbat/ECLIPSE.EGRID)
|
||||
add_test(NAME ecl_grid_copy_statoil2 COMMAND ecl_grid_copy_statoil ${_eclpath}/Mariner/MARINER.EGRID)
|
||||
add_test(NAME ecl_grid_copy_statoil3 COMMAND ecl_grid_copy_statoil ${_eclpath}/LGCcase/LGC_TESTCASE2.EGRID)
|
||||
add_test(NAME ecl_grid_copy_statoil4 COMMAND ecl_grid_copy_statoil ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID)
|
||||
|
||||
add_executable(ecl_fault_block_layer_statoil ecl/tests/ecl_fault_block_layer_statoil.c)
|
||||
target_link_libraries(ecl_fault_block_layer_statoil ecl)
|
||||
add_test(NAME ecl_fault_block_layer_statoil COMMAND ecl_fault_block_layer_statoil
|
||||
${_eclpath}/Mariner/MARINER.EGRID
|
||||
${_eclpath}/Mariner/faultblock.grdecl)
|
||||
|
||||
if (HAVE_UTIL_ABORT_INTERCEPT)
|
||||
add_executable(ecl_fortio ecl/tests/ecl_fortio.c)
|
||||
target_link_libraries( ecl_fortio ecl)
|
||||
add_test(NAME ecl_fortio COMMAND ecl_fortio ${_eclpath}/Gurbat/ECLIPSE.UNRST)
|
||||
endif()
|
||||
|
||||
add_executable(well_state_load ecl/tests/well_state_load.c)
|
||||
target_link_libraries( well_state_load ecl)
|
||||
|
||||
add_executable(well_state_load_missing_RSEG ecl/tests/well_state_load_missing_RSEG.c)
|
||||
target_link_libraries(well_state_load_missing_RSEG ecl)
|
||||
|
||||
add_test(NAME well_state_load1 COMMAND well_state_load ${_eclpath}/Gurbat/ECLIPSE.EGRID
|
||||
${_eclpath}/Gurbat/ECLIPSE.X0030)
|
||||
add_test(NAME well_state_load2 COMMAND well_state_load ${_eclpath}/MSWcase/MSW_CASE.EGRID
|
||||
${_eclpath}/MSWcase/MSW_CASE.X0021)
|
||||
add_test(NAME well_state_load3 COMMAND well_state_load ${_eclpath}/Troll/MSW/MSW.EGRID
|
||||
${_eclpath}/Troll/MSW/MSW.X0123)
|
||||
add_test(NAME well_state_load4 COMMAND well_state_load ${_eclpath}/Troll/MSW_LGR/LGR.EGRID
|
||||
${_eclpath}/Troll/MSW_LGR/LGR.X0095)
|
||||
add_test(NAME well_state_load5 COMMAND well_state_load ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID
|
||||
${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.X0061)
|
||||
add_test(NAME well_state_load_missing_RSEG1
|
||||
COMMAND well_state_load_missing_RSEG ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.EGRID
|
||||
${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.X0061)
|
||||
add_test(NAME well_state_load_missing_RSEG2
|
||||
COMMAND well_state_load_missing_RSEG ${_eclpath}/Troll/MSW/MSW.EGRID
|
||||
${_eclpath}/Troll/MSW/MSW.X0123)
|
||||
|
||||
add_executable(well_segment_load ecl/tests/well_segment_load.c)
|
||||
target_link_libraries(well_segment_load ecl)
|
||||
add_test(NAME well_segment_load
|
||||
COMMAND well_segment_load ${_eclpath}/MSWcase/MSW_CASE.X0021)
|
||||
|
||||
add_executable(well_segment_branch_conn_load ecl/tests/well_segment_branch_conn_load.c)
|
||||
target_link_libraries(well_segment_branch_conn_load ecl)
|
||||
add_test(NAME well_segment_branch_conn_load
|
||||
COMMAND well_segment_branch_conn_load ${_eclpath}/MSWcase/MSW_CASE.X0021)
|
||||
|
||||
add_executable(well_info ecl/tests/well_info.c)
|
||||
target_link_libraries(well_info ecl)
|
||||
add_test(NAME well_info COMMAND well_info ${_eclpath}/Gurbat/ECLIPSE.EGRID)
|
||||
|
||||
add_executable(well_conn_CF ecl/tests/well_conn_CF.c)
|
||||
target_link_libraries(well_conn_CF ecl)
|
||||
add_test(NAME well_conn_CF COMMAND well_conn_CF ${_eclpath}/Gurbat/ECLIPSE.X0060)
|
||||
|
||||
add_executable(well_conn_load ecl/tests/well_conn_load.c)
|
||||
target_link_libraries(well_conn_load ecl)
|
||||
add_test(NAME well_conn_load1 COMMAND well_conn_load ${_eclpath}/Gurbat/ECLIPSE.X0030 F)
|
||||
add_test(NAME well_conn_load2 COMMAND well_conn_load ${_eclpath}/10kcase/TEST10K_FLT_LGR_NNC.X0021 F)
|
||||
add_test(NAME well_conn_load3 COMMAND well_conn_load ${_eclpath}/MSWcase/MSW_CASE.X0021 T)
|
||||
add_test(NAME well_conn_load4 COMMAND well_conn_load ${_eclpath}/AmalgLGRcase/TESTCASE_AMALG_LGR.X0021 F)
|
||||
add_test(NAME well_conn_load5 COMMAND well_conn_load ${_eclpath}/DualPoro/DUALPORO.X0009 F)
|
||||
add_test(NAME well_conn_load6 COMMAND well_conn_load ${_eclpath}/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.X0003 F)
|
||||
|
||||
add_executable(well_ts ecl/tests/well_ts.c)
|
||||
target_link_libraries(well_ts ecl)
|
||||
add_test(NAME well_ts COMMAND well_ts ${_eclpath}/CO2case/BASE_CASE)
|
||||
|
||||
add_executable(well_dualp ecl/tests/well_dualp.c)
|
||||
target_link_libraries(well_dualp ecl)
|
||||
add_test(NAME well_dualp COMMAND well_dualp
|
||||
${_eclpath}/Gurbat/ECLIPSE.UNRST
|
||||
${_eclpath}/DualPoro/DUALPORO.X0005)
|
||||
|
||||
add_executable(well_lgr_load ecl/tests/well_lgr_load.c)
|
||||
target_link_libraries(well_lgr_load ecl)
|
||||
|
||||
add_test(NAME well_lgr_load1 COMMAND well_lgr_load ${_eclpath}/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.EGRID
|
||||
${_eclpath}/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.X0003)
|
||||
add_test(NAME well_lgr_load2 COMMAND well_lgr_load ${_eclpath}/AmalgLGRcase/TESTCASE_AMALG_LGR.EGRID
|
||||
${_eclpath}/AmalgLGRcase/TESTCASE_AMALG_LGR.X0016)
|
||||
|
||||
#
|
||||
# geometry
|
||||
#
|
||||
add_executable(geo_surface geometry/tests/geo_surface.c)
|
||||
target_link_libraries(geo_surface ecl)
|
||||
add_test(NAME geo_surface COMMAND geo_surface
|
||||
${_geopath}/Surface.irap
|
||||
${_geopath}/Surface_incompatible.irap)
|
@ -37,8 +37,13 @@ namespace ERT {
|
||||
{}
|
||||
|
||||
smspec_node::smspec_node( const std::string& keyword ) :
|
||||
smspec_node( ECL_SMSPEC_FIELD_VAR, "", keyword.c_str(),
|
||||
"", default_join, dummy_dims, 0 )
|
||||
smspec_node( ecl_smspec_identify_var_type( keyword.c_str() ),
|
||||
"",
|
||||
keyword.c_str(),
|
||||
"",
|
||||
default_join,
|
||||
dummy_dims,
|
||||
0 )
|
||||
{}
|
||||
|
||||
smspec_node::smspec_node(
|
@ -677,12 +677,87 @@ void ecl_file_free__(void * arg) {
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* Here we include a file with functions specialized to work with
|
||||
restart files. Observe that the files ecl_rstfile.c is compiled as
|
||||
part of the same compilation unit as ecl_file.c
|
||||
/* Functions specialized to work with restart files. */
|
||||
|
||||
/* Query functions. */
|
||||
/**
|
||||
Will look through all the INTEHEAD kw instances of the current
|
||||
ecl_file and look for @sim_time. If the value is found true is
|
||||
returned, otherwise false.
|
||||
*/
|
||||
|
||||
#include "ecl_rstfile.c"
|
||||
bool ecl_file_has_sim_time( const ecl_file_type * ecl_file , time_t sim_time) {
|
||||
return ecl_file_view_has_sim_time( ecl_file->active_view , sim_time );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This function will determine the restart block corresponding to the
|
||||
world time @sim_time; if @sim_time can not be found the function
|
||||
will return 0.
|
||||
|
||||
The returned index is the 'occurence number' in the restart file,
|
||||
i.e. in the (quite typical case) that not all report steps are
|
||||
present the return value will not agree with report step.
|
||||
|
||||
The return value from this function can then be used to get a
|
||||
corresponding solution field directly, or the file map can
|
||||
restricted to this block.
|
||||
|
||||
Direct access:
|
||||
|
||||
int index = ecl_file_get_restart_index( ecl_file , sim_time );
|
||||
if (index >= 0) {
|
||||
ecl_kw_type * pressure_kw = ecl_file_iget_named_kw( ecl_file , "PRESSURE" , index );
|
||||
....
|
||||
}
|
||||
|
||||
|
||||
Using block restriction:
|
||||
|
||||
int index = ecl_file_get_restart_index( ecl_file , sim_time );
|
||||
if (index >= 0) {
|
||||
ecl_file_iselect_rstblock( ecl_file , index );
|
||||
{
|
||||
ecl_kw_type * pressure_kw = ecl_file_iget_named_kw( ecl_file , "PRESSURE" , 0 );
|
||||
....
|
||||
}
|
||||
}
|
||||
|
||||
Specially in the case of LGRs the block restriction should be used.
|
||||
*/
|
||||
|
||||
int ecl_file_get_restart_index( const ecl_file_type * ecl_file , time_t sim_time) {
|
||||
int active_index = ecl_file_view_find_sim_time( ecl_file->active_view , sim_time );
|
||||
return active_index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Will look through all the SEQNUM kw instances of the current
|
||||
ecl_file and look for @report_step. If the value is found true is
|
||||
returned, otherwise false.
|
||||
*/
|
||||
|
||||
bool ecl_file_has_report_step( const ecl_file_type * ecl_file , int report_step) {
|
||||
return ecl_file_view_has_report_step( ecl_file->active_view , report_step );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function will look up the INTEHEAD keyword in a ecl_file_type
|
||||
instance, and calculate simulation date from this instance.
|
||||
|
||||
Will return -1 if the requested INTEHEAD keyword can not be found.
|
||||
*/
|
||||
|
||||
time_t ecl_file_iget_restart_sim_date( const ecl_file_type * restart_file , int index ) {
|
||||
return ecl_file_view_iget_restart_sim_date( restart_file->active_view , index );
|
||||
}
|
||||
|
||||
double ecl_file_iget_restart_sim_days( const ecl_file_type * restart_file , int index ) {
|
||||
return ecl_file_view_iget_restart_sim_days( restart_file->active_view , index );
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
/* Two small lookup functions which consider the INTEHEAD keyword,
|
||||
@ -799,4 +874,121 @@ bool ecl_file_save_kw( const ecl_file_type * ecl_file , const ecl_kw_type * ecl_
|
||||
}
|
||||
|
||||
|
||||
#include "ecl_file_deprecated.c"
|
||||
/* DEPRECATED */
|
||||
void ecl_file_push_block( ecl_file_type * ecl_file ) {
|
||||
vector_append_ref( ecl_file->map_stack , ecl_file->active_view );
|
||||
}
|
||||
|
||||
void ecl_file_pop_block( ecl_file_type * ecl_file ) {
|
||||
ecl_file->active_view = vector_pop_back( ecl_file->map_stack );
|
||||
}
|
||||
|
||||
|
||||
static ecl_file_view_type * ecl_file_get_relative_blockview( ecl_file_type * ecl_file , const char * kw , int occurence) {
|
||||
ecl_file_view_type * view = ecl_file_view_add_blockview( ecl_file->active_view , kw , occurence );
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ecl_file_subselect_block( ecl_file_type * ecl_file , const char * kw , int occurence) {
|
||||
ecl_file_view_type * blockmap = ecl_file_get_relative_blockview( ecl_file , kw , occurence);
|
||||
if (blockmap != NULL) {
|
||||
ecl_file->active_view = blockmap;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool ecl_file_select_block( ecl_file_type * ecl_file , const char * kw , int occurence ) {
|
||||
ecl_file_view_type * blockmap = ecl_file_get_global_blockview( ecl_file , kw , occurence);
|
||||
if (blockmap != NULL) {
|
||||
ecl_file->active_view = blockmap;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Will select restart block nr @seqnum_index - without considering
|
||||
report_steps or simulation time.
|
||||
*/
|
||||
bool ecl_file_iselect_rstblock( ecl_file_type * ecl_file , int seqnum_index ) {
|
||||
return ecl_file_select_block( ecl_file , SEQNUM_KW , seqnum_index );
|
||||
}
|
||||
|
||||
|
||||
bool ecl_file_select_rstblock_sim_time( ecl_file_type * ecl_file , time_t sim_time) {
|
||||
int seqnum_index = ecl_file_view_seqnum_index_from_sim_time( ecl_file->global_view , sim_time );
|
||||
|
||||
if (seqnum_index >= 0)
|
||||
return ecl_file_iselect_rstblock( ecl_file , seqnum_index);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool ecl_file_select_rstblock_report_step( ecl_file_type * ecl_file , int report_step) {
|
||||
int global_index = ecl_file_view_find_kw_value( ecl_file->global_view , SEQNUM_KW , &report_step);
|
||||
if ( global_index >= 0) {
|
||||
int seqnum_index = ecl_file_view_iget_occurence( ecl_file->global_view , global_index );
|
||||
return ecl_file_iselect_rstblock( ecl_file , seqnum_index);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static ecl_file_type * ecl_file_open_rstblock_report_step__( const char * filename , int report_step , int flags) {
|
||||
ecl_file_type * ecl_file = ecl_file_open( filename , flags );
|
||||
if (ecl_file) {
|
||||
if (!ecl_file_select_rstblock_report_step( ecl_file , report_step )) {
|
||||
ecl_file_close( ecl_file );
|
||||
ecl_file = NULL;
|
||||
}
|
||||
}
|
||||
return ecl_file;
|
||||
}
|
||||
|
||||
ecl_file_type * ecl_file_open_rstblock_report_step( const char * filename , int report_step , int flags) {
|
||||
return ecl_file_open_rstblock_report_step__(filename , report_step , flags );
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static ecl_file_type * ecl_file_open_rstblock_sim_time__( const char * filename , time_t sim_time, int flags ) {
|
||||
ecl_file_type * ecl_file = ecl_file_open( filename , flags );
|
||||
if (ecl_file) {
|
||||
if (!ecl_file_select_rstblock_sim_time( ecl_file , sim_time)) {
|
||||
ecl_file_close( ecl_file );
|
||||
ecl_file = NULL;
|
||||
}
|
||||
}
|
||||
return ecl_file;
|
||||
}
|
||||
|
||||
ecl_file_type * ecl_file_open_rstblock_sim_time( const char * filename , time_t sim_time, int flags) {
|
||||
return ecl_file_open_rstblock_sim_time__( filename , sim_time , flags );
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static ecl_file_type * ecl_file_iopen_rstblock__( const char * filename , int seqnum_index, int flags ) {
|
||||
ecl_file_type * ecl_file = ecl_file_open( filename , flags );
|
||||
if (ecl_file) {
|
||||
if (!ecl_file_iselect_rstblock( ecl_file , seqnum_index )) {
|
||||
ecl_file_close( ecl_file );
|
||||
ecl_file = NULL;
|
||||
}
|
||||
}
|
||||
return ecl_file;
|
||||
}
|
||||
|
||||
|
||||
ecl_file_type * ecl_file_iopen_rstblock( const char * filename , int seqnum_index , int flags) {
|
||||
return ecl_file_iopen_rstblock__(filename , seqnum_index , flags );
|
||||
}
|
@ -318,6 +318,7 @@ void ecl_file_kw_inplace_fwrite( ecl_file_kw_type * file_kw , fortio_type * fort
|
||||
ecl_file_kw_assert_kw( file_kw );
|
||||
fortio_fseek( fortio , file_kw->file_offset , SEEK_SET );
|
||||
ecl_kw_fskip_header( fortio );
|
||||
fortio_fclean(fortio);
|
||||
ecl_kw_fwrite_data( file_kw->kw , fortio );
|
||||
}
|
||||
|
@ -3953,20 +3953,6 @@ static bool tetrahedron_by_points_contains(const point_type * p0,
|
||||
return tetrahedron_contains(pro_tet, *p);
|
||||
}
|
||||
|
||||
static bool tetrahedron_positive_volume(const point_type * p0,
|
||||
const point_type * p1,
|
||||
const point_type * p2,
|
||||
const point_type * p3) {
|
||||
|
||||
tetrahedron_type pro_tet;
|
||||
pro_tet.p0 = *p0;
|
||||
pro_tet.p1 = *p1;
|
||||
pro_tet.p2 = *p2;
|
||||
pro_tet.p3 = *p3;
|
||||
|
||||
return tetrahedron_volume6(pro_tet) >= 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns true if and only if the cell "cell" decomposed by "method" contains the point "p".
|
||||
This is done by decomposing the cell into 5 tetrahedrons according to the decomposition
|
||||
@ -4001,34 +3987,19 @@ static bool concave_cell_contains( const ecl_cell_type * cell, int method, const
|
||||
};
|
||||
|
||||
// Test for containment in cell core
|
||||
bool contained = tetrahedron_by_points_contains(dia[0][0], dia[1][0], dia[0][1], dia[1][1], p);
|
||||
if (tetrahedron_by_points_contains(dia[0][0], dia[1][0], dia[0][1], dia[1][1], p))
|
||||
return true;
|
||||
|
||||
// Test for containment in protrusions
|
||||
for(int i = 0; i < 2; ++i) {
|
||||
if(tetrahedron_by_points_contains(dia[i][0], dia[i][1], dia[(i+1)%2][0], extra[i][0], p)) {
|
||||
contained = true;
|
||||
if(tetrahedron_by_points_contains(dia[i][0], dia[i][1], dia[(i+1)%2][0], extra[i][0], p))
|
||||
return true;
|
||||
|
||||
bool on_inner_faces = false;
|
||||
on_inner_faces |= triangle_contains3d(dia[i][0], dia[(i+1)%2][0], extra[i][0], p);
|
||||
on_inner_faces |= triangle_contains3d(dia[i][1], dia[(i+1)%2][0], extra[i][0], p);
|
||||
|
||||
if(!on_inner_faces && !tetrahedron_positive_volume(dia[i][0], dia[i][1], dia[(i+1)%2][0], extra[i][0]))
|
||||
return false;
|
||||
}
|
||||
|
||||
if(tetrahedron_by_points_contains(dia[i][0], dia[(i+1)%2][1], dia[i][1], extra[i][1], p)) {
|
||||
contained = true;
|
||||
|
||||
bool on_inner_faces = false;
|
||||
on_inner_faces |= triangle_contains3d(dia[i][0], dia[(i+1)%2][1], extra[i][1], p);
|
||||
on_inner_faces |= triangle_contains3d(dia[i][1], dia[(i+1)%2][1], extra[i][1], p);
|
||||
|
||||
if(!on_inner_faces && !tetrahedron_positive_volume(dia[i][0], dia[(i+1)%2][1], dia[i][1], extra[i][1]))
|
||||
return false;
|
||||
}
|
||||
if(tetrahedron_by_points_contains(dia[i][0], dia[(i+1)%2][1], dia[i][1], extra[i][1], p))
|
||||
return true;
|
||||
}
|
||||
|
||||
return contained;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4066,14 +4037,8 @@ bool ecl_grid_cell_contains_xyz3( const ecl_grid_type * ecl_grid , int i, int j
|
||||
bool max_k = (k == ecl_grid->nz-1);
|
||||
face_status_enum face_status = ecl_grid_on_cell_face(cell, method, &p, max_i, max_j, max_k);
|
||||
|
||||
if(face_status != NOT_ON_FACE) {
|
||||
// Since we might get false positives in the case when the cells
|
||||
// projections to the xy-plane is concave, we still check whether
|
||||
// the point is contained in the cell if it face_status is
|
||||
// BELONGS_TO_CELL.
|
||||
if(face_status == BELONGS_TO_OTHER)
|
||||
return false;
|
||||
}
|
||||
if(face_status != NOT_ON_FACE)
|
||||
return face_status == BELONGS_TO_CELL;
|
||||
|
||||
// Twisted cells
|
||||
if (ecl_cell_get_twist(cell) > 0) {
|
||||
@ -5068,6 +5033,9 @@ ecl_grid_type * ecl_grid_get_lgr(const ecl_grid_type * main_grid, const char * _
|
||||
*/
|
||||
|
||||
bool ecl_grid_has_lgr(const ecl_grid_type * main_grid, const char * __lgr_name) {
|
||||
if(!__lgr_name)
|
||||
return false;
|
||||
|
||||
__assert_main_grid( main_grid );
|
||||
{
|
||||
char * lgr_name = util_alloc_strip_copy( __lgr_name );
|
||||
@ -5077,6 +5045,18 @@ bool ecl_grid_has_lgr(const ecl_grid_type * main_grid, const char * __lgr_name)
|
||||
}
|
||||
}
|
||||
|
||||
bool ecl_grid_has_lgr_nr(const ecl_grid_type * main_grid, int lgr_nr) {
|
||||
__assert_main_grid( main_grid );
|
||||
{
|
||||
if (int_vector_size( main_grid->lgr_index_map ) > lgr_nr)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ecl_grid_get_num_coarse_groups( const ecl_grid_type * main_grid ) {
|
||||
return vector_get_size( main_grid->coarse_cells );
|
||||
@ -5812,8 +5792,8 @@ static const float * ecl_grid_get_mapaxes( const ecl_grid_type * grid ) {
|
||||
return grid->mapaxes;
|
||||
}
|
||||
|
||||
static ecl_kw_type * ecl_grid_alloc_mapaxes_kw( const float * mapaxes ) {
|
||||
return ecl_kw_alloc_new( MAPAXES_KW , 6 , ECL_FLOAT , mapaxes);
|
||||
ecl_kw_type * ecl_grid_alloc_mapaxes_kw( const ecl_grid_type * grid ) {
|
||||
return ecl_kw_alloc_new( MAPAXES_KW , 6 , ECL_FLOAT , grid->mapaxes);
|
||||
}
|
||||
|
||||
static ecl_kw_type * ecl_grid_alloc_mapunits_kw( ert_ecl_unit_enum output_unit ) {
|
||||
@ -5872,8 +5852,8 @@ static float ecl_grid_output_scaling( const ecl_grid_type * grid , ert_ecl_unit_
|
||||
}
|
||||
|
||||
|
||||
static void ecl_grid_fwrite_mapaxes( const float * mapaxes , fortio_type * fortio) {
|
||||
ecl_kw_type * mapaxes_kw = ecl_grid_alloc_mapaxes_kw( mapaxes );
|
||||
static void ecl_grid_fwrite_mapaxes( const ecl_grid_type * grid , fortio_type * fortio) {
|
||||
ecl_kw_type * mapaxes_kw = ecl_grid_alloc_mapaxes_kw( grid );
|
||||
ecl_kw_fwrite( mapaxes_kw , fortio );
|
||||
ecl_kw_free( mapaxes_kw );
|
||||
}
|
||||
@ -5896,7 +5876,7 @@ static void ecl_grid_fwrite_main_GRID_headers( const ecl_grid_type * ecl_grid ,
|
||||
ecl_grid_fwrite_mapunits( fortio , output_unit );
|
||||
|
||||
if (ecl_grid->use_mapaxes)
|
||||
ecl_grid_fwrite_mapaxes( ecl_grid->mapaxes , fortio );
|
||||
ecl_grid_fwrite_mapaxes( ecl_grid , fortio );
|
||||
|
||||
ecl_grid_fwrite_gridunits( fortio , output_unit );
|
||||
}
|
||||
@ -6035,7 +6015,7 @@ static void ecl_grid_fwrite_main_EGRID_header( const ecl_grid_type * grid , fort
|
||||
|
||||
ecl_grid_fwrite_mapunits( fortio , output_unit );
|
||||
if (mapaxes != NULL)
|
||||
ecl_grid_fwrite_mapaxes( mapaxes , fortio );
|
||||
ecl_grid_fwrite_mapaxes( grid , fortio );
|
||||
|
||||
ecl_grid_fwrite_gridunits( fortio , output_unit);
|
||||
}
|
||||
@ -6286,11 +6266,25 @@ float * ecl_grid_alloc_zcorn_data( const ecl_grid_type * grid ) {
|
||||
|
||||
|
||||
ecl_kw_type * ecl_grid_alloc_zcorn_kw( const ecl_grid_type * grid ) {
|
||||
ecl_kw_type * zcorn_kw = ecl_kw_alloc( ZCORN_KW , 8 * grid->size , ECL_FLOAT);
|
||||
ecl_grid_init_zcorn_data( grid , ecl_kw_get_void_ptr( zcorn_kw ));
|
||||
ecl_kw_type * zcorn_kw = ecl_kw_alloc( ZCORN_KW , ecl_grid_get_zcorn_size(grid), ECL_FLOAT);
|
||||
ecl_grid_init_zcorn_data(grid , ecl_kw_get_void_ptr(zcorn_kw));
|
||||
return zcorn_kw;
|
||||
}
|
||||
|
||||
ecl_kw_type * ecl_grid_alloc_coord_kw( const ecl_grid_type * grid) {
|
||||
if(grid->coord_kw)
|
||||
return ecl_kw_alloc_copy(grid->coord_kw);
|
||||
|
||||
ecl_kw_type * coord_kw = ecl_kw_alloc(
|
||||
COORD_KW,
|
||||
ECL_GRID_COORD_SIZE(grid->nx, grid->ny),
|
||||
ECL_FLOAT
|
||||
);
|
||||
ecl_grid_init_coord_data(grid, ecl_kw_get_float_ptr(coord_kw));
|
||||
|
||||
return coord_kw;
|
||||
}
|
||||
|
||||
|
||||
int ecl_grid_get_coord_size( const ecl_grid_type * grid) {
|
||||
return ECL_GRID_COORD_SIZE( grid->nx , grid->ny );
|
||||
@ -6681,7 +6675,7 @@ void ecl_grid_fprintf_grdecl2(ecl_grid_type * grid , FILE * stream , ert_ecl_uni
|
||||
}
|
||||
|
||||
if (grid->use_mapaxes) {
|
||||
ecl_kw_type * mapaxes_kw = ecl_grid_alloc_mapaxes_kw( grid->mapaxes );
|
||||
ecl_kw_type * mapaxes_kw = ecl_grid_alloc_mapaxes_kw( grid );
|
||||
ecl_kw_fprintf_grdecl( mapaxes_kw , stream );
|
||||
ecl_kw_free( mapaxes_kw );
|
||||
}
|
@ -474,9 +474,6 @@ static void ecl_kw_set_shared_ref(ecl_kw_type * ecl_kw , void *data_ptr) {
|
||||
|
||||
static void ecl_kw_initialize(ecl_kw_type * ecl_kw , const char *header , int size , ecl_data_type data_type) {
|
||||
ecl_kw_set_data_type(ecl_kw, data_type);
|
||||
if (strlen(header) > ECL_STRING8_LENGTH)
|
||||
util_abort("%s: Fatal error: ecl_header_name:%s is longer than eight characters - aborting \n",__func__,header);
|
||||
|
||||
ecl_kw_set_header_name(ecl_kw , header);
|
||||
ecl_kw->size = size;
|
||||
}
|
||||
@ -1474,11 +1471,17 @@ void ecl_kw_free_data(ecl_kw_type *ecl_kw) {
|
||||
|
||||
void ecl_kw_set_header_name(ecl_kw_type * ecl_kw , const char * header) {
|
||||
ecl_kw->header8 = realloc(ecl_kw->header8 , ECL_STRING8_LENGTH + 1);
|
||||
sprintf(ecl_kw->header8 , "%-8s" , header);
|
||||
if (strlen(header) <= 8) {
|
||||
sprintf(ecl_kw->header8 , "%-8s" , header);
|
||||
|
||||
/* Internalizing a header without the trailing spaces as well. */
|
||||
util_safe_free( ecl_kw->header );
|
||||
ecl_kw->header = util_alloc_strip_copy( ecl_kw->header8 );
|
||||
}
|
||||
else {
|
||||
ecl_kw->header = util_alloc_copy(header, strlen( header ) + 1);
|
||||
}
|
||||
|
||||
/* Internalizing a header without the trailing spaces as well. */
|
||||
util_safe_free( ecl_kw->header );
|
||||
ecl_kw->header = util_alloc_strip_copy( ecl_kw->header8 );
|
||||
}
|
||||
|
||||
|
||||
@ -1711,9 +1714,14 @@ void ecl_kw_fwrite_header(const ecl_kw_type *ecl_kw , fortio_type *fortio) {
|
||||
}
|
||||
|
||||
|
||||
void ecl_kw_fwrite(const ecl_kw_type *ecl_kw , fortio_type *fortio) {
|
||||
bool ecl_kw_fwrite(const ecl_kw_type *ecl_kw , fortio_type *fortio) {
|
||||
if (strlen(ecl_kw_get_header( ecl_kw)) > ECL_STRING8_LENGTH) {
|
||||
fortio_fwrite_error(fortio);
|
||||
return false;
|
||||
}
|
||||
ecl_kw_fwrite_header(ecl_kw , fortio);
|
||||
ecl_kw_fwrite_data(ecl_kw , fortio);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <ert/ecl/ecl_type.h>
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
#define MAX_GRDECL_HEADER_SIZE 512
|
||||
|
||||
/*
|
||||
This file is devoted to different routines for reading and writing
|
||||
@ -74,7 +75,7 @@
|
||||
bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) {
|
||||
long start_pos = util_ftell( stream );
|
||||
long current_pos;
|
||||
char next_kw[256];
|
||||
char next_kw[MAX_GRDECL_HEADER_SIZE];
|
||||
|
||||
/*
|
||||
Determine if the current position of the file pointer is at the
|
||||
@ -146,7 +147,7 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) {
|
||||
|
||||
char * ecl_kw_grdecl_alloc_next_header( FILE * stream ) {
|
||||
if (ecl_kw_grdecl_fseek_next_kw( stream )) {
|
||||
char next_kw[256];
|
||||
char next_kw[MAX_GRDECL_HEADER_SIZE];
|
||||
fscanf( stream , "%s" , next_kw);
|
||||
return util_alloc_string_copy( next_kw );
|
||||
} else
|
||||
@ -187,89 +188,7 @@ static bool ecl_kw_grdecl_fseek_kw__(const char * kw , FILE * stream) {
|
||||
|
||||
|
||||
|
||||
// static bool ecl_kw_grdecl_fseek_kw__OLD(const char * kw , FILE * stream) {
|
||||
// const int newline_char = '\n';
|
||||
// long int init_pos = ftell(stream);
|
||||
//
|
||||
// if (util_fseek_string(stream , kw , false , true)) {
|
||||
// /*
|
||||
// OK the keyword is found in the file; now we must verify that:
|
||||
//
|
||||
// 1. It is terminated with a blank, i.e. when searching for
|
||||
// 'COORD' we do not want a positive on 'COORDSYS'.
|
||||
//
|
||||
// 2. That the keyword indeed starts with a isspace() character; we
|
||||
// are not interested in the 'SYS' in 'COORDSYS'.
|
||||
//
|
||||
// 3. That the current location is not a comment section.
|
||||
// */
|
||||
// long int kw_pos = ftell( stream );
|
||||
// bool valid_kw = false;
|
||||
// int c;
|
||||
//
|
||||
// fseek( stream , strlen(kw) , SEEK_CUR); // Seek to end of kw
|
||||
// c = fgetc( stream ); // Read one character
|
||||
// fseek( stream , kw_pos , SEEK_SET ); // Seek back to beginning of kw
|
||||
//
|
||||
// if (isspace(c)) {
|
||||
// if (kw_pos > 0) {
|
||||
// fseek( stream , kw_pos - 1 , SEEK_SET);
|
||||
// c = fgetc( stream );
|
||||
// if (isspace(c))
|
||||
// // OK - we have verifed that the kw string we have found both
|
||||
// // starts and ends with a isspace() character.
|
||||
// valid_kw = true;
|
||||
// } else
|
||||
// valid_kw = true; // kw is at the very beginning of the file.
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if (valid_kw) {
|
||||
// // OK - the kw is validly terminated with a space/tab/newline; now
|
||||
// // we must verify that it is not in a comment section.
|
||||
// if (kw_pos >= strlen(ECL_COMMENT_STRING) ) { // Must have this check to avoid infinite spinning
|
||||
// // when the keyword is in the very beginning of the file.
|
||||
// fseek( stream , 1 , SEEK_CUR );
|
||||
// while (true) {
|
||||
// fseek( stream , -2 , SEEK_CUR );
|
||||
// c = fgetc( stream );
|
||||
// if ((c == newline_char) || (ftell(stream) == 0))
|
||||
// break;
|
||||
// }
|
||||
// {
|
||||
// // We have gone as far back as necessary.
|
||||
// int line_length = kw_pos - ftell( stream );
|
||||
// char * line = util_malloc(line_length + 1 , __func__);
|
||||
//
|
||||
// fread( stream , sizeof * line , line_length , stream);
|
||||
// line[line_length] = '\0';
|
||||
//
|
||||
// if (strstr( line , ECL_COMMENT_STRING) == NULL)
|
||||
// // We are not in a commen section.
|
||||
// valid_kw = true;
|
||||
// else
|
||||
// valid_kw = false;
|
||||
//
|
||||
// free( line );
|
||||
// }
|
||||
// }
|
||||
// } else
|
||||
// valid_kw = false;
|
||||
//
|
||||
// if (valid_kw)
|
||||
// return true;
|
||||
// else {
|
||||
// fseek( stream , strlen(kw) , SEEK_CUR ); // Skip over the kw so we don't find it again.
|
||||
// if (ecl_kw_grdecl_fseek_kw__(kw , stream))
|
||||
// return true;
|
||||
// else {
|
||||
// fseek( stream , init_pos , SEEK_SET );
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// } else
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
bool ecl_kw_grdecl_fseek_kw(const char * kw , bool rewind , FILE * stream) {
|
||||
@ -291,7 +210,6 @@ bool ecl_kw_grdecl_fseek_kw(const char * kw , bool rewind , FILE * stream) {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Observe that this function does not preserve the '*' structure
|
||||
which (might) have been used in the input.
|
||||
@ -476,9 +394,9 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_
|
||||
|
||||
The ecl_kw class has a quite deeply wired assumption that the
|
||||
header is a string of length 8 (I hope/think that is an ECLIPSE
|
||||
limitation), and the the class is not able to create ecl_kw
|
||||
instances with header length of more than 8 characters - code will
|
||||
abort hard if @kw is longer than 8 characters.
|
||||
limitation). The class cannot read/write kw with headers longer than 8 bytes.
|
||||
ecl_kw_grdecl is a workaround allowing for reading/writing kw with long
|
||||
headers.
|
||||
|
||||
-----------------------------------------------------------------
|
||||
|
||||
@ -517,6 +435,9 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_
|
||||
*/
|
||||
|
||||
static ecl_kw_type * __ecl_kw_fscanf_alloc_grdecl__(FILE * stream , const char * header , bool strict , int size , ecl_data_type data_type) {
|
||||
if (header && strlen(header) >MAX_GRDECL_HEADER_SIZE)
|
||||
util_abort("%s cannot read KW of more than %d bytes. strlen(header) == %d\n", __func__, MAX_GRDECL_HEADER_SIZE, strlen(header) );
|
||||
|
||||
if (!ecl_type_is_numeric(data_type))
|
||||
util_abort("%s: sorry only types FLOAT, INT and DOUBLE supported\n",__func__);
|
||||
|
||||
@ -525,7 +446,7 @@ static ecl_kw_type * __ecl_kw_fscanf_alloc_grdecl__(FILE * stream , const char *
|
||||
return NULL; /* Could not find it. */
|
||||
|
||||
{
|
||||
char file_header[9];
|
||||
char file_header[MAX_GRDECL_HEADER_SIZE];
|
||||
if (fscanf(stream , "%s" , file_header) == 1) {
|
||||
int kw_size;
|
||||
char * data = fscanf_alloc_grdecl_data( file_header , strict , data_type , &kw_size , stream );
|
280
ThirdParty/Ert/lib/ecl/ecl_nnc_data.c
vendored
Normal file
280
ThirdParty/Ert/lib/ecl/ecl_nnc_data.c
vendored
Normal file
@ -0,0 +1,280 @@
|
||||
/*
|
||||
Copyright (C) 2017 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_file_view.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#define ECL_NNC_DATA_TYPE_ID 83756236
|
||||
|
||||
#include <ert/ecl/ecl_nnc_data.h>
|
||||
#include <ert/ecl/ecl_nnc_geometry.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_file_view.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
|
||||
enum kw_data_type {
|
||||
TRANS_DATA = 1,
|
||||
WTR_FLUX_DATA = 2,
|
||||
OIL_FLUX_DATA = 3,
|
||||
GAS_FLUX_DATA = 4
|
||||
};
|
||||
|
||||
struct ecl_nnc_data_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
int size;
|
||||
double * values;
|
||||
};
|
||||
|
||||
|
||||
static const char * ecl_nnc_data_get_str_kw(int kw_type, int grid1, int grid2) {
|
||||
char * kw = NULL;
|
||||
switch (kw_type) {
|
||||
|
||||
case TRANS_DATA:
|
||||
if (grid1 == grid2)
|
||||
kw = TRANNNC_KW;
|
||||
else if (grid1 == 0)
|
||||
kw = TRANGL_KW;
|
||||
else
|
||||
kw = TRANLL_KW;
|
||||
break;
|
||||
|
||||
case WTR_FLUX_DATA:
|
||||
if (grid1 == grid2)
|
||||
kw = FLRWATNNC_KW;
|
||||
else if (grid1 == 0)
|
||||
kw = FLRWATLG_KW;
|
||||
else
|
||||
kw = FLRWATLL_KW;
|
||||
break;
|
||||
|
||||
case OIL_FLUX_DATA:
|
||||
if (grid1 == grid2)
|
||||
kw = FLROILNNC_KW;
|
||||
else if (grid1 == 0)
|
||||
kw = FLROILLG_KW;
|
||||
else
|
||||
kw = FLROILLL_KW;
|
||||
break;
|
||||
|
||||
case GAS_FLUX_DATA:
|
||||
if (grid1 == grid2)
|
||||
kw = FLRGASNNC_KW;
|
||||
else if (grid1 == 0)
|
||||
kw = FLRGASLG_KW;
|
||||
else
|
||||
kw = FLRGASLL_KW;
|
||||
break;
|
||||
|
||||
default:
|
||||
kw = NULL;
|
||||
|
||||
}
|
||||
return kw;
|
||||
}
|
||||
|
||||
|
||||
static ecl_kw_type * ecl_nnc_data_get_gl_kw( const ecl_file_view_type * init_file_view , const char * kw, int kw_type, int lgr_nr) {
|
||||
ecl_kw_type * return_kw = NULL;
|
||||
|
||||
if (kw != NULL)
|
||||
if (lgr_nr == 0) {
|
||||
if(ecl_file_view_has_kw(init_file_view, kw))
|
||||
return_kw = ecl_file_view_iget_named_kw(init_file_view, kw, 0);
|
||||
} else {
|
||||
{
|
||||
const int file_num_kw = ecl_file_view_get_size( init_file_view );
|
||||
int global_kw_index = 0;
|
||||
bool finished = false;
|
||||
bool correct_lgrheadi = false;
|
||||
int head_index = 0;
|
||||
int steps = 0;
|
||||
|
||||
while(!finished){
|
||||
ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( init_file_view , global_kw_index );
|
||||
const char *current_kw = ecl_kw_get_header(ecl_kw);
|
||||
if (strcmp( LGRHEADI_KW , current_kw) == 0) {
|
||||
if (ecl_kw_iget_int( ecl_kw , LGRHEADI_LGR_NR_INDEX) == lgr_nr) {
|
||||
correct_lgrheadi = true;
|
||||
head_index = global_kw_index;
|
||||
}else{
|
||||
correct_lgrheadi = false;
|
||||
}
|
||||
}
|
||||
if(correct_lgrheadi) {
|
||||
if (strcmp(kw, current_kw) == 0) {
|
||||
steps = global_kw_index - head_index; /* This is to calculate who fare from lgrheadi we found the TRANGL/TRANNNC key word */
|
||||
if (kw_type != TRANS_DATA || steps == 3 || steps == 4 || steps == 6) { /* We only support a file format where TRANNNC is 3 steps and TRANGL is 4 or 6 steps from LGRHEADI */
|
||||
return_kw = ecl_kw;
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
global_kw_index++;
|
||||
if (global_kw_index == file_num_kw)
|
||||
finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return return_kw;
|
||||
}
|
||||
|
||||
|
||||
static ecl_kw_type * ecl_nnc_data_get_tranll_kw( const ecl_grid_type * grid , const ecl_file_view_type * init_file_view , int lgr_nr1, int lgr_nr2 ) {
|
||||
const char * lgr_name1 = ecl_grid_get_lgr_name( grid , lgr_nr1 );
|
||||
const char * lgr_name2 = ecl_grid_get_lgr_name( grid , lgr_nr2 );
|
||||
|
||||
ecl_kw_type * tran_kw = NULL;
|
||||
const int file_num_kw = ecl_file_view_get_size( init_file_view );
|
||||
int global_kw_index = 0;
|
||||
|
||||
while (true) {
|
||||
if (global_kw_index >= file_num_kw)
|
||||
break;
|
||||
{
|
||||
ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( init_file_view , global_kw_index );
|
||||
if (strcmp( LGRJOIN_KW , ecl_kw_get_header( ecl_kw)) == 0) {
|
||||
|
||||
if (ecl_kw_icmp_string( ecl_kw , 0 , lgr_name1) && ecl_kw_icmp_string( ecl_kw , 1 , lgr_name2)) {
|
||||
tran_kw = ecl_file_view_iget_kw( init_file_view , global_kw_index + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
global_kw_index++;
|
||||
}
|
||||
}
|
||||
|
||||
return tran_kw;
|
||||
}
|
||||
|
||||
|
||||
static ecl_kw_type * ecl_nnc_data_get_kw( const ecl_grid_type * grid, const ecl_file_view_type * init_file_view, int lgr_nr1, int lgr_nr2 , int kw_type) {
|
||||
|
||||
const char * kw = ecl_nnc_data_get_str_kw(kw_type, lgr_nr1, lgr_nr2);
|
||||
if (lgr_nr1 == 0 || lgr_nr1 == lgr_nr2)
|
||||
return ecl_nnc_data_get_gl_kw( init_file_view , kw, kw_type, lgr_nr2 );
|
||||
else
|
||||
if (kw_type == TRANS_DATA)
|
||||
return ecl_nnc_data_get_tranll_kw( grid , init_file_view , lgr_nr1 , lgr_nr2 );
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void assert_correct_kw_count(ecl_kw_type * kw, char * function_name, bool check_kw_count, int correct_kw_count, int kw_count) {
|
||||
if (check_kw_count & (correct_kw_count != kw_count))
|
||||
util_abort("In function %s, reading kw: %s. %d != %d", function_name, ecl_kw_get_header(kw), correct_kw_count, kw_count);
|
||||
}
|
||||
|
||||
|
||||
static void ecl_nnc_data_set_values(ecl_nnc_data_type * data, const ecl_grid_type * grid, const ecl_nnc_geometry_type * nnc_geo, const ecl_file_view_type * init_file, int kw_type) {
|
||||
|
||||
int current_grid1 = -1;
|
||||
int current_grid2 = -1;
|
||||
ecl_kw_type * current_kw = NULL;
|
||||
int correct_kw_count = 0;
|
||||
int kw_count = 0;
|
||||
bool check_kw_count = false;
|
||||
int nnc_size = ecl_nnc_geometry_size( nnc_geo );
|
||||
|
||||
for (int nnc_index = 0; nnc_index < nnc_size; nnc_index++) {
|
||||
const ecl_nnc_pair_type * pair = ecl_nnc_geometry_iget( nnc_geo, nnc_index );
|
||||
int grid1 = pair->grid_nr1;
|
||||
int grid2 = pair->grid_nr2;
|
||||
|
||||
if (grid1 != current_grid1 || grid2 != current_grid2) {
|
||||
current_grid1 = grid1;
|
||||
current_grid2 = grid2;
|
||||
assert_correct_kw_count(current_kw, __func__, check_kw_count, correct_kw_count, kw_count);
|
||||
current_kw = ecl_nnc_data_get_kw( grid, init_file, grid1 , grid2 , kw_type);
|
||||
kw_count = 0;
|
||||
if (current_kw) {
|
||||
correct_kw_count = ecl_kw_get_size( current_kw );
|
||||
check_kw_count = true;
|
||||
data->size = nnc_index + correct_kw_count;
|
||||
}
|
||||
else {
|
||||
check_kw_count = false;
|
||||
printf("Warning: failed to obtain kw from file in function %s. ", __func__);
|
||||
printf("Grid1: %d, Grid2 %d\n", current_grid1, current_grid2);
|
||||
}
|
||||
}
|
||||
if (current_kw) {
|
||||
data->values[nnc_index] = ecl_kw_iget_as_double(current_kw, pair->input_index);
|
||||
kw_count++;
|
||||
}
|
||||
else
|
||||
data->values[nnc_index] = -1;
|
||||
}
|
||||
assert_correct_kw_count(current_kw, __func__, check_kw_count, correct_kw_count, kw_count);
|
||||
}
|
||||
|
||||
static ecl_nnc_data_type * ecl_nnc_data_alloc__(const ecl_grid_type * grid, const ecl_nnc_geometry_type * nnc_geo, const ecl_file_view_type * init_file, int kw_type) {
|
||||
ecl_nnc_data_type * data = util_malloc(sizeof * data);
|
||||
|
||||
data->size = 0;
|
||||
|
||||
int nnc_size = ecl_nnc_geometry_size( nnc_geo );
|
||||
|
||||
data->values = util_malloc( nnc_size * sizeof(double));
|
||||
|
||||
ecl_nnc_data_set_values(data, grid, nnc_geo, init_file, kw_type);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
ecl_nnc_data_type * ecl_nnc_data_alloc_tran(const ecl_grid_type * grid, const ecl_nnc_geometry_type * nnc_geo, const ecl_file_view_type * init_file) {
|
||||
return ecl_nnc_data_alloc__(grid, nnc_geo, init_file, TRANS_DATA);
|
||||
}
|
||||
|
||||
ecl_nnc_data_type * ecl_nnc_data_alloc_wat_flux(const ecl_grid_type * grid, const ecl_nnc_geometry_type * nnc_geo, const ecl_file_view_type * init_file) {
|
||||
return ecl_nnc_data_alloc__(grid, nnc_geo, init_file, WTR_FLUX_DATA);
|
||||
}
|
||||
|
||||
ecl_nnc_data_type * ecl_nnc_data_alloc_oil_flux(const ecl_grid_type * grid, const ecl_nnc_geometry_type * nnc_geo, const ecl_file_view_type * init_file) {
|
||||
return ecl_nnc_data_alloc__(grid, nnc_geo, init_file, OIL_FLUX_DATA);
|
||||
}
|
||||
|
||||
ecl_nnc_data_type * ecl_nnc_data_alloc_gas_flux(const ecl_grid_type * grid, const ecl_nnc_geometry_type * nnc_geo, const ecl_file_view_type * init_file) {
|
||||
return ecl_nnc_data_alloc__(grid, nnc_geo, init_file, GAS_FLUX_DATA);
|
||||
}
|
||||
|
||||
void ecl_nnc_data_free(ecl_nnc_data_type * data) {
|
||||
free(data->values);
|
||||
free(data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ecl_nnc_data_get_size(ecl_nnc_data_type * data) {
|
||||
return data->size;
|
||||
}
|
||||
|
||||
const double * ecl_nnc_data_get_values( const ecl_nnc_data_type * data ) {
|
||||
return data->values;
|
||||
}
|
||||
|
||||
|
||||
double ecl_nnc_data_iget_value(const ecl_nnc_data_type * data, int index) {
|
||||
if (index < data->size)
|
||||
return data->values[index];
|
||||
else
|
||||
util_abort("%s: index value:%d out range: [0,%d) \n",__func__ , index , data->size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -124,3 +124,11 @@ const ecl_nnc_pair_type * ecl_nnc_geometry_iget( const ecl_nnc_geometry_type * n
|
||||
return struct_vector_iget_ptr( nnc_geo->data , index );
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool ecl_nnc_geometry_same_kw( const ecl_nnc_pair_type * nnc1 , const ecl_nnc_pair_type * nnc2) {
|
||||
if ((nnc1->grid_nr1 == nnc2->grid_nr1) && (nnc1->grid_nr2 == nnc2->grid_nr2))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
@ -88,8 +88,7 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ
|
||||
// The only derived quantity
|
||||
rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year );
|
||||
}
|
||||
if (doubhead_kw)
|
||||
rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX );
|
||||
rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX );
|
||||
if (logihead_kw)
|
||||
rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX);
|
||||
|
||||
@ -110,15 +109,12 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ
|
||||
|
||||
ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int report_step) {
|
||||
const ecl_kw_type * intehead_kw = ecl_file_view_iget_named_kw( rst_view , INTEHEAD_KW , 0);
|
||||
const ecl_kw_type * doubhead_kw = NULL;
|
||||
const ecl_kw_type * doubhead_kw = ecl_file_view_iget_named_kw( rst_view , DOUBHEAD_KW , 0);
|
||||
const ecl_kw_type * logihead_kw = NULL;
|
||||
|
||||
if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW))
|
||||
logihead_kw = ecl_file_view_iget_named_kw( rst_view , LOGIHEAD_KW , 0);
|
||||
|
||||
if (ecl_file_view_has_kw(rst_view, DOUBHEAD_KW))
|
||||
doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0);
|
||||
|
||||
if (ecl_file_view_has_kw( rst_view , SEQNUM_KW)) {
|
||||
const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( rst_view , SEQNUM_KW , 0);
|
||||
report_step = ecl_kw_iget_int( seqnum_kw , 0);
|
@ -471,18 +471,13 @@ double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ) {
|
||||
*/
|
||||
|
||||
bool ecl_sum_data_check_sim_time( const ecl_sum_data_type * data , time_t sim_time) {
|
||||
if (time_interval_contains( data->sim_time , sim_time ) || (sim_time == time_interval_get_end( data->sim_time)))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return (time_interval_contains(data->sim_time, sim_time)
|
||||
|| (sim_time == time_interval_get_end(data->sim_time)));
|
||||
}
|
||||
|
||||
|
||||
bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_days) {
|
||||
if ((sim_days < data->days_start) || ( sim_days > data->sim_length))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return sim_days >= data->days_start && sim_days <= data->sim_length;
|
||||
}
|
||||
|
||||
|
||||
@ -526,10 +521,10 @@ bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_da
|
||||
|
||||
|
||||
static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data , time_t sim_time) {
|
||||
time_t data_start_time = time_interval_get_start( data->sim_time );
|
||||
time_t sim_end = time_interval_get_end( data->sim_time );
|
||||
time_t data_start_time = time_interval_get_start(data->sim_time);
|
||||
time_t sim_end = time_interval_get_end(data->sim_time);
|
||||
|
||||
if (!ecl_sum_data_check_sim_time( data , sim_time )) {
|
||||
if (!ecl_sum_data_check_sim_time(data, sim_time)) {
|
||||
fprintf(stderr , "Simulation start: "); util_fprintf_date_utc( ecl_smspec_get_start_time( data->smspec ) , stderr );
|
||||
fprintf(stderr , "Data start......: "); util_fprintf_date_utc( data_start_time , stderr );
|
||||
fprintf(stderr , "Simulation end .: "); util_fprintf_date_utc( sim_end , stderr );
|
||||
@ -543,47 +538,25 @@ static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data
|
||||
perfectly well be 'holes' in the time domain, because of e.g. the
|
||||
RPTONLY keyword.
|
||||
*/
|
||||
{
|
||||
int low_index = 0;
|
||||
int high_index = vector_get_size( data->data );
|
||||
int internal_index = INVALID_MINISTEP_NR;
|
||||
|
||||
int low_index = 0;
|
||||
int high_index = vector_get_size(data->data) - 1;
|
||||
|
||||
while (internal_index < 0) {
|
||||
if (low_index == high_index)
|
||||
internal_index = low_index;
|
||||
else {
|
||||
int center_index = 0.5*( low_index + high_index );
|
||||
const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , center_index );
|
||||
// perform binary search
|
||||
while (low_index+1 < high_index) {
|
||||
int center_index = (low_index + high_index) / 2;
|
||||
const ecl_sum_tstep_type * center_step = ecl_sum_data_iget_ministep(data, center_index);
|
||||
const time_t center_time = ecl_sum_tstep_get_sim_time(center_step);
|
||||
|
||||
if ((high_index - low_index) == 1) {
|
||||
/* Degenerate special case. */
|
||||
if (sim_time < ecl_sum_tstep_get_sim_time( ministep ))
|
||||
internal_index = low_index;
|
||||
else
|
||||
internal_index = high_index;
|
||||
} else {
|
||||
if (sim_time > ecl_sum_tstep_get_sim_time( ministep )) /* Low-----Center---X---High */
|
||||
low_index = center_index;
|
||||
else {
|
||||
time_t prev_time = data_start_time;
|
||||
if (center_index > 0) {
|
||||
const ecl_sum_tstep_type * prev_step = ecl_sum_data_iget_ministep( data , center_index - 1 );
|
||||
prev_time = ecl_sum_tstep_get_sim_time( prev_step );
|
||||
}
|
||||
|
||||
if (prev_time < sim_time)
|
||||
internal_index = center_index; /* Found it */
|
||||
else
|
||||
high_index = center_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return internal_index;
|
||||
if (sim_time > center_time)
|
||||
low_index = center_index;
|
||||
else
|
||||
high_index = center_index;
|
||||
}
|
||||
}
|
||||
|
||||
const ecl_sum_tstep_type * low_step = ecl_sum_data_iget_ministep(data, low_index);
|
||||
return sim_time <= ecl_sum_tstep_get_sim_time(low_step) ? low_index : high_index;
|
||||
}
|
||||
|
||||
int ecl_sum_data_get_index_from_sim_days( const ecl_sum_data_type * data , double sim_days) {
|
||||
time_t sim_time = ecl_smspec_get_start_time( data->smspec );
|
||||
@ -594,7 +567,7 @@ int ecl_sum_data_get_index_from_sim_days( const ecl_sum_data_type * data , doubl
|
||||
|
||||
/**
|
||||
This function will take a true time 'sim_time' as input. The
|
||||
ministep indices bracketing this sim_time is identified, and the
|
||||
ministep indices bracketing this sim_time are identified, and the
|
||||
corresponding weights are calculated.
|
||||
|
||||
The actual value we are interested in can then be computed with the
|
||||
@ -616,40 +589,40 @@ int ecl_sum_data_get_index_from_sim_days( const ecl_sum_data_type * data , doubl
|
||||
function should be used), consult documentation at the top of this
|
||||
file.
|
||||
*/
|
||||
void ecl_sum_data_init_interp_from_sim_time(const ecl_sum_data_type* data,
|
||||
time_t sim_time,
|
||||
int* index1,
|
||||
int* index2,
|
||||
double* weight1,
|
||||
double* weight2) {
|
||||
int idx = ecl_sum_data_get_index_from_sim_time(data, sim_time);
|
||||
|
||||
|
||||
|
||||
void ecl_sum_data_init_interp_from_sim_time( const ecl_sum_data_type * data , time_t sim_time, int *_index1, int *_index2 , double * _weight1 , double *_weight2) {
|
||||
int index2 = ecl_sum_data_get_index_from_sim_time( data , sim_time);
|
||||
int index1;
|
||||
const ecl_sum_tstep_type * ministep2 = ecl_sum_data_iget_ministep( data , index2 );
|
||||
const ecl_sum_tstep_type * ministep1;
|
||||
time_t sim_time2 = ecl_sum_tstep_get_sim_time( ministep2 );
|
||||
|
||||
|
||||
index1 = index2;
|
||||
while (true) {
|
||||
index1--;
|
||||
ministep1 = ecl_sum_data_iget_ministep( data , index1 );
|
||||
{
|
||||
time_t sim_time1 = ecl_sum_tstep_get_sim_time( ministep1 );
|
||||
if (sim_time1 < sim_time2)
|
||||
break;
|
||||
}
|
||||
if (index1 == 0)
|
||||
util_abort("%s: Hmm internal error?? \n",__func__);
|
||||
// if sim_time is first date, idx=0 and then we cannot interpolate, so we give
|
||||
// weight 1 to index1=index2=0.
|
||||
if (idx == 0) {
|
||||
*index1 = 0;
|
||||
*index2 = 0;
|
||||
*weight1 = 1;
|
||||
*weight2 = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
double weight2 = (sim_time - ecl_sum_tstep_get_sim_time( ministep1 ));
|
||||
double weight1 = -(sim_time - ecl_sum_tstep_get_sim_time( ministep2 ));
|
||||
const ecl_sum_tstep_type * ministep1 = ecl_sum_data_iget_ministep(data, idx-1);
|
||||
const ecl_sum_tstep_type * ministep2 = ecl_sum_data_iget_ministep(data, idx);
|
||||
|
||||
time_t sim_time1 = ecl_sum_tstep_get_sim_time(ministep1);
|
||||
time_t sim_time2 = ecl_sum_tstep_get_sim_time(ministep2);
|
||||
|
||||
*_index1 = index1;
|
||||
*_index2 = index2;
|
||||
*_weight1 = weight1 / ( weight1 + weight2 );
|
||||
*_weight2 = weight2 / ( weight1 + weight2 );
|
||||
}
|
||||
*index1 = idx-1;
|
||||
*index2 = idx;
|
||||
|
||||
// weights the interpolation each of the ministeps according to distance from sim_time
|
||||
double time_diff = sim_time2 - sim_time1;
|
||||
double time_dist1 = (sim_time - sim_time1);
|
||||
double time_dist2 = -(sim_time - sim_time2);
|
||||
|
||||
*weight1 = time_dist2 / time_diff;
|
||||
*weight2 = time_dist1 / time_diff;
|
||||
}
|
||||
|
||||
|
||||
@ -661,51 +634,42 @@ void ecl_sum_data_init_interp_from_sim_days( const ecl_sum_data_type * data , do
|
||||
}
|
||||
|
||||
|
||||
double_vector_type * ecl_sum_data_alloc_seconds_solution( const ecl_sum_data_type * data , const smspec_node_type * node , double cmp_value, bool rates_clamp_lower) {
|
||||
double_vector_type * solution = double_vector_alloc( 0, 0);
|
||||
const int param_index = smspec_node_get_params_index( node );
|
||||
const int size = vector_get_size( data->data);
|
||||
const double is_rate = smspec_node_is_rate( node );
|
||||
double_vector_type * ecl_sum_data_alloc_seconds_solution(const ecl_sum_data_type * data, const smspec_node_type * node, double cmp_value, bool rates_clamp_lower) {
|
||||
double_vector_type * solution = double_vector_alloc(0, 0);
|
||||
const int param_index = smspec_node_get_params_index(node);
|
||||
const int size = vector_get_size(data->data);
|
||||
|
||||
if (size > 1) {
|
||||
int index = 0;
|
||||
const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , index );
|
||||
const ecl_sum_tstep_type * prev_ministep;
|
||||
double value = ecl_sum_tstep_iget( ministep , param_index );
|
||||
double prev_value;
|
||||
if (size <= 1)
|
||||
return solution;
|
||||
|
||||
while (true) {
|
||||
index++;
|
||||
if (index >= size)
|
||||
break;
|
||||
for (int index = 0; index < size; ++index) {
|
||||
int prev_index = util_int_max(0, index-1);
|
||||
|
||||
prev_ministep = ministep;
|
||||
prev_value = value;
|
||||
const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep(data, index);
|
||||
const ecl_sum_tstep_type * prev_ministep = ecl_sum_data_iget_ministep(data, prev_index);
|
||||
double value = ecl_sum_tstep_iget(ministep, param_index);
|
||||
double prev_value = ecl_sum_tstep_iget(prev_ministep, param_index);
|
||||
|
||||
ministep = ecl_sum_data_iget_ministep( data , index );
|
||||
value = ecl_sum_tstep_iget( ministep , param_index );
|
||||
// cmp_value in interval value (closed) and prev_value (open)
|
||||
bool contained = value == cmp_value;
|
||||
contained |= (util_double_min(prev_value, value) < cmp_value) &&
|
||||
(cmp_value < util_double_max(prev_value, value));
|
||||
|
||||
if ((value == cmp_value) ||
|
||||
(((value - cmp_value) * (cmp_value - prev_value)) > 0)) {
|
||||
double time1 = ecl_sum_tstep_get_sim_seconds( prev_ministep );
|
||||
double time2 = ecl_sum_tstep_get_sim_seconds( ministep );
|
||||
if (!contained)
|
||||
continue;
|
||||
|
||||
if (is_rate) {
|
||||
if (rates_clamp_lower)
|
||||
double_vector_append( solution , time1 + 1 );
|
||||
else
|
||||
double_vector_append( solution , time2 );
|
||||
} else {
|
||||
double slope = (value - prev_value) / (time2 - time1);
|
||||
double seconds = (cmp_value - prev_value) / slope + time1;
|
||||
double prev_time = ecl_sum_tstep_get_sim_seconds(prev_ministep);
|
||||
double time = ecl_sum_tstep_get_sim_seconds(ministep);
|
||||
|
||||
double_vector_append( solution , seconds );
|
||||
}
|
||||
if (smspec_node_is_rate(node)) {
|
||||
double_vector_append(solution, rates_clamp_lower ? prev_time + 1 : time);
|
||||
} else {
|
||||
double slope = (value - prev_value) / (time - prev_time);
|
||||
double seconds = (cmp_value - prev_value)/slope + prev_time;
|
||||
|
||||
}
|
||||
double_vector_append(solution, seconds);
|
||||
}
|
||||
}
|
||||
|
||||
return solution;
|
||||
}
|
||||
|
||||
@ -1216,35 +1180,32 @@ double ecl_sum_data_interp_get(const ecl_sum_data_type * data , int time_index1
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
int time_index1 , time_index2;
|
||||
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;
|
||||
int time_index1, time_index2;
|
||||
|
||||
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;
|
||||
int i;
|
||||
|
||||
ecl_sum_data_init_interp_from_sim_time( data , sim_time , &time_index1 , &time_index2 , &weight1 , &weight2);
|
||||
for(i = 0; i< num_keywords; i++ ){
|
||||
bool is_rate = ecl_sum_vector_iget_is_rate(keylist, i);
|
||||
int params_index = ecl_sum_vector_iget_param_index(keylist , i);
|
||||
if(is_rate){
|
||||
int time_index;
|
||||
if (sim_time == time_interval_get_start( data->sim_time ))
|
||||
time_index = 0;
|
||||
else
|
||||
time_index = ecl_sum_data_get_index_from_sim_time( data , sim_time );
|
||||
|
||||
value = ecl_sum_data_iget( data , time_index , params_index);
|
||||
} else {
|
||||
value = ecl_sum_data_interp_get( data , time_index1 , time_index2 , weight1 , weight2 , params_index);
|
||||
|
||||
}
|
||||
if(i == 0){
|
||||
fprintf(fp , "%f",value);
|
||||
}else{
|
||||
fprintf(fp , ",%f",value);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
fprintf(fp, "%f", value);
|
||||
else
|
||||
fprintf(fp, ",%f", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1253,7 +1214,6 @@ void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type * data , time_t
|
||||
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 );
|
||||
if (smspec_node_is_rate( smspec_node )) {
|
||||
int time_index;
|
||||
/*
|
||||
In general the mapping from sim_time to index is based on half
|
||||
open intervals, which are closed in the upper end:
|
||||
@ -1267,11 +1227,7 @@ double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t s
|
||||
with the ECLIPSE results if you ask for a value interpolated to
|
||||
the starting time.
|
||||
*/
|
||||
if (sim_time == time_interval_get_start( data->sim_time ))
|
||||
time_index = 0;
|
||||
else
|
||||
time_index = ecl_sum_data_get_index_from_sim_time( data , sim_time );
|
||||
|
||||
int time_index = ecl_sum_data_get_index_from_sim_time( data , sim_time );
|
||||
return ecl_sum_data_iget( data , time_index , params_index);
|
||||
} else {
|
||||
/* Interpolated lookup based on two (hopefully) consecutive ministeps. */
|
@ -26,6 +26,7 @@
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/fault_block.h>
|
||||
#include <ert/ecl/fault_block_layer.h>
|
||||
#include <ert/ecl/layer.h>
|
||||
|
||||
#define FAULT_BLOCK_ID 3297376
|
||||
@ -50,7 +51,7 @@ UTIL_IS_INSTANCE_FUNCTION( fault_block , FAULT_BLOCK_ID )
|
||||
static UTIL_SAFE_CAST_FUNCTION( fault_block , FAULT_BLOCK_ID )
|
||||
|
||||
|
||||
static fault_block_type * fault_block_alloc( const fault_block_layer_type * parent_layer , int block_id ) {
|
||||
fault_block_type * fault_block_alloc( const fault_block_layer_type * parent_layer , int block_id ) {
|
||||
fault_block_type * block = util_malloc( sizeof * block );
|
||||
UTIL_TYPE_ID_INIT( block , FAULT_BLOCK_ID );
|
||||
block->parent_layer = parent_layer;
|
||||
@ -77,7 +78,7 @@ int fault_block_get_id( const fault_block_type * block ) {
|
||||
}
|
||||
|
||||
|
||||
static void fault_block_free( fault_block_type * block ) {
|
||||
void fault_block_free( fault_block_type * block ) {
|
||||
int_vector_free( block->i_list );
|
||||
int_vector_free( block->j_list );
|
||||
int_vector_free( block->region_list );
|
@ -24,6 +24,7 @@
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/fault_block_layer.h>
|
||||
#include <ert/ecl/fault_block.h>
|
||||
#include <ert/ecl/layer.h>
|
||||
|
||||
#define FAULT_BLOCK_LAYER_ID 2297476
|
||||
@ -34,21 +35,18 @@
|
||||
the fault_block.c file; however the fault blocks should be closely
|
||||
linked to the layer object in the fault_block_layer structure - it
|
||||
is therefor not possible/legal to create a fault block instance by
|
||||
itself. To support that encapsulation the fault_block.c file is
|
||||
included here, and the functions:
|
||||
itself. To support that encapsulation the fault_block.c file is included
|
||||
here, and the functions:
|
||||
|
||||
fault_block_alloc();
|
||||
fault_block_free();
|
||||
|
||||
Which must be called through the fault_block_layer class are made
|
||||
static.
|
||||
declared here.
|
||||
*/
|
||||
|
||||
static fault_block_type * fault_block_alloc( const fault_block_layer_type * parent_layer , int block_id );
|
||||
static void fault_block_free( fault_block_type * block );
|
||||
|
||||
#include "fault_block.c"
|
||||
|
||||
fault_block_type * fault_block_alloc( const fault_block_layer_type * parent_layer , int block_id );
|
||||
void fault_block_free( fault_block_type * block, int block_id );
|
||||
|
||||
struct fault_block_layer_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
@ -88,7 +88,7 @@ struct fortio_struct {
|
||||
Observe that the semantics of the fortio_fseek() function depends
|
||||
on whether the file is writable.
|
||||
*/
|
||||
bool readable;
|
||||
bool writable;
|
||||
offset_type read_size;
|
||||
};
|
||||
|
||||
@ -96,15 +96,16 @@ struct fortio_struct {
|
||||
UTIL_IS_INSTANCE_FUNCTION( fortio , FORTIO_ID );
|
||||
UTIL_SAFE_CAST_FUNCTION( fortio, FORTIO_ID );
|
||||
|
||||
static fortio_type * fortio_alloc__(const char *filename , bool fmt_file , bool endian_flip_header , bool stream_owner , bool readable) {
|
||||
static fortio_type * fortio_alloc__(const char *filename , bool fmt_file , bool endian_flip_header , bool stream_owner , bool writable) {
|
||||
fortio_type * fortio = util_malloc(sizeof * fortio );
|
||||
UTIL_TYPE_ID_INIT( fortio, FORTIO_ID );
|
||||
fortio->filename = util_alloc_string_copy(filename);
|
||||
fortio->endian_flip_header = endian_flip_header;
|
||||
fortio->fmt_file = fmt_file;
|
||||
fortio->stream_owner = stream_owner;
|
||||
fortio->read_size = 0;
|
||||
fortio->readable = readable;
|
||||
fortio->writable = writable;
|
||||
fortio->read_size = 0;
|
||||
|
||||
return fortio;
|
||||
}
|
||||
|
||||
@ -207,10 +208,9 @@ static void fortio_init_size(fortio_type * fortio) {
|
||||
|
||||
|
||||
|
||||
fortio_type * fortio_alloc_FILE_wrapper(const char *filename , bool endian_flip_header , bool fmt_file , bool readable , FILE * stream) {
|
||||
fortio_type * fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , false , readable);
|
||||
fortio_type * fortio_alloc_FILE_wrapper(const char *filename , bool endian_flip_header , bool fmt_file , bool writable , FILE * stream) {
|
||||
fortio_type * fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , false , writable);
|
||||
fortio->stream = stream;
|
||||
fortio_init_size( fortio );
|
||||
return fortio;
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ static FILE * fortio_fopen_append( const char * filename , bool fmt_file ) {
|
||||
fortio_type * fortio_open_reader(const char *filename , bool fmt_file , bool endian_flip_header) {
|
||||
FILE * stream = fortio_fopen_read( filename , fmt_file );
|
||||
if (stream) {
|
||||
fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , true , true);
|
||||
fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , true , false);
|
||||
fortio->stream = stream;
|
||||
fortio->fopen_mode = fortio_fopen_read_mode( fmt_file );
|
||||
fortio_init_size( fortio );
|
||||
@ -306,7 +306,7 @@ fortio_type * fortio_open_reader(const char *filename , bool fmt_file , bool end
|
||||
fortio_type * fortio_open_writer(const char *filename , bool fmt_file , bool endian_flip_header ) {
|
||||
FILE * stream = fortio_fopen_write( filename , fmt_file );
|
||||
if (stream) {
|
||||
fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header, true , false);
|
||||
fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header, true , true);
|
||||
fortio->stream = stream;
|
||||
fortio->fopen_mode = fortio_fopen_write_mode( fmt_file );
|
||||
fortio_init_size( fortio );
|
||||
@ -333,7 +333,7 @@ fortio_type * fortio_open_readwrite(const char *filename , bool fmt_file , bool
|
||||
fortio_type * fortio_open_append(const char *filename , bool fmt_file , bool endian_flip_header) {
|
||||
FILE * stream = fortio_fopen_append( filename , fmt_file );
|
||||
if (stream) {
|
||||
fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , true , false);
|
||||
fortio_type *fortio = fortio_alloc__(filename , fmt_file , endian_flip_header , true , true);
|
||||
|
||||
fortio->stream = stream;
|
||||
fortio->fopen_mode = fortio_fopen_append_mode( fmt_file );
|
||||
@ -488,6 +488,17 @@ void fortio_data_fseek(fortio_type* fortio, offset_type data_offset, size_t data
|
||||
}
|
||||
}
|
||||
|
||||
int fortio_fclean(fortio_type * fortio) {
|
||||
long current_pos = ftell(fortio->stream);
|
||||
if(current_pos == -1)
|
||||
return -1;
|
||||
|
||||
int flush_status = fflush(fortio->stream);
|
||||
if(flush_status != 0)
|
||||
return flush_status;
|
||||
|
||||
return fseek(fortio->stream, current_pos, SEEK_SET);
|
||||
}
|
||||
|
||||
bool fortio_complete_read(fortio_type *fortio , int record_size) {
|
||||
int trailer;
|
||||
@ -749,16 +760,17 @@ static bool fortio_fseek__(fortio_type * fortio , offset_type offset , int whenc
|
||||
The semantics of this function depends on the readbale flag of the
|
||||
fortio structure:
|
||||
|
||||
readable == false: Ordinary fseek() semantics.
|
||||
writable == true: Ordinary fseek() semantics which can potentially
|
||||
grow the file.
|
||||
|
||||
readable == true: The function will only seek within the range of
|
||||
writable == false: The function will only seek within the range of
|
||||
the file, and fail if you try to seek beyond the EOF marker.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
bool fortio_fseek( fortio_type * fortio , offset_type offset , int whence) {
|
||||
if (!fortio->readable)
|
||||
if (fortio->writable)
|
||||
return fortio_fseek__( fortio , offset , whence );
|
||||
else {
|
||||
offset_type new_offset = 0;
|
||||
@ -819,6 +831,17 @@ bool fortio_read_at_eof( fortio_type * fortio ) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
When this function is called the underlying file is unlinked, and
|
||||
the entry will be removed from the filsystem. Subsequent calls which
|
||||
write to this file will still (superficially) succeed.
|
||||
*/
|
||||
|
||||
void fortio_fwrite_error(fortio_type * fortio) {
|
||||
if (fortio->writable)
|
||||
unlink( fortio->filename );
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
void fortio_fflush(fortio_type * fortio) { fflush( fortio->stream); }
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user