#1396 Update libEcl to 06a39878636af0bc52582430ad0431450e51139c

To include phase split well connection rates and some summary intersect support. Supposedly Final update before release.
This commit is contained in:
Jacob Støren 2017-05-08 13:37:39 +02:00
parent 59cccf60f0
commit f5d1d2d1f9
264 changed files with 1776 additions and 1482 deletions

View File

@ -8,7 +8,7 @@ set(RESINSIGHT_INCREMENT_VERSION "flow.13")
set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f")
# https://github.com/Statoil/libecl
set(ERT_GITHUB_SHA "f39d2e7fd196350ab1db86bb1bd5a3faca72d75d")
set(ERT_GITHUB_SHA "06a39878636af0bc52582430ad0431450e51139c")
# https://github.com/OPM/opm-flowdiagnostics
set(OPM_FLOWDIAGNOSTICS_SHA "a14dc4ba1302bcc1e0aeb35c5de6b4bd39bce98")

View File

@ -22,6 +22,5 @@ python/lib64
scratch.sparsebundle
*.iml
*.DS_Store
__ert_lib_path.py
__ert_lib_info.py
__ecl_lib_path.py
__ecl_lib_info.py

View File

@ -129,17 +129,6 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
if (BUILD_SHARED_LIBS)
set( LIBRARY_TYPE SHARED )
else()
set( LIBRARY_TYPE STATIC )
if (BUILD_ERT)
message(FATAL_ERROR "The full ERT application must be built with shared libraries")
endif()
if (BUILD_PYTHON)
message(FATAL_ERROR "The Python wrappers require shared libraries")
endif()
endif()
if (MSVC)
add_definitions( -D__func__="\\"????\\"")
@ -179,12 +168,14 @@ endif()
include_directories( ${PROJECT_SOURCE_DIR}/libecl_well/include )
add_subdirectory( libecl_well )
if (BUILD_PYTHON)
if (ERT_WINDOWS)
message(STATUS "Python is not supported on Windows")
message(WARNING "Python is not supported on Windows")
set( BUILD_PYTHON OFF )
else()
include(cmake/python.cmake2)
# If finding the Python interpreter and required packages
# fails in the python/CMakeLists.txt file the BUILD_PYTHON
# will be set to OFF.
add_subdirectory( python )
if(ERT_DOC)
@ -193,3 +184,16 @@ if (BUILD_PYTHON)
endif()
endif()
if (BUILD_PYTHON)
if (NOT ${BUILD_SHARED_LIBS})
message(FATAL_ERROR "The Python wrappers require shared libraries")
endif()
endif()
configure_file( cmake/libecl-config.cmake.in libecl-config.cmake @ONLY)
configure_file( cmake/libecl-config-version.cmake.in libecl-config-version.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libecl-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/libecl-config-version.cmake
DESTINATION lib/libecl )

View File

