Updated internal ERT

Copied ERT from

614a4295ad
This commit is contained in:
Magne Sjaastad
2016-04-19 14:48:14 +02:00
parent 6e52a4101a
commit 362dd50e9b
1680 changed files with 29336 additions and 56081 deletions

View File

@@ -7,8 +7,8 @@ endif()
#-----------------------------------------------------------------
set( ERT_VERSION_MAJOR 1 )
set( ERT_VERSION_MINOR 10 )
set( ERT_VERSION_MAJOR 2 )
set( ERT_VERSION_MINOR 0 )
set( ERT_VERSION_MICRO git )
# If the micro version is not integer, that should be interpreted as a
@@ -18,7 +18,6 @@ set( ERT_VERSION_MICRO git )
option( BUILD_ERT "Build the full ERT application - Linux only" OFF)
option( BUILD_ENS_PLOT "Build small Eclipse plotting program - no" OFF)
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)
@@ -28,7 +27,7 @@ option( INSTALL_ERT "Should anything be installed when issuing make inst
option( ERT_BUILD_GUI "Should the pyQt based gui be compiled and installed" OFF )
option( ERT_USE_OPENMP "Use OpenMP - currently only in EclGrid" OFF)
option( ERT_DOC "Build ERT documantation" OFF)
option( ERT_BUILD_CXX "Build (some) CXX wrappers" ON)
option( ERT_BUILD_CXX "Build some CXX wrappers" ON)
include( CheckFunctionExists )
include( CheckTypeSize )
@@ -37,15 +36,15 @@ ENABLE_TESTING()
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(ERT_LINUX TRUE )
add_definitions( -DERT_LINUX )
set( ERT_BINARY_POSTFIX .${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} )
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(ERT_LINUX TRUE )
set(ERT_MAC TRUE)
add_definitions( -DERT_LINUX )
set( ERT_BINARY_POSTFIX .${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} )
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(ERT_WINDOWS TRUE)
add_definitions( -DERT_WINDOWS )
# This symbol must be defined to support large (> 2GB) files on windows.
add_definitions( -DWINDOWS_LFS )
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@@ -65,9 +64,7 @@ endif()
if (MSVC)
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
add_definitions( -DCOMPILER_MSVC )
elseif (CMAKE_COMPILER_IS_GNUCC)
add_definitions( -DCOMPILER_GCC )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x" )
endif()
@@ -84,28 +81,29 @@ if (ERT_USE_OPENMP)
endif()
include(cmake/ert_find.cmake)
include(cmake/ert_check.cmake)
#-----------------------------------------------------------------
# Checking based on compiling. Some of the code generates warnings, so we just cut down to bare-bone compiler flags.
set( CMAKE_C_FLAGS_main ${CMAKE_C_FLAGS} )
set( CMAKE_CXX_FLAGS_main ${CMAKE_CXX_FLAGS} )
if (NOT ERT_WINDOWS)
set( CMAKE_C_FLAGS "-std=gnu99" )
set( CMAKE_CXX_FLAGS "-std=c++0x")
endif()
set( ERT_EXTERNAL_UTIL_LIBS "" )
include(cmake/ert_build_check.cmake)
include(cmake/ert_api_check.cmake)
include(cmake/ert_lib_check.cmake)
set( CMAKE_C_FLAGS ${CMAKE_C_FLAGS_main} )
set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_main} )
include(cmake/Modules/UseMultiArch.cmake)
include(cmake/ert_link.cmake)
#-----------------------------------------------------------------
# Should we build the block_fs filesystem; this is used extensively
# by the ert application; but if you are only building the support
# eclipse related support libraries you can safely leave this at the
# default OFF value.
if (BUILD_ERT)
set( ERT_BUILD_BLOCK_FS ON)
else()
if (WITH_PTHREAD)
set( ERT_BUILD_BLOCK_FS OFF CACHE BOOL "Build the block_fs filesystem. Used by ERT application")
else()
set( ERT_BUILD_BLOCK_FS OFF)
endif()
endif()
#-----------------------------------------------------------------
set(INSTALL_GROUP "" CACHE STRING "Group to install as - blank to install as current group")
@@ -129,7 +127,6 @@ if (MSVC)
add_definitions( -D__func__="\\"????\\"")
endif()
if (ERT_LINUX)
set( NEED_LIBM TRUE )
set( LINK_STATIC FALSE )
@@ -139,10 +136,6 @@ else()
set( LINK_STATIC TRUE )
endif()
configure_file( ${PROJECT_SOURCE_DIR}/cmake/config/ert_build_config.h.in
${PROJECT_BINARY_DIR}/ert_build_config.h )
include_directories( ${PROJECT_SOURCE_DIR}/libert_util/include )
include_directories( ${PROJECT_BINARY_DIR}/libert_util/include )
if (MSVC)
@@ -154,21 +147,15 @@ add_subdirectory( libert_util )
include_directories( ${PROJECT_SOURCE_DIR}/libgeometry/include )
add_subdirectory( libgeometry )
if (BUILD_ERT OR BUILD_ENS_PLOT)
include_directories( ${PROJECT_SOURCE_DIR}/libplot/include )
add_subdirectory( libplot )
endif()
include_directories( ${PROJECT_SOURCE_DIR}/libecl/include )
add_subdirectory( libecl )
if (ERT_BUILD_CXX)
if (HAVE_CXX_SHARED_PTR)
include_directories( ${PROJECT_SOURCE_DIR}/libeclxx/include )
add_subdirectory( libeclxx )
else()
message(STATUS "Skipping CXX support - missing Cxx11 features.")
endif()
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 )

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +0,0 @@
#include <stdlib.h>
void dgemv_(char * , int * , int * , double * , double * , int * , const double * , int * , double * , double * , int * );
/*
This test is only to check if seperate linking with BLAS is
necessary; on the RedHat linux computers only explicit linking with
lapack is sufficient, whereas in other cases also blas must be
linked in specifically.
*/
int main(int argc , char ** argv) {
/* Wildly invalid input - but the signature is satisfies so it should compile. */
dgemv_( "A" , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL);
}

View File

@@ -1,8 +0,0 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
int main(int argc, char ** argv) {
struct stat stat_buffer;
return S_ISREG(stat_buffer.st_mode);
}

View File

@@ -1,7 +0,0 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
int main(int argc, char ** argv) {
mkdir("/tmp/path" , 0);
}

View File

@@ -0,0 +1,6 @@
#include <sys/stat.h>
int main(int argc, char ** argv) {
mode_t new_mode = S_IWGRP;
chmod( "/tmp" , new_mode );
}

View File

@@ -1,18 +0,0 @@
#cmakedefine HAVE_PTHREAD 1
#cmakedefine HAVE_EXECINFO 1
#cmakedefine HAVE_FORK 1
#cmakedefine HAVE_ZLIB 1
#cmakedefine HAVE_LSF 1
#cmakedefine HAVE_REALPATH 1
#cmakedefine HAVE_SYMLINK 1
#cmakedefine HAVE_READLINKAT 1
#cmakedefine HAVE_GETUID 1
#cmakedefine HAVE_LOCALTIME_R 1
#cmakedefine HAVE_LOCKF 1
#cmakedefine HAVE_SETENV 1
#cmakedefine HAVE_GLOB 1
#cmakedefine MKDIR_POSIX 1
#cmakedefine HAVE_FNMATCH 1
#cmakedefine NEED_BLAS 1
#cmakedefine HAVE_OPENMP 1
#cmakedefine HAVE_FTRUNCATE 1

View File

@@ -0,0 +1,74 @@
# This file contains feature checks which affect the API of the final
# product; i.e. if the test for zlib fails the function
# buffer_fwrite_compressed() will not be available in the final
# installation.
#
# The results of these tests will be assembled in the
# ert/util/ert_api_config.h header; all the symbols in that header will
# 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)
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()
message("ZLib not found - zlib support will not be included." )
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 )
add_definitions( -DPING_CMD="${PING_PATH}" )
endif()

View File

@@ -0,0 +1,75 @@
# This file contains checks which are used to implement portable
# utility functions. The results of these check are assembled in the
# generated header "ert/util/build_config.h" - that header is NOT part
# of the public api and it should only be included from source files
# as part of the compilation.
#
# 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( 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( _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()

View File

@@ -1,198 +0,0 @@
include(CheckSymbolExists)
check_function_exists( fseeko HAVE_FSEEKO )
if (HAVE_HFSEEKO)
add_definitions( -DHAVE_FSEEKO )
endif()
check_function_exists( regexec HAVE_REGEXP )
if (HAVE_REGEXP)
add_definitions( -DHAVE_REGEXP )
endif()
check_function_exists( realpath HAVE_REALPATH )
if (HAVE_REALPATH)
add_definitions( -DHAVE_REALPATH )
endif()
check_function_exists( chmod HAVE_CHMOD )
check_type_size( mode_t SIZE_MODE_T )
if (HAVE_CHMOD AND HAVE_SIZE_MODE_T)
add_definitions( -DHAVE_CHMOD_AND_MODE_T )
endif()
check_function_exists( fork HAVE_FORK )
if (HAVE_FORK)
add_definitions( -DHAVE_FORK )
endif()
check_function_exists( round HAVE_ROUND )
if (HAVE_ROUND)
add_definitions( -DHAVE_ROUND )
endif()
check_function_exists( ftruncate HAVE_FTRUNCATE )
if (HAVE_FTRUNCATE)
add_definitions( -DHAVE_FTRUNCATE )
endif()
check_function_exists( readlinkat HAVE_READLINKAT )
if (HAVE_READLINKAT)
add_definitions( -DHAVE_READLINKAT )
endif()
check_function_exists( symlink HAVE_SYMLINK )
if (HAVE_SYMLINK)
add_definitions( -DHAVE_SYMLINK )
endif()
check_function_exists( getuid HAVE_GETUID )
if (HAVE_GETUID)
add_definitions( -DHAVE_GETUID )
endif()
check_function_exists( _chdir HAVE_WINDOWS_CHDIR)
if (HAVE_WINDOWS_CHDIR)
add_definitions( -DHAVE_WINDOWS_CHDIR)
else()
check_function_exists( chdir HAVE_CHDIR)
if (HAVE_CHDIR)
add_definitions( -DHAVE_CHDIR)
else()
message(FATAL_ERROR "Could not find chdir() / _chdir() functions")
endif()
endif()
check_function_exists( localtime_r HAVE_LOCALTIME_R )
if (HAVE_LOCALTIME_R)
add_definitions( -DHAVE_LOCALTIME_R )
endif()
check_function_exists( lockf HAVE_LOCKF )
if (HAVE_LOCKF)
add_definitions( -DHAVE_LOCKF )
endif()
check_function_exists( glob HAVE_GLOB )
if (HAVE_GLOB)
add_definitions( -DHAVE_GLOB )
endif()
check_function_exists( fnmatch HAVE_FNMATCH )
if (HAVE_FNMATCH)
add_definitions( -DHAVE_FNMATCH )
endif()
check_function_exists( fsync HAVE_FSYNC )
if (HAVE_FSYNC)
add_definitions( -DHAVE_FSYNC )
endif()
check_function_exists( setenv HAVE_SETENV )
if (HAVE_SETENV)
add_definitions( -DPOSIX_SETENV )
endif()
check_function_exists( opendir HAVE_OPENDIR )
if (HAVE_OPENDIR)
add_definitions( -DHAVE_OPENDIR )
endif()
check_function_exists( getpwuid HAVE_GETPWUID )
if (HAVE_GETPWUID)
add_definitions( -DHAVE_GETPWUID )
endif()
# The usleep() check uses the symbol HAVE__USLEEP with double
# underscore to avoid conflict with plplot which defines the
# HAVE_USLEEP symbol.
check_function_exists( usleep HAVE__USLEEP )
if (HAVE__USLEEP)
add_definitions( -DHAVE__USLEEP )
endif()
check_symbol_exists(_tzname time.h HAVE_WINDOWS_TZNAME)
if (HAVE_WINDOWS_TZNAME)
add_definitions(-DHAVE_WINDOWS_TZNAME)
else()
check_symbol_exists(tzname time.h HAVE_TZNAME)
if (HAVE_TZNAME)
add_definitions(-DHAVE_TZNAME)
else()
message(FATAL_ERROR "Could not find tzname global variable")
endif()
endif()
check_function_exists(pthread_yield_np HAVE_YIELD_NP)
if (HAVE_YIELD_NP)
add_definitions(-DHAVE_YIELD_NP)
endif()
check_function_exists(pthread_yield HAVE_YIELD)
if (HAVE_YIELD)
add_definitions(-DHAVE_YIELD)
endif()
check_function_exists(pthread_timedjoin_np HAVE_TIMEDJOIN)
if (HAVE_TIMEDJOIN)
add_definitions(-DHAVE_TIMEDJOIN)
endif()
# Checking based on compiling. Some of the code generates warnings, so we just cut down to bare-bone compiler flags.
set( CMAKE_C_FLAGS_main ${CMAKE_C_FLAGS} )
set( CMAKE_CXX_FLAGS_main ${CMAKE_CXX_FLAGS} )
if (NOT ERT_WINDOWS)
set( CMAKE_C_FLAGS "-std=gnu99" )
set( CMAKE_CXX_FLAGS "-std=c++0x")
endif()
try_compile( HAVE_ISFINITE ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_isfinite.c )
if (HAVE_ISFINITE)
add_definitions( -DHAVE_ISFINITE )
endif()
try_compile( MKDIR_POSIX ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mkdir.c )
if (MKDIR_POSIX)
add_definitions( -DMKDIR_POSIX )
endif()
try_compile( HAVE_PID_T ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_pid_t.c )
if (HAVE_PID_T)
add_definitions( -DHAVE_PID_T )
endif()
try_compile( HAVE_VA_COPY ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_va_copy.c )
if (HAVE_VA_COPY)
add_definitions( -DHAVE_VA_COPY )
endif()
try_compile( ISREG_POSIX ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_isreg.c )
if (ISREG_POSIX)
add_definitions( -DHAVE_ISREG )
endif()
try_compile( HAVE_SIGBUS ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_have_sigbus.c )
if (HAVE_SIGBUS)
add_definitions( -DHAVE_SIGBUS )
endif()
try_compile( HAVE_CXX_SHARED_PTR ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_shared_ptr.cpp )
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)
add_definitions( -DTIME_T_64BIT_ACCEPT_PRE1970 )
endif()
endif()
endif()
set( CMAKE_C_FLAGS ${CMAKE_C_FLAGS_main} )
set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_main} )

View File

@@ -1,92 +0,0 @@
set(NEED_LIBDL OFF)
find_library( DL_LIBRARY NAMES dl )
find_path( DLFUNC_HEADER dlfcn.h )
if (DL_LIBRARY AND DLFUNC_HEADER)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl)
check_function_exists( dladdr HAVE_DLADDR )
if (HAVE_DLADDR)
add_definitions( -DHAVE_DLADDR )
set(NEED_LIBDL ON)
endif()
endif()
#-----------------------------------------------------------------
find_library( ZLIB_LIBRARY NAMES z )
find_path( ZLIB_HEADER zlib.h /usr/include )
if (ZLIB_LIBRARY AND ZLIB_HEADER)
option(WITH_ZLIB "Include support for zlib functions compress()/uncompress()" ON)
if (WITH_ZLIB)
add_definitions( -DWITH_ZLIB )
endif()
else()
set( WITH_ZLIB FALSE )
message("ZLib not found - zlib support will not be included." )
endif()
#-----------------------------------------------------------------
find_library( PTHREAD_LIBRARY NAMES pthread )
if (PTHREAD_LIBRARY)
option( WITH_PTHREAD "Include support for pthreads" ON )
if (WITH_PTHREAD)
add_definitions( -DWITH_PTHREAD )
endif()
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} pthread)
else()
set( WITH_PTHREAD FALSE )
message("pthread library not found - pthread support will not be included")
endif()
#-----------------------------------------------------------------
find_library( LAPACK_LIBRARY NAMES lapack)
if (LAPACK_LIBRARY)
set(CMAKE_REQUIRED_LIBS LAPACK_LIBRARY)
try_compile( BLAS0 ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_blas.c )
if (BLAS0)
set(NEED_BLAS OFF)
else()
set(NEED_BLAS ON)
find_library( BLAS_LIBRARY NAMES blas)
endif()
option(WITH_LAPACK "Build LAPACK enabled code" ON)
if (WITH_LAPACK)
add_definitions( -DWITH_LAPACK )
endif()
else()
set( WITH_LAPACK OFF)
message("LAPACK library not found - LAPACK support will not be included")
endif()
#-----------------------------------------------------------------
find_program(LATEX_PATH NAMES pdflatex)
if (LATEX_PATH)
option( WITH_LATEX "Build small class for compiling LaTeX files" ON)
if (WITH_LATEX)
set( WITH_LATEX ON)
add_definitions( -DWITH_LATEX )
endif()
else()
set( WITH_LATEX OFF )
endif()
#-----------------------------------------------------------------f
find_program(PING_PATH NAMES ping)
#-----------------------------------------------------------------
find_path( EXECINFO_HEADER execinfo.h /usr/include )
if (EXECINFO_HEADER)
add_definitions( -DHAVE_EXECINFO )
endif()
#-----------------------------------------------------------------
find_path( GETOPT_HEADER getopt.h /usr/include )
if (GETOPT_HEADER)
add_definitions( -DHAVE_GETOPT )
endif()
#-----------------------------------------------------------------
find_path( UNISTD_HEADER unistd.h /usr/include )
if (UNISTD_HEADER)
add_definitions( -DHAVE_UNISTD )
endif()
if (ERT_WINDOWS)
find_library( SHLWAPI_LIBRARY NAMES Shlwapi )
endif()
if (UNIX)
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
endif(UNIX)

View File

@@ -0,0 +1,30 @@
# 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()

View File

@@ -6,8 +6,18 @@ function(add_python_package target package_path source_files install_package)
set(build_files "")
foreach (file ${source_files} )
set( source_file ${CMAKE_CURRENT_SOURCE_DIR}/${file} )
set( build_file ${PROJECT_BINARY_DIR}/${package_path}/${file} )
string(SUBSTRING ${file} 0 1 first_char)
string(SUBSTRING ${file} 1 1 second_char)
if (first_char STREQUAL "/" OR second_char STREQUAL ":")
set( source_file ${file} )
set( build_file ${file} )
file(RELATIVE_PATH file ${CMAKE_CURRENT_BINARY_DIR} ${file})
set(dependent_target)
else()
set( source_file ${CMAKE_CURRENT_SOURCE_DIR}/${file} )
set( build_file ${PROJECT_BINARY_DIR}/${package_path}/${file} )
set(dependent_target DEPENDS ${source_file})
endif()
if("$ENV{DESTDIR}" STREQUAL "")
set( install_file ${CMAKE_INSTALL_PREFIX}/${package_path}/${file} )
else()
@@ -18,7 +28,7 @@ function(add_python_package target package_path source_files install_package)
OUTPUT ${build_file}
COMMAND ${PYTHON_EXECUTABLE}
ARGS ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc2 ${source_file} ${build_file}
DEPENDS ${source_file} )
${dependent_target})
list(APPEND build_files ${build_file} )
@@ -30,4 +40,4 @@ function(add_python_package target package_path source_files install_package)
endforeach()
add_custom_target( ${target} ALL DEPENDS ${build_files})
endfunction()
endfunction()

View File

