mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Updated ERT from https://github.com/Ensembles/ert/commits/master to version
4a78d88f1dc7bbc86f173c5adb825bbca29fa116 p4#: 21120
This commit is contained in:
parent
ef6ee4a26c
commit
32d67d9978
@ -23,7 +23,6 @@
|
||||
|
||||
#include <util.h>
|
||||
#include <int_vector.h>
|
||||
#include <ecl_intehead.h>
|
||||
#include <ecl_file.h>
|
||||
#include <ecl_kw.h>
|
||||
#include <ecl_kw_magic.h>
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "util.h"
|
||||
#include "ecl_file.h"
|
||||
#include "ecl_intehead.h"
|
||||
#include "ecl_kw_magic.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
36
ThirdParty/Ert/devel/CMakeLists.txt
vendored
36
ThirdParty/Ert/devel/CMakeLists.txt
vendored
@ -4,12 +4,14 @@ project( ERT C CXX )
|
||||
set( ERT_VERSION_MAJOR 1 )
|
||||
set( ERT_VERSION_MINOR 0 )
|
||||
|
||||
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_APPLICATONS "Should we build small utility applications" OFF)
|
||||
option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF)
|
||||
option( BUILD_PYTHON "Run py_compile on the python wrappers" OFF)
|
||||
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)
|
||||
option( BUILD_PYTHON "Run py_compile on the python wrappers" OFF)
|
||||
option( INSTALL_ERT "Should anything be installed when issuing make install?" ON)
|
||||
|
||||
|
||||
include( CheckFunctionExists )
|
||||
ENABLE_TESTING()
|
||||
@ -22,7 +24,7 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
add_definitions( -DERT_WINDOWS )
|
||||
endif()
|
||||
|
||||
set( CMAKE_C_FLAGS "-g -O2 -Wall -std=gnu99 -fno-leading-underscore" )
|
||||
set( CMAKE_C_FLAGS "-g -O2 -Wall -std=gnu99" )
|
||||
set( CMAKE_CXX_FLAGS "-g -O2 -Wall" )
|
||||
|
||||
include(cmake/ert_check.cmake)
|
||||
@ -35,16 +37,13 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
|
||||
if (MSVC)
|
||||
set(SHARED_LIB OFF)
|
||||
set( LIBRARY_TYPE STATIC )
|
||||
set( SHARED_LIB OFF )
|
||||
else()
|
||||
option( SHARED_LIB "Build shared libraries" ON)
|
||||
set( LIBRARY_TYPE SHARED )
|
||||
set( SHARED_LIB ON )
|
||||
endif()
|
||||
|
||||
if (SHARED_LIB)
|
||||
set( LIBRARY_TYPE SHARED )
|
||||
else()
|
||||
set( LIBRARY_TYPE STATIC )
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
@ -57,9 +56,11 @@ if (ERT_LINUX)
|
||||
set( NEED_LIBM TRUE )
|
||||
set( LINK_STATIC FALSE )
|
||||
add_definitions( -DHAVE_PROC )
|
||||
set( NEED_LIBDL ON )
|
||||
else()
|
||||
set( NEED_LIBM FALSE )
|
||||
set( LINK_STATIC TRUE )
|
||||
set( NEED_LIBDL OFF )
|
||||
endif()
|
||||
|
||||
|
||||
@ -92,13 +93,6 @@ add_subdirectory( libecl_well )
|
||||
#-----------------------------------------------------------------
|
||||
if (BUILD_ERT)
|
||||
#-----------------------------------------------------------------
|
||||
try_compile( DLOPEN ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_dlopen.c )
|
||||
if (DLOPEN)
|
||||
set(NEED_LIBDL OFF)
|
||||
else()
|
||||
set(NEED_LIBDL ON)
|
||||
endif()
|
||||
|
||||
option(USE_LSF "Include support for LSF" ON)
|
||||
|
||||
include_directories( ${PROJECT_SOURCE_DIR}/libconfig/include )
|
||||
|
@ -1,5 +0,0 @@
|
||||
#include <dlfcn.h>
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
dlopen( NULL , 0 );
|
||||
}
|
35
ThirdParty/Ert/devel/cmake/cmake_pyc
vendored
Normal file
35
ThirdParty/Ert/devel/cmake/cmake_pyc
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
import py_compile
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
# Small 'python compiler' used in the build system for ert. The
|
||||
# commandline arguments should be:
|
||||
#
|
||||
# cmake_pyc.py src1.py src2.py src3.py /path/to/pyc/files
|
||||
#
|
||||
# The input source files can contain a path component like
|
||||
# path/src1.py, but the path will not be recreated in the target
|
||||
# domain.
|
||||
|
||||
|
||||
def compile_file(src_file , target_file):
|
||||
path = os.path.dirname( target_file )
|
||||
if not os.path.exists( path ):
|
||||
os.makedirs( path )
|
||||
try:
|
||||
py_compile.compile( src_file , cfile = target_file , doraise = True)
|
||||
except Exception,error:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
target_path = sys.argv[-1]
|
||||
for src_file in sys.argv[1:-1]:
|
||||
compile_file( src_file , "%s/%sc" % (target_path , os.path.basename(src_file)))
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
#cmakedefine HAVE_PTHREAD
|
||||
#cmakedefine HAVE_EXECINFO
|
||||
#cmakedefine HAVE_FORK
|
||||
#cmakedefine HAVE_ZLIB
|
||||
#cmakedefine HAVE_LSF
|
||||
#cmakedefine HAVE_REALPATH
|
||||
#cmakedefine HAVE_SYMLINK
|
||||
#cmakedefine HAVE_READLINKAT
|
||||
#cmakedefine HAVE_GETUID
|
||||
#cmakedefine HAVE_LOCALTIME_R
|
||||
#cmakedefine HAVE_LOCKF
|
||||
#cmakedefine HAVE_SETENV
|
||||
#cmakedefine HAVE_GLOB
|
||||
#cmakedefine MKDIR_POSIX
|
||||
#cmakedefine HAVE_FNMATCH
|
||||
#cmakedefine NEED_BLAS
|
||||
#cmakedefine HAVE_OPENMP
|
||||
#cmakedefine HAVE_FTRUNCATE
|
||||
#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
|
||||
|
4
ThirdParty/Ert/devel/cmake/ert_find.cmake
vendored
4
ThirdParty/Ert/devel/cmake/ert_find.cmake
vendored
@ -52,6 +52,8 @@ if (LATEX_PATH)
|
||||
else()
|
||||
set( WITH_LATEX OFF )
|
||||
endif()
|
||||
#-----------------------------------------------------------------f
|
||||
find_program(PING_PATH NAMES ping)
|
||||
#-----------------------------------------------------------------
|
||||
find_path( EXECINFO_HEADER execinfo.h /usr/include )
|
||||
if (EXECINFO_HEADER)
|
||||
@ -63,6 +65,8 @@ if (GETOPT_HEADER)
|
||||
add_definitions( -DHAVE_GETOPT )
|
||||
endif()
|
||||
#-----------------------------------------------------------------
|
||||
find_path( UNISTD_HEADER unistd.h /usr/include )
|
||||
|
||||
if (ERT_WINDOWS)
|
||||
find_library( SHLWAPI_LIBRARY NAMES Shlwapi )
|
||||
endif()
|
||||
|
16
ThirdParty/Ert/devel/cmake/python.cmake
vendored
16
ThirdParty/Ert/devel/cmake/python.cmake
vendored
@ -3,15 +3,17 @@ macro(add_python_target tgt PYTHON_INSTALL_PATH ARGN)
|
||||
foreach(file ${ARGN})
|
||||
set(OUT ${CMAKE_CURRENT_BINARY_DIR}/${file}.pyc)
|
||||
list(APPEND OUT_FILES ${OUT})
|
||||
#------------------------------------------------------
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${file}.pyc
|
||||
COMMAND python -m py_compile
|
||||
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.py
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND mv
|
||||
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.pyc ${CMAKE_CURRENT_BINARY_DIR}
|
||||
OUTPUT ${OUT}
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc
|
||||
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PATH}
|
||||
)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.pyc DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PATH})
|
||||
#------------------------------------------------------
|
||||
if (INSTALL_ERT)
|
||||
install(FILES ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PATH}/${file}.pyc DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PATH})
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file}.py DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PATH})
|
||||
endif()
|
||||
endforeach(file)
|
||||
list(REMOVE_DUPLICATES OUT_FILES)
|
||||
ADD_CUSTOM_TARGET(
|
||||
|
6
ThirdParty/Ert/devel/debian/changelog
vendored
6
ThirdParty/Ert/devel/debian/changelog
vendored
@ -1,3 +1,9 @@
|
||||
libert.ecl (1.0-2) precise; urgency=low
|
||||
|
||||
* Mark -dev package as architecture independent
|
||||
|
||||
-- Arne Morten Kvarving <akva@SINTEFPC4169> Tue, 19 Feb 2013 10:03:04 +0100
|
||||
|
||||
libert.ecl (1.0-1) unstable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
2
ThirdParty/Ert/devel/debian/control
vendored
2
ThirdParty/Ert/devel/debian/control
vendored
@ -10,7 +10,7 @@ Vcs-Browser: https://github.com/Ensembles/ert
|
||||
|
||||
Package: libert.ecl-dev
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Architecture: all
|
||||
Depends: libert.ecl1 (= ${binary:Version})
|
||||
Description: The Ensemble based Reservoir Tool -- Development files
|
||||
ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble
|
||||
|
@ -1 +1,2 @@
|
||||
usr/lib/*/lib*.so.*
|
||||
usr/bin/*
|
||||
|
2
ThirdParty/Ert/devel/debian/rules
vendored
2
ThirdParty/Ert/devel/debian/rules
vendored
@ -13,4 +13,4 @@
|
||||
dh $@
|
||||
|
||||
override_dh_auto_configure:
|
||||
dh_auto_configure -- -DSHARED_LIB=1
|
||||
dh_auto_configure -- -DSHARED_LIB=1 -DBUILD_ECL_SUMMARY=1 -DCMAKE_BUILD_TYPE=Release
|
||||
|
@ -2,23 +2,22 @@
|
||||
#ifndef __RML_ENKF_COMMON_H__
|
||||
#define __RML_ENKF_COMMON_H__
|
||||
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <matrix.h>
|
||||
#include <rng.h>
|
||||
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/rng.h>
|
||||
|
||||
|
||||
void rml_enkf_common_initA__( matrix_type * A ,
|
||||
matrix_type * S ,
|
||||
matrix_type * Cd ,
|
||||
matrix_type * E ,
|
||||
matrix_type * D ,
|
||||
double truncation,
|
||||
double lamda,
|
||||
matrix_type * Ud,
|
||||
double * Wd,
|
||||
matrix_type * VdT);
|
||||
matrix_type * S ,
|
||||
matrix_type * Cd ,
|
||||
matrix_type * E ,
|
||||
matrix_type * D ,
|
||||
double truncation,
|
||||
double lamda,
|
||||
matrix_type * Ud,
|
||||
double * Wd,
|
||||
matrix_type * VdT);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -16,12 +16,15 @@ endif()
|
||||
set( CMAKE_SHARED_MODULE_PREFIX "" )
|
||||
add_library( std_enkf MODULE std_enkf.c )
|
||||
add_library( sqrt_enkf MODULE sqrt_enkf.c )
|
||||
add_library( rml_enkf MODULE rml_enkf.c rml_enkf_common.c )
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
install(TARGETS analysis DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
foreach(header ${header_files})
|
||||
install(FILES ../include/ert/analysis/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/analysis)
|
||||
endforeach()
|
||||
|
||||
if (INSTALL_ERT)
|
||||
install(TARGETS analysis DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS rml_enkf DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
foreach(header ${header_files})
|
||||
install(FILES ../include/ert/analysis/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/analysis)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
add_subdirectory( src )
|
||||
add_subdirectory( tests )
|
||||
|
@ -18,61 +18,52 @@
|
||||
|
||||
#ifndef __CONFIG_H__
|
||||
#define __CONFIG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/hash.h>
|
||||
|
||||
#include <ert/config/config_schema_item.h>
|
||||
#include <ert/config/config_content_item.h>
|
||||
#include <ert/config/config_content_node.h>
|
||||
|
||||
#define ECL_COM_KW "--"
|
||||
#define ENKF_COM_KW "--"
|
||||
|
||||
|
||||
/**
|
||||
Types used for validation of config items.
|
||||
*/
|
||||
typedef enum {CONFIG_STRING = 0,
|
||||
CONFIG_INT = 1,
|
||||
CONFIG_FLOAT = 2,
|
||||
CONFIG_FILE = 9, /* These file does not need to exist - but includes are handled. */
|
||||
CONFIG_EXISTING_FILE = 3,
|
||||
CONFIG_EXISTING_DIR = 4,
|
||||
CONFIG_BOOLEAN = 5,
|
||||
CONFIG_CONFIG = 6,
|
||||
CONFIG_BYTESIZE = 7,
|
||||
CONFIG_EXECUTABLE = 8 ,
|
||||
CONFIG_INVALID = 1000 } config_item_types;
|
||||
|
||||
typedef struct config_struct config_type;
|
||||
typedef struct config_schema_item_struct config_schema_item_type;
|
||||
|
||||
|
||||
typedef struct config_struct config_type;
|
||||
|
||||
|
||||
char ** config_alloc_active_list(const config_type *, int *);
|
||||
void config_free(config_type *);
|
||||
config_type * config_alloc( );
|
||||
char ** config_alloc_active_list(const config_type * , int * );
|
||||
void config_parse(config_type * , const char * , const char * , const char * , const char * , bool , bool );
|
||||
bool config_parse(config_type * , const char * , const char * , const char * , const char * , config_schema_unrecognized_enum unrecognized_behaviour , bool );
|
||||
bool config_has_schema_item(const config_type * config , const char * kw);
|
||||
void config_clear(config_type * config);
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
void config_schema_item_set_envvar_expansion( config_schema_item_type * item , bool expand_envvar );
|
||||
bool config_item_set(const config_type * , const char * );
|
||||
void config_schema_item_free__ (void * );
|
||||
void config_schema_item_free( config_schema_item_type * );
|
||||
config_schema_item_type * config_schema_item_alloc(const char * , bool , bool);
|
||||
config_schema_item_type * config_get_schema_item(const config_type *, const char *);
|
||||
bool config_item_set(const config_type * , const char * );
|
||||
void config_add_alias(config_type * , const char * , const char * );
|
||||
void config_install_message(config_type * , const char * , const char * );
|
||||
const char * config_safe_get(const config_type * , const char *);
|
||||
char * config_alloc_joined_string(const config_type * , const char * , const char * );
|
||||
|
||||
void config_add_define( config_type * config , const char * key , const char * value );
|
||||
|
||||
|
||||
/*
|
||||
bool config_schema_item_is_set(const config_schema_item_type * );
|
||||
void config_schema_item_set_argc_minmax(config_schema_item_type * , int , int , int type_map_size , const config_item_types * );
|
||||
void config_schema_item_set_common_selection_set(config_schema_item_type * , int argc , const char ** argv);
|
||||
@ -80,17 +71,12 @@ typedef struct config_schema_item_struct config_schema_item_type;
|
||||
void config_schema_item_set_required_children(config_schema_item_type * , stringlist_type * );
|
||||
void config_schema_item_set_required_children_on_value(config_schema_item_type * , const char * , stringlist_type * );
|
||||
void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key);
|
||||
*/
|
||||
|
||||
config_schema_item_type * config_add_schema_item(config_type * config,
|
||||
const char * kw,
|
||||
bool required);
|
||||
|
||||
config_schema_item_type * config_add_schema_item(config_type *,
|
||||
const char * ,
|
||||
bool ,
|
||||
bool);
|
||||
|
||||
|
||||
bool config_has_keys(const config_type *,
|
||||
const char **,
|
||||
int ,
|
||||
bool );
|
||||
|
||||
const char * config_safe_iget(const config_type * config , const char *kw, int occurence , int index);
|
||||
const char * config_iget(const config_type * , const char * , int occurence , int index);
|
||||
@ -100,21 +86,29 @@ typedef struct config_schema_item_struct config_schema_item_type;
|
||||
stringlist_type * config_alloc_complete_stringlist(const config_type* , const char * );
|
||||
stringlist_type * config_alloc_stringlist(const config_type * config , const char * );
|
||||
hash_type * config_alloc_hash(const config_type * , const char * );
|
||||
const stringlist_type * config_get_stringlist_ref(const config_type * , const char * );
|
||||
stringlist_type * config_iget_stringlist_ref(const config_type * , const char * , int );
|
||||
bool config_has_set_item(const config_type * , const char * );
|
||||
const stringlist_type * config_iget_stringlist_ref(const config_type * , const char * , int );
|
||||
|
||||
int config_get_occurences(const config_type * , const char * );
|
||||
int config_get_occurence_size( const config_type * config , const char * kw , int occurence);
|
||||
|
||||
|
||||
bool config_has_content_item( const config_type * config , const char * input_kw);
|
||||
config_content_item_type * config_get_content_item( const config_type * config , const char * input_kw);
|
||||
config_schema_item_type * config_add_key_value( config_type * config , const char * key , bool required , config_item_types item_type);
|
||||
bool config_get_value_as_bool(const config_type * config , const char * kw);
|
||||
int config_get_value_as_int(const config_type * config , const char * kw);
|
||||
double config_get_value_as_double(const config_type * config , const char * kw);
|
||||
const char * config_get_value_as_abspath( const config_type * config , const char * kw);
|
||||
const char * config_get_value_as_relpath( const config_type * config , const char * kw);
|
||||
const char * config_get_value_as_path( const config_type * config , const char * kw);
|
||||
const char * config_get_value(const config_type * config , const char * kw);
|
||||
void config_fprintf_item_list(const config_type * config , FILE * stream);
|
||||
const char * config_get_config_file( const config_type * config , bool abs_path);
|
||||
void config_fprintf_errors( const config_type * config , bool add_count , FILE * stream );
|
||||
|
||||
int config_get_schema_size( const config_type * config );
|
||||
int config_get_content_size( const config_type * config );
|
||||
const config_content_node_type * config_iget_content_node( const config_type * config , int index );
|
||||
config_content_node_type * config_get_value_node( const config_type * config , const char * kw);
|
||||
config_error_type * config_get_errors( const config_type * config );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
66
ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_item.h
vendored
Normal file
66
ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_item.h
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_content_item.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __CONFIG_CONTENT_ITEM_H__
|
||||
#define __CONFIG_CONTENT_ITEM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/hash.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
|
||||
#include <ert/config/config_error.h>
|
||||
#include <ert/config/config_schema_item.h>
|
||||
#include <ert/config/config_path_elm.h>
|
||||
#include <ert/config/config_content_node.h>
|
||||
|
||||
typedef struct config_content_item_struct config_content_item_type;
|
||||
|
||||
int config_content_item_get_size(const config_content_item_type * item);
|
||||
config_content_node_type * config_content_item_get_last_node(const config_content_item_type * item);
|
||||
config_content_node_type * config_content_item_iget_node(const config_content_item_type * item , int index);
|
||||
const config_content_node_type * config_content_item_get_last_node_const(const config_content_item_type * item);
|
||||
const config_content_node_type * config_content_item_iget_node_const(const config_content_item_type * item , int index);
|
||||
char * config_content_item_ialloc_joined_string(const config_content_item_type * item , const char * sep , int occurence);
|
||||
char * config_content_item_alloc_joined_string(const config_content_item_type * item , const char * sep);
|
||||
const stringlist_type * config_content_item_iget_stringlist_ref(const config_content_item_type * item, int occurence);
|
||||
const stringlist_type * config_content_item_get_stringlist_ref(const config_content_item_type * item);
|
||||
stringlist_type * config_content_item_alloc_complete_stringlist(const config_content_item_type * item, bool copy);
|
||||
stringlist_type * config_content_item_alloc_stringlist(const config_content_item_type * item, bool copy);
|
||||
hash_type * config_content_item_alloc_hash(const config_content_item_type * item , bool copy);
|
||||
const char * config_content_item_iget(const config_content_item_type * item , int occurence , int index);
|
||||
bool config_content_item_iget_as_bool(const config_content_item_type * item, int occurence , int index);
|
||||
int config_content_item_iget_as_int(const config_content_item_type * item, int occurence , int index);
|
||||
double config_content_item_iget_as_double(const config_content_item_type * item, int occurence , int index);
|
||||
void config_content_item_clear( config_content_item_type * item );
|
||||
void config_content_item_free( config_content_item_type * item );
|
||||
void config_content_item_free__( void * arg );
|
||||
config_content_item_type * config_content_item_alloc( const config_schema_item_type * schema , const config_path_elm_type * path_elm);
|
||||
void config_content_item_validate(const config_content_item_type * item, config_error_type * error);
|
||||
config_content_node_type * config_content_item_alloc_node( const config_content_item_type * item , const config_path_elm_type * path_elm);
|
||||
const config_schema_item_type * config_content_item_get_schema( const config_content_item_type * item );
|
||||
const config_path_elm_type * config_content_item_get_path_elm( const config_content_item_type * item );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
61
ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_node.h
vendored
Normal file
61
ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_node.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_content_node.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __CONFIG_CONTENT_NODE_H__
|
||||
#define __CONFIG_CONTENT_NODE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
define extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/hash.h>
|
||||
|
||||
#include <ert/config/config_schema_item.h>
|
||||
#include <ert/config/config_path_elm.h>
|
||||
|
||||
typedef struct config_content_node_struct config_content_node_type;
|
||||
|
||||
config_content_node_type * config_content_node_alloc( const config_schema_item_type * schema , const config_path_elm_type * cwd);
|
||||
void config_content_node_add_value(config_content_node_type * node , const char * value);
|
||||
void config_content_node_set(config_content_node_type * node , const stringlist_type * token_list);
|
||||
char * config_content_node_alloc_joined_string(const config_content_node_type * node, const char * sep);
|
||||
void config_content_node_free(config_content_node_type * node);
|
||||
void config_content_node_free__(void * arg);
|
||||
const char * config_content_node_get_full_string( config_content_node_type * node , const char * sep );
|
||||
const char * config_content_node_iget(const config_content_node_type * node , int index);
|
||||
bool config_content_node_iget_as_bool(const config_content_node_type * node , int index);
|
||||
int config_content_node_iget_as_int(const config_content_node_type * node , int index);
|
||||
double config_content_node_iget_as_double(const config_content_node_type * node , int index);
|
||||
const char * config_content_node_iget_as_path(config_content_node_type * node , int index);
|
||||
const char * config_content_node_iget_as_abspath( config_content_node_type * node , int index);
|
||||
const char * config_content_node_iget_as_relpath( config_content_node_type * node , int index);
|
||||
const stringlist_type * config_content_node_get_stringlist( const config_content_node_type * node );
|
||||
const char * config_content_node_safe_iget(const config_content_node_type * node , int index);
|
||||
int config_content_node_get_size( const config_content_node_type * node );
|
||||
const char * config_content_node_get_kw( const config_content_node_type * node );
|
||||
void config_content_node_assert_key_value( const config_content_node_type * node );
|
||||
const config_path_elm_type * config_content_node_get_path_elm( const config_content_node_type * node );
|
||||
void config_content_node_init_opt_hash( const config_content_node_type * node , hash_type * opt_hash , int elm_offset);
|
||||
void config_content_node_fprintf( const config_content_node_type * node , FILE * stream );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
45
ThirdParty/Ert/devel/libconfig/include/ert/config/config_error.h
vendored
Normal file
45
ThirdParty/Ert/devel/libconfig/include/ert/config/config_error.h
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_error.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef __CONFIG_ERROR_H__
|
||||
#define __CONFIG_ERROR_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct config_error_struct config_error_type;
|
||||
|
||||
|
||||
config_error_type * config_error_alloc();
|
||||
config_error_type * config_error_alloc_copy( const config_error_type * src_error);
|
||||
void config_error_free(config_error_type * error);
|
||||
const char * config_error_iget(const config_error_type * error , int index);
|
||||
void config_error_add( config_error_type * error , char * new_error );
|
||||
void config_error_clear( config_error_type * error );
|
||||
int config_error_count( const config_error_type * error );
|
||||
void config_error_fprintf( const config_error_type * error , bool add_count , FILE * stream );
|
||||
bool config_error_equal( const config_error_type * error1 , const config_error_type * error2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
44
ThirdParty/Ert/devel/libconfig/include/ert/config/config_path_elm.h
vendored
Normal file
44
ThirdParty/Ert/devel/libconfig/include/ert/config/config_path_elm.h
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_path_elm.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef __CONFIG_PATH_ELM_H__
|
||||
#define __CONFIG_PATH_ELM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
#include <ert/config/config_root_path.h>
|
||||
|
||||
typedef struct config_path_elm_struct config_path_elm_type;
|
||||
|
||||
void config_path_elm_free( config_path_elm_type * path_elm );
|
||||
void config_path_elm_free__( void * arg );
|
||||
config_path_elm_type * config_path_elm_alloc( const config_root_path_type * root_path , const char * path);
|
||||
const char * config_path_elm_get_abspath( const config_path_elm_type * path_elm );
|
||||
const char * config_path_elm_get_relpath( const config_path_elm_type * path_elm );
|
||||
const config_root_path_type * config_path_elm_get_rootpath( const config_path_elm_type * path_elm );
|
||||
char * config_path_elm_alloc_abspath(const config_path_elm_type * path_elm , const char * input_path);
|
||||
char * config_path_elm_alloc_relpath(const config_path_elm_type * path_elm , const char * input_path);
|
||||
char * config_path_elm_alloc_path(const config_path_elm_type * path_elm , const char * input_path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
40
ThirdParty/Ert/devel/libconfig/include/ert/config/config_root_path.h
vendored
Normal file
40
ThirdParty/Ert/devel/libconfig/include/ert/config/config_root_path.h
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_root_path.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef __CONFIG_ROOT_PATH_H__
|
||||
#define __CONFIG_ROOT_PATH_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct config_root_path_struct config_root_path_type;
|
||||
|
||||
void config_root_path_free( config_root_path_type * root_path );
|
||||
config_root_path_type * config_root_path_alloc( const char * input_path );
|
||||
|
||||
const char * config_root_path_get_input_path( const config_root_path_type * root_path );
|
||||
const char * config_root_path_get_rel_path( const config_root_path_type * root_path );
|
||||
const char * config_root_path_get_abs_path( const config_root_path_type * root_path );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
123
ThirdParty/Ert/devel/libconfig/include/ert/config/config_schema_item.h
vendored
Normal file
123
ThirdParty/Ert/devel/libconfig/include/ert/config/config_schema_item.h
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_schema_item.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __CONFIG_SCHEMA_ITEM_H__
|
||||
#define __CONFIG_SCHEMA_ITEM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/stringlist.h>
|
||||
|
||||
#include <ert/config/config_error.h>
|
||||
#include <ert/config/config_path_elm.h>
|
||||
|
||||
/**
|
||||
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_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
|
||||
|
||||
|
||||
|
||||
|
||||
#define CONFIG_DEFAULT_ARG_MIN -1
|
||||
#define CONFIG_DEFAULT_ARG_MAX -1
|
||||
|
||||
|
||||
|
||||
typedef struct config_schema_item_struct config_schema_item_type;
|
||||
|
||||
|
||||
config_schema_item_type * config_schema_item_alloc(const char * kw , bool required);
|
||||
bool config_schema_item_validate_set(const config_schema_item_type * item ,
|
||||
stringlist_type * token_list ,
|
||||
const char * config_file,
|
||||
const config_path_elm_type * path_elm,
|
||||
config_error_type * error_list);
|
||||
|
||||
void config_schema_item_free( config_schema_item_type * item);
|
||||
void config_schema_item_free__ (void * void_item);
|
||||
|
||||
|
||||
void config_schema_item_set_common_selection_set(config_schema_item_type * item , int argc , const char ** argv);
|
||||
void config_schema_item_set_indexed_selection_set(config_schema_item_type * item , int index , int argc , const char ** argv);
|
||||
void config_schema_item_set_required_children(config_schema_item_type * item , stringlist_type * stringlist);
|
||||
void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key);
|
||||
void config_schema_item_set_envvar_expansion( config_schema_item_type * item , bool expand_envvar );
|
||||
void config_schema_item_set_argc_minmax(config_schema_item_type * item ,
|
||||
int argc_min ,
|
||||
int argc_max);
|
||||
void config_schema_item_assure_type(const config_schema_item_type * item , int index , int type_mask);
|
||||
|
||||
int config_schema_item_num_required_children(const config_schema_item_type * item);
|
||||
const char * config_schema_item_iget_required_child( const config_schema_item_type * item , int index);
|
||||
const char * config_schema_item_get_kw( const config_schema_item_type * item );
|
||||
bool config_schema_item_required( const config_schema_item_type * item );
|
||||
bool config_schema_item_expand_envvar( const config_schema_item_type * item );
|
||||
void config_schema_item_get_argc( const config_schema_item_type * item , int *argc_min , int *argc_max);
|
||||
bool config_schema_item_has_required_children_value( const config_schema_item_type * item );
|
||||
stringlist_type * config_schema_item_get_required_children_value(const config_schema_item_type * item , const char * value);
|
||||
|
||||
void config_schema_item_iset_type( config_schema_item_type * item , int index , config_item_types type);
|
||||
config_item_types config_schema_item_iget_type(const config_schema_item_type * item , int index );
|
||||
void config_schema_item_set_default_type( config_schema_item_type * item , config_item_types type);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,12 +1,14 @@
|
||||
set( source_files config.c conf.c conf_util.c conf_data.c)
|
||||
set( header_files config.h conf.h conf_data.h)
|
||||
set( source_files config.c config_error.c config_schema_item.c config_content_item.c config_content_node.c config_root_path.c config_path_elm.c conf.c conf_util.c conf_data.c)
|
||||
set( header_files config.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 )
|
||||
|
||||
target_link_libraries( config ert_util )
|
||||
|
||||
install(TARGETS config DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
foreach(header ${header_files})
|
||||
install(FILES ../include/ert/config/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/config)
|
||||
endforeach()
|
||||
if (INSTALL_ERT)
|
||||
install(TARGETS config DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
foreach(header ${header_files})
|
||||
install(FILES ../include/ert/config/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/config)
|
||||
endforeach()
|
||||
endif()
|
||||
|
1409
ThirdParty/Ert/devel/libconfig/src/config.c
vendored
1409
ThirdParty/Ert/devel/libconfig/src/config.c
vendored
File diff suppressed because it is too large
Load Diff
291
ThirdParty/Ert/devel/libconfig/src/config_content_item.c
vendored
Normal file
291
ThirdParty/Ert/devel/libconfig/src/config_content_item.c
vendored
Normal file
@ -0,0 +1,291 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_content_item.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 <stdbool.h>
|
||||
|
||||
#include <ert/util/vector.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
|
||||
#include <ert/config/config_schema_item.h>
|
||||
#include <ert/config/config_content_node.h>
|
||||
#include <ert/config/config_content_item.h>
|
||||
#include <ert/config/config_error.h>
|
||||
#include <ert/config/config_path_elm.h>
|
||||
|
||||
|
||||
#define CONFIG_CONTENT_ITEM_ID 8876752
|
||||
struct config_content_item_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
const config_schema_item_type * schema;
|
||||
vector_type * nodes;
|
||||
const config_path_elm_type * path_elm;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
/**
|
||||
This function counts the number of times a config item has been
|
||||
set. Referring again to the example at the top:
|
||||
|
||||
config_content_item_get_occurences( "KEY1" )
|
||||
|
||||
will return 2.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int config_content_item_get_size(const config_content_item_type * item) {
|
||||
return vector_get_size( item->nodes );
|
||||
}
|
||||
|
||||
|
||||
config_content_node_type * config_content_item_get_last_node(const config_content_item_type * item) {
|
||||
return vector_get_last( item->nodes );
|
||||
}
|
||||
|
||||
config_content_node_type * config_content_item_iget_node(const config_content_item_type * item , int index) {
|
||||
return vector_iget( item->nodes , index );
|
||||
}
|
||||
|
||||
const config_content_node_type * config_content_item_get_last_node_const(const config_content_item_type * item) {
|
||||
return vector_get_last( item->nodes );
|
||||
}
|
||||
|
||||
const config_content_node_type * config_content_item_iget_node_const(const config_content_item_type * item , int index) {
|
||||
return vector_iget( item->nodes , index );
|
||||
}
|
||||
|
||||
|
||||
char * config_content_item_ialloc_joined_string(const config_content_item_type * item , const char * sep , int occurence) {
|
||||
const config_content_node_type * node = config_content_item_iget_node(item , occurence);
|
||||
return config_content_node_alloc_joined_string(node , sep);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char * config_content_item_alloc_joined_string(const config_content_item_type * item , const char * sep) {
|
||||
const int occurences = config_content_item_get_size( item );
|
||||
char * joined_string = NULL;
|
||||
|
||||
for (int i =0; i < occurences ; i++) {
|
||||
joined_string = util_strcat_realloc( joined_string , config_content_item_ialloc_joined_string(item , sep , i));
|
||||
if (i < (occurences - 1))
|
||||
joined_string = util_strcat_realloc( joined_string , sep );
|
||||
}
|
||||
|
||||
return joined_string;
|
||||
}
|
||||
|
||||
const stringlist_type * config_content_item_iget_stringlist_ref(const config_content_item_type * item, int occurence) {
|
||||
const config_content_node_type * node = config_content_item_iget_node(item , occurence);
|
||||
return config_content_node_get_stringlist( node );
|
||||
}
|
||||
|
||||
|
||||
const stringlist_type * config_content_item_get_stringlist_ref(const config_content_item_type * item) {
|
||||
const config_content_node_type * node = config_content_item_get_last_node( item );
|
||||
return config_content_node_get_stringlist( node );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
If copy == false - the stringlist will break down when/if the
|
||||
config object is freed - your call.
|
||||
*/
|
||||
|
||||
stringlist_type * config_content_item_alloc_complete_stringlist(const config_content_item_type * item, bool copy) {
|
||||
int inode;
|
||||
stringlist_type * stringlist = stringlist_alloc_new();
|
||||
for (inode = 0; inode < vector_get_size( item->nodes ); inode++) {
|
||||
const config_content_node_type * node = config_content_item_iget_node(item , inode);
|
||||
const stringlist_type * src_list = config_content_node_get_stringlist( node );
|
||||
|
||||
if (copy)
|
||||
stringlist_append_stringlist_copy( stringlist , src_list );
|
||||
else
|
||||
stringlist_append_stringlist_ref( stringlist , src_list );
|
||||
|
||||
}
|
||||
|
||||
return stringlist;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
If copy == false - the stringlist will break down when/if the
|
||||
config object is freed - your call.
|
||||
*/
|
||||
|
||||
stringlist_type * config_content_item_alloc_stringlist(const config_content_item_type * item, bool copy) {
|
||||
const config_content_node_type * node = config_content_item_get_last_node( item );
|
||||
stringlist_type * stringlist = stringlist_alloc_new();
|
||||
const stringlist_type * src_list = config_content_node_get_stringlist( node );
|
||||
|
||||
if (copy)
|
||||
stringlist_append_stringlist_copy( stringlist , src_list );
|
||||
else
|
||||
stringlist_append_stringlist_ref( stringlist , src_list );
|
||||
|
||||
return stringlist;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
If copy == false - the hash will break down when/if the
|
||||
config object is freed - your call.
|
||||
*/
|
||||
|
||||
hash_type * config_content_item_alloc_hash(const config_content_item_type * item , bool copy) {
|
||||
hash_type * hash = hash_alloc();
|
||||
if (item != NULL) {
|
||||
int inode;
|
||||
for (inode = 0; inode < vector_get_size( item->nodes ); inode++) {
|
||||
const config_content_node_type * node = config_content_item_iget_node(item , inode);
|
||||
const stringlist_type * src_list = config_content_node_get_stringlist( node );
|
||||
const char * key = stringlist_iget(src_list , 0);
|
||||
const char * value = stringlist_iget(src_list , 1);
|
||||
|
||||
if (copy) {
|
||||
hash_insert_hash_owned_ref(hash ,
|
||||
key ,
|
||||
util_alloc_string_copy(value) ,
|
||||
free);
|
||||
} else
|
||||
hash_insert_ref(hash , key , value );
|
||||
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
const char * config_content_item_iget(const config_content_item_type * item , int occurence , int index) {
|
||||
const config_content_node_type * node = config_content_item_iget_node(item , occurence);
|
||||
const stringlist_type * src_list = config_content_node_get_stringlist( node );
|
||||
return stringlist_iget( src_list , index );
|
||||
}
|
||||
|
||||
bool config_content_item_iget_as_bool(const config_content_item_type * item, int occurence , int index) {
|
||||
bool value;
|
||||
config_schema_item_assure_type(item->schema , index , CONFIG_BOOL);
|
||||
util_sscanf_bool( config_content_item_iget(item , occurence ,index) , &value );
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int config_content_item_iget_as_int(const config_content_item_type * item, int occurence , int index) {
|
||||
int value;
|
||||
config_schema_item_assure_type(item->schema , index , CONFIG_INT);
|
||||
util_sscanf_int( config_content_item_iget(item , occurence , index) , &value );
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
double config_content_item_iget_as_double(const config_content_item_type * item, int occurence , int index) {
|
||||
double value;
|
||||
config_schema_item_assure_type(item->schema , index , CONFIG_FLOAT);
|
||||
util_sscanf_double( config_content_item_iget(item , occurence , index) , &value );
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Used to reset an item is the special string 'CLEAR_STRING'
|
||||
is found as the only argument:
|
||||
|
||||
OPTION V1
|
||||
OPTION V2 V3 V4
|
||||
OPTION __RESET__
|
||||
OPTION V6
|
||||
|
||||
In this case OPTION will get the value 'V6'. The example given
|
||||
above is a bit contrived; this option is designed for situations
|
||||
where several config files are parsed serially; and the user can
|
||||
not/will not update the first.
|
||||
*/
|
||||
|
||||
void config_content_item_clear( config_content_item_type * item ) {
|
||||
vector_clear( item->nodes );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void config_content_item_free( config_content_item_type * item ) {
|
||||
vector_free( item->nodes );
|
||||
free(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
UTIL_SAFE_CAST_FUNCTION( config_content_item , CONFIG_CONTENT_ITEM_ID);
|
||||
|
||||
|
||||
|
||||
void config_content_item_free__( void * arg ) {
|
||||
config_content_item_type * content_item = config_content_item_safe_cast( arg );
|
||||
config_content_item_free( content_item );
|
||||
}
|
||||
|
||||
|
||||
config_content_item_type * config_content_item_alloc( const config_schema_item_type * schema , const config_path_elm_type * path_elm) {
|
||||
config_content_item_type * content_item = util_malloc( sizeof * content_item );
|
||||
UTIL_TYPE_ID_INIT( content_item , CONFIG_CONTENT_ITEM_ID );
|
||||
content_item->schema = schema;
|
||||
content_item->nodes = vector_alloc_new();
|
||||
content_item->path_elm = path_elm;
|
||||
return content_item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
config_content_node_type * config_content_item_alloc_node( const config_content_item_type * item , const config_path_elm_type * path_elm) {
|
||||
config_content_node_type * node = config_content_node_alloc( item->schema , path_elm );
|
||||
vector_append_owned_ref( item->nodes , node , config_content_node_free__);
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const config_schema_item_type * config_content_item_get_schema( const config_content_item_type * item ) {
|
||||
return item->schema;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const config_path_elm_type * config_content_item_get_path_elm( const config_content_item_type * item ) {
|
||||
return item->path_elm;
|
||||
}
|
229
ThirdParty/Ert/devel/libconfig/src/config_content_node.c
vendored
Normal file
229
ThirdParty/Ert/devel/libconfig/src/config_content_node.c
vendored
Normal file
@ -0,0 +1,229 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_content_node.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 <stdbool.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
|
||||
#include <ert/config/config_schema_item.h>
|
||||
#include <ert/config/config_content_node.h>
|
||||
#include <ert/config/config_path_elm.h>
|
||||
|
||||
|
||||
#define CONFIG_CONTENT_NODE_ID 6752887
|
||||
struct config_content_node_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
const config_schema_item_type * schema;
|
||||
stringlist_type * stringlist; /* The values which have been set. */
|
||||
const config_path_elm_type * cwd;
|
||||
stringlist_type * string_storage;
|
||||
};
|
||||
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION( config_content_node , CONFIG_CONTENT_NODE_ID )
|
||||
|
||||
|
||||
|
||||
config_content_node_type * config_content_node_alloc( const config_schema_item_type * schema , const config_path_elm_type * cwd) {
|
||||
config_content_node_type * node = util_malloc(sizeof * node );
|
||||
UTIL_TYPE_ID_INIT( node , CONFIG_CONTENT_NODE_ID );
|
||||
node->stringlist = stringlist_alloc_new();
|
||||
node->cwd = cwd;
|
||||
node->schema = schema;
|
||||
node->string_storage = NULL;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
void config_content_node_add_value(config_content_node_type * node , const char * value) {
|
||||
stringlist_append_copy( node->stringlist , value);
|
||||
}
|
||||
|
||||
|
||||
void config_content_node_set(config_content_node_type * node , const stringlist_type * token_list) {
|
||||
int argc = stringlist_get_size( token_list ) - 1;
|
||||
for (int iarg=0; iarg < argc; iarg++)
|
||||
config_content_node_add_value( node , stringlist_iget( token_list , iarg + 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
char * config_content_node_alloc_joined_string(const config_content_node_type * node, const char * sep) {
|
||||
return stringlist_alloc_joined_string(node->stringlist , sep);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void config_content_node_free(config_content_node_type * node) {
|
||||
stringlist_free(node->stringlist);
|
||||
if (node->string_storage != NULL)
|
||||
stringlist_free( node->string_storage );
|
||||
free(node);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void config_content_node_free__(void * arg) {
|
||||
config_content_node_type * node = config_content_node_safe_cast( arg );
|
||||
config_content_node_free( node );
|
||||
}
|
||||
|
||||
static void config_content_node_push_string( config_content_node_type * node , char * string) {
|
||||
if (node->string_storage == NULL)
|
||||
node->string_storage = stringlist_alloc_new( );
|
||||
|
||||
stringlist_append_owned_ref( node->string_storage , string );
|
||||
}
|
||||
|
||||
const char * config_content_node_get_full_string( config_content_node_type * node , const char * sep ) {
|
||||
char * full_string = stringlist_alloc_joined_string(node->stringlist , sep);
|
||||
config_content_node_push_string( node , full_string );
|
||||
return full_string;
|
||||
}
|
||||
|
||||
const char * config_content_node_iget(const config_content_node_type * node , int index) {
|
||||
return stringlist_iget( node->stringlist , index );
|
||||
}
|
||||
|
||||
|
||||
const char * config_content_node_safe_iget(const config_content_node_type * node , int index) {
|
||||
if (index >= stringlist_get_size( node->stringlist ))
|
||||
return NULL;
|
||||
else
|
||||
return stringlist_iget( node->stringlist , index );
|
||||
}
|
||||
|
||||
|
||||
bool config_content_node_iget_as_bool(const config_content_node_type * node , int index) {
|
||||
bool value;
|
||||
config_schema_item_assure_type(node->schema , index , CONFIG_BOOL);
|
||||
util_sscanf_bool( config_content_node_iget(node , index) , &value );
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int config_content_node_iget_as_int(const config_content_node_type * node , int index) {
|
||||
int value;
|
||||
config_schema_item_assure_type(node->schema , index , CONFIG_INT);
|
||||
util_sscanf_int( config_content_node_iget(node , index) , &value );
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double config_content_node_iget_as_double(const config_content_node_type * node , int index) {
|
||||
double value;
|
||||
config_schema_item_assure_type(node->schema , index , CONFIG_FLOAT + CONFIG_INT);
|
||||
util_sscanf_double( config_content_node_iget(node , index) , &value );
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const char * config_content_node_iget_as_path(config_content_node_type * node , int index) {
|
||||
config_schema_item_assure_type(node->schema , index , CONFIG_PATH + CONFIG_EXISTING_PATH);
|
||||
{
|
||||
const char * config_value = config_content_node_iget(node , index);
|
||||
char * path_value = config_path_elm_alloc_path( node->cwd , config_value );
|
||||
config_content_node_push_string( node , path_value );
|
||||
|
||||
return path_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char * config_content_node_iget_as_abspath( config_content_node_type * node , int index) {
|
||||
config_schema_item_assure_type(node->schema , index , CONFIG_PATH + CONFIG_EXISTING_PATH);
|
||||
{
|
||||
const char * config_value = config_content_node_iget(node , index);
|
||||
char * path_value = config_path_elm_alloc_abspath( node->cwd , config_value );
|
||||
config_content_node_push_string( node , path_value );
|
||||
|
||||
return path_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char * config_content_node_iget_as_relpath( config_content_node_type * node , int index) {
|
||||
config_schema_item_assure_type(node->schema , index , CONFIG_PATH + CONFIG_EXISTING_PATH);
|
||||
{
|
||||
const char * config_value = config_content_node_iget(node , index);
|
||||
char * path_value = config_path_elm_alloc_relpath( node->cwd , config_value );
|
||||
config_content_node_push_string( node , path_value );
|
||||
|
||||
return path_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const stringlist_type * config_content_node_get_stringlist( const config_content_node_type * node ) {
|
||||
return node->stringlist;
|
||||
}
|
||||
|
||||
|
||||
const char * config_content_node_get_kw( const config_content_node_type * node ) {
|
||||
return config_schema_item_get_kw( node->schema );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int config_content_node_get_size( const config_content_node_type * node ) {
|
||||
return stringlist_get_size( node->stringlist );
|
||||
}
|
||||
|
||||
|
||||
void config_content_node_assert_key_value( const config_content_node_type * node ) {
|
||||
int argc_min , argc_max;
|
||||
config_schema_item_get_argc( node->schema , &argc_min , &argc_max);
|
||||
|
||||
if (!((argc_min == 1) && (argc_min == 1)))
|
||||
util_abort("%s: item:%s before calling config_get_value() functions *without* index you must set argc_min == argc_max = 1 \n",__func__ , config_schema_item_get_kw( node->schema ));
|
||||
}
|
||||
|
||||
|
||||
const config_path_elm_type * config_content_node_get_path_elm( const config_content_node_type * node ) {
|
||||
return node->cwd;
|
||||
}
|
||||
|
||||
/**
|
||||
The node should contain elements of the type:
|
||||
|
||||
KEY1:VALUE1 KEY2:Value2 XX Key3:Val3 Ignored
|
||||
|
||||
Which will be inserted in the opt_hash dictionary as : {"KEY1" :
|
||||
"VALUE1" , ... } Elements which do not conform to this syntax are
|
||||
ignored.
|
||||
*/
|
||||
|
||||
|
||||
void config_content_node_init_opt_hash( const config_content_node_type * node , hash_type * opt_hash , int elm_offset) {
|
||||
int i;
|
||||
for (i = elm_offset; i < config_content_node_get_size( node ); i++)
|
||||
hash_add_option( opt_hash , config_content_node_iget( node , i ));
|
||||
}
|
||||
|
||||
|
||||
void config_content_node_fprintf( const config_content_node_type * node , FILE * stream ) {
|
||||
fprintf(stream , "%s: {" , config_schema_item_get_kw( node->schema ));
|
||||
stringlist_fprintf( node->stringlist , ", " , stream );
|
||||
fprintf(stream , "}\n");
|
||||
}
|
86
ThirdParty/Ert/devel/libconfig/src/config_error.c
vendored
Normal file
86
ThirdParty/Ert/devel/libconfig/src/config_error.c
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_error.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 <stdio.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
|
||||
#include <ert/config/config_error.h>
|
||||
|
||||
struct config_error_struct {
|
||||
stringlist_type * error_list;
|
||||
};
|
||||
|
||||
|
||||
|
||||
config_error_type * config_error_alloc() {
|
||||
config_error_type * error = util_malloc( sizeof * error );
|
||||
error->error_list = stringlist_alloc_new();
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
config_error_type * config_error_alloc_copy( const config_error_type * src_error) {
|
||||
config_error_type * config_error = config_error_alloc();
|
||||
stringlist_deep_copy( config_error->error_list , src_error->error_list );
|
||||
return config_error;
|
||||
}
|
||||
|
||||
|
||||
bool config_error_equal( const config_error_type * error1 , const config_error_type * error2) {
|
||||
return stringlist_equal( error1->error_list , error2->error_list );
|
||||
}
|
||||
|
||||
void config_error_free( config_error_type * error ) {
|
||||
stringlist_free( error->error_list );
|
||||
free( error );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void config_error_add( config_error_type * error , char * new_error) {
|
||||
stringlist_append_owned_ref( error->error_list , new_error );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void config_error_clear( config_error_type * error ) {
|
||||
stringlist_clear( error->error_list );
|
||||
}
|
||||
|
||||
|
||||
int config_error_count( const config_error_type * error ) {
|
||||
return stringlist_get_size( error->error_list );
|
||||
}
|
||||
|
||||
|
||||
const char * config_error_iget( const config_error_type * error , int index) {
|
||||
return stringlist_iget( error->error_list , index );
|
||||
}
|
||||
|
||||
|
||||
void config_error_fprintf( const config_error_type * error , bool add_count , FILE * stream ) {
|
||||
int error_nr;
|
||||
|
||||
for (error_nr = 0; error_nr < stringlist_get_size( error->error_list ); error_nr++) {
|
||||
if (add_count)
|
||||
fprintf(stream , " %02d: " , error_nr);
|
||||
|
||||
fprintf( stream , "%s\n" , stringlist_iget( error->error_list , error_nr));
|
||||
}
|
||||
}
|
114
ThirdParty/Ert/devel/libconfig/src/config_get.c
vendored
Normal file
114
ThirdParty/Ert/devel/libconfig/src/config_get.c
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_get.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.
|
||||
*/
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
/* All the functions in this block will operate on the last item
|
||||
which has been set with a particular key value. So assuming the
|
||||
config file looks like:
|
||||
|
||||
KEY VALUE1
|
||||
KEY VALUE2 OPTIONAL
|
||||
KEY 100 VALUE3 OPTIONAL ERROR
|
||||
|
||||
these functions will all operate on the last line in the config file:
|
||||
|
||||
KEY 100 VALUE3 OPTIONAL ERROR
|
||||
*/
|
||||
|
||||
|
||||
config_content_node_type * config_get_value_node( const config_type * config , const char * kw) {
|
||||
config_content_item_type * item = config_get_content_item(config , kw);
|
||||
if (item != NULL) {
|
||||
config_content_node_type * node = config_content_item_get_last_node( item );
|
||||
config_content_node_assert_key_value( node );
|
||||
return node;
|
||||
} else
|
||||
return NULL; // Will return NULL on unset keywords - must check NULL return value?!
|
||||
}
|
||||
|
||||
static config_content_node_type * config_get_value_node__( const config_type * config , const char * kw) {
|
||||
config_content_node_type * node = config_get_value_node( config , kw );
|
||||
if (node == NULL)
|
||||
util_abort("Tried to get value node from unset kw:%s \n",__func__ , kw );
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
bool config_get_value_as_bool(const config_type * config , const char * kw) {
|
||||
config_content_node_type * node = config_get_value_node__( config , kw );
|
||||
return config_content_node_iget_as_bool(node , 0);
|
||||
}
|
||||
|
||||
int config_get_value_as_int(const config_type * config , const char * kw) {
|
||||
config_content_node_type * node = config_get_value_node__( config , kw );
|
||||
return config_content_node_iget_as_int(node , 0);
|
||||
}
|
||||
|
||||
double config_get_value_as_double(const config_type * config , const char * kw) {
|
||||
config_content_node_type * node = config_get_value_node__( config , kw );
|
||||
return config_content_node_iget_as_double(node , 0);
|
||||
}
|
||||
|
||||
const char * config_get_value_as_path( const config_type * config , const char * kw) {
|
||||
config_content_node_type * node = config_get_value_node__( config , kw );
|
||||
return config_content_node_iget_as_path(node , 0);
|
||||
}
|
||||
|
||||
const char * config_get_value_as_abspath( const config_type * config , const char * kw) {
|
||||
config_content_node_type * node = config_get_value_node__( config , kw );
|
||||
return config_content_node_iget_as_abspath(node , 0);
|
||||
}
|
||||
|
||||
const char * config_get_value_as_relpath( const config_type * config , const char * kw) {
|
||||
config_content_node_type * node = config_get_value_node__( config , kw );
|
||||
return config_content_node_iget_as_relpath(node , 0);
|
||||
}
|
||||
|
||||
|
||||
const char * config_get_value(const config_type * config , const char * kw) {
|
||||
config_content_node_type * node = config_get_value_node__( config , kw );
|
||||
return config_content_node_iget(node , 0);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
int config_get_content_size( const config_type * config ) {
|
||||
return vector_get_size(config->content_list);
|
||||
}
|
||||
|
||||
|
||||
const config_content_node_type * config_iget_content_node( const config_type * config , int index) {
|
||||
return vector_iget_const( config->content_list , index );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int config_get_schema_size( const config_type * config ) {
|
||||
return hash_get_size( config->schema_items );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
config_error_type * config_get_errors( const config_type * config ) {
|
||||
return config->parse_errors;
|
||||
}
|
135
ThirdParty/Ert/devel/libconfig/src/config_path_elm.c
vendored
Normal file
135
ThirdParty/Ert/devel/libconfig/src/config_path_elm.c
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_path_elm.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/config/config_root_path.h>
|
||||
#include <ert/config/config_path_elm.h>
|
||||
|
||||
#define CONFIG_PATH_ELM_TYPE_ID 7100063
|
||||
|
||||
struct config_path_elm_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
char * abs_path; // This will always be absolute
|
||||
char * rel_path; // This will always be relative to the root path.
|
||||
const config_root_path_type * root_path;
|
||||
};
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION( config_path_elm , CONFIG_PATH_ELM_TYPE_ID )
|
||||
|
||||
|
||||
config_path_elm_type * config_path_elm_alloc( const config_root_path_type * root_path , const char * path) {
|
||||
if (root_path != NULL) {
|
||||
config_path_elm_type * path_elm = util_malloc( sizeof * path_elm );
|
||||
UTIL_TYPE_ID_INIT(path_elm , CONFIG_PATH_ELM_TYPE_ID);
|
||||
path_elm->root_path = root_path;
|
||||
if (path == NULL) {
|
||||
path_elm->rel_path = NULL;
|
||||
path_elm->abs_path = util_alloc_string_copy( config_root_path_get_abs_path(root_path) );
|
||||
} else {
|
||||
if (util_is_abs_path( path )) {
|
||||
path_elm->abs_path = util_alloc_string_copy( path );
|
||||
path_elm->rel_path = util_alloc_rel_path( config_root_path_get_abs_path(root_path) , path );
|
||||
} else {
|
||||
path_elm->abs_path = util_alloc_filename( config_root_path_get_abs_path(root_path) , path , NULL );
|
||||
path_elm->rel_path = util_alloc_string_copy( path );
|
||||
}
|
||||
}
|
||||
return path_elm;
|
||||
} else {
|
||||
util_abort("%s: root_path input argument == NULL - invalid \n",__func__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void config_path_elm_free( config_path_elm_type * path_elm ) {
|
||||
util_safe_free( path_elm->rel_path );
|
||||
util_safe_free( path_elm->abs_path );
|
||||
free( path_elm );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void config_path_elm_free__( void * arg ) {
|
||||
config_path_elm_type * path_elm = config_path_elm_safe_cast( arg );
|
||||
config_path_elm_free( path_elm );
|
||||
}
|
||||
|
||||
const config_root_path_type * config_path_elm_get_rootpath( const config_path_elm_type * path_elm ) {
|
||||
return path_elm->root_path;
|
||||
}
|
||||
|
||||
const char * config_path_elm_get_relpath( const config_path_elm_type * path_elm ) {
|
||||
return path_elm->rel_path;
|
||||
}
|
||||
|
||||
const char * config_path_elm_get_abspath( const config_path_elm_type * path_elm ) {
|
||||
return path_elm->abs_path;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
char * config_path_elm_alloc_path(const config_path_elm_type * path_elm , const char * path) {
|
||||
if (util_is_abs_path( path ))
|
||||
return util_alloc_string_copy( path );
|
||||
else {
|
||||
/* This will be relative or absolute depending on the relative/absolute
|
||||
status of the root_path. */
|
||||
const char * input_root = config_root_path_get_input_path( path_elm->root_path );
|
||||
if (input_root == NULL)
|
||||
return util_alloc_filename( path_elm->rel_path , path , NULL);
|
||||
else
|
||||
return util_alloc_joined_string( (const char *[3]) { input_root , path_elm->rel_path , path } , 3 , UTIL_PATH_SEP_STRING );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char * config_path_elm_alloc_relpath(const config_path_elm_type * path_elm , const char * input_path) {
|
||||
if (util_is_abs_path( input_path ))
|
||||
return util_alloc_rel_path( config_root_path_get_rel_path( path_elm->root_path ) , input_path);
|
||||
else {
|
||||
char * abs_path = config_path_elm_alloc_abspath( path_elm , input_path );
|
||||
char * rel_path = util_alloc_rel_path( config_root_path_get_abs_path( path_elm->root_path ) , abs_path );
|
||||
free( abs_path );
|
||||
return rel_path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char * config_path_elm_alloc_abspath(const config_path_elm_type * path_elm , const char * input_path) {
|
||||
if (util_is_abs_path( input_path ))
|
||||
return util_alloc_string_copy( input_path );
|
||||
else {
|
||||
char * abs_path1 = util_alloc_filename( path_elm->abs_path , input_path , NULL );
|
||||
char * abs_path = util_alloc_realpath__( abs_path1 ); // The util_alloc_realpath__() will work also for nonexsting paths
|
||||
free( abs_path1 );
|
||||
return abs_path;
|
||||
}
|
||||
}
|
97
ThirdParty/Ert/devel/libconfig/src/config_root_path.c
vendored
Normal file
97
ThirdParty/Ert/devel/libconfig/src/config_root_path.c
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_root_path.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/config/config_root_path.h>
|
||||
|
||||
struct config_root_path_struct {
|
||||
char * input_path;
|
||||
char * abs_path;
|
||||
char * rel_path;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Input must be an existing directory, which will be used as the
|
||||
root; or NULL in which case cwd will be used as root. The input
|
||||
directory can be both realtive or absolute.
|
||||
*/
|
||||
|
||||
config_root_path_type * config_root_path_alloc( const char * input_path ) {
|
||||
if (input_path == NULL || util_is_directory( input_path )) {
|
||||
config_root_path_type * root_path = util_malloc( sizeof * root_path );
|
||||
{
|
||||
char * cwd = util_alloc_cwd();
|
||||
|
||||
root_path->input_path = util_alloc_string_copy( input_path );
|
||||
if (input_path == NULL) {
|
||||
root_path->rel_path = NULL;
|
||||
root_path->abs_path = util_alloc_string_copy( cwd );
|
||||
} else {
|
||||
if (util_is_abs_path( input_path )) {
|
||||
root_path->abs_path = util_alloc_string_copy( input_path );
|
||||
root_path->rel_path = util_alloc_rel_path( cwd , root_path->abs_path);
|
||||
} else {
|
||||
root_path->rel_path = util_alloc_string_copy( input_path );
|
||||
{
|
||||
char * abs_path = util_alloc_filename( cwd , input_path , NULL );
|
||||
root_path->abs_path = util_alloc_realpath( abs_path );
|
||||
free( abs_path );
|
||||
}
|
||||
}
|
||||
}
|
||||
free( cwd );
|
||||
}
|
||||
return root_path;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void config_root_path_free( config_root_path_type * root_path ) {
|
||||
util_safe_free( root_path->rel_path );
|
||||
util_safe_free( root_path->abs_path );
|
||||
util_safe_free( root_path->input_path );
|
||||
free( root_path );
|
||||
}
|
||||
|
||||
const char * config_root_path_get_input_path( const config_root_path_type * root_path ) {
|
||||
return root_path->input_path;
|
||||
}
|
||||
|
||||
|
||||
const char * config_root_path_get_rel_path( const config_root_path_type * root_path ) {
|
||||
return root_path->rel_path;
|
||||
}
|
||||
|
||||
|
||||
const char * config_root_path_get_abs_path( const config_root_path_type * root_path ) {
|
||||
return root_path->abs_path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
536
ThirdParty/Ert/devel/libconfig/src/config_schema_item.c
vendored
Normal file
536
ThirdParty/Ert/devel/libconfig/src/config_schema_item.c
vendored
Normal file
@ -0,0 +1,536 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_schema_item.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/parser.h>
|
||||
#include <ert/util/hash.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/set.h>
|
||||
#include <ert/util/subst_list.h>
|
||||
#include <ert/util/vector.h>
|
||||
|
||||
#include <ert/config/config_error.h>
|
||||
#include <ert/config/config_schema_item.h>
|
||||
#include <ert/config/config_path_elm.h>
|
||||
|
||||
typedef struct validate_struct validate_type;
|
||||
|
||||
/**
|
||||
This is a 'support-struct' holding various pieces of information
|
||||
needed during the validation process. Observe the following about
|
||||
validation:
|
||||
|
||||
1. It is atomic, in the sense that if you try to an item like this:
|
||||
|
||||
KW ARG1 ARG2 ARG3
|
||||
|
||||
where ARG1 and ARG2 are valid, whereas there is something wrong
|
||||
with ARG3, NOTHING IS SET.
|
||||
|
||||
2. Validation is a two-step process, the first step is run when an
|
||||
item is parsed. This includes checking:
|
||||
|
||||
o The number of argument.
|
||||
o That the arguments have the right type.
|
||||
o That the values match the selection set.
|
||||
|
||||
The second validation step is done when the pasing is complete,
|
||||
in this pass we check dependencies - i.e. required_children and
|
||||
required_children_on_value.
|
||||
|
||||
|
||||
Observe that nothing has-to be set in this struct. There are some dependencies:
|
||||
|
||||
1. Only _one_ of common_selection_set and indexed_selection_set
|
||||
can be set.
|
||||
|
||||
2. If setting indexed_selection_set or type_map, you MUST set
|
||||
argc_max first.
|
||||
*/
|
||||
|
||||
|
||||
struct validate_struct {
|
||||
int argc_min; /* The minimum number of arguments: -1 means no lower limit. */
|
||||
int argc_max; /* The maximum number of arguments: -1 means no upper limit. */
|
||||
set_type * common_selection_set; /* A selection set which will apply uniformly to all the arguments. */
|
||||
set_type ** indexed_selection_set; /* A selection set which will apply for specifi (indexed) arguments. */
|
||||
int_vector_type * type_map; /* A list of types for the items. Set along with argc_minmax(); */
|
||||
stringlist_type * required_children; /* A list of item's which must also be set (if this item is set). (can be NULL) */
|
||||
hash_type * required_children_value; /* A list of item's which must also be set - depending on the value of this item. (can be NULL) (This one is complex). */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define CONFIG_SCHEMA_ITEM_ID 6751
|
||||
struct config_schema_item_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
char * kw; /* The kw which identifies this item· */
|
||||
|
||||
|
||||
bool required_set;
|
||||
stringlist_type * required_children; /* A list of item's which must also be set (if this item is set). (can be NULL) */
|
||||
hash_type * required_children_value; /* A list of item's which must also be set - depending on the value of this item. (can be NULL) */
|
||||
validate_type * validate; /* Information need during validation. */
|
||||
bool expand_envvar; /* Should environment variables like $HOME be expanded?*/
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
static void validate_set_default_type( validate_type * validate , config_item_types item_type) {
|
||||
int_vector_set_default(validate->type_map , item_type);
|
||||
}
|
||||
|
||||
static validate_type * validate_alloc() {
|
||||
validate_type * validate = util_malloc(sizeof * validate );
|
||||
validate->argc_min = CONFIG_DEFAULT_ARG_MIN;
|
||||
validate->argc_max = CONFIG_DEFAULT_ARG_MAX;
|
||||
validate->common_selection_set = NULL;
|
||||
validate->indexed_selection_set = NULL;
|
||||
validate->required_children = NULL;
|
||||
validate->required_children_value = NULL;
|
||||
validate->type_map = int_vector_alloc(0 , 0);
|
||||
validate_set_default_type( validate , CONFIG_STRING );
|
||||
return validate;
|
||||
}
|
||||
|
||||
|
||||
static void validate_free(validate_type * validate) {
|
||||
if (validate->common_selection_set != NULL) set_free(validate->common_selection_set);
|
||||
if (validate->indexed_selection_set != NULL) {
|
||||
for (int i = 0; i < validate->argc_max; i++)
|
||||
if (validate->indexed_selection_set[i] != NULL)
|
||||
set_free(validate->indexed_selection_set[i]);
|
||||
free(validate->indexed_selection_set);
|
||||
}
|
||||
|
||||
int_vector_free( validate->type_map );
|
||||
if (validate->required_children != NULL) stringlist_free(validate->required_children);
|
||||
if (validate->required_children_value != NULL) hash_free(validate->required_children_value);
|
||||
free(validate);
|
||||
}
|
||||
|
||||
|
||||
static void validate_iset_type( validate_type * validate , int index , config_item_types type) {
|
||||
int_vector_iset( validate->type_map , index , type);
|
||||
}
|
||||
|
||||
|
||||
static config_item_types validate_iget_type( const validate_type * validate , int index) {
|
||||
return int_vector_safe_iget( validate->type_map , index );
|
||||
}
|
||||
|
||||
|
||||
static void validate_set_argc_minmax(validate_type * validate , int argc_min , int argc_max) {
|
||||
if (validate->argc_min != CONFIG_DEFAULT_ARG_MIN)
|
||||
util_abort("%s: sorry - current implementation does not allow repeated calls to: %s \n",__func__ , __func__);
|
||||
|
||||
if (argc_min == CONFIG_DEFAULT_ARG_MIN)
|
||||
argc_min = 0;
|
||||
|
||||
validate->argc_min = argc_min;
|
||||
validate->argc_max = argc_max;
|
||||
|
||||
if ((argc_max != CONFIG_DEFAULT_ARG_MAX) && (argc_max < argc_min))
|
||||
util_abort("%s invalid arg min/max values. argc_min:%d argc_max:%d \n",__func__ , argc_min , argc_max);
|
||||
|
||||
{
|
||||
int internal_type_size = 0; /* Should end up in the range [argc_min,argc_max] */
|
||||
|
||||
if (argc_max > 0)
|
||||
internal_type_size = argc_max;
|
||||
else
|
||||
internal_type_size = argc_min;
|
||||
|
||||
if (internal_type_size > 0) {
|
||||
validate->indexed_selection_set = util_calloc( internal_type_size , sizeof * validate->indexed_selection_set );
|
||||
for (int iarg=0; iarg < internal_type_size; iarg++)
|
||||
validate->indexed_selection_set[iarg] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void validate_set_common_selection_set(validate_type * validate , int argc , const char ** argv) {
|
||||
if (validate->common_selection_set != NULL)
|
||||
set_free(validate->common_selection_set);
|
||||
validate->common_selection_set = set_alloc( argc , argv );
|
||||
}
|
||||
|
||||
|
||||
static void validate_set_indexed_selection_set(validate_type * validate , int index , int argc , const char ** argv) {
|
||||
|
||||
if (validate->indexed_selection_set == NULL)
|
||||
util_abort("%s: must call xxx_set_argc_minmax() first - aborting \n",__func__);
|
||||
|
||||
if (index >= validate->argc_min)
|
||||
util_abort("%s: When not not setting argc_max selection set can only be applied to indices up to argc_min\n",__func__);
|
||||
|
||||
if (validate->indexed_selection_set[index] != NULL)
|
||||
set_free(validate->indexed_selection_set[index]);
|
||||
|
||||
validate->indexed_selection_set[index] = set_alloc(argc , argv);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION( config_schema_item , CONFIG_SCHEMA_ITEM_ID)
|
||||
|
||||
void config_schema_item_assure_type(const config_schema_item_type * item , int index , int type_mask) {
|
||||
bool OK = false;
|
||||
|
||||
if (int_vector_safe_iget( item->validate->type_map , index) & type_mask)
|
||||
OK = true;
|
||||
|
||||
if (!OK)
|
||||
util_abort("%s: failed - wrong installed type \n" , __func__);
|
||||
}
|
||||
|
||||
|
||||
config_schema_item_type * config_schema_item_alloc(const char * kw , bool required) {
|
||||
config_schema_item_type * item = util_malloc(sizeof * item );
|
||||
UTIL_TYPE_ID_INIT( item , CONFIG_SCHEMA_ITEM_ID);
|
||||
item->kw = util_alloc_string_copy(kw);
|
||||
|
||||
item->required_set = required;
|
||||
item->required_children = NULL;
|
||||
item->required_children_value = NULL;
|
||||
item->expand_envvar = true; /* Default is to expand $VAR expressions; can be turned off with
|
||||
config_schema_item_set_envvar_expansion( item , false ); */
|
||||
item->validate = validate_alloc();
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static char * __alloc_relocated__(const config_path_elm_type * path_elm , const char * value) {
|
||||
char * file;
|
||||
|
||||
if (util_is_abs_path(value))
|
||||
file = util_alloc_string_copy( value );
|
||||
else
|
||||
file = util_alloc_filename(config_path_elm_get_relpath( path_elm ) , value , NULL);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
bool config_schema_item_validate_set(const config_schema_item_type * item , stringlist_type * token_list , const char * config_file, const config_path_elm_type * path_elm , config_error_type * error_list) {
|
||||
bool OK = true;
|
||||
int argc = stringlist_get_size( token_list ) - 1;
|
||||
if (item->validate->argc_min >= 0) {
|
||||
if (argc < item->validate->argc_min) {
|
||||
OK = false;
|
||||
{
|
||||
char * error_message;
|
||||
if (config_file != NULL)
|
||||
error_message = util_alloc_sprintf("Error when parsing config_file:\"%s\" Keyword:%s must have at least %d arguments.",config_file , item->kw , item->validate->argc_min);
|
||||
else
|
||||
error_message = util_alloc_sprintf("Error:: Keyword:%s must have at least %d arguments.",item->kw , item->validate->argc_min);
|
||||
|
||||
config_error_add( error_list , error_message );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item->validate->argc_max >= 0) {
|
||||
if (argc > item->validate->argc_max) {
|
||||
OK = false;
|
||||
{
|
||||
char * error_message;
|
||||
|
||||
if (config_file != NULL)
|
||||
error_message = util_alloc_sprintf("Error when parsing config_file:\"%s\" Keyword:%s must have maximum %d arguments.",config_file , item->kw , item->validate->argc_max);
|
||||
else
|
||||
error_message = util_alloc_sprintf("Error:: Keyword:%s must have maximum %d arguments.",item->kw , item->validate->argc_max);
|
||||
config_error_add( error_list , error_message );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
OK - now we have verified that the number of arguments is correct. Then
|
||||
we start actually looking at the values.
|
||||
*/
|
||||
if (OK) {
|
||||
/* Validating selection set - first common, then indexed */
|
||||
if (item->validate->common_selection_set) {
|
||||
for (int iarg = 0; iarg < argc; iarg++) {
|
||||
if (!set_has_key(item->validate->common_selection_set , stringlist_iget( token_list , iarg + 1))) {
|
||||
config_error_add( error_list , util_alloc_sprintf("%s: is not a valid value for: %s.",stringlist_iget( token_list , iarg + 1) , item->kw));
|
||||
OK = false;
|
||||
}
|
||||
}
|
||||
} else if (item->validate->indexed_selection_set != NULL) {
|
||||
for (int iarg = 0; iarg < argc; iarg++) {
|
||||
if ((item->validate->argc_max > 0) || (iarg < item->validate->argc_min)) { /* Without this test we might go out of range on the indexed selection set. */
|
||||
if (item->validate->indexed_selection_set[iarg] != NULL) {
|
||||
if (!set_has_key(item->validate->indexed_selection_set[iarg] , stringlist_iget( token_list , iarg + 1))) {
|
||||
config_error_add( error_list , util_alloc_sprintf("%s: is not a valid value for item %d of \'%s\'.",stringlist_iget( token_list , iarg + 1) , iarg + 1 , item->kw));
|
||||
OK = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Observe that the following code might rewrite the content of
|
||||
argv for arguments referring to path locations.
|
||||
*/
|
||||
|
||||
|
||||
/* Validate the TYPE of the various argumnents */
|
||||
{
|
||||
for (int iarg = 0; iarg < argc; iarg++) {
|
||||
const char * value = stringlist_iget(token_list , iarg + 1);
|
||||
switch (validate_iget_type( item->validate , iarg)) {
|
||||
case(CONFIG_STRING): /* This never fails ... */
|
||||
break;
|
||||
case(CONFIG_INT):
|
||||
if (!util_sscanf_int( value , NULL ))
|
||||
config_error_add( error_list , util_alloc_sprintf("Failed to parse:%s as an integer.",value));
|
||||
break;
|
||||
case(CONFIG_FLOAT):
|
||||
if (!util_sscanf_double( value , NULL )) {
|
||||
config_error_add( error_list , util_alloc_sprintf("Failed to parse:%s as a floating point number.", value));
|
||||
OK = false;
|
||||
}
|
||||
break;
|
||||
case(CONFIG_PATH):
|
||||
// As long as we do not reuqire the path to exist it is just a string.
|
||||
break;
|
||||
case(CONFIG_EXISTING_PATH):
|
||||
{
|
||||
char * path = config_path_elm_alloc_abspath( path_elm , value );
|
||||
if (!util_entry_exists(path)) {
|
||||
config_error_add( error_list , util_alloc_sprintf("Can not find entry %s in %s ",value , config_path_elm_get_relpath( path_elm) ));
|
||||
OK = false;
|
||||
}
|
||||
free( path );
|
||||
}
|
||||
break;
|
||||
case(CONFIG_EXECUTABLE):
|
||||
{
|
||||
/*
|
||||
1. If the supplied value is an abolute path - do nothing.
|
||||
2. If the supplied is _not_ an absolute path:
|
||||
|
||||
a. Try if the relocated exists - then use that.
|
||||
b. Else - try if the util_alloc_PATH_executable() exists.
|
||||
*/
|
||||
if (!util_is_abs_path( value )) {
|
||||
char * relocated = __alloc_relocated__(path_elm , value);
|
||||
char * path_exe = util_alloc_PATH_executable( value );
|
||||
|
||||
if (util_file_exists(relocated)) {
|
||||
if (util_is_executable(relocated))
|
||||
stringlist_iset_copy( token_list , iarg , relocated);
|
||||
} else if (path_exe != NULL)
|
||||
stringlist_iset_copy( token_list , iarg , path_exe);
|
||||
else
|
||||
config_error_add( error_list , util_alloc_sprintf("Could not locate executable:%s ", value));
|
||||
|
||||
free(relocated);
|
||||
util_safe_free(path_exe);
|
||||
} else {
|
||||
if (!util_is_executable( value ))
|
||||
config_error_add( error_list , util_alloc_sprintf("Could not locate executable:%s ", value));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case(CONFIG_BOOL):
|
||||
if (!util_sscanf_bool( value , NULL )) {
|
||||
config_error_add( error_list , util_alloc_sprintf("Failed to parse:%s as a boolean.", value));
|
||||
OK = false;
|
||||
}
|
||||
break;
|
||||
case(CONFIG_BYTESIZE):
|
||||
if (!util_sscanf_bytesize( value , NULL)) {
|
||||
config_error_add( error_list , util_alloc_sprintf("Failed to parse:\"%s\" as number of bytes." , value));
|
||||
OK = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
util_abort("%s: config_item_type:%d not recognized \n",__func__ , validate_iget_type(item->validate , iarg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
void config_schema_item_free( config_schema_item_type * item) {
|
||||
free(item->kw);
|
||||
if (item->required_children != NULL) stringlist_free(item->required_children);
|
||||
if (item->required_children_value != NULL) hash_free(item->required_children_value);
|
||||
validate_free(item->validate);
|
||||
free(item);
|
||||
}
|
||||
|
||||
|
||||
void config_schema_item_free__ (void * void_item) {
|
||||
config_schema_item_type * item = config_schema_item_safe_cast( void_item );
|
||||
config_schema_item_free( item );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void config_schema_item_set_required_children_on_value(config_schema_item_type * item , const char * value , stringlist_type * child_list) {
|
||||
if (item->required_children_value == NULL)
|
||||
item->required_children_value = hash_alloc();
|
||||
hash_insert_hash_owned_ref( item->required_children_value , value , stringlist_alloc_deep_copy(child_list) , stringlist_free__);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
This function is used to set the minimum and maximum number of
|
||||
arguments for an item. In addition you can pass in a pointer to an
|
||||
array of config_schema_item_types values which will be used for validation
|
||||
of the input. This vector must be argc_max elements long; it can be
|
||||
NULL.
|
||||
*/
|
||||
|
||||
|
||||
void config_schema_item_set_argc_minmax(config_schema_item_type * item ,
|
||||
int argc_min ,
|
||||
int argc_max) {
|
||||
|
||||
validate_set_argc_minmax(item->validate , argc_min , argc_max);
|
||||
|
||||
}
|
||||
|
||||
void config_schema_item_iset_type( config_schema_item_type * item , int index , config_item_types type) {
|
||||
validate_iset_type( item->validate , index , type );
|
||||
}
|
||||
|
||||
void config_schema_item_set_default_type( config_schema_item_type * item , config_item_types type) {
|
||||
validate_set_default_type( item->validate , type );
|
||||
}
|
||||
|
||||
|
||||
config_item_types config_schema_item_iget_type(const config_schema_item_type * item , int index ) {
|
||||
return validate_iget_type( item->validate , index );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void config_schema_item_set_envvar_expansion( config_schema_item_type * item , bool expand_envvar ) {
|
||||
item->expand_envvar = expand_envvar;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void config_schema_item_set_common_selection_set(config_schema_item_type * item , int argc , const char ** argv) {
|
||||
validate_set_common_selection_set(item->validate , argc , argv);
|
||||
}
|
||||
|
||||
void config_schema_item_set_indexed_selection_set(config_schema_item_type * item , int index , int argc , const char ** argv) {
|
||||
validate_set_indexed_selection_set(item->validate , index , argc , argv);
|
||||
}
|
||||
|
||||
|
||||
void config_schema_item_set_required_children(config_schema_item_type * item , stringlist_type * stringlist) {
|
||||
item->required_children = stringlist_alloc_deep_copy(stringlist);
|
||||
}
|
||||
|
||||
void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key) {
|
||||
if (item->required_children == NULL)
|
||||
item->required_children = stringlist_alloc_new();
|
||||
|
||||
stringlist_append_copy( item->required_children , child_key );
|
||||
}
|
||||
|
||||
|
||||
int config_schema_item_num_required_children(const config_schema_item_type * item) {
|
||||
if (item->required_children == NULL)
|
||||
return 0;
|
||||
else
|
||||
return stringlist_get_size( item->required_children );
|
||||
}
|
||||
|
||||
|
||||
const char * config_schema_item_iget_required_child( const config_schema_item_type * item , int index) {
|
||||
return stringlist_iget( item->required_children , index );
|
||||
}
|
||||
|
||||
|
||||
const char * config_schema_item_get_kw( const config_schema_item_type * item ) {
|
||||
return item->kw;
|
||||
}
|
||||
|
||||
|
||||
bool config_schema_item_required( const config_schema_item_type * item ) {
|
||||
return item->required_set;
|
||||
}
|
||||
|
||||
|
||||
bool config_schema_item_expand_envvar( const config_schema_item_type * item ) {
|
||||
return item->expand_envvar;
|
||||
}
|
||||
|
||||
|
||||
void config_schema_item_get_argc( const config_schema_item_type * item , int *argc_min , int *argc_max) {
|
||||
*argc_min = item->validate->argc_min;
|
||||
*argc_max = item->validate->argc_max;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool config_schema_item_has_required_children_value( const config_schema_item_type * item ) {
|
||||
if (item->required_children_value == NULL)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
stringlist_type * config_schema_item_get_required_children_value(const config_schema_item_type * item , const char * value) {
|
||||
return hash_safe_get( item->required_children_value , value );
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
/* 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);
|
||||
}
|
49
ThirdParty/Ert/devel/libconfig/tests/CMakeLists.txt
vendored
Normal file
49
ThirdParty/Ert/devel/libconfig/tests/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
add_executable( config_append_test config_append_test.c )
|
||||
target_link_libraries( config_append_test config )
|
||||
|
||||
add_executable( config_node_test config_node_test.c )
|
||||
target_link_libraries( config_node_test config )
|
||||
|
||||
add_executable( config_typeOK config_typeOK.c )
|
||||
target_link_libraries( config_typeOK config )
|
||||
|
||||
add_executable( config_typeFail config_typeFail.c )
|
||||
target_link_libraries( config_typeFail config )
|
||||
|
||||
add_executable( config_path_elm config_path_elm.c )
|
||||
target_link_libraries( config_path_elm config )
|
||||
|
||||
add_executable( config_root_path config_root_path.c )
|
||||
target_link_libraries( config_root_path config )
|
||||
|
||||
add_executable( config_include_test config_include_test.c)
|
||||
target_link_libraries( config_include_test config)
|
||||
|
||||
add_executable( config_content_node config_content_node.c)
|
||||
target_link_libraries( config_content_node config)
|
||||
|
||||
add_executable( config_content_item config_content_item.c)
|
||||
target_link_libraries( config_content_item config)
|
||||
|
||||
add_executable( config_error config_error.c)
|
||||
target_link_libraries( config_error config)
|
||||
add_test( config_error ${EXECUTABLE_OUTPUT_PATH}/config_error )
|
||||
|
||||
|
||||
add_executable( config_config config_config.c)
|
||||
target_link_libraries( config_config config)
|
||||
add_test( config_config ${EXECUTABLE_OUTPUT_PATH}/config_config )
|
||||
|
||||
add_executable( config_schema_item config_schema_item.c)
|
||||
target_link_libraries( config_schema_item config)
|
||||
add_test( config_schema_item ${EXECUTABLE_OUTPUT_PATH}/config_schema_item )
|
||||
|
||||
add_test( config_typeOK ${EXECUTABLE_OUTPUT_PATH}/config_typeOK ${CMAKE_CURRENT_SOURCE_DIR}/data/type_testOK )
|
||||
add_test( config_typeFail ${EXECUTABLE_OUTPUT_PATH}/config_typeFail ${CMAKE_CURRENT_SOURCE_DIR}/data/type_testFail )
|
||||
add_test( config_append_test ${EXECUTABLE_OUTPUT_PATH}/config_append_test ${CMAKE_CURRENT_SOURCE_DIR}/data/append_test )
|
||||
add_test( config_node_test ${EXECUTABLE_OUTPUT_PATH}/config_node_test ${CMAKE_CURRENT_SOURCE_DIR}/data/append_test )
|
||||
add_test( config_path_elm ${EXECUTABLE_OUTPUT_PATH}/config_path_elm )
|
||||
add_test( config_content_node ${EXECUTABLE_OUTPUT_PATH}/config_content_node )
|
||||
add_test( config_content_item ${EXECUTABLE_OUTPUT_PATH}/config_content_item ${CMAKE_CURRENT_SOURCE_DIR}/data/content_item_test)
|
||||
add_test( config_include_test ${EXECUTABLE_OUTPUT_PATH}/config_include_test ${CMAKE_CURRENT_SOURCE_DIR}/data include_test )
|
||||
add_test( config_root_path ${EXECUTABLE_OUTPUT_PATH}/config_root_path ${CMAKE_CURRENT_SOURCE_DIR}/data )
|
47
ThirdParty/Ert/devel/libconfig/tests/config_append_test.c
vendored
Normal file
47
ThirdParty/Ert/devel/libconfig/tests/config_append_test.c
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_append_test.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/config/config.h>
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * config_file = argv[1];
|
||||
config_type * config = config_alloc();
|
||||
bool OK;
|
||||
config_schema_item_type * item = config_add_schema_item(config , "APPEND" , false );
|
||||
config_schema_item_set_argc_minmax( item , 1 , 1);
|
||||
|
||||
test_assert_true(config_parse(config , config_file , "--" , NULL , NULL , false , true ));
|
||||
|
||||
{
|
||||
test_assert_int_equal( config_get_occurences( config , "APPEND" ) , 3);
|
||||
{
|
||||
const char * value = config_get_value( config , "APPEND");
|
||||
test_assert_string_equal( value , "VALUE3");
|
||||
}
|
||||
}
|
||||
|
||||
test_assert_false( config_parse( config , "DoesNotExist" , "--" , NULL , NULL , false , true));
|
||||
exit(0);
|
||||
}
|
36
ThirdParty/Ert/devel/libconfig/tests/config_config.c
vendored
Normal file
36
ThirdParty/Ert/devel/libconfig/tests/config_config.c
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_config.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/config/config.h>
|
||||
#include <ert/config/config_schema_item.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
config_type * config = config_alloc();
|
||||
config_schema_item_type * schema_item = config_add_schema_item( config , "KEYWORD" , false );
|
||||
config_free( config );
|
||||
exit(0);
|
||||
}
|
||||
|
58
ThirdParty/Ert/devel/libconfig/tests/config_content_item.c
vendored
Normal file
58
ThirdParty/Ert/devel/libconfig/tests/config_content_item.c
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_content_item.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/hash.h>
|
||||
|
||||
#include <ert/config/config.h>
|
||||
#include <ert/config/config_content_node.h>
|
||||
#include <ert/config/config_schema_item.h>
|
||||
#include <ert/config/config_path_elm.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * config_file = argv[1];
|
||||
config_type * config = config_alloc();
|
||||
|
||||
config_add_schema_item( config , "SET" , true );
|
||||
config_add_schema_item( config , "NOTSET" , false );
|
||||
|
||||
test_assert_true( config_parse( config , config_file , "--" , "INCLUDE" , NULL , CONFIG_UNRECOGNIZED_IGNORE , true ));
|
||||
|
||||
test_assert_not_NULL( config_get_content_item( config , "SET" ));
|
||||
test_assert_NULL( config_get_content_item( config , "NOTSET" ) );
|
||||
test_assert_NULL( config_get_content_item( config , "UNKNOWN" ) );
|
||||
|
||||
test_assert_true( config_has_schema_item( config , "SET" ));
|
||||
test_assert_true( config_has_schema_item( config , "NOTSET" ));
|
||||
test_assert_false( config_has_schema_item( config , "UNKNOWN" ));
|
||||
|
||||
test_assert_true( config_has_content_item( config , "SET" ));
|
||||
test_assert_false( config_has_content_item( config , "NOTSET" ));
|
||||
test_assert_false( config_has_content_item( config , "UNKNOWN" ));
|
||||
|
||||
|
||||
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
76
ThirdParty/Ert/devel/libconfig/tests/config_content_node.c
vendored
Normal file
76
ThirdParty/Ert/devel/libconfig/tests/config_content_node.c
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_content_node.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/hash.h>
|
||||
|
||||
#include <ert/config/config_content_node.h>
|
||||
#include <ert/config/config_schema_item.h>
|
||||
#include <ert/config/config_path_elm.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
config_schema_item_type * schema = config_schema_item_alloc("TEST" , true);
|
||||
config_root_path_type * root_path = config_root_path_alloc( NULL );
|
||||
config_path_elm_type * cwd = config_path_elm_alloc( root_path , NULL );
|
||||
{
|
||||
config_content_node_type * node = config_content_node_alloc( schema , cwd );
|
||||
config_content_node_add_value( node , "KEY1:VALUE1" );
|
||||
config_content_node_add_value( node , "KEY2:VALUE2" );
|
||||
config_content_node_add_value( node , "KEY3:VALUE3" );
|
||||
config_content_node_add_value( node , "KEYVALUE" );
|
||||
|
||||
test_assert_int_equal( config_content_node_get_size( node ) , 4 );
|
||||
test_assert_string_equal( config_content_node_iget( node , 0 ) , "KEY1:VALUE1" );
|
||||
test_assert_string_equal( config_content_node_iget( node , 2 ) , "KEY3:VALUE3" );
|
||||
|
||||
test_assert_string_equal( config_content_node_get_full_string( node , ",") , "KEY1:VALUE1,KEY2:VALUE2,KEY3:VALUE3,KEYVALUE");
|
||||
|
||||
{
|
||||
hash_type * opt_hash = hash_alloc( );
|
||||
{
|
||||
config_content_node_init_opt_hash( node , opt_hash , 0 );
|
||||
test_assert_int_equal( hash_get_size( opt_hash ) , 3 );
|
||||
test_assert_string_equal( hash_get( opt_hash , "KEY1" ) , "VALUE1" );
|
||||
test_assert_string_equal( hash_get( opt_hash , "KEY3" ) , "VALUE3" );
|
||||
}
|
||||
|
||||
hash_clear( opt_hash );
|
||||
test_assert_int_equal( hash_get_size( opt_hash ) , 0 );
|
||||
config_content_node_init_opt_hash( node , opt_hash , 1 );
|
||||
test_assert_int_equal( hash_get_size( opt_hash ) , 2 );
|
||||
test_assert_string_equal( hash_get( opt_hash , "KEY2" ) , "VALUE2" );
|
||||
test_assert_string_equal( hash_get( opt_hash , "KEY3" ) , "VALUE3" );
|
||||
test_assert_false( hash_has_key( opt_hash , "KEY1" ) );
|
||||
test_assert_false( hash_has_key( opt_hash , "KEYVALUE" ) );
|
||||
hash_free( opt_hash );
|
||||
}
|
||||
|
||||
|
||||
config_content_node_free( node );
|
||||
}
|
||||
config_path_elm_free( cwd );
|
||||
config_root_path_free( root_path );
|
||||
config_schema_item_free( schema );
|
||||
exit(0);
|
||||
}
|
||||
|
43
ThirdParty/Ert/devel/libconfig/tests/config_error.c
vendored
Normal file
43
ThirdParty/Ert/devel/libconfig/tests/config_error.c
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_error.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/config/config_error.h>
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
config_error_type * config_error = config_error_alloc();
|
||||
|
||||
{
|
||||
config_error_type * error_copy = config_error_alloc_copy( config_error );
|
||||
|
||||
test_assert_true( config_error_equal( config_error , error_copy ));
|
||||
test_assert_ptr_not_equal( config_error , error_copy );
|
||||
|
||||
config_error_free( error_copy );
|
||||
}
|
||||
|
||||
config_error_free( config_error );
|
||||
exit(0);
|
||||
}
|
||||
|
133
ThirdParty/Ert/devel/libconfig/tests/config_include_test.c
vendored
Normal file
133
ThirdParty/Ert/devel/libconfig/tests/config_include_test.c
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_include_test.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/path_stack.h>
|
||||
|
||||
#include <ert/config/config.h>
|
||||
#include <ert/config/config_schema_item.h>
|
||||
|
||||
void parse_test(config_type * config ,
|
||||
const char * root_path , // The new working directory - the test will start by chdir() here.
|
||||
const char * config_file ) { // The config_file, either as an absolute path - or relative from root_path
|
||||
|
||||
#ifdef ERT_LINUX
|
||||
const char * path0 = "PATH0";
|
||||
const char * path1 = "path/PATH1";
|
||||
const char * path2 = "path/PATH2";
|
||||
const char * path3 = "path/subpath/PATH3";
|
||||
const char * path4 = "path/subpath/subsubpath/PATH4";
|
||||
#endif
|
||||
|
||||
|
||||
char * config_path, *config_rel_path,*config_abs_path;
|
||||
path_stack_type * path_stack = path_stack_alloc();
|
||||
|
||||
util_alloc_file_components( config_file , &config_path , NULL , NULL);
|
||||
path_stack_push( path_stack , NULL );
|
||||
if (root_path != NULL)
|
||||
chdir( root_path );
|
||||
|
||||
config_abs_path = util_alloc_abs_path( config_path );
|
||||
config_rel_path = util_alloc_rel_path( NULL , config_abs_path);
|
||||
|
||||
{
|
||||
config_clear( config );
|
||||
if (config_parse( config , config_file , "--" , "INCLUDE" , NULL , CONFIG_UNRECOGNIZED_IGNORE , true )) {
|
||||
|
||||
char * relpath0 = util_alloc_filename( config_rel_path , path0, NULL);
|
||||
char * relpath1 = util_alloc_filename( config_rel_path , path1, NULL);
|
||||
char * relpath2 = util_alloc_filename( config_rel_path , path2, NULL);
|
||||
char * relpath3 = util_alloc_filename( config_rel_path , path3, NULL);
|
||||
char * relpath4 = util_alloc_filename( config_rel_path , path4, NULL);
|
||||
|
||||
char * abspath0 = util_alloc_filename( config_abs_path , path0, NULL);
|
||||
char * abspath1 = util_alloc_filename( config_abs_path , path1, NULL);
|
||||
char * abspath2 = util_alloc_filename( config_abs_path , path2, NULL);
|
||||
char * abspath3 = util_alloc_filename( config_abs_path , path3, NULL);
|
||||
char * abspath4 = util_alloc_filename( config_abs_path , path4, NULL);
|
||||
|
||||
test_assert_string_equal(config_get_value_as_relpath(config , "PATH0") , relpath0 );
|
||||
test_assert_string_equal(config_get_value_as_relpath(config , "PATH1") , relpath1 );
|
||||
test_assert_string_equal(config_get_value_as_relpath(config , "PATH2") , relpath2 );
|
||||
test_assert_string_equal(config_get_value_as_relpath(config , "PATH3") , relpath3 );
|
||||
test_assert_string_equal(config_get_value_as_relpath(config , "PATH4") , relpath4 );
|
||||
|
||||
test_assert_string_equal(config_get_value_as_abspath(config , "PATH0") , abspath0 );
|
||||
test_assert_string_equal(config_get_value_as_abspath(config , "PATH1") , abspath1 );
|
||||
test_assert_string_equal(config_get_value_as_abspath(config , "PATH2") , abspath2 );
|
||||
test_assert_string_equal(config_get_value_as_abspath(config , "PATH3") , abspath3 );
|
||||
test_assert_string_equal(config_get_value_as_abspath(config , "PATH4") , abspath4 );
|
||||
|
||||
} else {
|
||||
config_error_type * error = config_get_errors( config );
|
||||
config_error_fprintf( error , true , stdout );
|
||||
test_error_exit("Hmm - parsing %s failed \n", config_file );
|
||||
}
|
||||
}
|
||||
path_stack_pop( path_stack );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * abs_path = argv[1];
|
||||
const char * config_file = argv[2];
|
||||
char * abs_config_file = util_alloc_filename( abs_path , config_file , NULL);
|
||||
config_type * config = config_alloc();
|
||||
|
||||
{
|
||||
config_schema_item_type * schema_item;
|
||||
|
||||
schema_item = config_add_schema_item( config , "PATH0" , true );
|
||||
config_schema_item_set_argc_minmax( schema_item , 1 , 1 );
|
||||
config_schema_item_iset_type( schema_item , 0 , CONFIG_PATH );
|
||||
|
||||
schema_item = config_add_schema_item( config , "PATH1" , true );
|
||||
config_schema_item_set_argc_minmax( schema_item , 1 , 1 );
|
||||
config_schema_item_iset_type( schema_item , 0 , CONFIG_PATH );
|
||||
|
||||
schema_item = config_add_schema_item( config , "PATH2" , true );
|
||||
config_schema_item_set_argc_minmax( schema_item , 1 , 1 );
|
||||
config_schema_item_iset_type( schema_item , 0 , CONFIG_PATH );
|
||||
|
||||
schema_item = config_add_schema_item( config , "PATH3" , true );
|
||||
config_schema_item_set_argc_minmax( schema_item , 1 , 1 );
|
||||
config_schema_item_iset_type( schema_item , 0 , CONFIG_PATH );
|
||||
|
||||
schema_item = config_add_schema_item( config , "PATH4" , true );
|
||||
config_schema_item_set_argc_minmax( schema_item , 1 , 1 );
|
||||
config_schema_item_iset_type( schema_item , 0 , CONFIG_PATH );
|
||||
}
|
||||
|
||||
parse_test( config , abs_path , config_file );
|
||||
parse_test( config , abs_path , abs_config_file );
|
||||
parse_test( config , NULL , abs_config_file );
|
||||
parse_test( config , "../../" , abs_config_file );
|
||||
|
||||
config_free( config );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
55
ThirdParty/Ert/devel/libconfig/tests/config_node_test.c
vendored
Normal file
55
ThirdParty/Ert/devel/libconfig/tests/config_node_test.c
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_node_test.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/config/config.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * config_file = argv[1];
|
||||
config_type * config = config_alloc();
|
||||
bool OK;
|
||||
{
|
||||
config_schema_item_type * item = config_add_schema_item(config , "APPEND" , false );
|
||||
config_schema_item_set_argc_minmax( item , 1 , 1);
|
||||
}
|
||||
config_add_schema_item(config , "NEXT" , false );
|
||||
|
||||
OK = config_parse(config , config_file , "--" , NULL , NULL , false , true );
|
||||
|
||||
if (OK) {
|
||||
if (config_get_content_size( config ) == 4) {
|
||||
const config_content_node_type * node0 = config_iget_content_node( config , 0 );
|
||||
if (strcmp( config_content_node_get_kw( node0 ) , "APPEND") == 0) {
|
||||
if (config_content_node_get_size(node0) == 1) {
|
||||
const config_content_node_type * node3 = config_iget_content_node( config , 3 );
|
||||
if (strcmp( config_content_node_get_kw( node3 ) , "NEXT") == 0) {
|
||||
if (config_content_node_get_size(node3) == 2) {
|
||||
exit(0);
|
||||
} else printf("Size error node3\n");
|
||||
} else printf("kw error node3 \n");
|
||||
} else printf("Size error node0\n");
|
||||
} else printf("kw error node0 kw:%s \n", config_content_node_get_kw( node0 ));
|
||||
} else printf("Size error \n");
|
||||
} else printf("Parse error");
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
92
ThirdParty/Ert/devel/libconfig/tests/config_path_elm.c
vendored
Normal file
92
ThirdParty/Ert/devel/libconfig/tests/config_path_elm.c
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_path_elm.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/config/config.h>
|
||||
#include <ert/config/config_path_elm.h>
|
||||
#include <ert/config/config_root_path.h>
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
#ifdef ERT_LINUX
|
||||
const char * root = "/tmp/root";
|
||||
const char * rel_path = "rel/path";
|
||||
const char * abs_path = "/tmp/root/rel/path";
|
||||
const char * rel_true = "rel/path/XXX";
|
||||
const char * abs_true = "/tmp/root/rel/path/XXX";
|
||||
const char * path_true1 = "rel/path/XXX";
|
||||
const char * path_true2 = "/tmp/root/rel/path/XXX";
|
||||
|
||||
#endif
|
||||
|
||||
util_make_path( root );
|
||||
config_root_path_type * root_path = config_root_path_alloc( root );
|
||||
{
|
||||
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path );
|
||||
|
||||
test_assert_string_equal( config_path_elm_get_relpath( path_elm ) , rel_path );
|
||||
test_assert_string_equal( config_path_elm_get_abspath( path_elm ) , abs_path );
|
||||
|
||||
test_assert_string_equal( config_path_elm_alloc_relpath( path_elm , "XXX" ) , rel_true);
|
||||
test_assert_string_equal( config_path_elm_alloc_abspath( path_elm , "XXX" ) , abs_true);
|
||||
test_assert_string_equal( config_path_elm_alloc_path( path_elm , "XXX" ) , path_true2 );
|
||||
|
||||
|
||||
config_path_elm_free( path_elm );
|
||||
}
|
||||
printf("test1 OK \n");
|
||||
{
|
||||
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , abs_path );
|
||||
|
||||
test_assert_string_equal( config_path_elm_get_relpath( path_elm ) , rel_path );
|
||||
test_assert_string_equal( config_path_elm_get_abspath( path_elm ) , abs_path );
|
||||
|
||||
test_assert_string_equal( config_path_elm_alloc_relpath( path_elm , "XXX" ) , rel_true);
|
||||
test_assert_string_equal( config_path_elm_alloc_abspath( path_elm , "XXX" ) , abs_true);
|
||||
test_assert_string_equal( config_path_elm_alloc_path( path_elm , "XXX" ) , path_true2 );
|
||||
|
||||
config_path_elm_free( path_elm );
|
||||
}
|
||||
printf("test2 OK \n");
|
||||
config_root_path_free( root_path );
|
||||
|
||||
chdir( root );
|
||||
root_path = config_root_path_alloc( NULL );
|
||||
{
|
||||
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path );
|
||||
|
||||
test_assert_string_equal( config_path_elm_get_relpath( path_elm ) , rel_path );
|
||||
test_assert_string_equal( config_path_elm_get_abspath( path_elm ) , abs_path );
|
||||
|
||||
test_assert_string_equal( config_path_elm_alloc_relpath( path_elm , "XXX" ) , rel_true);
|
||||
test_assert_string_equal( config_path_elm_alloc_abspath( path_elm , "XXX" ) , abs_true);
|
||||
test_assert_string_equal( config_path_elm_alloc_path( path_elm , "XXX" ) , path_true1 );
|
||||
|
||||
|
||||
config_path_elm_free( path_elm );
|
||||
}
|
||||
printf("test3 OK \n");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
88
ThirdParty/Ert/devel/libconfig/tests/config_root_path.c
vendored
Normal file
88
ThirdParty/Ert/devel/libconfig/tests/config_root_path.c
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_root_path.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/config/config.h>
|
||||
#include <ert/config/config_root_path.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
#ifdef ERT_LINUX
|
||||
const char * root = "/tmp/root";
|
||||
const char * rel_path = "rel/path";
|
||||
const char * abs_path = "/tmp/root/abs/path";
|
||||
const char * rel_true = "rel/path/XXX";
|
||||
const char * abs_true = "/tmp/root/rel/path/XXX";
|
||||
const char * path_true1 = "rel/path/XXX";
|
||||
const char * path_true2 = "/tmp/root/rel/path/XXX";
|
||||
#endif
|
||||
|
||||
char * cwd = util_alloc_cwd();
|
||||
|
||||
{
|
||||
config_root_path_type * root_path = config_root_path_alloc( NULL );
|
||||
|
||||
if (!test_string_equal( config_root_path_get_abs_path( root_path ) , cwd ))
|
||||
test_error_exit("abs:path:%s expeceted:%s \n",config_root_path_get_abs_path( root_path ) , cwd );
|
||||
|
||||
if (!test_string_equal( config_root_path_get_input_path( root_path ) , NULL ))
|
||||
test_error_exit("input:path:%s expeceted:%s \n",config_root_path_get_input_path( root_path ) , NULL );
|
||||
|
||||
if (!test_string_equal( config_root_path_get_rel_path( root_path ) , NULL ))
|
||||
test_error_exit("rel:path:%s expeceted:%s \n",config_root_path_get_rel_path( root_path ) , NULL );
|
||||
|
||||
|
||||
config_root_path_free( root_path );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
config_root_path_type * root_path = config_root_path_alloc( "/does/not/exist" );
|
||||
if (root_path != NULL)
|
||||
test_error_exit("Created root_path instance for not-existing input \n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
const char * input_path = argv[1];
|
||||
char * cwd = util_alloc_cwd();
|
||||
char * rel_path = util_alloc_rel_path( cwd , input_path );
|
||||
|
||||
config_root_path_type * root_path1 = config_root_path_alloc( input_path );
|
||||
config_root_path_type * root_path2 = config_root_path_alloc( rel_path );
|
||||
|
||||
if (!test_string_equal( config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2 )))
|
||||
test_error_exit("Rel: %s != %s \n",config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2));
|
||||
|
||||
if (!test_string_equal( config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 )))
|
||||
test_error_exit("Abs: %s != %s \n",config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 ));
|
||||
|
||||
config_root_path_free( root_path1 );
|
||||
config_root_path_free( root_path2 );
|
||||
}
|
||||
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
48
ThirdParty/Ert/devel/libconfig/tests/config_schema_item.c
vendored
Normal file
48
ThirdParty/Ert/devel/libconfig/tests/config_schema_item.c
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_schema_item.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/config/config_schema_item.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
config_schema_item_type * schema_item = config_schema_item_alloc( "KW" , false );
|
||||
|
||||
test_assert_int_equal( config_schema_item_iget_type( schema_item , 1 ) , CONFIG_STRING );
|
||||
test_assert_int_equal( config_schema_item_iget_type( schema_item , 2 ) , CONFIG_STRING );
|
||||
|
||||
config_schema_item_iset_type( schema_item , 0 , CONFIG_INT );
|
||||
config_schema_item_iset_type( schema_item , 5 , CONFIG_BOOL );
|
||||
|
||||
|
||||
test_assert_int_equal( config_schema_item_iget_type( schema_item , 0 ) , CONFIG_INT );
|
||||
test_assert_int_equal( config_schema_item_iget_type( schema_item , 1 ) , CONFIG_STRING );
|
||||
test_assert_int_equal( config_schema_item_iget_type( schema_item , 2 ) , CONFIG_STRING );
|
||||
test_assert_int_equal( config_schema_item_iget_type( schema_item , 5 ) , CONFIG_BOOL );
|
||||
|
||||
config_schema_item_set_default_type( schema_item , CONFIG_FLOAT );
|
||||
test_assert_int_equal( config_schema_item_iget_type( schema_item , 7 ) , CONFIG_FLOAT );
|
||||
|
||||
config_schema_item_free( schema_item );
|
||||
exit(0);
|
||||
}
|
||||
|
67
ThirdParty/Ert/devel/libconfig/tests/config_typeFail.c
vendored
Normal file
67
ThirdParty/Ert/devel/libconfig/tests/config_typeFail.c
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_typeFail.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/config/config_error.h>
|
||||
#include <ert/config/config.h>
|
||||
|
||||
|
||||
void error(char * msg) {
|
||||
fprintf(stderr , msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * config_file = argv[1];
|
||||
config_type * config = config_alloc();
|
||||
bool OK;
|
||||
{
|
||||
config_schema_item_type * item = config_add_schema_item(config , "TYPES_KEY" , false );
|
||||
config_schema_item_set_argc_minmax( item , 4 , 4 );
|
||||
config_schema_item_iset_type( item , 0 , CONFIG_INT );
|
||||
config_schema_item_iset_type( item , 1 , CONFIG_FLOAT );
|
||||
config_schema_item_iset_type( item , 2 , CONFIG_BOOL );
|
||||
|
||||
item = config_add_schema_item( config , "SHORT_KEY" , false );
|
||||
config_schema_item_set_argc_minmax( item , 1 , 1 );
|
||||
|
||||
item = config_add_schema_item( config , "LONG_KEY" , false );
|
||||
config_schema_item_set_argc_minmax( item , 3 , CONFIG_DEFAULT_ARG_MAX);
|
||||
}
|
||||
OK = config_parse(config , config_file , "--" , NULL , NULL , false , true );
|
||||
|
||||
if (OK) {
|
||||
error("Parse error\n");
|
||||
} else {
|
||||
config_error_type * cerror = config_get_errors( config );
|
||||
if (config_error_count( cerror ) > 0) {
|
||||
int i;
|
||||
for (i=0; i < config_error_count( cerror ); i++) {
|
||||
printf("Error %d: %s \n",i , config_error_iget( cerror , i ));
|
||||
}
|
||||
}
|
||||
printf("Error count:%d \n",config_error_count( cerror ));
|
||||
if (config_error_count( cerror ) != 5)
|
||||
error("Wrong error count\n");
|
||||
}
|
||||
printf("OK \n");
|
||||
exit(0);
|
||||
}
|
||||
|
55
ThirdParty/Ert/devel/libconfig/tests/config_typeOK.c
vendored
Normal file
55
ThirdParty/Ert/devel/libconfig/tests/config_typeOK.c
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'config_typeOK.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/config/config.h>
|
||||
|
||||
|
||||
void error(char * msg) {
|
||||
fprintf(stderr , msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * config_file = argv[1];
|
||||
config_type * config = config_alloc();
|
||||
bool OK;
|
||||
{
|
||||
config_schema_item_type * item = config_add_schema_item(config , "TYPE_KEY" , false );
|
||||
config_schema_item_set_argc_minmax( item , 4 , 4 );
|
||||
config_schema_item_iset_type( item , 0 , CONFIG_INT );
|
||||
config_schema_item_iset_type( item , 1 , CONFIG_FLOAT );
|
||||
config_schema_item_iset_type( item , 2 , CONFIG_BOOL );
|
||||
|
||||
item = config_add_schema_item( config , "SHORT_KEY" , false );
|
||||
config_schema_item_set_argc_minmax( item , 1 , 1 );
|
||||
|
||||
item = config_add_schema_item( config , "LONG_KEY" , false );
|
||||
config_schema_item_set_argc_minmax( item , 3 , CONFIG_DEFAULT_ARG_MAX );
|
||||
}
|
||||
OK = config_parse(config , config_file , "--" , NULL , NULL , false , true );
|
||||
|
||||
if (OK) {
|
||||
|
||||
} else error("Parse error\n");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
4
ThirdParty/Ert/devel/libconfig/tests/data/append_test
vendored
Normal file
4
ThirdParty/Ert/devel/libconfig/tests/data/append_test
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
APPEND VALUE1
|
||||
APPEND VALUE2
|
||||
APPEND VALUE3
|
||||
NEXT VALUE4 VALUE5
|
1
ThirdParty/Ert/devel/libconfig/tests/data/content_item_test
vendored
Normal file
1
ThirdParty/Ert/devel/libconfig/tests/data/content_item_test
vendored
Normal file
@ -0,0 +1 @@
|
||||
SET SetValue
|
3
ThirdParty/Ert/devel/libconfig/tests/data/include_test
vendored
Normal file
3
ThirdParty/Ert/devel/libconfig/tests/data/include_test
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
PATH0 PATH0
|
||||
INCLUDE path/include1
|
||||
INCLUDE path/subpath/include2
|
5
ThirdParty/Ert/devel/libconfig/tests/data/path/include1
vendored
Normal file
5
ThirdParty/Ert/devel/libconfig/tests/data/path/include1
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
PATH1 PATH1
|
||||
PATH2 PATH2
|
||||
|
||||
INCLUDE subpath/include3
|
||||
INCLUDE subpath/subsubpath/include4
|
1
ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include2
vendored
Normal file
1
ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include2
vendored
Normal file
@ -0,0 +1 @@
|
||||
PATH2 PATH2
|
1
ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include3
vendored
Normal file
1
ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include3
vendored
Normal file
@ -0,0 +1 @@
|
||||
PATH3 PATH3
|
1
ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/subsubpath/include4
vendored
Normal file
1
ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/subsubpath/include4
vendored
Normal file
@ -0,0 +1 @@
|
||||
PATH4 PATH4
|
6
ThirdParty/Ert/devel/libconfig/tests/data/type_testFail
vendored
Normal file
6
ThirdParty/Ert/devel/libconfig/tests/data/type_testFail
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
TYPES_KEY 100 0.75 rue String
|
||||
TYPES_KEY 100 0.75 True String
|
||||
TYPES_KEY 100 0.75X True String
|
||||
TYPES_KEY 100X 0.75 True String
|
||||
SHORT_KEY 100 100
|
||||
LONG_KEY 100 100
|
4
ThirdParty/Ert/devel/libconfig/tests/data/type_testOK
vendored
Normal file
4
ThirdParty/Ert/devel/libconfig/tests/data/type_testOK
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
TYPES_KEY 100 0.75 True String
|
||||
SHORT_KEY 100
|
||||
LONG_KEY 100 100 100
|
||||
LONG_KEY asc asc asc asc asc asc as asc sac asc sac sca sca sa sac
|
7
ThirdParty/Ert/devel/libecl/CMakeLists.txt
vendored
7
ThirdParty/Ert/devel/libecl/CMakeLists.txt
vendored
@ -1,8 +1,9 @@
|
||||
add_subdirectory( src )
|
||||
if (BUILD_APPLICATONS OR BUILD_ECL_SUMMARY)
|
||||
add_subdirectory( applications )
|
||||
endif()
|
||||
#if (BUILD_APPLICATIONS OR BUILD_ECL_SUMMARY)
|
||||
# add_subdirectory( applications )
|
||||
#endif()
|
||||
|
||||
add_subdirectory( applications )
|
||||
if (BUILD_TESTS)
|
||||
add_subdirectory( tests )
|
||||
endif()
|
||||
|
@ -4,6 +4,7 @@ if (BUILD_APPLICATIONS)
|
||||
add_executable( grdecl_grid grdecl_grid.c )
|
||||
add_executable( summary2csv summary2csv.c )
|
||||
if (ERT_LINUX)
|
||||
add_executable( esummary.x esummary.c )
|
||||
add_executable( convert.x convert.c )
|
||||
add_executable( grdecl_test.x grdecl_test.c )
|
||||
add_executable( kw_list.x kw_list.c )
|
||||
@ -14,7 +15,7 @@ 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 summary2csv 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 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)
|
||||
else()
|
||||
# The stupid .x extension creates problems on windows
|
||||
add_executable( convert convert.c )
|
||||
@ -36,10 +37,12 @@ if (BUILD_APPLICATIONS)
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
install(TARGETS ${prog} DESTINATION ${destination})
|
||||
if (INSTALL_GROUP)
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})")
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})")
|
||||
if (INSTALL_ERT)
|
||||
install(TARGETS ${prog} DESTINATION ${destination})
|
||||
if (INSTALL_GROUP)
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})")
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
@ -47,13 +50,15 @@ 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 ert_util)
|
||||
target_link_libraries( ens_plot.x plot ecl)
|
||||
|
||||
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
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)")
|
||||
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()
|
||||
|
||||
@ -61,13 +66,15 @@ endif()
|
||||
|
||||
if (BUILD_ECL_SUMMARY)
|
||||
add_executable( ecl_summary view_summary.c )
|
||||
target_link_libraries( ecl_summary ecl ert_util)
|
||||
target_link_libraries( ecl_summary ecl)
|
||||
|
||||
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
install(TARGETS ecl_summary DESTINATION ${destination})
|
||||
if (INSTALL_GROUP)
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/ecl_summary)")
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/ecl_summary)")
|
||||
if (INSTALL_ERT)
|
||||
install(TARGETS ecl_summary DESTINATION ${destination})
|
||||
if (INSTALL_GROUP)
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/ecl_summary)")
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/ecl_summary)")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include <ert/util/thread_pool.h>
|
||||
|
||||
#include <ert/config/config.h>
|
||||
#include <ert/config/config_content_item.h>
|
||||
#include <ert/config/config_content_node.h>
|
||||
|
||||
#include <ert/ecl/ecl_sum.h>
|
||||
|
||||
@ -222,16 +224,23 @@ void ensemble_init( ensemble_type * ensemble , config_type * config) {
|
||||
thread_pool_type * tp = thread_pool_alloc( LOAD_THREADS , true );
|
||||
{
|
||||
int i,j;
|
||||
for (i=0; i < config_get_occurences( config , "CASE_LIST"); i++) {
|
||||
const stringlist_type * case_list = config_iget_stringlist_ref( config , "CASE_LIST" , i );
|
||||
for (j=0; j < stringlist_get_size( case_list ); j++)
|
||||
ensemble_load_from_glob( ensemble , stringlist_iget( case_list , j ) , tp);
|
||||
const config_content_item_type * case_item = config_get_content_item( config , "CASE_LIST" );
|
||||
|
||||
if (case_item != NULL) {
|
||||
for (j=0; j < config_content_node_get_size( case_item ); j++) {
|
||||
const config_content_node_type * case_node = config_content_item_iget_node( case_item );
|
||||
for (i=0; i < config_content_node_get_size( case_node ) i++) {
|
||||
const char * case_glob = config_content_node_iget( case_node , i );
|
||||
ensemble_load_from_glob( ensemble , case_glob , tp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
thread_pool_join( tp );
|
||||
thread_pool_free( tp );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
const sum_case_type * tmp = vector_iget_const( ensemble->data , 0 );
|
||||
ensemble->refcase = tmp->ecl_sum;
|
||||
@ -347,17 +356,21 @@ static void output_add_key( const ecl_sum_type * refcase , output_type * output
|
||||
|
||||
void output_table_init( const ecl_sum_type * refcase, hash_type * output_table , const config_type * config ) {
|
||||
int i,j;
|
||||
for (i=0; i < config_get_occurences( config , "OUTPUT" ); i++) {
|
||||
const stringlist_type * tokens = config_iget_stringlist_ref( config , "OUTPUT" , i);
|
||||
const char * file = stringlist_iget( tokens , 0 );
|
||||
const char * format_string = stringlist_iget( tokens , 1 );
|
||||
output_type * output = output_alloc( file , format_string );
|
||||
const config_content_item_type * output_item = config_get_content_item( config , "OUTPUT");
|
||||
if (output_item != NULL) {
|
||||
for (i = 0; i < config_content_item_get_size( output_item ); i++) {
|
||||
const config_content_node_type * output_node = config_content_item_iget_node( output_item , i );
|
||||
|
||||
const char * file = config_content_node_iget( output_node , 0 );
|
||||
const char * format_string = config_content_node_iget( output_node , 1 );
|
||||
output_type * output = output_alloc( file , format_string );
|
||||
|
||||
/* All the keys are just added - without any check. */
|
||||
for (j = 2; j < stringlist_get_size( tokens ); j++)
|
||||
output_add_key( refcase , output , stringlist_iget( tokens , j));
|
||||
|
||||
hash_insert_hash_owned_ref( output_table , file , output , output_free__ );
|
||||
/* All the keys are just added - without any check. */
|
||||
for (j = 2; j < config_content_node_get_size( output_node ); j++)
|
||||
output_add_key( refcase , output , config_content_node_iget( output_node , j));
|
||||
|
||||
hash_insert_hash_owned_ref( output_table , file , output , output_free__ );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -713,7 +726,7 @@ void config_init( config_type * config ) {
|
||||
{
|
||||
config_schema_item_type * item;
|
||||
item = config_add_schema_item( config , "OUTPUT" , true , true );
|
||||
config_schema_item_set_argc_minmax( item , 2 , -1 , 0 , NULL );
|
||||
config_schema_item_set_argc_minmax( item , 2 , CONFIG_DEFAULT_ARG_MAX , 0 , NULL );
|
||||
config_schema_item_set_indexed_selection_set( item , 1 , 3 , (const char *[3]) { S3GRAPH_STRING , HEADER_STRING , PLAIN_STRING });
|
||||
}
|
||||
|
||||
@ -815,16 +828,18 @@ int main( int argc , char ** argv ) {
|
||||
const char * config_arg = argv[1];
|
||||
|
||||
config_init( config );
|
||||
config_parse( config , config_arg , "--" , NULL , NULL , true , true );
|
||||
|
||||
{
|
||||
if (config_parse( config , config_arg , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN, true )) {
|
||||
char * config_path;
|
||||
util_alloc_file_components( config_arg , &config_path , NULL , NULL);
|
||||
if (config_path != NULL) {
|
||||
chdir( config_path );
|
||||
free( config_path );
|
||||
}
|
||||
} else {
|
||||
config_fprintf_errors( config , stderr );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ensemble_init( ensemble , config );
|
||||
|
140
ThirdParty/Ert/devel/libecl/applications/esummary.c
vendored
140
ThirdParty/Ert/devel/libecl/applications/esummary.c
vendored
@ -16,13 +16,16 @@
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <ecl_kw.h>
|
||||
#include <stdlib.h>
|
||||
#include <ecl_sum.h>
|
||||
#include <util.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <vector.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/vector.h>
|
||||
#include <ert/util/time_interval.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_sum.h>
|
||||
|
||||
|
||||
void install_SIGNALS(void) {
|
||||
@ -39,6 +42,8 @@ void usage() {
|
||||
}
|
||||
|
||||
|
||||
#define MISSING_STRING " 0.000"
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
@ -49,6 +54,12 @@ int main(int argc , char ** argv) {
|
||||
{
|
||||
ecl_sum_type * first_ecl_sum; /* This governs the timing */
|
||||
vector_type * ecl_sum_list = vector_alloc_new();
|
||||
time_interval_type * time_union = NULL;
|
||||
time_interval_type * time_intersect = NULL;
|
||||
time_interval_type * time = NULL;
|
||||
bool use_time_union = true;
|
||||
|
||||
int load_count = 0;
|
||||
int nvars;
|
||||
char ** var_list;
|
||||
bool * has_var;
|
||||
@ -61,51 +72,46 @@ int main(int argc , char ** argv) {
|
||||
char * path , * basename;
|
||||
ecl_sum_type * ecl_sum;
|
||||
util_alloc_file_components( argv[iarg] , &path , &basename , NULL);
|
||||
ecl_sum = ecl_sum_fread_alloc_case( argv[iarg] , ":");
|
||||
if (iarg == 1)
|
||||
first_ecl_sum = ecl_sum; /* Keep track of this - might sort the vector */
|
||||
|
||||
fprintf(stderr,"Loading case: %s/%s" , path , basename); fflush(stderr);
|
||||
vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ );
|
||||
ecl_sum = ecl_sum_fread_alloc_case( argv[iarg] , ":");
|
||||
|
||||
if (iarg == 1) {
|
||||
first_ecl_sum = ecl_sum; /* Keep track of this - might sort the vector */
|
||||
time_union = time_interval_alloc_copy( ecl_sum_get_sim_time( ecl_sum ));
|
||||
time_intersect = time_interval_alloc_copy( ecl_sum_get_sim_time( ecl_sum ));
|
||||
|
||||
if (use_time_union)
|
||||
time = time_union;
|
||||
else
|
||||
time = time_intersect;
|
||||
vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ );
|
||||
} else {
|
||||
const time_interval_type * ti = ecl_sum_get_sim_time( ecl_sum );
|
||||
if (time_interval_has_overlap(time , ti)) {
|
||||
time_interval_intersect( time_intersect , ti );
|
||||
time_interval_extend( time_union , ti );
|
||||
|
||||
vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ );
|
||||
load_count++;
|
||||
} else {
|
||||
fprintf(stderr,"** Warning case:%s has no time overlap - discarded \n",ecl_sum_get_case( ecl_sum ));
|
||||
ecl_sum_free( ecl_sum );
|
||||
}
|
||||
}
|
||||
|
||||
iarg++;
|
||||
fprintf(stderr,"\n");
|
||||
util_safe_free( path );
|
||||
free( basename );
|
||||
}
|
||||
}
|
||||
nvars = argc - vector_get_size( ecl_sum_list ) - 1;
|
||||
if (load_count == 0)
|
||||
usage();
|
||||
|
||||
nvars = argc - load_count - 1;
|
||||
if (nvars == 0) util_exit(" --- No variables \n");
|
||||
var_list = &argv[vector_get_size( ecl_sum_list ) + 1];
|
||||
var_list = &argv[load_count + 1];
|
||||
has_var = util_calloc( nvars , sizeof * has_var );
|
||||
|
||||
|
||||
/** Checking time consistency - and discarding those with unmatching time vector. */
|
||||
{
|
||||
int i;
|
||||
time_t_vector_type * first_time = ecl_sum_alloc_time_vector( vector_iget_const( ecl_sum_list , 0) , true );
|
||||
|
||||
for (i=1; i < vector_get_size( ecl_sum_list); i++) {
|
||||
time_t_vector_type * time_vector;
|
||||
const ecl_sum_type * ecl_sum = vector_iget_const( ecl_sum_list , i );
|
||||
if (ecl_sum_get_first_report_step( ecl_sum ) >= 0 ) {
|
||||
time_vector = ecl_sum_alloc_time_vector( ecl_sum , true );
|
||||
int i;
|
||||
for (i=0; i < util_int_min( time_t_vector_size( first_time ) , time_t_vector_size( time_vector )); i++) {
|
||||
if (time_t_vector_iget( first_time , i) != time_t_vector_iget(time_vector , i)) {
|
||||
vector_iset_ref( ecl_sum_list , i , NULL);
|
||||
printf("Discarding case:%s due to time inconsistencies \n" , ecl_sum_get_case( ecl_sum ));
|
||||
break;
|
||||
}
|
||||
}
|
||||
time_t_vector_free( time_vector );
|
||||
} else {
|
||||
vector_iset_ref( ecl_sum_list , i , NULL);
|
||||
printf("Discarding case:%s - no data \n" , ecl_sum_get_case( ecl_sum ));
|
||||
}
|
||||
}
|
||||
time_t_vector_free( first_time );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Checking that the summary files have the various variables -
|
||||
@ -131,39 +137,55 @@ int main(int argc , char ** argv) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!time_interval_equal(time_union , time_intersect )) {
|
||||
fprintf(stderr,"** Warning: not all simulations have the same length. ");
|
||||
if (use_time_union)
|
||||
fprintf(stderr,"Using %s for missing values.\n" , MISSING_STRING);
|
||||
else
|
||||
fprintf(stderr,"Only showing common time period.\n");
|
||||
}
|
||||
|
||||
/** The actual summary lookup. */
|
||||
{
|
||||
int first_report = ecl_sum_get_first_report_step( first_ecl_sum );
|
||||
int last_report = ecl_sum_get_last_report_step( first_ecl_sum );
|
||||
time_t_vector_type * date_list = time_t_vector_alloc(0,0);
|
||||
time_t start_time = time_interval_get_start( time );
|
||||
FILE * stream = stdout;
|
||||
int iens,ivar,report;
|
||||
int iens,ivar,itime;
|
||||
|
||||
for (report = first_report; report <= last_report; report++) {
|
||||
ecl_util_init_month_range( date_list , time_interval_get_start( time ) , time_interval_get_end( time ));
|
||||
for (itime = 0; itime < time_t_vector_size( date_list ); itime++) {
|
||||
time_t current_time = time_t_vector_iget( date_list , itime );
|
||||
for (ivar = 0; ivar < nvars; ivar++) { /* Iterating over the variables */
|
||||
if (has_var[ivar]) {
|
||||
for (iens = 0; iens < vector_get_size( ecl_sum_list ); iens++) { /* Iterating over the ensemble members */
|
||||
const ecl_sum_type * ecl_sum = vector_iget_const( ecl_sum_list , iens );
|
||||
double value = 0;
|
||||
int end_index;
|
||||
if (ecl_sum_has_report_step(ecl_sum , report)) {
|
||||
end_index = ecl_sum_iget_report_end( ecl_sum , report );
|
||||
if (end_index >= 0) {
|
||||
if (ivar == 0 && iens == 0) { /* Display time info in the first columns */
|
||||
int day,month,year;
|
||||
util_set_date_values(ecl_sum_iget_sim_time(ecl_sum , end_index) , &day , &month, &year);
|
||||
fprintf(stream , "%7.2f %02d/%02d/%04d " , ecl_sum_iget_sim_days(ecl_sum , end_index) , day , month , year);
|
||||
}
|
||||
value = ecl_sum_get_general_var(ecl_sum , end_index , var_list[ivar]);
|
||||
}
|
||||
|
||||
if (ivar == 0 && iens == 0) { /* Display time info in the first columns */
|
||||
int day,month,year;
|
||||
util_set_date_values( current_time , &day , &month, &year);
|
||||
fprintf(stream , "%7.2f %02d/%02d/%04d " , util_difftime_days( start_time , current_time ) , day , month , year);
|
||||
}
|
||||
|
||||
{
|
||||
const time_interval_type * sim_time = ecl_sum_get_sim_time( ecl_sum );
|
||||
|
||||
if (time_interval_arg_before( sim_time , current_time))
|
||||
fprintf(stream , " %s " , MISSING_STRING); // We are before this case has data.
|
||||
else if (time_interval_arg_after( sim_time , current_time))
|
||||
fprintf(stream , " %s " , MISSING_STRING); // We are after this case has data.
|
||||
else {
|
||||
double value = ecl_sum_get_general_var_from_sim_time(ecl_sum , current_time , var_list[ivar]);
|
||||
fprintf(stream , " %12.3f " , value);
|
||||
}
|
||||
|
||||
}
|
||||
fprintf(stream , " %12.3f " , value);
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(stream , "\n");
|
||||
}
|
||||
time_t_vector_free( date_list );
|
||||
}
|
||||
vector_free( ecl_sum_list );
|
||||
free( has_var );
|
||||
|
@ -149,7 +149,7 @@ extern "C" {
|
||||
double ecl_grid_get_double_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k);
|
||||
int ecl_grid_get_int_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k);
|
||||
|
||||
void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , FILE * stream , double double_default);
|
||||
void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream , double double_default);
|
||||
bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid );
|
||||
|
||||
void ecl_grid_fwrite_EGRID( ecl_grid_type * grid , const char * filename);
|
||||
|
@ -98,6 +98,7 @@ extern "C" {
|
||||
bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2 , 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);
|
||||
void ecl_kw_fskip_data__( ecl_type_enum ecl_type , int size , fortio_type * fortio);
|
||||
void ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio);
|
||||
void ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio);
|
||||
|
@ -48,6 +48,7 @@ extern "C" {
|
||||
char * ecl_kw_grdecl_alloc_next_header( FILE * stream );
|
||||
|
||||
void ecl_kw_fprintf_grdecl(const ecl_kw_type * ecl_kw , FILE * stream);
|
||||
void ecl_kw_fprintf_grdecl__(const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_INTEHEAD.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
The file 'ecl_RSTHEAD.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -16,8 +16,8 @@
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef __ECL_INTEHEAD_H__
|
||||
#define __ECL_INTEHEAD_H__
|
||||
#ifndef __ECL_RSTHEAD_H__
|
||||
#define __ECL_RSTHEAD_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -25,9 +25,9 @@ extern "C" {
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
|
||||
#define INTEHEAD_KW "INTEHEAD" /* Long array with lots of data. */
|
||||
|
||||
typedef struct {
|
||||
int day;
|
||||
@ -63,14 +63,24 @@ extern "C" {
|
||||
int nswlmx; // The maximum number of segmented wells
|
||||
int nlbrmx; // The maximum number of lateral branches pr well
|
||||
int nilbrz; // The number of entries pr segment in ILBR array
|
||||
} ecl_intehead_type;
|
||||
|
||||
// Properteies from the LOGIHEAD keyword:
|
||||
bool dualp;
|
||||
|
||||
|
||||
// Properties from the DOUBHEAD keyword:
|
||||
double sim_days;
|
||||
} ecl_rsthead_type;
|
||||
|
||||
|
||||
|
||||
void ecl_intehead_free( ecl_intehead_type * intehead );
|
||||
ecl_intehead_type * ecl_intehead_alloc( const ecl_kw_type * intehead_kw );
|
||||
time_t ecl_intehead_date( const ecl_kw_type * intehead_kw );
|
||||
void ecl_intehead_fprintf( const ecl_intehead_type * header , FILE * stream);
|
||||
void ecl_rsthead_free( ecl_rsthead_type * rsthead );
|
||||
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 );
|
||||
time_t ecl_rsthead_date( const ecl_kw_type * intehead_kw );
|
||||
void ecl_rsthead_fprintf( const ecl_rsthead_type * header , FILE * stream);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
@ -30,6 +30,7 @@ extern "C" {
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/double_vector.h>
|
||||
#include <ert/util/time_interval.h>
|
||||
|
||||
#include <ert/ecl/ecl_smspec.h>
|
||||
#include <ert/ecl/ecl_sum_tstep.h>
|
||||
@ -59,6 +60,7 @@ typedef struct ecl_sum_struct ecl_sum_type;
|
||||
|
||||
double ecl_sum_get_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const smspec_node_type * node);
|
||||
double ecl_sum_get_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const smspec_node_type * node);
|
||||
double ecl_sum_time2days( const ecl_sum_type * ecl_sum , time_t sim_time);
|
||||
|
||||
void ecl_sum_set_unified( ecl_sum_type * ecl_sum , bool unified );
|
||||
void ecl_sum_set_fmt_case( ecl_sum_type * ecl_sum , bool fmt_case );
|
||||
@ -158,6 +160,7 @@ typedef struct ecl_sum_struct ecl_sum_type;
|
||||
time_t ecl_sum_get_data_start( const ecl_sum_type * ecl_sum );
|
||||
time_t ecl_sum_get_end_time( const ecl_sum_type * ecl_sum);
|
||||
time_t ecl_sum_get_start_time(const ecl_sum_type * );
|
||||
const time_interval_type * ecl_sum_get_sim_time( const ecl_sum_type * ecl_sum);
|
||||
|
||||
const char * ecl_sum_get_base(const ecl_sum_type * ecl_sum );
|
||||
const char * ecl_sum_get_path(const ecl_sum_type * ecl_sum );
|
||||
|
@ -29,6 +29,7 @@ extern "C" {
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/double_vector.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/time_interval.h>
|
||||
|
||||
#include <ert/ecl/ecl_sum_tstep.h>
|
||||
#include <ert/ecl/smspec_node.h>
|
||||
@ -40,6 +41,7 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ;
|
||||
void ecl_sum_data_fread_restart( ecl_sum_data_type * data , const stringlist_type * filelist);
|
||||
ecl_sum_data_type * ecl_sum_data_alloc_writer( ecl_smspec_type * smspec );
|
||||
ecl_sum_data_type * ecl_sum_data_alloc( ecl_smspec_type * smspec);
|
||||
double ecl_sum_data_time2days( const ecl_sum_data_type * data , time_t sim_time);
|
||||
int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time_t sim_time);
|
||||
int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , double days);
|
||||
bool ecl_sum_data_check_sim_time( const ecl_sum_data_type * data , time_t sim_time);
|
||||
@ -52,6 +54,7 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ;
|
||||
time_t ecl_sum_data_get_data_start( const ecl_sum_data_type * data );
|
||||
time_t ecl_sum_data_get_report_time( const ecl_sum_data_type * data , int report_step);
|
||||
double ecl_sum_data_get_first_day( const ecl_sum_data_type * data);
|
||||
const time_interval_type * ecl_sum_data_get_sim_time( const ecl_sum_data_type * data);
|
||||
time_t ecl_sum_data_get_sim_start ( const ecl_sum_data_type * data );
|
||||
time_t ecl_sum_data_get_sim_end ( const ecl_sum_data_type * data );
|
||||
double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data );
|
||||
|
@ -25,6 +25,7 @@ extern "C" {
|
||||
#include <time.h>
|
||||
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
|
||||
typedef enum { ECL_OTHER_FILE = 0 ,
|
||||
ECL_RESTART_FILE = 1 ,
|
||||
@ -178,6 +179,8 @@ 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);
|
||||
void ecl_util_init_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
|
||||
void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit );
|
||||
bool smspec_node_is_rate( const smspec_node_type * smspec_node );
|
||||
bool smspec_node_is_total( const smspec_node_type * smspec_node );
|
||||
bool smspec_node_is_historical( const smspec_node_type * smspec_node );
|
||||
bool smspec_node_need_nums( const smspec_node_type * smspec_node );
|
||||
void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream);
|
||||
|
||||
|
15
ThirdParty/Ert/devel/libecl/src/CMakeLists.txt
vendored
15
ThirdParty/Ert/devel/libecl/src/CMakeLists.txt
vendored
@ -2,9 +2,9 @@ include_directories( ext )
|
||||
file(GLOB ext_source "ext/*.c" )
|
||||
file(GLOB ext_header "ext/*.h" )
|
||||
|
||||
set( source_files ecl_sum_tstep.c ecl_rst_file.c ecl_init_file.c ecl_grid_cache.c smspec_node.c ecl_kw_grdecl.c ecl_file_kw.c ecl_grav.c ecl_grav_calc.c ecl_smspec.c ecl_sum_data.c ecl_util.c ecl_kw.c ecl_sum.c fortio.c ecl_rft_file.c ecl_rft_node.c ecl_grid.c ecl_coarse_cell.c ecl_box.c ecl_io_config.c ecl_file.c ecl_region.c point.c tetrahedron.c ecl_intehead.c ecl_subsidence.c ecl_grav_common.c ${ext_source})
|
||||
set( source_files ecl_rsthead.c ecl_sum_tstep.c ecl_rst_file.c ecl_init_file.c ecl_grid_cache.c smspec_node.c ecl_kw_grdecl.c ecl_file_kw.c ecl_grav.c ecl_grav_calc.c ecl_smspec.c ecl_sum_data.c ecl_util.c ecl_kw.c ecl_sum.c fortio.c ecl_rft_file.c ecl_rft_node.c ecl_grid.c ecl_coarse_cell.c ecl_box.c ecl_io_config.c ecl_file.c ecl_region.c point.c tetrahedron.c ecl_subsidence.c ecl_grav_common.c ${ext_source})
|
||||
|
||||
set( header_files ecl_sum_tstep.h ecl_rst_file.h ecl_init_file.h smspec_node.h ecl_grid_cache.h ecl_kw_grdecl.h ecl_file_kw.h ecl_grav.h ecl_grav_calc.h ecl_endian_flip.h ecl_smspec.h ecl_sum_data.h ecl_util.h ecl_kw.h ecl_sum.h fortio.h ecl_rft_file.h ecl_rft_node.h ecl_box.h ecl_coarse_cell.h ecl_grid.h ecl_io_config.h ecl_file.h ecl_region.h ecl_intehead.h ecl_kw_magic.h ecl_subsidence.h ${ext_header} ecl_grav_common.h)
|
||||
set( header_files ecl_rsthead.h ecl_sum_tstep.h ecl_rst_file.h ecl_init_file.h smspec_node.h ecl_grid_cache.h ecl_kw_grdecl.h ecl_file_kw.h ecl_grav.h ecl_grav_calc.h ecl_endian_flip.h ecl_smspec.h ecl_sum_data.h ecl_util.h ecl_kw.h ecl_sum.h fortio.h ecl_rft_file.h ecl_rft_node.h ecl_box.h ecl_coarse_cell.h ecl_grid.h ecl_io_config.h ecl_file.h ecl_region.h ecl_kw_magic.h ecl_subsidence.h ${ext_header} ecl_grav_common.h)
|
||||
|
||||
|
||||
|
||||
@ -28,11 +28,12 @@ endif()
|
||||
target_link_libraries( ecl ert_geometry ert_util )
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
install(TARGETS ecl DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
foreach(header ${header_files})
|
||||
install(FILES ../include/ert/ecl/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/ecl)
|
||||
endforeach()
|
||||
|
||||
if (INSTALL_ERT)
|
||||
install(TARGETS ecl DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
foreach(header ${header_files})
|
||||
install(FILES ../include/ert/ecl/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/ecl)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
2
ThirdParty/Ert/devel/libecl/src/ecl_file.c
vendored
2
ThirdParty/Ert/devel/libecl/src/ecl_file.c
vendored
@ -33,7 +33,7 @@
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_endian_flip.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_intehead.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
#include <ert/ecl/ecl_file_kw.h>
|
||||
|
||||
|
||||
|
12
ThirdParty/Ert/devel/libecl/src/ecl_grid.c
vendored
12
ThirdParty/Ert/devel/libecl/src/ecl_grid.c
vendored
@ -3005,8 +3005,10 @@ int ecl_grid_get_active_fracture_index3(const ecl_grid_type * ecl_grid , int i ,
|
||||
*/
|
||||
|
||||
int ecl_grid_get_active_fracture_index1(const ecl_grid_type * ecl_grid , int global_index) {
|
||||
if (!ecl_grid->fracture_index_map) return -1;
|
||||
return ecl_grid->fracture_index_map[global_index];
|
||||
if (ecl_grid->fracture_index_map == NULL)
|
||||
return -1;
|
||||
else
|
||||
return ecl_grid->fracture_index_map[global_index];
|
||||
}
|
||||
|
||||
|
||||
@ -3720,10 +3722,10 @@ int ecl_grid_get_region_cells(const ecl_grid_type * ecl_grid , const ecl_kw_type
|
||||
|
||||
|
||||
|
||||
void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , FILE * stream , double double_default) {
|
||||
void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream , double double_default) {
|
||||
int src_size = ecl_kw_get_size( ecl_kw );
|
||||
if (src_size == ecl_grid->size)
|
||||
ecl_kw_fprintf_grdecl( ecl_kw , stream );
|
||||
ecl_kw_fprintf_grdecl__( ecl_kw , special_header , stream );
|
||||
else if (src_size == ecl_grid->total_active) {
|
||||
void * default_ptr = NULL;
|
||||
float float_default;
|
||||
@ -3755,7 +3757,7 @@ void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_t
|
||||
|
||||
{
|
||||
ecl_kw_type * tmp_kw = ecl_kw_alloc_scatter_copy( ecl_kw , ecl_grid->size , ecl_grid->inv_index_map , default_ptr );
|
||||
ecl_kw_fprintf_grdecl( tmp_kw , stream );
|
||||
ecl_kw_fprintf_grdecl__( tmp_kw , special_header , stream );
|
||||
ecl_kw_free( tmp_kw );
|
||||
}
|
||||
} else
|
||||
|
79
ThirdParty/Ert/devel/libecl/src/ecl_intehead.c
vendored
79
ThirdParty/Ert/devel/libecl/src/ecl_intehead.c
vendored
@ -1,79 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_intehead.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_intehead.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
|
||||
static time_t intehead_date( int day , int month , int year) {
|
||||
return util_make_date( day , month, year );
|
||||
}
|
||||
|
||||
|
||||
time_t ecl_intehead_date( const ecl_kw_type * intehead_kw ) {
|
||||
return intehead_date( ecl_kw_iget_int( intehead_kw , INTEHEAD_DAY_INDEX) ,
|
||||
ecl_kw_iget_int( intehead_kw , INTEHEAD_MONTH_INDEX) ,
|
||||
ecl_kw_iget_int( intehead_kw , INTEHEAD_YEAR_INDEX) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
ecl_intehead_type * ecl_intehead_alloc( const ecl_kw_type * intehead_kw ) {
|
||||
ecl_intehead_type * intehead = util_malloc( sizeof * intehead );
|
||||
const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw );
|
||||
|
||||
intehead->day = data[INTEHEAD_DAY_INDEX];
|
||||
intehead->month = data[INTEHEAD_MONTH_INDEX];
|
||||
intehead->year = data[INTEHEAD_YEAR_INDEX];
|
||||
intehead->version = data[INTEHEAD_IPROG_INDEX];
|
||||
intehead->phase_sum = data[INTEHEAD_PHASE_INDEX];
|
||||
|
||||
intehead->nx = data[INTEHEAD_NX_INDEX];
|
||||
intehead->ny = data[INTEHEAD_NY_INDEX];
|
||||
intehead->nz = data[INTEHEAD_NZ_INDEX];
|
||||
intehead->nactive = data[INTEHEAD_NACTIVE_INDEX];
|
||||
|
||||
intehead->nwells = data[INTEHEAD_NWELLS_INDEX];
|
||||
intehead->niwelz = data[INTEHEAD_NIWELZ_INDEX];
|
||||
intehead->nzwelz = data[INTEHEAD_NZWELZ_INDEX];
|
||||
|
||||
intehead->niconz = data[INTEHEAD_NICONZ_INDEX];
|
||||
intehead->ncwmax = data[INTEHEAD_NCWMAX_INDEX];
|
||||
|
||||
intehead->nisegz = data[INTEHEAD_NISEGZ_INDEX];
|
||||
intehead->nsegmx = data[INTEHEAD_NSEGMX_INDEX];
|
||||
intehead->nswlmx = data[INTEHEAD_NSWLMX_INDEX];
|
||||
|
||||
// The only derived quantity
|
||||
intehead->sim_time = intehead_date( intehead->day , intehead->month , intehead->year );
|
||||
return intehead;
|
||||
}
|
||||
|
||||
|
||||
void ecl_intehead_fprintf( const ecl_intehead_type * header , FILE * stream) {
|
||||
fprintf(stream , "nx %d \n",header->nx);
|
||||
fprintf(stream , "nwells %d \n",header->nwells);
|
||||
fprintf(stream , "niwelz %d \n\n",header->niwelz);
|
||||
}
|
||||
|
||||
void ecl_intehead_free( ecl_intehead_type * intehead ) {
|
||||
free( intehead );
|
||||
}
|
28
ThirdParty/Ert/devel/libecl/src/ecl_kw.c
vendored
28
ThirdParty/Ert/devel/libecl/src/ecl_kw.c
vendored
@ -336,15 +336,25 @@ bool ecl_kw_ichar_eq(const ecl_kw_type *ecl_kw , int i , const char *value) {
|
||||
}
|
||||
|
||||
|
||||
static bool ecl_kw_size_and_type_equal( const ecl_kw_type *ecl_kw1 , const ecl_kw_type * ecl_kw2 ) {
|
||||
bool equal = true;
|
||||
|
||||
if (ecl_kw1->size != ecl_kw2->size)
|
||||
equal = false;
|
||||
else if (ecl_kw1->ecl_type != ecl_kw2->ecl_type)
|
||||
equal = false;
|
||||
|
||||
return equal;
|
||||
}
|
||||
|
||||
|
||||
bool ecl_kw_header_eq(const ecl_kw_type *ecl_kw1 , const ecl_kw_type * ecl_kw2) {
|
||||
bool equal = true;
|
||||
|
||||
if (strcmp(ecl_kw1->header8 , ecl_kw2->header8) != 0)
|
||||
equal = false;
|
||||
else if (ecl_kw1->size != ecl_kw2->size)
|
||||
equal = false;
|
||||
else if (ecl_kw1->ecl_type != ecl_kw2->ecl_type)
|
||||
equal = false;
|
||||
else
|
||||
equal = ecl_kw_size_and_type_equal( ecl_kw1 , ecl_kw2 );
|
||||
|
||||
return equal;
|
||||
}
|
||||
@ -368,6 +378,16 @@ 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) {
|
||||
if (ecl_kw_size_and_type_equal( ecl_kw1 , ecl_kw2))
|
||||
return ecl_kw_data_equal__( ecl_kw1 , ecl_kw2->data , ecl_kw1->size);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
This function compares two ecl_kw instances, and returns true if they are equal.
|
||||
|
19
ThirdParty/Ert/devel/libecl/src/ecl_kw_grdecl.c
vendored
19
ThirdParty/Ert/devel/libecl/src/ecl_kw_grdecl.c
vendored
@ -633,8 +633,19 @@ ecl_kw_type * ecl_kw_fscanf_alloc_current_grdecl( FILE * stream , ecl_type_enum
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
void ecl_kw_fprintf_grdecl(const ecl_kw_type * ecl_kw , FILE * stream) {
|
||||
fprintf(stream,"%s\n" , ecl_kw_get_header(ecl_kw));
|
||||
|
||||
/*
|
||||
This method allows to write with a different header,
|
||||
i.e. PORO_XXXX. This header is even allowed to break the 8 character
|
||||
length limit; i.e. loading it back naively will fail.
|
||||
*/
|
||||
|
||||
void ecl_kw_fprintf_grdecl__(const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream) {
|
||||
if (special_header)
|
||||
fprintf(stream,"%s\n" , special_header);
|
||||
else
|
||||
fprintf(stream,"%s\n" , ecl_kw_get_header(ecl_kw));
|
||||
|
||||
{
|
||||
fortio_type * fortio = fortio_alloc_FILE_wrapper(NULL , false , true , stream); /* Endian flip should *NOT* be used */
|
||||
ecl_kw_fwrite_data(ecl_kw , fortio);
|
||||
@ -644,3 +655,7 @@ void ecl_kw_fprintf_grdecl(const ecl_kw_type * ecl_kw , FILE * stream) {
|
||||
}
|
||||
|
||||
|
||||
void ecl_kw_fprintf_grdecl(const ecl_kw_type * ecl_kw , FILE * stream) {
|
||||
ecl_kw_fprintf_grdecl__(ecl_kw , NULL , stream );
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_endian_flip.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_intehead.h>
|
||||
#include <ert/ecl/ecl_file_kw.h>
|
||||
#include <ert/ecl/ecl_rst_file.h>
|
||||
|
||||
|
@ -158,7 +158,7 @@ static time_t file_map_iget_restart_sim_date(const file_map_type * file_map , in
|
||||
|
||||
if (seqnum_map != NULL) {
|
||||
ecl_kw_type * intehead_kw = file_map_iget_named_kw( seqnum_map , INTEHEAD_KW , 0);
|
||||
sim_time = ecl_intehead_date( intehead_kw );
|
||||
sim_time = ecl_rsthead_date( intehead_kw );
|
||||
file_map_free( seqnum_map );
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ static int file_map_find_sim_time(const file_map_type * file_map , time_t sim_ti
|
||||
int index = 0;
|
||||
while (index < int_vector_size( intehead_index_list )) {
|
||||
const ecl_kw_type * intehead_kw = file_map_iget_kw( file_map , int_vector_iget( intehead_index_list , index ));
|
||||
if (ecl_intehead_date( intehead_kw ) == sim_time) {
|
||||
if (ecl_rsthead_date( intehead_kw ) == sim_time) {
|
||||
seqnum_index = index;
|
||||
break;
|
||||
}
|
||||
|
155
ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c
vendored
Normal file
155
ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c
vendored
Normal file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_rsthead.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
|
||||
|
||||
static time_t rsthead_date( int day , int month , int year) {
|
||||
return util_make_date( day , month, year );
|
||||
}
|
||||
|
||||
|
||||
time_t ecl_rsthead_date( const ecl_kw_type * intehead_kw ) {
|
||||
return rsthead_date( ecl_kw_iget_int( intehead_kw , INTEHEAD_DAY_INDEX) ,
|
||||
ecl_kw_iget_int( intehead_kw , INTEHEAD_MONTH_INDEX) ,
|
||||
ecl_kw_iget_int( intehead_kw , INTEHEAD_YEAR_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 * logihead_kw = ecl_file_iget_named_kw( rst_file , LOGIHEAD_KW , occurence);
|
||||
const ecl_kw_type * doubhead_kw = ecl_file_iget_named_kw( rst_file , DOUBHEAD_KW , occurence);
|
||||
|
||||
ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead );
|
||||
|
||||
{
|
||||
const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw );
|
||||
|
||||
rsthead->day = data[INTEHEAD_DAY_INDEX];
|
||||
rsthead->month = data[INTEHEAD_MONTH_INDEX];
|
||||
rsthead->year = data[INTEHEAD_YEAR_INDEX];
|
||||
rsthead->version = data[INTEHEAD_IPROG_INDEX];
|
||||
rsthead->phase_sum = data[INTEHEAD_PHASE_INDEX];
|
||||
|
||||
rsthead->nx = data[INTEHEAD_NX_INDEX];
|
||||
rsthead->ny = data[INTEHEAD_NY_INDEX];
|
||||
rsthead->nz = data[INTEHEAD_NZ_INDEX];
|
||||
rsthead->nactive = data[INTEHEAD_NACTIVE_INDEX];
|
||||
|
||||
rsthead->nwells = data[INTEHEAD_NWELLS_INDEX];
|
||||
rsthead->niwelz = data[INTEHEAD_NIWELZ_INDEX];
|
||||
rsthead->nzwelz = data[INTEHEAD_NZWELZ_INDEX];
|
||||
|
||||
rsthead->niconz = data[INTEHEAD_NICONZ_INDEX];
|
||||
rsthead->ncwmax = data[INTEHEAD_NCWMAX_INDEX];
|
||||
|
||||
rsthead->nisegz = data[INTEHEAD_NISEGZ_INDEX];
|
||||
rsthead->nsegmx = data[INTEHEAD_NSEGMX_INDEX];
|
||||
rsthead->nswlmx = data[INTEHEAD_NSWLMX_INDEX];
|
||||
|
||||
// The only derived quantity
|
||||
rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year );
|
||||
}
|
||||
rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX);
|
||||
rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX );
|
||||
|
||||
return rsthead;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_type * rst_file) {
|
||||
return ecl_rsthead_ialloc( rst_file , 0 );
|
||||
}
|
||||
|
||||
|
||||
void ecl_rsthead_fprintf( const ecl_rsthead_type * header , FILE * stream) {
|
||||
fprintf(stream , "nx %d \n",header->nx);
|
||||
fprintf(stream , "nwells %d \n",header->nwells);
|
||||
fprintf(stream , "niwelz %d \n\n",header->niwelz);
|
||||
}
|
||||
|
||||
|
||||
bool ecl_rsthead_equal( const ecl_rsthead_type * header1 , const ecl_rsthead_type * header2) {
|
||||
bool equal = true;
|
||||
equal = equal && (header1->day == header2->day);
|
||||
equal = equal && (header1->year == header2->year);
|
||||
equal = equal && (header1->month == header2->month);
|
||||
equal = equal && (header1->sim_time == header2->sim_time);
|
||||
equal = equal && (header1->version == header2->version);
|
||||
equal = equal && (header1->phase_sum == header2->phase_sum);
|
||||
equal = equal && (header1->nx == header2->nx);
|
||||
equal = equal && (header1->ny == header2->ny);
|
||||
equal = equal && (header1->nz == header2->nz);
|
||||
equal = equal && (header1->nactive == header2->nactive);
|
||||
equal = equal && (header1->nwells == header2->nwells);
|
||||
equal = equal && (header1->niwelz == header2->niwelz);
|
||||
equal = equal && (header1->nzwelz == header2->nzwelz);
|
||||
equal = equal && (header1->niconz == header2->niconz);
|
||||
equal = equal && (header1->ncwmax == header2->ncwmax);
|
||||
equal = equal && (header1->nisegz == header2->nisegz);
|
||||
equal = equal && (header1->nsegmx == header2->nsegmx);
|
||||
equal = equal && (header1->nswlmx == header2->nswlmx);
|
||||
equal = equal && (header1->nlbrmx == header2->nlbrmx);
|
||||
equal = equal && (header1->nilbrz == header2->nilbrz);
|
||||
equal = equal && (header1->dualp == header2->dualp);
|
||||
equal = equal && util_double_approx_equal(header1->sim_days , header2->sim_days );
|
||||
|
||||
return equal;
|
||||
}
|
||||
|
||||
void ecl_rsthead_fprintf_struct( const ecl_rsthead_type * header , FILE * stream) {
|
||||
fprintf(stream , "{.day = %d,\n",header->day);
|
||||
fprintf(stream , ".year = %d,\n",header->year);
|
||||
fprintf(stream , ".month = %d,\n",header->month);
|
||||
fprintf(stream , ".sim_time = %ld,\n",header->sim_time);
|
||||
fprintf(stream , ".version = %d,\n",header->version);
|
||||
fprintf(stream , ".phase_sum = %d,\n",header->phase_sum);
|
||||
fprintf(stream , ".nx = %d,\n",header->nx);
|
||||
fprintf(stream , ".ny = %d,\n",header->ny);
|
||||
fprintf(stream , ".nz = %d,\n",header->nz);
|
||||
fprintf(stream , ".nactive = %d,\n",header->nactive);
|
||||
fprintf(stream , ".nwells = %d,\n",header->nwells);
|
||||
fprintf(stream , ".niwelz = %d,\n",header->niwelz);
|
||||
fprintf(stream , ".nzwelz = %d,\n",header->nzwelz);
|
||||
fprintf(stream , ".niconz = %d,\n",header->niconz);
|
||||
fprintf(stream , ".ncwmax = %d,\n",header->ncwmax);
|
||||
fprintf(stream , ".nisegz = %d,\n",header->nisegz);
|
||||
fprintf(stream , ".nsegmx = %d,\n",header->nsegmx);
|
||||
fprintf(stream , ".nswlmx = %d,\n",header->nswlmx);
|
||||
fprintf(stream , ".nlbrmx = %d,\n",header->nlbrmx);
|
||||
fprintf(stream , ".nilbrz = %d,\n",header->nilbrz);
|
||||
fprintf(stream , ".dualp = %d,\n",header->dualp);
|
||||
fprintf(stream , ".sim_days = %g};\n",header->sim_days);
|
||||
}
|
||||
|
||||
|
||||
void ecl_rsthead_free( ecl_rsthead_type * rsthead ) {
|
||||
free( rsthead );
|
||||
}
|
8
ThirdParty/Ert/devel/libecl/src/ecl_sum.c
vendored
8
ThirdParty/Ert/devel/libecl/src/ecl_sum.c
vendored
@ -31,6 +31,7 @@
|
||||
#include <ert/util/bool_vector.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/time_interval.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_sum.h>
|
||||
@ -402,6 +403,9 @@ double ecl_sum_get_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days
|
||||
return ecl_sum_data_get_from_sim_days( ecl_sum->data , sim_days , node );
|
||||
}
|
||||
|
||||
double ecl_sum_time2days( const ecl_sum_type * ecl_sum , time_t sim_time) {
|
||||
return ecl_sum_data_time2days( ecl_sum->data , sim_time );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -810,6 +814,10 @@ time_t ecl_sum_iget_sim_time( const ecl_sum_type * ecl_sum , int index ) {
|
||||
return ecl_sum_data_iget_sim_time( ecl_sum->data , index );
|
||||
}
|
||||
|
||||
const time_interval_type * ecl_sum_get_sim_time( const ecl_sum_type * ecl_sum) {
|
||||
return ecl_sum_data_get_sim_time( ecl_sum->data );
|
||||
}
|
||||
|
||||
time_t ecl_sum_get_data_start( const ecl_sum_type * ecl_sum ) {
|
||||
return ecl_sum_data_get_data_start( ecl_sum->data );
|
||||
}
|
||||
|
48
ThirdParty/Ert/devel/libecl/src/ecl_sum_data.c
vendored
48
ThirdParty/Ert/devel/libecl/src/ecl_sum_data.c
vendored
@ -23,6 +23,7 @@
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/int_vector.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/time_interval.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_smspec.h>
|
||||
@ -212,10 +213,6 @@ struct ecl_sum_data_struct {
|
||||
int first_ministep;
|
||||
int last_ministep;
|
||||
double days_start;
|
||||
time_t data_start_time; /* This is the first time_t we have data for; will typically
|
||||
agree with sim_start,
|
||||
but in the case of restarts it will be after sim_start. */
|
||||
time_t sim_end;
|
||||
double sim_length;
|
||||
int_vector_type * report_first_index ; /* Indexed by report_step - giving first internal_index in report_step. */
|
||||
int_vector_type * report_last_index; /* Indexed by report_step - giving last internal_index in report_step. */
|
||||
@ -224,6 +221,9 @@ struct ecl_sum_data_struct {
|
||||
time_t __min_time; /* An internal member used during the load of
|
||||
restarted cases; see doc in ecl_sum_data_append_tstep. */
|
||||
bool index_valid;
|
||||
time_interval_type * sim_time; /* The time interval sim_time goes from the first time value where we have
|
||||
data to the end of the simulation. In the case of restarts the start
|
||||
value might disagree with the simulation start reported by the smspec file. */
|
||||
};
|
||||
|
||||
|
||||
@ -236,6 +236,7 @@ struct ecl_sum_data_struct {
|
||||
vector_free( data->data );
|
||||
int_vector_free( data->report_first_index );
|
||||
int_vector_free( data->report_last_index );
|
||||
time_interval_free( data->sim_time );
|
||||
free(data);
|
||||
}
|
||||
|
||||
@ -253,12 +254,11 @@ static void ecl_sum_data_clear_index( ecl_sum_data_type * data ) {
|
||||
data->first_report_step = 1024 * 1024;
|
||||
data->last_report_step = -1024 * 1024;
|
||||
data->days_start = 0;
|
||||
data->data_start_time = -1;
|
||||
data->sim_end = -1;
|
||||
data->sim_length = -1;
|
||||
data->first_ministep = -1;
|
||||
data->last_ministep = -1;
|
||||
data->index_valid = false;
|
||||
time_interval_reopen( data->sim_time );
|
||||
}
|
||||
|
||||
|
||||
@ -270,7 +270,7 @@ ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) {
|
||||
|
||||
data->report_first_index = int_vector_alloc( 0 , -1 ); /* This -1 value is hard-wired around in the place - not good. */
|
||||
data->report_last_index = int_vector_alloc( 0 , -1 );
|
||||
|
||||
data->sim_time = time_interval_alloc_open();
|
||||
|
||||
ecl_sum_data_clear_index( data );
|
||||
return data;
|
||||
@ -437,10 +437,11 @@ void ecl_sum_data_fwrite( const ecl_sum_data_type * data , const char * ecl_case
|
||||
|
||||
|
||||
|
||||
const time_interval_type * ecl_sum_data_get_sim_time( const ecl_sum_data_type * data) { return data->sim_time; }
|
||||
|
||||
time_t ecl_sum_data_get_sim_end (const ecl_sum_data_type * data ) { return data->sim_end; }
|
||||
time_t ecl_sum_data_get_sim_end (const ecl_sum_data_type * data ) { return time_interval_get_end( data->sim_time ); }
|
||||
|
||||
time_t ecl_sum_data_get_data_start ( const ecl_sum_data_type * data ) { return data->data_start_time; }
|
||||
time_t ecl_sum_data_get_data_start ( const ecl_sum_data_type * data ) { return time_interval_get_start( data->sim_time ); }
|
||||
|
||||
double ecl_sum_data_get_first_day( const ecl_sum_data_type * data) { return data->days_start; }
|
||||
|
||||
@ -469,10 +470,10 @@ double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ) {
|
||||
*/
|
||||
|
||||
bool ecl_sum_data_check_sim_time( const ecl_sum_data_type * data , time_t sim_time) {
|
||||
if ((sim_time < data->data_start_time) || (sim_time > data->sim_end))
|
||||
return false;
|
||||
else
|
||||
if (time_interval_contains( data->sim_time , sim_time ) || (sim_time == time_interval_get_end( data->sim_time)))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -524,14 +525,15 @@ bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_da
|
||||
|
||||
|
||||
static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data , time_t sim_time) {
|
||||
time_t data_start_time = data->data_start_time;
|
||||
time_t data_start_time = time_interval_get_start( data->sim_time );
|
||||
time_t sim_end = time_interval_get_end( data->sim_time );
|
||||
|
||||
if ((sim_time < data_start_time) || (sim_time > data->sim_end)) {
|
||||
if (!ecl_sum_data_check_sim_time( data , sim_time )) {
|
||||
fprintf(stderr , "Simulation start: "); util_fprintf_date( ecl_smspec_get_start_time( data->smspec ) , stderr );
|
||||
fprintf(stderr , "Data start......: "); util_fprintf_date( data_start_time , stderr );
|
||||
fprintf(stderr , "Simulation end .: "); util_fprintf_date( data->sim_end , stderr );
|
||||
fprintf(stderr , "Simulation end .: "); util_fprintf_date( sim_end , stderr );
|
||||
fprintf(stderr , "Requested date .: "); util_fprintf_date( sim_time , stderr );
|
||||
util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , data_start_time , data->sim_end);
|
||||
util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , data_start_time , sim_end);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -705,9 +707,9 @@ static void ecl_sum_data_append_tstep__( ecl_sum_data_type * data , int ministep
|
||||
static void ecl_sum_data_update_end_info( ecl_sum_data_type * sum_data ) {
|
||||
const ecl_sum_tstep_type * last_ministep = vector_get_last_const( sum_data->data );
|
||||
|
||||
sum_data->last_ministep = ecl_sum_tstep_get_ministep( last_ministep );
|
||||
sum_data->last_ministep = ecl_sum_tstep_get_ministep( last_ministep );
|
||||
sum_data->sim_length = ecl_sum_tstep_get_sim_days( last_ministep );
|
||||
sum_data->sim_end = ecl_sum_tstep_get_sim_time( last_ministep );
|
||||
time_interval_update_end( sum_data->sim_time , ecl_sum_tstep_get_sim_time( last_ministep ));
|
||||
}
|
||||
|
||||
static int cmp_ministep( const void * arg1 , const void * arg2) {
|
||||
@ -749,7 +751,7 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) {
|
||||
will be a difference.
|
||||
*/
|
||||
sum_data->days_start = ecl_sum_tstep_get_sim_days( first_ministep );
|
||||
sum_data->data_start_time = ecl_sum_tstep_get_sim_time( first_ministep );
|
||||
time_interval_update_start( sum_data->sim_time , ecl_sum_tstep_get_sim_time( first_ministep ));
|
||||
}
|
||||
ecl_sum_data_update_end_info( sum_data );
|
||||
|
||||
@ -1199,7 +1201,8 @@ int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , doub
|
||||
|
||||
|
||||
int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time_t sim_time) {
|
||||
if ((sim_time < data->data_start_time) || (sim_time > data->sim_end))
|
||||
|
||||
if (!ecl_sum_data_check_sim_time(data , sim_time))
|
||||
return -1;
|
||||
|
||||
{
|
||||
@ -1232,6 +1235,11 @@ int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time
|
||||
}
|
||||
|
||||
|
||||
double ecl_sum_data_time2days( const ecl_sum_data_type * data , time_t sim_time) {
|
||||
time_t start_time = ecl_smspec_get_start_time( data->smspec );
|
||||
return util_difftime_days( start_time , sim_time );
|
||||
}
|
||||
|
||||
double ecl_sum_data_get_from_sim_days( const ecl_sum_data_type * data , double sim_days , const smspec_node_type * smspec_node) {
|
||||
time_t sim_time = ecl_smspec_get_start_time( data->smspec );
|
||||
util_inplace_forward_days( &sim_time , sim_days );
|
||||
|
64
ThirdParty/Ert/devel/libecl/src/ecl_util.c
vendored
64
ThirdParty/Ert/devel/libecl/src/ecl_util.c
vendored
@ -1322,6 +1322,70 @@ bool ecl_util_valid_basename( const char * basename ) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Will append time_t values corresponding to the first day in every
|
||||
month in the open interval (start_date , end_date). Iff start_date
|
||||
corresponds to the first date in a month the list will start with
|
||||
start_date, otherwise the list will start with the first day in the
|
||||
month following after start_date.
|
||||
|
||||
If end_date corresponds to the first day of the month the list will
|
||||
end with end_date, otherwise it will ende with the first day in the
|
||||
month prior to end_date:
|
||||
|
||||
(1,1,2000) , (10,3,2000) => {(1,1,2000) , (1,2,2000) , (1,3,2000) }
|
||||
(10,1,2000) , (1,4,2000) => {(1,2,2000) , (1,3,2000) , (1,4,2000) }
|
||||
|
||||
All time_t values added to the date list will be pure dates,
|
||||
i.e. the time part will be 00:00:00; that also applies to start_date
|
||||
and end_date where possible time parts will be normalized away prior
|
||||
to insertion.
|
||||
*/
|
||||
|
||||
|
||||
void ecl_util_append_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date , bool force_append_end) {
|
||||
start_date = util_make_pure_date( start_date );
|
||||
end_date = util_make_pure_date( end_date );
|
||||
|
||||
if (util_is_first_day_in_month( start_date))
|
||||
time_t_vector_append( date_list , start_date );
|
||||
|
||||
{
|
||||
time_t current_date = start_date;
|
||||
while (true) {
|
||||
int month,year;
|
||||
util_set_date_values( current_date , NULL , &month , &year);
|
||||
if (month == 12) {
|
||||
month = 1;
|
||||
year += 1;
|
||||
} else
|
||||
month += 1;
|
||||
|
||||
current_date = util_make_date( 1 , month , year );
|
||||
if (current_date < end_date)
|
||||
time_t_vector_append( date_list , current_date );
|
||||
else {
|
||||
if (current_date == end_date)
|
||||
time_t_vector_append( date_list , current_date );
|
||||
else if (force_append_end)
|
||||
time_t_vector_append( date_list , end_date );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ecl_util_init_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date) {
|
||||
time_t_vector_reset( date_list );
|
||||
if (!util_is_first_day_in_month( start_date ))
|
||||
time_t_vector_append( date_list , util_make_pure_date(start_date));
|
||||
|
||||
ecl_util_append_month_range( date_list , start_date , end_date , true );
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
/* Small functions to support enum introspection. */
|
||||
|
||||
|
25
ThirdParty/Ert/devel/libecl/src/smspec_node.c
vendored
25
ThirdParty/Ert/devel/libecl/src/smspec_node.c
vendored
@ -65,6 +65,7 @@ struct smspec_node_struct {
|
||||
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. */
|
||||
};
|
||||
@ -234,8 +235,12 @@ 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;
|
||||
}
|
||||
|
||||
static char LAST_CHAR(const char * s) {
|
||||
return s[ strlen(s) - 1];
|
||||
}
|
||||
|
||||
static void smspec_node_set_flags( smspec_node_type * smspec_node) {
|
||||
/*
|
||||
@ -249,7 +254,7 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) {
|
||||
int ivar;
|
||||
for (ivar = 0; ivar < num_rate_vars; ivar++) {
|
||||
const char * var_substring = &smspec_node->keyword[1];
|
||||
if (util_string_equal( rate_vars[ivar] , var_substring)) {
|
||||
if (strncmp( rate_vars[ivar] , var_substring , strlen( rate_vars[ivar] )) == 0) {
|
||||
is_rate = true;
|
||||
break;
|
||||
}
|
||||
@ -257,6 +262,11 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) {
|
||||
smspec_node->rate_variable = is_rate;
|
||||
}
|
||||
|
||||
{
|
||||
if (LAST_CHAR(smspec_node->keyword) == 'H')
|
||||
smspec_node->historical = true;
|
||||
}
|
||||
|
||||
/*
|
||||
This code checks in a predefined list whether a certain WGNAMES
|
||||
variable represents a total accumulated quantity. Only the last three
|
||||
@ -265,7 +275,7 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) {
|
||||
|
||||
The list below is all the keyowrds with 'Total' in the information from
|
||||
the tables 2.7 - 2.11 in the ECLIPSE fileformat documentation. Have
|
||||
skipped some of the most exotic keywords (AND ALL THE HISTORICAL).
|
||||
skipped some of the most exotic keywords.
|
||||
*/
|
||||
{
|
||||
bool is_total = false;
|
||||
@ -278,7 +288,12 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) {
|
||||
int ivar;
|
||||
for (ivar = 0; ivar < num_total_vars; ivar++) {
|
||||
const char * var_substring = &smspec_node->keyword[1];
|
||||
if (util_string_equal( total_vars[ivar] , var_substring)) {
|
||||
/*
|
||||
We want to mark both FOPT and FOPTH as historical variables;
|
||||
we use strncmp() to make certain that the trailing 'H' is
|
||||
not included in the comparison.
|
||||
*/
|
||||
if (strncmp( total_vars[ivar] , var_substring , strlen( total_vars[ivar] )) == 0) {
|
||||
is_total = true;
|
||||
break;
|
||||
}
|
||||
@ -761,6 +776,10 @@ bool smspec_node_is_total( const smspec_node_type * smspec_node ){
|
||||
return smspec_node->total_variable;
|
||||
}
|
||||
|
||||
bool smspec_node_is_historical( const smspec_node_type * smspec_node ){
|
||||
return smspec_node->historical;
|
||||
}
|
||||
|
||||
|
||||
const char * smspec_node_get_unit( const smspec_node_type * smspec_node) {
|
||||
return smspec_node->unit;
|
||||
|
43
ThirdParty/Ert/devel/libecl/tests/CMakeLists.txt
vendored
43
ThirdParty/Ert/devel/libecl/tests/CMakeLists.txt
vendored
@ -1,18 +1,55 @@
|
||||
add_executable( ecl_coarse_test ecl_coarse_test.c )
|
||||
target_link_libraries( ecl_coarse_test ecl )
|
||||
add_test( ecl_coarse_test ${EXECUTABLE_OUTPUT_PATH}/ecl_coarse_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
|
||||
|
||||
|
||||
add_executable( ecl_restart_test ecl_restart_test.c )
|
||||
target_link_libraries( ecl_restart_test ecl )
|
||||
add_test( ecl_restart_test ${EXECUTABLE_OUTPUT_PATH}/ecl_restart_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
|
||||
|
||||
|
||||
|
||||
add_executable( ecl_lgr_test ecl_lgr_test.c )
|
||||
target_link_libraries( ecl_lgr_test ecl )
|
||||
|
||||
add_test( ecl_coarse_test ${EXECUTABLE_OUTPUT_PATH}/ecl_coarse_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
|
||||
add_test( ecl_restart_test ${EXECUTABLE_OUTPUT_PATH}/ecl_restart_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
|
||||
add_test( ecl_lgr_test1 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID)
|
||||
add_test( ecl_lgr_test2 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.GRID)
|
||||
|
||||
|
||||
add_executable( ecl_grid_simple ecl_grid_simple.c )
|
||||
target_link_libraries( ecl_grid_simple ecl )
|
||||
add_test( ecl_grid_simple ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_simple ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
|
||||
|
||||
|
||||
add_executable( ecl_kw_grdecl ecl_kw_grdecl.c )
|
||||
target_link_libraries( ecl_kw_grdecl ecl )
|
||||
add_test( ecl_kw_grdecl ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_grdecl )
|
||||
|
||||
add_executable( ecl_kw_equal ecl_kw_equal.c )
|
||||
target_link_libraries( ecl_kw_equal ecl )
|
||||
add_test( ecl_kw_equal ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_equal )
|
||||
|
||||
|
||||
add_executable( ecl_dualp ecl_dualp.c )
|
||||
target_link_libraries( ecl_dualp ecl )
|
||||
add_test( ecl_dualp ${EXECUTABLE_OUTPUT_PATH}/ecl_dualp ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
|
||||
|
||||
add_executable( ecl_util_month_range ecl_util_month_range.c )
|
||||
target_link_libraries( ecl_util_month_range ecl )
|
||||
add_test( ecl_util_month_range ${EXECUTABLE_OUTPUT_PATH}/ecl_util_month_range )
|
||||
|
||||
add_executable( ecl_sum_test ecl_sum_test.c )
|
||||
target_link_libraries( ecl_sum_test ecl )
|
||||
add_test( ecl_sum_test ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
|
||||
|
||||
add_executable( ecl_rsthead ecl_rsthead.c )
|
||||
target_link_libraries( ecl_rsthead ecl )
|
||||
add_test( ecl_rsthead ${EXECUTABLE_OUTPUT_PATH}/ecl_rsthead ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO.X0005 )
|
||||
|
||||
set_property( TEST ecl_coarse_test PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_restart_test PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_lgr_test1 PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_lgr_test2 PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_grid_simple PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_dualp PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_sum_test PROPERTY LABELS Statoil )
|
||||
|
76
ThirdParty/Ert/devel/libecl/tests/ecl_dualp.c
vendored
Normal file
76
ThirdParty/Ert/devel/libecl/tests/ecl_dualp.c
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_dualp.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * case_path = argv[1];
|
||||
char * grid_file = ecl_util_alloc_filename( NULL , case_path , ECL_EGRID_FILE , false , 0 );
|
||||
char * init_file = ecl_util_alloc_filename( NULL , case_path , ECL_INIT_FILE , false , 0 );
|
||||
char * rst_file = ecl_util_alloc_filename( NULL , case_path , ECL_RESTART_FILE , false , 0 );
|
||||
|
||||
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_file );
|
||||
ecl_file_type * RST_file = ecl_file_open( rst_file );
|
||||
ecl_file_type * INIT_file = ecl_file_open( init_file );
|
||||
ecl_file_type * GRID_file = ecl_file_open( grid_file );
|
||||
|
||||
{
|
||||
ecl_kw_type * actnum = ecl_file_iget_named_kw( GRID_file , "ACTNUM" , 0 );
|
||||
ecl_kw_type * swat = ecl_file_iget_named_kw( RST_file , "SWAT" , 0 );
|
||||
ecl_kw_type * permx = ecl_file_iget_named_kw( INIT_file , "PERMX" , 0 );
|
||||
int fracture_size = ecl_grid_get_nactive_fracture( ecl_grid );
|
||||
int matrix_size = ecl_grid_get_nactive( ecl_grid );
|
||||
|
||||
test_assert_int_equal( fracture_size + matrix_size , ecl_kw_get_size( swat ));
|
||||
test_assert_int_equal( fracture_size + matrix_size , ecl_kw_get_size( permx ));
|
||||
|
||||
{
|
||||
int gi;
|
||||
int matrix_index = 0;
|
||||
int fracture_index = 0;
|
||||
|
||||
for (gi = 0; gi < ecl_grid_get_global_size( ecl_grid ); gi++) {
|
||||
if (ecl_kw_iget_int( actnum , gi ) & ACTIVE_MATRIX) {
|
||||
test_assert_int_equal( ecl_grid_get_active_index1( ecl_grid , gi ) , matrix_index);
|
||||
test_assert_int_equal( ecl_grid_get_global_index1A( ecl_grid , matrix_index ) , gi);
|
||||
matrix_index++;
|
||||
}
|
||||
|
||||
if (ecl_kw_iget_int( actnum , gi ) & ACTIVE_FRACTURE) {
|
||||
test_assert_int_equal( ecl_grid_get_active_fracture_index1( ecl_grid , gi ) , fracture_index);
|
||||
test_assert_int_equal( ecl_grid_get_global_index1F( ecl_grid , fracture_index ) , gi);
|
||||
fracture_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ecl_file_close( RST_file );
|
||||
ecl_file_close( INIT_file );
|
||||
ecl_grid_free( ecl_grid );
|
||||
|
||||
exit(0);
|
||||
}
|
36
ThirdParty/Ert/devel/libecl/tests/ecl_grid_simple.c
vendored
Normal file
36
ThirdParty/Ert/devel/libecl/tests/ecl_grid_simple.c
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_grid_simple.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * grid_file = argv[1];
|
||||
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_file );
|
||||
|
||||
test_assert_int_equal( ecl_grid_get_nactive_fracture( ecl_grid ) , 0 );
|
||||
test_assert_int_equal( ecl_grid_get_active_fracture_index1( ecl_grid , 10 ) , -1 );
|
||||
|
||||
ecl_grid_free( ecl_grid );
|
||||
exit(0);
|
||||
}
|
65
ThirdParty/Ert/devel/libecl/tests/ecl_kw_equal.c
vendored
Normal file
65
ThirdParty/Ert/devel/libecl/tests/ecl_kw_equal.c
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_kw_equal.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
ecl_kw_type * ecl_kw1 = ecl_kw_alloc( "KW" , 10 , ECL_INT_TYPE );
|
||||
int data[10];
|
||||
int i;
|
||||
for (i=0; i < 10; i++) {
|
||||
ecl_kw_iset_int(ecl_kw1 , i , i );
|
||||
data[i] = i;
|
||||
}
|
||||
|
||||
{
|
||||
ecl_kw_type * ecl_kw2 = ecl_kw_alloc_copy( ecl_kw1 );
|
||||
|
||||
test_assert_true( ecl_kw_equal( ecl_kw1 , ecl_kw2 ));
|
||||
|
||||
ecl_kw_iset_int( ecl_kw2 , 1 , 77 );
|
||||
test_assert_false( ecl_kw_equal( ecl_kw1 , ecl_kw2 ));
|
||||
ecl_kw_iset_int( ecl_kw2 , 1 , 1 );
|
||||
test_assert_true( ecl_kw_equal( ecl_kw1 , ecl_kw2 ));
|
||||
|
||||
ecl_kw_set_header_name( ecl_kw2 , "TEST" );
|
||||
test_assert_false( ecl_kw_equal( ecl_kw1 , ecl_kw2 ));
|
||||
test_assert_true( ecl_kw_content_equal( ecl_kw1 , ecl_kw2 ));
|
||||
ecl_kw_free( ecl_kw2 );
|
||||
}
|
||||
|
||||
{
|
||||
ecl_kw_type * ecl_ikw = ecl_kw_alloc_new_shared( "KW" , 10 , ECL_INT_TYPE , data);
|
||||
ecl_kw_type * ecl_fkw = ecl_kw_alloc_new_shared( "KW" , 10 , ECL_FLOAT_TYPE , data);
|
||||
|
||||
test_assert_true( ecl_kw_content_equal( ecl_kw1 , ecl_ikw ));
|
||||
test_assert_false( ecl_kw_content_equal( ecl_kw1 , ecl_fkw ));
|
||||
}
|
||||
|
||||
test_assert_true( ecl_kw_data_equal( ecl_kw1 , data ));
|
||||
data[0] = 99;
|
||||
test_assert_false( ecl_kw_data_equal( ecl_kw1 , data ));
|
||||
|
||||
|
||||
|
||||
}
|
70
ThirdParty/Ert/devel/libecl/tests/ecl_kw_grdecl.c
vendored
Normal file
70
ThirdParty/Ert/devel/libecl/tests/ecl_kw_grdecl.c
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_kw_grdecl.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
int i;
|
||||
ecl_kw_type * ecl_kw = ecl_kw_alloc("HEAD" , 10 , ECL_INT_TYPE);
|
||||
|
||||
for (i=0; i < 10; i++)
|
||||
ecl_kw_iset_int(ecl_kw , i , i );
|
||||
|
||||
{
|
||||
FILE * stream = util_fopen( "FILE.grdecl" , "w");
|
||||
|
||||
ecl_kw_fprintf_grdecl(ecl_kw , stream );
|
||||
fclose(stream);
|
||||
|
||||
stream = util_fopen( "FILE.grdecl" , "r");
|
||||
{
|
||||
ecl_kw_type * ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD" , 10 , ECL_INT_TYPE);
|
||||
|
||||
test_assert_not_NULL( ecl_kw2 );
|
||||
test_assert_true( ecl_kw_equal( ecl_kw , ecl_kw2));
|
||||
ecl_kw_free( ecl_kw2 );
|
||||
}
|
||||
fclose( stream );
|
||||
|
||||
stream = util_fopen( "FILE.grdecl" , "w");
|
||||
ecl_kw_fprintf_grdecl__(ecl_kw , "HEAD1234" , stream );
|
||||
fclose( stream );
|
||||
|
||||
stream = util_fopen( "FILE.grdecl" , "r");
|
||||
{
|
||||
ecl_kw_type * ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD" , 10 , ECL_INT_TYPE);
|
||||
|
||||
test_assert_NULL( ecl_kw2 );
|
||||
ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD1234" , 10 , ECL_INT_TYPE);
|
||||
test_assert_not_NULL( ecl_kw2 );
|
||||
|
||||
test_assert_string_equal( ecl_kw_get_header( ecl_kw2 ) , "HEAD1234" );
|
||||
test_assert_true( ecl_kw_content_equal( ecl_kw , ecl_kw2 ));
|
||||
ecl_kw_free( ecl_kw2 );
|
||||
}
|
||||
fclose( stream );
|
||||
|
||||
}
|
||||
ecl_kw_free( ecl_kw );
|
||||
|
||||
exit(0);
|
||||
}
|
108
ThirdParty/Ert/devel/libecl/tests/ecl_rsthead.c
vendored
Normal file
108
ThirdParty/Ert/devel/libecl/tests/ecl_rsthead.c
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
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>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
|
||||
|
||||
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 );
|
||||
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 );
|
||||
}
|
||||
test_assert_true( ecl_rsthead_equal( rst_head , true_header ));
|
||||
|
||||
ecl_rsthead_free( rst_head );
|
||||
} else
|
||||
test_assert_NULL( rst_head );
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
ecl_rsthead_type true1 = {.day = 1,
|
||||
.year = 2000,
|
||||
.month = 1,
|
||||
.sim_time = (time_t) 946681200,
|
||||
.version = 100,
|
||||
.phase_sum = 7,
|
||||
.nx = 40,
|
||||
.ny = 64,
|
||||
.nz = 14,
|
||||
.nactive = 34770,
|
||||
.nwells = 3,
|
||||
.niwelz = 145,
|
||||
.nzwelz = 3,
|
||||
.niconz = 20,
|
||||
.ncwmax = 120,
|
||||
.nisegz = 18,
|
||||
.nsegmx = 1,
|
||||
.nswlmx = 1,
|
||||
.nlbrmx = -1,
|
||||
.nilbrz = -1,
|
||||
.dualp = 0,
|
||||
.sim_days = 0};
|
||||
|
||||
ecl_rsthead_type true2 = {.day = 22,
|
||||
.year = 1990,
|
||||
.month = 1,
|
||||
.sim_time = (time_t) 632962800,
|
||||
.version = 100,
|
||||
.phase_sum = 7,
|
||||
.nx = 4,
|
||||
.ny = 4,
|
||||
.nz = 4,
|
||||
.nactive = 64,
|
||||
.nwells = 3,
|
||||
.niwelz = 147,
|
||||
.nzwelz = 3,
|
||||
.niconz = 20,
|
||||
.ncwmax = 13,
|
||||
.nisegz = 18,
|
||||
.nsegmx = 1,
|
||||
.nswlmx = 1,
|
||||
.nlbrmx = -1,
|
||||
.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);
|
||||
}
|
66
ThirdParty/Ert/devel/libecl/tests/ecl_sum_test.c
vendored
Normal file
66
ThirdParty/Ert/devel/libecl/tests/ecl_sum_test.c
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_sum_test.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_sum.h>
|
||||
|
||||
|
||||
void test_time_range( const ecl_sum_type * ecl_sum ) {
|
||||
// Hardcoded Gurbat case values
|
||||
time_t start = util_make_date( 1,1,2000);
|
||||
time_t end = util_make_date( 31,12,2004 );
|
||||
|
||||
test_assert_time_t_equal( ecl_sum_get_start_time( ecl_sum ) , start );
|
||||
test_assert_time_t_equal( ecl_sum_get_end_time( ecl_sum ) , end );
|
||||
test_assert_time_t_equal( ecl_sum_get_data_start(ecl_sum) , start);
|
||||
}
|
||||
|
||||
|
||||
void test_days( const ecl_sum_type * ecl_sum ) {
|
||||
time_t date1 = util_make_date( 1,1,2000);
|
||||
time_t date2 = util_make_date( 31,12,2004 );
|
||||
time_t date3 = util_make_date( 2,1,2000 );
|
||||
|
||||
double days1 = ecl_sum_time2days( ecl_sum , date1 );
|
||||
double days2 = ecl_sum_time2days( ecl_sum , date2);
|
||||
double days3 = ecl_sum_time2days( ecl_sum , date3 );
|
||||
|
||||
test_assert_double_equal( days1 , 0 );
|
||||
test_assert_double_equal( days2 , 1826 );
|
||||
test_assert_double_equal( days3 , 1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
const char * casename = argv[1];
|
||||
|
||||
ecl_sum_type * ecl_sum = ecl_sum_fread_alloc_case( casename , ":");
|
||||
|
||||
test_time_range( ecl_sum );
|
||||
test_days( ecl_sum );
|
||||
|
||||
exit(0);
|
||||
}
|
124
ThirdParty/Ert/devel/libecl/tests/ecl_util_month_range.c
vendored
Normal file
124
ThirdParty/Ert/devel/libecl/tests/ecl_util_month_range.c
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_util_month_range.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
|
||||
void test_body( time_t_vector_type * date_list , int offset) {
|
||||
int i;
|
||||
for (i=offset; i < (time_t_vector_size( date_list ) - 1); i++) {
|
||||
int month,year;
|
||||
time_t current_date = time_t_vector_iget( date_list , i );
|
||||
test_assert_true( util_is_first_day_in_month( current_date ));
|
||||
util_set_date_values( current_date , NULL , &month , &year);
|
||||
if (i > offset) {
|
||||
time_t prev_date = time_t_vector_iget( date_list , i - 1 );
|
||||
int prev_month , prev_year;
|
||||
util_set_date_values( prev_date , NULL , &prev_month , &prev_year);
|
||||
|
||||
if (prev_year == year)
|
||||
test_assert_int_equal( month , prev_month + 1);
|
||||
else {
|
||||
test_assert_int_equal( month , 1);
|
||||
test_assert_int_equal( prev_month , 12);
|
||||
test_assert_int_equal( year - prev_year , 1);
|
||||
}
|
||||
}
|
||||
test_assert_time_t_equal( current_date , util_make_pure_date( current_date ));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_append( const char * name , time_t_vector_type * date_list , time_t date1 , time_t date2, bool force_append_end) {
|
||||
int offset = time_t_vector_size( date_list );
|
||||
|
||||
printf("%s ...",name);
|
||||
fflush( stdout );
|
||||
|
||||
ecl_util_append_month_range( date_list , date1 , date2 , force_append_end);
|
||||
|
||||
// The start:
|
||||
test_assert_true( util_make_pure_date(date1) <= time_t_vector_iget( date_list , offset));
|
||||
|
||||
// The body:
|
||||
test_body( date_list , offset );
|
||||
|
||||
// The tail:
|
||||
if ( force_append_end )
|
||||
test_assert_time_t_equal( time_t_vector_get_last( date_list ) , util_make_pure_date(date2));
|
||||
else
|
||||
test_assert_true( util_is_first_day_in_month( time_t_vector_get_last( date_list )));
|
||||
|
||||
|
||||
printf(" OK \n");
|
||||
}
|
||||
|
||||
|
||||
void test_init( const char * name , time_t_vector_type * date_list , time_t start_date , time_t end_date) {
|
||||
printf("%s ...",name);
|
||||
fflush( stdout );
|
||||
{
|
||||
ecl_util_init_month_range( date_list , start_date , end_date );
|
||||
test_assert_time_t_equal( time_t_vector_get_first( date_list ) , util_make_pure_date( start_date ));
|
||||
test_body( date_list , 1 );
|
||||
test_assert_time_t_equal( time_t_vector_get_last( date_list ) , util_make_pure_date(end_date ));
|
||||
}
|
||||
printf(" OK \n");
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
time_t date1 = util_make_datetime(0,2,0,1,1,2000);
|
||||
time_t date2 = util_make_datetime(0,3,0,1,1,2005);
|
||||
time_t date3 = util_make_datetime(0,4,0,10,1,2000);
|
||||
time_t date4 = util_make_datetime(0,5,0,10,1,2005);
|
||||
|
||||
|
||||
|
||||
{
|
||||
time_t_vector_type * date_list = time_t_vector_alloc(0 ,0 );
|
||||
test_append( "Append Test1" , date_list , date1 , date2 , true);
|
||||
test_append( "Append Test2" , date_list , date1 , date2 , false);
|
||||
test_append( "Append Test3" , date_list , date1 , date4 , true);
|
||||
test_append( "Append Test4" , date_list , date1 , date4 , false);
|
||||
test_append( "Append Test5" , date_list , date3 , date2 , true);
|
||||
test_append( "Append Test6" , date_list , date3 , date2 , false);
|
||||
test_append( "Append Test7" , date_list , date3 , date4 , true);
|
||||
test_append( "Append Test8" , date_list , date3 , date4 , false);
|
||||
time_t_vector_free( date_list );
|
||||
}
|
||||
{
|
||||
time_t_vector_type * date_list = time_t_vector_alloc(0 ,0 );
|
||||
|
||||
test_init( "Init Test1" , date_list , date1 , date2 );
|
||||
test_init( "Init Test2" , date_list , date1 , date4 );
|
||||
test_init( "Init Test3" , date_list , date3 , date2 );
|
||||
test_init( "Init Test4" , date_list , date3 , date4 );
|
||||
|
||||
time_t_vector_free( date_list );
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
@ -3,6 +3,6 @@ if (BUILD_APPLICATONS)
|
||||
add_subdirectory( applications )
|
||||
endif()
|
||||
|
||||
#if (BUILD_TESTS)
|
||||
# add_subdirectory( tests )
|
||||
#endif()
|
||||
if (BUILD_TESTS)
|
||||
add_subdirectory( tests )
|
||||
endif()
|
||||
|
@ -12,9 +12,11 @@ foreach(prog ${program_list})
|
||||
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
endif()
|
||||
|
||||
install(TARGETS ${prog} DESTINATION ${destination})
|
||||
if (INSTALL_GROUP)
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})")
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})")
|
||||
if (INSTALL_ERT)
|
||||
install(TARGETS ${prog} DESTINATION ${destination})
|
||||
if (INSTALL_GROUP)
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})")
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/int_vector.h>
|
||||
|
||||
#include <ert/ecl/ecl_intehead.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
|
@ -27,7 +27,7 @@ extern "C" {
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/ecl/ecl_intehead.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
|
||||
typedef enum {
|
||||
well_conn_dirX = 1,
|
||||
@ -43,8 +43,8 @@ extern "C" {
|
||||
|
||||
void well_conn_free( well_conn_type * conn);
|
||||
void well_conn_free__( void * arg );
|
||||
well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw , const ecl_kw_type * iseg_kw , const ecl_intehead_type * header , int well_nr , int seg_well_nr , int conn_nr);
|
||||
well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_intehead_type * header , int well_nr);
|
||||
well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw , const ecl_kw_type * iseg_kw , const ecl_rsthead_type * header , int well_nr , int seg_well_nr , int conn_nr);
|
||||
well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_rsthead_type * header , int well_nr);
|
||||
|
||||
int well_conn_get_branch(const well_conn_type * conn);
|
||||
int well_conn_get_i(const well_conn_type * conn);
|
||||
@ -53,6 +53,8 @@ extern "C" {
|
||||
well_conn_dir_enum well_conn_get_dir(const well_conn_type * conn);
|
||||
bool well_conn_open( const well_conn_type * conn );
|
||||
int well_conn_get_segment( const well_conn_type * conn );
|
||||
bool well_conn_fracture_connection( const well_conn_type * conn);
|
||||
bool well_conn_matrix_connection( const well_conn_type * conn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ extern "C" {
|
||||
#include <time.h>
|
||||
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_intehead.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
|
@ -10,10 +10,11 @@ set_target_properties( ecl_well PROPERTIES VERSION 1.0 SOVERSION 1.0 )
|
||||
target_link_libraries( ecl_well ecl )
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
install(TARGETS ecl_well DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
foreach(header ${header_files})
|
||||
install(FILES ../include/ert/ecl_well/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/ecl_well)
|
||||
endforeach()
|
||||
|
||||
if (INSTALL_ERT)
|
||||
install(TARGETS ecl_well DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
foreach(header ${header_files})
|
||||
install(FILES ../include/ert/ecl_well/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/ecl_well)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
||||
|
45
ThirdParty/Ert/devel/libecl_well/src/well_conn.c
vendored
45
ThirdParty/Ert/devel/libecl_well/src/well_conn.c
vendored
@ -21,6 +21,7 @@
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
@ -37,7 +38,8 @@ struct well_conn_struct {
|
||||
int k;
|
||||
well_conn_dir_enum dir;
|
||||
bool open;
|
||||
int segment; // -1: Ordinary well
|
||||
int segment; // -1: Ordinary well
|
||||
bool matrix_connection; // k >= nz => fracture (and k -= nz )
|
||||
/*-----------------------------------------------------------------*/
|
||||
/* If the segment field == -1 - i.e. an ordinary well, the
|
||||
outlet_segment is rubbish and should not be consulted.
|
||||
@ -47,10 +49,23 @@ struct well_conn_struct {
|
||||
};
|
||||
|
||||
|
||||
static void well_conn_set_k( well_conn_type * conn , const ecl_rsthead_type * header , int icon_k) {
|
||||
conn->k = icon_k;
|
||||
conn->matrix_connection = true;
|
||||
|
||||
if (header->dualp) {
|
||||
int geometric_nz = header->nz / 2;
|
||||
if (icon_k >= geometric_nz) {
|
||||
conn->k -= geometric_nz;
|
||||
conn->matrix_connection = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_intehead_type * header , int well_nr) {
|
||||
|
||||
well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_rsthead_type * header , int well_nr) {
|
||||
const int iwel_offset = header->niwelz * well_nr;
|
||||
int conn_i = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADI_ITEM );
|
||||
|
||||
@ -59,8 +74,11 @@ well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const e
|
||||
|
||||
conn->i = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADI_ITEM ) - 1;
|
||||
conn->j = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADJ_ITEM ) - 1;
|
||||
conn->k = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADK_ITEM ) - 1;
|
||||
|
||||
{
|
||||
int icon_k = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADK_ITEM ) - 1;
|
||||
well_conn_set_k( conn , header , icon_k);
|
||||
}
|
||||
|
||||
conn->open = true; // This is not really specified anywhere.
|
||||
conn->branch = 0;
|
||||
conn->segment = 0;
|
||||
@ -72,12 +90,16 @@ well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const e
|
||||
}
|
||||
|
||||
|
||||
static well_conn_type * well_conn_alloc__( const ecl_kw_type * icon_kw , int icon_offset) {
|
||||
static well_conn_type * well_conn_alloc__( const ecl_kw_type * icon_kw , const ecl_rsthead_type * header , int icon_offset) {
|
||||
well_conn_type * conn = util_malloc( sizeof * conn );
|
||||
|
||||
conn->i = ecl_kw_iget_int( icon_kw , icon_offset + ICON_I_ITEM ) - 1;
|
||||
conn->j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_ITEM ) - 1;
|
||||
conn->k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_ITEM ) - 1;
|
||||
{
|
||||
int icon_k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_ITEM ) - 1;
|
||||
well_conn_set_k( conn , header , icon_k);
|
||||
}
|
||||
|
||||
conn->segment = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_ITEM ) - 1;
|
||||
|
||||
conn->outlet_segment = -999;
|
||||
@ -91,7 +113,7 @@ static well_conn_type * well_conn_alloc__( const ecl_kw_type * icon_kw , int ico
|
||||
*/
|
||||
well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw ,
|
||||
const ecl_kw_type * iseg_kw ,
|
||||
const ecl_intehead_type * header ,
|
||||
const ecl_rsthead_type * header ,
|
||||
int well_nr ,
|
||||
int seg_well_nr ,
|
||||
int conn_nr ) {
|
||||
@ -99,7 +121,7 @@ well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw ,
|
||||
const int icon_offset = header->niconz * ( header->ncwmax * well_nr + conn_nr );
|
||||
int IC = ecl_kw_iget_int( icon_kw , icon_offset + ICON_IC_ITEM );
|
||||
if (IC > 0) {
|
||||
well_conn_type * conn = well_conn_alloc__( icon_kw , icon_offset );
|
||||
well_conn_type * conn = well_conn_alloc__( icon_kw , header , icon_offset );
|
||||
{
|
||||
int int_status = ecl_kw_iget_int( icon_kw , icon_offset + ICON_STATUS_ITEM );
|
||||
if (int_status > 0)
|
||||
@ -204,4 +226,11 @@ int well_conn_get_segment( const well_conn_type * conn ) {
|
||||
return conn->segment;
|
||||
}
|
||||
|
||||
bool well_conn_fracture_connection( const well_conn_type * conn) {
|
||||
return !conn->matrix_connection;
|
||||
}
|
||||
|
||||
bool well_conn_matrix_connection( const well_conn_type * conn) {
|
||||
return conn->matrix_connection;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <ert/util/int_vector.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
|
||||
#include <ert/ecl/ecl_intehead.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
@ -287,14 +287,14 @@ static void well_info_add_state( well_info_type * well_info , well_state_type *
|
||||
*/
|
||||
|
||||
void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file , int report_nr) {
|
||||
ecl_intehead_type * global_header = ecl_intehead_alloc( ecl_file_iget_named_kw( rst_file , INTEHEAD_KW , 0 ));
|
||||
ecl_rsthead_type * global_header = ecl_rsthead_alloc( rst_file );
|
||||
int well_nr;
|
||||
for (well_nr = 0; well_nr < global_header->nwells; well_nr++) {
|
||||
well_state_type * well_state = well_state_alloc( rst_file , report_nr , well_nr );
|
||||
if (well_state != NULL)
|
||||
well_info_add_state( well_info , well_state );
|
||||
}
|
||||
ecl_intehead_free( global_header );
|
||||
ecl_rsthead_free( global_header );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <ert/util/int_vector.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/ecl/ecl_intehead.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
@ -96,7 +96,7 @@ well_path_type * well_state_add_path( well_state_type * well_state , const ecl_f
|
||||
}
|
||||
|
||||
|
||||
void well_state_add_wellhead( well_state_type * well_state , const ecl_intehead_type * header , const ecl_kw_type * iwel_kw , int well_nr , const char * grid_name , int grid_nr) {
|
||||
void well_state_add_wellhead( well_state_type * well_state , const ecl_rsthead_type * header , const ecl_kw_type * iwel_kw , int well_nr , const char * grid_name , int grid_nr) {
|
||||
well_conn_type * wellhead = well_conn_alloc_wellhead( iwel_kw , header , well_nr );
|
||||
|
||||
if (wellhead != NULL) {
|
||||
@ -113,7 +113,7 @@ void well_state_add_wellhead( well_state_type * well_state , const ecl_intehead_
|
||||
*/
|
||||
|
||||
static void well_state_add_connections( well_state_type * well_state , const ecl_file_type * rst_file , int grid_nr, int well_nr ) {
|
||||
ecl_intehead_type * header = ecl_intehead_alloc( ecl_file_iget_named_kw( rst_file , INTEHEAD_KW , 0 ));
|
||||
ecl_rsthead_type * header = ecl_rsthead_alloc( rst_file );
|
||||
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0);
|
||||
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0);
|
||||
const int iwel_offset = header->niwelz * well_nr;
|
||||
@ -152,7 +152,7 @@ static void well_state_add_connections( well_state_type * well_state , const ec
|
||||
well_path_add_conn( path , conn );
|
||||
}
|
||||
}
|
||||
ecl_intehead_free( header );
|
||||
ecl_rsthead_free( header );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -167,6 +167,7 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons
|
||||
int well_nr = -1;
|
||||
|
||||
if (ecl_file_has_kw( ecl_file , ZWEL_KW)) {
|
||||
ecl_rsthead_type * header = ecl_rsthead_alloc( ecl_file ); //
|
||||
const ecl_kw_type * zwel_kw = ecl_file_iget_named_kw( ecl_file , ZWEL_KW , 0);
|
||||
int num_wells = ecl_kw_get_size( zwel_kw );
|
||||
well_nr = 0;
|
||||
@ -174,7 +175,8 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons
|
||||
bool found = false;
|
||||
|
||||
{
|
||||
char * lgr_well_name = util_alloc_strip_copy( ecl_kw_iget_ptr( zwel_kw , well_nr) );
|
||||
char * lgr_well_name = util_alloc_strip_copy( ecl_kw_iget_ptr( zwel_kw , well_nr * header->nzwelz) );
|
||||
|
||||
if ( strcmp( well_state->name , lgr_well_name) == 0)
|
||||
found = true;
|
||||
else
|
||||
@ -189,7 +191,9 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons
|
||||
well_nr = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
ecl_rsthead_free( header );
|
||||
}
|
||||
return well_nr;
|
||||
}
|
||||
@ -197,8 +201,8 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons
|
||||
|
||||
well_state_type * well_state_alloc( ecl_file_type * ecl_file , int report_nr , int global_well_nr) {
|
||||
if (ecl_file_has_kw( ecl_file , IWEL_KW)) {
|
||||
well_state_type * well_state = NULL;
|
||||
ecl_intehead_type * global_header = ecl_intehead_alloc( ecl_file_iget_named_kw( ecl_file , INTEHEAD_KW , 0 ));
|
||||
well_state_type * well_state = NULL;
|
||||
ecl_rsthead_type * global_header = ecl_rsthead_alloc( ecl_file );
|
||||
const ecl_kw_type * global_iwel_kw = ecl_file_iget_named_kw( ecl_file , IWEL_KW , 0);
|
||||
const ecl_kw_type * global_zwel_kw = ecl_file_iget_named_kw( ecl_file , ZWEL_KW , 0);
|
||||
|
||||
@ -263,7 +267,6 @@ well_state_type * well_state_alloc( ecl_file_type * ecl_file , int report_nr ,
|
||||
ecl_file_subselect_block( ecl_file , LGR_KW , lgr_nr ); //
|
||||
{ // Restrict the file view
|
||||
int well_nr = well_state_get_lgr_well_nr( well_state , ecl_file); // to one LGR block.
|
||||
//
|
||||
if (well_nr >= 0) //
|
||||
well_state_add_connections( well_state , ecl_file , lgr_nr + 1, well_nr ); //
|
||||
} //
|
||||
@ -272,7 +275,7 @@ well_state_type * well_state_alloc( ecl_file_type * ecl_file , int report_nr ,
|
||||
}
|
||||
}
|
||||
}
|
||||
ecl_intehead_free( global_header );
|
||||
ecl_rsthead_free( global_header );
|
||||
return well_state;
|
||||
} else
|
||||
/* This seems a bit weird - have come over E300 restart files without the IWEL keyword. */
|
||||
|
51
ThirdParty/Ert/devel/libecl_well/src/well_ts.c
vendored
51
ThirdParty/Ert/devel/libecl_well/src/well_ts.c
vendored
@ -101,6 +101,7 @@ static well_node_type * well_node_alloc( well_state_type * well_state) {
|
||||
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION( well_node , WELL_NODE_TYPE_ID )
|
||||
static UTIL_SAFE_CAST_FUNCTION_CONST( well_node , WELL_NODE_TYPE_ID )
|
||||
|
||||
|
||||
static void well_node_free( well_node_type * well_node ) {
|
||||
@ -113,6 +114,20 @@ static void well_node_free__( void * arg ) {
|
||||
well_node_free( node );
|
||||
}
|
||||
|
||||
static int well_node_time_cmp( const void * arg1 , const void * arg2) {
|
||||
const well_node_type * node1 = well_node_safe_cast_const( arg1 );
|
||||
const well_node_type * node2 = well_node_safe_cast_const( arg2 );
|
||||
|
||||
if (node1->sim_time < node2->sim_time)
|
||||
return -1;
|
||||
else if (node1->sim_time == node2->sim_time)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
static well_ts_type * well_ts_alloc_empty( ) {
|
||||
@ -144,13 +159,13 @@ static int well_ts_get_index__( const well_ts_type * well_ts , int report_step ,
|
||||
|
||||
if (use_report) {
|
||||
if (report_step < first_node->report_nr)
|
||||
return 0; // Before the start
|
||||
return -1; // Before the start
|
||||
|
||||
if (report_step >= last_node->report_nr)
|
||||
return size - 1; // After end
|
||||
} else {
|
||||
if (sim_time < first_node->sim_time)
|
||||
return 0; // Before the start
|
||||
return -1; // Before the start
|
||||
|
||||
if (sim_time >= last_node->sim_time)
|
||||
return size - 1; // After end
|
||||
@ -247,33 +262,15 @@ static int well_ts_get_index( const well_ts_type * well_ts , int report_step , t
|
||||
|
||||
void well_ts_add_well( well_ts_type * well_ts , well_state_type * well_state ) {
|
||||
well_node_type * new_node = well_node_alloc( well_state );
|
||||
vector_append_owned_ref( well_ts->ts , new_node , well_node_free__ );
|
||||
|
||||
if (vector_get_size( well_ts->ts ) == 0)
|
||||
// The first element in the vector
|
||||
vector_append_owned_ref( well_ts->ts , new_node , well_node_free__ );
|
||||
else {
|
||||
if (vector_get_size( well_ts->ts ) > 1) {
|
||||
const well_node_type * last_node = vector_get_last_const(well_ts->ts );
|
||||
if (new_node->sim_time > last_node->sim_time)
|
||||
// This is the fast path which will apply when the well_state objects
|
||||
// are added in a time-ordered fashion.
|
||||
vector_append_owned_ref( well_ts->ts , new_node , well_node_free__ );
|
||||
else {
|
||||
// Use binary search through the vector to determine the
|
||||
// new location
|
||||
int index = well_ts_get_index( well_ts , new_node->report_nr , -1 , true);
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
|
||||
{
|
||||
const well_node_type * exnode = vector_iget_const( well_ts->ts , index );
|
||||
if (exnode->report_nr == new_node->report_nr)
|
||||
// Replace the exsisting node
|
||||
vector_iset_owned_ref( well_ts->ts , index , new_node , well_node_free__ );
|
||||
else
|
||||
// Insert a new node - pushing the existing to the right.
|
||||
vector_insert_owned_ref( well_ts->ts , index , new_node , well_node_free__ );
|
||||
}
|
||||
}
|
||||
if (new_node->sim_time < last_node->sim_time)
|
||||
// The new node is chronologically before the previous node;
|
||||
// i.e. we must sort the nodes in time. This should probably happen
|
||||
// quite seldom:
|
||||
vector_sort( well_ts->ts , well_node_time_cmp );
|
||||
}
|
||||
}
|
||||
|
||||
|
16
ThirdParty/Ert/devel/libecl_well/tests/CMakeLists.txt
vendored
Normal file
16
ThirdParty/Ert/devel/libecl_well/tests/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
add_executable( well_ts well_ts.c )
|
||||
target_link_libraries( well_ts ecl_well )
|
||||
add_test( well_ts ${EXECUTABLE_OUTPUT_PATH}/well_ts ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/CO2case/BASE_CASE )
|
||||
set_property( TEST well_ts PROPERTY LABELS Statoil )
|
||||
|
||||
|
||||
add_executable( well_dualp well_dualp.c )
|
||||
target_link_libraries( well_dualp ecl_well )
|
||||
add_test( well_dualp ${EXECUTABLE_OUTPUT_PATH}/well_dualp ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO.X0005 )
|
||||
|
||||
|
||||
add_executable( well_lgr_load well_lgr_load.c )
|
||||
target_link_libraries( well_lgr_load ecl_well )
|
||||
add_test( well_lgr_load ${EXECUTABLE_OUTPUT_PATH}/well_lgr_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.X0003)
|
||||
set_property( TEST well_lgr_load PROPERTY LABELS Statoil )
|
65
ThirdParty/Ert/devel/libecl_well/tests/well_dualp.c
vendored
Normal file
65
ThirdParty/Ert/devel/libecl_well/tests/well_dualp.c
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_dualp.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
|
||||
void test_rstfile( const char * filename , bool fracture_connection) {
|
||||
ecl_file_type * rst_file = ecl_file_open( filename );
|
||||
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0);
|
||||
ecl_rsthead_type * header = ecl_rsthead_alloc( rst_file );
|
||||
|
||||
well_conn_type * wellhead = well_conn_alloc_wellhead( iwel_kw , header , 0 );
|
||||
|
||||
if (fracture_connection) {
|
||||
test_assert_true( well_conn_fracture_connection( wellhead ));
|
||||
test_assert_false( well_conn_matrix_connection( wellhead ));
|
||||
} else {
|
||||
test_assert_false( well_conn_fracture_connection( wellhead ));
|
||||
test_assert_true( well_conn_matrix_connection( wellhead ));
|
||||
}
|
||||
|
||||
test_assert_true( well_conn_get_k( wellhead ) < header->nz );
|
||||
|
||||
ecl_rsthead_free( header );
|
||||
well_conn_free( wellhead );
|
||||
ecl_file_close( rst_file );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * matrix_rstfile = argv[1];
|
||||
const char * fracture_rstfile = argv[2];
|
||||
|
||||
test_rstfile( fracture_rstfile , true);
|
||||
test_rstfile( matrix_rstfile , false );
|
||||
|
||||
exit(0);
|
||||
}
|
66
ThirdParty/Ert/devel/libecl_well/tests/well_lgr_load.c
vendored
Normal file
66
ThirdParty/Ert/devel/libecl_well/tests/well_lgr_load.c
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_lgr_load.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <stdbool.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/int_vector.h>
|
||||
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
#include <ert/ecl_well/well_state.h>
|
||||
#include <ert/ecl_well/well_info.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_ts.h>
|
||||
|
||||
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */
|
||||
signal(SIGTERM , util_abort_signal); /* If killing the enkf program with SIGTERM (the default kill signal) you will get a backtrace.
|
||||
Killing with SIGKILL (-9) will not give a backtrace.*/
|
||||
signal(SIGABRT , util_abort_signal); /* Signal abort. */
|
||||
{
|
||||
well_info_type * well_info = well_info_alloc( NULL );
|
||||
int i;
|
||||
for (i=1; i < argc; i++) {
|
||||
printf("Loading file: %s \n",argv[i]);
|
||||
well_info_load_rstfile( well_info , argv[i]);
|
||||
}
|
||||
|
||||
// List all wells:
|
||||
{
|
||||
int iwell;
|
||||
for (iwell = 0; iwell < well_info_get_num_wells( well_info ); iwell++) {
|
||||
well_ts_type * well_ts = well_info_get_ts( well_info , well_info_iget_well_name( well_info , iwell));
|
||||
well_state_type * well_state = well_ts_get_last_state( well_ts );
|
||||
|
||||
well_state_summarize( well_state , stdout );
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
well_info_free( well_info );
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
71
ThirdParty/Ert/devel/libecl_well/tests/well_ts.c
vendored
Normal file
71
ThirdParty/Ert/devel/libecl_well/tests/well_ts.c
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_ts.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
#include <ert/ecl_well/well_info.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * case_path = argv[1];
|
||||
stringlist_type * file_list = stringlist_alloc_new( );
|
||||
ecl_util_select_filelist( NULL , case_path , ECL_RESTART_FILE , false , file_list);
|
||||
|
||||
printf("Searching in:%s \n",case_path);
|
||||
test_assert_int_equal( 4 , stringlist_get_size( file_list ));
|
||||
stringlist_sort( file_list , (string_cmp_ftype *) util_strcmp_int );
|
||||
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < stringlist_get_size( file_list); i++) {
|
||||
char * ext;
|
||||
char * target_ext = util_alloc_sprintf("X%04d" , i);
|
||||
util_alloc_file_components( stringlist_iget( file_list , i ) , NULL , NULL , &ext);
|
||||
|
||||
test_assert_string_equal( ext , target_ext);
|
||||
free( ext );
|
||||
free( target_ext );
|
||||
}
|
||||
}
|
||||
{
|
||||
well_info_type * well_info = well_info_alloc( NULL );
|
||||
int i;
|
||||
for (i=0; i < stringlist_get_size( file_list ); i++)
|
||||
well_info_load_rstfile( well_info , stringlist_iget(file_list , i));
|
||||
well_info_free( well_info );
|
||||
}
|
||||
|
||||
{
|
||||
well_info_type * well_info = well_info_alloc( NULL );
|
||||
int i;
|
||||
stringlist_reverse( file_list );
|
||||
for (i=0; i < stringlist_get_size( file_list ); i++)
|
||||
well_info_load_rstfile( well_info , stringlist_iget(file_list , i));
|
||||
well_info_free( well_info );
|
||||
}
|
||||
|
||||
|
||||
exit(0);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user