@ -131,6 +131,7 @@ filesystem. One level above the toplevel source directory is a practical choice.
ccmake <path/to/directory/containing/CMakeLists.txt>
```
Go through several 'configure' steps with CMake and generate native build files.
3. Exit ccmake and invoke the native build system, i.e. ordinarily 'make' on
Linux.
4. Subsequent builds can be performed using just the native make command, as in

View File

@ -1,35 +0,0 @@
#!/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 as error:
sys.exit(str(error))
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)

View File

@ -1,32 +0,0 @@
#!/usr/bin/env python
import py_compile
import os
import os.path
import sys
import shutil
src_file = sys.argv[1]
target_file = sys.argv[2]
(target_path , tail) = os.path.split( target_file )
if not os.path.exists( target_path ):
try:
os.makedirs( target_path )
except:
# When running with make -j 4 there might be a race to create this directory.
pass
shutil.copyfile( src_file , target_file )
shutil.copystat( src_file , target_file )
try:
py_compile.compile( target_file , doraise = True)
except Exception as error:
sys.exit("py_compile(%s) failed:%s" % (target_file , error))
sys.exit(0)

View File

@ -1,20 +0,0 @@
#!/usr/bin/env python
import py_compile
import os
import sys
import os.path
# Small 'python compiler' used in the build system for ert.
for file in sys.argv[1:]:
try:
py_compile.compile( file , doraise = True )
except Exception as error:
sys.exit("py_compile(%s) failed:%s" % (file , error))
sys.exit(0)

View File

@ -1,35 +0,0 @@
#!/usr/bin/env python
import py_compile
import os
import sys
import os.path
# Small 'python compiler' used in the build system for ert. The
# commandline argument should be the top level name of directory
# containing python source code. The 'compiler' will walk through the
# tree and in-place compile all the python files.
root_path = sys.argv[1]
for (root , dir_list , file_list) in os.walk( root_path ):
for file in file_list:
full_path = os.path.join( root , file )
(tmp , ext) = os.path.splitext( full_path )
if ext == ".py":
py_file = full_path
pyc_file = full_path + "c"
if os.path.exists( pyc_file ):
os.unlink( pyc_file )
try:
print "Compiling: %s" % py_file
py_compile.compile( py_file , doraise = True )
except Exception as error:
sys.exit("py_compile(%s) failed:%s" % (py_file , error))
sys.exit(0)

View File

@ -0,0 +1,14 @@
set(PACKAGE_VERSION @ERT_VERSION_MAJOR@.@ERT_VERSION_MINOR@.@ERT_VERSION_PATCH@)
set(PACKAGE_VERSION_MAJOR @ERT_VERSION_MAJOR@)
set(PACKAGE_VERSION_MINOR @ERT_VERSION_MINOR@)
set(PACKAGE_VERSION_PATCH @ERT_VERSION_MICRO@)
set(libecl_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include)
set(libecl_LIBRARIES -lecl_well -lecl -lert_geometry -lert_util)
link_directories( @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ )
include_directories( @CMAKE_INSTALL_PREFIX@/include )
set( CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/share/cmake/Modules ${CMAKE_MODULE_PATH})
if (@BUILD_PYTHON@)
set(libecl_PYTHONPATH @CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_PREFIX@ )
endif()

View File

@ -0,0 +1,10 @@
set(libecl_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/include)
set(libecl_LIBRARIES -lecl_well -lecl -lert_geometry -lert_util)
set( CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/share/cmake/Modules ${CMAKE_MODULE_PATH})
link_directories( @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ )
include_directories( @CMAKE_INSTALL_PREFIX@/include )
if (@BUILD_PYTHON@)
set(libecl_PYTHONPATH @CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_PREFIX@ )
endif()

View File

@ -1,25 +0,0 @@
macro(add_python_target tgt PYTHON_INSTALL_PATH)
SET(OUT_FILES "")
foreach(file ${python_source_files})
set(OUT ${CMAKE_CURRENT_BINARY_DIR}/${file}.pyc)
list(APPEND OUT_FILES ${OUT})
#------------------------------------------------------
ADD_CUSTOM_COMMAND(
OUTPUT ${OUT}
COMMAND ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PATH}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.py)
#------------------------------------------------------
if (INSTALL_ERT)
install(FILES ${PROJECT_BINARY_DIR}/${PYTHON}/${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(
${tgt} ALL DEPENDS ${OUT_FILES})
endmacro()

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
from ert.ecl import EclSum
from ecl.ecl import EclSum
def writeDiff(filename, vector1, vector2):
with open(filename, "w") as f:

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
from ert.ecl import EclSum
from ecl.ecl import EclSum
OIL_PRICES = {"2010-01-01": 78.33,
"2010-02-01": 76.39,

View File

@ -3,8 +3,8 @@ from datetime import datetime
import os
import sys
from ert.ecl import EclSum, EclSumTStep
from ert.test import ExtendedTestCase
from ecl.ecl import EclSum, EclSumTStep
from ecl.test import ExtendedTestCase
try:
from synthesizer import OilSimulator

View File

@ -40,8 +40,7 @@ extern "C" {
typedef enum {
ECL_KW_READ_OK = 0,
ECL_KW_READ_FAIL = 1,
ECL_KW_READ_SKIP = 2
ECL_KW_READ_FAIL = 1
} ecl_read_status_enum;
/*
@ -111,6 +110,8 @@ extern "C" {
void ecl_kw_iset(ecl_kw_type *ecl_kw , int i , const void *iptr);
void ecl_kw_iset_char_ptr( ecl_kw_type * ecl_kw , int index, const char * s);
void ecl_kw_iset_string8(ecl_kw_type * ecl_kw , int index , const char *s8);
void ecl_kw_iset_string_ptr(ecl_kw_type*, int, const char*);
const char * ecl_kw_iget_string_ptr(const ecl_kw_type *, int);
const char * ecl_kw_iget_char_ptr( const ecl_kw_type * ecl_kw , int i);
void * ecl_kw_iget_ptr(const ecl_kw_type *, int);
int ecl_kw_get_size(const ecl_kw_type *);

View File

@ -414,6 +414,7 @@ values (2e20) are denoted with '*'.
#define MINISTEP_KW "MINISTEP"
#define STARTDAT_KW "STARTDAT" /* Intgere keyword containing day,month,year. */
#define WGNAMES_KW "WGNAMES" /* The names of wells/groups for the summary vectors. */
#define NAMES_KW "NAMES" /* Alias for WGNAMES_KW. */
#define KEYWORDS_KW "KEYWORDS" /* The variable type for the various summary vectors. */
#define UNITS_KW "UNITS" /* The units, i.e SM^3/DAY the summary vectors. */
#define DIMENS_KW "DIMENS" /* The dimensions of the grid - also used in the GRID files. */

View File

@ -38,6 +38,8 @@ extern "C" {
different code paths for C and C++.
*/
#define ECL_STRING8_LENGTH 8
#define ECL_TYPE_LENGTH 4
typedef enum {
ECL_CHAR_TYPE = 0,
@ -46,7 +48,7 @@ typedef enum {
ECL_INT_TYPE = 3,
ECL_BOOL_TYPE = 4,
ECL_MESS_TYPE = 5,
ECL_C010_TYPE = 6 // See comment immediately above about the limited support of this type.
ECL_STRING_TYPE = 7
} ecl_type_enum;
#define ECL_TYPE_ENUM_DEFS {.value = 0 , .name = "ECL_CHAR_TYPE"}, \
@ -54,9 +56,10 @@ typedef enum {
{.value = 2 , .name = "ECL_DOUBLE_TYPE"}, \
{.value = 3 , .name = "ECL_INT_TYPE"}, \
{.value = 4 , .name = "ECL_BOOL_TYPE"}, \
{.value = 5 , .name = "ECL_MESS_TYPE"}
{.value = 5 , .name = "ECL_MESS_TYPE"}, \
{.value = 7 , .name = "ECL_STRING_TYPE"}
#define ECL_TYPE_ENUM_SIZE 6
#define ECL_TYPE_ENUM_SIZE 7
/*
Character data in ECLIPSE files comes as an array of fixed-length
@ -77,13 +80,13 @@ typedef enum {
#ifdef __cplusplus
struct ecl_type_struct {
const ecl_type_enum type;
const size_t element_size;
const ecl_type_enum type;
const size_t element_size;
ecl_type_struct( ecl_type_enum t, size_t es) :
type( t ),
element_size( es )
{}
ecl_type_struct( ecl_type_enum t, size_t es) :
type( t ),
element_size( es )
{}
};
#define ECL_INT ecl_data_type( ECL_INT_TYPE, sizeof(int))
@ -92,13 +95,13 @@ struct ecl_type_struct {
#define ECL_BOOL ecl_data_type( ECL_BOOL_TYPE, sizeof(int))
#define ECL_CHAR ecl_data_type( ECL_CHAR_TYPE, ECL_STRING8_LENGTH + 1)
#define ECL_MESS ecl_data_type( ECL_MESS_TYPE, 0)
#define ECL_C010 ecl_data_type( ECL_C010_TYPE . ECL_STRING10_LENGTH + 1)
#define ECL_STRING(size) ecl_data_type(ECL_STRING_TYPE, size + 1)
#else
struct ecl_type_struct {
const ecl_type_enum type;
const size_t element_size;
const ecl_type_enum type;
const size_t element_size;
};
#define ECL_CHAR (ecl_data_type) {.type = ECL_CHAR_TYPE, .element_size = ECL_STRING8_LENGTH + 1}
@ -107,26 +110,23 @@ struct ecl_type_struct {
#define ECL_DOUBLE (ecl_data_type) {.type = ECL_DOUBLE_TYPE, .element_size = sizeof(double)}
#define ECL_BOOL (ecl_data_type) {.type = ECL_BOOL_TYPE, .element_size = sizeof(int)}
#define ECL_MESS (ecl_data_type) {.type = ECL_MESS_TYPE, .element_size = 0}
#define ECL_C010 (ecl_data_type) {.type = ECL_C010_TYPE, .element_size = ECL_STRING10_LENGTH + 1}
#define ECL_STRING(size) (ecl_data_type) {.type = ECL_STRING_TYPE, .element_size = size + 1}
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ecl_type_struct ecl_data_type;
ecl_data_type ecl_type_create_from_name(const char *);
ecl_data_type ecl_type_create(const ecl_type_enum, const size_t);
ecl_data_type ecl_type_create_from_type(const ecl_type_enum);
ecl_type_enum ecl_type_get_type(const ecl_data_type);
const char * ecl_type_get_name(const ecl_data_type);
char * ecl_type_alloc_name(const ecl_data_type);
int ecl_type_get_sizeof_ctype(const ecl_data_type);
int ecl_type_get_sizeof_ctype_fortio(const ecl_data_type);
@ -134,14 +134,18 @@ int ecl_type_get_sizeof_ctype_fortio(const ecl_data_type);
bool ecl_type_is_equal(const ecl_data_type, const ecl_data_type);
bool ecl_type_is_numeric(const ecl_data_type);
bool ecl_type_is_alpha(const ecl_data_type);
bool ecl_type_is_char(const ecl_data_type);
bool ecl_type_is_int(const ecl_data_type);
bool ecl_type_is_float(const ecl_data_type);
bool ecl_type_is_double(const ecl_data_type);
bool ecl_type_is_mess(const ecl_data_type);
bool ecl_type_is_bool(const ecl_data_type);
bool ecl_type_is_C010(const ecl_data_type);
bool ecl_type_is_string(const ecl_data_type);
// Temporary fixup for OPM.
char * ecl_type_get_name(const ecl_data_type);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,46 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
The file 'ecl_units.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 ECL_UNITS_H
#define ECL_UNITS_H
#ifdef __cplusplus
extern "C" {
#endif
#define ECL_UNITS_CUBIC(x) ((x)*(x)*(x))
#define ECL_UNITS_MILLI(x) ((x)*0.001)
#define ECL_UNITS_MEGA(x) ((x)*1000000)
#define ECL_UNITS_LENGTH_INCH 0.0254
#define ECL_UNITS_LENGTH_FEET 12 * ECL_UNITS_LENGTH_INCH
#define ECL_UNITS_VOLUME_GALLON 231 * ECL_UNITS_CUBIC( ECL_UNITS_LENGTH_INCH )
#define ECL_UNITS_VOLUME_BARREL ECL_UNITS_VOLUME_GALLON * 42
#define ECL_UNITS_VOLUME_LITER 0.001
#define ECL_UNITS_VOLUME_MILLI_LITER ECL_UNITS_MILLI( ECL_UNITS_VOLUME_LITER )
#define ECL_UNITS_VOLUME_GAS_FIELD ECL_UNITS_MEGA( ECL_UNITS_CUBIC( ECL_UNITS_LENGTH_FEET ) )
#define ECL_UNITS_TIME_HOUR 3600
#define ECL_UNITS_TIME_DAY 24 * ECL_UNITS_TIME_HOUR
#ifdef __cplusplus
}
#endif
#endif

View File

@ -45,6 +45,7 @@ set( source_files
${ext_source})
set( header_files
ecl_units.h
ecl_rsthead.h
ecl_sum_tstep.h
ecl_rst_file.h
@ -95,7 +96,7 @@ if (ERT_USE_OPENMP)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_SHARED_LINKER_FLAGS}")
endif()
add_library( ecl ${LIBRARY_TYPE} ${source_files} )
add_library( ecl ${source_files} )
set_target_properties( ecl PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR})
if (USE_RUNPATH)
add_runpath( ecl )

View File

@ -539,13 +539,6 @@ static bool ecl_file_scan( ecl_file_type * ecl_file ) {
else
break;
}
if (read_status == ECL_KW_READ_SKIP) {
bool skip_ok = ecl_kw_fskip_data( work_kw , ecl_file->fortio );
fprintf(stderr,"** Warning: keyword %s is of type \'C010\' - will be skipped when loading file. skip_ok:%d\n" , ecl_kw_get_header( work_kw ) , skip_ok);
if (!skip_ok)
break;
}
}
}

View File

@ -358,10 +358,12 @@ void ecl_file_view_fprintf_kw_list(const ecl_file_view_type * ecl_file_view , FI
int i;
for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) {
const ecl_file_kw_type * file_kw = vector_iget_const( ecl_file_view->kw_list , i );
char * type_name = ecl_type_alloc_name(ecl_file_kw_get_data_type(file_kw));
fprintf(stream , "%-8s %7d:%s\n",
ecl_file_kw_get_header( file_kw ) ,
ecl_file_kw_get_size( file_kw ) ,
ecl_type_get_name( ecl_file_kw_get_data_type( file_kw )));
type_name);
free(type_name);
}
}

View File

@ -5401,7 +5401,7 @@ static bool ecl_grid_get_property__(const ecl_grid_type * ecl_grid , const ecl_k
return false;
} else {
util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n",__func__ , ecl_type_get_name( data_type ) , __func__);
util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n",__func__ , ecl_type_alloc_name( data_type ) , __func__);
return false;
}
}
@ -5466,7 +5466,7 @@ double ecl_grid_get_property(const ecl_grid_type * ecl_grid , const ecl_kw_type
return -1; /* Tried to lookup an inactive cell. */
} else {
util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n",__func__ , ecl_type_get_name( data_type ) , __func__);
util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n",__func__ , ecl_type_alloc_name( data_type ) , __func__);
return -1;
}
}
@ -5517,7 +5517,7 @@ void ecl_grid_get_column_property(const ecl_grid_type * ecl_grid , const ecl_kw_
}
}
} else
util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n",__func__ , ecl_type_get_name( data_type ) , __func__);
util_abort("%s: sorry - can not lookup ECLIPSE type:%s with %s.\n",__func__ , ecl_type_alloc_name( data_type ) , __func__);
}

View File

@ -61,7 +61,6 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID )
#define BLOCKSIZE_NUMERIC 1000
#define BLOCKSIZE_CHAR 105
#define BLOCKSIZE_C010 105
@ -113,7 +112,6 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID )
*/
#define READ_FMT_CHAR "%8c"
#define READ_FMT_C010 "%10c"
#define READ_FMT_FLOAT "%gE"
#define READ_FMT_INT "%d"
#define READ_FMT_MESS "%8c"
@ -122,7 +120,6 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID )
#define WRITE_FMT_CHAR " '%-8s'"
#define WRITE_FMT_C010 " '%-10s'"
#define WRITE_FMT_INT " %11d"
#define WRITE_FMT_FLOAT " %11.8fE%+03d"
#define WRITE_FMT_DOUBLE " %17.14fD%+03d"
@ -161,75 +158,68 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID )
ecl_type_enum ecl_kw_get_type(const ecl_kw_type *);
void ecl_kw_set_data_type(ecl_kw_type * ecl_kw, ecl_data_type data_type);
static const char * get_read_fmt(const ecl_data_type data_type ) {
static char * alloc_read_fmt_string(const ecl_data_type ecl_type) {
return util_alloc_sprintf(
"%%%dc",
ecl_type_get_sizeof_ctype_fortio(ecl_type)
);
}
static char * alloc_read_fmt(const ecl_data_type data_type ) {
switch(ecl_type_get_type(data_type)) {
case(ECL_CHAR_TYPE):
return READ_FMT_CHAR;
break;
case(ECL_C010_TYPE):
return READ_FMT_C010;
break;
return util_alloc_string_copy(READ_FMT_CHAR);
case(ECL_INT_TYPE):
return READ_FMT_INT;
break;
return util_alloc_string_copy(READ_FMT_INT);
case(ECL_FLOAT_TYPE):
return READ_FMT_FLOAT;
break;
return util_alloc_string_copy(READ_FMT_FLOAT);
case(ECL_DOUBLE_TYPE):
return READ_FMT_DOUBLE;
break;
return util_alloc_string_copy(READ_FMT_DOUBLE);
case(ECL_BOOL_TYPE):
return READ_FMT_BOOL;
break;
return util_alloc_string_copy(READ_FMT_BOOL);
case(ECL_MESS_TYPE):
return READ_FMT_MESS;
break;
return util_alloc_string_copy(READ_FMT_MESS);
case(ECL_STRING_TYPE):
return alloc_read_fmt_string(data_type);
default:
util_abort("%s: invalid ecl_type:%d \n",__func__ , ecl_type_get_type(data_type));
util_abort("%s: invalid ecl_type:%s \n",__func__ , ecl_type_alloc_name(data_type));
return NULL;
}
}
static char * alloc_write_fmt_string(const ecl_data_type ecl_type) {
return util_alloc_sprintf(
" '%%-%ds'",
ecl_type_get_sizeof_ctype_fortio(ecl_type)
);
}
static const char * ecl_kw_get_write_fmt(const ecl_data_type data_type) {
static char * alloc_write_fmt(const ecl_data_type data_type) {
switch(ecl_type_get_type(data_type)) {
case(ECL_CHAR_TYPE):
return WRITE_FMT_CHAR;
break;
case(ECL_C010_TYPE):
return WRITE_FMT_C010;
break;
return util_alloc_string_copy(WRITE_FMT_CHAR);
case(ECL_INT_TYPE):
return WRITE_FMT_INT;
break;
return util_alloc_string_copy(WRITE_FMT_INT);
case(ECL_FLOAT_TYPE):
return WRITE_FMT_FLOAT;
break;
return util_alloc_string_copy(WRITE_FMT_FLOAT);
case(ECL_DOUBLE_TYPE):
return WRITE_FMT_DOUBLE;
break;
return util_alloc_string_copy(WRITE_FMT_DOUBLE);
case(ECL_BOOL_TYPE):
return WRITE_FMT_BOOL;
break;
return util_alloc_string_copy(WRITE_FMT_BOOL);
case(ECL_MESS_TYPE):
return WRITE_FMT_MESS;
break;
return util_alloc_string_copy(WRITE_FMT_MESS);
case(ECL_STRING_TYPE):
return alloc_write_fmt_string(data_type);
default:
util_abort("%s: invalid ecl_type:%d \n",__func__ , ecl_type_get_type(data_type));
util_abort("%s: invalid ecl_type: %s\n",__func__ , ecl_type_alloc_name(data_type));
return NULL;
}
}
static int get_blocksize( ecl_data_type data_type ) {
if (ecl_type_is_char(data_type))
if (ecl_type_is_alpha(data_type))
return BLOCKSIZE_CHAR;
if (ecl_type_is_mess(data_type))
return BLOCKSIZE_CHAR;
if (ecl_type_is_C010(data_type))
return BLOCKSIZE_C010;
return BLOCKSIZE_NUMERIC;
}
@ -238,24 +228,20 @@ static int get_columns(const ecl_data_type data_type) {
switch(ecl_type_get_type(data_type)) {
case(ECL_CHAR_TYPE):
return COLUMNS_CHAR;
break;
case(ECL_INT_TYPE):
return COLUMNS_INT;
break;
case(ECL_FLOAT_TYPE):
return COLUMNS_FLOAT;
break;
case(ECL_DOUBLE_TYPE):
return COLUMNS_DOUBLE;
break;
case(ECL_BOOL_TYPE):
return COLUMNS_BOOL;
break;
case(ECL_MESS_TYPE):
return COLUMNS_MESSAGE;
break;
case(ECL_STRING_TYPE):
return COLUMNS_CHAR; // TODO: Is this correct?
default:
util_abort("%s: invalid ecl_type:%d \n",__func__ , ecl_type_get_type(data_type));
util_abort("%s: invalid ecl_type: %s\n",__func__ , ecl_type_alloc_name(data_type));
return -1;
}
}
@ -535,17 +521,13 @@ ecl_kw_type * ecl_kw_alloc_new(const char * header , int size, ecl_data_type da
ecl_kw_type * ecl_kw_alloc( const char * header , int size , ecl_data_type data_type ) {
if (ecl_type_is_C010(data_type))
return NULL;
{
ecl_kw_type *ecl_kw;
ecl_kw_type *ecl_kw;
ecl_kw = ecl_kw_alloc_empty();
ecl_kw_initialize(ecl_kw , header , size , data_type);
ecl_kw_alloc_data(ecl_kw);
ecl_kw = ecl_kw_alloc_empty();
ecl_kw_initialize(ecl_kw , header , size , data_type);
ecl_kw_alloc_data(ecl_kw);
return ecl_kw;
}
return ecl_kw;
}
@ -812,6 +794,12 @@ const char * ecl_kw_iget_char_ptr( const ecl_kw_type * ecl_kw , int i) {
return ecl_kw_iget_ptr( ecl_kw , i );
}
const char * ecl_kw_iget_string_ptr( const ecl_kw_type * ecl_kw, int i) {
if (ecl_kw_get_type(ecl_kw) != ECL_STRING_TYPE)
util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw));
return ecl_kw_iget_ptr( ecl_kw , i );
}
/**
This will set the elemnts of the ecl_kw data storage in index to
@ -864,6 +852,30 @@ void ecl_kw_iset_char_ptr( ecl_kw_type * ecl_kw , int index, const char * s) {
}
}
/**
* This function will verify that the given string is of approperiate length
* (0 <= lenght <= data_type.element_size). If so, the elements of @s will be
* written to the @ecl_kw string array starting at @index.
*/
void ecl_kw_iset_string_ptr( ecl_kw_type * ecl_kw, int index, const char * s) {
if(!ecl_type_is_alpha(ecl_kw_get_data_type(ecl_kw))) {
char * type_name = ecl_type_alloc_name(ecl_kw_get_data_type(ecl_kw));
util_abort("%s: Expected alphabetic data type (CHAR, CXXX or MESS), was %s\n", __func__, type_name);
}
size_t input_len = strlen(s);
size_t type_len = ecl_type_get_sizeof_ctype_fortio(ecl_kw_get_data_type(ecl_kw));
if(input_len > type_len)
util_abort("%s: String of length %d cannot hold input string of length %d\n", __func__, type_len, input_len);
char * ecl_string = (char *) ecl_kw_iget_ptr(ecl_kw, index);
for(int i = 0; i < input_len; ++i)
ecl_string[i] = s[i];
ecl_string[input_len] = '\0';
}
/**
This function will compare the string at position @index with the
@ -1078,7 +1090,7 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) {
const int blocksize = get_blocksize( ecl_kw->data_type );
if (fmt_file) {
const int blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1);
const char * read_fmt = get_read_fmt( ecl_kw->data_type );
char * read_fmt = alloc_read_fmt( ecl_kw->data_type );
FILE * stream = fortio_get_FILE(fortio);
int offset = 0;
int index = 0;
@ -1090,6 +1102,14 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) {
case(ECL_CHAR_TYPE):
ecl_kw_fscanf_qstring(&ecl_kw->data[offset] , read_fmt , 8, stream);
break;
case(ECL_STRING_TYPE):
ecl_kw_fscanf_qstring(
&ecl_kw->data[offset],
read_fmt,
ecl_type_get_sizeof_ctype_fortio(ecl_kw_get_data_type(ecl_kw)),
stream
);
break;
case(ECL_INT_TYPE):
{
int iread = fscanf(stream , read_fmt , (int *) &ecl_kw->data[offset]);
@ -1141,10 +1161,11 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) {
/* Skip the trailing newline */
fortio_fseek( fortio , 1 , SEEK_CUR);
free(read_fmt);
return true;
} else {
bool read_ok = true;
if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_mess(ecl_kw->data_type)) {
if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_mess(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type)) {
const int blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1);
int ib = 0;
while (true) {
@ -1157,9 +1178,11 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) {
int record_size = fortio_init_read(fortio);
if (record_size >= 0) {
int ir;
const int sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type);
const int sizeof_ctype_fortio = ecl_type_get_sizeof_ctype_fortio(ecl_kw->data_type);
for (ir = 0; ir < read_elm; ir++) {
util_fread( &ecl_kw->data[(ib * blocksize + ir) * ecl_kw_get_sizeof_ctype(ecl_kw)] , 1 , ECL_STRING8_LENGTH , stream , __func__);
ecl_kw->data[(ib * blocksize + ir) * ecl_kw_get_sizeof_ctype(ecl_kw) + ECL_STRING8_LENGTH] = null_char;
util_fread( &ecl_kw->data[(ib * blocksize + ir) * sizeof_ctype] , 1 , sizeof_ctype_fortio , stream , __func__);
ecl_kw->data[(ib * blocksize + ir) * sizeof_ctype + sizeof_ctype_fortio] = null_char;
}
read_ok = fortio_complete_read(fortio , record_size);
} else
@ -1228,31 +1251,27 @@ bool ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio) {
*/
bool ecl_kw_fskip_data__( ecl_data_type data_type , const int element_count , fortio_type * fortio) {
if (element_count <= 0)
return true;
bool fmt_file = fortio_fmt_file(fortio);
bool skip_ok = true;
if (element_count > 0) {
if (fmt_file) {
/* Formatted skipping actually involves reading the data - nice ??? */
ecl_kw_type * tmp_kw = ecl_kw_alloc_empty( );
ecl_kw_initialize( tmp_kw , "WORK" , element_count , data_type );
ecl_kw_alloc_data(tmp_kw);
ecl_kw_fread_data(tmp_kw , fortio);
ecl_kw_free( tmp_kw );
} else {
const int blocksize = get_blocksize( data_type );
const int block_count = element_count / blocksize + (element_count % blocksize == 0 ? 0 : 1);
if (fmt_file) {
/* Formatted skipping actually involves reading the data - nice ??? */
ecl_kw_type * tmp_kw = ecl_kw_alloc_empty( );
ecl_kw_initialize( tmp_kw , "WORK" , element_count , data_type );
ecl_kw_alloc_data(tmp_kw);
ecl_kw_fread_data(tmp_kw , fortio);
ecl_kw_free( tmp_kw );
} else {
const int blocksize = get_blocksize( data_type );
const int block_count = element_count / blocksize + (element_count % blocksize != 0);
int element_size = ecl_type_get_sizeof_ctype_fortio(data_type);
int element_size = ecl_type_get_sizeof_ctype(data_type);
if(ecl_type_is_char(data_type))
element_size = ECL_STRING8_LENGTH;
if(ecl_type_is_C010(data_type))
element_size = ECL_STRING10_LENGTH;
skip_ok = fortio_data_fskip(fortio, element_size, element_count, block_count);
}
if(!fortio_data_fskip(fortio, element_size, element_count, block_count))
return false;
}
return skip_ok;
return true;
}
@ -1289,51 +1308,47 @@ ecl_read_status_enum ecl_kw_fread_header(ecl_kw_type *ecl_kw , fortio_type * for
char ecl_type_str[ECL_TYPE_LENGTH + 1];
int record_size;
int size;
bool OK = true;
if (fmt_file) {
OK = ecl_kw_fscanf_qstring(header , "%8c" , 8 , stream);
if (OK) {
int read_count = fscanf(stream , "%d" , &size);
if (read_count == 1) {
ecl_kw_fscanf_qstring(ecl_type_str , "%4c" , 4 , stream);
fgetc(stream); /* Reading the trailing newline ... */
} else
util_abort("%s: reading failed - at end of file?\n",__func__);
}
} else {
header[ECL_STRING8_LENGTH] = null_char;
if(!ecl_kw_fscanf_qstring(header , "%8c" , 8 , stream))
return ECL_KW_READ_FAIL;
int read_count = fscanf(stream , "%d" , &size);
if (read_count != 1)
util_abort("%s: reading failed - at end of file?\n",__func__);
ecl_kw_fscanf_qstring(ecl_type_str , "%4c" , 4 , stream);
fgetc(stream); /* Reading the trailing newline ... */
}
else {
header[ECL_STRING8_LENGTH] = null_char;
ecl_type_str[ECL_TYPE_LENGTH] = null_char;
record_size = fortio_init_read(fortio);
if (record_size > 0) {
char buffer[ECL_KW_HEADER_DATA_SIZE];
size_t read_bytes = fread(buffer , 1 , ECL_KW_HEADER_DATA_SIZE , stream);
if (read_bytes == ECL_KW_HEADER_DATA_SIZE) {
memcpy( header , &buffer[0] , ECL_STRING8_LENGTH);
size = *( (int *) &buffer[ECL_STRING8_LENGTH] );
memcpy( ecl_type_str , &buffer[ECL_STRING8_LENGTH + sizeof(size)] , ECL_TYPE_LENGTH);
if (record_size <= 0)
return ECL_KW_READ_FAIL;
OK = fortio_complete_read(fortio , record_size);
} else
OK = false;
char buffer[ECL_KW_HEADER_DATA_SIZE];
size_t read_bytes = fread(buffer , 1 , ECL_KW_HEADER_DATA_SIZE , stream);
if (OK && ECL_ENDIAN_FLIP)
util_endian_flip_vector(&size , sizeof size , 1);
} else
OK = false;
if (read_bytes != ECL_KW_HEADER_DATA_SIZE)
return ECL_KW_READ_FAIL;
memcpy( header , &buffer[0] , ECL_STRING8_LENGTH);
size = *( (int *) &buffer[ECL_STRING8_LENGTH] );
memcpy( ecl_type_str , &buffer[ECL_STRING8_LENGTH + sizeof(size)] , ECL_TYPE_LENGTH);
if(!fortio_complete_read(fortio , record_size))
return ECL_KW_READ_FAIL;
if (ECL_ENDIAN_FLIP)
util_endian_flip_vector(&size , sizeof size , 1);
}
if (OK) {
ecl_data_type data_type = ecl_type_create_from_name( ecl_type_str );
ecl_kw_initialize( ecl_kw , header , size , data_type);
ecl_data_type data_type = ecl_type_create_from_name( ecl_type_str );
ecl_kw_initialize( ecl_kw , header , size , data_type);
if (ecl_type_is_C010(data_type))
return ECL_KW_READ_SKIP;
return ECL_KW_READ_OK;
} else
return ECL_KW_READ_FAIL;
return ECL_KW_READ_OK;
}
@ -1526,18 +1541,19 @@ static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type *
for (block_nr = 0; block_nr < num_blocks; block_nr++) {
int this_blocksize = util_int_min((block_nr + 1)*blocksize , ecl_kw->size) - block_nr*blocksize;
if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_mess(ecl_kw->data_type)) {
if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_mess(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type)) {
/*
Due to the terminating \0 characters there is not a
continous file/memory mapping - the \0 characters arel
skipped.
*/
FILE *stream = fortio_get_FILE(fortio);
int record_size = this_blocksize * ECL_STRING8_LENGTH; /* The total size in bytes of the record written by the fortio layer. */
int i;
FILE *stream = fortio_get_FILE(fortio);
int word_size = ecl_type_get_sizeof_ctype_fortio(ecl_kw->data_type);
int record_size = this_blocksize * word_size; /* The total size in bytes of the record written by the fortio layer. */
int i;
fortio_init_write(fortio , record_size );
for (i = 0; i < this_blocksize; i++)
fwrite(&ecl_kw->data[(block_nr * blocksize + i) * ecl_kw_get_sizeof_ctype(ecl_kw)] , 1 , ECL_STRING8_LENGTH , stream);
fwrite(&ecl_kw->data[(block_nr * blocksize + i) * ecl_kw_get_sizeof_ctype(ecl_kw)] , 1 , word_size , stream);
fortio_complete_write(fortio , record_size);
} else {
int record_size = this_blocksize * ecl_kw_get_sizeof_ctype(ecl_kw); /* The total size in bytes of the record written by the fortio layer. */
@ -1595,7 +1611,7 @@ static void ecl_kw_fwrite_data_formatted( ecl_kw_type * ecl_kw , fortio_type * f
FILE * stream = fortio_get_FILE( fortio );
const int blocksize = get_blocksize( ecl_kw->data_type );
const int columns = get_columns( ecl_kw->data_type );
const char * write_fmt = ecl_kw_get_write_fmt( ecl_kw->data_type );
char * write_fmt = alloc_write_fmt( ecl_kw->data_type );
const int num_blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1);
int block_nr;
@ -1613,7 +1629,7 @@ static void ecl_kw_fwrite_data_formatted( ecl_kw_type * ecl_kw , fortio_type * f
case(ECL_CHAR_TYPE):
fprintf(stream , write_fmt , data_ptr);
break;
case(ECL_C010_TYPE):
case(ECL_STRING_TYPE):
fprintf(stream , write_fmt , data_ptr);
break;
case(ECL_INT_TYPE):
@ -1651,6 +1667,8 @@ static void ecl_kw_fwrite_data_formatted( ecl_kw_type * ecl_kw , fortio_type * f
fprintf(stream , "\n");
}
}
free(write_fmt);
}
}
@ -1670,8 +1688,10 @@ void ecl_kw_fwrite_data(const ecl_kw_type *_ecl_kw , fortio_type *fortio) {
void ecl_kw_fwrite_header(const ecl_kw_type *ecl_kw , fortio_type *fortio) {
FILE *stream = fortio_get_FILE(fortio);
bool fmt_file = fortio_fmt_file(fortio);
char * type_name = ecl_type_alloc_name(ecl_kw->data_type);
if (fmt_file)
fprintf(stream , WRITE_HEADER_FMT , ecl_kw->header8 , ecl_kw->size , ecl_type_get_name( ecl_kw->data_type ));
fprintf(stream , WRITE_HEADER_FMT , ecl_kw->header8 , ecl_kw->size , type_name);
else {
int size = ecl_kw->size;
if (ECL_ENDIAN_FLIP)
@ -1681,11 +1701,13 @@ void ecl_kw_fwrite_header(const ecl_kw_type *ecl_kw , fortio_type *fortio) {
fwrite(ecl_kw->header8 , sizeof(char) , ECL_STRING8_LENGTH , stream);
fwrite(&size , sizeof(int) , 1 , stream);
fwrite(ecl_type_get_name( ecl_kw->data_type ) , sizeof(char) , ECL_TYPE_LENGTH , stream);
fwrite(type_name , sizeof(char) , ECL_TYPE_LENGTH , stream);
fortio_complete_write(fortio , ECL_KW_HEADER_DATA_SIZE);
}
free(type_name);
}
@ -1892,9 +1914,11 @@ void ecl_kw_fread_double_param(const char * filename , bool fmt_file , double *
void ecl_kw_summarize(const ecl_kw_type * ecl_kw) {
char * type_name = ecl_type_alloc_name(ecl_kw->data_type);
printf("%8s %10d:%4s \n",ecl_kw_get_header8(ecl_kw),
ecl_kw_get_size(ecl_kw),
ecl_type_get_name( ecl_kw->data_type));
type_name);
free(type_name);
}
@ -2109,7 +2133,7 @@ void ecl_kw_inplace_add_indexed( ecl_kw_type * target_kw , const int_vector_type
ecl_kw_inplace_add_indexed_int( target_kw , index_set , add_kw );
break;
default:
util_abort("%s: inplace add not implemented for type:%s \n",__func__ , ecl_type_get_name( ecl_kw_get_data_type(target_kw) ));
util_abort("%s: inplace add not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(target_kw) ));
}
}
@ -2147,7 +2171,7 @@ void ecl_kw_inplace_add( ecl_kw_type * target_kw , const ecl_kw_type * add_kw) {
ecl_kw_inplace_add_int( target_kw , add_kw );
break;
default:
util_abort("%s: inplace add not implemented for type:%s \n",__func__ , ecl_type_get_name( ecl_kw_get_data_type(target_kw) ));
util_abort("%s: inplace add not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(target_kw) ));
}
}
@ -2186,7 +2210,7 @@ void ecl_kw_inplace_sub( ecl_kw_type * target_kw , const ecl_kw_type * sub_kw) {
ecl_kw_inplace_sub_int( target_kw , sub_kw );
break;
default:
util_abort("%s: inplace sub not implemented for type:%s \n",__func__ , ecl_type_get_name( ecl_kw_get_data_type(target_kw) ));
util_abort("%s: inplace sub not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(target_kw) ));
}
}
@ -2226,7 +2250,7 @@ void ecl_kw_inplace_sub_indexed( ecl_kw_type * target_kw , const int_vector_type
ecl_kw_inplace_sub_indexed_int( target_kw , index_set , sub_kw );
break;
default:
util_abort("%s: inplace sub not implemented for type:%s \n",__func__ , ecl_type_get_name( ecl_kw_get_data_type(target_kw) ));
util_abort("%s: inplace sub not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(target_kw) ));
}
}
@ -2261,7 +2285,7 @@ void ecl_kw_inplace_abs( ecl_kw_type * kw ) {
ecl_kw_inplace_abs_int( kw );
break;
default:
util_abort("%s: inplace abs not implemented for type:%s \n",__func__ , ecl_type_get_name( ecl_kw_get_data_type(kw) ));
util_abort("%s: inplace abs not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(kw) ));
}
}
@ -2298,7 +2322,7 @@ void ecl_kw_inplace_mul( ecl_kw_type * target_kw , const ecl_kw_type * mul_kw) {
ecl_kw_inplace_mul_int( target_kw , mul_kw );
break;
default:
util_abort("%s: inplace mul not implemented for type:%s \n",__func__ , ecl_type_get_name( ecl_kw_get_data_type(target_kw) ));
util_abort("%s: inplace mul not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(target_kw) ));
}
}
@ -2338,7 +2362,7 @@ void ecl_kw_inplace_mul_indexed( ecl_kw_type * target_kw , const int_vector_type
ecl_kw_inplace_mul_indexed_int( target_kw , index_set , mul_kw );
break;
default:
util_abort("%s: inplace mul not implemented for type:%s \n",__func__ , ecl_type_get_name( ecl_kw_get_data_type(target_kw) ));
util_abort("%s: inplace mul not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(target_kw) ));
}
}
@ -2376,7 +2400,7 @@ void ecl_kw_inplace_div( ecl_kw_type * target_kw , const ecl_kw_type * div_kw) {
ecl_kw_inplace_div_int( target_kw , div_kw );
break;
default:
util_abort("%s: inplace div not implemented for type:%s \n",__func__ , ecl_type_get_name( ecl_kw_get_data_type(target_kw) ));
util_abort("%s: inplace div not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(target_kw) ));
}
}
@ -2417,7 +2441,7 @@ void ecl_kw_inplace_div_indexed( ecl_kw_type * target_kw , const int_vector_type
ecl_kw_inplace_div_indexed_int( target_kw , index_set , div_kw );
break;
default:
util_abort("%s: inplace div not implemented for type:%s \n",__func__ , ecl_type_get_name( ecl_kw_get_data_type(target_kw) ));
util_abort("%s: inplace div not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(target_kw) ));
}
}
@ -2673,7 +2697,7 @@ static void ecl_kw_fprintf_data_bool( const ecl_kw_type * ecl_kw , const char *
}
static void ecl_kw_fprintf_data_char( const ecl_kw_type * ecl_kw , const char * fmt , FILE * stream) {
static void ecl_kw_fprintf_data_string( const ecl_kw_type * ecl_kw , const char * fmt , FILE * stream) {
int i;
for (i=0; i < ecl_kw->size; i++)
fprintf(stream , fmt , &ecl_kw->data[ i * ecl_kw_get_sizeof_ctype(ecl_kw)]);
@ -2689,8 +2713,8 @@ void ecl_kw_fprintf_data( const ecl_kw_type * ecl_kw , const char * fmt , FILE *
ecl_kw_fprintf_data_int( ecl_kw , fmt , stream );
else if (ecl_type_is_bool(ecl_kw->data_type))
ecl_kw_fprintf_data_bool( ecl_kw , fmt , stream );
else if (ecl_type_is_char(ecl_kw->data_type))
ecl_kw_fprintf_data_char( ecl_kw , fmt , stream );
else if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type))
ecl_kw_fprintf_data_string( ecl_kw , fmt , stream );
}

View File

@ -413,7 +413,7 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_
value_ptr = &value;
} else
util_abort("%s: sorry type:%s not supported \n",__func__ , ecl_type_get_name(data_type));
util_abort("%s: sorry type:%s not supported \n",__func__ , ecl_type_alloc_name(data_type));
/*
Removing this warning on user request:

View File

@ -88,8 +88,7 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ
// The only derived quantity
rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year );
}
if (doubhead_kw)
rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX );
rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX );
if (logihead_kw)
rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX);
@ -110,15 +109,12 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ
ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int report_step) {
const ecl_kw_type * intehead_kw = ecl_file_view_iget_named_kw( rst_view , INTEHEAD_KW , 0);
const ecl_kw_type * doubhead_kw = NULL;
const ecl_kw_type * doubhead_kw = ecl_file_view_iget_named_kw( rst_view , DOUBHEAD_KW , 0);
const ecl_kw_type * logihead_kw = NULL;
if (ecl_file_view_has_kw(rst_view, LOGIHEAD_KW))
logihead_kw = ecl_file_view_iget_named_kw( rst_view , LOGIHEAD_KW , 0);
if (ecl_file_view_has_kw(rst_view, DOUBHEAD_KW))
doubhead_kw = ecl_file_view_iget_named_kw(rst_view, DOUBHEAD_KW, 0);
if (ecl_file_view_has_kw( rst_view , SEQNUM_KW)) {
const ecl_kw_type * seqnum_kw = ecl_file_view_iget_named_kw( rst_view , SEQNUM_KW , 0);
report_step = ecl_kw_iget_int( seqnum_kw , 0);
@ -233,3 +229,13 @@ void ecl_rsthead_fprintf_struct( const ecl_rsthead_type * header , FILE * stream
void ecl_rsthead_free( ecl_rsthead_type * rsthead ) {
free( rsthead );
}
int ecl_rsthead_get_nxconz( const ecl_rsthead_type * rsthead ) {
return rsthead->nxconz;
}
int ecl_rsthead_get_ncwmax( const ecl_rsthead_type * rsthead ) {
return rsthead->ncwmax;
}

View File

@ -234,11 +234,14 @@ static const char* special_vars[] = {"NEWTON",
this simple list.
*/
static const char* smspec_required_keywords[] = {WGNAMES_KW,
KEYWORDS_KW,
STARTDAT_KW,
UNITS_KW,
DIMENS_KW};
static const size_t num_req_keywords = 5;
static const char* smspec_required_keywords[] = {
WGNAMES_KW,
KEYWORDS_KW,
STARTDAT_KW,
UNITS_KW,
DIMENS_KW
};
/*****************************************************************/
@ -333,6 +336,21 @@ void ecl_smspec_lock( ecl_smspec_type * smspec ) {
smspec->locked = true;
}
/**
* Returns an ecl data type for which all names will fit. If the maximum name
* length is at most 8, an ECL_CHAR is returned and otherwise a large enough
* ECL_STRING.
*/
static ecl_data_type get_wgnames_type(const ecl_smspec_type * smspec) {
size_t max_len = 0;
for(int i = 0; i < ecl_smspec_num_nodes(smspec); ++i) {
const char * name = smspec_node_get_wgname(ecl_smspec_iget_node(smspec, i));
if(name != NULL)
max_len = util_size_t_max(max_len, strlen(name));
}
return max_len <= 8 ? ECL_CHAR : ECL_STRING(max_len);
}
// DIMENS
// KEYWORDS
@ -371,10 +389,18 @@ static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_ty
{
ecl_kw_type * keywords_kw = ecl_kw_alloc( KEYWORDS_KW , num_nodes , ECL_CHAR );
ecl_kw_type * wgnames_kw = ecl_kw_alloc( WGNAMES_KW , num_nodes , ECL_CHAR );
ecl_kw_type * units_kw = ecl_kw_alloc( UNITS_KW , num_nodes , ECL_CHAR );
ecl_kw_type * nums_kw = NULL;
// If the names_type is an ECL_STRING we expect this to be an INTERSECT
// summary, otherwise an ECLIPSE summary.
ecl_data_type names_type = get_wgnames_type(smspec);
ecl_kw_type * wgnames_kw = ecl_kw_alloc(
ecl_type_is_char(names_type) ? WGNAMES_KW : NAMES_KW,
num_nodes,
names_type
);
if (smspec->need_nums)
nums_kw = ecl_kw_alloc( NUMS_KW , num_nodes , ECL_INT);
{
@ -403,7 +429,7 @@ static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_ty
if (smspec_node_get_var_type( smspec_node ) == ECL_SMSPEC_INVALID_VAR) {
ecl_kw_iset_string8( keywords_kw , i , "WWCT" );
ecl_kw_iset_string8( units_kw , i , "????????");
ecl_kw_iset_string8( wgnames_kw , i , DUMMY_WELL);
ecl_kw_iset_string_ptr( wgnames_kw , i , DUMMY_WELL);
} else {
ecl_kw_iset_string8( keywords_kw , i , smspec_node_get_keyword( smspec_node ));
ecl_kw_iset_string8( units_kw , i , smspec_node_get_unit( smspec_node ));
@ -411,7 +437,7 @@ static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_ty
const char * wgname = DUMMY_WELL;
if (smspec_node_get_wgname( smspec_node ) != NULL)
wgname = smspec_node_get_wgname( smspec_node );
ecl_kw_iset_string8( wgnames_kw , i , wgname);
ecl_kw_iset_string_ptr( wgnames_kw , i , wgname);
}
}
@ -958,7 +984,7 @@ bool ecl_smspec_equal( const ecl_smspec_type * self , const ecl_smspec_type * ot
static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_file_type * header ) {
if (ecl_file_has_kw( header , RESTART_KW )) {
const ecl_kw_type * restart_kw = ecl_file_iget_kw( header , 0 );
const ecl_kw_type * restart_kw = ecl_file_iget_named_kw(header, RESTART_KW , 0);
char tmp_base[73]; /* To accomodate a maximum of 9 items which consist of 8 characters each. */
char * restart_base;
int i;
@ -1058,16 +1084,25 @@ const int_vector_type * ecl_smspec_get_index_map( const ecl_smspec_type * smspec
return smspec->index_map;
}
/**
* This function is to support the NAMES alias for WGNAMES. If similar
* situations occur in the future, this is a sane starting point for general
* support.
*/
static const char * get_active_keyword_alias(ecl_file_type * header, const char * keyword) {
if (strcmp(keyword, WGNAMES_KW) == 0 || strcmp(keyword, NAMES_KW) == 0)
return ecl_file_has_kw(header, WGNAMES_KW) ? WGNAMES_KW : NAMES_KW;
return keyword;
}
static bool ecl_smspec_check_header( ecl_file_type * header ) {
bool OK = true;
int num_required = sizeof( smspec_required_keywords ) / sizeof( smspec_required_keywords[0] );
int i;
for (i=0; i < num_required; i++) {
if (!ecl_file_has_kw( header , smspec_required_keywords[i])) {
OK = false;
break;
}
for (int i=0; i < num_req_keywords && OK; i++) {
OK &= ecl_file_has_kw(
header,
get_active_keyword_alias(header, smspec_required_keywords[i])
);
}
return OK;
@ -1077,16 +1112,18 @@ static bool ecl_smspec_check_header( ecl_file_type * header ) {
static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * header_file , bool include_restart) {
ecl_file_type * header = ecl_file_open( header_file , 0);
if (header && ecl_smspec_check_header( header )) {
ecl_kw_type *wells = ecl_file_iget_named_kw(header, WGNAMES_KW , 0);
ecl_kw_type *keywords = ecl_file_iget_named_kw(header, KEYWORDS_KW , 0);
ecl_kw_type *startdat = ecl_file_iget_named_kw(header, STARTDAT_KW , 0);
ecl_kw_type *units = ecl_file_iget_named_kw(header, UNITS_KW , 0);
ecl_kw_type *dimens = ecl_file_iget_named_kw(header, DIMENS_KW , 0);
ecl_kw_type *nums = NULL;
ecl_kw_type *lgrs = NULL;
ecl_kw_type *numlx = NULL;
ecl_kw_type *numly = NULL;
ecl_kw_type *numlz = NULL;
const char * names_alias = get_active_keyword_alias(header, WGNAMES_KW);
ecl_kw_type *wells = ecl_file_iget_named_kw(header, names_alias , 0);
ecl_kw_type *keywords = ecl_file_iget_named_kw(header, KEYWORDS_KW , 0);
ecl_kw_type *startdat = ecl_file_iget_named_kw(header, STARTDAT_KW , 0);
ecl_kw_type *units = ecl_file_iget_named_kw(header, UNITS_KW , 0);
ecl_kw_type *dimens = ecl_file_iget_named_kw(header, DIMENS_KW , 0);
ecl_kw_type *nums = NULL;
ecl_kw_type *lgrs = NULL;
ecl_kw_type *numlx = NULL;
ecl_kw_type *numly = NULL;
ecl_kw_type *numlz = NULL;
int params_index;
ecl_smspec->num_regions = 0;
if (startdat == NULL)

View File

@ -18,6 +18,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <ert/util/util.h>
#include <ert/ecl/ecl_type.h>
@ -27,71 +28,96 @@
types.
*/
#define ECL_TYPE_NAME_CHAR "CHAR"
#define ECL_TYPE_NAME_C010 "C010"
#define ECL_TYPE_NAME_FLOAT "REAL"
#define ECL_TYPE_NAME_INT "INTE"
#define ECL_TYPE_NAME_DOUBLE "DOUB"
#define ECL_TYPE_NAME_BOOL "LOGI"
#define ECL_TYPE_NAME_MESSAGE "MESS"
static char * alloc_string_name(const ecl_data_type ecl_type) {
return util_alloc_sprintf(
"C%03d",
ecl_type_get_sizeof_ctype_fortio(ecl_type)
);
}
static bool is_ecl_string_name(const char * type_name) {
return (type_name[0] == 'C' &&
isdigit(type_name[1]) &&
isdigit(type_name[2]) &&
isdigit(type_name[3])
);
}
static size_t get_ecl_string_length(const char * type_name) {
if(!is_ecl_string_name(type_name))
util_abort("%s: Expected eclipse string (CXXX), received %s\n",
__func__, type_name);
return atoi(type_name+1);
}
ecl_data_type ecl_type_create(const ecl_type_enum type, const size_t element_size) {
ecl_data_type ecl_type = ecl_type_create_from_type(type);
ecl_data_type ecl_type = (
type == ECL_STRING_TYPE ?
ECL_STRING(element_size) :
ecl_type_create_from_type(type)
);
if(ecl_type.element_size != element_size)
util_abort(
"%s: element_size mismatch for type %d, was: %d, expected: %d\n",
__func__, type, element_size, ecl_type.element_size);
if(ecl_type_get_sizeof_ctype_fortio(ecl_type) != element_size)
util_abort(
"%s: element_size mismatch for type %d, was: %d, expected: %d\n",
__func__, type,
element_size, ecl_type_get_sizeof_ctype_fortio(ecl_type)
);
return ecl_type;
return ecl_type;
}
ecl_data_type ecl_type_create_from_type(const ecl_type_enum type) {
switch(type) {
case(ECL_CHAR_TYPE):
return ECL_CHAR;
case(ECL_INT_TYPE):
return ECL_INT;
case(ECL_FLOAT_TYPE):
return ECL_FLOAT;
case(ECL_DOUBLE_TYPE):
return ECL_DOUBLE;
case(ECL_BOOL_TYPE):
return ECL_BOOL;
case(ECL_MESS_TYPE):
return ECL_MESS;
case(ECL_C010_TYPE):
return ECL_C010;
default:
util_abort("%s: invalid ecl_type: %d\n", __func__, type);
return ECL_INT; /* Dummy */
}
switch(type) {
case(ECL_CHAR_TYPE):
return ECL_CHAR;
case(ECL_INT_TYPE):
return ECL_INT;
case(ECL_FLOAT_TYPE):
return ECL_FLOAT;
case(ECL_DOUBLE_TYPE):
return ECL_DOUBLE;
case(ECL_BOOL_TYPE):
return ECL_BOOL;
case(ECL_MESS_TYPE):
return ECL_MESS;
case(ECL_STRING_TYPE):
util_abort("%s: Variable length string type cannot be created"
" from type alone!\n" , __func__);
return ECL_STRING(0); /* Dummy */
default:
util_abort("%s: invalid ecl_type: %d\n", __func__, type);
return ECL_INT; /* Dummy */
}
}
ecl_type_enum ecl_type_get_type(const ecl_data_type ecl_type) {
return ecl_type.type;
}
size_t ecl_type_get_element_size(const ecl_data_type ecl_type) {
return ecl_type.element_size;
}
const char * ecl_type_get_name(const ecl_data_type ecl_type) {
char * ecl_type_alloc_name(const ecl_data_type ecl_type) {
switch (ecl_type.type) {
case(ECL_CHAR_TYPE):
return ECL_TYPE_NAME_CHAR ;
case(ECL_C010_TYPE):
return ECL_TYPE_NAME_C010;
return util_alloc_string_copy(ECL_TYPE_NAME_CHAR);
case(ECL_STRING_TYPE):
return alloc_string_name(ecl_type);
case(ECL_FLOAT_TYPE):
return ECL_TYPE_NAME_FLOAT;
return util_alloc_string_copy(ECL_TYPE_NAME_FLOAT);
case(ECL_DOUBLE_TYPE):
return ECL_TYPE_NAME_DOUBLE;
return util_alloc_string_copy(ECL_TYPE_NAME_DOUBLE);
case(ECL_INT_TYPE):
return ECL_TYPE_NAME_INT;
return util_alloc_string_copy(ECL_TYPE_NAME_INT);
case(ECL_BOOL_TYPE):
return ECL_TYPE_NAME_BOOL;
return util_alloc_string_copy(ECL_TYPE_NAME_BOOL);
case(ECL_MESS_TYPE):
return ECL_TYPE_NAME_MESSAGE;
return util_alloc_string_copy(ECL_TYPE_NAME_MESSAGE);
default:
util_abort("Internal error in %s - internal eclipse_type: %d not recognized - aborting \n",__func__ , ecl_type.type);
return NULL; /* Dummy */
@ -107,8 +133,8 @@ ecl_data_type ecl_type_create_from_name( const char * type_name ) {
return ECL_DOUBLE;
else if (strncmp( type_name , ECL_TYPE_NAME_CHAR , ECL_TYPE_LENGTH) == 0)
return ECL_CHAR;
else if (strncmp( type_name , ECL_TYPE_NAME_C010 , ECL_TYPE_LENGTH) == 0)
return ECL_C010;
else if (is_ecl_string_name(type_name))
return ECL_STRING(get_ecl_string_length(type_name));
else if (strncmp( type_name , ECL_TYPE_NAME_MESSAGE , ECL_TYPE_LENGTH) == 0)
return ECL_MESS;
else if (strncmp( type_name , ECL_TYPE_NAME_BOOL , ECL_TYPE_LENGTH) == 0)
@ -121,52 +147,64 @@ ecl_data_type ecl_type_create_from_name( const char * type_name ) {
int ecl_type_get_sizeof_ctype_fortio(const ecl_data_type ecl_type) {
if(ecl_type_is_char(ecl_type) || ecl_type_is_C010(ecl_type))
if(ecl_type_is_char(ecl_type) || ecl_type_is_string(ecl_type))
return ecl_type.element_size - 1;
else
return ecl_type_get_sizeof_ctype(ecl_type);
}
int ecl_type_get_sizeof_ctype(const ecl_data_type ecl_type) {
return ecl_type.element_size;
return ecl_type.element_size;
}
bool ecl_type_is_numeric(const ecl_data_type ecl_type) {
return (ecl_type_is_int(ecl_type) ||
ecl_type_is_float(ecl_type) ||
ecl_type_is_double(ecl_type));
return (ecl_type_is_int(ecl_type) ||
ecl_type_is_float(ecl_type) ||
ecl_type_is_double(ecl_type));
}
bool ecl_type_is_alpha(const ecl_data_type ecl_type) {
return (ecl_type_is_char(ecl_type) ||
ecl_type_is_mess(ecl_type) ||
ecl_type_is_string(ecl_type));
}
bool ecl_type_is_equal(const ecl_data_type ecl_type1,
const ecl_data_type ecl_type2) {
return (ecl_type1.type == ecl_type2.type &&
ecl_type1.element_size == ecl_type2.element_size);
return (ecl_type1.type == ecl_type2.type &&
ecl_type1.element_size == ecl_type2.element_size);
}
bool ecl_type_is_char(const ecl_data_type ecl_type) {
return (ecl_type.type == ECL_CHAR_TYPE);
return (ecl_type.type == ECL_CHAR_TYPE);
}
bool ecl_type_is_int(const ecl_data_type ecl_type) {
return (ecl_type.type == ECL_INT_TYPE);
return (ecl_type.type == ECL_INT_TYPE);
}
bool ecl_type_is_float(const ecl_data_type ecl_type) {
return (ecl_type.type == ECL_FLOAT_TYPE);
return (ecl_type.type == ECL_FLOAT_TYPE);
}
bool ecl_type_is_double(const ecl_data_type ecl_type) {
return (ecl_type.type == ECL_DOUBLE_TYPE);
return (ecl_type.type == ECL_DOUBLE_TYPE);
}
bool ecl_type_is_mess(const ecl_data_type ecl_type) {
return (ecl_type.type == ECL_MESS_TYPE);
return (ecl_type.type == ECL_MESS_TYPE);
}
bool ecl_type_is_bool(const ecl_data_type ecl_type) {
return (ecl_type.type == ECL_BOOL_TYPE);
return (ecl_type.type == ECL_BOOL_TYPE);
}
bool ecl_type_is_C010(const ecl_data_type ecl_type) {
return (ecl_type.type == ECL_C010_TYPE);
bool ecl_type_is_string(const ecl_data_type ecl_type) {
return (ecl_type.type == ECL_STRING_TYPE);
}
// Temporary fixup for OPM.
char * ecl_type_get_name(const ecl_data_type ecl_type) {
return ecl_type_alloc_name( ecl_type );
}

View File

@ -36,8 +36,8 @@ ecl_type_enum ecl_type_get_type_python(const ecl_data_type * ecl_type) {
return ecl_type_get_type(*ecl_type);
}
const char * ecl_type_get_name_python(const ecl_data_type * ecl_type) {
return ecl_type_get_name(*ecl_type);
const char * ecl_type_alloc_name_python(const ecl_data_type * ecl_type) {
return ecl_type_alloc_name(*ecl_type);
}
int ecl_type_get_sizeof_ctype_fortio_python(const ecl_data_type * ecl_type) {
@ -81,8 +81,8 @@ bool ecl_type_is_bool_python(const ecl_data_type * ecl_type) {
return ecl_type_is_bool(*ecl_type);
}
bool ecl_type_is_C010_python(const ecl_data_type * ecl_type) {
return ecl_type_is_C010(*ecl_type);
bool ecl_type_is_string_python(const ecl_data_type * ecl_type) {
return ecl_type_is_string(*ecl_type);
}
/**

View File

@ -33,21 +33,6 @@
#include <ert/ecl/ecl_type.h>
/*****************************************************************/
/* The string names for the different ECLIPSE low-level
types.
*/
#define ECL_TYPE_NAME_CHAR "CHAR"
#define ECL_TYPE_NAME_C010 "C010"
#define ECL_TYPE_NAME_FLOAT "REAL"
#define ECL_TYPE_NAME_INT "INTE"
#define ECL_TYPE_NAME_DOUBLE "DOUB"
#define ECL_TYPE_NAME_BOOL "LOGI"
#define ECL_TYPE_NAME_MESSAGE "MESS"
#define ECL_PHASE_NAME_OIL "SOIL" // SHould match the keywords found in restart file
#define ECL_PHASE_NAME_WATER "SWAT"
#define ECL_PHASE_NAME_GAS "SGAS"
@ -700,7 +685,7 @@ void ecl_util_memcpy_typed_data(void *_target_data , const void * _src_data , ec
break;
}
default:
util_abort("%s con not convert %s -> %s \n",__func__ , ecl_type_get_name(src_type) , ecl_type_get_name(target_type));
util_abort("%s con not convert %s -> %s \n",__func__ , ecl_type_alloc_name(src_type) , ecl_type_alloc_name(target_type));
}
}
}

View File

@ -407,20 +407,12 @@ smspec_node_type * smspec_node_alloc_new(int params_index, float default_value)
}
/**
Observe that the wellname can have max 8 characters; anything
beyond that is silently dropped.
*/
static void smspec_node_set_wgname( smspec_node_type * index , const char * wgname ) {
if (wgname == NULL) {
util_safe_free( index->wgname );
index->wgname = NULL;
} else {
if (strlen(wgname) > 8)
index->wgname = util_realloc_substring_copy(index->wgname , wgname , 8);
else
index->wgname = util_realloc_string_copy(index->wgname , wgname );
index->wgname = util_realloc_string_copy(index->wgname , wgname );
}
}

View File

@ -1,41 +0,0 @@
/*
Copyright (C) 2017 Statoil ASA, Norway.
The file 'ecl_kw_ix_types.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_util.h>
#include <ert/ecl/ecl_kw.h>
/*
The behaviour of the ECL_C010_TYPE is quite unclear; we therefor do
not alloaw instanstiation of keywords with this type.
*/
void test_create_ECL_C010_TYPE() {
ecl_kw_type * ecl_kw = ecl_kw_alloc("TEST" , 1000 , ECL_C010 );
test_assert_NULL( ecl_kw );
}
int main( int argc , char ** argv) {
test_create_ECL_C010_TYPE();
}

View File

@ -14,10 +14,6 @@ add_executable( ecl_kw_init ecl_kw_init.c )
target_link_libraries( ecl_kw_init ecl )
add_test( ecl_kw_init ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_init )
add_executable( ecl_kw_ix_types ecl_kw_ix_types.c )
target_link_libraries( ecl_kw_ix_types ecl )
add_test( ecl_kw_ix_types ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_ix_types )
add_executable( ecl_grid_init_fwrite ecl_grid_init_fwrite.c )
target_link_libraries( ecl_grid_init_fwrite ecl )
add_test( ecl_grid_init_fwrite ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_init_fwrite )

View File

@ -105,9 +105,9 @@ extern "C" {
#define SCON_CF_INDEX 0
#define XCON_WRAT_INDEX 46
#define XCON_GRAT_INDEX 47
#define XCON_ORAT_INDEX 48
#define XCON_ORAT_INDEX 0
#define XCON_WRAT_INDEX 1
#define XCON_GRAT_INDEX 2
#define XCON_QR_INDEX 49
#define RSEG_LENGTH_INDEX 0

View File

@ -82,6 +82,7 @@ extern "C" {
bool well_state_is_open( const well_state_type * well_state );
int well_state_get_well_nr( const well_state_type * well_state );
const well_conn_type * well_state_get_global_wellhead( const well_state_type * well_state );
const well_conn_type * well_state_iget_wellhead( const well_state_type * well_state , int grid_nr);
const well_conn_type * well_state_get_wellhead( const well_state_type * well_state , const char * grid_name);

View File

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

View File

@ -227,6 +227,7 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
if (xcon_kw) {
const int xcon_offset = header->nxconz * (header->ncwmax * well_nr + conn_nr);
conn->water_rate = ecl_kw_iget_as_double(xcon_kw, xcon_offset + XCON_WRAT_INDEX);
conn->gas_rate = ecl_kw_iget_as_double(xcon_kw, xcon_offset + XCON_GRAT_INDEX);
conn->oil_rate = ecl_kw_iget_as_double(xcon_kw, xcon_offset + XCON_ORAT_INDEX);

View File

@ -37,6 +37,8 @@
#include <ert/ecl/ecl_kw_magic.h>
#include <ert/ecl/ecl_util.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/ecl_units.h>
#include <ert/ecl/ecl_util.h>
#include <ert/ecl_well/well_const.h>
#include <ert/ecl_well/well_conn.h>
@ -173,7 +175,7 @@ struct well_state_struct {
double gas_rate;
double water_rate;
double volume_rate;
ert_ecl_unit_enum unit_system;
hash_type * connections; // hash<grid_name,well_conn_collection>
well_segment_collection_type * segments;
@ -210,7 +212,7 @@ well_state_type * well_state_alloc(const char * well_name , int global_well_nr ,
well_state->gas_rate = 0;
well_state->water_rate = 0;
well_state->volume_rate = 0;
well_state->unit_system = ECL_METRIC_UNITS;
/* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */
if ((type == ECL_WELL_ZERO) && open)
@ -240,17 +242,44 @@ double well_state_get_volume_rate( const well_state_type * well_state) {
}
double well_state_get_oil_rate_si( const well_state_type * well_state ) {
return well_state->oil_rate;
double conversion_factor = 1;
if (well_state->unit_system == ECL_METRIC_UNITS)
conversion_factor = 1.0 / ECL_UNITS_TIME_DAY;
else if (well_state->unit_system == ECL_FIELD_UNITS)
conversion_factor = ECL_UNITS_VOLUME_BARREL / ECL_UNITS_TIME_DAY;
else if (well_state->unit_system == ECL_LAB_UNITS)
conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR;
return well_state->oil_rate * conversion_factor;
}
double well_state_get_gas_rate_si( const well_state_type * well_state ) {
return well_state->gas_rate;
double conversion_factor = 1;
if (well_state->unit_system == ECL_METRIC_UNITS)
conversion_factor = 1.0 / ECL_UNITS_TIME_DAY;
else if (well_state->unit_system == ECL_FIELD_UNITS)
conversion_factor = ECL_UNITS_VOLUME_GAS_FIELD / ECL_UNITS_TIME_DAY;
else if (well_state->unit_system == ECL_LAB_UNITS)
conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR;
return well_state->gas_rate * conversion_factor;
}
double well_state_get_water_rate_si( const well_state_type * well_state) {
return well_state->water_rate;
double conversion_factor = 1;
if (well_state->unit_system == ECL_METRIC_UNITS)
conversion_factor = 1.0 / ECL_UNITS_TIME_DAY;
else if (well_state->unit_system == ECL_FIELD_UNITS)
conversion_factor = ECL_UNITS_VOLUME_BARREL / ECL_UNITS_TIME_DAY;
else if (well_state->unit_system == ECL_LAB_UNITS)
conversion_factor = ECL_UNITS_VOLUME_MILLI_LITER / ECL_UNITS_TIME_HOUR;
return well_state->water_rate * conversion_factor;
}
double well_state_get_volume_rate_si( const well_state_type * well_state) {
@ -278,6 +307,7 @@ static bool well_state_add_rates( well_state_type * well_state ,
ecl_rsthead_type *header = ecl_rsthead_alloc(rst_view, -1);
int offset = header->nxwelz * well_nr;
well_state->unit_system = header->unit_system;
well_state->oil_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_ORAT_ITEM);
well_state->gas_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_GRAT_ITEM);
well_state->water_rate = ecl_kw_iget_double(xwel_kw, offset + XWEL_RES_WRAT_ITEM);
@ -611,6 +641,13 @@ const well_conn_type * well_state_get_wellhead( const well_state_type * well_sta
return NULL;
}
const well_conn_type * well_state_get_global_wellhead( const well_state_type * well_state ) {
if (hash_has_key( well_state->name_wellhead , ECL_GRID_GLOBAL_GRID))
return hash_get( well_state->name_wellhead , ECL_GRID_GLOBAL_GRID );
else
return NULL;
}
well_type_enum well_state_get_type( const well_state_type * well_state){
return well_state->type;

View File

@ -12,7 +12,7 @@ set( header_files
)
add_library( eclxx ${LIBRARY_TYPE} ${source_files} )
add_library( eclxx ${source_files} )
set_target_properties( eclxx PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR})
if (USE_RUNPATH)
add_runpath( eclxx )

View File

@ -161,7 +161,7 @@ if (ERT_BUILD_CXX)
list( APPEND header_files test_util.hpp )
endif()
add_library( ert_util ${LIBRARY_TYPE} ${source_files} )
add_library( ert_util ${source_files} )
message(STATUS "Linking with: ${ERT_EXTERNAL_UTIL_LIBS}")
set_target_properties( ert_util PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR} )

View File

@ -8,7 +8,7 @@ set( header_files
)
add_library( ert_utilxx ${LIBRARY_TYPE} ${source_files} )
add_library( ert_utilxx ${source_files} )
set_target_properties( ert_utilxx PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR})
if (USE_RUNPATH)
add_runpath( ert_utilxx )

View File

@ -1,7 +1,7 @@
set( source_files geo_surface.c geo_util.c geo_pointset.c geo_region.c geo_polygon.c geo_polygon_collection.c)
set( header_files geo_surface.h geo_util.h geo_pointset.h geo_region.h geo_polygon.h geo_polygon_collection.h)
add_library( ert_geometry ${LIBRARY_TYPE} ${source_files} )
add_library( ert_geometry ${source_files} )
set_target_properties( ert_geometry PROPERTIES VERSION ${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} SOVERSION ${ERT_VERSION_MAJOR})
target_link_libraries( ert_geometry ert_util )
if (USE_RUNPATH)

View File

@ -1,28 +1,21 @@
include(cmake/find_python_module.cmake)
include(cmake/python_package_versions.cmake) # finds version
install( DIRECTORY cmake DESTINATION share )
FIND_PACKAGE(PythonInterp 2.7 EXACT)
if (NOT DEFINED PYTHON_EXECUTABLE)
message("Python2.7 interpreter not found - Python wrappers not enabled")
return()
endif()
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
include(init_python)
init_python( 2.7 )
python_package(numpy 1.7.1)
find_python_package(numpy 1.7.1 ${PYTHON_INSTALL_PREFIX})
if (NOT DEFINED PY_numpy)
message("numpy module not found - Python wrappers not enabled")
message(WARNING "numpy module not found - Python wrappers not enabled")
set( BUILD_PYTHON OFF PARENT_SCOPE )
return()
endif()
if (EXISTS "/etc/debian_version")
set( PYTHON_PACKAGE_PATH "dist-packages")
else()
set( PYTHON_PACKAGE_PATH "site-packages")
endif()
set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")
if (BUILD_TESTS)
add_subdirectory( tests )
endif()
add_subdirectory( python )

View File

@ -4,4 +4,4 @@ Python.
More detailed documentation of the wrapping can be found in
docs/devel.txt.
doc/devel.txt.

View File

@ -1,6 +1,3 @@
if (NOT PYTHONINTERP_FOUND)
find_package (PythonInterp REQUIRED)
endif ()
function(add_python_package target package_path source_files install_package)
set(build_files "")
@ -27,14 +24,14 @@ function(add_python_package target package_path source_files install_package)
add_custom_command(
OUTPUT ${build_file}
COMMAND ${PYTHON_EXECUTABLE}
ARGS ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc2 ${source_file} ${build_file}
ARGS ${PROJECT_BINARY_DIR}/bin/cmake_pyc ${source_file} ${build_file}
${dependent_target})
list(APPEND build_files ${build_file} )
if (install_package)
install(FILES ${build_file} DESTINATION ${CMAKE_INSTALL_PREFIX}/${package_path})
install(CODE "execute_process(COMMAND ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc_file ${install_file})")
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/bin/cmake_pyc_file ${install_file})")
endif()
endforeach()

View File

@ -0,0 +1,38 @@
# This macro will create a ctest based on the supplied TEST_CLASS. The
# TEST_CLASS argument should correspond to a valid Python path, i.e.
#
# >> import ${TEST_CLASS}
#
# should work. The actual test is by running a small test script which
# will invoke normal Python test discovery functionality. This is a
# macro, and relevant variables must be crrectly set in calling scope
# before it is invoked:
#
# PYTHON_TEST_RUNNER: Path to executable which will load the testcase
# given by ${TEST_CLASS} and run it.
#
#
# CTEST_PYTHONPATH: Normal colon separated path variable, should at
# least include the binary root directory of the current python
# installation, but can in addition contain the path to
# additional packages. The PYTHON_TEST_RUNNER should inspect the
# $CTEST_PYTHONPATH environment variable and update sys.path
# accordingly.
macro( addPythonTest TEST_CLASS )
set(TEST_NAME ${TEST_CLASS})
add_test(NAME ${TEST_NAME}
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}"
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/bin/ctest_run_python ${TEST_CLASS} )
set(oneValueArgs LABELS)
cmake_parse_arguments(TEST_OPTIONS "" "${oneValueArgs}" "" ${ARGN})
if(TEST_OPTIONS_LABELS)
set_property(TEST ${TEST_NAME} PROPERTY LABELS "Python:${TEST_OPTIONS_LABELS}")
else()
set_property(TEST ${TEST_NAME} PROPERTY LABELS "Python")
endif()
set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "CTEST_PYTHONPATH=${CTEST_PYTHONPATH}")
endmacro( )

View File

@ -1,6 +1,6 @@
# try import python module, if success, check its version, store as PY_module.
# the module is imported as-is, hence the case (e.g. PyQt4) must be correct.
function(python_package_version package)
function(find_python_package_version package)
set(PY_VERSION_ACCESSOR "__version__")
set(PY_package_name ${package})
@ -30,8 +30,25 @@ endfunction()
# If we find the correct module and new enough version, set PY_package, where
# "package" is the given argument to the version we found else, display warning
# and do not set any variables.
function(python_package package version)
python_package_version(${package})
function(find_python_package package version python_prefix)
if (CMAKE_PREFIX_PATH)
set( ORG_PYTHONPATH $ENV{PYTHONPATH} )
foreach ( PREFIX_PATH ${CMAKE_PREFIX_PATH} )
set(THIS_PYTHONPATH "${PREFIX_PATH}/${python_prefix}")
set(ENV{PYTHONPATH} "${THIS_PYTHONPATH}:${ORG_PYTHONPATH}")
find_python_package_version(${package})
if (DEFINED PY_${package})
if (${PY_${package}_PATH} STREQUAL ${THIS_PYTHONPATH})
set(CTEST_PYTHONPATH "${PY_${package}_PATH}:${CTEST_PYTHONPATH}" PARENT_SCOPE)
endif()
break( )
endif()
endforeach()
set(ENV{PYTHONPATH} ${ORG_PYTHONPATH})
else()
find_python_package_version(${package})
endif()
if(NOT DEFINED PY_${package})
message("Could not find Python package " ${package})

View File

@ -0,0 +1,175 @@
# This macro will initialize the current cmake session for Python. The
# macro starts by looking for the Python interpreter of correct
# version. When a Python interepreter of the correct version has been
# located the macro will continue to set variables, load other cmake
# modules and generate scripts to be used in the remaining part of the
# cmake process.
#
# Variables which will be set:
# ----------------------------
#
# PYTHON_INSTALL_PREFIX: All python packages will be located in
# ${GLOBAL_PREFIX}/${PYTHON_INSTALL_PREFIX} - this applies both
# when searching for dependencies and when installing.
#
# CTEST_PYTHONPATH: Normal ':' separated path variables which is
# passed to the test runner. Should contain the PYTHONPATH to
# all third party packages which are not in the default search
# path. The CTEST_PYTHONPATH variable will be updated by the
# python_package( ) function when searching for third party
# packages.
#
#
# New functions/macros which will be available:
# ---------------------------------------------
#
# add_python_package( ): This function will copy python source files
# to the build directory, 'compile' them and set up installation.
#
#
# add_python_test( ): Set up a test based on invoking a Python test
# class with a small python executable front end.
#
# find_python_package( ): Will search for a python package.
#
#
# New scripts generated:
# ----------------------
#
#
# cmake_pyc: Small script which will run in-place Python compilation
# of a directory tree recursively.
#
# cmake_pyc_file: Small script which will compile one python file.
#
# ctest_run_python: Small script which will invoke one Python test class.
#
# All the generated scripts will be located in ${PROJECT_BINARY_DIR}/bin.
#
#
# Downstream projects should use this as:
#
# include( init_python )
# init_python( 2.7 )
# ...
macro(init_python target_version)
FIND_PACKAGE(PythonInterp)
if (NOT DEFINED PYTHON_EXECUTABLE)
message(WARNING "Python interpreter not found - Python wrappers not enabled")
set( BUILD_PYTHON OFF PARENT_SCOPE )
return()
endif()
if (NOT "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" STREQUAL "${target_version}")
message(WARNING "Need Python version ${target_version}, found version: ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} - Python wrappers not enabled")
set( BUILD_PYTHON OFF PARENT_SCOPE )
return()
endif()
if (EXISTS "/etc/debian_version")
set( PYTHON_PACKAGE_PATH "dist-packages")
else()
set( PYTHON_PACKAGE_PATH "site-packages")
endif()
set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")
set(CTEST_PYTHONPATH ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX})
configure_python_env( )
include(add_python_test)
include(find_python_package)
include(add_python_package)
endmacro()
# The function configure_python_env( ) will generate three small
# Python scripts which will be located in ${PROJECT_BINARY_DIR}/bin
# and will be used when 'compiling' and testing Python code. The
# function will be called from the init_python() macro.
function( configure_python_env )
FILE(WRITE "${PROJECT_BINARY_DIR}/bin/ctest_run_python"
"import sys
import os
from unittest import TextTestRunner
def runTestCase(tests, verbosity=0):
test_result = TextTestRunner(verbosity=verbosity).run(tests)
if len(test_result.errors) or len(test_result.failures):
test_result.printErrors()
sys.exit(1)
def update_path():
for path in os.environ['CTEST_PYTHONPATH'].split(':'):
sys.path.insert(0 , path)
if __name__ == '__main__':
update_path( )
from ecl.test import ErtTestRunner
for test_class in sys.argv[1:]:
tests = ErtTestRunner.getTestsFromTestClass(test_class)
# Set verbosity to 2 to see which test method in a class that fails.
runTestCase(tests, verbosity=0)
")
#-----------------------------------------------------------------
FILE(WRITE "${PROJECT_BINARY_DIR}/bin/cmake_pyc"
"
import py_compile
import os
import os.path
import sys
import shutil
src_file = sys.argv[1]
target_file = sys.argv[2]
(target_path , tail) = os.path.split( target_file )
if not os.path.exists( target_path ):
try:
os.makedirs( target_path )
except:
# When running make with multiple processes there might be a
# race to create this directory.
pass
shutil.copyfile( src_file , target_file )
shutil.copystat( src_file , target_file )
try:
py_compile.compile( target_file , doraise = True)
except Exception as error:
sys.exit('py_compile(%s) failed:%s' % (target_file , error))
")
#-----------------------------------------------------------------
FILE(WRITE "${PROJECT_BINARY_DIR}/bin/cmake_pyc_file"
"
import py_compile
import os
import sys
import os.path
# Small 'python compiler' used in the build system for ert.
for file in sys.argv[1:]:
try:
py_compile.compile( file , doraise = True )
except Exception as error:
sys.exit('py_compile(%s) failed:%s' % (file , error))
")
endfunction()

View File

@ -1,27 +0,0 @@
# Found from: github user ivansafrin
#
# Find if a Python module is installed
# Found at http://www.cmake.org/pipermail/cmake/2011-January/041666.html
# To use do: find_python_module(PyQt4 REQUIRED)
function(find_python_module module)
string(TOUPPER ${module} module_upper)
if(NOT PY_${module_upper})
if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED")
set(${module}_FIND_REQUIRED TRUE)
endif()
# A module's location is usually a directory, but for binary modules
# it's a .so file.
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
RESULT_VARIABLE _${module}_status
OUTPUT_VARIABLE _${module}_location
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT _${module}_status)
set(PY_${module_upper} ${_${module}_location} CACHE STRING
"Location of Python module ${module}")
endif()
endif(NOT PY_${module_upper})
find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper})
endfunction(find_python_module)

View File

@ -1,5 +1,5 @@
configure_file(test_env.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/test_env.py )
add_subdirectory(cwrap)
add_subdirectory( ert )
add_subdirectory( ecl )
add_subdirectory( bin )

View File

@ -55,7 +55,7 @@ class CFILE(BaseCClass):
If the supplied argument is not of type py_file the function
will raise a TypeException.
Examples: ert.ecl.ecl_kw.EclKW.fprintf_grdecl()
Examples: ecl.ecl.ecl_kw.EclKW.fprintf_grdecl()
"""
c_ptr = self._as_file(py_file)
try:

View File

@ -17,13 +17,13 @@
Observe that to ensure that all libraries are loaded through the same
code path, all required libraries should be loaded explicitly through
the use of import statements; i.e. the ert.geo package requires the
the use of import statements; i.e. the ecl.geo package requires the
libert_util librarary, to ensure that the correct version of the
libert_util.so library file is loaded we should manually load that
first as:
import ert.util
GEO_LIB = ert.load("libert_geometry")
import ecl.util
GEO_LIB = ecl.load("libert_geometry")
Otherwise the standard operating system dependency resolve code will
be invoked when loading libert_geometry, and that could in principle

View File

@ -0,0 +1,14 @@
set(PYTHON_SOURCES
__init__.py
)
add_python_package("python.ecl" ${PYTHON_INSTALL_PREFIX}/ecl "${PYTHON_SOURCES}" True)
add_subdirectory(ecl)
add_subdirectory(geo)
add_subdirectory(test)
add_subdirectory(util)
add_subdirectory(well)
configure_file(ecl_lib_info_build.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ecl/__ecl_lib_info.py )
configure_file(ecl_lib_info_install.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ecl_lib_info_install.py )
install(FILES ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/ecl_lib_info_install.py DESTINATION ${PYTHON_INSTALL_PREFIX}/ecl RENAME __ecl_lib_info.py)

View File

@ -18,12 +18,10 @@ ert - Ensemble Reservoir Tool - a package for reservoir modeling.
The ert package itself has no code, but contains several subpackages:
ert.ecl: Package for working with ECLIPSE files. The far most mature
ecl.ecl: Package for working with ECLIPSE files. The far most mature
package in ert.
ert.job_queue:
ert.util:
ecl.util:
The ert package is based on wrapping the libriaries from the ERT C
code with ctypes; an essential part of ctypes approach is to load the
@ -69,22 +67,22 @@ except ImportError:
pass
required_version_hex = 0x02060000
required_version_hex = 0x02070000
ert_lib_path = None
ecl_lib_path = None
ert_so_version = ""
__version__ = "0.0.0"
# 1. Try to load the __ert_lib_info module; this module has been
# 1. Try to load the __ecl_lib_info module; this module has been
# configured by cmake during the build configuration process. The
# module should contain the variable lib_path pointing to the
# directory with shared object files.
try:
import __ert_lib_info
ert_lib_path = __ert_lib_info.lib_path
ert_so_version = __ert_lib_info.so_version
__version__ = __ert_lib_info.__version__
import __ecl_lib_info
ecl_lib_path = __ecl_lib_info.lib_path
ert_so_version = __ecl_lib_info.so_version
__version__ = __ecl_lib_info.__version__
except ImportError:
pass
except AttributeError:
@ -105,23 +103,23 @@ if env_lib_path:
# Check that the final ert_lib_path setting corresponds to an existing
# directory.
if ert_lib_path:
if not os.path.isdir( ert_lib_path ):
ert_lib_path = None
if ecl_lib_path:
if not os.path.isdir( ecl_lib_path ):
ecl_lib_path = None
if sys.hexversion < required_version_hex:
raise Exception("ERT Python requires at least version 2.6 of Python")
raise Exception("ERT Python requires Python 2.7.")
# This load() function is *the* function actually loading shared
# libraries.
def load(name):
return cwrapload( name , path = ert_lib_path , so_version = ert_so_version)
return cwrapload(name, path=ecl_lib_path, so_version=ert_so_version)
from ert.util import Version
from ert.util import updateAbortSignals
from .util import Version
from .util import updateAbortSignals
updateAbortSignals( )

View File

@ -30,7 +30,7 @@ set(PYTHON_SOURCES
ecl_grid_generator.py
)
add_python_package("python.ert.ecl" ${PYTHON_INSTALL_PREFIX}/ert/ecl "${PYTHON_SOURCES}" True)
add_python_package("python.ecl.ecl" ${PYTHON_INSTALL_PREFIX}/ecl/ecl "${PYTHON_SOURCES}" True)
add_subdirectory(faults)
add_subdirectory(rft)

View File

@ -72,19 +72,19 @@ per module organization:
namespace 'ecl'.
"""
import ert.util
import ert.geo
import ecl.util
import ecl.geo
from cwrap import Prototype
class EclPrototype(Prototype):
lib = ert.load("libecl")
lib = ecl.load("libecl")
def __init__(self, prototype, bind=True):
super(EclPrototype, self).__init__(EclPrototype.lib, prototype, bind=bind)
ECL_LIB = ert.load("libecl")
ECL_LIB = ecl.load("libecl")
from .ecl_util import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil
from .ecl_type import EclTypeEnum, EclDataType

View File

@ -14,7 +14,7 @@
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from ert.ecl import EclFile, Ecl3DKW
from ecl.ecl import EclFile, Ecl3DKW
class Ecl3DFile(EclFile):

View File

@ -37,7 +37,7 @@ class Ecl3DKW(EclKW):
Usage example:
from ert.ecl import EclInitFile,EclGrid
from ecl.ecl import EclInitFile,EclGrid
grid = EclGrid("ECLIPSE.EGRID")
file = EclInitFile(grid , "ECLIPSE.INIT")
@ -168,7 +168,7 @@ class Ecl3DKW(EclKW):
2. Convert the keyword to a 3D keyword.
from ert.ecl import EclGrid,EclKW,Ecl3DKW
from ecl.ecl import EclGrid,EclKW,Ecl3DKW
grid = EclGrid("ECLIPSE.EGRID")
poro = EclKW.read_grdecl(open("poro.grdecl") , "PORO")

View File

@ -14,7 +14,7 @@
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from ert.ecl import EclSum
from ecl.ecl import EclSum
class EclCase(object):

View File

@ -41,8 +41,8 @@ import datetime
import ctypes
from cwrap import BaseCClass
from ert.ecl import EclPrototype, EclKW, EclFileEnum, EclFileView
from ert.util import CTime
from ecl.ecl import EclPrototype, EclKW, EclFileEnum, EclFileView
from ecl.util import CTime
class EclFile(BaseCClass):
@ -100,7 +100,7 @@ class EclFile(BaseCClass):
corresponding to @report_step can be found. Since this is a
classmethod it is invoked like this:
import ert.ecl.ecl as ecl
import ecl.ecl.ecl as ecl
....
if ecl.EclFile.contains_report_step("ECLIPSE.UNRST" , 20):
print "OK - file contains report step 20"
@ -124,7 +124,7 @@ class EclFile(BaseCClass):
time corresponding to @dtime can be found. Since this is a
classmethod it is invoked like this:
import ert.ecl.ecl as ecl
import ecl.ecl.ecl as ecl
....
if ecl.EclFile.contains_sim_time("ECLIPSE.UNRST" , datetime.datetime( 2007 , 10 , 10) ):
print "OK - file contains 10th of October 2007"
@ -669,7 +669,7 @@ class EclFile(BaseCClass):
This method will write the current EclFile instance to a
FortIO stream already opened for writing:
import ert.ecl.ecl as ecl
import ecl.ecl.ecl as ecl
...
fortio = ecl.FortIO( "FILE.XX" )
file.fwrite( fortio )

View File

@ -17,8 +17,8 @@
from __future__ import absolute_import, division, print_function, unicode_literals
from six import string_types
from cwrap import BaseCClass
from ert.ecl import EclPrototype
from ert.util import CTime
from ecl.ecl import EclPrototype
from ecl.util import CTime
class EclFileView(BaseCClass):
TYPE_NAME = "ecl_file_view"

View File

@ -22,7 +22,7 @@ different surveys. The implementation is a thin wrapper around the
ecl_grav.c implementation in the libecl library.
"""
from cwrap import BaseCClass
from ert.ecl import EclPhaseEnum, EclPrototype
from ecl.ecl import EclPhaseEnum, EclPrototype
class EclGrav(BaseCClass):
@ -84,7 +84,7 @@ class EclGrav(BaseCClass):
to load the @restart_view argument is:
import datetime
from ert.ecl import EclRestartFile
from ecl.ecl import EclRestartFile
...
...
date = datetime.datetime( year , month , day )

View File

@ -14,7 +14,7 @@
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from ert.ecl import EclPrototype
from ecl.ecl import EclPrototype
_phase_deltag = EclPrototype("double ecl_grav_phase_deltag( double, double ,double , ecl_grid , ecl_file , ecl_kw , ecl_kw , ecl_kw , ecl_kw , ecl_kw , ecl_kw")

View File

@ -32,8 +32,8 @@ import os.path
import math
import itertools
from cwrap import CFILE, BaseCClass
from ert.util import IntVector
from ert.ecl import EclPrototype, EclDataType, EclKW, FortIO, EclUnitTypeEnum
from ecl.util import IntVector
from ecl.ecl import EclPrototype, EclDataType, EclKW, FortIO, EclUnitTypeEnum
class EclGrid(BaseCClass):
@ -222,7 +222,7 @@ class EclGrid(BaseCClass):
super(EclGrid, self).__init__(c_ptr)
else:
raise IOError("Loading grid from:%s failed" % filename)
self.__str__ = self.__repr__
def free(self):
self._free( )

View File

@ -17,8 +17,8 @@
import itertools
import numpy
from ert.util import IntVector
from ert.ecl import EclGrid, EclKW, EclDataType, EclPrototype
from ecl.util import IntVector
from ecl.ecl import EclGrid, EclKW, EclDataType, EclPrototype
class EclGridGenerator:

View File

@ -14,7 +14,7 @@
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from ert.ecl import EclFileEnum , EclFile, Ecl3DKW , Ecl3DFile
from ecl.ecl import EclFileEnum , EclFile, Ecl3DKW , Ecl3DFile
class EclInitFile(Ecl3DFile):

View File

@ -45,8 +45,8 @@ import warnings
import numpy
from cwrap import CFILE, BaseCClass
from ert.ecl import EclDataType
from ert.ecl import EclTypeEnum, EclUtil, EclPrototype
from ecl.ecl import EclDataType
from ecl.ecl import EclTypeEnum, EclUtil, EclPrototype
def dump_type_deprecation_warning():
warnings.warn("EclTypeEnum is deprecated. " +
@ -109,6 +109,8 @@ class EclKW(BaseCClass):
_get_type = EclPrototype("ecl_type_enum ecl_kw_get_type( ecl_kw )")
_iget_char_ptr = EclPrototype("char* ecl_kw_iget_char_ptr( ecl_kw , int )")
_iset_char_ptr = EclPrototype("void ecl_kw_iset_char_ptr( ecl_kw , int , char*)")
_iget_string_ptr = EclPrototype("char* ecl_kw_iget_string_ptr( ecl_kw , int )")
_iset_string_ptr = EclPrototype("void ecl_kw_iset_string_ptr( ecl_kw , int, char*)")
_iget_bool = EclPrototype("bool ecl_kw_iget_bool( ecl_kw , int)")
_iset_bool = EclPrototype("bool ecl_kw_iset_bool( ecl_kw , int, bool)")
_iget_int = EclPrototype("int ecl_kw_iget_int( ecl_kw , int )")
@ -398,6 +400,8 @@ class EclKW(BaseCClass):
self.str_fmt = "%d"
elif self.data_type.is_mess():
self.str_fmt = "%s" #"Message type"
elif self.data_type.is_string():
self.str_fmt = "%" + str(self.data_type.element_size) + "s"
else:
raise ValueError("Unknown EclDataType (%s)!" % self.data_type.type_name)
@ -474,6 +478,8 @@ class EclKW(BaseCClass):
return self._iget_bool( index)
elif self.data_type.is_char():
return self._iget_char_ptr( index )
elif self.data_type.is_string():
return self._iget_string_ptr( index )
else:
raise TypeError("Internal implementation error ...")
elif isinstance( index , slice):
@ -502,6 +508,8 @@ class EclKW(BaseCClass):
self._iset_bool( index , value)
elif self.data_type.is_char():
return self._iset_char_ptr( index , value)
elif self.data_type.is_string():
return self._iset_string_ptr( index, value)
else:
raise SystemError("Internal implementation error ...")
elif isinstance( index , slice):
@ -1059,7 +1067,7 @@ class EclKW(BaseCClass):
existing GRDECL file, set all poro values below 0.05 to 0.00
and write back an updated GRDECL file.
poro = ecl.EclKW.load_grdecl( open("poro1.grdecl" , "r") , "PORO" )
poro = ecl.EclKW.read_grdecl( open("poro1.grdecl" , "r") , "PORO" )
grid = ecl.EclGrid( "ECLIPSE.EGRID" )
reg = ecl.EclRegion( grid , False )

View File

@ -17,7 +17,7 @@
import re
import datetime
import numbers
from ert.ecl import EclSum
from ecl.ecl import EclSum
class NPVParseKey(object):

View File

@ -28,10 +28,10 @@ queried for the corresponding list of indices.
import ctypes
from cwrap import BaseCClass
from ert.ecl.faults import Layer
from ert.ecl import EclKW, EclDataType, EclPrototype
from ert.geo import CPolyline
from ert.util import IntVector
from ecl.ecl.faults import Layer
from ecl.ecl import EclKW, EclDataType, EclPrototype
from ecl.geo import CPolyline
from ecl.util import IntVector
def select_method(select):
@ -825,7 +825,7 @@ class EclRegion(BaseCClass):
vertical coordinate @k.
The input @layer should be of type Layer - from the
ert.ecl.faults.layer module. The k value must in the range
ecl.ecl.faults.layer module. The k value must in the range
[0,grid.nz) and the dimensions of the layer must correspond
exactly to nx,ny of the grid.
"""

View File

@ -14,8 +14,8 @@
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from ert.util import CTime
from ert.ecl import EclPrototype , EclFile, Ecl3DKW , Ecl3DFile, EclFileEnum
from ecl.util import CTime
from ecl.ecl import EclPrototype , EclFile, Ecl3DKW , Ecl3DFile, EclFileEnum
from cwrap import BaseCClass
class EclRestartHead(BaseCClass):
@ -26,7 +26,9 @@ class EclRestartHead(BaseCClass):
_get_report_step = EclPrototype("int ecl_rsthead_get_report_step(ecl_rsthead)")
_get_sim_time = EclPrototype("time_t ecl_rsthead_get_sim_time(ecl_rsthead)")
_get_sim_days = EclPrototype("double ecl_rsthead_get_sim_days(ecl_rsthead)")
_get_nxconz = EclPrototype("int ecl_rsthead_get_nxconz(ecl_rsthead)")
_get_ncwmax = EclPrototype("int ecl_rsthead_get_ncwmax(ecl_rsthead)")
def __init__(self , kw_arg = None , rst_view = None):
if kw_arg is None and rst_view is None:
raise ValueError('Cannot construct EclRestartHead without one of kw_arg and rst_view, both were None!')
@ -53,6 +55,11 @@ class EclRestartHead(BaseCClass):
def getSimDays(self):
return self._get_sim_days( )
def well_details(self):
return {"NXCONZ" : self._get_nxconz(),
"NCWMAX" : self._get_ncwmax()}
class EclRestartFile(Ecl3DFile):
@ -129,3 +136,13 @@ class EclRestartFile(Ecl3DFile):
time_list.append( (header.getReportStep() , header.getSimDate( ) , header.getSimDays( )) )
return time_list
def headers(self):
self.assertHeaders()
return self.rst_headers
def get_header(self, index):
self.assertHeaders()
return self.rst_headers[index]

View File

@ -20,8 +20,8 @@ Module for loading ECLIPSE RFT files.
from __future__ import absolute_import, division, print_function, unicode_literals
from cwrap import BaseCClass
from ert.ecl import EclRFTCell, EclPLTCell, EclPrototype
from ert.util import CTime
from ecl.ecl import EclRFTCell, EclPLTCell, EclPrototype
from ecl.util import CTime
class EclRFT(BaseCClass):
"""The EclRFT class contains the information for *one* RFT.

View File

@ -15,7 +15,7 @@
# for more details.
from cwrap import BaseCClass
from ert.ecl import EclPrototype
from ecl.ecl import EclPrototype
class RFTCell(BaseCClass):

View File

@ -15,7 +15,7 @@
# for more details.
from cwrap import BaseCClass
from ert.ecl import EclPrototype
from ecl.ecl import EclPrototype
class EclSMSPECNode(BaseCClass):

View File

@ -23,7 +23,7 @@ different surveys. The implementation is a thin wrapper around the
ecl_subsidence.c implementation in the libecl library.
"""
from cwrap import BaseCClass
from ert.ecl import EclPrototype
from ecl.ecl import EclPrototype
class EclSubsidence(BaseCClass):
@ -79,7 +79,7 @@ class EclSubsidence(BaseCClass):
to load the @restart_file argument is:
import datetime
import ert.ecl.ecl as ecl
import ecl.ecl.ecl as ecl
...
...
date = datetime.datetime( year , month , day )

View File

@ -31,18 +31,18 @@ import os.path
# index as the first argument and the key/key_index as second
# argument. In the python code this order has been reversed.
from cwrap import BaseCClass, CFILE
from ert.ecl import EclSumTStep
from ert.ecl import EclSumVarType
from ert.ecl.ecl_sum_vector import EclSumVector
from ert.ecl.ecl_smspec_node import EclSMSPECNode
from ert.util import StringList, CTime, DoubleVector, TimeVector, IntVector
from ert.ecl import EclPrototype
from ecl.ecl import EclSumTStep
from ecl.ecl import EclSumVarType
from ecl.ecl.ecl_sum_vector import EclSumVector
from ecl.ecl.ecl_smspec_node import EclSMSPECNode
from ecl.util import StringList, CTime, DoubleVector, TimeVector, IntVector
from ecl.ecl import EclPrototype
#, EclSumKeyWordVector
#import ert.ecl_plot.sum_plot as sum_plot
#import ecl.ecl_plot.sum_plot as sum_plot
# The date2num function is a verbatim copy of the _to_ordinalf()
# function from the matplotlib.dates module. Inserted here only to
@ -1240,5 +1240,5 @@ class EclSum(BaseCClass):
import ert.ecl.ecl_sum_keyword_vector
import ecl.ecl.ecl_sum_keyword_vector
EclSum._dump_csv_line = EclPrototype("void ecl_sum_fwrite_interp_csv_line(ecl_sum , time_t , ecl_sum_vector, FILE)" , bind = False)

View File

@ -24,7 +24,7 @@ import datetime
# argument. In the python code this order has been reversed.
from cwrap import BaseCClass
from ert.ecl import EclPrototype
from ecl.ecl import EclPrototype

View File

@ -1,6 +1,6 @@
from cwrap import BaseCClass
from ert.ecl import EclPrototype
from ert.util import CTime
from ecl.ecl import EclPrototype
from ecl.util import CTime
class EclSumTStep(BaseCClass):

View File

@ -14,7 +14,7 @@
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from cwrap import BaseCEnum
from ert.ecl import ECL_LIB
from ecl.ecl import ECL_LIB
class EclSumVarType(BaseCEnum):

View File

@ -16,7 +16,7 @@
from __future__ import print_function
import warnings
from ert.ecl.ecl_sum_node import EclSumNode
from ecl.ecl.ecl_sum_node import EclSumNode
class EclSumVector(object):

View File

@ -15,7 +15,7 @@
# for more details.
from cwrap import BaseCClass, BaseCEnum
from ert.ecl import EclPrototype
from ecl.ecl import EclPrototype
class EclTypeEnum(BaseCEnum):
TYPE_NAME="ecl_type_enum"
@ -25,6 +25,7 @@ class EclTypeEnum(BaseCEnum):
ECL_INT_TYPE = None
ECL_BOOL_TYPE = None
ECL_MESS_TYPE = None
ECL_STRING_TYPE = None
EclTypeEnum.addEnum("ECL_CHAR_TYPE" , 0 )
EclTypeEnum.addEnum("ECL_FLOAT_TYPE" , 1 )
@ -32,6 +33,7 @@ EclTypeEnum.addEnum("ECL_DOUBLE_TYPE" , 2 )
EclTypeEnum.addEnum("ECL_INT_TYPE" , 3 )
EclTypeEnum.addEnum("ECL_BOOL_TYPE" , 4 )
EclTypeEnum.addEnum("ECL_MESS_TYPE" , 5 )
EclTypeEnum.addEnum("ECL_STRING_TYPE" , 7 )
#-----------------------------------------------------------------
@ -44,14 +46,15 @@ class EclDataType(BaseCClass):
_alloc_from_name = EclPrototype("void* ecl_type_alloc_from_name_python(char*)", bind = False)
_free = EclPrototype("void ecl_type_free_python(ecl_data_type)")
_get_type = EclPrototype("ecl_type_enum ecl_type_get_type_python(ecl_data_type)")
_get_element_size = EclPrototype("size_t ecl_type_get_sizeof_ctype_python(ecl_data_type)")
_get_element_size = EclPrototype("size_t ecl_type_get_sizeof_ctype_fortio_python(ecl_data_type)")
_is_int = EclPrototype("bool ecl_type_is_int_python(ecl_data_type)")
_is_char = EclPrototype("bool ecl_type_is_char_python(ecl_data_type)")
_is_float = EclPrototype("bool ecl_type_is_float_python(ecl_data_type)")
_is_double = EclPrototype("bool ecl_type_is_double_python(ecl_data_type)")
_is_mess = EclPrototype("bool ecl_type_is_mess_python(ecl_data_type)")
_is_bool = EclPrototype("bool ecl_type_is_bool_python(ecl_data_type)")
_get_name = EclPrototype("char* ecl_type_get_name_python(ecl_data_type)")
_is_string = EclPrototype("bool ecl_type_is_string_python(ecl_data_type)")
_get_name = EclPrototype("char* ecl_type_alloc_name_python(ecl_data_type)")
_is_numeric = EclPrototype("bool ecl_type_is_numeric_python(ecl_data_type)")
_is_equal = EclPrototype("bool ecl_type_is_equal_python(ecl_data_type, ecl_data_type)")
@ -60,7 +63,7 @@ class EclDataType(BaseCClass):
if type_name:
c_ptr = self._alloc_from_name(type_name)
elif not element_size:
elif element_size is None:
c_ptr = self._alloc_from_type(type_enum)
else:
c_ptr = self._alloc(type_enum, element_size)
@ -70,10 +73,22 @@ class EclDataType(BaseCClass):
def _assert_valid_arguments(self, type_enum, element_size, type_name):
if type_name is not None:
if type_enum is not None or element_size is not None:
raise ValueError("Type name given (%s). Expected both type_enum and element_size to be None")
err_msg = ("Type name given (%s). Expected both " +
"type_enum and element_size to be None")
raise ValueError(err_msg % type_name)
elif type_enum is None:
raise ValueError("Both type_enum and type_name is None!")
elif type_enum == EclTypeEnum.ECL_STRING_TYPE:
if element_size is None:
raise ValueError("When creating an ECL_STRING one must " +
"provide an element size!")
if not (0 <= element_size <= 999):
raise ValueError("Expected element_size to be in the range " +
"[0, 999], was: %d" % element_size)
@property
def type(self):
return self._get_type()
@ -107,6 +122,9 @@ class EclDataType(BaseCClass):
def is_bool(self):
return self._is_bool()
def is_string(self):
return self._is_string()
def is_numeric(self):
return self._is_numeric()
@ -160,3 +178,7 @@ class EclDataType(BaseCClass):
@classproperty
def ECL_CHAR(cls):
return EclDataType(EclTypeEnum.ECL_CHAR_TYPE)
@classmethod
def ECL_STRING(cls, elem_size):
return EclDataType(EclTypeEnum.ECL_STRING_TYPE, elem_size)

View File

@ -26,7 +26,7 @@ functions from ecl_util.c which are not bound to any class type.
"""
import ctypes
from cwrap import BaseCEnum
from ert.ecl import EclPrototype, ECL_LIB
from ecl.ecl import EclPrototype, ECL_LIB
class EclFileEnum(BaseCEnum):
TYPE_NAME="ecl_file_enum"

View File

@ -9,4 +9,4 @@ set(PYTHON_SOURCES
layer.py
)
add_python_package("python.ert.ecl.faults" ${PYTHON_INSTALL_PREFIX}/ert/ecl/faults "${PYTHON_SOURCES}" True)
add_python_package("python.ecl.ecl.faults" ${PYTHON_INSTALL_PREFIX}/ecl/ecl/faults "${PYTHON_SOURCES}" True)

View File

@ -14,9 +14,9 @@
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
# for more details.
from ert.geo import Polyline, CPolyline, GeometryTools
from ert.util import stat
from ert.util import Matrix
from ecl.geo import Polyline, CPolyline, GeometryTools
from ecl.util import stat
from ecl.util import Matrix
from .fault_line import FaultLine
from .fault_segments import FaultSegment, SegmentMap

View File

@ -15,10 +15,10 @@
# for more details.
import ctypes
from ert.ecl import EclPrototype
from ecl.ecl import EclPrototype
from cwrap import BaseCClass
from ert.geo import Polyline, GeometryTools , CPolylineCollection
from ert.util import DoubleVector , IntVector
from ecl.geo import Polyline, GeometryTools , CPolylineCollection
from ecl.util import DoubleVector , IntVector
class FaultBlockCell(object):
def __init__(self , i,j,k ,x,y,z):

View File

@ -16,7 +16,7 @@
from cwrap import BaseCClass
from ert.ecl import EclPrototype
from ecl.ecl import EclPrototype
class FaultBlockCollection(BaseCClass):

View File

@ -16,8 +16,8 @@
from __future__ import print_function
from cwrap import BaseCClass
from ert.ecl import EclDataType, EclPrototype
from ert.ecl.faults import Fault
from ecl.ecl import EclDataType, EclPrototype
from ecl.ecl.faults import Fault
class FaultBlockLayer(BaseCClass):
TYPE_NAME = "fault_block_layer"

View File

@ -16,7 +16,7 @@
import re
from .fault import Fault
from ert.ecl import EclGrid
from ecl.ecl import EclGrid
comment_regexp = re.compile("--.*")

View File

@ -16,8 +16,8 @@
from __future__ import print_function
import sys
from ert.util import DoubleVector,stat
from ert.geo import CPolyline
from ecl.util import DoubleVector,stat
from ecl.geo import CPolyline
from .fault_segments import FaultSegment

View File

@ -16,8 +16,8 @@
import ctypes
from cwrap import BaseCClass
from ert.ecl import EclPrototype
from ert.util import IntVector
from ecl.ecl import EclPrototype
from ecl.util import IntVector
class Layer(BaseCClass):

View File

@ -40,7 +40,7 @@ import ctypes
import os
import sys
from cwrap import BaseCClass
from ert.ecl import EclPrototype
from ecl.ecl import EclPrototype
class FortIO(BaseCClass):
@ -85,7 +85,7 @@ class FortIO(BaseCClass):
all the pressure keywords to another file:
import sys
from ert.ecl import FortIO, EclFile
from ecl.ecl import FortIO, EclFile
rst_file = EclFile(sys.argv[1])
fortio = FortIO("PRESSURE", mode=FortIO.WRITE_MODE)
@ -194,7 +194,7 @@ def openFortIO(file_name, mode=FortIO.READ_MODE, fmt_file=False, endian_flip_hea
the situation where you need to ensure resource cleanup.
import sys
from ert.ecl import FortIO, EclFile
from ecl.ecl import FortIO, EclFile
rst_file = EclFile(sys.argv[1])
with openFortIO("PRESSURE", mode=FortIO.WRITE_MODE) as fortio:

View File

@ -9,5 +9,5 @@ if (EXISTS ${ECL_LOCAL_TARGET})
endif()
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py")
add_python_package( "Python ert.ecl.ecl_local" ${PYTHON_INSTALL_PREFIX}/ert/ecl "ecl_local.py" True)
endif()
add_python_package( "Python ecl.ecl.ecl_local" ${PYTHON_INSTALL_PREFIX}/ecl/ecl "ecl_local.py" True)
endif()

View File

@ -0,0 +1,6 @@
set(PYTHON_SOURCES
__init__.py
well_trajectory.py
)
add_python_package("python.ecl.ecl.rft" ${PYTHON_INSTALL_PREFIX}/ecl/ecl/rft "${PYTHON_SOURCES}" True)

View File

@ -10,4 +10,4 @@ set(PYTHON_SOURCES
surface.py
)
add_python_package("python.ert.geo" ${PYTHON_INSTALL_PREFIX}/ert/geo "${PYTHON_SOURCES}" True)
add_python_package("python.ecl.geo" ${PYTHON_INSTALL_PREFIX}/ecl/geo "${PYTHON_SOURCES}" True)

View File

@ -17,11 +17,11 @@
Simple package for working with 2D geometry.
"""
import ert
import ecl
from cwrap import Prototype
class GeoPrototype(Prototype):
lib = ert.load("libert_geometry")
lib = ecl.load("libert_geometry")
def __init__(self, prototype, bind=True):
super(GeoPrototype, self).__init__(GeoPrototype.lib, prototype, bind=bind)

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