@@ -0,0 +1 @@
usr/lib/python2.7/*

View File

@@ -17,7 +17,7 @@ configure_file(index.rst.in ${PROJECT_BINARY_DIR}/tmp_doc/index.rst)
configure_file(conf.py.in ${PROJECT_BINARY_DIR}/conf.py)
add_custom_target(doc_out ALL
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/script/run-sphinx.py ${PROJECT_BINARY_DIR}/conf.py ${PROJECT_BINARY_DIR}/python ${PROJECT_BINARY_DIR}/tmp_doc
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/script/run-sphinx.py ${PROJECT_BINARY_DIR}/conf.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} ${PROJECT_BINARY_DIR}/tmp_doc
DEPENDS enkf )
INSTALL( DIRECTORY ${PROJECT_BINARY_DIR}/tmp_doc/_build/ DESTINATION ${CMAKE_INSTALL_PREFIX}/documentation )

View File

@@ -0,0 +1,2 @@
Working with Eclipse files
==========================

View File

@@ -0,0 +1,3 @@
Working with full ert cases
===========================

View File

@@ -0,0 +1,2 @@
Working with geometric objects
==============================

View File

@@ -0,0 +1,10 @@
.. _example:
Examples
========
.. toctree::
:maxdepth: 1
Eclipse results <eclipse/index>
Geometric objects <geo/index>
Full ert cases <ert/index>

View File

@@ -1,10 +1,13 @@
.. _python_documentation:
Python documentation
====================
.. toctree::
:maxdepth: 1
:maxdepth: 2
introduction/index
eclipse/index
../../API/python/ert
../../API/python/ert_gui
Overview of ert Python <packages/index>
examples/index
ert package - autogenerated API documentation <../../API/python/ert>
ert_gui package - autogenerated API documentation <../../API/python/ert_gui>

View File

@@ -1,4 +1,703 @@
Simple introduction to Python
=============================
An introduction to Python
.. contents::
:depth: 2
:local:
Python is a object oriented scripting language. The language is used
in a wide range of a applications. Beeing a interpreted scripting
language it is not blazingly fast in itself, but it is quite easy to
extend with compiled code written in e.g. C, that is how we are making
large parts of the ERT functionality available in Python. The Python
language has good documentation, including tutorials on
http://www.python.org, however some language concepts which will be
much used in the documentation will be briefly explained here. The
rest of this section will focus on the following little example which
contains the class defintion of a circle object.
.. code-block:: python
:linenos:
import math
class Circle(object):
def __init__( self , x0 , y0 , r):
"Create a new circle with radius r centered at (x0,y0)."
self.x0 = x0
self.y0 = y0
self.r = r
def move(self, new_x , new_y):
"Move the position of the circle to (new_x,new_y)."
self.x0 = new_x
self.y0 = new_y
# Observe that here we have three different ways to get the area
# of the circle: The normal method getArea( ), the class method
# calculateArea( ) and finally the area property. Having three
# different methods in this way should *not* be interpreted as a
# best practice in any way - it is mainly to illustrate the
# concepts of class methods and properties.
def getArea( self ):
"Calculate the area of the circle."
return math.pi*self.r * self.r
def calculateArea(cls , radius):
"Calculate the area of *a* circle with radius 'radius'."
return math.pi * radius * radius
@property
def area( self ):
"Calculate the area of the circle."
return math.pi*self.r * self.r
def distance( self , other ):
"Calculate the distance between two circles."
if isinstance( other , Circle ):
dx = self.x0 - other.x0
dy = self.y0 - other.y0
return math.sqrt( dx*dx + dy*dy)
else:
raise TypeError("Second argument must be Circle instance.")
# Create two circles
circle1 = Circle( 2,2,3 )
circle2 = Circle( 5,5,7 )
# Calculate the area of the circles, and the distance between them
print "Area of circle1:%10.3f" % circle1.getArea( )
print "Area of circle2:%10.3f" % circle2.getArea( )
print "Distance between circles: %10.3f" % circle1.distance( circle2 )
# Move one of the circles and calculate new distance
circle1.move( 3,3 )
print "Distance between circles: %10.3f" % circle1.distance( circle2 )
Notation
--------
Whitespace matters
..................
In Python whitespace, or more precisely indentation level, matters -
the logical codeblocks are defined by the indentation level. Observe
for instance the if test on line 39. If the if test evaluates to True
the codeblock in lines 40-42 is executed, otherwise the statement on
line 44 is executed. Aport from the indentation level additional
whitespace in the code, including blank lines, is ignored.
Comments
........
Comments in Python are prefixed with :code:`#`; everything from a
:code:`#` to the end of the current line is disregarded as a comment:
.. code:: python
# The following function will add to numbers and return the summary
def add_numbers(a,b):
return a+b
Documentation strings
.....................
It is possible to add documentation strings right after the
:code:`def` statement, in the example above we have documentation
strings on lines 6,12,25,29,34 and 38. These documentation strings
will be picked up by the Python documentation tool :code:`pydoc`. In
the example below we use :code:`pydoc` to print the documentation of
the area method:
.. code:: bash
bash% pydoc XXX.Circle.getArea
Calculate the area of the circle.
Where XXX should be the name of the module containing the Circle
class. Most of the modules and classes in the ert package have
reasonably good documentation strings.
Functions
---------
Functions are declared with the keyword :code:`def` and the name of
the function. Functions take ordinary named arguments, but can in
addition have optional arguments. If an argument is optional the
default value must be specified in the statement defining the
function. In the function below the a gross price is calculated based
on a net price and a vat rate, the vat rate is given as an optional
variable:
.. code:: python
def gross_price( net_price , vat_rate = 0.25):
return net_price * (1 + vat_rate)
total = gross_price( 100 )
total_taxfree = gross_price( 100 , vat_rate = 0.0 )
Optional arguments with suitable defaults is used quite a lot in the
ert. The ERT python code is mainly based on classes, it is not
required to use classes in the the code you write yourself - but ample
use of functions is highly recommended to aid readiblity and
maintainence.
Object oriented programming - classes
-------------------------------------
Python is an *object oriented* language. An object is a composite
variable which consists of normal variables (often called members) and
functions to operate on the members (often called) methods. When
programming we *implement a Class*, and the class can viewed as a
recipee for how to create an object. The process of creating an object
is often called instantiation, and an object of a particular type is
called an instance. The normal way to create a new object is just to
"call" the class name with the required arguments, i.e.
.. code:: python
circle = Circle(0,0,5)
Will create a new :code:`Circle` object located in position (0,0) with
radius 5.
Members
.......
In Python the class members are not declared anywhere, but
automagically comes into life when assigned to. In the
:code:`__init__()` method on line 5 we create the member variables
:code:`x0,y0` and :code:`r` by assignment. The Python language does
not have any built in notion of public and private, all members and
methods are public by construction, and can be accessed outside the
class, if we have a :code:`Circle` instance we can both read and the
radius attribute directly:
.. code:: python
circle = Circle(0,0,5)
print("The radius of the circle is %g " % circle.r)
# Enlarge the circle
circle.r *= 2.0
print("The radius of the circle is %g " % circle.r)
Directly accessing a member variable in this form is considered bad
form - see the discussion of the :code:`move()` implementation
further down for a better alternative.
Methods
.......
Methods are functions defined as part of a class definition; the
methods represent the "handles" to the outside world - which can be
used to query and manipulate the state of the object. The method
:code:`move()` in the :code:`Circle` class is used to move the circle
to a new location:
.. code:: python
circle = Circle(0,0,5)
circle.move(2 , 2)
# Since the members are not protected, you can move the circle
# without going through the move() method:
circle.x0 = 2
circle.y0 = 2
# Directly assigning to the member variable in this way is
# considered *very bad form*.
In addition to the :code:`move` method The :code:`Circle` class has
the ordinary methods :code:`distance()` and :code:`getArea()`. The
:code:`distance()` and :code:`getArea()` methods perform a
calculation, but do not change the state of the object. The
:code:`__init__()` method is quite ordinary, but it is invoked
automatically by the Python runtime system when a new object is
instantiated, and normally not invoked explicitly.
In the implementation all normal methods should have the *class
instance* as the first argument, the variable name *self* is usually
used for this class instance variable.
Properties
..........
Properties are methods without arguments which can be called without
the empty :code:`( )`. Consider the :code:`area` property in
:code:`Circle` example:
.. code:: python
circle = Circle( 10 )
print("method call: The area of the circle is: %g" % circle.getArea( ))
print("property : The area of the circle is: %g" % circle.area)
The example in :code:`Circle` class is a *read/get* property - it is
also possible to implement *write/set* properties. In the :code:`ert`
Python package we have deprecated the use of properties in the favor
of traditional methods with :code:`( )`- but there are still some
properties, in particular in the :code:`ert.ecl` package.
Classmethods
............
A normal method requires that you first create an instance of an
object, and then afterwards you can can use the methods of the
object. For instance you must have a :code:`Circle` instance available
before you can call the :code:`getArea()` method. However there are
situations where you would like to make functionality available with a
particular class, without really requring a class instance - then a
*class method* can be used. Se for instance the :code:`calculateArea`
method of :code:`Circle` class. Since a class method is implemented
without a class instance, the implementation *can not make use of
members in the class*. The class methods are called with the class
name as prefix, or *if* you have a circle instance you can use that
prefix:
.. code:: python
# Call the calculateArea class method:
print("Area of circle with radius:10 m = %g m*m " % Circle.calculateArea( 10 ))
# If we have class instance we can use that to call a class method; since
# the class method does not have access to the members of the class we must
# pass the radius explicitly:
c = Circle( 10 )
print("Area of circle : %g" % c.calculateArea( c.r ))
Special functions / operators
.............................
When implementing a Python class you can implement various *special
methods* which will integrate your class into Python language, the
special methods all have names like :code:`__xxx__`. Let us assume we
are creating a class for a mathematical vector, for a vector you
typically want to query how long it is, set and get individual
elements and you might be interested in adding two vectors:
.. code-block:: python
:linenos:
class Vector(object):
def __init__(self, size, initial_value = 0):
self.data = [ initial_value ] * size
def __len__(self):
return len(self.data)
def __iadd__(self , other):
if isinstance(other , Vector):
if len(self) == len(other):
for index,value in enumerate(other):
self[index] += value
else:
raise ValueError("The two vectors must be equally long")
else:
raise TypeError("__iadd__() function requires two vectors")
return self
def __add__(self , other):
copy = Vector( len(self) )
for index,value in enumerate(self):
copy[index] = value
copy += other
return copy
def __getitem__(self, index):
if 0 <= index < len(self):
return self.data[index]
else:
raise IndexError("Invalid index:%d" % index)
def __setitem__(self, index,value):
if 0 <= index < len(self):
self.data[index] = value
else:
raise IndexError("Invalid index:%d" % index)
The important point with this example is the methods :code:`__len__`,
:code:`__getitem__` and :code:`__setitem__`. The :code:`__len__`
method is bound to the :code:`len( )` operator and :code:`__getitem__`
and :code:`__setitem__` are bound to the :code:`[]` operator [1]_:
.. code:: python
# Create a new vector of length 10; initialized to zero.
v = Vector(10)
# Check the length
print("The length of the vector is:%d" % len(v))
# Set the elements to 0,1,2,3,...
for i in range(len(v)):
v[i] = i
# Check that the elements are correctly set
for i in range(len(v)):
if not v[i] == i:
raise Exception("operator[] not corectly implemented")
# When getitem is implemented we can loop over the whole vector
sum = 0
for elm in v:
sum += elm
# Create a new vector
v2 = Vector(10)
for i in range(len(v2)):
v2[i] = i
# This will call the __add__() method
v3 = v + v2
# This will call the __iadd__() method
v3 += v2
For this example we have only implemented the :code:`__add__` and
:code:`__iadd__` methods to add to vectors, in addition there are
similar functions :code:`__sub__`, :code:`__mul__` and :code:`__div__`
for subtraction, multiplaction and divition. Observe the difference
between the :code:`__add__` and :code:`__iadd__` - the first creates a
new copy whereas the second updates a vector *in place*.
For the ert classes we have tried to implement the special methods
where it makes sense, depending on the class that typically includes
:code:`__len__`, :code:`__getitem__`, :code:`__setitem__`,
:code:`__contains__` and the arithmetic operators.
Error handling - exceptipons
-----------------------------
Python uses a mechanism called *exceptions* to signal error
conditions. When an exception is raised the "current location" in the
program will return back (stack unwind) all the way back to a
statement handling the exception, or the program will exit if the
exception is not handled. The advantage of exceptions as a way to
handle errors is that it is not necessary to clutter the code with
error handling conditions "all over the place". Exceptions is the way
to handle error conditions in many programming languages.
.. code-block:: python
:linenos:
#!/usr/bin/env python
import math
def call_sqrt(x):
y = math.sqrt(x)
print "The square root of %g is %g" % (x , y)
y = call_sqrt( -1 )
In this example we try to calculate the square root of -1, that is
invalid and Python will raise an exception:
.. code:: bash
Traceback (most recent call last):
File "/path/to/file.py" line 9 in <module>
call_sqrt(-1)
File "/path/to/file.py" line 5 in call_sqrt
y = math.sqrt(x)
ValueError: math domain error
What happens here is the following:
1. In the internal function :code:`sqrt` which is called on line 5
the invalid input argument is detected an exception is *raised*.
2. The exception will propagate backwards in the call stack, first to
to the line 5, and then back to call on line 9 and finally the
program will print an error message and terminate.
The error messages from an exception can be a bit challenging to read,
but by looking at it we can see where the error happens, and we get a
*hint* of what is wrong - in this case the hint "math domain error"
should give us a clue of what the problem is. There is some logic to
the type of the exception, in this case the exception raised will be
:code:`ValueError`- the value -1 is an invalid argument to the
:code:`sqrt` function.
If we don't *handle* the exception the program will eventuelly exit
with an error message, but if this error does not signal a fatal
error, but rather something which might very well happen, we might
wish to *catch* the exception with a :code:`try` :code:`except`
construction:
.. code-block:: python
:linenos:
#!/usr/bin/env python
import math
def call_sqrt(x):
try:
y = math.sqrt(x)
print "The square root of %g is %g" % (x , y)
except ValueError:
print "Oh no - you can not do sqrt( %g )" % x
call_sqrt( 16 )
call_sqrt( -1 )
call_sqrt( 9 )
When we run this program the :code:`try: except:` block will *catch*
the :code:`ValueError` exception and instead print a friendly error
message:
.. code:: bash
The square root of 16 is 4
Oh no - you can not do sqrt( -1 )
The square root of 9 is 3
The ert code uses exceptions to signal error conditions, if you get an
exception in your ert based code you can *assume* that there is a
something wrong in your code. On the other hand you might get a really
*hard crash* with an error message looking like[2]_:
.. code:: bash
Abort called from: float_vector_iset (/home/joaho/jenkins/workspace/ERT-deploy-upstream-branch/build/libert_util/src/float_vector.c:615)
float_vector_iset: Sorry - can NOT set negative indices. called with index:-1
--------------------------------------------------------------------------------
#00 ???(..) in /path/devel/libert_util/src/util_abort_gnu.c:154
#01 util_abort__(..) in /path/devel/libert_util/src/util_abort_gnu.c:263
#02 float_vector_iset(..) in /path/build/libert_util/src/float_vector.c:615
#03 ecl_smspec_fread_alloc(..) in /path/devel/libecl/src/ecl_smspec.c:1078
#04 ???(..) in /path/devel/libecl/src/ecl_sum.c:198
#05 ecl_sum_fread_alloc_case__(..) in /path/devel/libecl/src/ecl_sum.c:227
#06 ffi_call_unix64(..) in /tmp/Python-2.7.6/Modules/_ctypes/libffi/src/x86/unix64.S:79
#07 ffi_call(..) in /tmp/Python-2.7.6/Modules/_ctypes/libffi/src/x86/ffi64.c:524
#08 _ctypes_callproc(..) in /tmp/Python-2.7.6/Modules/_ctypes/callproc.c:857
#09 ???(..) in /tmp/Python-2.7.6/Modules/_ctypes/_ctypes.c:3940
#10 PyObject_Call(..) in ???
#11 PyEval_EvalFrameEx(..) in ???
#12 PyEval_EvalCodeEx(..) in ???
--------------------------------------------------------------------------------
These hard crashes can unfortunately *not* be handled by the
:code:`try: except:` construction in Python. There might be a bug in
your code; but that it results in such a brutal traceback is certainly
a bug in the ert code - please report it!
Organizing python code in modules and packages
----------------------------------------------
Python code is written in files and stored in directories; this is the
foundation for modules and packages.
Modules
.......
Python code is written in files, one file of Python code is called a
module, and can be imported into other Python code. In the small
example below we create a module which contains a class :code:`C`, a
function :code:`add` and a scalar variable :code:`var`. The whole
thing is saved in a file called :code:`module.py`:
.. code:: python
class C(object):
def __init__(self , arg ):
self.arg = arg
def calc( self , v ):
return ...
def add(a, b):
return a+b
var = "Bjarne"
This module now contains three *symbols*: :code:`C`, :code:`add` and
:code:`var` which can be reused from another context. To be able to
use the symbols from the module we must *import* the module, there are
several minor variations over the import statement, the exact import
statement used determines which name the symbols should be given in
the importing scope.
Import all symbols under the module namespace
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
.. code:: python
import module
c = module.C( 10 )
print "Variable is:%s" % module.var
print "Adding 10,20:%g" % module.add(10,20)
I.e. all the symbols from module.py have become available, but we must
prefix them with :code:`module` to use them.
Import all the symbols from module into the current namespace
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
.. code:: python
from module import *
c = C( 10 )
print "Variable is:%s" % var
print "Adding 10,20:%g" % add(10,20)
Again all the symbols from :code:`module.py` are available, but now
they have been imported all the way into the current namespace and can
be accessed without the module prefix.
Selectively importing some symbols
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
.. code:: python
from module import C
import module.add
c = C( 10 )
print "Adding 10,20:%g" % module.add(10,20)
We have imported the :code:`C` and :code:`add` symbols; the :code:`C`
symbol has been imported all the way into the current namespace,
whereas the :code:`add` symbol is available under the module
namespace. The :code:`var` symbol has not been imported, and if we try
to access that, using either :code:`var` or :code:`module.var` will we
get an error.
Import and rename
,,,,,,,,,,,,,,,,,
.. code:: python
import module as myModule
c = myModule.C( 10 )
print "Adding 10,20:%g" % myModule.add(10,20)
Here we have imported all of module, but we access it internally as
myModule.
Packages
........
Modules are just ordinary Python files, in the same way packages are
just ordinary directories, with the *special file* :code:`__init__.py`
in them; the :code:`__init__.py` file can be empty - but it must exist
in the directory for Python to treat the directory as a *package*. The
files and directories contained in the package directory will then be
modules and subpackages. In the ert distribution the package,
subpackage and module looks like this:
.. code::
ert/ <-- Top level package / directory.
ert/__init__.py <-- Magic file signalling that 'ert' is a package.
ert/ecl/ <-- ecl is subpackage.
ert/ecl/__init__.py <-- Magic file signalling that 'ecl' is a package.
ert/ecl/ecl_grid.py <-- Normal module in the ecl package.
ert/ecl/ecl_sum.py <-- Normal module in the ecl package.
All of ert Python is organized as a Python package. The top level
package ert has nearly no content, but contains subpackages ert.ecl,
ert.job_queue and so on ert.util. Each of the subpackages contain many
modules, as the module ert.ecl.ecl_grid which implements functionality
to work with ECLIPSE grids. Each of the modules typically implement
one or a few related classes, like the class EclGrid which is
implemented in the ert.ecl.ecl_grid module.
The :code:`__init__.py` file must be present for Python to realize
that a certainl directory should be interpreted as a *package*; the
file can be empty, but it can also be used for e.g. initialization. In
the case of :code:`ert` we import symbols from modules to the
subpackage, so that we can import class symbols as:
.. code:: python
from ert.ecl import EclGrid, EclSum
Getting started with ert Python
-------------------------------
If the ert python package and the necessary shared libraries have all
been correctly installed at your site, the following script should
work:
.. code:: python
#!/usr/bin/env python
import ert
print "Python: the ert package has been sucessfuly loaded"
If this works as intended you are ready to actually start working on
your actual problem. Hopefully the example section will have something
you can start from.
.. [1] A vector designed for high performance numerical operations
would never be implemented this way; performance aside a class
implementing this functionality should also have much more
error checking.
.. [2] Observe that the error message will typically point to a file
like :code:`/tmp/ert_abort_dump_xxx_20160101-026343.log` - the
content of that file will resemble the backtrace listed here.

View File

@@ -0,0 +1,3 @@
The ert.config package
======================

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
The ert.enkf package
====================

View File

@@ -0,0 +1,2 @@
The ert.geo package
===================

View File

@@ -0,0 +1,20 @@
The ert packages
================
.. toctree::
:maxdepth: 1
util/index.rst
config/index.rst
eclipse/index.rst
well/index.rst
geometry/index.rst
enkf/index.rst
Currently only the package targeted at working with Eclipse files,
:code:`ert.ecl` has extensive documentation. In
:ref:`python_documentation` there are links to auto generated API
documentation for all of ert, and in :ref:`example` there are some
additional examples.

View File

@@ -0,0 +1,2 @@
The ert.util package
===================

View File

@@ -0,0 +1,2 @@
The ert.well package
====================

View File

@@ -19,7 +19,7 @@ import os
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../python/python'))
sys.path.insert(0, os.path.abspath('${PYTHON_INSTALL_PREFIX}'))
# -- General configuration ------------------------------------------------

View File

@@ -216,7 +216,7 @@ Concrete tips:
....
this can then be easily captured to a temporary file by setting
the stdout redirection of the util_fork_exec() function, and then
the stdout redirection of the util_spawn() function, and then
subsequently the 100% normal way of creating a gen_obs instance
can be used. Input arguments / input files / e.t.c. to the
OBS_SCRIPT should be given in the SCRIPT_ARG option - fully

View File

@@ -8,6 +8,7 @@ Contents:
tutorial/index
keywords/index
magic_strings/index
workflows/index
observations/index
distributions/index

View File

@@ -63,7 +63,6 @@ Keyword name Required by
:ref:`ENKF_PEN_PRESS <enkf_pen_press>` NO FALSE Should we want to use a penalised PRESS statistic in model selection?
:ref:`ENKF_RERUN <enkf_rerun>` NO FALSE Should the simulations be restarted from time zero after each update.
:ref:`ENKF_SCALING <enkf_scaling>` NO TRUE Do we want to normalize the data ensemble to have unit variance?
:ref:`ENKF_SCHED_FILE <enkf_sched_file>` NO Allows fine-grained control of the time steps in the simulation.
:ref:`ENKF_TRUNCATION <enfk_truncation>` NO 0.99 Cutoff used on singular value spectrum.
:ref:`ENSPATH <enspath>` NO storage Folder used for storage of simulation results.
:ref:`EQUIL_INIT_FILE <equil_init_file>` NO Use INIT_SECTION instead
@@ -76,6 +75,7 @@ Keyword name Required by
:ref:`GEN_PARAM <gen_param>` NO Add a general parameter.
:ref:`GRID <grid>` YES Provide an ECLIPSE grid for the reservoir model.
:ref:`HISTORY_SOURCE <history_source>` NO REFCASE_HISTORY Source used for historical values.
:ref:`HOOK_WORKFLOW <hook_workflow>` NO Install a workflow to be run automatically.
:ref:`HOST_TYPE <host_type>` NO
:ref:`IGNORE_SCHEDULE <ignore_schedule>` NO
:ref:`IMAGE_TYPE <image_type>` NO png The type of the images created when plotting.
@@ -87,7 +87,6 @@ Keyword name Required by
:ref:`ITER_RETRY_COUNT <iter_retry_count>` NO 4 Number of retries for a iteration - iterated ensemble smoother
:ref:`JOBNAME <jobname>` NO Name used for simulation files. An alternative to ECLBASE.
:ref:`JOB_SCRIPT <job_script>` NO Python script managing the forward model.
:ref:`KEEP_RUNPATH <keep_runpath>` NO Specify realizations that simulations should be kept for.
:ref:`LOAD_SEED <load_seed>` NO Load random seed from given file.
:ref:`LOAD_WORKFLOW <load_workflow>` NO Load a workflow into ERT.
:ref:`LOAD_WORKFLOW_JOB <load_workflow_job>` NO Load a workflow job into ERT.
@@ -118,19 +117,10 @@ Keyword name Required by
:ref:`PLOT_WIDTH <plot_width>` NO 1024 Pixel width of the plots.
:ref:`PRE_CLEAR_RUNPATH <pre_clear_runpath>` NO FALSE Should the runpath be cleared before initializing?
:ref:`QC_PATH <qc_path>` NO QC ...
:ref:`QC_WORKFLOW <qc_workflow>` NO Name of existing workflow to do QC work.
:ref:`QUEUE_SYSTEM <queue_system>` NO System used for running simulation jobs.
:ref:`REFCASE <refcase>` NO (see HISTORY_SOURCE and SUMMARY) Reference case used for observations and plotting.
:ref:`REFCASE_LIST <refcase_list>` NO Full path to Eclipse .DATA files containing completed runs (which you can add to plots)
:ref:`REPORT_CONTEXT <report_context>` NO Values for variables used in report templates.
:ref:`REPORT_GROUP_LIST <report_group_list>` NO Specify list of groups used in report templates.
:ref:`REPORT_LARGE <report_large>` NO FALSE
:ref:`REPORT_LIST <report_list>` NO List of templates used for creating reports.
:ref:`REPORT_PATH <report_path>` NO Reports Directory where final reports are stored.
:ref:`REPORT_SEARCH_PATH <report_search_path>` NO Search path for report templates.
:ref:`REPORT_TIMEOUT <report_timeout>` NO 120 Timeout for running LaTeX.
:ref:`REPORT_WELL_LIST <report_well_list>` NO Specify list of wells used in report templates.
:ref:`RERUN_PATH <rerun_path>` NO ...
:ref:`RERUN_PATH <rerun_path>` NO ...
:ref:`RERUN_START <rerun_start>` NO 0 ...
:ref:`RFT_CONFIG <rft_config>` NO Config file specifying wellnames and dates for rft-measurments. Used for plotting. The format has to be name day month year (ex. Q-2FI 02 08 1973), with a new entry on a new line.
:ref:`RFTPATH <rftpath>` NO rft Path to where the rft well observations are stored
@@ -141,7 +131,6 @@ Keyword name Required by
:ref:`STD_SCALE_CORRELATED_OBS <std_scale_correlated_obs>` NO FALSE Try to estimate the correlations in the data to inflate the observation std.
:ref:`SCHEDULE_FILE <schedule_file>` YES Provide an ECLIPSE schedule file for the problem.
:ref:`SCHEDULE_PREDICTION_FILE <schedule_prediction_file>` NO Schedule prediction file.
:ref:`SELECT_CASE <select_case>` NO The current case / default You can tell ert to select a particular case on bootup.
:ref:`SETENV <setenv>` NO You can modify the UNIX environment with SETENV calls.
:ref:`SINGLE_NODE_UPDATE <single_node_update>` NO FALSE ...
:ref:`STD_CUTOFF <std_cutoff>` NO 1e-6 ...
@@ -296,7 +285,13 @@ These keywords are optional. However, they serve many useful purposes, and it is
.. _delete_runpath:
.. topic:: DELETE_RUNPATH
When the enkf application is running it creates directories for the ECLIPSE simulations, one for each realization. When the simulations are done, the enkf will load the results into it's internal database. If you are using the enkf application as a convenient way to start many simulations, e.g. using the screening experiment option, the default behavior is to not delete these simulation directories. This behavior can be overridden with the DELETE_RUNPATH keyword, which causes enkf to delete the specified simulation directories. When running the EnKF algorithm, the behavior is the opposite. The keyword KEEP_RUNPATH can then be used to override the default behavoir.
When the ert application is running it creates directories for
the forward model simulations, one for each realization. When
the simulations are done, ert will load the results into the
internal database. By default the realization folders will be
left intact after ert has loaded the results, but using the
keyword DELETE_RUNPATH you can request to have (some of) the
directories deleted after results have been loaded.
*Example A:*
@@ -314,46 +309,6 @@ These keywords are optional. However, they serve many useful purposes, and it is
The DELETE_RUNPATH keyword is optional.
.. _enfk_sched_file:
.. topic:: ENKF_SCHED_FILE
When the enkf application runs the EnKF algorithm, it will use
ECLIPSE to simulate one report step at a time, and do an
update after each step. However, in some cases it will be
beneficial to turn off the EnKF update for some report steps
or to skip some steps completely. The keyword ENKF_SCHED_FILE
can point to a file with a more advanced schedule for when to
perform the updates. The format of the file pointed to by
ENKF_SCHED_FILE should be plain text, with one entry per
line. Each line should have the following form:
::
REPORT_STEP1 REPORT_STEP2 ON|OFF STRIDE
...
Here REPORT_STEP1 and REPORT_STEP2 are the first and last
report steps respectively and ON|OFF determines whether the
EnKF analysis should be ON or OFF, the STRIDE argument is
optional. If the analysis is ON the stride will default to
REPORT_STEP2 minus REPORT_STEP1, thus if you want to perform
analysis at each report step set stride equal to 1. Observe
that whatever value of stride is used, the integration will
always start on REPORT_STEP1 and end on REPORT_STEP2. Example:
::
0 100 OFF
100 125 ON 5
125 200 ON 1
In this example, the enkf application will do the following:
#. Simulate directly from report step 0 to report step 100. No EnKF update will be performed.
#. From report step 100 to report step 125 it will simulate five report steps at a time, doing EnKF update at report steps 105, 110, 115, 120 and 125.
#. From report step 125 to report step 200 it will simulate one report step at a time, doing EnKF update for every timestep.
The ENKF_SCHED_FILE keyword is optional.
.. _end_date:
.. topic:: END_DATE
@@ -398,16 +353,6 @@ These keywords are optional. However, they serve many useful purposes, and it is
The ENSPATH keyword is optional.
.. _select_case:
.. topic:: SELECT_CASE
By default ert will remember the selected case from the
previous run, or select the case "default" if this is the
first time you start a project. By using the SELECT_CASE
keyword you can tell ert to start up with a particular
case. If the requested case does not exist ert will ignore the
SELECT_CASE command, the case will not be created
automagically.
.. _history_source:
.. topic:: HISTORY_SOURCE
@@ -481,20 +426,6 @@ These keywords are optional. However, they serve many useful purposes, and it is
The INSTALL_JOB keyword is optional.
.. _keep_runpath:
.. topic:: KEEP_RUNPATH
When the enkf application is running it creates directories for the ECLIPSE simulations, one for each realization. If you are using the enkf application to run the EnKF algorithm, the default behavior is to delete these directories after the simulation results have been internalized. This behavior can be overridden with the KEEP_RUNPATH keyword, which causes enkf to keep the specified simulation directories. When running the enkf application as a convenient way to start many simulations, e.g. using the screening experiment option, the behavior is the opposite, and can be overridden with the DELETE_RUNPATH keyword.
*Example:*
::
-- Keep simulation directories 0 to 15 and 18 and 20
KEEP_RUNPATH 0-15, 18, 20
The KEEP_RUNPATH keyword is optional.
.. _obs_config:
.. topic:: OBS_CONFIG
@@ -1995,173 +1926,33 @@ The name and location of this file is available as the magical string <RUNPATH_F
QC keywords
-----------
.. _qc_keywords:
.. _hook_workflow:
.. topic:: HOOK_WORKFLOW
The QC system is mainly based on workflows.
.. _qc_workflow:
.. topic:: QC_WORKFLOW
Name of an existing workflow to do QC work. Will be invoked automatically when a ensemble simulation has been completed, can alternatively be invoked from the QC menu.
.. _qc_path:
.. topic:: QC_PATH
No information on this keyword yet
Creating reports
----------------
.. _creating_reports:
ERT has a limited capability to create pdf reports based on a LaTeX template and the plots you have created. The process for creating reports works like this:
#. You select a report template using the REPORT_LIST keyword.
#. ERT will insantiate a LaTeX report file by using your template, and performing some substitutions. The LaTeX report will be stored in a temporary directory /tmp/latex-XXXXXX.
#. pdflatex is used to compile the latex file into a pdf file
**Format of the template file**
The template file should mostly be ordinary LaTeX, but when instantiating ERT will search and replace some strings. The most important are:
**$PLOT_CASE**
This will be replaced with the name of the current case, and that is used to locate the active figures.
**$WELL_LIST**
This will be expanded to a list of well names, REPORT_WELL_LIST below.
**$GROUP_LIST**
This will be expanded to a list of group names, REPORT_GROUP_LIST below.
**$CONFIG_FILE**
The full path of the config file currently in use.
**$USER**
The username of the current user.
**Template loops**
The template can have a very simple for loop construction. The syntax of the for loop is as follows:
With the keyword :code:`HOOK_WORKFLOW` you can configure workflow
'hooks'; meaning workflows which will be run automatically at certain
points during ERTs execution. Currently there are two points in ERTs
flow of execution where you can hook in a workflow, either just before
the simulations start, :code:`PRE_SIMULATION` - or after all the
simulations have completed :code:`POST_SIMULATION`. The
:code:`POST_SIMULATION` hook is typically used to trigger QC
workflows:
::
{% for x in [a,b,c,d] %}
%% Do something with x
{% endfor %}
HOOK_WORKFLOW initWFLOW PRE_SIMULATION
HOOK_WORKFLOW QC_WFLOW1 POST_SIMULATION
HOOK_WORKFLOW QC_WFLOW2 POST_SIMULATION
The whole concept is based on regular expressions and is quite picky on the format. Observe the following:
#. CaSe MAttErs - i.e. {% For ... %} with a capital 'F' will not work.
#. The loop variable must start with $ or a letter, followed by an arbitrary number of letters and numbers. I.e. $well, x and ab21 are all valid variable names, whereas 5b, __internal and #var are examples of invalid variable names.
#. The behaviour of the matching in the body depends on whether the variable starts with '$' or not:
#. If the variable starts with '$' embedded substrings will be matched - i.e. WWCT$well will be expanded to e.g. WWCTOP-1.
#. If the variable starts with an alphabet character substrings will not be replaced - i.e. the well in wellname will not be touched.
#. All the spaces (underlined here) in {% for x in [a,b,c,d] %} and {% endfor %} must be present; you can have more spaces if you like.
#. A missing {% endfor %} will be detected with a warning; all other errors will go undected, producing something different from what you wanted, it will probably not even compile.
**Problems**
When LaTeX compiling you will get a prompt like this on the screen:
::
Creating report Reports/<Case>/<Name.pdf> [Work-path:/tmp/latex-XXXXXX] ......
This means that ERT has created the directory /tmp/latex-XXXXXX and populated that with the file which is compiled. If there are LaTeX problems of some kind you must go to this directory to check out what is wrong, and then fix the source template. When the compilation is finished ERT will print:
::
Creating report Reports/<Case>/<Name.pdf> [Work-path:/tmp/latex-XXXXXX] ...... OK??
As indicated by the OK?? it is quite difficult for ERT to assert that the compilation has been successfull, so the pdf file must be opened with e.g. acroread to be certain.
.. _report_context:
.. topic:: REPORT_CONTEXT
With the report context word you can define key,value pairs which will be used in a search-and-replace operation in the template.
*Example:*
::
REPORT_CONTEXT $FIELD Snorre
REPORT_CONTEXT $MODEL "DG-X sensitivity studies"
Here every occurence of $FIELD will be replaced with 'Snorre' and every occurence of $MODEL will be replaced with 'DG-X sensitivity studies'. Observe that the config parser expects that the REPORT_CONTEXT keyword gets two space separated arguments, so quoting with "" is necessary when the value consists of several words. The use of a '$' prefix on the keys above is just a suggestion, and not a rule.
.. _report_list:
.. topic:: REPORT_LIST
This should be a list of LaTeX templates which you want to use for creating reports. The arguments in this list should either be the path to an existing file, or alternatively the name of a file which can be found in REPORT_SEARCH_PATH. The search order will be to first look directly in the filesystem, and then subsequently go through the paths listed in REPORT_SEARCH_PATH
The filename can optionally be followed by a :Name, in that case the created report will be renamed Name.pdf irrespective of the name of the template file.
*Example:*
::
REPORT_SEARCH_PATH /common/report/path
REPORT_LIST templates/report.tex /some/absolute/path/report.tex:Report2 well_report.tex:snorre_wells.tex
In the example we specify templates for three different reports:
#. In the relative path templates/report.tex
#. In the absolute path /some/absolute/path/report.tex
#. Assuming there is no file well_report.tex in your current directory ERT will look in the paths specified by REPORT_SEARCH_PATH.
Observe the two latter reports will be renamed Report2.pdf and snorre_wells.pdf respectively.
.. _report_path:
.. topic:: REPORT_PATH
The REPORT_PATH keyword is used to tell ERT where you want to store the finished pdf reports. A subdirectory with the current case name will be appended to this path:
::
REPORT_LIST templates/well_report.tex templates/field_report.tex
REPORT_PATH Reports
Assuming the selected case is called prior you will get the reports Reports/prior/well_report.pdf and Reports/prior/field_report.tex.
.. _report_search_path:
.. topic:: REPORT_SEARCH_PATH
It is possible to install LaTeX templates for reports in a common location, the REPORT_LIST keyword will then search for the templates in these locations. You can use the REPORT_SEARCH_PATH keyword in your config file, but the most relevant use is in the global site configuration file.
::
REPORT_SEARCH_PATH /common/path/well_reports /common/path/group_reports
REPORT_SEARCH_PATH /common/path/field_reports
.. _report_well_list:
.. topic:: REPORT_WELL_LIST
By using the {% for x in [] %} construction in the templates it is possible to have report templates which loop over a list of wells. Unfortunately it is not very interesting to loop over all wells, because ECLIPSE has a limited amount of meta information about the wells, which means that injectors and producers will be treated equally. By using the REPORT_WELL_LIST keyword you can specify which wells you wish to include in the report, these well names will then be assembled into a list which will go into the $WELL_LIST keyword in the report template.
::
REPORT_WELL_LIST C* E1-H -- Must have supplied a REFCASE for the '*' to work properly
REPORT_WELL_LIST OP*
These well names are then assembled into a list and replace the symbol $WELL_LIST when creating the report. For this to work the report template should contain a section like:
::
{% for $well in $WELL_LIST %}
% Do something with $well
{% endfor %}
.. _report_group_list:
.. topic:: REPORT_GROUP_LIST
This is just like the REPORT_WELL_LIST keyword, but for groups.
In this example the the workflow :code:`initWFLOW` will run after all
the simulation directiories have been created, just before the forward
model is submitted to the queue. When all the simulations are complete
the two workflows :code:`QC_WFLOW1` and :code:`QC_WFLOW2` will be
run. Observe that the workflows being 'hooked in' with the
:code:`HOOK_WORKFLOW` must be loaded with the :code:`LOAD_WORKFLOW`
keyword.
NB: Currently the :code:`PRE_SIMULATION` workflow is never called.
Manipulating the Unix environment
---------------------------------

View File

@@ -16,28 +16,69 @@ An alterative way to 'program' the local config commands is by writing a Python
Not all the commands available from the local config programming are supported for Python scripting.
**Local config ERT script example:**
**Local config python script example:**
::
from ert.enkf import ErtScript
from ert.enkf import LocalConfig
class LocalConfigJob(ErtScript):
def run(self):
ert = self.ert()
local_config = ert.getLocalConfig()
# Add your local config commands here
dataset_multflt = local_config.createDataset("DATASET_MULTFLT")
...
from ert.enkf import ErtScript
from ert.enkf import LocalConfig, LocalObsdata, LocalObsdataNode, LocalMinistep, LocalUpdateStep, LocalDataset, ActiveList
from ert.ecl import EclGrid, EclRegion, Ecl3DKW, EclFile, EclInitFile, EclKW, EclTypeEnum
class LocalConfigJob(ErtScript):
def run(self):
# This example can be used with the REEK data set from the ERT tutorial
# Get the ert object
ert = self.ert()
# Get local config object
local_config = ert.getLocalConfig()
# Reset internal local config structure. From now you need to specify what to localize
local_config.clear()
# There is only one update step
updatestep = local_config.getUpdatestep()
# A ministep
ministep = local_config.createMinistep("MINISTEP" )
# Add some dataset you want to localize here.
dataset_multflt = local_config.createDataset("DATASET_MULTFLT")
# Add some field and localize inside a box
data_poro = local_config.createDataset("DATA_PORO")
ecl_grid = local_config.getGrid()
ecl_region = EclRegion(ecl_grid, False)
ecl_region.select_box((0,0,0),(3,3,3))
data_poro.addField("PORO", ecl_region)
# Add some index from MULTFLT to the dataset
dataset_multflt.addNode("MULTFLT")
active_list = dataset_multflt.getActiveList("MULTFLT")
active_list.addActiveIndex(0)
# Add existing observations from WOPR:OP_1. Alternatively, use getObservations and filter the observations you want to use for this ministep.
obsdata_wopr = local_config.createObsdata("WOPR:OP_1_10")
for i in range(1,10):
obsdata_wopr.addNode("OBS"+str(i))
# Attach the created dataset and obsset to the ministep
ministep.attachDataset(dataset_multflt)
ministep.attachObsset(obsdata_wopr)
# Then attach the ministep to the update step
updatestep.attachMinistep(ministep)
# Write a .csv file for debugging. The generated file can be imported into Excel for a better tabulation of the setup
local_config.writeSummaryFile("tmp/summary_local_config.csv")
# Write to file for debugging
local_config.writeLocalConfigFile("tmp/debug_local_config.txt")
List of keywords
@@ -45,8 +86,8 @@ List of keywords
=========================================================================================== =========================================================== ==============================================================================================================================================
Keyword name ERT script function Purpose
=========================================================================================== =========================================================== ==============================================================================================================================================
:ref:`CREATE_UPDATESTEP <create_updatestep>` getUpdatestep Creates/gets default updatestep
:ref:`CREATE_MINISTEP <create_ministep>` createMinistep Creates ministep
:ref:`CREATE_UPDATESTEP <create_updatestep>` createUpdatestep Creates updatestep
:ref:`CREATE_DATASET <create_dataset>` createDataset Creates dataset
:ref:`COPY_DATASET <copy_dataset>` copyDataset Deep copy of dataset
:ref:`CREATE_OBSSET <create_obsset>` createObsdata Creates observation set
@@ -56,14 +97,13 @@ Keyword name
:ref:`ATTACH_OBSSET <attach_obsset>` attachObsset Attaches observation set to mini step
:ref:`ADD_DATA <add_data>` addNode Adds data node to dataset
:ref:`DEL_DATA <del_data>` del Deletes observation node from dataset
:ref:`ADD_OBS <add_obs>` addNodeAndRange Adds observation node to observation set
:ref:`ADD_OBS <add_obs>` addNode, addNodeAndRange Adds observation node to observation set for all times or in a given time range
:ref:`DEL_OBS <del_obs>` del Deletes observation node from observation set
:ref:`DATASET_DEL_ALL_DATA <dataset_del_all_data>` clear Delete all the data keys from a dataset
:ref:`ACTIVE_LIST_ADD_DATA_INDEX <active_list_add_data_index>` addActiveIndex Adds data index to the list of active indices
:ref:`ACTIVE_LIST_ADD_OBS_INDEX <active_list_add_obs_index>` addActiveIndex Adds observation index to the list of active indices
:ref:`ACTIVE_LIST_ADD_MANY_DATA_INDEX <active_list_add_many_data_index>` addActiveIndex Adds several data indices to the list of active indices
:ref:`ACTIVE_LIST_ADD_MANY_OBS_INDEX <active_list_add_many_obs_index>` addActiveIndex Adds several observation indinces to the list of active indices
:ref:`INSTALL_DEFAULT_UPDATESTEP <install_default_updatestep>` Installs default update step
:ref:`ADD_FIELD <add_field>` addField Adds field node to dataset
:ref:`LOAD_FILE <load_file>` EclGrid, EclInitFile, Loads eclipse file in restart format
:ref:`CREATE_ECLREGION <create_eclregion>` EclRegion Creates a new region for use when defining active regions for fields
@@ -82,6 +122,8 @@ Keyword name
:ref:`SURFACE_REGION_SELECT_IN_POLYGON <surface_region_select_in_polygon>` Creates region to select or deselect parts of a surface
:ref:`SURFACE_REGION_SELECT_LINE <surface_region_select_line>` Selects or deselects parts of a surface in half space define by a line
:ref:`ADD_DATA_SURFACE <add_data_surface>` Adds surface node to dataset with elements in a surface region
| getObservations Get the observations currently imported. Use to filter the observations to localize.
| getGrid Get the underlying grid. Use to define active cells in a field.
=========================================================================================== =========================================================== ==============================================================================================================================================
.. ###########################################################################################################
@@ -89,23 +131,23 @@ Keyword name
.. _create_updatestep:
.. topic:: CREATE_UPDATESTEP
| This function will create a new updatestep with the name 'NAME_OF_UPDATESTEP'. Observe that you must add (at least) one ministep to the updatestep, otherwise it will not be able to do anything.
| This function will create a updatestep with the name 'NAME_OF_UPDATESTEP'.
| Observe that you must add (at least) one ministep to the updatestep, otherwise it will not be able to do anything.
| Currently supports only one update step. It is kept here due to historical reasons when it was possible to have several update steps.
*Example:*
::
-- Update step in time interval 0->1
CREATE_UPDATESTEP UPDATESTEP_0_1
-- Updatestep
CREATE_UPDATESTEP DEFAULT
*Example:*
::
update_step_0_1 = local_config.createUpdatestep("UPDATESTEP_0_1")
updatestep = local_config.getUpdatestep()
.. ###########################################################################################################
@@ -119,14 +161,14 @@ Keyword name
::
-- Mini step 0 in update step 0->1
CREATE_MINISTEP MINISTEP_0_1_0
-- Ministep in updatestep
CREATE_MINISTEP MINISTEP
*Example:*
::
ministep_0_1_0 = local_config.createMinistep("MINISTEP_0_1_0")
ministep = local_config.createMinistep("MINISTEP")
@@ -213,14 +255,14 @@ Keyword name
::
-- Attach MINISTEP_0_1_0 to UPDATESTEP_0_1
ATTACH_MINISTEP UPDATESTEP_0_1 MINISTEP_0_1_0
-- Attach MINISTEP to UPDATESTEP
ATTACH_MINISTEP UPDATESTEP MINISTEP
*Example:*
::
update_step_0_1.attachMinistep(ministep_0_1_0)
update_step.attachMinistep(ministep)
.. ###########################################################################################################
@@ -234,14 +276,14 @@ Keyword name
::
-- Attach DATASET_MULTFLT to MINISTEP_0_1_0
ATTACH_MINISTEP MINISTEP_0_1_0 DATASET_MULTFLT
-- Attach DATASET_MULTFLT to MINISTEP
ATTACH_MINISTEP MINISTEP DATASET_MULTFLT
*Example:*
::
ministep_0_1_0.attachDataset(dataset_multflt)
ministep.attachDataset(dataset_multflt)
.. ###########################################################################################################
@@ -255,14 +297,14 @@ Keyword name
::
-- Attach OBS_WELL to MINISTEP_0_1_0
ATTACH_MINISTEP MINISTEP_0_1_0 OBS_WELL
-- Attach OBS_WELL to MINISTEP
ATTACH_MINISTEP MINISTEP OBS_WELL
*Example:*
::
ministep_0_1_0.attachObsset(obsset_obs_well)
ministep.attachObsset(obsset_obs_well)
.. ###########################################################################################################
@@ -329,6 +371,9 @@ Keyword name
-- The obsset has a time range
obsset_obs_well.addNodeAndRange("WOPR:OBS_WELL", 0, 1)
-- All times are active
obsset_obs_well.addNode("WOPR:OBS_WELL")
.. ###########################################################################################################
@@ -449,23 +494,6 @@ Keyword name
-- Add index 0, 1 and 2 from data WOPR:OBS_WELL to obsset OBS_WELL
ACTIVE_LIST_ADD_MANY_OBS_INDEX OBS_WELL WOPR:OBS_WELL 0 1 2
.. ###########################################################################################################
.. _install_default_updatestep:
.. topic:: INSTALL_DEFAULT_UPDATESTEP
| This function will install 'NAME_OF_UPDATESTEP' as the default updatestep which applies to all report steps where you have not explicitly set another updatestep with the INSTALL_UPDATESTEP function.
*Example:*
::
-- Install default update step
INSTALL_DEFAULT_UPDATESTEP ALL_ACTIVE
.. ###########################################################################################################

View File

@@ -0,0 +1,30 @@
.. _ert_magic_strings_full_doc:
Magic Strings
===================================
Magic strings are special keywords that can be used in configuration files and templates which have special meanings.
ERT Config
----------
These magic strings are available in the ERT config file.
**<CONFIG_FILE>**
Inserts the config file name with extension into the config file.
::
ENSPATH storage/<CONFIG_FILE>/ensemble
If the config file is named *config.ert* then the resulting storage path will be:
::
storage/config.ert/ensemble
**<CONFIG_FILE_BASE>**
Same as <CONFIG_FILE> but inserts the config file name without the extension into the config file.

View File

@@ -195,36 +195,28 @@ Jobs related to running simulations - including updates
**RUN_SMOOTHER**
The RUN_SMOOTHER job will run a simulation and perform an update. The updated parameters are default stored as the new initial parameters of the current case. Optionally the job can take 1 or 2 parameters. The case to store the updated parameters in can be specified as the first argument. A second argument can be specified to run a simulation with the updated parameters.
The RUN_SMOOTHER job will run a simulation and perform an update. The
job has one required argument - the name of a case where the updated
parameters are stored. Optionally the job can take a second boolean
argument, if the second argument is set to true the job will rerun
based on the updated parameters.
Run a simulation and an update. The updated parameters are stored as the new initial parameters of the current case:
::
RUN_SMOOTHER
Run a simulation and an update. Store the updated parameters in the specified case. This case is created if it does not exist:
Run a simulation and an update. Store the updated parameters in the
specified case. This case is created if it does not exist:
::
RUN_SMOOTHER new_case
Run a simulation and an update. Store the updated parameters in the specified case, then run a simulation on this case:
Run a simulation and an update. Store the updated parameters in the
specified case, then run a simulation on this case:
::
RUN_SMOOTHER new_case true
Run a simulation and an update. Store the updated parameters in the current case, then run a simulation again. Specify "*" to use the current case:
::
RUN_SMOOTHER * true
**RUN_SMOOTHER_WITH_ITER**

View File

@@ -3,7 +3,7 @@ set( source_files analysis_module.c enkf_linalg.c std_enkf.c sqrt_enkf.c cv_enkf
set( header_files analysis_module.h enkf_linalg.h analysis_table.h std_enkf.h fwd_step_enkf.h)
add_library( analysis SHARED ${source_files} )
set_target_properties( analysis PROPERTIES COMPILE_DEFINITIONS INTERNAL_LINK)
set_target_properties( analysis PROPERTIES VERSION 1.0 SOVERSION 1.0 )
set_target_properties( analysis PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR} )
target_link_libraries( analysis ert_util )
target_link_libraries( analysis dl )

View File

@@ -50,6 +50,7 @@ typedef struct config_content_struct config_content_type;
int config_content_iget_as_int( const config_content_type * content , const char * key , int occurence , int index);
bool config_content_iget_as_bool( const config_content_type * content , const char * key , int occurence , int index);
double config_content_iget_as_double( const config_content_type * content , const char * key , int occurence , int index);
const char * config_content_iget_as_path( const config_content_type * content , const char * key , int occurence , int index);
const char * config_content_safe_iget(const config_content_type * content , const char *kw, int occurence , int index);
int config_content_get_occurences(const config_content_type * content, const char * kw);

View File

@@ -49,7 +49,7 @@ typedef struct config_parser_struct config_parser_type;
void config_free(config_parser_type *);
config_parser_type * config_alloc( );
char ** config_alloc_active_list(const config_parser_type * , int * );
config_content_type * config_parse(config_parser_type * , const char * , const char * , const char * , const char * , config_schema_unrecognized_enum unrecognized_behaviour , bool );
config_content_type * config_parse(config_parser_type * config, const char * filename, const char * comment_string, const char * include_kw, const char * define_kw, const hash_type * pre_defined_kw_map, config_schema_unrecognized_enum unrecognized_behaviour , bool validate);
bool config_has_schema_item(const config_parser_type * config , const char * kw);
/*****************************************************************/

View File

@@ -32,44 +32,25 @@ extern "C" {
/**
Types used for validation of config items.
*/
typedef enum {CONFIG_STRING = 1,
CONFIG_INT = 2,
CONFIG_FLOAT = 4,
CONFIG_PATH = 8,
CONFIG_EXISTING_PATH = 16,
CONFIG_BOOL = 32,
CONFIG_CONFIG = 64,
CONFIG_BYTESIZE = 128,
CONFIG_EXECUTABLE = 256 ,
CONFIG_INVALID = 512 } config_item_types;
#define CONFIG_ITEM_TYPE_ENUM_DEFS \
{.value = 1 , .name="CONFIG_STRING"}, \
{.value = 2 , .name="CONFIG_INT"}, \
{.value = 4 , .name="CONFIG_FLOAT"}, \
{.value = 8 , .name="CONFIG_PATH"}, \
{.value = 16 , .name="CONFIG_EXISTING_PATH"}, \
{.value = 32 , .name="CONFIG_BOOL"}, \
{.value = 64 , .name="CONFIG_CONFIG"}, \
{.value = 128 , .name="CONFIG_BYTESIZE"}, \
{.value = 256 , .name="CONFIG_EXECUTABLE"}, \
{.value = 512 , .name="CONFIG_INVALID"}
#define CONFIG_ITEM_TYPE_ENUM_SIZE 10
typedef enum {
CONFIG_STRING = 1,
CONFIG_INT = 2,
CONFIG_FLOAT = 4,
CONFIG_PATH = 8,
CONFIG_EXISTING_PATH = 16,
CONFIG_BOOL = 32,
CONFIG_CONFIG = 64,
CONFIG_BYTESIZE = 128,
CONFIG_EXECUTABLE = 256,
CONFIG_INVALID = 512
} config_item_types;
typedef enum {
typedef enum {
CONFIG_UNRECOGNIZED_IGNORE = 0,
CONFIG_UNRECOGNIZED_WARN = 1,
CONFIG_UNRECOGNIZED_ERROR = 2
} config_schema_unrecognized_enum;
#define CONFIG_SCHEMA_UNRECOGNIZED_ENUM_DEFS \
{.value = 0 , .name="CONFIG_UNRECOGNIZED_IGNORE"}, \
{.value = 1 , .name="CONFIG_UNRECOGNIZED_WARN"}, \
{.value = 2 , .name="CONFIG_UNRECOGNIZED_ERROR"}
#define CONFIG_SCHEMA_UNRECOGNIZED_ENUM_SIZE 3
} config_schema_unrecognized_enum;

View File

@@ -2,7 +2,7 @@ set( source_files config_parser.c config_content.c config_error.c config_schema_
set( header_files config_parser.h config_content.h config_error.h config_schema_item.h config_content_item.h config_content_node.h config_root_path.h config_path_elm.h conf.h conf_data.h)
add_library( config ${LIBRARY_TYPE} ${source_files} )
set_target_properties( config PROPERTIES VERSION 1.0 SOVERSION 1.0 )
set_target_properties( config PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR} )
target_link_libraries( config ert_util )
if (USE_RUNPATH)

View File

@@ -110,6 +110,8 @@ config_error_type * config_content_get_errors( const config_content_type * conte
void config_content_free( config_content_type * content ) {
vector_free( content->nodes );
vector_free( content->path_elm_stack );
vector_free( content->path_elm_storage );
hash_free( content->items );
config_error_free( content->parse_errors );
subst_list_free( content->define_list );
@@ -197,6 +199,12 @@ double config_content_iget_as_double( const config_content_type * content , cons
return config_content_item_iget_as_double(item , occurence , index);
}
const char * config_content_iget_as_path( const config_content_type * content , const char * key , int occurence , int index) {
config_content_item_type * item = config_content_get_item(content , key);
config_content_node_type * node = config_content_item_iget_node( item , index );
return config_content_node_iget_as_path(node , index);
}
/**
This function will return NULL is the item has not been set,

View File

@@ -192,10 +192,12 @@ static config_content_node_type * config_content_item_set_arg__(subst_list_type
int iarg;
for (iarg = 0; iarg < argc; iarg++) {
int env_offset = 0;
char * env_var;
do {
env_var = util_isscanf_alloc_envvar( stringlist_iget(token_list , iarg + 1) , env_offset );
if (env_var != NULL) {
while (true) {
char * env_var = util_isscanf_alloc_envvar( stringlist_iget(token_list , iarg + 1) , env_offset );
if (env_var == NULL)
break;
{
const char * env_value = getenv( &env_var[1] );
if (env_value != NULL) {
char * new_value = util_string_replace_alloc( stringlist_iget( token_list , iarg + 1 ) , env_var , env_value );
@@ -205,7 +207,9 @@ static config_content_node_type * config_content_item_set_arg__(subst_list_type
fprintf(stderr,"** Warning: environment variable: %s is not defined \n", env_var);
}
}
} while (env_var != NULL);
free( env_var );
}
}
}
@@ -637,11 +641,25 @@ config_content_type * config_parse(config_parser_type * config ,
const char * comment_string ,
const char * include_kw ,
const char * define_kw ,
const hash_type * pre_defined_kw_map,
config_schema_unrecognized_enum unrecognized_behaviour,
bool validate) {
config_content_type * content = config_content_alloc( );
if(pre_defined_kw_map != NULL) {
hash_iter_type * keys = hash_iter_alloc(pre_defined_kw_map);
while(!hash_iter_is_complete(keys)) {
const char * key = hash_iter_get_next_key(keys);
const char * value = hash_get(pre_defined_kw_map, key);
config_content_add_define( content , key , value );
}
hash_iter_free(keys);
}
//
if (util_file_readable( filename )) {
path_stack_type * path_stack = path_stack_alloc();
{

View File

@@ -87,7 +87,7 @@ struct validate_struct {
#define CONFIG_SCHEMA_ITEM_ID 6751
struct config_schema_item_struct {
UTIL_TYPE_ID_DECLARATION;
char * kw; /* The kw which identifies this item<EFBFBD> */
char * kw; /* The kw which identifies this item */
bool required_set;
@@ -526,12 +526,3 @@ stringlist_type * config_schema_item_get_required_children_value(const config_sc
/*****************************************************************/
/* Small functions to support enum introspection. */
const char * config_schema_item_type_enum_iget( int index, int * value) {
return util_enum_iget( index , CONFIG_ITEM_TYPE_ENUM_SIZE , (const util_enum_element_type []) { CONFIG_ITEM_TYPE_ENUM_DEFS }, value);
}
const char * config_schema_item_unrecognized_enum_iget( int index, int * value) {
return util_enum_iget( index , CONFIG_SCHEMA_UNRECOGNIZED_ENUM_SIZE , (const util_enum_element_type []) { CONFIG_SCHEMA_UNRECOGNIZED_ENUM_DEFS }, value);
}

View File

@@ -33,7 +33,7 @@ int main(int argc , char ** argv) {
config_schema_item_set_argc_minmax( item , 1 , 1);
{
config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , false , true );
config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , NULL , false , true );
test_assert_true(config_content_is_instance( content ));
test_assert_true(config_content_is_valid( content ));
test_assert_int_equal( config_content_get_occurences( content , "APPEND" ) , 3);
@@ -47,7 +47,7 @@ int main(int argc , char ** argv) {
}
{
config_content_type * content = config_parse( config , "DoesNotExist" , "--" , NULL , NULL , false , true);
config_content_type * content = config_parse( config , "DoesNotExist" , "--" , NULL , NULL , NULL , false , true);
test_assert_false( config_content_is_valid( content ));
config_content_free( content );
}

View File

@@ -49,14 +49,14 @@ int main(int argc , char ** argv) {
config_schema_item_set_argc_minmax( schema_item , 2 , 2 );
{
config_content_type * content = config_parse( config , argc_OK , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true);
config_content_type * content = config_parse( config , argc_OK , "--" , NULL , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true);
test_assert_true( config_content_is_instance( content ));
test_assert_true(config_content_is_valid( content ));
config_content_free( content );
}
{
config_content_type * content = config_parse( config , argc_less , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true);
config_content_type * content = config_parse( config , argc_less , "--" , NULL , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true);
test_assert_true( config_content_is_instance( content ));
test_assert_false( config_content_is_valid( content ));
@@ -71,7 +71,7 @@ int main(int argc , char ** argv) {
}
{
config_content_type * content = config_parse( config , argc_more , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true);
config_content_type * content = config_parse( config , argc_more , "--" , NULL , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true);
test_assert_true( config_content_is_instance( content ));
test_assert_false( config_content_is_valid( content ));
{

View File

@@ -37,7 +37,7 @@ int main(int argc , char ** argv) {
config_add_schema_item( config , "NOTSET" , false );
{
config_content_type * content = config_parse( config , config_file , "--" , "INCLUDE" , NULL , CONFIG_UNRECOGNIZED_IGNORE , true );
config_content_type * content = config_parse( config , config_file , "--" , "INCLUDE" , NULL , NULL , CONFIG_UNRECOGNIZED_IGNORE , true );
test_assert_true( config_content_is_instance( content ));
test_assert_true(config_content_is_valid( content ));

View File

@@ -28,9 +28,11 @@
#include <ert/config/config_schema_item.h>
#include <ert/config/config_path_elm.h>
void test_define(config_parser_type * config , const char * config_file) {
config_content_type * content = config_parse( config , config_file , NULL , NULL , "DEFINE" , CONFIG_UNRECOGNIZED_IGNORE , true );
hash_type * pre_defined_kw_map = hash_alloc();
hash_insert_string(pre_defined_kw_map, "<CONFIG_FILE>", "TEST_VALUE");
config_content_type * content = config_parse( config , config_file , NULL , NULL , "DEFINE" , pre_defined_kw_map , CONFIG_UNRECOGNIZED_IGNORE , true );
hash_free(pre_defined_kw_map);
test_assert_true( config_content_is_instance( content ));
test_assert_true(config_content_is_valid( content ));
{
@@ -38,13 +40,16 @@ void test_define(config_parser_type * config , const char * config_file) {
test_assert_true( subst_list_has_key( define_list , "VAR1"));
test_assert_true( subst_list_has_key( define_list , "VAR2"));
test_assert_true( subst_list_has_key( define_list , "VARX"));
test_assert_true( subst_list_has_key( define_list , "<CONFIG_FILE>"));
test_assert_false( subst_list_has_key( define_list , "VARY"));
test_assert_string_equal( subst_list_get_value( define_list , "VAR1") , "100");
test_assert_string_equal( subst_list_get_value( define_list , "VAR2") , "10");
test_assert_string_equal( subst_list_get_value( define_list , "VARX") , "1");
test_assert_string_equal( subst_list_get_value( define_list , "<CONFIG_FILE>") , "TEST_VALUE");
}
config_content_free( content );
}

View File

@@ -53,7 +53,7 @@ void parse_test(config_parser_type * config ,
config_rel_path = util_alloc_rel_path( NULL , config_abs_path);
{
config_content_type * content = config_parse( config , config_file , "--" , "INCLUDE" , NULL , CONFIG_UNRECOGNIZED_IGNORE , true );
config_content_type * content = config_parse( config , config_file , "--" , "INCLUDE" , NULL , NULL , CONFIG_UNRECOGNIZED_IGNORE , true );
if (config_content_is_valid( content )) {
char * relpath0 = util_alloc_filename( config_rel_path , path0, NULL);

View File

@@ -32,7 +32,7 @@ int main(int argc , char ** argv) {
}
config_add_schema_item(config , "NEXT" , false );
config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , false , true );
config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , NULL , false , true );
if (config_content_is_valid( content )) {
if (config_content_get_size( content ) == 4) {

View File

@@ -49,7 +49,7 @@ int main(int argc , char ** argv) {
}
{
config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , false , true );
config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , NULL , false , true );
if (config_content_is_valid( content )) {
error("Parse error\n");

View File

@@ -42,7 +42,7 @@ int main(int argc , char ** argv) {
config_schema_item_set_argc_minmax( item , 3 , CONFIG_DEFAULT_ARG_MAX );
}
{
config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , false , true );
config_content_type * content = config_parse(config , config_file , "--" , NULL , NULL , NULL , false , true );
test_assert_true( config_content_is_valid( content ));
config_content_free( content );
}

View File

@@ -2,9 +2,9 @@ if (BUILD_APPLICATIONS)
add_executable( sum_write sum_write.c )
add_executable( make_grid make_grid.c )
add_executable( grdecl_grid grdecl_grid.c )
add_executable( summary2csv summary2csv.c )
add_executable( summary2csv2 summary2csv2.c )
if (ERT_LINUX)
add_executable( ecl_pack.x ecl_pack.c )
add_executable( ecl_unpack.x ecl_unpack.c )
add_executable( esummary.x esummary.c )
add_executable( convert.x convert.c )
add_executable( grdecl_test.x grdecl_test.c )
@@ -16,12 +16,11 @@ if (BUILD_APPLICATIONS)
add_executable( summary.x view_summary.c )
add_executable( select_test.x select_test.c )
add_executable( load_test.x load_test.c )
set(program_list summary2csv2 summary2csv esummary.x kw_extract.x grdecl_grid make_grid sum_write load_test.x grdecl_test.x grid_dump_ascii.x select_test.x grid_dump.x convert.x kw_list.x grid_info.x summary.x)
set(program_list ecl_pack.x ecl_unpack.x esummary.x kw_extract.x grdecl_grid make_grid sum_write load_test.x grdecl_test.x grid_dump_ascii.x select_test.x grid_dump.x convert.x kw_list.x grid_info.x summary.x)
else()
# The stupid .x extension creates problems on windows
add_executable( convert convert.c )
add_executable( grdecl_test grdecl_test.c )
add_executable( kw_list kw_list.c )
add_executable( ecl_pack ecl_pack.c )
add_executable( ecl_unpack ecl_unpack.c )
add_executable( kw_extract kw_extract.c )
add_executable( grid_info grid_info.c )
add_executable( grid_dump grid_dump.c )
@@ -29,7 +28,7 @@ if (BUILD_APPLICATIONS)
add_executable( summary view_summary.c )
add_executable( select_test select_test.c )
add_executable( load_test load_test.c )
set(program_list summary2csv2 summary2csv kw_extract grdecl_grid make_grid sum_write load_test grdecl_test grid_dump_ascii select_test grid_dump convert kw_list grid_info summary)
set(program_list ecl_pack ecl_unpack kw_extract grdecl_grid make_grid sum_write load_test grid_dump_ascii select_test grid_dump grid_info summary)
endif()
if (BUILD_ERT)
@@ -58,26 +57,6 @@ if (BUILD_APPLICATIONS)
endforeach()
endif()
if (BUILD_ENS_PLOT)
include_directories( ${PLPLOT_HEADER} )
add_executable( ens_plot.x ens_plot.c )
target_link_libraries( ens_plot.x plot ecl)
if (USE_RUNPATH)
add_runpath( ens_plot.x )
endif()
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
if (INSTALL_ERT)
install(TARGETS ens_plot.x DESTINATION ${destination})
if (INSTALL_GROUP)
install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/ens_plot.x)")
install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/ens_plot.x)")
endif()
endif()
endif()
if (BUILD_ECL_SUMMARY)
add_executable( ecl_summary view_summary.c )
target_link_libraries( ecl_summary ecl)

View File

@@ -92,7 +92,7 @@ int main(int argc, char ** argv) {
prev_report_step = report_step;
msg_update(msg , stringlist_iget( filelist , i));
{
ecl_file_type * src_file = ecl_file_open( stringlist_iget( filelist , i) );
ecl_file_type * src_file = ecl_file_open( stringlist_iget( filelist , i) , 0 );
if (target_type == ECL_UNIFIED_RESTART_FILE) {
/* Must insert the SEQNUM keyword first. */
ecl_kw_iset_int(seqnum_kw , 0 , report_step);

View File

@@ -830,7 +830,7 @@ int main( int argc , char ** argv ) {
const char * config_arg = argv[1];
config_init( config );
content = config_parse( config , config_arg , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN, true );
content = config_parse( config , config_arg , "--" , NULL , NULL , NULL , CONFIG_UNRECOGNIZED_WARN, true );
if (config_content_is_valid( content )) {
char * config_path;

View File

@@ -17,13 +17,15 @@
*/
#include <stdbool.h>
#include <util.h>
#include <ecl_file.h>
#include <ecl_util.h>
#include <ecl_kw.h>
#include <msg.h>
#include <ecl_endian_flip.h>
#include <ecl_kw_magic.h>
#include <ert/util/util.h>
#include <ert/util/msg.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_util.h>
#include <ert/ecl/ecl_kw.h>
#include <ert/ecl/ecl_endian_flip.h>
#include <ert/ecl/ecl_kw_magic.h>
void unpack_file(const char * filename) {
ecl_file_enum target_type = ECL_OTHER_FILE;
@@ -41,7 +43,7 @@ void unpack_file(const char * filename) {
printf("** Warning: when unpacking unified summary files it as ambigous - starting with 0001 -> \n");
}
{
ecl_file_type * src_file = ecl_file_open( filename );
ecl_file_type * src_file = ecl_file_open( filename , 0 );
int size;
int offset;
int report_step = 0;

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,19 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'grid_info.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
Copyright (C) 2011 Statoil ASA, Norway.
The file 'grid_info.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#include <stdlib.h>
@@ -35,13 +35,13 @@ int main(int argc, char ** argv) {
{
ecl_grid_type * ecl_grid;
const char * grid_file = argv[1];
ecl_grid = ecl_grid_alloc(grid_file );
ecl_grid_summarize( ecl_grid );
if (argc >= 3) {
ecl_grid_type * grid2 = ecl_grid_alloc( argv[2] );
if (ecl_grid_compare( ecl_grid , grid2 , true , false , false))
printf("\nThe grids %s %s are IDENTICAL.\n" , argv[1] , argv[2]);
else {
@@ -54,13 +54,12 @@ int main(int argc, char ** argv) {
/*
printf("----\n");
{
double * ri_points = util_calloc( ecl_grid_get_global_size( ecl_grid ) * 24 , sizeof * ri_points );
double * ri_points = util_calloc( ecl_grid_get_global_size( ecl_grid ) * 24 , sizeof * ri_points );
ecl_grid_ri_export( ecl_grid , ri_points );
free( ri_points );
}
printf("----\n");
*/
ecl_grid_fwrite_EGRID( ecl_grid , "/tmp/INFO.EGRID", true);
ecl_grid_free(ecl_grid);
}
}

View File

@@ -1,112 +0,0 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'summary2csv.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <stdbool.h>
#include <ert/util/util.h>
#include <ert/util/stringlist.h>
#include <ert/ecl/ecl_sum.h>
static bool extend_key_list( const ecl_sum_type * ecl_sum , const stringlist_type * var_list , const char * well , stringlist_type * key_list ) {
bool oil_producer = false;
int last_step = ecl_sum_get_data_length( ecl_sum ) - 1;
char * wopt_key = ecl_sum_alloc_well_key( ecl_sum , "WOPT", well);
if (ecl_sum_has_key( ecl_sum , wopt_key) && (ecl_sum_get_well_var( ecl_sum , last_step , well , "WOPT") > 0 )) {
/*
We add all the keys unconditionally here; and then let the
ecl_sum_fprintf() function print a message on stderr if it is
missing.
*/
int ivar;
for (ivar = 0; ivar < stringlist_get_size( var_list ); ivar++) {
const char * var = stringlist_iget( var_list , ivar );
stringlist_append_owned_ref( key_list , ecl_sum_alloc_well_key( ecl_sum , var, well) );
}
oil_producer = true;
}
free( wopt_key );
return oil_producer;
}
int main(int argc , char ** argv) {
{
ecl_sum_fmt_type fmt;
bool well_rows = false;
bool include_restart = true;
int arg_offset = 1;
if (argc != 2) {
printf("You must supply the name of a case as:\n\n summary2csv.exe ECLIPSE_CASE\n\nThe case can optionally contain a leading path component.\n");
exit(1);
}
{
char * data_file = argv[arg_offset];
ecl_sum_type * ecl_sum;
stringlist_type * var_list = stringlist_alloc_new();
stringlist_append_ref( var_list , "WOPR" );
stringlist_append_ref( var_list , "WOPT" );
stringlist_append_ref( var_list , "WGPR" );
stringlist_append_ref( var_list , "WGPT" );
stringlist_append_ref( var_list , "WWPR" );
stringlist_append_ref( var_list , "WWPT" );
ecl_sum_fmt_init_csv( &fmt );
ecl_sum = ecl_sum_fread_alloc_case__( data_file , ":" , include_restart);
if (ecl_sum != NULL) {
char * csv_file = util_alloc_filename( NULL , ecl_sum_get_base(ecl_sum) , "txt"); // Will save to current path; can use ecl_sum_get_path() to save to target path instead.
FILE * stream = util_fopen( csv_file , "w");
stringlist_type * well_list = ecl_sum_alloc_well_list( ecl_sum , NULL );
stringlist_type * key_list = stringlist_alloc_new( );
int iw;
for (iw = 0; iw < stringlist_get_size( well_list ); iw++) {
const char * well = stringlist_iget( well_list , iw );
if (!extend_key_list( ecl_sum , var_list , well , key_list))
fprintf(stderr , "Ignoring well: %s \n",well);
if (well_rows) {
if (stringlist_get_size(key_list)) {
ecl_sum_fprintf(ecl_sum , stream , key_list , false , &fmt);
stringlist_clear( key_list );
}
}
}
if (!well_rows)
ecl_sum_fprintf(ecl_sum , stream , key_list , false , &fmt);
stringlist_free( well_list );
stringlist_free( key_list );
ecl_sum_free(ecl_sum);
fclose( stream );
free( csv_file );
} else
fprintf(stderr,"summary2csv: No summary data found for case:%s\n", data_file );
stringlist_free( var_list );
}
}
}

View File

@@ -19,7 +19,9 @@
#include <string.h>
#include <signal.h>
#ifdef HAVE_GETOPT
#include <ert/util/ert_api_config.h>
#ifdef ERT_HAVE_GETOPT
#include <getopt.h>
#endif
@@ -60,7 +62,7 @@ void print_help_and_exit() {
printf(" LBPR:LGR3:10,10,10 - The block pressure in cell 10,10,10 - in LGR3\n");
printf("\n");
#ifdef HAVE_GETOPT
#ifdef ERT_HAVE_GETOPT
printf("The option --list can be used to list all available keys.\n");
printf("\n");
printf("Options:\n");
@@ -126,13 +128,9 @@ static void build_key_list( const ecl_sum_type * ecl_sum , stringlist_type * key
missing keys.
*/
if (util_string_has_wildcard( argv[iarg] )) {
stringlist_type * tmp_keys = stringlist_alloc_new( );
ecl_sum_select_matching_general_var_list( ecl_sum , argv[iarg] , tmp_keys);
stringlist_sort( tmp_keys , (string_cmp_ftype *) util_strcmp_int );
stringlist_append_stringlist_copy( key_list , tmp_keys );
stringlist_free( tmp_keys );
} else
if (util_string_has_wildcard( argv[iarg] ))
ecl_sum_select_matching_general_var_list( ecl_sum , argv[iarg] , key_list);
else
stringlist_append_copy( key_list , argv[iarg] );
}
}
@@ -147,7 +145,7 @@ int main(int argc , char ** argv) {
bool print_header = true;
int arg_offset = 1;
#ifdef HAVE_GETOPT
#ifdef ERT_HAVE_GETOPT
if (argc == 1)
print_help_and_exit();
else {

View File

@@ -144,6 +144,10 @@ extern "C" {
bool ecl_grid_cell_invalid3(const ecl_grid_type * ecl_grid , int i , int j , int k);
double ecl_grid_cell_invalid1A(const ecl_grid_type * grid , int active_index);
bool ecl_grid_cell_valid1(const ecl_grid_type * ecl_grid , int global_index);
bool ecl_grid_cell_valid3(const ecl_grid_type * ecl_grid , int i , int j , int k);
double ecl_grid_cell_valid1A(const ecl_grid_type * grid , int active_index);
void ecl_grid_dump(const ecl_grid_type * grid , FILE * stream);
void ecl_grid_dump_ascii(ecl_grid_type * grid , bool active_only , FILE * stream);
void ecl_grid_dump_ascii_cell1(ecl_grid_type * grid , int global_index , FILE * stream, const double * offset);

View File

@@ -99,7 +99,7 @@ extern "C" {
bool ecl_kw_header_eq(const ecl_kw_type *ecl_kw1 , const ecl_kw_type * ecl_kw2);
bool ecl_kw_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2);
bool ecl_kw_icmp_string( const ecl_kw_type * ecl_kw , int index, const char * other_string);
bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2 , double rel_diff);
bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2 , double abs_diff , double rel_diff);
bool ecl_kw_block_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2 , int cmp_elements);
bool ecl_kw_data_equal( const ecl_kw_type * ecl_kw , const void * data);
bool ecl_kw_content_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2);
@@ -145,6 +145,7 @@ extern "C" {
void ecl_kw_inplace_sub( ecl_kw_type * target_kw , const ecl_kw_type * sub_kw);
void ecl_kw_inplace_div( ecl_kw_type * target_kw , const ecl_kw_type * div_kw);
void ecl_kw_inplace_mul( ecl_kw_type * target_kw , const ecl_kw_type * mul_kw);
void ecl_kw_inplace_abs( ecl_kw_type * kw );
void ecl_kw_inplace_add_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * add_kw);
void ecl_kw_inplace_sub_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * sub_kw);

View File

@@ -34,7 +34,6 @@ typedef struct ecl_rft_file_struct ecl_rft_file_type;
char * ecl_rft_file_alloc_case_filename(const char * case_input );
const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file );
ecl_rft_file_type * ecl_rft_file_alloc_case(const char * case_input );
bool ecl_rft_file_case_has_rft(const char * case_input );
bool ecl_rft_file_case_has_rft( const char * case_input );
ecl_rft_file_type * ecl_rft_file_alloc(const char * );
void ecl_rft_file_free(ecl_rft_file_type * );

View File

@@ -30,6 +30,9 @@ extern "C" {
typedef struct {
// The report step is from the SEQNUM keyword for unified files,
// and inferred from the filename for non unified files.
int report_step;
int day;
int year;
int month;
@@ -77,6 +80,7 @@ extern "C" {
void ecl_rsthead_free( ecl_rsthead_type * rsthead );
ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_type * intehead_kw , const ecl_kw_type * doubhead_kw , const ecl_kw_type * logihead_kw );
ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occurence);
ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_type * rst_file );
ecl_rsthead_type * ecl_rsthead_alloc_empty();
@@ -85,6 +89,8 @@ extern "C" {
void ecl_rsthead_fprintf_struct( const ecl_rsthead_type * header , FILE * stream);
bool ecl_rsthead_equal( const ecl_rsthead_type * header1 , const ecl_rsthead_type * header2);
double ecl_rsthead_get_sim_days( const ecl_rsthead_type * header );
int ecl_rsthead_get_report_step( const ecl_rsthead_type * header );
time_t ecl_rsthead_get_sim_time( const ecl_rsthead_type * header );
#ifdef __cplusplus
}

View File

@@ -52,7 +52,6 @@ extern "C" {
char * value_dash;
} ecl_sum_fmt_type;
void ecl_sum_fmt_init_csv( ecl_sum_fmt_type * fmt );
/*****************************************************************/
@@ -205,6 +204,7 @@ typedef struct ecl_sum_struct ecl_sum_type;
char * ecl_sum_alloc_well_key( const ecl_sum_type * ecl_sum , const char * keyword , const char * wgname);
bool ecl_sum_report_step_equal( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2);
bool ecl_sum_report_step_compatible( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2);
void ecl_sum_export_csv(const ecl_sum_type * ecl_sum , const char * filename , const stringlist_type * var_list , const char * date_format , const char * sep);
UTIL_IS_INSTANCE_HEADER( ecl_sum );

View File

@@ -86,7 +86,7 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ;
ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int report_step , double sim_seconds);
bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2);
bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2);
void ecl_sum_data_write_csv_file(const ecl_sum_data_type * data , time_t sim_time, const ecl_sum_vector_type * keylist, FILE *fp);
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);
#ifdef __cplusplus
}

View File

@@ -22,6 +22,9 @@
#ifdef __cplusplus
extern "C" {
#endif
#include <ert/util/type_macros.h>
#include <ert/ecl/ecl_sum.h>
typedef struct ecl_sum_vector_struct ecl_sum_vector_type;
@@ -36,6 +39,9 @@ typedef struct ecl_sum_vector_struct ecl_sum_vector_type;
int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type * ecl_sum_vector, int index);
int ecl_sum_vector_get_size(const ecl_sum_vector_type * ecl_sum_vector);
UTIL_IS_INSTANCE_HEADER( ecl_sum_vector);
#ifdef __cplusplus
}
#endif

View File

@@ -175,7 +175,6 @@ ert_ecl_unit_enum ecl_util_get_unit_set(const char * data_file);
bool ecl_util_valid_basename_fmt( const char * basename_fmt );
bool ecl_util_valid_basename( const char * basename );
const char * ecl_util_get_phase_name( ecl_phase_enum phase );
const char * ecl_util_file_enum_iget( int index, int * value);
int ecl_util_select_filelist( const char * path , const char * base , ecl_file_enum file_type , bool fmt_file , stringlist_type * filelist);
void ecl_util_append_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date , bool force_append_end);

View File

@@ -22,9 +22,6 @@
#include <stdbool.h>
#include <ert/ecl/ecl_smspec.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -34,6 +31,13 @@ extern "C" {
#define SMSPEC_PARAMS_INDEX_INVALID -77
#define SMSPEC_TIME_KEYWORD "TIME"
#define SMSPEC_TIME_NUMS_VALUE -32676
#define SMSPEC_YEARS_KEYWORD "YEARS"
#define SMSPEC_YEARS_NUMS_VALUE -32676
typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
ECL_SMSPEC_AQUIFER_VAR = 1 ,
ECL_SMSPEC_WELL_VAR = 2 , /* X */
@@ -99,6 +103,7 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
float default_value);
smspec_node_type * smspec_node_alloc_new(int params_index, float default_value);
smspec_node_type * smspec_node_alloc_copy( const smspec_node_type* );
void smspec_node_free( smspec_node_type * index );
void smspec_node_free__(void * arg);

View File

@@ -91,7 +91,7 @@ if (ERT_USE_OPENMP)
endif()
add_library( ecl ${LIBRARY_TYPE} ${source_files} )
set_target_properties( ecl PROPERTIES VERSION 1.0 SOVERSION 1.0 )
set_target_properties( ecl PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR})
if (USE_RUNPATH)
add_runpath( ecl )
endif()

View File

@@ -1129,14 +1129,4 @@ bool ecl_file_save_kw( const ecl_file_type * ecl_file , const ecl_kw_type * ecl_
}
}
/* Small function to support Python based enum introspection. */
#ifdef HAVE_FORK
const char * ecl_util_file_flags_enum_iget( int index , int * value) {
return util_enum_iget( index , ECL_FILE_FLAGS_ENUM_SIZE , (const util_enum_element_type []) { ECL_FILE_FLAGS_ENUM_DEFS }, value);
}
#endif

View File

@@ -2287,6 +2287,10 @@ static void ecl_grid_init_nnc(ecl_grid_type * main_grid, ecl_file_type * ecl_fil
int num_nnchead_kw = ecl_file_get_num_named_kw( ecl_file , NNCHEAD_KW );
int i;
if(num_nnchead_kw > 0 && main_grid->eclipse_version == 2015){
return; //Eclipse 2015 has an error with nnc.
}
for (i = 0; i < num_nnchead_kw; i++) {
ecl_file_push_block(ecl_file); /* <---------------------------------------------------------------- */
ecl_file_select_block(ecl_file , NNCHEAD_KW , i);
@@ -4319,9 +4323,19 @@ double ecl_grid_get_cell_thickness3( const ecl_grid_type * grid , int i , int j
double ecl_grid_get_cell_dx1( const ecl_grid_type * grid , int global_index ) {
fprintf(stderr , "** WARNING: The ecl_grid_get_cell_dx1() function is only a stub returning -1.\n");
fprintf(stderr , " If you need a correct value for cell dx you must rebuild a new ert version.\n");
return -1;
const ecl_cell_type * cell = ecl_grid_get_cell( grid , global_index);
double dx = 0;
double dy = 0;
int c;
for (c = 1; c < 8; c += 2) {
dx += cell->corner_list[c].x - cell->corner_list[c - 1].x;
dy += cell->corner_list[c].y - cell->corner_list[c - 1].y;
}
dx *= 0.25;
dy *= 0.25;
return sqrt( dx * dx + dy * dy );
}
@@ -4332,15 +4346,17 @@ double ecl_grid_get_cell_dx3( const ecl_grid_type * grid , int i , int j , int k
double ecl_grid_get_cell_dy1( const ecl_grid_type * grid , int global_index ) {
fprintf(stderr , "** WARNING: The ecl_grid_get_cell_dy1() function is only a stub returning -1.\n");
fprintf(stderr , " If you need a correct value for cell dy you must update rebuild a new ert version.\n");
return -1;
double V = ecl_grid_get_cell_volume1(grid , global_index);
double dz = ecl_grid_get_cell_thickness1( grid , global_index);
double dx = ecl_grid_get_cell_dx1( grid , global_index);
return V / (dx * dz);
}
double ecl_grid_get_cell_dy3( const ecl_grid_type * grid , int i , int j , int k) {
const int global_index = ecl_grid_get_global_index3(grid , i,j,k);
return ecl_grid_get_cell_dy1( grid , global_index );
return ecl_grid_get_cell_dx1( grid , global_index );
}
@@ -4395,6 +4411,25 @@ double ecl_grid_cell_invalid1A(const ecl_grid_type * grid , int active_index) {
}
bool ecl_grid_cell_valid1(const ecl_grid_type * ecl_grid , int global_index) {
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index);
if (GET_CELL_FLAG(cell , CELL_FLAG_TAINTED))
return false;
else
return (GET_CELL_FLAG(cell , CELL_FLAG_VALID));
}
bool ecl_grid_cell_valid3(const ecl_grid_type * ecl_grid , int i , int j , int k) {
int global_index = ecl_grid_get_global_index3( ecl_grid , i , j , k);
return ecl_grid_cell_valid1( ecl_grid , global_index );
}
double ecl_grid_cell_valid1A(const ecl_grid_type * grid , int active_index) {
const int global_index = ecl_grid_get_global_index1A(grid , active_index);
return ecl_grid_cell_valid1( grid , global_index );
}
/*****************************************************************/
/* Functions for LGR query/lookup/... */
@@ -4633,6 +4668,13 @@ double ecl_grid_get_cell_volume1( const ecl_grid_type * ecl_grid, int global_ind
}
double ecl_grid_get_cell_volume1A( const ecl_grid_type * ecl_grid, int active_index ) {
int global_index = ecl_grid_get_global_index1A( ecl_grid , active_index );
return ecl_grid_get_cell_volume1( ecl_grid , global_index );
}
double ecl_grid_get_cell_volume1_tskille( const ecl_grid_type * ecl_grid, int global_index ) {
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index );
return ecl_cell_get_volume_tskille( cell );
@@ -5978,3 +6020,38 @@ int ecl_grid_get_num_nnc( const ecl_grid_type * grid ) {
}
static ecl_kw_type * ecl_grid_alloc_volume_kw_active( const ecl_grid_type * grid) {
ecl_kw_type * volume_kw = ecl_kw_alloc("VOLUME" , ecl_grid_get_active_size(grid) , ECL_DOUBLE_TYPE);
{
double * volume_data = ecl_kw_get_ptr( volume_kw );
int active_index;
for (active_index = 0; active_index < ecl_grid_get_active_size(grid); active_index++) {
double cell_volume = ecl_grid_get_cell_volume1A(grid , active_index);
volume_data[ active_index] = cell_volume;
}
}
return volume_kw;
}
static ecl_kw_type * ecl_grid_alloc_volume_kw_global( const ecl_grid_type * grid) {
ecl_kw_type * volume_kw = ecl_kw_alloc("VOLUME" , ecl_grid_get_global_size(grid) , ECL_DOUBLE_TYPE);
{
double * volume_data = ecl_kw_get_ptr( volume_kw );
int global_index;
for (global_index = 0; global_index < ecl_grid_get_global_size(grid); global_index++) {
double cell_volume = ecl_grid_get_cell_volume1(grid , global_index);
volume_data[ global_index] = cell_volume;
}
}
return volume_kw;
}
ecl_kw_type * ecl_grid_alloc_volume_kw( const ecl_grid_type * grid , bool active_size) {
if (active_size)
return ecl_grid_alloc_volume_kw_active( grid );
else
return ecl_grid_alloc_volume_kw_global( grid );
}

View File

@@ -404,17 +404,22 @@ bool ecl_kw_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2) {
}
#define CMP(ctype,ABS) \
static bool CMP_ ## ctype( ctype v1, ctype v2 , ctype epsilon) { \
#define CMP(ctype,ABS) \
static bool CMP_ ## ctype( ctype v1, ctype v2 , ctype abs_epsilon , ctype rel_epsilon) { \
if ((ABS(v1) + ABS(v2)) == 0) \
return true; \
else { \
ctype d = ABS(v1 - v2) / (ABS(v1) + ABS(v2)); \
if (d < epsilon) \
return true; \
else \
return false; \
ctype diff = ABS(v1 - v2); \
if (diff < abs_epsilon) \
return true; \
else { \
ctype sum = ABS(v1) + ABS(v2); \
ctype d = diff / sum; \
if (d < rel_epsilon) \
return true; \
} \
} \
return false; \
}
CMP(float,fabsf)
CMP(double,fabs)
@@ -422,14 +427,14 @@ CMP(double,fabs)
#define ECL_KW_NUMERIC_CMP(ctype) \
static bool ecl_kw_numeric_equal_ ## ctype( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2 , ctype rel_diff) { \
static bool ecl_kw_numeric_equal_ ## ctype( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2 , ctype abs_diff , ctype rel_diff) { \
int index; \
bool equal = true; \
{ \
const ctype * data1 = (const ctype *) ecl_kw1->data; \
const ctype * data2 = (const ctype *) ecl_kw2->data; \
for (index = 0; index < ecl_kw1->size; index++) { \
equal = CMP_ ## ctype( data1[index] , data2[index] , rel_diff); \
equal = CMP_ ## ctype( data1[index] , data2[index] , abs_diff , rel_diff); \
if (!equal) \
break; \
} \
@@ -448,7 +453,7 @@ ECL_KW_NUMERIC_CMP( double )
@rel_diff. Does not consider consider the kw header.
*/
bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2 , double rel_diff) {
bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2 , double abs_diff , double rel_diff) {
bool equal = true;
if ( ecl_kw1->ecl_type != ecl_kw2->ecl_type)
equal = false;
@@ -458,9 +463,9 @@ bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2
if (equal) {
if (ecl_kw1->ecl_type == ECL_FLOAT_TYPE)
equal = ecl_kw_numeric_equal_float( ecl_kw1 , ecl_kw2 , rel_diff );
equal = ecl_kw_numeric_equal_float( ecl_kw1 , ecl_kw2 , abs_diff , rel_diff );
else if (ecl_kw1->ecl_type == ECL_DOUBLE_TYPE)
equal = ecl_kw_numeric_equal_double( ecl_kw1 , ecl_kw2 , rel_diff );
equal = ecl_kw_numeric_equal_double( ecl_kw1 , ecl_kw2 , abs_diff , rel_diff );
else
equal = ecl_kw_data_equal( ecl_kw1 , ecl_kw2->data );
}
@@ -1127,6 +1132,9 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) {
index++;
}
}
/* Skip the trailing newline */
fortio_fseek( fortio , 1 , SEEK_CUR);
return true;
} else {
bool read_ok = true;
@@ -2226,6 +2234,41 @@ void ecl_kw_inplace_sub_indexed( ecl_kw_type * target_kw , const int_vector_type
}
/*****************************************************************/
#define ECL_KW_TYPED_INPLACE_ABS( ctype , abs_func) \
void ecl_kw_inplace_abs_ ## ctype( ecl_kw_type * kw ) { \
ctype * data = ecl_kw_get_data_ref( kw ); \
int i; \
for (i=0; i < kw->size; i++) \
data[i] = abs_func(data[i]); \
}
ECL_KW_TYPED_INPLACE_ABS( int , abs )
ECL_KW_TYPED_INPLACE_ABS( double , fabs )
ECL_KW_TYPED_INPLACE_ABS( float , fabsf )
#undef ECL_KW_TYPED_INPLACE_ABS
void ecl_kw_inplace_abs( ecl_kw_type * kw ) {
ecl_type_enum type = ecl_kw_get_type(kw);
switch (type) {
case(ECL_FLOAT_TYPE):
ecl_kw_inplace_abs_float( kw );
break;
case(ECL_DOUBLE_TYPE):
ecl_kw_inplace_abs_double( kw );
break;
case(ECL_INT_TYPE):
ecl_kw_inplace_abs_int( kw );
break;
default:
util_abort("%s: inplace abs not implemented for type:%s \n",__func__ , ecl_util_get_type_name( type ));
}
}
/*****************************************************************/
#define ECL_KW_TYPED_INPLACE_MUL( ctype ) \

View File

@@ -37,6 +37,7 @@
#define PLT_DATA_TYPE_ID 87166667
struct ecl_rft_cell_struct {
UTIL_TYPE_ID_DECLARATION;
int i,j,k;

View File

@@ -69,6 +69,20 @@ struct ecl_rft_node_struct {
/*
The implementation of cell types based on _either_ RFT data or PLT
data is based on a misunderstanding and is currently WRONG. One
section in an RFT file can contain RFT data, PLT data and SEGMENT
data. The @data_type string should therefor not be interpreted as a
type string, but rather as a "bit mask":
"R" => Section contains only RFT data.
"P" => Section contains only PLT data.
"RP" => Section contains *BOTH* RFT data and PLT data.
*/
/**
Will return NULL if the data_type_string is equal to "SEGMENT" -
that is not (yet) supported.
@@ -137,6 +151,18 @@ void ecl_rft_node_append_cell( ecl_rft_node_type * rft_node , ecl_rft_cell_type
}
static ecl_kw_type * ecl_rft_node_get_pressure_kw( ecl_rft_node_type * rft_node , const ecl_file_type * rft ) {
if (rft_node->data_type == RFT)
return ecl_file_iget_named_kw( rft , PRESSURE_KW , 0);
else {
ecl_kw_type * conpres_kw = ecl_file_iget_named_kw( rft , CONPRES_KW , 0);
if (ecl_kw_element_sum_float( conpres_kw ) > 0.0 )
return conpres_kw;
else
return ecl_file_iget_named_kw( rft , PRESSURE_KW , 0);
}
}
static void ecl_rft_node_init_RFT_cells( ecl_rft_node_type * rft_node , const ecl_file_type * rft) {
const ecl_kw_type * conipos = ecl_file_iget_named_kw( rft , CONIPOS_KW , 0);
@@ -145,7 +171,7 @@ static void ecl_rft_node_init_RFT_cells( ecl_rft_node_type * rft_node , const ec
const ecl_kw_type * depth_kw = ecl_file_iget_named_kw( rft , DEPTH_KW , 0);
const ecl_kw_type * swat_kw = ecl_file_iget_named_kw( rft , SWAT_KW , 0);
const ecl_kw_type * sgas_kw = ecl_file_iget_named_kw( rft , SGAS_KW , 0);
const ecl_kw_type * pressure_kw = ecl_file_iget_named_kw( rft , PRESSURE_KW , 0);
const ecl_kw_type * pressure_kw = ecl_rft_node_get_pressure_kw( rft_node , rft );
const float * SW = ecl_kw_get_float_ptr( swat_kw );
const float * SG = ecl_kw_get_float_ptr( sgas_kw );
@@ -183,7 +209,7 @@ static void ecl_rft_node_init_PLT_cells( ecl_rft_node_type * rft_node , const ec
const float * WR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONWRAT_KW , 0));
const float * GR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONGRAT_KW , 0));
const float * OR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONORAT_KW , 0));
const float * P = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONPRES_KW , 0));
const float * P = ecl_kw_get_float_ptr( ecl_rft_node_get_pressure_kw( rft_node , rft ));
const float * depth = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONDEPTH_KW , 0));
const float * flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONVTUB_KW , 0));
const float * oil_flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONOTUB_KW , 0));

View File

@@ -37,19 +37,26 @@ time_t ecl_rsthead_date( const ecl_kw_type * intehead_kw ) {
}
time_t ecl_rsthead_get_sim_time( const ecl_rsthead_type * header ) {
return header->sim_time;
}
double ecl_rsthead_get_sim_days( const ecl_rsthead_type * header ) {
return header->sim_days;
}
int ecl_rsthead_get_report_step( const ecl_rsthead_type * header ) {
return header->report_step;
}
ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occurence) {
if (ecl_file_get_num_named_kw( rst_file , INTEHEAD_KW) > occurence) {
const ecl_kw_type * intehead_kw = ecl_file_iget_named_kw( rst_file , INTEHEAD_KW , occurence);
ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead );
{
ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_type * intehead_kw , const ecl_kw_type * doubhead_kw , const ecl_kw_type * logihead_kw ) {
ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead );
rsthead->report_step = report_step;
{
const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw );
rsthead->day = data[INTEHEAD_DAY_INDEX];
@@ -78,31 +85,43 @@ ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occu
// The only derived quantity
rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year );
}
}
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);
if (ecl_file_get_num_named_kw(rst_file, DOUBHEAD_KW) > occurence) {
const ecl_kw_type * doubhead_kw = ecl_file_iget_named_kw( rst_file , DOUBHEAD_KW , occurence);
rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX );
}
return rsthead;
}
if (ecl_file_get_num_named_kw(rst_file, LOGIHEAD_KW) > occurence) {
const ecl_kw_type * logihead_kw = ecl_file_iget_named_kw( rst_file , LOGIHEAD_KW , occurence);
rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX);
ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occurence) {
if (ecl_file_get_num_named_kw( rst_file , INTEHEAD_KW) > occurence) {
const ecl_kw_type * intehead_kw = ecl_file_iget_named_kw( rst_file , INTEHEAD_KW , occurence);
const ecl_kw_type * doubhead_kw = ecl_file_iget_named_kw( rst_file , DOUBHEAD_KW , occurence);
const ecl_kw_type * logihead_kw = NULL;
int report_step;
if (ecl_file_get_num_named_kw(rst_file, LOGIHEAD_KW) > occurence)
logihead_kw = ecl_file_iget_named_kw( rst_file , LOGIHEAD_KW , occurence);
if (ecl_file_get_num_named_kw( rst_file , SEQNUM_KW) > occurence) {
const ecl_kw_type * seqnum_kw = ecl_file_iget_named_kw( rst_file , SEQNUM_KW , occurence );
report_step = ecl_kw_iget_int( seqnum_kw , 0);
} else
rsthead->dualp = false;
ecl_util_get_file_type( ecl_file_get_src_file(rst_file) , NULL , &report_step);
return rsthead;
return ecl_rsthead_alloc_from_kw( report_step , intehead_kw , doubhead_kw , logihead_kw );
} else
return NULL;
}
ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_type * rst_file) {
return ecl_rsthead_ialloc( rst_file , 0 );
}
ecl_rsthead_type * ecl_rsthead_alloc_empty() {
ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead );

View File

@@ -1711,6 +1711,17 @@ void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec
hash_iter_type * iter = hash_iter_alloc( smspec->gen_var_index );
while (!hash_iter_is_complete( iter )) {
const char * key = hash_iter_get_next_key( iter );
/*
The TIME is typically special cased by output and will not
match the 'all keys' wildcard.
*/
if (util_string_equal( key , "TIME")) {
if ((pattern == NULL) || (util_string_equal( pattern , "*")))
continue;
}
if ((pattern == NULL) || (util_fnmatch( pattern , key ) == 0)) {
if (!hash_has_key( ex_keys , key))
stringlist_append_copy( keys , key );
@@ -1720,6 +1731,7 @@ void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec
}
hash_free( ex_keys );
stringlist_sort( keys , (string_cmp_ftype *) util_strcmp_int );
}

View File

@@ -649,8 +649,8 @@ double ecl_sum_get_general_var(const ecl_sum_type * ecl_sum , int time_index , c
}
void ecl_sum_dump_line_to_csv_file(const ecl_sum_type * ecl_sum, time_t sim_time, const ecl_sum_vector_type * key_words, FILE *fp){
ecl_sum_data_write_csv_file(ecl_sum->data, sim_time, key_words, fp);
void ecl_sum_fwrite_interp_csv_line(const ecl_sum_type * ecl_sum, time_t sim_time, const ecl_sum_vector_type * key_words, FILE *fp){
ecl_sum_data_fwrite_interp_csv_line(ecl_sum->data, sim_time, key_words, fp);
}
@@ -868,20 +868,6 @@ double ecl_sum_iget_sim_days( const ecl_sum_type * ecl_sum , int index ) {
/*****************************************************************/
/* This is essentially the summary.x program. */
void ecl_sum_fmt_init_csv( ecl_sum_fmt_type * fmt ) {
fmt->locale = "Norwegian";
fmt->sep = "\t";
fmt->date_fmt = "%d/%m/%y";
fmt->value_fmt = "%g";
fmt->days_fmt = "%7.2f";
fmt->header_fmt = "%s";
fmt->newline = "\r\n";
fmt->date_header = "DAYS\tDATE";
fmt->print_header = true;
fmt->print_dash = false;
}
void ecl_sum_fmt_init_summary_x( const ecl_sum_type * ecl_sum , ecl_sum_fmt_type * fmt ) {
@@ -1021,6 +1007,36 @@ void ecl_sum_fprintf(const ecl_sum_type * ecl_sum , FILE * stream , const string
#undef DATE_STRING_LENGTH
static void ecl_sum_fmt_init_csv( ecl_sum_fmt_type * fmt , const char * date_format , const char * date_header , const char * sep) {
fmt->locale = NULL; //"Norwegian";
fmt->sep = sep;
fmt->date_fmt = date_format;
fmt->value_fmt = "%g";
fmt->days_fmt = "%7.2f";
fmt->header_fmt = "%s";
fmt->newline = "\r\n";
fmt->date_header = date_header;
fmt->print_header = true;
fmt->print_dash = false;
}
void ecl_sum_export_csv(const ecl_sum_type * ecl_sum , const char * filename , const stringlist_type * var_list , const char * date_format , const char * sep) {
FILE * stream = util_mkdir_fopen(filename , "w");
char * date_header = util_alloc_sprintf("DAYS%sDATE" , sep);
bool report_only = false;
ecl_sum_fmt_type fmt;
ecl_sum_fmt_init_csv( &fmt , date_format , date_header , sep );
ecl_sum_fprintf( ecl_sum , stream , var_list , report_only , &fmt );
fclose( stream );
free( date_header );
}
const char * ecl_sum_get_case(const ecl_sum_type * ecl_sum) {
return ecl_sum->ecl_case;
}

View File

@@ -1131,7 +1131,7 @@ double ecl_sum_data_interp_get(const ecl_sum_data_type * data , int time_index1
}
void ecl_sum_data_write_csv_file(const ecl_sum_data_type * data , time_t sim_time, const ecl_sum_vector_type * keylist, FILE *fp){
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;

View File

@@ -27,21 +27,28 @@
#include <ert/util/bool_vector.h>
#define ECL_SUM_VECTOR_TYPE_ID 8756667078
#define ECL_SUM_VECTOR_TYPE_ID 8768778
struct ecl_sum_vector_struct {
UTIL_TYPE_ID_DECLARATION;
int_vector_type * node_index_list;
bool_vector_type * is_rate_list;
const ecl_sum_type * ecl_sum;
};
void ecl_sum_vector_free( ecl_sum_vector_type * ecl_sum_vector ){
int_vector_free(ecl_sum_vector->node_index_list);
bool_vector_free(ecl_sum_vector->is_rate_list);
}
UTIL_IS_INSTANCE_FUNCTION( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID )
ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum){
ecl_sum_vector_type * ecl_sum_vector = util_malloc( sizeof * ecl_sum_vector );
UTIL_TYPE_ID_INIT( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID);
ecl_sum_vector->ecl_sum = ecl_sum;
ecl_sum_vector->node_index_list = int_vector_alloc(0,0);
ecl_sum_vector->is_rate_list = bool_vector_alloc(0,false);

File diff suppressed because it is too large Load Diff

View File

@@ -64,7 +64,6 @@ struct smspec_node_struct {
int * lgr_ijk; /* The (i,j,k) coordinate, in the local grid, if this is a LGR variable. WIll be NULL for no-lgr variables. */
bool rate_variable; /* Is this a rate variable (i.e. WOPR) or a state variable (i.e. BPR). Relevant when doing time interpolation. */
bool total_variable; /* Is this a total variable like WOPT? */
bool need_nums; /* Do we use the NUMS vector - relevant for storing. */
bool historical; /* Does the name end with 'H'? */
int params_index; /* The index of this variable (applies to all the vectors - in particular the PARAMS vectors of the summary files *.Snnnn / *.UNSMRY ). */
float default_value; /* Default value for this variable. */
@@ -253,7 +252,6 @@ static void smspec_node_set_keyword( smspec_node_type * smspec_node , const char
static void smspec_node_set_invalid_flags( smspec_node_type * smspec_node) {
smspec_node->rate_variable = false;
smspec_node->total_variable = false;
smspec_node->need_nums = false;
smspec_node->historical = false;
}
@@ -320,23 +318,6 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) {
}
smspec_node->total_variable = is_total;
}
/*
Check if this node needs the nums field; if at least one of the
nodes need the NUMS field must be stored when writing a SMSPEC
file.
*/
{
if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR ||
smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR ||
smspec_node->var_type == ECL_SMSPEC_REGION_VAR ||
smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR ||
smspec_node->var_type == ECL_SMSPEC_BLOCK_VAR ||
smspec_node->var_type == ECL_SMSPEC_AQUIFER_VAR)
smspec_node->need_nums = true;
else
smspec_node->need_nums = false;
}
}
/**
@@ -602,13 +583,27 @@ bool smspec_node_init( smspec_node_type * smspec_node,
break;
case(ECL_SMSPEC_MISC_VAR):
/* Misc variable : */
/* Fully initialized with the smspec_common_init() function */
/*
For some keywords the SMSPEC files generated by Eclipse have a
non zero NUMS value although; it seems that value is required
for the generatd summaryfiles to display nicely in
e.g. S3GRAF.
*/
if (util_string_equal( keyword ,SMSPEC_TIME_KEYWORD))
smspec_node_set_num( smspec_node , grid_dims , SMSPEC_TIME_NUMS_VALUE );
if (util_string_equal( keyword ,SMSPEC_YEARS_KEYWORD))
smspec_node_set_num( smspec_node , grid_dims , SMSPEC_YEARS_NUMS_VALUE );
break;
default:
/* Lots of legitimate alternatives which are not internalized. */
initOK = false;
break;
}
if (initOK)
smspec_node_set_gen_keys( smspec_node , key_join_string );
return initOK;
@@ -741,6 +736,42 @@ smspec_node_type * smspec_node_alloc_lgr( ecl_smspec_var_type var_type ,
}
}
smspec_node_type* smspec_node_alloc_copy( const smspec_node_type* node ) {
if( !node ) return NULL;
{
smspec_node_type* copy = util_malloc( sizeof * copy );
UTIL_TYPE_ID_INIT( copy, SMSPEC_TYPE_ID );
copy->gen_key1 = util_alloc_string_copy( node->gen_key1 );
copy->gen_key2 = util_alloc_string_copy( node->gen_key2 );
copy->var_type = node->var_type;
copy->wgname = util_alloc_string_copy( node->wgname );
copy->keyword = util_alloc_string_copy( node->keyword );
copy->unit = util_alloc_string_copy( node->unit );
copy->num = node->num;
copy->ijk = NULL;
if( node->ijk ) {
copy->ijk = util_calloc( 3 , sizeof * node->ijk );
memcpy( copy->ijk, node->ijk, 3 * sizeof( * node->ijk ) );
}
copy->lgr_name = util_alloc_string_copy( node->lgr_name );
copy->lgr_ijk = NULL;
if( node->lgr_ijk ) {
copy->lgr_ijk = util_calloc( 3 , sizeof * node->lgr_ijk );
memcpy( copy->lgr_ijk, node->lgr_ijk, 3 * sizeof( * node->lgr_ijk ) );
}
copy->rate_variable = node->rate_variable;
copy->total_variable = node->total_variable;
copy->historical = node->historical;
copy->params_index = node->params_index;
copy->default_value = node->default_value;
return copy;
}
}
void smspec_node_free( smspec_node_type * index ) {
util_safe_free( index->unit );
@@ -830,9 +861,29 @@ void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit )
bool smspec_node_need_nums( const smspec_node_type * smspec_node ) {
return smspec_node->need_nums;
/*
Check if this node needs the nums field; if at least one of the
nodes need the NUMS field must be stored when writing a SMSPEC
file.
*/
{
if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR ||
smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR ||
smspec_node->var_type == ECL_SMSPEC_REGION_VAR ||
smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR ||
smspec_node->var_type == ECL_SMSPEC_BLOCK_VAR ||
smspec_node->var_type == ECL_SMSPEC_AQUIFER_VAR)
return true;
else {
if (smspec_node->num == SMSPEC_NUMS_INVALID)
return false;
else
return true;
}
}
}
void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream) {
fprintf(stream, "KEYWORD: %s \n",smspec_node->keyword);
fprintf(stream, "WGNAME : %s \n",smspec_node->wgname);

View File

@@ -19,6 +19,7 @@
#include <stdbool.h>
#include <ert/util/test_util.h>
#include <ert/util/test_util_abort.h>
#include <ert/util/util.h>
#include <ert/util/vector.h>
#include <ert/util/test_work_area.h>

View File

@@ -19,6 +19,7 @@
#include <stdbool.h>
#include <ert/util/test_util.h>
#include <ert/util/test_util_abort.h>
#include <ert/ecl/ecl_grid.h>

View File

@@ -19,6 +19,7 @@
#include <stdbool.h>
#include <ert/util/test_util.h>
#include <ert/util/test_util_abort.h>
#include <ert/util/util.h>
#include <ert/util/struct_vector.h>

View File

@@ -1,19 +1,19 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_rst_header.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_rst_header.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#include <stdlib.h>
#include <stdbool.h>
@@ -30,13 +30,13 @@
void test_file( const char * filename , int occurence , bool exists , const ecl_rsthead_type * true_header) {
ecl_file_type * rst_file = ecl_file_open( filename , 0);
ecl_rsthead_type * rst_head = ecl_rsthead_ialloc( rst_file , occurence);
if (exists) {
test_assert_not_NULL( rst_head );
if (occurence == 0) {
ecl_rsthead_type * rst_head0 = ecl_rsthead_alloc( rst_file );
test_assert_true( ecl_rsthead_equal( rst_head , rst_head0 ));
ecl_rsthead_free( rst_head0 );
}
@@ -45,12 +45,13 @@ void test_file( const char * filename , int occurence , bool exists , const ecl_
ecl_rsthead_free( rst_head );
} else
test_assert_NULL( rst_head );
}
int main(int argc , char ** argv) {
ecl_rsthead_type true1 = {.day = 1,
ecl_rsthead_type true1 = {.report_step = 1,
.day = 1,
.year = 2000,
.month = 1,
.sim_time = (time_t) 946681200,
@@ -72,8 +73,9 @@ int main(int argc , char ** argv) {
.nilbrz = -1,
.dualp = 0,
.sim_days = 0};
ecl_rsthead_type true2 = {.day = 22,
ecl_rsthead_type true2 = {.report_step = 5,
.day = 22,
.year = 1990,
.month = 1,
.sim_time = (time_t) 632962800,
@@ -95,14 +97,14 @@ int main(int argc , char ** argv) {
.nilbrz = -1,
.dualp = 1,
.sim_days = 21};
const char * unified_file = argv[1];
const char * Xfile = argv[2];
test_file( unified_file , 0 , true , &true1 );
test_file( unified_file , 100 , false , NULL );
test_file( Xfile , 0 , true , &true2 );
exit(0);
}

View File

@@ -127,11 +127,6 @@ target_link_libraries( ecl_grid_reset_actnum ecl test_util )
add_test( ecl_grid_reset_actnum ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_reset_actnum )
add_executable( ecl_grid_export ecl_grid_export.c )
add_executable( ecl_grid_corner ecl_grid_corner.c )
target_link_libraries( ecl_grid_corner ecl test_util )
add_test( ecl_grid_corner ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_corner )
target_link_libraries( ecl_grid_export ecl test_util )
add_test( ecl_grid_export ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_export ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
@@ -180,10 +175,6 @@ add_executable( ecl_point ecl_point.c )
target_link_libraries( ecl_point ecl test_util )
add_test(ecl_point ${EXECUTABLE_OUTPUT_PATH}/ecl_point )
add_executable( ecl_layer ecl_layer.c )
target_link_libraries( ecl_layer ecl test_util )
add_test(ecl_layer ${EXECUTABLE_OUTPUT_PATH}/ecl_layer )
add_executable( ecl_layer_statoil ecl_layer_statoil.c )
target_link_libraries( ecl_layer_statoil ecl test_util )
@@ -233,9 +224,20 @@ add_test( ecl_sum_report_step_compatible4 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_repo
add_test( ecl_sum_report_step_compatible5 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/enkf/ECLIPSE TRUE)
add_test( ecl_sum_report_step_compatible6 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre/SNORRE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre2/SNORRE2 FALSE)
add_executable( ecl_fortio ecl_fortio.c )
target_link_libraries( ecl_fortio ecl test_util )
add_test( ecl_fortio ${EXECUTABLE_OUTPUT_PATH}/ecl_fortio ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
if (HAVE_UTIL_ABORT_INTERCEPT)
add_executable( ecl_fortio ecl_fortio.c )
target_link_libraries( ecl_fortio ecl test_util )
add_test( ecl_fortio ${EXECUTABLE_OUTPUT_PATH}/ecl_fortio ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
set_property( TEST ecl_fortio PROPERTY LABELS StatoilData)
add_executable( ecl_grid_corner ecl_grid_corner.c )
target_link_libraries( ecl_grid_corner ecl test_util )
add_test( ecl_grid_corner ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_corner )
add_executable( ecl_layer ecl_layer.c )
target_link_libraries( ecl_layer ecl test_util )
add_test(ecl_layer ${EXECUTABLE_OUTPUT_PATH}/ecl_layer )
endif()
add_executable( ecl_file ecl_file.c )
target_link_libraries( ecl_file ecl test_util )
@@ -328,7 +330,6 @@ set_property( TEST ecl_sum_report_step_compatible6 PROPERTY LABELS StatoilData )
set_property( TEST ecl_fortio PROPERTY LABELS StatoilData)
set_property( TEST ecl_grid_dims1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_dims2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_grid_dims3 PROPERTY LABELS StatoilData )

View File

@@ -17,7 +17,6 @@
*/
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <math.h>
#include <ert/util/stringlist.h>

View File

@@ -33,7 +33,7 @@ include_directories( ${libgeometry_src_path} )
add_library( ecl_well ${LIBRARY_TYPE} ${source_files} )
set_target_properties( ecl_well PROPERTIES VERSION 1.0 SOVERSION 1.0 )
set_target_properties( ecl_well PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR} )
target_link_libraries( ecl_well ecl )
if (USE_RUNPATH)
add_runpath( ecl_well )

View File

@@ -29,8 +29,9 @@
#include <ert/ecl/ecl_kw.h>
#include <ert/ecl/ecl_util.h>
#include <ert/ecl/FortIO.hpp>
#include <ert/util/ert_unique_ptr.hpp>
#include <ert/ecl/FortIO.hpp>
namespace ERT {
@@ -51,12 +52,12 @@ namespace ERT {
return *( static_cast<T *>( ecl_kw_iget_ptr( m_kw.get() , index) ));
}
void fwrite(FortIO& fortio) const {
ecl_kw_fwrite( m_kw.get() , fortio.getPointer() );
ecl_kw_fwrite( m_kw.get() , fortio.get() );
}
void assignVector(const std::vector<T>& data) {
if (data.size() == size())
ecl_kw_set_memcpy_data( m_kw.get() , data.data() );
@@ -67,21 +68,17 @@ namespace ERT {
ecl_kw_type * getPointer() const {
return m_kw.get();
}
private:
EclKW(ecl_kw_type * c_ptr) {
reset(c_ptr);
}
void reset(ecl_kw_type * c_ptr) {
m_kw.reset( c_ptr , ecl_kw_free);
m_kw.reset( c_ptr );
}
static EclKW checkedLoad(FortIO& fortio, ecl_type_enum expectedType) {
ecl_kw_type * c_ptr = ecl_kw_fread_alloc( fortio.getPointer() );
ecl_kw_type * c_ptr = ecl_kw_fread_alloc( fortio.get() );
if (c_ptr) {
if (ecl_kw_get_type( c_ptr ) == expectedType)
if (ecl_kw_get_type( c_ptr ) == expectedType)
return EclKW( c_ptr );
else
throw std::invalid_argument("Type error");
@@ -89,8 +86,8 @@ namespace ERT {
throw std::invalid_argument("fread kw failed - EOF?");
}
std::shared_ptr<ecl_kw_type> m_kw;
ert_unique_ptr<ecl_kw_type , ecl_kw_free> m_kw;
};
}

View File

@@ -27,6 +27,7 @@
#include <ert/ecl/fortio.h>
#include <ert/ecl/ecl_endian_flip.h>
#include <ert/util/ert_unique_ptr.hpp>
@@ -34,13 +35,14 @@ namespace ERT {
class FortIO
{
public:
FortIO();
FortIO(const std::string& filename , std::ios_base::openmode mode , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP);
fortio_type * getPointer() const;
void close();
void reset() const;
void open(const std::string& filename , std::ios_base::openmode mode , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP);
fortio_type * get() const;
void close();
private:
std::shared_ptr<fortio_type> m_fortio;
ert_unique_ptr<fortio_type , fortio_fclose> m_fortio;
};
}

View File

@@ -0,0 +1,51 @@
#ifndef OPM_ERT_SMSPEC_HPP
#define OPM_ERT_SMSPEC_HPP
#include <memory>
#include <string>
#include <ert/ecl/smspec_node.h>
#include <ert/util/ert_unique_ptr.hpp>
namespace ERT {
class smspec_node {
public:
smspec_node( const smspec_node& );
smspec_node(
ecl_smspec_var_type,
const std::string& wgname,
const std::string& keyword
);
smspec_node( const std::string& keyword );
smspec_node( const std::string& keyword,
int dims[ 3 ],
int ijk[ 3 ] );
smspec_node( const std::string& keyword,
const std::string& wellname,
int dims[ 3 ],
int ijk[ 3 ] );
smspec_node( const std::string& keyword,
int dims[ 3 ],
int region );
const char* wgname() const;
const char* keyword() const;
private:
smspec_node(
ecl_smspec_var_type,
const char*, const char*, const char*, const char*,
const int[3], int, int = 0, float = 0 );
ert_unique_ptr< smspec_node_type, smspec_node_free > node;
};
}
#endif //OPM_ERT_SMSPEC_HPP

View File

@@ -1,14 +1,18 @@
set( source_files
EclKW.cpp
FortIO.cpp )
FortIO.cpp
Smspec.cpp
)
set( header_files
EclKW.hpp
FortIO.hpp )
FortIO.hpp
Smspec.hpp
)
add_library( eclxx ${LIBRARY_TYPE} ${source_files} )
set_target_properties( eclxx PROPERTIES VERSION 1.0 SOVERSION 1.0 )
set_target_properties( eclxx PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR})
if (USE_RUNPATH)
add_runpath( eclxx )
endif()

View File

@@ -3,22 +3,19 @@
namespace ERT {
template <>
EclKW<int>::EclKW(const std::string& kw, int size_) {
ecl_kw_type * c_ptr = ecl_kw_alloc( kw.c_str() , size_ , ECL_INT_TYPE );
reset( c_ptr );
}
EclKW<int>::EclKW(const std::string& kw, int size_)
: m_kw( ecl_kw_alloc( kw.c_str() , size_ , ECL_INT_TYPE ) )
{ }
template <>
EclKW<float>::EclKW(const std::string& kw, int size_) {
ecl_kw_type * c_ptr = ecl_kw_alloc( kw.c_str() , size_ , ECL_FLOAT_TYPE );
reset( c_ptr );
}
EclKW<float>::EclKW(const std::string& kw, int size_)
: m_kw( ecl_kw_alloc( kw.c_str() , size_ , ECL_FLOAT_TYPE ) )
{ }
template <>
EclKW<double>::EclKW(const std::string& kw, int size_) {
ecl_kw_type * c_ptr = ecl_kw_alloc( kw.c_str() , size_ , ECL_DOUBLE_TYPE );
reset( c_ptr );
}
EclKW<double>::EclKW(const std::string& kw, int size_)
: m_kw( ecl_kw_alloc( kw.c_str() , size_ , ECL_DOUBLE_TYPE ) )
{ }

View File

@@ -26,16 +26,28 @@
namespace ERT {
FortIO::FortIO(const std::string& filename , std::ios_base::openmode mode , bool fmt_file , bool endian_flip_header) {
FortIO::FortIO( ) { }
FortIO::FortIO(const std::string& filename , std::ios_base::openmode mode , bool fmt_file , bool endian_flip_header)
{
open( filename , mode , fmt_file , endian_flip_header );
}
void FortIO::open(const std::string& filename , std::ios_base::openmode mode , bool fmt_file , bool endian_flip_header) {
if (mode == std::ios_base::in) {
if (util_file_exists( filename.c_str() )) {
fortio_type * c_ptr = fortio_open_reader( filename.c_str() , fmt_file , endian_flip_header);
m_fortio.reset( c_ptr , fortio_fclose );
m_fortio.reset( c_ptr );
} else
throw std::invalid_argument("File " + filename + " does not exist");
} else if (mode == std::ios_base::app) {
fortio_type * c_ptr = fortio_open_append( filename.c_str() , fmt_file , endian_flip_header);
m_fortio.reset( c_ptr );
} else {
fortio_type * c_ptr = fortio_open_writer( filename.c_str() , fmt_file , endian_flip_header);
m_fortio.reset( c_ptr , fortio_fclose );
m_fortio.reset( c_ptr );
}
}
@@ -48,7 +60,7 @@ namespace ERT {
fortio_type * FortIO::getPointer() const {
fortio_type * FortIO::get() const {
return m_fortio.get();
}

View File

@@ -0,0 +1,77 @@
#include <ert/ecl/ecl_smspec.h>
#include <ert/ecl/Smspec.hpp>
namespace ERT {
smspec_node::smspec_node( const smspec_node& rhs ) :
node( smspec_node_alloc_copy( rhs.node.get() ) )
{}
static const int dummy_dims[ 3 ] = { -1, -1, -1 };
const auto default_join = ":";
static int global_index( int dims[ 3 ], int ijk[ 3 ] ) {
/* num is offset 1 global index */
return 1 + ijk[ 0 ] + ( ijk[ 1 ] * dims[ 0 ] ) + ( ijk[ 2 ] * dims[ 1 ] * dims[ 0 ] );
}
smspec_node::smspec_node(
ecl_smspec_var_type var_type,
const std::string& name,
const std::string& kw
) : smspec_node( var_type, name.c_str(), kw.c_str(), "", default_join, dummy_dims, 0 )
{}
smspec_node::smspec_node( const std::string& keyword ) :
smspec_node( ECL_SMSPEC_FIELD_VAR, "", keyword.c_str(),
"", default_join, dummy_dims, 0 )
{}
smspec_node::smspec_node(
const std::string& keyword,
int dims[ 3 ],
int ijk[ 3 ] ) :
smspec_node(
ECL_SMSPEC_BLOCK_VAR, "", keyword.c_str(), "", default_join, dims, global_index( dims, ijk )
)
{}
smspec_node::smspec_node(
const std::string& keyword,
const std::string& wellname,
int dims[ 3 ],
int ijk[ 3 ] ) :
smspec_node(
ECL_SMSPEC_COMPLETION_VAR, wellname.c_str(), keyword.c_str(), "", default_join, dims, global_index( dims, ijk )
)
{}
smspec_node::smspec_node(
const std::string& keyword,
int dims[ 3 ],
int region ) :
smspec_node(
ECL_SMSPEC_REGION_VAR, "", keyword.c_str(), "", default_join, dims, region
)
{}
smspec_node::smspec_node(
ecl_smspec_var_type type,
const char* wgname,
const char* keyword,
const char* unit,
const char* join,
const int grid_dims[ 3 ],
int num, int index, float default_value ) :
node( smspec_node_alloc( type, wgname, keyword, unit,
join, grid_dims, num, index, default_value ) )
{}
const char* smspec_node::wgname() const {
return smspec_node_get_wgname( this->node.get() );
}
const char* smspec_node::keyword() const {
return smspec_node_get_keyword( this->node.get() );
}
}

View File

@@ -5,3 +5,7 @@ add_test(eclxx_kw ${EXECUTABLE_OUTPUT_PATH}/eclxx_kw)
add_executable(eclxx_fortio eclxx_fortio.cpp)
target_link_libraries(eclxx_fortio eclxx test_util util)
add_test(eclxx_fortio ${EXECUTABLE_OUTPUT_PATH}/eclxx_fortio)
add_executable(eclxx_smspec eclxx_smspec.cpp)
target_link_libraries(eclxx_smspec eclxx test_util util)
add_test(eclxx_smspec ${EXECUTABLE_OUTPUT_PATH}/eclxx_smspec)

View File

@@ -28,6 +28,49 @@
#include <ert/ecl/FortIO.hpp>
void test_open() {
test_work_area_type * work_area = test_work_area_alloc("fortio");
ERT::FortIO fortio;
fortio.open( "new_file" , std::fstream::out );
{
std::vector<int> data;
for (size_t i=0; i < 1000; i++)
data.push_back(i);
fortio_fwrite_record( fortio.get() , reinterpret_cast<char *>(data.data()) , 1000 * 4 );
}
fortio.close();
fortio.open( "new_file" , std::fstream::app );
{
std::vector<int> data;
for (size_t i=0; i < 1000; i++)
data.push_back(i);
fortio_fwrite_record( fortio.get() , reinterpret_cast<char *>(data.data()) , 1000 * 4 );
}
fortio.close();
fortio.open( "new_file" , std::fstream::in );
{
std::vector<int> data;
for (size_t i=0; i < 1000; i++)
data.push_back(99);
test_assert_true( fortio_fread_buffer( fortio.get() , reinterpret_cast<char *>(data.data()) , 1000 * 4 ) );
for (size_t i =0; i < 1000; i++)
test_assert_size_t_equal(data[i], i);
test_assert_true( fortio_fread_buffer( fortio.get() , reinterpret_cast<char *>(data.data()) , 1000 * 4 ) );
for (size_t i =0; i < 1000; i++)
test_assert_size_t_equal(data[i], i);
}
fortio.close();
test_work_area_free( work_area );
}
void test_fortio() {
test_work_area_type * work_area = test_work_area_alloc("fortio");
@@ -38,7 +81,7 @@ void test_fortio() {
for (size_t i=0; i < 1000; i++)
data.push_back(i);
fortio_fwrite_record( fortio.getPointer() , reinterpret_cast<char *>(data.data()) , 1000 * 4 );
fortio_fwrite_record( fortio.get() , reinterpret_cast<char *>(data.data()) , 1000 * 4 );
}
fortio.close();
@@ -48,7 +91,7 @@ void test_fortio() {
for (size_t i=0; i < 1000; i++)
data.push_back(99);
test_assert_true( fortio_fread_buffer( fortio.getPointer() , reinterpret_cast<char *>(data.data()) , 1000 * 4 ) );
test_assert_true( fortio_fread_buffer( fortio.get() , reinterpret_cast<char *>(data.data()) , 1000 * 4 ) );
for (size_t i =0; i < 1000; i++)
test_assert_size_t_equal(data[i], i);
@@ -91,6 +134,7 @@ void test_fortio_kw() {
int main(int argc , char ** argv) {
test_open();
test_fortio();
test_fortio_kw();
}

View File

@@ -0,0 +1,86 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM 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.
OPM 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 for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ert/util/test_util.h>
#include <ert/util/test_work_area.h>
#include <ert/ecl/Smspec.hpp>
void test_smspec_copy() {
std::string kw( "FOPT" );
ERT::smspec_node field( kw );
ERT::smspec_node copy( field );
}
void test_smspec_wg() {
std::string kw( "WWCT" );
std::string wg( "OP1" );
std::string gr( "WG1" );
ERT::smspec_node well( ECL_SMSPEC_WELL_VAR, wg, kw );
ERT::smspec_node group( ECL_SMSPEC_GROUP_VAR, gr, kw );
test_assert_true(well.wgname() == wg);
test_assert_true(group.wgname() == gr);
}
void test_smspec_field() {
std::string kw( "FOPT" );
ERT::smspec_node field( kw );
test_assert_true( field.keyword() == kw );
}
void test_smspec_block() {
std::string kw( "BPR" );
int dims[ 3 ] = { 10, 10, 10 };
int ijk[ 3 ] = { 5, 5, 5 };
ERT::smspec_node block( kw, dims, ijk );
test_assert_true( block.keyword() == kw );
}
void test_smspec_region() {
std::string kw( "ROIP" );
int dims[ 3 ] = { 10, 10, 10 };
ERT::smspec_node region( kw, dims, 0 );
test_assert_true( region.keyword() == kw );
}
void test_smspec_completion() {
std::string kw( "CWIT" );
std::string wg( "WELL1" );
int dims[ 3 ] = { 10, 10, 10 };
int ijk[ 3 ] = { 1, 1, 1 };
ERT::smspec_node completion( kw, wg, dims, ijk );
test_assert_true( completion.keyword() == kw );
}
int main (int argc, char **argv) {
test_smspec_copy();
test_smspec_wg();
test_smspec_field();
test_smspec_block();
test_smspec_region();
test_smspec_completion();
}

View File

@@ -1,8 +1,7 @@
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories( ${PLPLOT_HEADER} )
set( src_list main.c enkf_tui_main.c enkf_tui_fs.c enkf_tui_ranking.c enkf_tui_misc.c enkf_tui_table.c enkf_tui_plot.c enkf_tui_plot_rft.c enkf_tui_plot_util.c
enkf_tui_run.c enkf_tui_util.c enkf_tui_init.c enkf_tui_export.c enkf_tui_analysis.c enkf_tui_QC.c enkf_tui_help.c enkf_tui_simple.c ert_tui_jobs.c enkf_tui_workflow.c)
set( src_list main.c enkf_tui_main.c enkf_tui_fs.c enkf_tui_ranking.c enkf_tui_misc.c enkf_tui_table.c
enkf_tui_run.c enkf_tui_util.c enkf_tui_init.c enkf_tui_export.c enkf_tui_analysis.c enkf_tui_help.c enkf_tui_simple.c enkf_tui_workflow.c)
execute_process(COMMAND date "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE BUILD_TIME )
string(STRIP ${BUILD_TIME} BUILD_TIME)
@@ -20,7 +19,7 @@ endif()
set_source_files_properties( main.c PROPERTIES COMPILE_DEFINITIONS "COMPILE_TIME_STAMP=\"${BUILD_TIME}\";GIT_COMMIT=\"${GIT_COMMIT}\"")
add_executable( ert ${src_list} )
target_link_libraries( ert enkf sched rms ecl config plot job_queue analysis ert_util )
target_link_libraries( ert enkf sched rms ecl config job_queue analysis ert_util )
if (USE_RUNPATH)
add_runpath( ert )
endif()

View File

@@ -1,65 +0,0 @@
import os
import os.path
import sys
sys.path += ["../../../scons-config"]
import global_config
from global_config import LIBUTIL
from global_config import LIBECL
from global_config import LIBPLOT
from global_config import LIBCONFIG
from global_config import LIBJOB_QUEUE
from global_config import LIBENKF
from global_config import LIBRMS
from global_config import LIBSCHED
from global_config import LIBANALYSIS
from global_config import LIBGEOMETRY
from global_config import add_program
lib_path = "../lib"
include_path = "../include"
bin_path = "../bin"
conf = global_config.get_conf(os.getcwd() , 3)
env = Environment()
lib_list = ["lapack" , "blas" , "plplotd" , "m" , "z" , "pthread" , "dl"]
if conf.INCLUDE_LSF:
lib_list.append( ["bat" , "lsf" , "nsl"] )
if conf.g2c:
lib_list.append( "g2c" )
fileH = open("site_config_file.h" , "w")
fileH.write( "#define SITE_CONFIG_FILE \"%s\"\n" % conf.SITE_CONFIG_FILE)
fileH.close()
conf.update_env( env , [ LIBENKF , LIBRMS , LIBANALYSIS , LIBJOB_QUEUE , LIBSCHED , LIBECL , LIBGEOMETRY , LIBPLOT , LIBCONFIG , LIBUTIL ] , lib_list , link = True)
env.Append( CPPPATH = conf.PLPLOT_INCLUDE_PATH )
env.Append( LIBPATH = conf.PLPLOT_LIB_PATH )
if conf.INCLUDE_LSF:
env.Append( LIBPATH = conf.LSF_LIB_PATH )
tui_objects = env.Object( ["enkf_tui_main.c" , "enkf_tui_fs.c" ,
"enkf_tui_ranking.c" , "enkf_tui_misc.c" ,
"enkf_tui_table.c" , "enkf_tui_plot.c" ,
"enkf_tui_plot_rft.c",
"enkf_tui_plot_util.c" , "enkf_tui_run.c",
"enkf_tui_util.c" , "enkf_tui_init.c" ,
"enkf_tui_export.c" , "enkf_tui_analysis.c" ,
"enkf_tui_QC.c" , "enkf_tui_help.c"])
define_fmt = "\'%s=\"%s\"\'"
main_object = env.Object("main.c" , CPPDEFINES = "DEVEL_VERSION")
local_config = env.Program( "local_config" , ["local_config.c"])
upgrade_fs104 = env.Program( "upgrade_fs104" , ["upgrade_fs104.c"])
ert = env.Program( "ert" , [main_object, tui_objects])
ert_svn = env.Program( "ert_%s" % conf.SVN_VERSION , [main_object, tui_objects])
env.Install( bin_path , [ert , local_config , upgrade_fs104])
Default( bin_path )

Some files were not shown because too many files have changed in this diff Show More