mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
parent
a7ba7c793c
commit
c07875701a
@ -53,7 +53,7 @@ include (ResInsightVersion.cmake)
|
||||
|
||||
# Disable install of ERT libs and headers, as Ert code is compiled and linked directly
|
||||
SET(INSTALL_ERT OFF CACHE BOOL "ERT: Install library")
|
||||
SET(USE_OPENMP ${OPENMP_FOUND} CACHE BOOL "ERT: Compile using OpenMP")
|
||||
SET(ERT_USE_OPENMP ${OPENMP_FOUND} CACHE BOOL "ERT: Compile using OpenMP")
|
||||
|
||||
add_subdirectory(ThirdParty/Ert/devel)
|
||||
|
||||
|
49
ThirdParty/Ert/devel/CMakeLists.txt
vendored
49
ThirdParty/Ert/devel/CMakeLists.txt
vendored
@ -10,10 +10,13 @@ option( BUILD_TESTS "Should the tests be built" OFF)
|
||||
option( BUILD_APPLICATIONS "Should we build small utility applications" OFF)
|
||||
option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF)
|
||||
option( BUILD_PYTHON "Run py_compile on the python wrappers" OFF)
|
||||
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
|
||||
option( INSTALL_ERT "Should anything be installed when issuing make install?" ON)
|
||||
|
||||
option( ERT_BUILD_GUI "Should the pyQt based gui be compiled and installed" OFF )
|
||||
option( ERT_USE_OPENMP "Use OpenMP - currently only in EclGrid" ON)
|
||||
|
||||
include( CheckFunctionExists )
|
||||
include( CheckTypeSize )
|
||||
ENABLE_TESTING()
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
@ -26,6 +29,7 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
add_definitions( -DWINDOWS_LFS )
|
||||
endif()
|
||||
|
||||
|
||||
# Treat warnings as errors if not on Windows
|
||||
if (ERT_WINDOWS)
|
||||
set( CMAKE_C_FLAGS "-O2" )
|
||||
@ -35,29 +39,42 @@ else()
|
||||
set( CMAKE_CXX_FLAGS "-g -Wall -O2 ")
|
||||
endif()
|
||||
|
||||
if (ERT_USE_OPENMP)
|
||||
find_package(OpenMP)
|
||||
if (OPENMP_FOUND)
|
||||
message(STATUS "Enabling OpenMP support")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_SHARED_LINKER_FLAGS}")
|
||||
else()
|
||||
message(STATUS "OpenMP package not found - OpenMP disabled")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
include(cmake/ert_check.cmake)
|
||||
include(cmake/ert_find.cmake)
|
||||
include(cmake/Modules/UseMultiArch.cmake)
|
||||
include(cmake/ert_link.cmake)
|
||||
|
||||
|
||||
set( INSTALL_GROUP "" CACHE STRING "Group to install as - blank to install as current group")
|
||||
set(INSTALL_GROUP "" CACHE STRING "Group to install as - blank to install as current group")
|
||||
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
|
||||
if (MSVC)
|
||||
set( LIBRARY_TYPE STATIC )
|
||||
set( SHARED_LIB OFF )
|
||||
else()
|
||||
if (INSTALL_ERT)
|
||||
set( LIBRARY_TYPE SHARED )
|
||||
set( SHARED_LIB ON )
|
||||
else()
|
||||
set( LIBRARY_TYPE STATIC )
|
||||
set( SHARED_LIB OFF )
|
||||
endif(INSTALL_ERT)
|
||||
endif()
|
||||
|
||||
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__="\\"????\\"")
|
||||
@ -67,12 +84,10 @@ endif()
|
||||
if (ERT_LINUX)
|
||||
set( NEED_LIBM TRUE )
|
||||
set( LINK_STATIC FALSE )
|
||||
set( NEED_LIBDL ON )
|
||||
add_definitions( -DHAVE_PROC )
|
||||
else()
|
||||
set( NEED_LIBM FALSE )
|
||||
set( LINK_STATIC TRUE )
|
||||
set( NEED_LIBDL OFF )
|
||||
endif()
|
||||
|
||||
|
||||
@ -105,8 +120,6 @@ add_subdirectory( libecl_well )
|
||||
#-----------------------------------------------------------------
|
||||
if (BUILD_ERT)
|
||||
#-----------------------------------------------------------------
|
||||
option(USE_LSF "Include support for LSF" ON)
|
||||
|
||||
include_directories( ${PROJECT_SOURCE_DIR}/libconfig/include )
|
||||
add_subdirectory( libconfig )
|
||||
|
||||
|
21
ThirdParty/Ert/devel/cmake/Tests/test_mktime_before1970.c
vendored
Normal file
21
ThirdParty/Ert/devel/cmake/Tests/test_mktime_before1970.c
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
struct tm ts;
|
||||
ts.tm_sec = 0;
|
||||
ts.tm_min = 0;
|
||||
ts.tm_hour = 0;
|
||||
ts.tm_mday = 1;
|
||||
ts.tm_mon = 0;
|
||||
ts.tm_year = 0;
|
||||
ts.tm_isdst = -1;
|
||||
{
|
||||
time_t t = mktime( &ts );
|
||||
if (t == -1)
|
||||
exit(1);
|
||||
else
|
||||
exit(0);
|
||||
}
|
||||
}
|
71
ThirdParty/Ert/devel/cmake/create_cmakelists.py
vendored
Normal file
71
ThirdParty/Ert/devel/cmake/create_cmakelists.py
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from os import listdir
|
||||
from os.path import isfile, join, isdir
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
def findFilesAndDirectories(directory):
|
||||
all_files = listdir(directory)
|
||||
files = []
|
||||
directories = []
|
||||
for f in all_files:
|
||||
path = join(directory, f)
|
||||
if isfile(path) and not f == "CMakeLists.txt":
|
||||
files.append(f)
|
||||
if isdir(path):
|
||||
directories.append(f)
|
||||
|
||||
return sorted(files), sorted(directories)
|
||||
|
||||
|
||||
def findRelativeModulePath(directory):
|
||||
"""@type directory: str"""
|
||||
index = directory.rfind("python/")
|
||||
index += len("python/")
|
||||
return directory[index:len(directory)]
|
||||
|
||||
def createPythonSources(files):
|
||||
result = ""
|
||||
|
||||
if len(files) > 0:
|
||||
result = "set(PYTHON_SOURCES\n"
|
||||
|
||||
files = [f for f in files if f.endswith(".py")]
|
||||
|
||||
for f in files:
|
||||
result += " " + str(f) + "\n"
|
||||
|
||||
if len(files) > 0:
|
||||
result += ")"
|
||||
|
||||
return result
|
||||
|
||||
def addSubDirectories(directories):
|
||||
result = ""
|
||||
|
||||
for d in directories:
|
||||
result += "add_subdirectory(" + str(d) + ")\n"
|
||||
|
||||
return result
|
||||
|
||||
def addPythonPackage(relative_module_path):
|
||||
module_name = ".".join(relative_module_path.split("/"))
|
||||
template = "add_python_package(\"Python %s\" ${PYTHON_INSTALL_PREFIX}/%s \"${PYTHON_SOURCES}\" True)"
|
||||
|
||||
return template % (module_name, relative_module_path)
|
||||
|
||||
|
||||
files, directories = findFilesAndDirectories(sys.argv[1])
|
||||
module_path = findRelativeModulePath(sys.argv[1])
|
||||
|
||||
output_file = join(sys.argv[1], "CMakeLists.txt")
|
||||
with open(output_file, "w+") as text_file:
|
||||
text_file.write(createPythonSources(files))
|
||||
text_file.write("\n\n")
|
||||
text_file.write(addPythonPackage(module_path))
|
||||
text_file.write("\n\n")
|
||||
text_file.write(addSubDirectories(directories))
|
||||
|
||||
|
21
ThirdParty/Ert/devel/cmake/ert_check.cmake
vendored
21
ThirdParty/Ert/devel/cmake/ert_check.cmake
vendored
@ -43,6 +43,18 @@ if (HAVE_GETUID)
|
||||
add_definitions( -DHAVE_GETUID )
|
||||
endif()
|
||||
|
||||
check_function_exists( _chdir HAVE_WINDOWS_CHDIR)
|
||||
if (HAVE_WINDOWS_CHDIR)
|
||||
add_definitions( -DHAVE_WINDOWS_CHDIR)
|
||||
else()
|
||||
check_function_exists( chdir HAVE_CHDIR)
|
||||
if (HAVE_CHDIR)
|
||||
add_definitions( -DHAVE_CHDIR)
|
||||
else()
|
||||
message(FATAL_ERROR "Could not find chdir() / _chdir() functions")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
check_function_exists( localtime_r HAVE_LOCALTIME_R )
|
||||
if (HAVE_LOCALTIME_R)
|
||||
add_definitions( -DHAVE_LOCALTIME_R )
|
||||
@ -128,5 +140,14 @@ if (ISREG_POSIX)
|
||||
add_definitions( -DHAVE_ISREG )
|
||||
endif()
|
||||
|
||||
check_type_size(time_t SIZE_OF_TIME_T)
|
||||
if (${SIZE_OF_TIME_T} EQUAL 8)
|
||||
try_run( RUN_RESULT COMPILE_RESULT ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mktime_before1970.c )
|
||||
if (RUN_RESULT)
|
||||
add_defintions( -DTIME_T_64BIT_ACCEPT_PRE1970 )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set( CMAKE_C_FLAGS ${CMAKE_C_FLAGS_main} )
|
||||
set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_main} )
|
||||
|
||||
|
15
ThirdParty/Ert/devel/cmake/ert_find.cmake
vendored
15
ThirdParty/Ert/devel/cmake/ert_find.cmake
vendored
@ -1,3 +1,15 @@
|
||||
set(NEED_LIBDL OFF)
|
||||
find_library( DL_LIBRARY NAMES dl )
|
||||
find_path( DLFUNC_HEADER dlfcn.h )
|
||||
if (DL_LIBRARY AND DLFUNC_HEADER)
|
||||
set(CMAKE_REQUIRED_LIBRARIES dl)
|
||||
|
||||
check_function_exists( dladdr HAVE_DLADDR )
|
||||
if (HAVE_DLADDR)
|
||||
add_definitions( -DHAVE_DLADDR )
|
||||
set(NEED_LIBDL ON)
|
||||
endif()
|
||||
endif()
|
||||
#-----------------------------------------------------------------
|
||||
find_library( ZLIB_LIBRARY NAMES z )
|
||||
find_path( ZLIB_HEADER zlib.h /usr/include )
|
||||
@ -66,6 +78,9 @@ if (GETOPT_HEADER)
|
||||
endif()
|
||||
#-----------------------------------------------------------------
|
||||
find_path( UNISTD_HEADER unistd.h /usr/include )
|
||||
if (UNISTD_HEADER)
|
||||
add_definitions( -DHAVE_UNISTD )
|
||||
endif()
|
||||
|
||||
if (ERT_WINDOWS)
|
||||
find_library( SHLWAPI_LIBRARY NAMES Shlwapi )
|
||||
|
@ -1,8 +1,8 @@
|
||||
function( ert_module module args source_files )
|
||||
|
||||
set( build_file ${CMAKE_CURRENT_BINARY_DIR}/${module}.so )
|
||||
function( ert_module target args source_files )
|
||||
|
||||
set( build_file ${target}.so )
|
||||
set( depends analysis )
|
||||
set( arg_string "${module} ${args}")
|
||||
set( arg_string "${target} ${args}")
|
||||
separate_arguments( arg_list UNIX_COMMAND "${arg_string}")
|
||||
foreach (src_file ${source_files} )
|
||||
list(APPEND arg_list ${CMAKE_CURRENT_SOURCE_DIR}/${src_file} )
|
||||
@ -16,6 +16,8 @@ function( ert_module module args source_files )
|
||||
DEPENDS ${depends})
|
||||
|
||||
install(FILES ${build_file} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
get_filename_component( module ${target} NAME )
|
||||
add_custom_target( ${module} ALL DEPENDS ${build_file} )
|
||||
|
||||
endfunction()
|
||||
|
@ -22,6 +22,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/matrix.h>
|
||||
|
||||
|
||||
@ -38,11 +39,22 @@ extern "C" {
|
||||
*/
|
||||
|
||||
|
||||
#define ANALYSIS_NEED_ED 1
|
||||
#define ANALYSIS_USE_A 4 // The module will read the content of A - but not modify it.
|
||||
#define ANALYSIS_UPDATE_A 8 // The update will be based on modifying A directly, and not on an X matrix.
|
||||
#define ANALYSIS_SCALE_DATA 16
|
||||
#define ANALYSIS_ITERABLE 32 // The module can bu uused as an iterative smoother.
|
||||
typedef enum {
|
||||
ANALYSIS_NEED_ED = 1,
|
||||
ANALYSIS_USE_A = 4, // The module will read the content of A - but not modify it.
|
||||
ANALYSIS_UPDATE_A = 8, // The update will be based on modifying A directly, and not on an X matrix.
|
||||
ANALYSIS_SCALE_DATA = 16,
|
||||
ANALYSIS_ITERABLE = 32 // The module can bu used as an iterative smoother.
|
||||
} analysis_module_flag_enum;
|
||||
|
||||
|
||||
#define ANALYSIS_MODULE_FLAG_ENUM_SIZE 5
|
||||
#define ANALYSIS_MODULE_FLAG_ENUM_DEFS {.value = ANALYSIS_NEED_ED , .name = "ANALYSIS_NEED_ED"},\
|
||||
{.value = ANALYSIS_USE_A , .name = "ANALYSIS_USE_A"},\
|
||||
{.value = ANALYSIS_UPDATE_A , .name = "ANALYSIS_UPDATE_A"},\
|
||||
{.value = ANALYSIS_SCALE_DATA , .name = "ANALYSIS_SCALE_DATA"},\
|
||||
{.value = ANALYSIS_ITERABLE , .name = "ANALYSIS_ITERABLE"}
|
||||
|
||||
|
||||
#define EXTERNAL_MODULE_NAME "analysis_table"
|
||||
#define EXTERNAL_MODULE_SYMBOL analysis_table
|
||||
@ -96,13 +108,18 @@ extern "C" {
|
||||
bool analysis_module_set_var( analysis_module_type * module , const char * var_name , const char * string_value );
|
||||
const char * analysis_module_get_table_name( const analysis_module_type * module);
|
||||
const char * analysis_module_get_name( const analysis_module_type * module );
|
||||
bool analysis_module_get_option( const analysis_module_type * module , long flag);
|
||||
bool analysis_module_check_option( const analysis_module_type * module , long flag);
|
||||
void analysis_module_complete_update( analysis_module_type * module );
|
||||
|
||||
bool analysis_module_has_var( const analysis_module_type * module , const char * var );
|
||||
double analysis_module_get_double( const analysis_module_type * module , const char * var);
|
||||
int analysis_module_get_int( const analysis_module_type * module , const char * var);
|
||||
void * analysis_module_get_ptr( const analysis_module_type * module , const char * var);
|
||||
const char * analysis_module_flag_enum_iget( int index, int * value);
|
||||
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( analysis_module );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void enkf_linalg_rml_enkfX3(matrix_type *X3, matrix_type *VdTr, double *Wdr,matr
|
||||
void enkf_linalg_rml_enkfdA(matrix_type *dA1,matrix_type *Dm,matrix_type *X3);
|
||||
|
||||
double enkf_linalg_data_mismatch(matrix_type *D , matrix_type *R , matrix_type *Sk);
|
||||
void enkf_linalg_Covariance(matrix_type *Cd, matrix_type *E, double nsc ,int nrobs);
|
||||
void enkf_linalg_Covariance(matrix_type *Cd, const matrix_type *E, double nsc ,int nrobs);
|
||||
void enkf_linalg_rml_enkfAm(matrix_type * Um, double * Wm,int nsign1);
|
||||
|
||||
void enkf_linalg_rml_enkfX4 (matrix_type *X4,matrix_type *Am, matrix_type *A);
|
||||
|
@ -4,4 +4,9 @@ set( RML_SOURCE_FILES
|
||||
rml_enkf.c
|
||||
rml_enkf_common.c )
|
||||
|
||||
ert_module( rml_enkf ${args} "${RML_SOURCE_FILES}")
|
||||
set( RMLI_SOURCE_FILES
|
||||
rml_enkf_imodel.c
|
||||
rml_enkf_common.c )
|
||||
|
||||
ert_module( ${LIBRARY_OUTPUT_PATH}/rml_enkf ${args} "${RML_SOURCE_FILES}")
|
||||
ert_module( ${LIBRARY_OUTPUT_PATH}/rmli_enkf ${args} "${RMLI_SOURCE_FILES}")
|
||||
|
129
ThirdParty/Ert/devel/libanalysis/modules/rml_enkf.c
vendored
129
ThirdParty/Ert/devel/libanalysis/modules/rml_enkf.c
vendored
@ -89,11 +89,10 @@ struct rml_enkf_data_struct {
|
||||
long option_flags;
|
||||
|
||||
int iteration_nr; // Keep track of the outer iteration loop
|
||||
double lamda; // parameter to control the search direction in Marquardt levenberg optimization
|
||||
double lambda; // parameter to control the search direction in Marquardt levenberg optimization
|
||||
double Sk; // Objective function value
|
||||
double Std; // Standard Deviation of the Objective function
|
||||
matrix_type *state;
|
||||
matrix_type *Cd;
|
||||
};
|
||||
|
||||
|
||||
@ -143,7 +142,6 @@ void * rml_enkf_data_alloc( rng_type * rng) {
|
||||
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_ITERABLE;
|
||||
data->iteration_nr = 0;
|
||||
data->Std = 0;
|
||||
data->Cd = NULL;
|
||||
data->state = NULL;
|
||||
return data;
|
||||
}
|
||||
@ -152,9 +150,6 @@ void * rml_enkf_data_alloc( rng_type * rng) {
|
||||
void rml_enkf_data_free( void * module_data ) {
|
||||
rml_enkf_data_type * data = rml_enkf_data_safe_cast( module_data );
|
||||
|
||||
if (data->Cd != NULL)
|
||||
matrix_free( data->Cd );
|
||||
|
||||
if (data->state != NULL)
|
||||
matrix_free( data->state );
|
||||
|
||||
@ -165,6 +160,19 @@ void rml_enkf_data_free( void * module_data ) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
About the matrix Cd: The matrix Cd is calculated based on the content
|
||||
of the E input matrix. In the original implementation this matrix was
|
||||
only calculated in the first iteration, and then reused between subsequent
|
||||
iterations.
|
||||
|
||||
Due to deactivating outliers the number of active observations can change
|
||||
from one iteration to the next, if the matrix Cd is then reused between
|
||||
iterations we will get a matrix size mismatch in the linear algebra. In the
|
||||
current implementation the Cd matrix is recalculated based on the E input
|
||||
for each iteration.
|
||||
*/
|
||||
|
||||
void rml_enkf_updateA(void * module_data ,
|
||||
matrix_type * A ,
|
||||
matrix_type * S ,
|
||||
@ -181,6 +189,7 @@ void rml_enkf_updateA(void * module_data ,
|
||||
|
||||
int ens_size = matrix_get_columns( S );
|
||||
int nrobs = matrix_get_rows( S );
|
||||
matrix_type * Cd = matrix_alloc( nrobs , nrobs);
|
||||
double nsc = 1/sqrt(ens_size-1);
|
||||
matrix_type * Skm = matrix_alloc(matrix_get_columns(D),matrix_get_columns(D));
|
||||
FILE *fp = util_fopen("rml_enkf_output","a");
|
||||
@ -191,82 +200,76 @@ void rml_enkf_updateA(void * module_data ,
|
||||
double * Wd = util_calloc( nrmin , sizeof * Wd );
|
||||
|
||||
|
||||
|
||||
|
||||
Cd = matrix_alloc( nrobs, nrobs );
|
||||
enkf_linalg_Covariance(Cd ,E ,nsc, nrobs);
|
||||
matrix_inv(Cd);
|
||||
|
||||
if (data->iteration_nr == 0) {
|
||||
data->Cd = matrix_alloc( nrobs, nrobs );
|
||||
enkf_linalg_Covariance(data->Cd ,E ,nsc, nrobs);
|
||||
matrix_inv(data->Cd);
|
||||
|
||||
Sk_new = enkf_linalg_data_mismatch(D,data->Cd,Skm); //Calculate the intitial data mismatch term
|
||||
Std_new= matrix_diag_std(Skm,Sk_new);
|
||||
data->lamda =pow(10,floor(log10(Sk_new/(2*nrobs))));
|
||||
Sk_new = enkf_linalg_data_mismatch(D,Cd,Skm); //Calculate the intitial data mismatch term
|
||||
Std_new = matrix_diag_std(Skm,Sk_new);
|
||||
data->lambda = pow(10,floor(log10(Sk_new/(2*nrobs))));
|
||||
data->state = matrix_realloc_copy(data->state , A);
|
||||
rml_enkf_common_initA__(A,S,data->Cd,E,D,truncation,data->lamda,Ud,Wd,VdT);
|
||||
data->Sk = Sk_new;
|
||||
data->Std=Std_new;
|
||||
rml_enkf_common_initA__(A,S,Cd,E,D,truncation,data->lambda,Ud,Wd,VdT);
|
||||
data->Sk = Sk_new;
|
||||
data->Std = Std_new;
|
||||
printf("Prior Objective function value is %5.3f \n", data->Sk);
|
||||
|
||||
fprintf(fp,"Iteration number\t Lamda Value \t Current Mean (OB FN) \t Old Mean\t Current Stddev\n");
|
||||
fprintf(fp, "\n\n");
|
||||
fprintf(fp,"%d \t\t NA \t %5.5f \t \t %5.5f \n",data->iteration_nr, Sk_new, Std_new);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
} else {
|
||||
Sk_new = enkf_linalg_data_mismatch(D , Cd , Skm); //Calculate the intitial data mismatch term
|
||||
Std_new= matrix_diag_std(Skm,Sk_new);
|
||||
printf(" Current Objective function value is %5.3f \n\n",Sk_new);
|
||||
printf("The old Objective function value is %5.3f \n", data->Sk);
|
||||
|
||||
|
||||
if ((Sk_new< (data->Sk)) && (Std_new< (data->Std)))
|
||||
{
|
||||
Sk_new = enkf_linalg_data_mismatch(D,data->Cd,Skm); //Calculate the intitial data mismatch term
|
||||
Std_new= matrix_diag_std(Skm,Sk_new);
|
||||
printf(" Current Objective function value is %5.3f \n\n",Sk_new);
|
||||
printf("The old Objective function value is %5.3f \n", data->Sk);
|
||||
|
||||
|
||||
if ((Sk_new< (data->Sk)) && (Std_new< (data->Std)))
|
||||
{
|
||||
if ( (1- (Sk_new/data->Sk)) < .0001) // check convergence ** model change norm has to be added in this!!
|
||||
data-> iteration_nr = 16;
|
||||
if ( (1- (Sk_new/data->Sk)) < .0001) // check convergence ** model change norm has to be added in this!!
|
||||
data-> iteration_nr = 16;
|
||||
|
||||
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lamda, Sk_new,data->Sk, Std_new);
|
||||
data->lamda = data->lamda / 10 ;
|
||||
data->Std = Std_new;
|
||||
data->state = matrix_realloc_copy(data->state , A);
|
||||
data->Sk = Sk_new;
|
||||
rml_enkf_common_initA__(A,S,data->Cd,E,D,truncation,data->lamda,Ud,Wd,VdT);
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lambda, Sk_new,data->Sk, Std_new);
|
||||
data->lambda = data->lambda / 10 ;
|
||||
data->Std = Std_new;
|
||||
data->state = matrix_realloc_copy(data->state , A);
|
||||
data->Sk = Sk_new;
|
||||
rml_enkf_common_initA__(A,S,Cd,E,D,truncation,data->lambda,Ud,Wd,VdT);
|
||||
}
|
||||
else if((Sk_new< (data->Sk)) && (Std_new > (data->Std)))
|
||||
{
|
||||
if ( (1- (Sk_new/data->Sk)) < .0001) // check convergence ** model change norm has to be added in this!!
|
||||
data-> iteration_nr = 16;
|
||||
|
||||
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lambda, Sk_new,data->Sk, Std_new);
|
||||
data->Std=Std_new;
|
||||
data->state = matrix_realloc_copy(data->state , A);
|
||||
data->Sk = Sk_new;
|
||||
rml_enkf_common_initA__(A,S,Cd,E,D,truncation,data->lambda,Ud,Wd,VdT);
|
||||
}
|
||||
else {
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lambda, Sk_new,data->Sk, Std_new);
|
||||
printf("The previous step is rejected !!\n");
|
||||
data->lambda = data ->lambda * 4;
|
||||
matrix_assign( A , data->state );
|
||||
rml_enkf_common_initA__(A,S,Cd,E,D,truncation,data->lambda,Ud,Wd,VdT);
|
||||
data->iteration_nr--;
|
||||
}
|
||||
else if((Sk_new< (data->Sk)) && (Std_new > (data->Std)))
|
||||
{
|
||||
if ( (1- (Sk_new/data->Sk)) < .0001) // check convergence ** model change norm has to be added in this!!
|
||||
data-> iteration_nr = 16;
|
||||
|
||||
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lamda, Sk_new,data->Sk, Std_new);
|
||||
data->lamda = data->lamda; // Here we are not updating lamda!
|
||||
data->Std=Std_new;
|
||||
data->state = matrix_realloc_copy(data->state , A);
|
||||
data->Sk = Sk_new;
|
||||
rml_enkf_common_initA__(A,S,data->Cd,E,D,truncation,data->lamda,Ud,Wd,VdT);
|
||||
}
|
||||
else {
|
||||
fprintf(fp,"%d \t\t %5.5f \t %5.5f \t %5.5f \t %5.5f \n",data->iteration_nr,data->lamda, Sk_new,data->Sk, Std_new);
|
||||
printf("The previous step is rejected !!\n");
|
||||
data->lamda = data ->lamda * 4;
|
||||
matrix_assign( A , data->state );
|
||||
rml_enkf_common_initA__(A,S,data->Cd,E,D,truncation,data->lamda,Ud,Wd,VdT);
|
||||
data->iteration_nr--;
|
||||
}
|
||||
}
|
||||
data->iteration_nr++;
|
||||
|
||||
//setting the lower bound for lamda
|
||||
if (data->lamda <.01)
|
||||
data->lamda= .01;
|
||||
|
||||
// setting the lower bound for lambda
|
||||
if (data->lambda <.01)
|
||||
data->lambda= .01;
|
||||
|
||||
|
||||
printf ("The current iteration number is %d \n ", data->iteration_nr);
|
||||
|
||||
|
||||
|
||||
matrix_free(Cd);
|
||||
matrix_free(Ud);
|
||||
matrix_free(VdT);
|
||||
matrix_free(Skm);
|
||||
|
@ -32,9 +32,10 @@
|
||||
#include <ert/analysis/analysis_module.h>
|
||||
#include <ert/analysis/analysis_table.h>
|
||||
#include <ert/analysis/enkf_linalg.h>
|
||||
#include <ert/analysis/rml_enkf_common.h>
|
||||
#include <ert/analysis/std_enkf.h>
|
||||
|
||||
#include <rml_enkf_common.h>
|
||||
|
||||
/*
|
||||
A random 'magic' integer id which is used for run-time type checking
|
||||
of the input data.
|
||||
@ -139,7 +140,7 @@ void * rml_enkf_imodel_data_alloc( rng_type * rng) {
|
||||
|
||||
rml_enkf_imodel_set_truncation( data , DEFAULT_ENKF_TRUNCATION_ );
|
||||
rml_enkf_imodel_set_subspace_dimension( data , DEFAULT_SUBSPACE_DIMENSION );
|
||||
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A;
|
||||
data->option_flags = ANALYSIS_NEED_ED + ANALYSIS_UPDATE_A + ANALYSIS_ITERABLE;
|
||||
data->iteration_nr = 0;
|
||||
data->Std = 0;
|
||||
return data;
|
||||
@ -473,7 +474,6 @@ long rml_enkf_imodel_get_options( void * arg , long flag ) {
|
||||
|
||||
|
||||
bool rml_enkf_imodel_has_var( const void * arg, const char * var_name) {
|
||||
const rml_enkf_imodel_data_type * module_data = rml_enkf_imodel_data_safe_cast_const( arg );
|
||||
{
|
||||
if (strcmp(var_name , "ITER") == 0)
|
||||
return true;
|
@ -4,7 +4,7 @@ import os
|
||||
import os.path
|
||||
from optparse import OptionParser
|
||||
|
||||
ert_root = os.path.realpath( os.path.join(os.path.dirname( os.path.abspath( __file__)) , "../") )
|
||||
ert_root = os.path.realpath( os.path.join(os.path.dirname( os.path.realpath( os.path.abspath( __file__))) , "../") )
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
|
@ -6,25 +6,13 @@ set_target_properties( analysis PROPERTIES COMPILE_DEFINITIONS INTERNAL_LINK)
|
||||
set_target_properties( analysis PROPERTIES VERSION 1.0 SOVERSION 1.0 )
|
||||
|
||||
target_link_libraries( analysis ert_util )
|
||||
if (NEED_LIBDL)
|
||||
target_link_libraries( analysis dl )
|
||||
endif()
|
||||
target_link_libraries( analysis dl )
|
||||
|
||||
if (USE_RUNPATH)
|
||||
add_runpath( analysis )
|
||||
endif()
|
||||
|
||||
|
||||
## List of modules
|
||||
#set( CMAKE_SHARED_MODULE_PREFIX "" )
|
||||
##add_library( std_enkf MODULE std_enkf.c )
|
||||
#add_library( sqrt_enkf MODULE sqrt_enkf.c )
|
||||
#add_library( rml_enkf MODULE rml_enkf.c rml_enkf_common.c )
|
||||
#
|
||||
#ert_module( std_enkf std_enkf.c )
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
if (INSTALL_ERT)
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/rng.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/analysis/analysis_module.h>
|
||||
#include <ert/analysis/analysis_table.h>
|
||||
@ -81,9 +82,12 @@ static analysis_module_type * analysis_module_alloc_empty( const char * user_nam
|
||||
module->get_int = NULL;
|
||||
module->get_double = NULL;
|
||||
module->get_ptr = NULL;
|
||||
module->user_name = util_alloc_string_copy( user_name );
|
||||
module->symbol_table = util_alloc_string_copy( symbol_table );
|
||||
module->lib_name = util_alloc_string_copy( lib_name );
|
||||
module->alloc = NULL;
|
||||
|
||||
module->user_name = util_alloc_string_copy( user_name );
|
||||
module->symbol_table = util_alloc_string_copy( symbol_table );
|
||||
module->lib_name = util_alloc_string_copy( lib_name );
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
@ -119,7 +123,7 @@ static analysis_module_type * analysis_module_alloc__( rng_type * rng ,
|
||||
module->get_double = table->get_double;
|
||||
module->get_ptr = table->get_ptr;
|
||||
|
||||
if (module->alloc != NULL)
|
||||
if (module->alloc)
|
||||
module->module_data = module->alloc( rng );
|
||||
|
||||
if (!analysis_module_internal_check( module )) {
|
||||
@ -213,6 +217,7 @@ bool analysis_module_internal( const analysis_module_type * module ) {
|
||||
/*****************************************************************/
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION( analysis_module , ANALYSIS_MODULE_TYPE_ID )
|
||||
UTIL_IS_INSTANCE_FUNCTION( analysis_module , ANALYSIS_MODULE_TYPE_ID )
|
||||
|
||||
|
||||
void analysis_module_free( analysis_module_type * module ) {
|
||||
@ -372,13 +377,16 @@ bool analysis_module_set_var( analysis_module_type * module , const char * var_n
|
||||
}
|
||||
|
||||
|
||||
bool analysis_module_get_option( const analysis_module_type * module , long flag) {
|
||||
return (flag & module->get_options( module->module_data , flag ));
|
||||
bool analysis_module_check_option( const analysis_module_type * module , long flag) {
|
||||
if ((flag & module->get_options( module->module_data , flag )) == flag)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool analysis_module_has_var( const analysis_module_type * module , const char * var) {
|
||||
if (module->has_var != NULL)
|
||||
if (module->has_var)
|
||||
return module->has_var( module->module_data , var );
|
||||
else
|
||||
return false;
|
||||
@ -422,3 +430,11 @@ void * analysis_module_get_ptr( const analysis_module_type * module , const char
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
const char * analysis_module_flag_enum_iget( int index, int * value) {
|
||||
return util_enum_iget( index , ANALYSIS_MODULE_FLAG_ENUM_SIZE , (const util_enum_element_type []) { ANALYSIS_MODULE_FLAG_ENUM_DEFS }, value);
|
||||
}
|
||||
|
||||
|
@ -180,8 +180,6 @@ int enkf_linalg_svdS(const matrix_type * S ,
|
||||
}
|
||||
}
|
||||
|
||||
printf("PCA completed: Number of significant terms = %d\n",num_significant);
|
||||
|
||||
/* Inverting the significant singular values */
|
||||
for (i = 0; i < num_significant; i++)
|
||||
inv_sig0[i] = 1.0 / sig0[i];
|
||||
@ -700,9 +698,15 @@ double enkf_linalg_data_mismatch(matrix_type *D , matrix_type *R , matrix_type *
|
||||
{
|
||||
matrix_type * tmp = matrix_alloc (matrix_get_columns(D), matrix_get_columns(R));
|
||||
double mean;
|
||||
|
||||
|
||||
printf("-----------------------------------------------------------------\n");
|
||||
printf("%s:%d Calling matrix_dgemm() \n",__func__ , __LINE__);
|
||||
// C A B
|
||||
matrix_dgemm(tmp, D, R,true, false, 1.0, 0.0);
|
||||
printf("-----------------------------------------------------------------\n");
|
||||
printf("%s:%d Calling matrix_dgemm() \n",__func__ , __LINE__);
|
||||
matrix_dgemm(Sk, tmp, D, false, false, 1.0, 0.0);
|
||||
printf("-----------------------------------------------------------------\n");
|
||||
|
||||
printf("The data mismatch computed");
|
||||
|
||||
@ -712,7 +716,7 @@ double enkf_linalg_data_mismatch(matrix_type *D , matrix_type *R , matrix_type *
|
||||
return mean;
|
||||
}
|
||||
|
||||
void enkf_linalg_Covariance(matrix_type *Cd, matrix_type *E, double nsc ,int nrobs)
|
||||
void enkf_linalg_Covariance(matrix_type *Cd, const matrix_type *E, double nsc ,int nrobs)
|
||||
{
|
||||
matrix_matlab_dump( E, "matrixE.dat");
|
||||
printf("Starting Dgemm for EE(T)\n");
|
||||
|
@ -1 +1,9 @@
|
||||
add_test( analysis_rml_enkf_module ${EXECUTABLE_OUTPUT_PATH}/ert_module_test ${PROJECT_BINARY_DIR}/libanalysis/modules/rml_enkf.so )
|
||||
add_test( analysis_module_test_RML ${EXECUTABLE_OUTPUT_PATH}/ert_module_test ${LIBRARY_OUTPUT_PATH}/rml_enkf.so )
|
||||
add_test( analysis_module_test_RMLI ${EXECUTABLE_OUTPUT_PATH}/ert_module_test ${LIBRARY_OUTPUT_PATH}/rmli_enkf.so )
|
||||
|
||||
|
||||
add_executable(analysis_test_external_module analysis_test_external_module.c )
|
||||
target_link_libraries( analysis_test_external_module analysis util test_util )
|
||||
|
||||
add_test( analysis_module_rml ${EXECUTABLE_OUTPUT_PATH}/analysis_test_external_module "RML_ENKF" ${LIBRARY_OUTPUT_PATH}/rml_enkf.so 41 ITER)
|
||||
add_test( analysis_module_rmli ${EXECUTABLE_OUTPUT_PATH}/analysis_test_external_module "RMLI_ENKF" ${LIBRARY_OUTPUT_PATH}/rmli_enkf.so 41 ITER)
|
62
ThirdParty/Ert/devel/libanalysis/tests/analysis_test_external_module.c
vendored
Normal file
62
ThirdParty/Ert/devel/libanalysis/tests/analysis_test_external_module.c
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'analysis_test_external_module.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/rng.h>
|
||||
|
||||
#include <ert/analysis/analysis_module.h>
|
||||
|
||||
|
||||
|
||||
void load_module( rng_type * rng , const char * user_name , const char * lib_name, const char * options_str , int nvar , const char ** var_list) {
|
||||
long flags = strtol(options_str , NULL , 10);
|
||||
analysis_module_type * analysis_module = analysis_module_alloc_external(rng , user_name , lib_name);
|
||||
|
||||
printf("Loading:%s \n" , lib_name);
|
||||
test_assert_string_equal( EXTERNAL_MODULE_NAME , analysis_module_get_table_name(analysis_module));
|
||||
if (util_is_abs_path(lib_name))
|
||||
test_assert_string_equal( lib_name , analysis_module_get_lib_name(analysis_module));
|
||||
|
||||
test_assert_true( analysis_module_is_instance( analysis_module));
|
||||
for (int i=0; i < nvar; i++) {
|
||||
printf("has_var(%s) \n" , var_list[i]);
|
||||
test_assert_true( analysis_module_has_var(analysis_module , var_list[i]));
|
||||
}
|
||||
test_assert_false( analysis_module_has_var(analysis_module , "DoesNotHaveThisVariable"));
|
||||
test_assert_true( analysis_module_check_option( analysis_module , flags));
|
||||
flags += 1;
|
||||
test_assert_false( analysis_module_check_option( analysis_module , flags));
|
||||
analysis_module_free( analysis_module);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * user_name = argv[1];
|
||||
const char * lib_name = argv[2];
|
||||
const char * options_str = argv[3];
|
||||
int nvar = argc - 4;
|
||||
rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT);
|
||||
|
||||
load_module(rng , user_name , lib_name , options_str , nvar , (const char **) &argv[4]);
|
||||
rng_free( rng );
|
||||
|
||||
exit(0);
|
||||
}
|
2
ThirdParty/Ert/devel/libconfig/src/config.c
vendored
2
ThirdParty/Ert/devel/libconfig/src/config.c
vendored
@ -648,7 +648,7 @@ static void config_parse__(config_type * config ,
|
||||
current_path_elm = config_add_path_elm( config , config_path );
|
||||
path_stack_push_cwd( path_stack );
|
||||
if (config_path != NULL) {
|
||||
chdir( config_path );
|
||||
util_chdir( config_path );
|
||||
free( config_path );
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void parse_test(config_type * config ,
|
||||
util_alloc_file_components( config_file , &config_path , NULL , NULL);
|
||||
path_stack_push( path_stack , NULL );
|
||||
if (root_path != NULL)
|
||||
chdir( root_path );
|
||||
util_chdir( root_path );
|
||||
|
||||
config_abs_path = util_alloc_abs_path( config_path );
|
||||
config_rel_path = util_alloc_rel_path( NULL , config_abs_path);
|
||||
|
@ -36,13 +36,13 @@ int main(int argc , char ** argv) {
|
||||
|
||||
|
||||
#endif
|
||||
test_work_area_type * work_area = test_work_area_alloc( "config_path_elm" , true );
|
||||
test_work_area_type * work_area = test_work_area_alloc( "config_path_elm" );
|
||||
const char * root = test_work_area_get_cwd( work_area );
|
||||
char * abs_path = util_alloc_filename( root , "rel/path" , NULL);
|
||||
char * abs_true = util_alloc_filename( root , "rel/path/XXX" , NULL);
|
||||
char * path_true2 = util_alloc_filename( root , "rel/path/XXX" , NULL);
|
||||
|
||||
chdir( test_work_area_get_original_cwd( work_area ));
|
||||
util_chdir( test_work_area_get_original_cwd( work_area ));
|
||||
config_root_path_type * root_path = config_root_path_alloc( root );
|
||||
{
|
||||
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path );
|
||||
@ -71,7 +71,7 @@ int main(int argc , char ** argv) {
|
||||
}
|
||||
config_root_path_free( root_path );
|
||||
|
||||
chdir( root );
|
||||
util_chdir( root );
|
||||
root_path = config_root_path_alloc( NULL );
|
||||
{
|
||||
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path );
|
||||
|
@ -832,7 +832,7 @@ int main( int argc , char ** argv ) {
|
||||
char * config_path;
|
||||
util_alloc_file_components( config_arg , &config_path , NULL , NULL);
|
||||
if (config_path != NULL) {
|
||||
chdir( config_path );
|
||||
util_chdir( config_path );
|
||||
free( config_path );
|
||||
}
|
||||
} else {
|
||||
|
@ -173,6 +173,8 @@ bool ecl_util_fmt_file(const char * filename , bool * __fmt_file);
|
||||
char * ecl_util_alloc_exfilename_anyfmt(const char * path, const char * base , ecl_file_enum file_type , bool start_fmt , int report_nr);
|
||||
int ecl_util_get_month_nr(const char * month_name);
|
||||
int ecl_util_fname_report_cmp(const void *f1, const void *f2);
|
||||
time_t ecl_util_make_date(int mday , int month , int year);
|
||||
time_t ecl_util_make_date__(int mday , int month , int year, int * year_offset);
|
||||
|
||||
bool ecl_util_valid_basename( const char * basename );
|
||||
const char * ecl_util_get_phase_name( ecl_phase_enum phase );
|
||||
|
15
ThirdParty/Ert/devel/libecl/src/CMakeLists.txt
vendored
15
ThirdParty/Ert/devel/libecl/src/CMakeLists.txt
vendored
@ -13,21 +13,6 @@ set_target_properties( ecl PROPERTIES VERSION 1.0 SOVERSION 1.0 )
|
||||
if (USE_RUNPATH)
|
||||
add_runpath( ecl )
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
set( OPENMP OFF )
|
||||
option(USE_OPENMP "Include OpenMP support" OFF)
|
||||
if (USE_OPENMP)
|
||||
INCLUDE(CheckCCompilerFlag)
|
||||
CHECK_C_COMPILER_FLAG(-fopenmp OPENMP)
|
||||
endif()
|
||||
|
||||
if (OPENMP)
|
||||
add_definitions( -DHAVE_OPENMP -fopenmp )
|
||||
target_link_libraries( ecl gomp )
|
||||
else()
|
||||
add_definitions( -fno-openmp )
|
||||
endif()
|
||||
target_link_libraries( ecl ert_geometry ert_util )
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
7
ThirdParty/Ert/devel/libecl/src/ecl_grid.c
vendored
7
ThirdParty/Ert/devel/libecl/src/ecl_grid.c
vendored
@ -42,13 +42,6 @@
|
||||
#include <ert/ecl/nnc_info.h>
|
||||
#include <ert/ecl/nnc_index_list.h>
|
||||
|
||||
/*
|
||||
If openmp is enabled the main loop in ecl_grid_init_GRDECL_data is
|
||||
parallelized with openmp.
|
||||
*/
|
||||
#ifdef HAVE_OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
this function implements functionality to load eclispe grid files,
|
||||
|
@ -225,7 +225,7 @@ ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_type * rft) {
|
||||
/* Time information. */
|
||||
{
|
||||
int * time = ecl_kw_get_int_ptr( date_kw );
|
||||
rft_node->recording_date = util_make_date( time[DATE_DAY_INDEX] , time[DATE_MONTH_INDEX] , time[DATE_YEAR_INDEX] );
|
||||
rft_node->recording_date = ecl_util_make_date( time[DATE_DAY_INDEX] , time[DATE_MONTH_INDEX] , time[DATE_YEAR_INDEX] );
|
||||
}
|
||||
rft_node->days = ecl_kw_iget_float( ecl_file_iget_named_kw( rft , TIME_KW , 0 ) , 0);
|
||||
if (ecl_file_has_kw( rft , CONLENST_KW))
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
|
||||
static time_t rsthead_date( int day , int month , int year) {
|
||||
return util_make_date( day , month, year );
|
||||
return ecl_util_make_date( day , month, year );
|
||||
}
|
||||
|
||||
|
||||
|
6
ThirdParty/Ert/devel/libecl/src/ecl_smspec.c
vendored
6
ThirdParty/Ert/devel/libecl/src/ecl_smspec.c
vendored
@ -1058,9 +1058,9 @@ static void ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h
|
||||
|
||||
{
|
||||
int * date = ecl_kw_get_int_ptr(startdat);
|
||||
ecl_smspec->sim_start_time = util_make_date(date[STARTDAT_DAY_INDEX] ,
|
||||
date[STARTDAT_MONTH_INDEX] ,
|
||||
date[STARTDAT_YEAR_INDEX]);
|
||||
ecl_smspec->sim_start_time = ecl_util_make_date(date[STARTDAT_DAY_INDEX] ,
|
||||
date[STARTDAT_MONTH_INDEX] ,
|
||||
date[STARTDAT_YEAR_INDEX]);
|
||||
}
|
||||
|
||||
ecl_smspec->grid_dims[0] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NX_INDEX );
|
||||
|
36
ThirdParty/Ert/devel/libecl/src/ecl_util.c
vendored
36
ThirdParty/Ert/devel/libecl/src/ecl_util.c
vendored
@ -1235,7 +1235,7 @@ time_t ecl_util_get_start_date(const char * data_file) {
|
||||
int day, year, month_nr;
|
||||
if ( util_sscanf_int( stringlist_iget( tokens , 0 ) , &day) && util_sscanf_int( stringlist_iget(tokens , 2) , &year)) {
|
||||
month_nr = ecl_util_get_month_nr(stringlist_iget( tokens , 1));
|
||||
start_date = util_make_date(day , month_nr , year );
|
||||
start_date = ecl_util_make_date(day , month_nr , year );
|
||||
} else
|
||||
util_abort("%s: failed to parse DAY MONTH YEAR from : \"%s\" \n",__func__ , buffer);
|
||||
stringlist_free( tokens );
|
||||
@ -1364,7 +1364,7 @@ void ecl_util_append_month_range( time_t_vector_type * date_list , time_t start_
|
||||
} else
|
||||
month += 1;
|
||||
|
||||
current_date = util_make_date( 1 , month , year );
|
||||
current_date = ecl_util_make_date( 1 , month , year );
|
||||
if (current_date < end_date)
|
||||
time_t_vector_append( date_list , current_date );
|
||||
else {
|
||||
@ -1389,6 +1389,38 @@ void ecl_util_init_month_range( time_t_vector_type * date_list , time_t start_da
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
time_t ecl_util_make_date__(int mday , int month , int year, int * __year_offset) {
|
||||
time_t date;
|
||||
|
||||
#ifdef TIME_T_64BIT_ACCEPT_PRE1970
|
||||
*__year_offset = 0;
|
||||
date = util_make_date(mday , month , year);
|
||||
#else
|
||||
static bool offset_initialized = false;
|
||||
static int year_offset = 0;
|
||||
|
||||
if (!offset_initialized) {
|
||||
if (year < 1970) {
|
||||
year_offset = 2000 - year;
|
||||
fprintf(stderr,"Warning: all year values will be shifted %d years forward. \n", year_offset);
|
||||
}
|
||||
offset_initialized = true;
|
||||
}
|
||||
*__year_offset = year_offset;
|
||||
date = util_make_date(mday , month , year + year_offset);
|
||||
#endif
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
time_t ecl_util_make_date(int mday , int month , int year) {
|
||||
int year_offset;
|
||||
return ecl_util_make_date__( mday , month , year , &year_offset);
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
/* Small functions to support enum introspection. */
|
||||
|
||||
|
4
ThirdParty/Ert/devel/libecl/tests/ecl_file.c
vendored
4
ThirdParty/Ert/devel/libecl/tests/ecl_file.c
vendored
@ -104,7 +104,7 @@ void test_close_stream1(const char * src_file , const char * target_file ) {
|
||||
|
||||
|
||||
void test_writable(const char * src_file ) {
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_file_writable" , true);
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_file_writable" );
|
||||
char * fname = util_split_alloc_filename( src_file );
|
||||
|
||||
test_work_area_copy_file( work_area , src_file );
|
||||
@ -131,7 +131,7 @@ int main( int argc , char ** argv) {
|
||||
const char * target_file = argv[2];
|
||||
|
||||
{
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_file" , true);
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_file");
|
||||
|
||||
test_work_area_install_file( work_area , src_file );
|
||||
test_flags( src_file );
|
||||
|
2
ThirdParty/Ert/devel/libecl/tests/ecl_fmt.c
vendored
2
ThirdParty/Ert/devel/libecl/tests/ecl_fmt.c
vendored
@ -56,7 +56,7 @@ void test_small( ) {
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_work_area_type * work_area = test_work_area_alloc( "ecl_fmt" , true);
|
||||
test_work_area_type * work_area = test_work_area_alloc( "ecl_fmt");
|
||||
{
|
||||
const char * binary_file = argv[1];
|
||||
const char * text_file = argv[2];
|
||||
|
@ -84,7 +84,7 @@ int main( int argc , char ** argv) {
|
||||
test_wrapper( file );
|
||||
test_write( "/tmp/path/does/not/exist" , false );
|
||||
{
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" , true );
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" );
|
||||
util_make_path("path");
|
||||
test_write( "path/file.x" , true );
|
||||
test_work_area_free( work_area );
|
||||
|
@ -32,7 +32,7 @@ int main(int argc , char ** argv) {
|
||||
ecl_kw_iset_int(ecl_kw , i , i );
|
||||
|
||||
{
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_kw_grdecl" , true);
|
||||
test_work_area_type * work_area = test_work_area_alloc("ecl_kw_grdecl");
|
||||
FILE * stream = util_fopen( "FILE.grdecl" , "w");
|
||||
|
||||
ecl_kw_fprintf_grdecl(ecl_kw , stream );
|
||||
|
@ -30,5 +30,6 @@
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
ecl_grid_type * ecl_grid = ecl_grid_alloc( argv[1] );
|
||||
ecl_grid_free( ecl_grid );
|
||||
exit(0);
|
||||
}
|
||||
|
@ -38,18 +38,18 @@ int main(int argc , char ** argv) {
|
||||
nnc_info_add_nnc(nnc_info, 1, 110);
|
||||
nnc_info_add_nnc(nnc_info, 1, 111);
|
||||
|
||||
const nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1);
|
||||
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1);
|
||||
const int_vector_type * nnc_cells = nnc_info_get_index_list(nnc_info, 1);
|
||||
test_assert_int_equal(int_vector_size(nnc_cells), 2);
|
||||
test_assert_ptr_equal( nnc_cells , nnc_vector_get_index_list( nnc_vector ));
|
||||
|
||||
|
||||
const nnc_vector_type * nnc_vector_null = nnc_info_get_vector( nnc_info , 2);
|
||||
nnc_vector_type * nnc_vector_null = nnc_info_get_vector( nnc_info , 2);
|
||||
const int_vector_type * nnc_cells_null = nnc_info_get_index_list(nnc_info, 2);
|
||||
test_assert_NULL(nnc_cells_null);
|
||||
test_assert_NULL(nnc_vector_null);
|
||||
|
||||
const nnc_vector_type * nnc_vector_self = nnc_info_get_self_vector( nnc_info );
|
||||
nnc_vector_type * nnc_vector_self = nnc_info_get_self_vector( nnc_info );
|
||||
const nnc_vector_type * nnc_vector_77 = nnc_info_get_vector( nnc_info , lgr_nr );
|
||||
test_assert_ptr_equal( nnc_vector_77 , nnc_vector_self );
|
||||
|
||||
|
48
ThirdParty/Ert/devel/libecl/tests/ecl_util_make_date_no_shift.c
vendored
Normal file
48
ThirdParty/Ert/devel/libecl/tests/ecl_util_make_date_no_shift.c
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_util_make_date_no_shift.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
void test_date(int mday, int month , int year) {
|
||||
time_t t0 = ecl_util_make_date( mday , month , year );
|
||||
time_t t1 = util_make_date( mday , month , year);
|
||||
|
||||
test_assert_time_t_equal( t0 , t1 );
|
||||
}
|
||||
|
||||
void test_offset(int mday, int month , int year) {
|
||||
int year_offset;
|
||||
ecl_util_make_date__( mday , month , year , &year_offset);
|
||||
test_assert_int_equal( 0 , year_offset );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_date(10,10,2000);
|
||||
test_offset(10,10,2000);
|
||||
// test_assert_util_abort( make_date( 1 , 1 , 0);
|
||||
exit(0);
|
||||
}
|
51
ThirdParty/Ert/devel/libecl/tests/ecl_util_make_date_shift.c
vendored
Normal file
51
ThirdParty/Ert/devel/libecl/tests/ecl_util_make_date_shift.c
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
/* Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_util_make_date_shift.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
void test_date(int mday, int month , int year, int * year_offset) {
|
||||
time_t t0 = ecl_util_make_date__( mday , month , year , year_offset);
|
||||
time_t t1 = util_make_date( mday , month , year + *year_offset);
|
||||
test_assert_time_t_equal( t0 , t1 );
|
||||
}
|
||||
|
||||
|
||||
void test_offset(int mday, int month , int year , int current_offset) {
|
||||
int year_offset;
|
||||
time_t t0 = ecl_util_make_date__( mday , month , year , &year_offset);
|
||||
time_t t1 = util_make_date( mday , month , year + current_offset);
|
||||
|
||||
test_assert_time_t_equal(t0,t1);
|
||||
test_assert_int_equal( current_offset , year_offset );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
int year_offset;
|
||||
test_date(1,1,0 , &year_offset);
|
||||
test_offset(1,1,1000 , year_offset);
|
||||
exit(0);
|
||||
}
|
@ -10,6 +10,13 @@ add_executable( ecl_restart_test ecl_restart_test.c )
|
||||
target_link_libraries( ecl_restart_test ecl test_util )
|
||||
add_test( ecl_restart_test ${EXECUTABLE_OUTPUT_PATH}/ecl_restart_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
|
||||
|
||||
add_executable( ecl_util_make_date_no_shift ecl_util_make_date_no_shift.c )
|
||||
target_link_libraries( ecl_util_make_date_no_shift ecl test_util )
|
||||
add_test( ecl_util_make_date_no_shift ${EXECUTABLE_OUTPUT_PATH}/ecl_util_make_date_no_shift )
|
||||
|
||||
add_executable( ecl_util_make_date_shift ecl_util_make_date_shift.c )
|
||||
target_link_libraries( ecl_util_make_date_shift ecl test_util )
|
||||
add_test( ecl_util_make_date_shift ${EXECUTABLE_OUTPUT_PATH}/ecl_util_make_date_shift )
|
||||
|
||||
add_executable( ecl_grid_lgr_name ecl_grid_lgr_name.c )
|
||||
target_link_libraries( ecl_grid_lgr_name ecl test_util )
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <ert/util/bool_vector.h>
|
||||
#include <ert/util/msg.h>
|
||||
#include <ert/util/vector.h>
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/type_vector_functions.h>
|
||||
|
||||
#include <ert/plot/plot.h>
|
||||
@ -52,6 +53,8 @@
|
||||
#include <ert/enkf/plot_config.h>
|
||||
#include <ert/enkf/member_config.h>
|
||||
#include <ert/enkf/enkf_analysis.h>
|
||||
#include <ert/enkf/obs_tstep_list.h>
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
|
||||
#include <enkf_tui_util.h>
|
||||
#include <enkf_tui_plot.h>
|
||||
@ -60,100 +63,78 @@
|
||||
#include <enkf_tui_plot_util.h>
|
||||
|
||||
|
||||
void enkf_tui_QC_plot_get_PC( enkf_main_type * enkf_main , int step1 , int step2 , state_enum state , const local_obsset_type * obsset ,
|
||||
double truncation , int ncomp ,
|
||||
matrix_type * PC , matrix_type * PC_obs) {
|
||||
|
||||
bool_vector_type * ens_mask = bool_vector_alloc(0 , false);
|
||||
obs_data_type * obs_data = obs_data_alloc();
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
int_vector_type * step_list = int_vector_alloc(0,0);
|
||||
enkf_fs_type * source_fs = enkf_main_get_fs( enkf_main);
|
||||
state_map_type * state_map = enkf_fs_get_state_map(source_fs);
|
||||
int_vector_type * ens_active_list;
|
||||
meas_data_type * meas_data;
|
||||
|
||||
state_map_select_matching(state_map , ens_mask , STATE_HAS_DATA);
|
||||
ens_active_list = bool_vector_alloc_active_list(ens_mask);
|
||||
meas_data = meas_data_alloc(ens_active_list);
|
||||
{
|
||||
for (int step =step1; step <= step2; step++)
|
||||
int_vector_append( step_list , step );
|
||||
}
|
||||
|
||||
obs_data_reset( obs_data );
|
||||
meas_data_reset( meas_data );
|
||||
void enkf_tui_QC_plot_PC_list( void * arg ) {
|
||||
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
|
||||
stringlist_type * all_obs_keys = enkf_obs_alloc_keylist( enkf_main_get_obs( enkf_main ));
|
||||
stringlist_type * obs_keys = stringlist_alloc_new();
|
||||
|
||||
{
|
||||
double std_cutoff = analysis_config_get_std_cutoff( analysis_config );
|
||||
double alpha = analysis_config_get_alpha( analysis_config );
|
||||
|
||||
enkf_obs_get_obs_and_measure(enkf_main_get_obs( enkf_main ),
|
||||
source_fs ,
|
||||
step_list ,
|
||||
state,
|
||||
ens_active_list ,
|
||||
(const enkf_state_type **) enkf_main_get_ensemble( enkf_main ),
|
||||
meas_data ,
|
||||
obs_data ,
|
||||
obsset );
|
||||
|
||||
enkf_analysis_deactivate_outliers( obs_data , meas_data , std_cutoff , alpha);
|
||||
char * keys_input;
|
||||
util_printf_prompt("Observation keys (wildcards allowed) - [default: all]", PROMPT_LEN, '=', "=> ");
|
||||
keys_input = util_alloc_stdin_line();
|
||||
if (keys_input)
|
||||
{
|
||||
stringlist_type * pattern_list = stringlist_alloc_from_split(keys_input, " ,");
|
||||
for (int i = 0; i < stringlist_get_size(pattern_list); i++)
|
||||
{
|
||||
const char * pattern = stringlist_iget(pattern_list, i);
|
||||
stringlist_append_matching_elements(obs_keys, all_obs_keys, pattern);
|
||||
}
|
||||
free(keys_input);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (stringlist_get_size(obs_keys) > 0)
|
||||
{
|
||||
int active_size = obs_data_get_active_size( obs_data );
|
||||
matrix_type * S = meas_data_allocS( meas_data , active_size );
|
||||
matrix_type * dObs = obs_data_allocdObs( obs_data , active_size );
|
||||
const int last_report = enkf_main_get_history_length(enkf_main);
|
||||
vector_type * PC_list = vector_alloc_new();
|
||||
const int ncomp = 1;
|
||||
|
||||
obs_data_scale( obs_data , S , NULL , NULL , NULL , dObs );
|
||||
enkf_main_get_PC( enkf_main , S , dObs , local_obsset_get_name( obsset ) , step1 , step2 , truncation , ncomp , PC , PC_obs );
|
||||
|
||||
matrix_free( S );
|
||||
matrix_free( dObs );
|
||||
}
|
||||
for (int iobs = 0; iobs < stringlist_get_size(obs_keys); iobs++)
|
||||
{
|
||||
local_obsdata_node_type * obsnode = local_obsdata_node_alloc(stringlist_iget(obs_keys, iobs));
|
||||
local_obsdata_type * obsdata = local_obsdata_alloc_wrapper(obsnode);
|
||||
local_obsdata_node_add_range(obsnode, 0, last_report);
|
||||
{
|
||||
pca_plot_data_type * plot_data = enkf_main_alloc_pca_plot_data(enkf_main, obsdata, ncomp);
|
||||
vector_append_owned_ref(PC_list, plot_data, pca_plot_data_free__);
|
||||
}
|
||||
local_obsdata_free(obsdata);
|
||||
}
|
||||
enkf_tui_plot_PC_list(enkf_main , PC_list);
|
||||
vector_free(PC_list);
|
||||
} else
|
||||
printf("Sorry: no observation keys mathced the pattern(s).\n");
|
||||
|
||||
bool_vector_free(ens_mask);
|
||||
int_vector_free( step_list );
|
||||
obs_data_free( obs_data );
|
||||
meas_data_free( meas_data );
|
||||
stringlist_free( obs_keys );
|
||||
stringlist_free( all_obs_keys );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void enkf_tui_QC_plot_PC( void * arg ) {
|
||||
enkf_main_type * enkf_main = enkf_main_safe_cast( arg );
|
||||
local_config_type * local_config = enkf_main_get_local_config( enkf_main );
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
const int last_report = enkf_main_get_history_length( enkf_main );
|
||||
int step1,step2;
|
||||
int ncomp;
|
||||
double truncation;
|
||||
double truncation_or_ncomp;
|
||||
local_obsdata_type * obsdata = local_obsdata_alloc("PCA Observations");
|
||||
char * keys_input;
|
||||
|
||||
state_enum state = FORECAST;
|
||||
const local_updatestep_type * update_step;
|
||||
local_obsset_type * obsset;
|
||||
|
||||
|
||||
enkf_tui_util_scanf_report_steps(last_report , PROMPT_LEN , &step1 , &step2);
|
||||
util_printf_prompt("Observation keys (wildcards allowed) - [default: all]" , PROMPT_LEN , '=' , "=> ");
|
||||
keys_input = util_alloc_stdin_line();
|
||||
|
||||
util_printf_prompt("Truncation: [0,1): Explained variance [1,ens_size): fixed" , PROMPT_LEN , '=' , "=> ");
|
||||
|
||||
{
|
||||
char * input = util_alloc_stdin_line();
|
||||
|
||||
if (input == NULL)
|
||||
return;
|
||||
else {
|
||||
double truncation_or_ncomp;
|
||||
if (util_sscanf_double( input , &truncation_or_ncomp)) {
|
||||
if (truncation_or_ncomp < 1) {
|
||||
truncation = truncation_or_ncomp;
|
||||
ncomp = -1;
|
||||
} else {
|
||||
truncation = -1;
|
||||
ncomp = util_int_min( (int) truncation_or_ncomp , ens_size );
|
||||
}
|
||||
} else {
|
||||
if (!util_sscanf_double( input , &truncation_or_ncomp)) {
|
||||
fprintf(stderr , "Failed to parse:%s as number \n",input);
|
||||
free( input );
|
||||
return;
|
||||
@ -163,41 +144,57 @@ void enkf_tui_QC_plot_PC( void * arg ) {
|
||||
free( input );
|
||||
}
|
||||
|
||||
update_step = local_config_iget_updatestep( local_config , step2 );
|
||||
{
|
||||
int obsset_nr = 0;
|
||||
if (local_updatestep_get_num_ministep( update_step) > 1) {
|
||||
stringlist_type * obsset_list = stringlist_alloc_new();
|
||||
for (int i =0; i < local_updatestep_get_num_ministep( update_step ); i++) {
|
||||
local_obsset_type * obsset = local_updatestep_iget_obsset( update_step , i );
|
||||
stringlist_append_ref( obsset_list , local_obsset_get_name( obsset ));
|
||||
|
||||
printf(" %02d : %s \n", i +1 , local_obsset_get_name( obsset ));
|
||||
}
|
||||
stringlist_free( obsset_list );
|
||||
stringlist_type * all_keys = enkf_obs_alloc_keylist( enkf_main_get_obs( enkf_main ));
|
||||
stringlist_type * obs_keys = stringlist_alloc_new();
|
||||
|
||||
obsset_nr = util_scanf_int( "Choose observation set" , PROMPT_LEN );
|
||||
obsset_nr--;
|
||||
}
|
||||
if ((obsset_nr < 0) || (obsset_nr >= local_updatestep_get_num_ministep( update_step)))
|
||||
return;
|
||||
|
||||
obsset = local_updatestep_iget_obsset( update_step , obsset_nr );
|
||||
}
|
||||
|
||||
{
|
||||
if (keys_input) {
|
||||
stringlist_type * input_keys = stringlist_alloc_from_split( keys_input , " ");
|
||||
int i;
|
||||
for (i=0; i < stringlist_get_size( input_keys ); i++)
|
||||
stringlist_append_matching_elements( obs_keys , all_keys , stringlist_iget( input_keys , i ));
|
||||
stringlist_free( input_keys );
|
||||
} else
|
||||
stringlist_deep_copy( obs_keys , all_keys );
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
int iobs;
|
||||
|
||||
for (iobs = 0; iobs < stringlist_get_size( obs_keys); iobs++) {
|
||||
const char * obs_key = stringlist_iget( obs_keys , iobs );
|
||||
if (!local_obsdata_has_node( obsdata , obs_key )) {
|
||||
local_obsdata_node_type * obs_node = local_obsdata_node_alloc( obs_key );
|
||||
|
||||
local_obsdata_node_add_range( obs_node , step1 , step2 );
|
||||
local_obsdata_add_node( obsdata , obs_node );
|
||||
}
|
||||
}
|
||||
|
||||
stringlist_free( all_keys );
|
||||
stringlist_free( obs_keys );
|
||||
}
|
||||
}
|
||||
|
||||
if (local_obsdata_get_size( obsdata )) {
|
||||
matrix_type * PC = matrix_alloc(1,1);
|
||||
matrix_type * PC_obs = matrix_alloc(1,1);
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
char * plot_name = util_alloc_sprintf(analysis_config_get_PC_filename( analysis_config ) ,
|
||||
step1 , step2 , local_obsset_get_name( obsset ));
|
||||
step1 , step2 , "obs");
|
||||
|
||||
pca_plot_data_type * plot_data = enkf_main_alloc_pca_plot_data( enkf_main , obsdata , truncation_or_ncomp);
|
||||
|
||||
enkf_tui_QC_plot_get_PC( enkf_main , step1 , step2 , state , obsset , truncation , ncomp , PC , PC_obs );
|
||||
enkf_tui_plot_PC( enkf_main , plot_name , PC , PC_obs );
|
||||
enkf_tui_plot_PC( enkf_main , plot_name , plot_data );
|
||||
|
||||
free( plot_name );
|
||||
matrix_free( PC );
|
||||
matrix_free( PC_obs );
|
||||
pca_plot_data_free( plot_data );
|
||||
}
|
||||
local_obsdata_free( obsdata );
|
||||
}
|
||||
|
||||
|
||||
@ -221,11 +218,18 @@ void enkf_tui_QC_menu(void * arg) {
|
||||
|
||||
{
|
||||
menu_type * menu = menu_alloc("Quality check of prior" , "Back" , "bB");
|
||||
menu_item_type * plot_PC_item = menu_add_item( menu , "Plot of prior principal components" , "pP" , enkf_tui_QC_plot_PC , enkf_main , NULL);
|
||||
menu_item_type * plot_PC_item = menu_add_item( menu , "Plot of prior principal components" , "pP" ,
|
||||
enkf_tui_QC_plot_PC , enkf_main , NULL);
|
||||
|
||||
menu_item_type * plot_PC_list_item = menu_add_item( menu , "Plot first principal component for all observations" , "aA" ,
|
||||
enkf_tui_QC_plot_PC_list, enkf_main , NULL);
|
||||
|
||||
menu_item_type * run_QC_workflow_item = menu_add_item( menu , "Run QC workflow" , "rR" , enkf_tui_QC_run_workflow , enkf_main , NULL);
|
||||
|
||||
if (!enkf_main_have_obs( enkf_main ))
|
||||
if (!enkf_main_have_obs( enkf_main )) {
|
||||
menu_item_disable( plot_PC_item );
|
||||
menu_item_disable( plot_PC_list_item );
|
||||
}
|
||||
|
||||
if (!enkf_main_has_QC_workflow( enkf_main ))
|
||||
menu_item_disable( run_QC_workflow_item );
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include <ert/enkf/time_map.h>
|
||||
#include <ert/enkf/ert_report_list.h>
|
||||
#include <ert/enkf/ecl_refcase_list.h>
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
|
||||
#include <ert_tui_const.h>
|
||||
#include <enkf_tui_util.h>
|
||||
@ -88,32 +89,84 @@ static void __plot_add_data(plot_type * plot , const char * label , int N , cons
|
||||
|
||||
|
||||
|
||||
void enkf_tui_plot_PC( enkf_main_type * enkf_main , const char * plot_name , const matrix_type * PC , const matrix_type * PC_obs) {
|
||||
|
||||
|
||||
void enkf_tui_plot_PC_list( enkf_main_type * enkf_main , const vector_type * PC_list ) {
|
||||
plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main );
|
||||
char * plot_file = enkf_tui_plot_alloc_plot_file( plot_config , enkf_main_get_current_fs( enkf_main ), "PC_list" );
|
||||
plot_type * plot = enkf_tui_plot_alloc(plot_config ,
|
||||
"Standardized PC value " ,
|
||||
"Observation #",
|
||||
"Principle components" ,
|
||||
plot_file);
|
||||
|
||||
int num_obs = vector_get_size( PC_list );
|
||||
int iobs;
|
||||
for (iobs = 0; iobs < num_obs; iobs++) {
|
||||
const pca_plot_data_type * pca_data = vector_iget_const( PC_list , iobs );
|
||||
const pca_plot_vector_type * pca_vector = pca_plot_data_iget_vector( pca_data , 0 );
|
||||
int ens_size = pca_plot_vector_get_size( pca_vector );
|
||||
{
|
||||
char * data_label = util_alloc_sprintf("%s - simulated" , pca_plot_data_get_name( pca_data ));
|
||||
plot_dataset_type * sim_data = plot_alloc_new_dataset( plot , data_label , PLOT_XY );
|
||||
plot_dataset_set_style( sim_data , POINTS );
|
||||
plot_dataset_set_point_color( sim_data , BLUE);
|
||||
for (int iens = 0; iens < ens_size; iens++)
|
||||
plot_dataset_append_point_xy( sim_data ,
|
||||
pca_plot_vector_iget_sim_value( pca_vector , iens ),
|
||||
iobs );
|
||||
free( data_label );
|
||||
}
|
||||
{
|
||||
char * obs_label = util_alloc_sprintf("%s - obs" , pca_plot_data_get_name( pca_data ));
|
||||
plot_dataset_type * obs_data = plot_alloc_new_dataset( plot , obs_label , PLOT_XY );
|
||||
plot_dataset_set_style( obs_data , POINTS );
|
||||
plot_dataset_set_point_color( obs_data , RED);
|
||||
plot_dataset_append_point_xy( obs_data , pca_plot_vector_get_obs_value( pca_vector ) , iobs );
|
||||
free( obs_label );
|
||||
}
|
||||
// POsition of text is not considered when the autorange is applied; i.e. with
|
||||
// fixed coordinates it might fall outside the clipping region ...
|
||||
plot_add_text( plot , -0.75 , iobs , 0.35 , pca_plot_data_get_name( pca_data ));
|
||||
}
|
||||
enkf_tui_show_plot( plot , plot_config , plot_file ); /* Frees the plot - logical ehhh. */
|
||||
free( plot_file );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void enkf_tui_plot_PC( enkf_main_type * enkf_main , const char * plot_name , const pca_plot_data_type * plot_data) {
|
||||
plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main );
|
||||
char * plot_file = enkf_tui_plot_alloc_plot_file( plot_config , enkf_main_get_current_fs( enkf_main ), plot_name );
|
||||
plot_type * plot = enkf_tui_plot_alloc(plot_config , "PC number", /* y akse */ "Standardized PC value " , "Principle components" , plot_file);
|
||||
|
||||
|
||||
{
|
||||
const int num_PC = matrix_get_rows( PC );
|
||||
const int ens_size = matrix_get_columns( PC );
|
||||
const int num_PC = pca_plot_data_get_size( plot_data );
|
||||
const int ens_size = pca_plot_data_get_ens_size( plot_data );
|
||||
int ipc, iens;
|
||||
|
||||
{
|
||||
plot_dataset_type * sim_data = plot_alloc_new_dataset( plot , "simulated" , PLOT_XY );
|
||||
plot_dataset_set_style( sim_data , POINTS );
|
||||
plot_dataset_set_point_color( sim_data , BLUE);
|
||||
for (ipc = 0; ipc < num_PC; ipc++)
|
||||
for (ipc = 0; ipc < num_PC; ipc++) {
|
||||
const pca_plot_vector_type * pca_vector = pca_plot_data_iget_vector( plot_data , ipc );
|
||||
for (iens =0; iens < ens_size; iens++)
|
||||
plot_dataset_append_point_xy( sim_data , (ipc + 1) , matrix_iget( PC , ipc , iens ));
|
||||
plot_dataset_append_point_xy( sim_data ,
|
||||
(ipc + 1) ,
|
||||
pca_plot_vector_iget_sim_value( pca_vector , iens ));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
plot_dataset_type * obs_data = plot_alloc_new_dataset( plot , "observation" , PLOT_XY );
|
||||
plot_dataset_set_style( obs_data , POINTS );
|
||||
plot_dataset_set_point_color( obs_data , RED);
|
||||
for (ipc = 0; ipc < num_PC; ipc++)
|
||||
plot_dataset_append_point_xy( obs_data , (ipc + 1) , matrix_iget( PC_obs , ipc , 0 ));
|
||||
for (ipc = 0; ipc < num_PC; ipc++) {
|
||||
const pca_plot_vector_type * pca_vector = pca_plot_data_iget_vector( plot_data , ipc );
|
||||
plot_dataset_append_point_xy( obs_data , (ipc + 1) , pca_plot_vector_get_obs_value( pca_vector ));
|
||||
}
|
||||
}
|
||||
}
|
||||
enkf_tui_show_plot( plot , plot_config , plot_file ); /* Frees the plot - logical ehhh. */
|
||||
|
@ -21,12 +21,15 @@
|
||||
|
||||
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/vector.h>
|
||||
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
|
||||
void enkf_tui_plot_simple_menu(void * );
|
||||
void enkf_tui_plot_menu(void * );
|
||||
void enkf_tui_plot_PC( enkf_main_type * enkf_main , const char * plot_name , const matrix_type * PC , const matrix_type * PC_obs);
|
||||
void enkf_tui_plot_PC( enkf_main_type * enkf_main , const char * plot_name , const pca_plot_data_type * plot_data);
|
||||
void enkf_tui_plot_PC_list( enkf_main_type * enkf_main , const vector_type * PC_list );
|
||||
void enkf_tui_plot_reports(void *);
|
||||
void enkf_tui_plot_all_summary__( enkf_main_type * enkf_main , int iens1 , int iens2 , int step1 , int step2 , bool prediction_mode);
|
||||
|
||||
|
@ -318,12 +318,13 @@ void enkf_tui_run_menu(void * arg) {
|
||||
{
|
||||
const ecl_config_type * ecl_config = enkf_main_get_ecl_config( enkf_main );
|
||||
const model_config_type * model_config = enkf_main_get_model_config( enkf_main );
|
||||
const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
|
||||
|
||||
menu_item_type * enkf_item = menu_add_item(menu , "Start EnKF run from beginning" , "sS" , enkf_tui_run_start , enkf_main , NULL);
|
||||
menu_item_type * restart_enkf_item = menu_add_item(menu , "Restart EnKF run from arbitrary state" , "rR" , enkf_tui_run_restart__ , enkf_main , NULL);
|
||||
menu_item_type * ES_item = menu_add_item(menu , "Integrated smoother update" , "iI" , enkf_tui_run_smoother , enkf_main , NULL);
|
||||
menu_item_type * it_ES_item = menu_add_item(menu , "Iterated smoother [RML-EnKF]" , "tT" , enkf_tui_run_iterated_ES , enkf_main , NULL);
|
||||
menu_item_type * one_more_item = menu_add_item(menu , "One more iteration" , "mM" , enkf_tui_run_one_more_iteration , enkf_main , NULL);
|
||||
menu_item_type * one_more_item = menu_add_item(menu , "One more iteration (disabled)" , "mM" , enkf_tui_run_one_more_iteration , enkf_main , NULL);
|
||||
|
||||
if (!ecl_config_has_schedule( ecl_config )) {
|
||||
menu_item_disable( enkf_item );
|
||||
@ -333,9 +334,20 @@ void enkf_tui_run_menu(void * arg) {
|
||||
if (!ecl_config_has_init_section( ecl_config ))
|
||||
menu_item_disable( enkf_item );
|
||||
|
||||
menu_item_disable( one_more_item );
|
||||
if (!analysis_config_get_module_option(analysis_config , ANALYSIS_ITERABLE)) {
|
||||
menu_item_disable( it_ES_item );
|
||||
menu_item_disable( one_more_item );
|
||||
} else {
|
||||
menu_item_disable( enkf_item );
|
||||
menu_item_disable( restart_enkf_item );
|
||||
menu_item_disable( ES_item );
|
||||
}
|
||||
|
||||
if (!model_config_has_history( model_config )) {
|
||||
menu_item_disable( it_ES_item );
|
||||
menu_item_disable( ES_item );
|
||||
menu_item_disable( one_more_item );
|
||||
}
|
||||
}
|
||||
menu_add_separator(menu);
|
||||
@ -367,5 +379,4 @@ void enkf_tui_run_menu(void * arg) {
|
||||
menu_add_item(menu , "Help" , "hH" , enkf_tui_help_menu_run , enkf_main , NULL);
|
||||
menu_run(menu);
|
||||
menu_free(menu);
|
||||
|
||||
}
|
||||
|
@ -22,25 +22,31 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/enkf/enkf_types.h>
|
||||
|
||||
|
||||
typedef struct active_list_struct active_list_type;
|
||||
|
||||
active_list_type * active_list_alloc( active_mode_type mode );
|
||||
void active_list_reset(active_list_type * );
|
||||
void active_list_add_index(active_list_type * , int);
|
||||
void active_list_free( active_list_type *);
|
||||
const int * active_list_get_active(const active_list_type * );
|
||||
int active_list_get_active_size(const active_list_type * , int total_size );
|
||||
void active_list_set_all_active(active_list_type * );
|
||||
void active_list_set_data_size(active_list_type * , int );
|
||||
void active_list_free( active_list_type * );
|
||||
active_mode_type active_list_get_mode(const active_list_type * );
|
||||
void active_list_free__( void * arg );
|
||||
active_list_type * active_list_alloc_copy( const active_list_type * src);
|
||||
void active_list_fprintf( const active_list_type * active_list , bool obs , const char * key , FILE * stream );
|
||||
bool active_list_iget( const active_list_type * active_list , int index );
|
||||
active_list_type * active_list_alloc( );
|
||||
void active_list_reset(active_list_type * );
|
||||
void active_list_add_index(active_list_type * , int);
|
||||
void active_list_free( active_list_type *);
|
||||
const int * active_list_get_active(const active_list_type * );
|
||||
int active_list_get_active_size(const active_list_type * , int total_size );
|
||||
void active_list_set_all_active(active_list_type * );
|
||||
void active_list_set_data_size(active_list_type * , int );
|
||||
void active_list_free( active_list_type * );
|
||||
active_mode_type active_list_get_mode(const active_list_type * );
|
||||
void active_list_free__( void * arg );
|
||||
active_list_type * active_list_alloc_copy( const active_list_type * src);
|
||||
void active_list_fprintf( const active_list_type * active_list , bool obs , const char * key , FILE * stream );
|
||||
bool active_list_iget( const active_list_type * active_list , int index );
|
||||
bool active_list_equal( const active_list_type * active_list1 , const active_list_type * active_list2);
|
||||
void active_list_copy( active_list_type * target , const active_list_type * src);
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( active_list );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -43,8 +43,11 @@ typedef struct analysis_config_struct analysis_config_type;
|
||||
|
||||
analysis_iter_config_type * analysis_config_get_iter_config( const analysis_config_type * config );
|
||||
analysis_module_type * analysis_config_get_module( analysis_config_type * config , const char * module_name );
|
||||
void analysis_config_load_internal_module( analysis_config_type * config , const char * user_name , const char * symbol_table );
|
||||
void analysis_config_load_internal_modules( analysis_config_type * analysis );
|
||||
void analysis_config_reload_module( analysis_config_type * config , const char * module_name);
|
||||
bool analysis_config_get_module_option( const analysis_config_type * config , long flag);
|
||||
bool analysis_config_load_external_module( analysis_config_type * config , const char * user_name , const char * lib_name);
|
||||
|
||||
stringlist_type * analysis_config_alloc_module_names( analysis_config_type * config );
|
||||
const char * analysis_config_get_log_path( const analysis_config_type * config );
|
||||
@ -96,10 +99,14 @@ void analysis_config_set_PC_filename( analysis_config_type * c
|
||||
const char * analysis_config_get_PC_filename( const analysis_config_type * config );
|
||||
void analysis_config_set_PC_path( analysis_config_type * config , const char * path );
|
||||
const char * analysis_config_get_PC_path( const analysis_config_type * config );
|
||||
void analysis_config_set_min_realisations( analysis_config_type * config , int min_realisations);
|
||||
int analysis_config_get_min_realisations( const analysis_config_type * config );
|
||||
bool analysis_config_have_enough_realisations( const analysis_config_type * config , int realisations);
|
||||
|
||||
void analysis_config_set_min_realisations( analysis_config_type * config , int min_realisations);
|
||||
int analysis_config_get_min_realisations( const analysis_config_type * config );
|
||||
bool analysis_config_have_enough_realisations( const analysis_config_type * config , int realisations);
|
||||
void analysis_config_set_stop_long_running( analysis_config_type * config, bool stop_long_running );
|
||||
bool analysis_config_get_stop_long_running( const analysis_config_type * config);
|
||||
void analysis_config_set_max_runtime( analysis_config_type * config, int max_runtime );
|
||||
int analysis_config_get_max_runtime( const analysis_config_type * config );
|
||||
const char * analysis_config_get_active_module_name( const analysis_config_type * config );
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( analysis_config );
|
||||
|
||||
|
@ -36,7 +36,9 @@ typedef struct analysis_iter_config_struct analysis_iter_config_type;
|
||||
const char * analysis_iter_config_iget_runpath_fmt( analysis_iter_config_type * config , int iter);
|
||||
void analysis_iter_config_add_config_items( config_type * config );
|
||||
void analysis_iter_config_init(analysis_iter_config_type * iter_config , const config_type * config);
|
||||
|
||||
void analysis_iter_config_set_runpath_fmt( analysis_iter_config_type * config , const char * runpath_fmt);
|
||||
char * analysis_iter_config_get_runpath_fmt( analysis_iter_config_type * config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -168,6 +168,8 @@ extern "C" {
|
||||
#define WORKFLOW_JOB_DIRECTORY_KEY "WORKFLOW_JOB_DIRECTORY"
|
||||
#define LOAD_WORKFLOW_KEY "LOAD_WORKFLOW"
|
||||
#define LOAD_WORKFLOW_JOB_KEY "LOAD_WORKFLOW_JOB"
|
||||
#define STOP_LONG_RUNNING_KEY "STOP_LONG_RUNNING"
|
||||
#define MAX_RUNTIME_KEY "MAX_RUNTIME"
|
||||
|
||||
#define CONFIG_BOOL_STRING( var ) (var) ? "TRUE" : "FALSE"
|
||||
|
||||
|
@ -95,31 +95,34 @@
|
||||
Defaults for the EnKF analysis. The analysis_config object is
|
||||
instantiated with these values.
|
||||
*/
|
||||
#define DEFAULT_ENKF_MODE ENKF_STANDARD
|
||||
#define DEFAULT_NCOMP 1
|
||||
#define DEFAULT_ENKF_TRUNCATION 0.99
|
||||
#define DEFAULT_ENKF_ALPHA 1.50 /* Should be raised ?? */
|
||||
#define DEFAULT_ENKF_STD_CUTOFF 1e-6
|
||||
#define DEFAULT_MERGE_OBSERVATIONS false
|
||||
#define DEFAULT_RERUN false
|
||||
#define DEFAULT_RERUN_START 0
|
||||
#define DEFAULT_UPDATE_LOG_PATH "update_log"
|
||||
#define DEFAULT_CV_NFOLDS 10
|
||||
#define DEFAULT_ENKF_SCALING true
|
||||
#define DEFAULT_ENKF_KERNEL_REG false
|
||||
#define DEFAULT_ENKF_KERNEL_FUNC 1 /*Default is the Gaussian */
|
||||
#define DEFAULT_ENKF_KERNEL_PARAM 1 /*Scale by the maximum value in the distance matrix */
|
||||
#define DEFAULT_ENKF_CV false
|
||||
#define DEFAULT_ENKF_BOOTSTRAP false
|
||||
#define DEFAULT_ENKF_PEN_PRESS false
|
||||
#define DEFAULT_ENKF_FORCE_NCOMP false
|
||||
#define DEFAULT_UPDATE_RESULTS false
|
||||
#define DEFAULT_SINGLE_NODE_UPDATE true
|
||||
#define DEFAULT_ANALYSIS_MODULE "STD_ENKF"
|
||||
#define DEFAULT_ANALYSIS_NUM_ITERATIONS 4
|
||||
#define DEFAULT_ANALYSIS_ITER_CASE "ITERATED_ENSEMBLE_SMOOTHER%d"
|
||||
#define DEFAULT_ANALYSIS_ITER_RUNPATH "Simulations/Real%d"
|
||||
#define DEFAULT_ANALYSIS_MIN_REALISATIONS 0 // 0: No lower limit
|
||||
#define DEFAULT_ENKF_MODE ENKF_STANDARD
|
||||
#define DEFAULT_NCOMP 1
|
||||
#define DEFAULT_ENKF_TRUNCATION 0.99
|
||||
#define DEFAULT_ENKF_ALPHA 1.50 /* Should be raised ?? */
|
||||
#define DEFAULT_ENKF_STD_CUTOFF 1e-6
|
||||
#define DEFAULT_MERGE_OBSERVATIONS false
|
||||
#define DEFAULT_RERUN false
|
||||
#define DEFAULT_RERUN_START 0
|
||||
#define DEFAULT_UPDATE_LOG_PATH "update_log"
|
||||
#define DEFAULT_CV_NFOLDS 10
|
||||
#define DEFAULT_ENKF_SCALING true
|
||||
#define DEFAULT_ENKF_KERNEL_REG false
|
||||
#define DEFAULT_ENKF_KERNEL_FUNC 1 /*Default is the Gaussian */
|
||||
#define DEFAULT_ENKF_KERNEL_PARAM 1 /*Scale by the maximum value in the distance matrix */
|
||||
#define DEFAULT_ENKF_CV false
|
||||
#define DEFAULT_ENKF_BOOTSTRAP false
|
||||
#define DEFAULT_ENKF_PEN_PRESS false
|
||||
#define DEFAULT_ENKF_FORCE_NCOMP false
|
||||
#define DEFAULT_UPDATE_RESULTS false
|
||||
#define DEFAULT_SINGLE_NODE_UPDATE false
|
||||
#define DEFAULT_ANALYSIS_MODULE "STD_ENKF"
|
||||
#define DEFAULT_ANALYSIS_NUM_ITERATIONS 4
|
||||
#define DEFAULT_ANALYSIS_ITER_CASE "ITERATED_ENSEMBLE_SMOOTHER%d"
|
||||
#define DEFAULT_ANALYSIS_ITER_RUNPATH "Simulations/Real%d"
|
||||
#define DEFAULT_ANALYSIS_MIN_REALISATIONS 0 // 0: No lower limit
|
||||
#define DEFAULT_ANALYSIS_STOP_LONG_RUNNING false
|
||||
#define DEFAULT_MAX_RUNTIME 0
|
||||
|
||||
|
||||
/* Default directories. */
|
||||
#define DEFAULT_QC_PATH "QC"
|
||||
|
@ -58,12 +58,13 @@ extern "C" {
|
||||
#include <ert/enkf/ranking_table.h>
|
||||
#include <ert/enkf/qc_module.h>
|
||||
#include <ert/enkf/rng_config.h>
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
typedef struct enkf_main_struct enkf_main_type;
|
||||
void enkf_main_close_alt_fs(enkf_main_type * enkf_main , enkf_fs_type * fs);
|
||||
enkf_fs_type * enkf_main_get_alt_fs(enkf_main_type * enkf_main , const char * case_path , bool read_only , bool create);
|
||||
void enkf_main_close_alt_fs(const enkf_main_type * enkf_main , enkf_fs_type * fs);
|
||||
enkf_fs_type * enkf_main_get_alt_fs(const enkf_main_type * enkf_main , const char * case_path , bool read_only , bool create);
|
||||
stringlist_type * enkf_main_alloc_caselist( const enkf_main_type * enkf_main );
|
||||
void enkf_main_set_fs( enkf_main_type * enkf_main , enkf_fs_type * fs , const char * case_path );
|
||||
char * enkf_main_alloc_mount_point( const enkf_main_type * enkf_main , const char * case_path);
|
||||
@ -144,6 +145,7 @@ extern "C" {
|
||||
ert_impl_type enkf_main_impl_type(const enkf_main_type *, const char * );
|
||||
enkf_state_type * enkf_main_iget_state(const enkf_main_type * , int );
|
||||
enkf_state_type ** enkf_main_get_ensemble( enkf_main_type * enkf_main);
|
||||
const enkf_state_type ** enkf_main_get_ensemble_const( const enkf_main_type * enkf_main);
|
||||
|
||||
const enkf_config_node_type * enkf_main_get_config_node(const enkf_main_type * , const char *);
|
||||
const sched_file_type * enkf_main_get_sched_file(const enkf_main_type *);
|
||||
@ -200,6 +202,11 @@ extern "C" {
|
||||
const stringlist_type * node_list);
|
||||
|
||||
|
||||
pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_main ,
|
||||
local_obsdata_type * obs_data,
|
||||
double truncation_or_ncomp);
|
||||
|
||||
|
||||
void enkf_main_set_case_table( enkf_main_type * enkf_main , const char * case_table_file );
|
||||
void enkf_main_list_users( set_type * users , const char * executable );
|
||||
const ext_joblist_type * enkf_main_get_installed_jobs( const enkf_main_type * enkf_main );
|
||||
@ -218,6 +225,7 @@ extern "C" {
|
||||
void enkf_main_install_SIGNALS(void);
|
||||
const char * enkf_main_get_SVN_VERSION( void );
|
||||
const char * enkf_main_get_COMPILE_TIME( void );
|
||||
bool enkf_main_case_is_initialized( const enkf_main_type * enkf_main , const char * case_name , bool_vector_type * __mask);
|
||||
bool enkf_main_is_initialized( const enkf_main_type * enkf_main ,bool_vector_type * __mask);
|
||||
void enkf_main_del_node(enkf_main_type * enkf_main , const char * key);
|
||||
void enkf_main_update_node( enkf_main_type * enkf_main , const char * key );
|
||||
@ -227,16 +235,23 @@ extern "C" {
|
||||
qc_module_type * enkf_main_get_qc_module( const enkf_main_type * enkf_main );
|
||||
bool enkf_main_has_QC_workflow( const enkf_main_type * enkf_main );
|
||||
|
||||
void enkf_main_get_PC( const enkf_main_type * enkf_main ,
|
||||
const matrix_type * S,
|
||||
void enkf_main_get_PC( const matrix_type * S,
|
||||
const matrix_type * dObs,
|
||||
const char * obsset_name ,
|
||||
int step1 , int step2 ,
|
||||
double truncation ,
|
||||
int ncomp ,
|
||||
matrix_type * PC ,
|
||||
matrix_type * PC_obs);
|
||||
|
||||
void enkf_main_init_PC( const enkf_main_type * enkf_main ,
|
||||
const local_obsdata_type * obsdata ,
|
||||
double truncation_or_ncomp ,
|
||||
matrix_type * PC ,
|
||||
matrix_type * PC_obs );
|
||||
|
||||
void enkf_main_fprintf_PC(const char * filename ,
|
||||
matrix_type * PC ,
|
||||
matrix_type * PC_obs);
|
||||
|
||||
|
||||
void enkf_main_set_verbose( enkf_main_type * enkf_main , bool verbose);
|
||||
bool enkf_main_get_verbose( const enkf_main_type * enkf_main );
|
||||
@ -251,6 +266,7 @@ extern "C" {
|
||||
void enkf_main_rng_init( enkf_main_type * enkf_main);
|
||||
|
||||
UTIL_SAFE_CAST_HEADER(enkf_main);
|
||||
UTIL_IS_INSTANCE_HEADER(enkf_main);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ extern "C" {
|
||||
#include <ert/enkf/obs_vector.h>
|
||||
#include <ert/enkf/local_obsset.h>
|
||||
#include <ert/enkf/enkf_types.h>
|
||||
#include <ert/enkf/local_obsdata_node.h>
|
||||
#include <ert/enkf/local_obsdata.h>
|
||||
|
||||
bool enkf_obs_have_obs( const enkf_obs_type * enkf_obs );
|
||||
const char * enkf_obs_get_config_file( const enkf_obs_type * enkf_obs);
|
||||
@ -71,6 +73,26 @@ extern "C" {
|
||||
const local_obsset_type * obsset);
|
||||
|
||||
|
||||
void enkf_obs_get_obs_and_measure_node( const enkf_obs_type * enkf_obs,
|
||||
enkf_fs_type * fs,
|
||||
const local_obsdata_node_type * obs_node ,
|
||||
state_enum state,
|
||||
const int_vector_type * ens_active_list ,
|
||||
const enkf_state_type ** ensemble ,
|
||||
meas_data_type * meas_data,
|
||||
obs_data_type * obs_data);
|
||||
|
||||
|
||||
void enkf_obs_get_obs_and_measure_data(const enkf_obs_type * enkf_obs,
|
||||
enkf_fs_type * fs,
|
||||
const local_obsdata_type * local_obsdata ,
|
||||
state_enum state,
|
||||
const int_vector_type * ens_active_list ,
|
||||
const enkf_state_type ** ensemble ,
|
||||
meas_data_type * meas_data,
|
||||
obs_data_type * obs_data);
|
||||
|
||||
|
||||
stringlist_type * enkf_obs_alloc_typed_keylist( enkf_obs_type * enkf_obs , obs_impl_type );
|
||||
hash_type * enkf_obs_alloc_data_map(enkf_obs_type * enkf_obs);
|
||||
|
||||
@ -78,7 +100,8 @@ extern "C" {
|
||||
bool enkf_obs_has_key(const enkf_obs_type * , const char * );
|
||||
|
||||
hash_iter_type * enkf_obs_alloc_iter( const enkf_obs_type * enkf_obs );
|
||||
|
||||
|
||||
stringlist_type * enkf_obs_alloc_keylist(enkf_obs_type * enkf_obs );
|
||||
stringlist_type * enkf_obs_alloc_matching_keylist(const enkf_obs_type * enkf_obs , const char * input_string);
|
||||
time_t enkf_obs_iget_obs_time(enkf_obs_type * enkf_obs , int report_step);
|
||||
void enkf_obs_fprintf_config( const enkf_obs_type * enkf_obs , FILE * stream);
|
||||
|
46
ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata.h
vendored
Normal file
46
ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata.h
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'local_obsdata.h'
|
||||
|
||||
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 __LOCAL_OBSDATA_H__
|
||||
#define __LOCAL_OBSDATA_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/enkf/local_obsdata_node.h>
|
||||
|
||||
typedef struct local_obsdata_struct local_obsdata_type;
|
||||
|
||||
bool local_obsdata_has_node( const local_obsdata_type * data , const char * key);
|
||||
local_obsdata_type * local_obsdata_alloc( const char * name );
|
||||
void local_obsdata_free( local_obsdata_type * data );
|
||||
int local_obsdata_get_size( const local_obsdata_type * data );
|
||||
bool local_obsdata_add_node( local_obsdata_type * data , local_obsdata_node_type * node );
|
||||
const local_obsdata_node_type * local_obsdata_iget( const local_obsdata_type * data , int index);
|
||||
local_obsdata_type * local_obsdata_alloc_wrapper( local_obsdata_node_type * node );
|
||||
const char * local_obsdata_get_name( const local_obsdata_type * data);
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( local_obsdata );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
48
ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata_node.h
vendored
Normal file
48
ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_obsdata_node.h
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'local_obsdata_node.h'
|
||||
|
||||
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 __LOCAL_OBSDATA_NODE_H__
|
||||
#define __LOCAL_OBSDATA_NODE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/enkf/obs_tstep_list.h>
|
||||
#include <ert/enkf/active_list.h>
|
||||
|
||||
|
||||
typedef struct local_obsdata_node_struct local_obsdata_node_type;
|
||||
|
||||
local_obsdata_node_type * local_obsdata_node_alloc( const char * obs_key );
|
||||
const char * local_obsdata_node_get_key( const local_obsdata_node_type * node );
|
||||
void local_obsdata_node_free( local_obsdata_node_type * node );
|
||||
void local_obsdata_node_free__( void * arg );
|
||||
active_list_type * local_obsdata_node_get_active_list( const local_obsdata_node_type * node );
|
||||
const obs_tstep_list_type * local_obsdata_node_get_tstep_list( const local_obsdata_node_type * node);
|
||||
void local_obsdata_node_copy_active_list( local_obsdata_node_type * node , const active_list_type * active_list);
|
||||
void local_obsdata_node_add_tstep( local_obsdata_node_type * node, int tstep);
|
||||
void local_obsdata_node_add_range( local_obsdata_node_type * node, int step1, int step2);
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( local_obsdata_node );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
48
ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_tstep_list.h
vendored
Normal file
48
ThirdParty/Ert/devel/libenkf/include/ert/enkf/obs_tstep_list.h
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'obs_tstep_list.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 __OBS_TSTEP_LIST_H__
|
||||
#define __OBS_TSTEP_LIST_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
typedef struct obs_tstep_list_struct obs_tstep_list_type;
|
||||
|
||||
obs_tstep_list_type * obs_tstep_list_alloc();
|
||||
void obs_tstep_list_free( obs_tstep_list_type * list );
|
||||
bool obs_tstep_list_all_active( const obs_tstep_list_type * list );
|
||||
int obs_tstep_list_get_size( const obs_tstep_list_type * list );
|
||||
void obs_tstep_list_add_tstep( obs_tstep_list_type * list , int tstep);
|
||||
void obs_tstep_list_add_range( obs_tstep_list_type * list , int step1 , int step2);
|
||||
bool obs_tstep_list_contains( const obs_tstep_list_type * list , int tstep);
|
||||
int obs_tstep_list_iget( const obs_tstep_list_type * list , int index);
|
||||
int obs_tstep_list_get_last( const obs_tstep_list_type * list );
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( obs_tstep_list );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
46
ThirdParty/Ert/devel/libenkf/include/ert/enkf/pca_plot_data.h
vendored
Normal file
46
ThirdParty/Ert/devel/libenkf/include/ert/enkf/pca_plot_data.h
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'pca_plot_data.h'
|
||||
|
||||
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 __PCA_PLOT_DATA_H__
|
||||
#define __PCA_PLOT_DATA_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/matrix.h>
|
||||
|
||||
#include <ert/enkf/pca_plot_vector.h>
|
||||
|
||||
typedef struct pca_plot_data_struct pca_plot_data_type;
|
||||
|
||||
pca_plot_data_type * pca_plot_data_alloc( const char * name , const matrix_type * PC, const matrix_type * PC_obs);
|
||||
|
||||
void pca_plot_data_free( pca_plot_data_type * plot_data );
|
||||
const pca_plot_vector_type * pca_plot_data_iget_vector( const pca_plot_data_type * plot_data , int ivec);
|
||||
int pca_plot_data_get_size( const pca_plot_data_type * plot_data );
|
||||
const char * pca_plot_data_get_name( const pca_plot_data_type * plot_data );
|
||||
int pca_plot_data_get_ens_size( const pca_plot_data_type * plot_data );
|
||||
void pca_plot_data_free__( void * arg );
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( pca_plot_data );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
44
ThirdParty/Ert/devel/libenkf/include/ert/enkf/pca_plot_vector.h
vendored
Normal file
44
ThirdParty/Ert/devel/libenkf/include/ert/enkf/pca_plot_vector.h
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'pca_plot_vector.h'
|
||||
|
||||
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 __PCA_PLOT_VECTOR_H__
|
||||
#define __PCA_PLOT_VECTOR_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/matrix.h>
|
||||
|
||||
typedef struct pca_plot_vector_struct pca_plot_vector_type;
|
||||
|
||||
pca_plot_vector_type * pca_plot_vector_alloc( int component , const matrix_type * PC, const matrix_type * PC_obs);
|
||||
|
||||
void pca_plot_vector_free( pca_plot_vector_type * plot_vector );
|
||||
bool pca_plot_assert_input( const matrix_type * PC, const matrix_type * PC_obs);
|
||||
void pca_plot_vector_free__( void * arg );
|
||||
double pca_plot_vector_get_obs_value( const pca_plot_vector_type * vector );
|
||||
double pca_plot_vector_iget_sim_value( const pca_plot_vector_type * vector , int sim_index);
|
||||
int pca_plot_vector_get_size( const pca_plot_vector_type * vector );
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( pca_plot_vector );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -37,6 +37,7 @@ extern "C" {
|
||||
int state_map_get_size( state_map_type * map);
|
||||
realisation_state_enum state_map_iget( state_map_type * map , int index);
|
||||
void state_map_update_undefined( state_map_type * map , int index , realisation_state_enum new_state);
|
||||
void state_map_update_matching( state_map_type * map , int index , int state_mask , realisation_state_enum new_state);
|
||||
void state_map_iset( state_map_type * map ,int index , realisation_state_enum state);
|
||||
bool state_map_equal( state_map_type * map1 , state_map_type * map2);
|
||||
void state_map_fwrite( state_map_type * map , const char * filename);
|
||||
|
@ -1,10 +1,12 @@
|
||||
set( source_files ert_report.c time_map.c rng_config.c trans_func.c enkf_types.c enkf_obs.c obs_data.c block_obs.c enkf_config_node.c field_config.c field.c ecl_static_kw.c enkf_state.c enkf_util.c enkf_node.c gen_kw_config.c gen_kw.c enkf_fs.c fs_driver.c meas_data.c summary_obs.c summary.c summary_config.c gen_data_config.c gen_data.c gen_common.c gen_obs.c enkf_sched.c enkf_serialize.c ecl_config.c enkf_defaults.c ensemble_config.c model_config.c site_config.c active_list.c obs_vector.c field_trans.c plain_driver.c local_ministep.c local_updatestep.c container_config.c container.c local_context.c local_config.c analysis_config.c misfit_ensemble.c misfit_member.c misfit_ts.c data_ranking.c misfit_ranking.c ranking_table.c fs_types.c block_fs_driver.c plot_config.c ert_template.c member_config.c enkf_analysis.c enkf_main.c local_dataset.c local_obsset.c surface.c surface_config.c enkf_plot_data.c enkf_plot_member.c qc_module.c ert_report_list.c enkf_plot_arg.c runpath_list.c ert_workflow_list.c analysis_iter_config.c enkf_main_jobs.c ecl_refcase_list.c cases_config.c state_map.c)
|
||||
set( source_files ert_report.c time_map.c rng_config.c trans_func.c enkf_types.c enkf_obs.c obs_data.c block_obs.c enkf_config_node.c field_config.c field.c ecl_static_kw.c enkf_state.c enkf_util.c enkf_node.c gen_kw_config.c gen_kw.c enkf_fs.c fs_driver.c meas_data.c summary_obs.c summary.c summary_config.c gen_data_config.c gen_data.c gen_common.c gen_obs.c enkf_sched.c enkf_serialize.c ecl_config.c enkf_defaults.c ensemble_config.c model_config.c site_config.c active_list.c obs_vector.c field_trans.c plain_driver.c local_ministep.c local_updatestep.c container_config.c container.c local_context.c local_config.c analysis_config.c misfit_ensemble.c misfit_member.c misfit_ts.c data_ranking.c misfit_ranking.c ranking_table.c fs_types.c block_fs_driver.c plot_config.c ert_template.c member_config.c enkf_analysis.c enkf_main.c local_dataset.c local_obsset.c surface.c surface_config.c enkf_plot_data.c enkf_plot_member.c qc_module.c ert_report_list.c enkf_plot_arg.c runpath_list.c ert_workflow_list.c analysis_iter_config.c enkf_main_jobs.c ecl_refcase_list.c local_obsdata_node.c local_obsdata.c obs_tstep_list.c pca_plot_data.c pca_plot_vector.c state_map.c cases_config.c state_map.c)
|
||||
|
||||
set( header_files ert_report.h time_map.h rng_config.h enkf_analysis.h enkf_fs_type.h trans_func.h enkf_obs.h obs_data.h enkf_config_node.h block_obs.h field_config.h field.h enkf_macros.h ecl_static_kw.h enkf_state.h enkf_util.h enkf_main.h enkf_node.h enkf_fs.h gen_kw_config.h gen_kw.h enkf_types.h fs_driver.h meas_data.h summary_obs.h summary_config.h summary_config.h gen_data_config.h gen_data.h gen_common.h gen_obs.h enkf_sched.h fs_types.h enkf_serialize.h plain_driver.h ecl_config.h ensemble_config.h model_config.h site_config.h active_list.h obs_vector.h field_trans.h plain_driver.h local_ministep.h container.h local_updatestep.h local_config.h analysis_config.h misfit_ensemble.h misfit_ensemble_typedef.h misfit_ts.h misfit_member.h data_ranking.h ranking_table.h ranking_common.h misfit_ranking.h block_fs_driver.h field_common.h gen_kw_common.h gen_data_common.h plot_config.h ert_template.h member_config.h enkf_defaults.h container_config.h local_dataset.h local_obsset.h surface.h surface_config.h local_context.h enkf_plot_data.h enkf_plot_member.h qc_module.h ert_report_list.h enkf_plot_arg.h runpath_list.h ert_workflow_list.h analysis_iter_config.h ecl_refcase_list.h local_obsdata_node.h local_obsdata.h obs_tstep_list.h pca_plot_data.h pca_plot_vector.h state_map.h cases_config.h state_map.h)
|
||||
|
||||
set( header_files ert_report.h time_map.h rng_config.h enkf_analysis.h enkf_fs_type.h trans_func.h enkf_obs.h obs_data.h enkf_config_node.h block_obs.h field_config.h field.h enkf_macros.h ecl_static_kw.h enkf_state.h enkf_util.h enkf_main.h enkf_node.h enkf_fs.h gen_kw_config.h gen_kw.h enkf_types.h fs_driver.h meas_data.h summary_obs.h summary_config.h summary_config.h gen_data_config.h gen_data.h gen_common.h gen_obs.h enkf_sched.h fs_types.h enkf_serialize.h plain_driver.h ecl_config.h ensemble_config.h model_config.h site_config.h active_list.h obs_vector.h field_trans.h plain_driver.h local_ministep.h container.h local_updatestep.h local_config.h analysis_config.h misfit_ensemble.h misfit_ensemble_typedef.h misfit_ts.h misfit_member.h data_ranking.h ranking_table.h ranking_common.h misfit_ranking.h block_fs_driver.h field_common.h gen_kw_common.h gen_data_common.h plot_config.h ert_template.h member_config.h enkf_defaults.h container_config.h local_dataset.h local_obsset.h surface.h surface_config.h local_context.h enkf_plot_data.h enkf_plot_member.h qc_module.h ert_report_list.h enkf_plot_arg.h runpath_list.h ert_workflow_list.h analysis_iter_config.h ecl_refcase_list.h cases_config.h state_map.h)
|
||||
|
||||
add_library( enkf ${LIBRARY_TYPE} ${source_files} )
|
||||
set_target_properties( enkf PROPERTIES VERSION 1.0 SOVERSION 1.0 )
|
||||
|
||||
|
||||
#configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/CMake/config/ert_build_info.h.in
|
||||
# ${CMAKE_CURRENT_BINARY_DIR}/ert_build_info.h )
|
||||
#list( APPEND src_files ${CMAKE_CURRENT_BINARY_DIR}/ert_build_info.h )
|
||||
|
31
ThirdParty/Ert/devel/libenkf/src/active_list.c
vendored
31
ThirdParty/Ert/devel/libenkf/src/active_list.c
vendored
@ -72,8 +72,8 @@ struct active_list_struct {
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
UTIL_SAFE_CAST_FUNCTION(active_list , ACTIVE_LIST_TYPE_ID)
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION(active_list , ACTIVE_LIST_TYPE_ID)
|
||||
UTIL_IS_INSTANCE_FUNCTION( active_list , ACTIVE_LIST_TYPE_ID)
|
||||
|
||||
|
||||
|
||||
@ -81,17 +81,17 @@ UTIL_SAFE_CAST_FUNCTION(active_list , ACTIVE_LIST_TYPE_ID)
|
||||
/**
|
||||
The newly created active_list default to setting all indices actiove.
|
||||
*/
|
||||
active_list_type * active_list_alloc(active_mode_type mode) {
|
||||
active_list_type * active_list_alloc( ) {
|
||||
active_list_type * active_list = util_malloc(sizeof * active_list);
|
||||
UTIL_TYPE_ID_INIT( active_list , ACTIVE_LIST_TYPE_ID );
|
||||
active_list->index_list = int_vector_alloc(0 , -1);
|
||||
active_list->mode = mode;
|
||||
active_list->mode = ALL_ACTIVE;
|
||||
return active_list;
|
||||
}
|
||||
|
||||
|
||||
active_list_type * active_list_alloc_copy( const active_list_type * src) {
|
||||
active_list_type * new = active_list_alloc( ALL_ACTIVE );
|
||||
active_list_type * new = active_list_alloc( );
|
||||
new->mode = src->mode;
|
||||
int_vector_free( new->index_list ) ;
|
||||
new->index_list = int_vector_alloc_copy( src->index_list );
|
||||
@ -99,6 +99,11 @@ active_list_type * active_list_alloc_copy( const active_list_type * src) {
|
||||
}
|
||||
|
||||
|
||||
void active_list_copy( active_list_type * target , const active_list_type * src) {
|
||||
target->mode = src->mode;
|
||||
int_vector_memcpy( target->index_list , src->index_list);
|
||||
}
|
||||
|
||||
|
||||
void active_list_free( active_list_type * active_list ) {
|
||||
int_vector_free(active_list->index_list);
|
||||
@ -218,3 +223,19 @@ void active_list_fprintf( const active_list_type * active_list , bool obs , cons
|
||||
} /* else: if mode == ALL_ACTIVE nothing is written */
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool active_list_equal( const active_list_type * active_list1 , const active_list_type * active_list2) {
|
||||
if (active_list1 == active_list2)
|
||||
return true;
|
||||
else {
|
||||
if (active_list1->mode != active_list2->mode)
|
||||
return false;
|
||||
else {
|
||||
if (active_list1->mode == PARTLY_ACTIVE)
|
||||
return int_vector_equal( active_list1->index_list , active_list2->index_list);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,8 +57,11 @@ struct analysis_config_struct {
|
||||
bool update_results; /* Should result values like e.g. WWCT be updated? */
|
||||
bool single_node_update; /* When creating the default ALL_ACTIVE local configuration. */
|
||||
rng_type * rng;
|
||||
analysis_iter_config_type * iter_config;
|
||||
int min_realisations;
|
||||
analysis_iter_config_type * iter_config;
|
||||
int min_realisations;
|
||||
bool stop_long_running;
|
||||
int max_runtime;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -137,6 +140,22 @@ bool analysis_config_have_enough_realisations( const analysis_config_type * conf
|
||||
}
|
||||
}
|
||||
|
||||
void analysis_config_set_stop_long_running( analysis_config_type * config, bool stop_long_running ) {
|
||||
config->stop_long_running = stop_long_running;
|
||||
}
|
||||
|
||||
bool analysis_config_get_stop_long_running( const analysis_config_type * config) {
|
||||
return config->stop_long_running;
|
||||
}
|
||||
|
||||
int analysis_config_get_max_runtime( const analysis_config_type * config ) {
|
||||
return config->max_runtime;
|
||||
}
|
||||
|
||||
void analysis_config_set_max_runtime( analysis_config_type * config, int max_runtime ) {
|
||||
config->max_runtime = max_runtime;
|
||||
}
|
||||
|
||||
void analysis_config_set_min_realisations( analysis_config_type * config , int min_realisations) {
|
||||
config->min_realisations = min_realisations;
|
||||
}
|
||||
@ -260,13 +279,16 @@ void analysis_config_load_internal_module( analysis_config_type * config ,
|
||||
|
||||
|
||||
|
||||
void analysis_config_load_external_module( analysis_config_type * config ,
|
||||
bool analysis_config_load_external_module( analysis_config_type * config ,
|
||||
const char * user_name , const char * lib_name) {
|
||||
analysis_module_type * module = analysis_module_alloc_external( config->rng , user_name , lib_name );
|
||||
if (module != NULL)
|
||||
if (module != NULL) {
|
||||
hash_insert_hash_owned_ref( config->analysis_modules , user_name , module , analysis_module_free__ );
|
||||
else
|
||||
return true;
|
||||
} else {
|
||||
fprintf(stderr,"** Warning: failed to load module %s from %s.\n",user_name , lib_name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -336,9 +358,27 @@ bool analysis_config_has_module(analysis_config_type * config , const char * mod
|
||||
return hash_has_key( config->analysis_modules , module_name );
|
||||
}
|
||||
|
||||
bool analysis_config_get_module_option( const analysis_config_type * config , long flag) {
|
||||
if (config->analysis_module)
|
||||
return analysis_module_check_option(config->analysis_module , flag);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool analysis_config_select_module( analysis_config_type * config , const char * module_name ) {
|
||||
if (analysis_config_has_module( config , module_name )) {
|
||||
config->analysis_module = analysis_config_get_module( config , module_name );
|
||||
analysis_module_type * module = analysis_config_get_module( config , module_name );
|
||||
|
||||
if (analysis_module_check_option( module , ANALYSIS_ITERABLE)) {
|
||||
if (analysis_config_get_single_node_update( config )) {
|
||||
fprintf(stderr," ** Warning: the module:%s requires the setting \"SINGLE_NODE_UPDATE FALSE\" in the config file.\n" , module_name);
|
||||
fprintf(stderr," ** the module has NOT been selected. \n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
config->analysis_module = module;
|
||||
return true;
|
||||
} else {
|
||||
if (config->analysis_module == NULL)
|
||||
@ -356,6 +396,16 @@ analysis_module_type * analysis_config_get_active_module( analysis_config_type *
|
||||
return config->analysis_module;
|
||||
}
|
||||
|
||||
|
||||
const char * analysis_config_get_active_module_name( const analysis_config_type * config ) {
|
||||
if (config->analysis_module)
|
||||
return analysis_module_get_name( config->analysis_module );
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
@ -402,6 +452,14 @@ void analysis_config_init( analysis_config_type * analysis , const config_type *
|
||||
if (config_item_set( config , MIN_REALIZATIONS_KEY ))
|
||||
analysis_config_set_min_realisations( analysis , config_get_value_as_int( config , MIN_REALIZATIONS_KEY ));
|
||||
|
||||
if (config_item_set( config , STOP_LONG_RUNNING_KEY ))
|
||||
analysis_config_set_stop_long_running( analysis , config_get_value_as_bool( config , STOP_LONG_RUNNING_KEY ));
|
||||
|
||||
if (config_item_set( config, MAX_RUNTIME_KEY)) {
|
||||
analysis_config_set_max_runtime( analysis, config_get_value_as_int( config, MAX_RUNTIME_KEY ));
|
||||
}
|
||||
|
||||
|
||||
/* Loading external modules */
|
||||
{
|
||||
const config_content_item_type * load_item = config_get_content_item( config , ANALYSIS_LOAD_KEY );
|
||||
@ -508,7 +566,9 @@ analysis_config_type * analysis_config_alloc( rng_type * rng ) {
|
||||
analysis_config_set_store_PC( config , DEFAULT_STORE_PC );
|
||||
analysis_config_set_PC_filename( config , DEFAULT_PC_FILENAME );
|
||||
analysis_config_set_PC_path( config , DEFAULT_PC_PATH );
|
||||
analysis_config_set_min_realisations( config , DEFAULT_ANALYSIS_MIN_REALISATIONS );
|
||||
analysis_config_set_min_realisations( config , DEFAULT_ANALYSIS_MIN_REALISATIONS );
|
||||
analysis_config_set_stop_long_running( config , DEFAULT_ANALYSIS_STOP_LONG_RUNNING );
|
||||
analysis_config_set_max_runtime( config , DEFAULT_MAX_RUNTIME );
|
||||
|
||||
config->analysis_module = NULL;
|
||||
config->analysis_modules = hash_alloc();
|
||||
@ -547,7 +607,14 @@ void analysis_config_add_config_items( config_type * config ) {
|
||||
config_add_key_value( config , RERUN_START_KEY , false , CONFIG_INT);
|
||||
config_add_key_value( config , UPDATE_LOG_PATH_KEY , false , CONFIG_STRING);
|
||||
config_add_key_value( config , MIN_REALIZATIONS_KEY , false , CONFIG_INT );
|
||||
|
||||
config_add_key_value( config , MAX_RUNTIME_KEY , false , CONFIG_INT );
|
||||
|
||||
item = config_add_key_value( config , STOP_LONG_RUNNING_KEY, false, CONFIG_BOOL );
|
||||
stringlist_type * child_list = stringlist_alloc_new();
|
||||
stringlist_append_ref(child_list, MIN_REALIZATIONS_KEY);
|
||||
config_schema_item_set_required_children_on_value(item , "TRUE" , child_list);
|
||||
stringlist_free(child_list);
|
||||
|
||||
config_add_key_value( config , ANALYSIS_SELECT_KEY , false , CONFIG_STRING);
|
||||
|
||||
item = config_add_schema_item( config , ANALYSIS_LOAD_KEY , false );
|
||||
@ -561,9 +628,9 @@ void analysis_config_add_config_items( config_type * config ) {
|
||||
config_schema_item_set_argc_minmax( item , 3 , CONFIG_DEFAULT_ARG_MAX);
|
||||
analysis_iter_config_add_config_items( config );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void analysis_config_fprintf_config( analysis_config_type * config , FILE * stream) {
|
||||
fprintf( stream , CONFIG_COMMENTLINE_FORMAT );
|
||||
fprintf( stream , CONFIG_COMMENT_FORMAT , "Here comes configuration information related to the EnKF analysis.");
|
||||
|
@ -55,7 +55,7 @@ int analysis_iter_config_get_num_iterations( const analysis_iter_config_type * c
|
||||
an extra '%'.
|
||||
*/
|
||||
|
||||
static void analysis_iter_config_set_runpath_fmt( analysis_iter_config_type * config , const char * runpath_fmt) {
|
||||
void analysis_iter_config_set_runpath_fmt( analysis_iter_config_type * config , const char * runpath_fmt) {
|
||||
util_safe_free( config->runpath_fmt );
|
||||
if (runpath_fmt != NULL) {
|
||||
config->runpath_fmt = util_calloc( strlen(runpath_fmt ) + 2 , sizeof * config->runpath_fmt);
|
||||
@ -68,6 +68,10 @@ static void analysis_iter_config_set_runpath_fmt( analysis_iter_config_type * co
|
||||
}
|
||||
}
|
||||
|
||||
char * analysis_iter_config_get_runpath_fmt( analysis_iter_config_type * config){
|
||||
return config->runpath_fmt;
|
||||
}
|
||||
|
||||
void analysis_iter_config_set_case_fmt( analysis_iter_config_type * config , const char * case_fmt) {
|
||||
config->case_fmt = util_realloc_string_copy( config->case_fmt , case_fmt );
|
||||
}
|
||||
|
659
ThirdParty/Ert/devel/libenkf/src/enkf_main.c
vendored
659
ThirdParty/Ert/devel/libenkf/src/enkf_main.c
vendored
@ -101,6 +101,7 @@
|
||||
#include <ert/enkf/enkf_defaults.h>
|
||||
#include <ert/enkf/config_keys.h>
|
||||
#include <ert/enkf/runpath_list.h>
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
#include <ert/enkf/analysis_config.h>
|
||||
#include <ert/enkf/analysis_iter_config.h>
|
||||
|
||||
@ -187,6 +188,7 @@ void enkf_main_init_internalization( enkf_main_type * , run_mode_type );
|
||||
/*****************************************************************/
|
||||
|
||||
UTIL_SAFE_CAST_FUNCTION(enkf_main , ENKF_MAIN_ID)
|
||||
UTIL_IS_INSTANCE_FUNCTION(enkf_main , ENKF_MAIN_ID)
|
||||
|
||||
analysis_config_type * enkf_main_get_analysis_config(const enkf_main_type * enkf_main) {
|
||||
return enkf_main->analysis_config;
|
||||
@ -977,47 +979,132 @@ static serialize_info_type * serialize_info_alloc( enkf_fs_type * src_fs,
|
||||
return serialize_info;
|
||||
}
|
||||
|
||||
void enkf_main_fprintf_PC(const char * filename ,
|
||||
matrix_type * PC ,
|
||||
matrix_type * PC_obs) {
|
||||
|
||||
void enkf_main_get_PC( const enkf_main_type * enkf_main ,
|
||||
const matrix_type * S,
|
||||
FILE * stream = util_mkdir_fopen(filename , "w");
|
||||
const int num_PC = matrix_get_rows( PC );
|
||||
const int ens_size = matrix_get_columns( PC );
|
||||
int ipc,iens;
|
||||
|
||||
for (ipc = 0; ipc < num_PC; ipc++)
|
||||
fprintf(stream , "%10.6f " , matrix_iget( PC_obs , ipc , 0));
|
||||
fprintf(stream , "\n");
|
||||
|
||||
for (iens = 0; iens < ens_size; iens++) {
|
||||
for (ipc = 0; ipc < num_PC; ipc++)
|
||||
fprintf(stream ,"%10.6f " , matrix_iget( PC , ipc, iens ));
|
||||
fprintf(stream , "\n");
|
||||
}
|
||||
fclose( stream );
|
||||
}
|
||||
|
||||
|
||||
void enkf_main_get_PC( const matrix_type * S,
|
||||
const matrix_type * dObs,
|
||||
const char * obsset_name ,
|
||||
int step1 , int step2 ,
|
||||
double truncation ,
|
||||
int ncomp ,
|
||||
matrix_type * PC ,
|
||||
matrix_type * PC_obs) {
|
||||
|
||||
enkf_linalg_get_PC( S , dObs , truncation , ncomp , PC , PC_obs);
|
||||
{
|
||||
char * filename = util_alloc_sprintf(analysis_config_get_PC_filename( enkf_main->analysis_config ) , step1 , step2 , obsset_name);
|
||||
char * full_path = util_alloc_filename( analysis_config_get_PC_path( enkf_main->analysis_config) , filename , NULL );
|
||||
FILE * stream = util_mkdir_fopen(full_path , "w");
|
||||
{
|
||||
const int num_PC = matrix_get_rows( PC );
|
||||
const int ens_size = matrix_get_columns( PC );
|
||||
int ipc,iens;
|
||||
|
||||
for (ipc = 0; ipc < num_PC; ipc++)
|
||||
fprintf(stream , "%10.6f " , matrix_iget( PC_obs , ipc , 0));
|
||||
fprintf(stream , "\n");
|
||||
|
||||
for (iens = 0; iens < ens_size; iens++) {
|
||||
for (ipc = 0; ipc < num_PC; ipc++)
|
||||
fprintf(stream ,"%10.6f " , matrix_iget( PC , ipc, iens ));
|
||||
fprintf(stream , "\n");
|
||||
}
|
||||
}
|
||||
fclose( stream );
|
||||
free( filename );
|
||||
free( full_path );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void enkf_main_init_PC( const enkf_main_type * enkf_main ,
|
||||
const local_obsdata_type * obsdata ,
|
||||
double truncation_or_ncomp ,
|
||||
matrix_type * PC ,
|
||||
matrix_type * PC_obs ) {
|
||||
state_enum state = FORECAST;
|
||||
enkf_fs_type * fs = enkf_main_get_fs( enkf_main );
|
||||
state_map_type * state_map = enkf_fs_get_state_map( fs );
|
||||
bool_vector_type * ens_mask = bool_vector_alloc(0 , false );
|
||||
obs_data_type * obs_data = obs_data_alloc();
|
||||
int_vector_type * ens_active_list;
|
||||
meas_data_type * meas_data;
|
||||
|
||||
state_map_select_matching( state_map , ens_mask , STATE_HAS_DATA );
|
||||
ens_active_list = bool_vector_alloc_active_list( ens_mask );
|
||||
if (int_vector_size( ens_active_list )) {
|
||||
meas_data = meas_data_alloc( ens_active_list );
|
||||
|
||||
enkf_obs_get_obs_and_measure_data( enkf_main_get_obs( enkf_main ),
|
||||
enkf_main_get_fs( enkf_main ),
|
||||
obsdata ,
|
||||
state ,
|
||||
ens_active_list ,
|
||||
enkf_main_get_ensemble_const( enkf_main ),
|
||||
meas_data ,
|
||||
obs_data );
|
||||
|
||||
if (0)
|
||||
{
|
||||
const analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
double std_cutoff = analysis_config_get_std_cutoff( analysis_config );
|
||||
double alpha = analysis_config_get_alpha( analysis_config );
|
||||
|
||||
enkf_analysis_deactivate_outliers( obs_data , meas_data , std_cutoff , alpha);
|
||||
}
|
||||
|
||||
{
|
||||
int active_size = obs_data_get_active_size( obs_data );
|
||||
matrix_type * S = meas_data_allocS( meas_data , active_size );
|
||||
matrix_type * dObs = obs_data_allocdObs( obs_data , active_size );
|
||||
double truncation = -1;
|
||||
int ncomp = -1;
|
||||
|
||||
if (truncation_or_ncomp < 1)
|
||||
truncation = truncation_or_ncomp;
|
||||
else
|
||||
ncomp = (int) truncation_or_ncomp;
|
||||
|
||||
obs_data_scale( obs_data , S , NULL , NULL , NULL , dObs );
|
||||
enkf_linalg_get_PC( S , dObs , truncation , ncomp , PC , PC_obs);
|
||||
|
||||
matrix_free( S );
|
||||
matrix_free( dObs );
|
||||
}
|
||||
|
||||
bool_vector_free( ens_mask );
|
||||
int_vector_free( ens_active_list );
|
||||
obs_data_free( obs_data );
|
||||
meas_data_free( meas_data );
|
||||
} else
|
||||
fprintf(stderr," ** Warning: no realisations with data - no plot created \n");
|
||||
}
|
||||
|
||||
|
||||
pca_plot_data_type * enkf_main_alloc_pca_plot_data( const enkf_main_type * enkf_main ,
|
||||
local_obsdata_type * obs_data,
|
||||
double truncation_or_ncomp) {
|
||||
pca_plot_data_type * pca_plot_data;
|
||||
{
|
||||
matrix_type * PC = matrix_alloc(1,1);
|
||||
matrix_type * PC_obs = matrix_alloc(1,1);
|
||||
|
||||
|
||||
enkf_main_init_PC( enkf_main , obs_data , truncation_or_ncomp , PC , PC_obs );
|
||||
pca_plot_data = pca_plot_data_alloc( local_obsdata_get_name( obs_data ) , PC , PC_obs );
|
||||
|
||||
|
||||
matrix_free( PC );
|
||||
matrix_free( PC_obs );
|
||||
}
|
||||
return pca_plot_data;
|
||||
}
|
||||
|
||||
|
||||
static void assert_matrix_size(const matrix_type * m , const char * name , int rows , int columns) {
|
||||
if (!matrix_check_dims(m , rows , columns))
|
||||
util_abort("%s: matrix mismatch %s:[%d,%d] - expected:[%d, %d]", __func__ , name , matrix_get_rows(m) , matrix_get_columns(m) , rows , columns);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void enkf_main_analysis_update( enkf_main_type * enkf_main ,
|
||||
enkf_fs_type * target_fs ,
|
||||
const bool_vector_type * ens_mask ,
|
||||
@ -1046,18 +1133,23 @@ static void enkf_main_analysis_update( enkf_main_type * enkf_main ,
|
||||
matrix_type * localA = NULL;
|
||||
int_vector_type * iens_active_index = bool_vector_alloc_active_index_list(ens_mask , -1);
|
||||
|
||||
if (analysis_module_get_option( module , ANALYSIS_NEED_ED)) {
|
||||
|
||||
assert_matrix_size(X , "X" , ens_size , ens_size);
|
||||
assert_matrix_size(S , "S" , active_size , ens_size);
|
||||
assert_matrix_size(R , "R" , active_size , active_size);
|
||||
if (analysis_module_check_option( module , ANALYSIS_NEED_ED)) {
|
||||
E = obs_data_allocE( obs_data , enkf_main->rng , ens_size , active_size );
|
||||
D = obs_data_allocD( obs_data , E , S );
|
||||
|
||||
assert_matrix_size( E , "E" , active_size , ens_size);
|
||||
assert_matrix_size( D , "D" , active_size , ens_size);
|
||||
}
|
||||
|
||||
if (analysis_module_get_option( module , ANALYSIS_SCALE_DATA)){
|
||||
if (analysis_module_check_option( module , ANALYSIS_SCALE_DATA))
|
||||
obs_data_scale( obs_data , S , E , D , R , dObs );
|
||||
}
|
||||
|
||||
if (analysis_module_get_option( module , ANALYSIS_USE_A | ANALYSIS_UPDATE_A)){
|
||||
|
||||
if (analysis_module_check_option( module , ANALYSIS_USE_A) || analysis_module_check_option(module , ANALYSIS_UPDATE_A))
|
||||
localA = A;
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
@ -1081,16 +1173,25 @@ static void enkf_main_analysis_update( enkf_main_type * enkf_main ,
|
||||
int ncomp = ens_size - 1;
|
||||
matrix_type * PC = matrix_alloc(1,1);
|
||||
matrix_type * PC_obs = matrix_alloc(1,1);
|
||||
local_obsset_type * obsset = local_ministep_get_obsset( ministep );
|
||||
const char * obsset_name = local_obsset_get_name( obsset );
|
||||
|
||||
enkf_main_get_PC( enkf_main , S , dObs , local_ministep_get_name( ministep ) , step1 , step2 , truncation , ncomp , PC , PC_obs );
|
||||
|
||||
enkf_main_get_PC( S , dObs , truncation , ncomp , PC , PC_obs );
|
||||
{
|
||||
char * filename = util_alloc_sprintf(analysis_config_get_PC_filename( enkf_main->analysis_config ) , step1 , step2 , obsset_name);
|
||||
char * full_path = util_alloc_filename( analysis_config_get_PC_path( enkf_main->analysis_config) , filename , NULL );
|
||||
|
||||
enkf_main_fprintf_PC( full_path , PC , PC_obs);
|
||||
|
||||
free( full_path );
|
||||
free( filename );
|
||||
}
|
||||
matrix_free( PC );
|
||||
matrix_free( PC_obs );
|
||||
}
|
||||
|
||||
if (localA == NULL){
|
||||
if (localA == NULL)
|
||||
analysis_module_initX( module , X , NULL , S , R , dObs , E , D );
|
||||
}
|
||||
|
||||
|
||||
while (!hash_iter_is_complete( dataset_iter )) {
|
||||
@ -1102,8 +1203,8 @@ static void enkf_main_analysis_update( enkf_main_type * enkf_main ,
|
||||
|
||||
enkf_main_serialize_dataset( enkf_main , dataset , step2 , use_count , active_size , row_offset , tp , serialize_info);
|
||||
|
||||
if (analysis_module_get_option( module , ANALYSIS_UPDATE_A)){
|
||||
if (analysis_module_get_option( module , ANALYSIS_ITERABLE)){
|
||||
if (analysis_module_check_option( module , ANALYSIS_UPDATE_A)){
|
||||
if (analysis_module_check_option( module , ANALYSIS_ITERABLE)){
|
||||
int iteration = cases_config_get_iteration_number(enkf_fs_get_cases_config(src_fs));
|
||||
char iteration_str[15];
|
||||
sprintf(iteration_str,"%d",iteration);
|
||||
@ -1114,7 +1215,7 @@ static void enkf_main_analysis_update( enkf_main_type * enkf_main ,
|
||||
analysis_module_updateA( module , localA , S , R , dObs , E , D );
|
||||
}
|
||||
else {
|
||||
if (analysis_module_get_option( module , ANALYSIS_USE_A)){
|
||||
if (analysis_module_check_option( module , ANALYSIS_USE_A)){
|
||||
analysis_module_initX( module , X , localA , S , R , dObs , E , D );
|
||||
}
|
||||
|
||||
@ -1196,7 +1297,13 @@ static bool enkf_main_UPDATE(enkf_main_type * enkf_main , const int_vector_type
|
||||
const char * log_path = analysis_config_get_log_path( enkf_main->analysis_config );
|
||||
FILE * log_stream;
|
||||
|
||||
|
||||
|
||||
if ((local_updatestep_get_num_ministep( updatestep ) > 1) &&
|
||||
(analysis_config_get_module_option( analysis_config , ANALYSIS_ITERABLE))) {
|
||||
util_exit("** ERROR: Can not combine iterable modules with multi step updates - sorry\n");
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
char * log_file;
|
||||
if (int_vector_size( step_list ) == 1)
|
||||
@ -1314,7 +1421,32 @@ static void enkf_main_report_load_failure( const enkf_main_type * enkf_main , in
|
||||
job_queue_iget_run_path( job_queue , queue_index));
|
||||
}
|
||||
|
||||
static void enkf_main_monitor_job_queue ( const enkf_main_type * enkf_main) {
|
||||
job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config);
|
||||
int min_realisations = analysis_config_get_min_realisations(enkf_main->analysis_config);
|
||||
|
||||
bool cont = true;
|
||||
if (0 >= min_realisations)
|
||||
cont = false;
|
||||
|
||||
while (cont) {
|
||||
//Check if minimum number of realizations have run, and if so, kill the rest after a certain time
|
||||
if ((job_queue_get_num_complete(job_queue) >= min_realisations)) {
|
||||
job_queue_set_auto_job_stop_time(job_queue);
|
||||
cont = false;
|
||||
}
|
||||
|
||||
//Check if minimum number of realizations is not possible. If so, it is time to give up
|
||||
int possible_sucesses = job_queue_get_num_running(job_queue) + job_queue_get_num_waiting(job_queue) + job_queue_get_num_pending(job_queue) + job_queue_get_num_complete(job_queue);
|
||||
if (possible_sucesses < min_realisations) {
|
||||
cont = false;
|
||||
}
|
||||
|
||||
if (cont) {
|
||||
util_usleep(10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
If all simulations have completed successfully the function will
|
||||
@ -1347,8 +1479,6 @@ static void enkf_main_run_step(enkf_main_type * enkf_main ,
|
||||
int iens;
|
||||
|
||||
state_map_deselect_matching( enkf_fs_get_state_map( fs ) , iactive , STATE_LOAD_FAILURE | STATE_PARENT_FAILURE);
|
||||
bool_vector_fprintf( iactive , stdout , "IACTIVE" , "%2d");
|
||||
|
||||
|
||||
if (enkf_main->verbose) {
|
||||
if (run_mode == ENKF_ASSIMILATION)
|
||||
@ -1366,12 +1496,14 @@ static void enkf_main_run_step(enkf_main_type * enkf_main ,
|
||||
pthread_t queue_thread;
|
||||
job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config);
|
||||
|
||||
|
||||
/* Start the queue */
|
||||
if (run_mode != INIT_ONLY) {
|
||||
arg_pack_type * queue_args = arg_pack_alloc(); /* This arg_pack will be freed() in the job_que_run_jobs__() */
|
||||
arg_pack_append_ptr(queue_args , job_queue);
|
||||
arg_pack_append_int(queue_args , job_size);
|
||||
arg_pack_append_bool(queue_args , verbose_queue);
|
||||
job_queue_reset(job_queue);
|
||||
pthread_create( &queue_thread , NULL , job_queue_run_jobs__ , queue_args);
|
||||
}
|
||||
|
||||
@ -1427,6 +1559,14 @@ static void enkf_main_run_step(enkf_main_type * enkf_main ,
|
||||
if (run_mode != INIT_ONLY) {
|
||||
job_queue_submit_complete( job_queue );
|
||||
log_add_message(enkf_main->logh , 1 , NULL , "All jobs submitted to internal queue - waiting for completion" , false);
|
||||
|
||||
int max_runtime = analysis_config_get_max_runtime(enkf_main_get_analysis_config( enkf_main ));
|
||||
job_queue_set_max_job_duration(job_queue, max_runtime);
|
||||
|
||||
if (analysis_config_get_stop_long_running(enkf_main_get_analysis_config( enkf_main ))) {
|
||||
enkf_main_monitor_job_queue( enkf_main );
|
||||
}
|
||||
|
||||
pthread_join( queue_thread , NULL ); /* Wait for the job_queue_run_jobs() function to complete. */
|
||||
}
|
||||
}
|
||||
@ -1450,10 +1590,9 @@ static void enkf_main_run_step(enkf_main_type * enkf_main ,
|
||||
case JOB_RUN_OK:
|
||||
break;
|
||||
default:
|
||||
util_abort("%s: invalid job status:%s \n",__func__ , run_status );
|
||||
util_abort("%s: invalid job status:%d \n",__func__ , run_status );
|
||||
}
|
||||
totalOK = totalOK && ( run_status == JOB_RUN_OK );
|
||||
|
||||
}
|
||||
}
|
||||
enkf_fs_fsync( enkf_main->dbase );
|
||||
@ -1538,9 +1677,9 @@ void enkf_main_run_exp(enkf_main_type * enkf_main ,
|
||||
run_mode_type run_mode = simulate ? ENSEMBLE_EXPERIMENT : INIT_ONLY;
|
||||
{
|
||||
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
|
||||
if(initialize)
|
||||
if (initialize)
|
||||
enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1, force_init);
|
||||
|
||||
|
||||
stringlist_free( param_list );
|
||||
}
|
||||
enkf_main_init_run( enkf_main , run_mode );
|
||||
@ -1559,224 +1698,249 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main ,
|
||||
int init_step_parameters ,
|
||||
int start_report ,
|
||||
state_enum start_state) {
|
||||
bool force_init = false;
|
||||
int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
{
|
||||
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
|
||||
enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1 , force_init );
|
||||
stringlist_free( param_list );
|
||||
}
|
||||
bool rerun = analysis_config_get_rerun( enkf_main->analysis_config );
|
||||
int rerun_start = analysis_config_get_rerun_start( enkf_main->analysis_config );
|
||||
enkf_main_init_run( enkf_main , ENKF_ASSIMILATION);
|
||||
{
|
||||
bool analyzed_start = false;
|
||||
bool prev_enkf_on;
|
||||
const enkf_sched_type * enkf_sched = model_config_get_enkf_sched(enkf_main->model_config);
|
||||
const int num_nodes = enkf_sched_get_num_nodes(enkf_sched);
|
||||
const int start_inode = enkf_sched_get_node_index(enkf_sched , start_report);
|
||||
int inode;
|
||||
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
if (!analysis_config_get_module_option( analysis_config , ANALYSIS_ITERABLE)) {
|
||||
bool force_init = false;
|
||||
int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
{
|
||||
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
|
||||
enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1 , force_init );
|
||||
stringlist_free( param_list );
|
||||
}
|
||||
bool rerun = analysis_config_get_rerun( enkf_main->analysis_config );
|
||||
int rerun_start = analysis_config_get_rerun_start( enkf_main->analysis_config );
|
||||
enkf_main_init_run( enkf_main , ENKF_ASSIMILATION);
|
||||
{
|
||||
bool analyzed_start = false;
|
||||
bool prev_enkf_on;
|
||||
const enkf_sched_type * enkf_sched = model_config_get_enkf_sched(enkf_main->model_config);
|
||||
const int num_nodes = enkf_sched_get_num_nodes(enkf_sched);
|
||||
const int start_inode = enkf_sched_get_node_index(enkf_sched , start_report);
|
||||
int inode;
|
||||
|
||||
if (start_state == ANALYZED)
|
||||
analyzed_start = true;
|
||||
else if (start_state == FORECAST)
|
||||
analyzed_start = false;
|
||||
else
|
||||
util_abort("%s: internal error - start_state must be analyzed | forecast \n",__func__);
|
||||
if (start_state == ANALYZED)
|
||||
analyzed_start = true;
|
||||
else if (start_state == FORECAST)
|
||||
analyzed_start = false;
|
||||
else
|
||||
util_abort("%s: internal error - start_state must be analyzed | forecast \n",__func__);
|
||||
|
||||
prev_enkf_on = analyzed_start;
|
||||
for (inode = start_inode; inode < num_nodes; inode++) {
|
||||
const enkf_sched_node_type * node = enkf_sched_iget_node(enkf_sched , inode);
|
||||
state_enum init_state_parameter;
|
||||
state_enum init_state_dynamic;
|
||||
int init_step_parameter;
|
||||
int load_start;
|
||||
int report_step1;
|
||||
int report_step2;
|
||||
bool enkf_on;
|
||||
prev_enkf_on = analyzed_start;
|
||||
for (inode = start_inode; inode < num_nodes; inode++) {
|
||||
const enkf_sched_node_type * node = enkf_sched_iget_node(enkf_sched , inode);
|
||||
state_enum init_state_parameter;
|
||||
state_enum init_state_dynamic;
|
||||
int init_step_parameter;
|
||||
int load_start;
|
||||
int report_step1;
|
||||
int report_step2;
|
||||
bool enkf_on;
|
||||
|
||||
|
||||
enkf_sched_node_get_data(node , &report_step1 , &report_step2 , &enkf_on );
|
||||
if (inode == start_inode)
|
||||
report_step1 = start_report; /* If we are restarting from somewhere. */
|
||||
enkf_sched_node_get_data(node , &report_step1 , &report_step2 , &enkf_on );
|
||||
if (inode == start_inode)
|
||||
report_step1 = start_report; /* If we are restarting from somewhere. */
|
||||
|
||||
if (rerun) {
|
||||
/* rerun ... */
|
||||
load_start = report_step1; /* +1 below. Observe that report_step is set to rerun_start below. */
|
||||
init_step_parameter = report_step1;
|
||||
init_state_dynamic = FORECAST;
|
||||
init_state_parameter = ANALYZED;
|
||||
report_step1 = rerun_start;
|
||||
} else {
|
||||
if (prev_enkf_on)
|
||||
init_state_dynamic = ANALYZED;
|
||||
else
|
||||
init_state_dynamic = FORECAST;
|
||||
/*
|
||||
This is not a rerun - and then parameters and dynamic
|
||||
data should be initialized from the same report step.
|
||||
*/
|
||||
init_step_parameter = report_step1;
|
||||
init_state_parameter = init_state_dynamic;
|
||||
load_start = report_step1;
|
||||
}
|
||||
|
||||
if (load_start > 0)
|
||||
load_start++;
|
||||
|
||||
enkf_main_run_step(enkf_main , ENKF_ASSIMILATION , iactive , load_start , init_step_parameter ,
|
||||
init_state_parameter , init_state_dynamic , report_step1 , report_step2);
|
||||
{
|
||||
enkf_fs_type * fs = enkf_main_get_fs(enkf_main);
|
||||
state_map_type * state_map = enkf_fs_get_state_map(fs);
|
||||
const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
|
||||
int active_ens_size = state_map_count_matching(state_map , STATE_HAS_DATA);
|
||||
|
||||
if (analysis_config_have_enough_realisations(analysis_config , active_ens_size)) {
|
||||
if (enkf_on) {
|
||||
bool merge_observations = analysis_config_get_merge_observations( enkf_main->analysis_config );
|
||||
int_vector_type * step_list;
|
||||
int stride;
|
||||
|
||||
if (merge_observations)
|
||||
stride = 1;
|
||||
else
|
||||
stride = 0;
|
||||
|
||||
step_list = enkf_main_update_alloc_step_list( enkf_main , load_start , report_step2 , stride );
|
||||
|
||||
enkf_main_assimilation_update(enkf_main , step_list);
|
||||
int_vector_free( step_list );
|
||||
enkf_fs_fsync( enkf_main->dbase );
|
||||
}
|
||||
if (rerun) {
|
||||
/* rerun ... */
|
||||
load_start = report_step1; /* +1 below. Observe that report_step is set to rerun_start below. */
|
||||
init_step_parameter = report_step1;
|
||||
init_state_dynamic = FORECAST;
|
||||
init_state_parameter = ANALYZED;
|
||||
report_step1 = rerun_start;
|
||||
} else {
|
||||
fprintf(stderr,"** ERROR ** There are %d active realisations left, which is less than the minimum specified (%d) - stopping assimilation.\n" ,
|
||||
active_ens_size ,
|
||||
analysis_config_get_min_realisations(analysis_config));
|
||||
break;
|
||||
if (prev_enkf_on)
|
||||
init_state_dynamic = ANALYZED;
|
||||
else
|
||||
init_state_dynamic = FORECAST;
|
||||
/*
|
||||
This is not a rerun - and then parameters and dynamic
|
||||
data should be initialized from the same report step.
|
||||
*/
|
||||
init_step_parameter = report_step1;
|
||||
init_state_parameter = init_state_dynamic;
|
||||
load_start = report_step1;
|
||||
}
|
||||
|
||||
if (load_start > 0)
|
||||
load_start++;
|
||||
|
||||
enkf_main_run_step(enkf_main , ENKF_ASSIMILATION , iactive , load_start , init_step_parameter ,
|
||||
init_state_parameter , init_state_dynamic , report_step1 , report_step2);
|
||||
{
|
||||
enkf_fs_type * fs = enkf_main_get_fs(enkf_main);
|
||||
state_map_type * state_map = enkf_fs_get_state_map(fs);
|
||||
const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
|
||||
int active_ens_size = state_map_count_matching(state_map , STATE_HAS_DATA);
|
||||
|
||||
if (analysis_config_have_enough_realisations(analysis_config , active_ens_size)) {
|
||||
if (enkf_on) {
|
||||
bool merge_observations = analysis_config_get_merge_observations( enkf_main->analysis_config );
|
||||
int_vector_type * step_list;
|
||||
int stride;
|
||||
|
||||
if (merge_observations)
|
||||
stride = 1;
|
||||
else
|
||||
stride = 0;
|
||||
|
||||
step_list = enkf_main_update_alloc_step_list( enkf_main , load_start , report_step2 , stride );
|
||||
|
||||
enkf_main_assimilation_update(enkf_main , step_list);
|
||||
int_vector_free( step_list );
|
||||
enkf_fs_fsync( enkf_main->dbase );
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,"** ERROR ** There are %d active realisations left, which is less than the minimum specified (%d) - stopping assimilation.\n" ,
|
||||
active_ens_size ,
|
||||
analysis_config_get_min_realisations(analysis_config));
|
||||
break;
|
||||
}
|
||||
prev_enkf_on = enkf_on;
|
||||
}
|
||||
prev_enkf_on = enkf_on;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
fprintf(stderr,"** ERROR: EnKF assimilation can not be combined with an iterable analysis module.\n");
|
||||
}
|
||||
|
||||
|
||||
void enkf_main_run_smoother(enkf_main_type * enkf_main , const char * target_fs_name , bool rerun) {
|
||||
bool force_init = false;
|
||||
int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
{
|
||||
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
|
||||
enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1 , force_init);
|
||||
stringlist_free( param_list );
|
||||
}
|
||||
|
||||
{
|
||||
bool_vector_type * iactive = bool_vector_alloc( 0 , true );
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
|
||||
enkf_main_init_run( enkf_main , ENSEMBLE_EXPERIMENT);
|
||||
enkf_main_run_step(enkf_main , ENSEMBLE_EXPERIMENT , iactive , 0 , 0 , ANALYZED , UNDEFINED , 0 , 0);
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
if (!analysis_config_get_module_option( analysis_config , ANALYSIS_ITERABLE)) {
|
||||
bool force_init = false;
|
||||
int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
{
|
||||
bool update_done;
|
||||
time_map_type * time_map = enkf_fs_get_time_map( enkf_main_get_fs( enkf_main ));
|
||||
enkf_fs_type * target_fs = enkf_main_get_alt_fs( enkf_main , target_fs_name , false , true );
|
||||
stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
|
||||
enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1 , force_init);
|
||||
stringlist_free( param_list );
|
||||
}
|
||||
|
||||
{
|
||||
bool_vector_type * iactive = bool_vector_alloc( ens_size , true );
|
||||
enkf_main_init_run( enkf_main , ENSEMBLE_EXPERIMENT);
|
||||
enkf_main_run_step(enkf_main , ENSEMBLE_EXPERIMENT , iactive , 0 , 0 , ANALYZED , UNDEFINED , 0 , 0);
|
||||
{
|
||||
int stride = 1;
|
||||
int_vector_type * step_list = enkf_main_update_alloc_step_list( enkf_main , 0 , time_map_get_last_step( time_map ) , stride);
|
||||
update_done = enkf_main_smoother_update( enkf_main , step_list , target_fs );
|
||||
int_vector_free( step_list );
|
||||
bool update_done;
|
||||
time_map_type * time_map = enkf_fs_get_time_map( enkf_main_get_fs( enkf_main ));
|
||||
enkf_fs_type * target_fs = enkf_main_get_alt_fs( enkf_main , target_fs_name , false , true );
|
||||
{
|
||||
int stride = 1;
|
||||
int_vector_type * step_list = enkf_main_update_alloc_step_list( enkf_main , 0 , time_map_get_last_step( time_map ) , stride);
|
||||
update_done = enkf_main_smoother_update( enkf_main , step_list , target_fs );
|
||||
int_vector_free( step_list );
|
||||
}
|
||||
|
||||
if (rerun) {
|
||||
/*
|
||||
IFF a rerun path has been added with the RERUN_PATH config
|
||||
key the model_config object will select that runpath as the
|
||||
currently active one. If no path has been created with the
|
||||
RERUN_PATH config option the model_config_select_runpath()
|
||||
call will fail silently.
|
||||
|
||||
The runpath select with this call will remain the currently
|
||||
active runpath for the remaining part of this program
|
||||
invocation.
|
||||
*/
|
||||
if (update_done) {
|
||||
enkf_main_set_fs( enkf_main , target_fs , target_fs_name);
|
||||
model_config_select_runpath( enkf_main_get_model_config( enkf_main ) , RERUN_PATH_KEY );
|
||||
enkf_main_run_step(enkf_main , ENSEMBLE_EXPERIMENT , iactive , 0 , 0 , ANALYZED , UNDEFINED , 0 , 0 );
|
||||
} else
|
||||
fprintf(stderr,"** Warning: the analysis update failed - no rerun started.\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (rerun) {
|
||||
/*
|
||||
IFF a rerun path has been added with the RERUN_PATH config
|
||||
key the model_config object will select that runpath as the
|
||||
currently active one. If no path has been created with the
|
||||
RERUN_PATH config option the model_config_select_runpath()
|
||||
call will fail silently.
|
||||
|
||||
The runpath select with this call will remain the currently
|
||||
active runpath for the remaining part of this program
|
||||
invocation.
|
||||
*/
|
||||
if (update_done) {
|
||||
enkf_main_set_fs( enkf_main , target_fs , target_fs_name);
|
||||
model_config_select_runpath( enkf_main_get_model_config( enkf_main ) , RERUN_PATH_KEY );
|
||||
enkf_main_run_step(enkf_main , ENSEMBLE_EXPERIMENT , iactive , 0 , 0 , ANALYZED , UNDEFINED , 0 , 0 );
|
||||
} else
|
||||
fprintf(stderr,"** Warning: the analysis update failed - no rerun started.\n");
|
||||
}
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
} else
|
||||
fprintf(stderr,"** ERROR: The normal smoother should not be combined with an iterable analysis module\n");
|
||||
}
|
||||
|
||||
void enkf_main_iterate_smoother(enkf_main_type * enkf_main, int step2, int iteration_number, analysis_iter_config_type * iter_config, int_vector_type * step_list, bool_vector_type * iactive, model_config_type * model_config){
|
||||
|
||||
bool enkf_main_iterate_smoother(enkf_main_type * enkf_main, int step2, int iteration_number, analysis_iter_config_type * iter_config, int_vector_type * step_list, bool_vector_type * iactive, model_config_type * model_config){
|
||||
const char * target_fs_name = analysis_iter_config_iget_case( iter_config , iteration_number+1 );
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
const int step1 = 0;
|
||||
bool updateOK = false;
|
||||
|
||||
if (target_fs_name == NULL){
|
||||
fprintf(stderr,"Sorry: the updated ensemble will overwrite the current case in the iterated ensemble smoother.");
|
||||
enkf_main_smoother_update(enkf_main , step_list , enkf_main_get_fs(enkf_main));
|
||||
}
|
||||
else{
|
||||
updateOK = enkf_main_smoother_update(enkf_main , step_list , enkf_main_get_fs(enkf_main));
|
||||
} else {
|
||||
enkf_fs_type * target_fs = enkf_main_get_alt_fs(enkf_main , target_fs_name , false , true );
|
||||
enkf_main_smoother_update(enkf_main , step_list , target_fs );
|
||||
updateOK = enkf_main_smoother_update(enkf_main , step_list , target_fs );
|
||||
enkf_main_set_fs(enkf_main , target_fs , enkf_fs_get_case_name( target_fs ));
|
||||
cases_config_set_int(enkf_fs_get_cases_config(target_fs), "iteration_number", iteration_number+1);
|
||||
}
|
||||
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
const char * runpath_fmt = analysis_iter_config_iget_runpath_fmt( iter_config , iteration_number);
|
||||
if (runpath_fmt != NULL) {
|
||||
char * runpath_key = util_alloc_sprintf( "runpath-%d" , 999);
|
||||
model_config_add_runpath( model_config , runpath_key , runpath_fmt);
|
||||
model_config_select_runpath( model_config , runpath_key );
|
||||
free( runpath_key );
|
||||
if (updateOK) {
|
||||
const char * runpath_fmt = analysis_iter_config_iget_runpath_fmt(iter_config, iteration_number);
|
||||
if (runpath_fmt != NULL ) {
|
||||
char * runpath_key = util_alloc_sprintf("runpath-%d", 999);
|
||||
model_config_add_runpath(model_config, runpath_key, runpath_fmt);
|
||||
model_config_select_runpath(model_config, runpath_key);
|
||||
free(runpath_key);
|
||||
}
|
||||
enkf_main_run_exp(enkf_main , iactive , true , step1 , step1 , FORECAST, false);
|
||||
}
|
||||
|
||||
enkf_main_run_exp(enkf_main , iactive , true , step1 , step1 , FORECAST, false);
|
||||
|
||||
return updateOK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void enkf_main_run_iterated_ES(enkf_main_type * enkf_main, int step2) {
|
||||
{
|
||||
const int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
model_config_type * model_config = enkf_main_get_model_config( enkf_main );
|
||||
const analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
analysis_iter_config_type * iter_config = analysis_config_get_iter_config( analysis_config );
|
||||
const int step1 = 0;
|
||||
int_vector_type * step_list = int_vector_alloc(0,0);
|
||||
bool_vector_type * iactive = bool_vector_alloc(0 , true);
|
||||
int iter = 0;
|
||||
int num_iter = analysis_iter_config_get_num_iterations( iter_config );
|
||||
{
|
||||
for (int step=step1; step <= step2; step++)
|
||||
int_vector_append( step_list , step );
|
||||
}
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
const char * runpath_fmt = analysis_iter_config_iget_runpath_fmt( iter_config , iter);
|
||||
if (runpath_fmt != NULL) {
|
||||
char * runpath_key = util_alloc_sprintf( "runpath-%d" , iter);
|
||||
model_config_add_runpath( model_config , runpath_key , runpath_fmt);
|
||||
model_config_select_runpath( model_config , runpath_key );
|
||||
free( runpath_key );
|
||||
}
|
||||
enkf_main_run_exp(enkf_main , iactive , true , step1 , step1 , FORECAST, true);
|
||||
while (true) {
|
||||
if (iter == num_iter)
|
||||
break;
|
||||
|
||||
enkf_main_iterate_smoother(enkf_main, step2, iter, iter_config, step_list, iactive, model_config);
|
||||
iter++;
|
||||
}
|
||||
int_vector_free( step_list );
|
||||
bool_vector_free( iactive );
|
||||
}
|
||||
const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
|
||||
|
||||
if (analysis_config_get_module_option( analysis_config , ANALYSIS_ITERABLE)) {
|
||||
const int ens_size = enkf_main_get_ensemble_size(enkf_main);
|
||||
model_config_type * model_config = enkf_main_get_model_config(enkf_main);
|
||||
analysis_iter_config_type * iter_config = analysis_config_get_iter_config(analysis_config);
|
||||
int_vector_type * step_list = int_vector_alloc(0, 0);
|
||||
bool_vector_type * iactive = bool_vector_alloc(ens_size , true);
|
||||
|
||||
|
||||
const int step1 = 0;
|
||||
int iter = 0;
|
||||
int num_iter = analysis_iter_config_get_num_iterations(iter_config);
|
||||
{
|
||||
for (int step = step1; step <= step2; step++)
|
||||
int_vector_append(step_list, step);
|
||||
}
|
||||
|
||||
{
|
||||
const char * runpath_fmt = analysis_iter_config_iget_runpath_fmt(iter_config, iter);
|
||||
if (runpath_fmt != NULL )
|
||||
{
|
||||
char * runpath_key = util_alloc_sprintf("runpath-%d", iter);
|
||||
model_config_add_runpath(model_config, runpath_key, runpath_fmt);
|
||||
model_config_select_runpath(model_config, runpath_key);
|
||||
free(runpath_key);
|
||||
}
|
||||
}
|
||||
|
||||
enkf_main_run_exp(enkf_main, iactive, true, step1, step1, FORECAST, true);
|
||||
while (true)
|
||||
{
|
||||
if (iter == num_iter)
|
||||
break;
|
||||
|
||||
if (enkf_main_iterate_smoother(enkf_main, step2, iter, iter_config, step_list, iactive, model_config))
|
||||
iter++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
int_vector_free(step_list);
|
||||
bool_vector_free(iactive);
|
||||
} else
|
||||
fprintf(stderr,"** ERROR: The current analysis module:%s can not be used for iterations \n",
|
||||
analysis_config_get_active_module_name( analysis_config ));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void enkf_main_run_one_more_iteration(enkf_main_type * enkf_main, int step2) {
|
||||
model_config_type * model_config = enkf_main_get_model_config( enkf_main );
|
||||
const analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
@ -2466,13 +2630,14 @@ void enkf_main_update_node( enkf_main_type * enkf_main , const char * key ) {
|
||||
//}
|
||||
|
||||
|
||||
/*
|
||||
void enkf_main_create_fs( enkf_main_type * enkf_main , const char * fs_path) {
|
||||
fs_driver_impl driver_id = model_config_get_dbase_type( enkf_main->model_config );
|
||||
void * arg = NULL;
|
||||
|
||||
enkf_fs_create_fs( fs_path , driver_id , arg );
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
static void enkf_main_link_current_fs__( enkf_main_type * enkf_main , const char * case_path) {
|
||||
const char * ens_path = model_config_get_enspath( enkf_main->model_config);
|
||||
@ -2609,13 +2774,13 @@ stringlist_type * enkf_main_alloc_caselist( const enkf_main_type * enkf_main ) {
|
||||
}
|
||||
|
||||
|
||||
void enkf_main_close_alt_fs(enkf_main_type * enkf_main , enkf_fs_type * fs) {
|
||||
void enkf_main_close_alt_fs(const enkf_main_type * enkf_main , enkf_fs_type * fs) {
|
||||
if (fs != enkf_main->dbase)
|
||||
enkf_fs_close( fs );
|
||||
}
|
||||
|
||||
|
||||
enkf_fs_type * enkf_main_get_alt_fs(enkf_main_type * enkf_main , const char * case_path , bool read_only , bool create) {
|
||||
enkf_fs_type * enkf_main_get_alt_fs(const enkf_main_type * enkf_main , const char * case_path , bool read_only , bool create) {
|
||||
enkf_fs_type * alt_fs = enkf_main->dbase;
|
||||
if (case_path != NULL) {
|
||||
char * new_mount_point = enkf_main_alloc_mount_point( enkf_main , case_path );
|
||||
@ -2975,7 +3140,7 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo
|
||||
util_alloc_file_components(_model_config , &path , &base , &ext);
|
||||
|
||||
if (path != NULL) {
|
||||
if (chdir(path) != 0)
|
||||
if (util_chdir(path) != 0)
|
||||
util_abort("%s: failed to change directory to: %s : %s \n",__func__ , path , strerror(errno));
|
||||
|
||||
if (verbose)
|
||||
@ -3239,6 +3404,11 @@ enkf_state_type ** enkf_main_get_ensemble( enkf_main_type * enkf_main) {
|
||||
}
|
||||
|
||||
|
||||
const enkf_state_type ** enkf_main_get_ensemble_const( const enkf_main_type * enkf_main) {
|
||||
return (const enkf_state_type **) enkf_main->ensemble;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
In this function we initialize the variables which control
|
||||
@ -3439,7 +3609,7 @@ int enkf_main_get_observation_count( const enkf_main_type * enkf_main, const cha
|
||||
all realizations will be checked).
|
||||
*/
|
||||
|
||||
bool enkf_main_is_initialized( const enkf_main_type * enkf_main , bool_vector_type * __mask) {
|
||||
static bool enkf_main_case_is_initialized__( const enkf_main_type * enkf_main , enkf_fs_type * fs , bool_vector_type * __mask) {
|
||||
stringlist_type * parameter_keys = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER );
|
||||
bool_vector_type * mask;
|
||||
bool initialized = true;
|
||||
@ -3449,18 +3619,18 @@ bool enkf_main_is_initialized( const enkf_main_type * enkf_main , bool_vector_ty
|
||||
else
|
||||
mask = bool_vector_alloc(0 , true );
|
||||
|
||||
do {
|
||||
while ((ikey < stringlist_get_size( parameter_keys )) && (initialized)) {
|
||||
const enkf_config_node_type * config_node = ensemble_config_get_node( enkf_main->ensemble_config , stringlist_iget( parameter_keys , ikey) );
|
||||
int iens = 0;
|
||||
do {
|
||||
if (bool_vector_safe_iget( mask , iens)) {
|
||||
node_id_type node_id = {.report_step = 0 , .iens = iens , .state = ANALYZED };
|
||||
initialized = enkf_config_node_has_node( config_node , enkf_main->dbase , node_id);
|
||||
initialized = enkf_config_node_has_node( config_node , fs , node_id);
|
||||
}
|
||||
iens++;
|
||||
} while ((iens < enkf_main->ens_size) && (initialized));
|
||||
ikey++;
|
||||
} while ((ikey < stringlist_get_size( parameter_keys )) && (initialized));
|
||||
}
|
||||
|
||||
stringlist_free( parameter_keys );
|
||||
if (__mask == NULL)
|
||||
@ -3469,6 +3639,19 @@ bool enkf_main_is_initialized( const enkf_main_type * enkf_main , bool_vector_ty
|
||||
}
|
||||
|
||||
|
||||
bool enkf_main_is_initialized( const enkf_main_type * enkf_main , bool_vector_type * __mask) {
|
||||
return enkf_main_case_is_initialized__(enkf_main , enkf_main->dbase , __mask);
|
||||
}
|
||||
|
||||
bool enkf_main_case_is_initialized( const enkf_main_type * enkf_main , const char * case_name , bool_vector_type * __mask) {
|
||||
enkf_fs_type * fs = enkf_main_get_alt_fs(enkf_main , case_name , true , false);
|
||||
if (fs) {
|
||||
bool initialized = enkf_main_case_is_initialized__(enkf_main , fs , __mask);
|
||||
enkf_main_close_alt_fs(enkf_main , fs);
|
||||
return initialized;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void enkf_main_log_fprintf_config( const enkf_main_type * enkf_main , FILE * stream ) {
|
||||
|
@ -66,6 +66,28 @@ void * enkf_main_smoother_JOB( void * self , const stringlist_type * args ) {
|
||||
}
|
||||
|
||||
|
||||
void * enkf_main_iterated_smoother_JOB( void * self , const stringlist_type * args ) {
|
||||
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
|
||||
int ens_size = enkf_main_get_ensemble_size( enkf_main );
|
||||
bool_vector_type * iactive = bool_vector_alloc( 0 , true );
|
||||
int last_step = enkf_main_get_history_length( enkf_main );
|
||||
|
||||
bool_vector_iset( iactive , ens_size - 1 , true );
|
||||
enkf_main_run_iterated_ES( enkf_main , last_step);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void * enkf_main_select_module_JOB( void * self , const stringlist_type * args ) {
|
||||
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
|
||||
analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main );
|
||||
|
||||
analysis_config_select_module( analysis_config , stringlist_iget( args , 0 ));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void * enkf_main_create_reports_JOB(void * self , const stringlist_type * args ) {
|
||||
enkf_main_type * enkf_main = enkf_main_safe_cast( self );
|
||||
|
166
ThirdParty/Ert/devel/libenkf/src/enkf_obs.c
vendored
166
ThirdParty/Ert/devel/libenkf/src/enkf_obs.c
vendored
@ -40,6 +40,8 @@
|
||||
#include <ert/enkf/enkf_obs.h>
|
||||
#include <ert/enkf/enkf_defaults.h>
|
||||
#include <ert/enkf/config_keys.h>
|
||||
#include <ert/enkf/local_obsdata_node.h>
|
||||
#include <ert/enkf/local_obsdata.h>
|
||||
|
||||
/*
|
||||
|
||||
@ -264,17 +266,18 @@ obs_vector_type * enkf_obs_get_vector(const enkf_obs_type * obs, const char * ke
|
||||
static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf_obs,
|
||||
obs_vector_type * obs_vector ,
|
||||
enkf_fs_type * fs,
|
||||
const int_vector_type * step_list ,
|
||||
const local_obsdata_node_type * obs_node ,
|
||||
state_enum state,
|
||||
const int_vector_type * ens_active_list ,
|
||||
const enkf_state_type ** ensemble ,
|
||||
meas_data_type * meas_data,
|
||||
obs_data_type * obs_data,
|
||||
const local_obsset_type * obsset ,
|
||||
double_vector_type * obs_value ,
|
||||
double_vector_type * obs_std) {
|
||||
|
||||
const active_list_type * active_list = local_obsset_get_obs_active_list( obsset , obs_vector_get_obs_key( obs_vector ));
|
||||
|
||||
const obs_tstep_list_type * tstep_list = local_obsdata_node_get_tstep_list( obs_node );
|
||||
const active_list_type * active_list = local_obsdata_node_get_active_list( obs_node );
|
||||
|
||||
matrix_type * error_covar = NULL;
|
||||
int active_count = 0;
|
||||
int last_step = -1;
|
||||
@ -284,8 +287,8 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf
|
||||
double_vector_reset( obs_std );
|
||||
double_vector_reset( obs_value );
|
||||
|
||||
for (int i = 0; i < int_vector_size( step_list ); i++) {
|
||||
step = int_vector_iget( step_list , i );
|
||||
for (int i = 0; i < obs_tstep_list_get_size( tstep_list ); i++) {
|
||||
step = obs_tstep_list_iget( tstep_list , i );
|
||||
if (obs_vector_iget_active( obs_vector , step ) && active_list_iget( active_list , 0 /* Index into the scalar summary observation */)) {
|
||||
{
|
||||
const summary_obs_type * summary_obs = obs_vector_iget_node( obs_vector , step );
|
||||
@ -323,8 +326,8 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf
|
||||
}
|
||||
{
|
||||
char * filename = util_alloc_sprintf( "/tmp/covar/%s_%04d-%04d" , obs_vector_get_obs_key( obs_vector ),
|
||||
int_vector_iget( step_list , 0 ),
|
||||
int_vector_get_last( step_list ));
|
||||
obs_tstep_list_iget( tstep_list , 0 ),
|
||||
obs_tstep_list_get_last( tstep_list ));
|
||||
FILE * stream = util_mkdir_fopen( filename , "w");
|
||||
|
||||
matrix_fprintf(error_covar , "%7.3f " , stream );
|
||||
@ -343,14 +346,14 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf
|
||||
|
||||
{
|
||||
obs_block_type * obs_block = obs_data_add_block( obs_data , obs_vector_get_obs_key( obs_vector ) , active_count , error_covar , true);
|
||||
meas_block_type * meas_block = meas_data_add_block( meas_data, obs_vector_get_obs_key( obs_vector ) , int_vector_get_last( step_list ) , active_count );
|
||||
meas_block_type * meas_block = meas_data_add_block( meas_data, obs_vector_get_obs_key( obs_vector ) , obs_tstep_list_get_last( tstep_list ) , active_count );
|
||||
|
||||
for (int i=0; i < active_count; i++)
|
||||
obs_block_iset( obs_block , i , double_vector_iget( obs_value , i) , double_vector_iget( obs_std , i ));
|
||||
|
||||
active_count = 0;
|
||||
for (int i = 0; i < int_vector_size( step_list ); i++) {
|
||||
int step = int_vector_iget( step_list , i );
|
||||
for (int i = 0; i < obs_tstep_list_get_size( tstep_list ); i++) {
|
||||
int step = obs_tstep_list_iget( tstep_list , i );
|
||||
if (obs_vector_iget_active( obs_vector , step ) && active_list_iget( active_list , 0 /* Index into the scalar summary observation */)) {
|
||||
|
||||
for (int iens_index = 0; iens_index < int_vector_size( ens_active_list ); iens_index++) {
|
||||
@ -375,7 +378,54 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf
|
||||
}
|
||||
}
|
||||
|
||||
void enkf_obs_get_obs_and_measure_node( const enkf_obs_type * enkf_obs,
|
||||
enkf_fs_type * fs,
|
||||
const local_obsdata_node_type * obs_node ,
|
||||
state_enum state,
|
||||
const int_vector_type * ens_active_list ,
|
||||
const enkf_state_type ** ensemble ,
|
||||
meas_data_type * meas_data,
|
||||
obs_data_type * obs_data) {
|
||||
|
||||
const char * obs_key = local_obsdata_node_get_key( obs_node );
|
||||
obs_vector_type * obs_vector = hash_get( enkf_obs->obs_hash , obs_key );
|
||||
obs_impl_type obs_type = obs_vector_get_impl_type( obs_vector );
|
||||
double_vector_type * work_value = double_vector_alloc( 0 , -1 );
|
||||
double_vector_type * work_std = double_vector_alloc( 0 , -1 );
|
||||
|
||||
if ((obs_type == SUMMARY_OBS)) //&& ((end_step - start_step) > 1))
|
||||
enkf_obs_get_obs_and_measure_summary( enkf_obs ,
|
||||
obs_vector ,
|
||||
fs ,
|
||||
obs_node ,
|
||||
state ,
|
||||
ens_active_list ,
|
||||
ensemble ,
|
||||
meas_data ,
|
||||
obs_data ,
|
||||
work_value,
|
||||
work_std);
|
||||
else {
|
||||
const obs_tstep_list_type * tstep_list = local_obsdata_node_get_tstep_list( obs_node );
|
||||
for (int i=0; i < obs_tstep_list_get_size( tstep_list ); i++) {
|
||||
int report_step = obs_tstep_list_iget( tstep_list , i );
|
||||
if (obs_vector_iget_active(obs_vector , report_step)) { /* The observation is active for this report step. */
|
||||
const active_list_type * active_list = local_obsdata_node_get_active_list( obs_node );
|
||||
obs_vector_iget_observations(obs_vector , report_step , obs_data , active_list); /* Collect the observed data in the obs_data instance. */
|
||||
{
|
||||
/* Could be multithreaded */
|
||||
for (int iens_index = 0; iens_index < int_vector_size( ens_active_list ); iens_index++) {
|
||||
const int iens = int_vector_iget( ens_active_list , iens_index );
|
||||
obs_vector_measure(obs_vector , fs , state , report_step , iens_index , ensemble[iens] , meas_data , active_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double_vector_free( work_value );
|
||||
double_vector_free( work_std );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -385,6 +435,32 @@ static void enkf_obs_get_obs_and_measure_summary(const enkf_obs_type * enkf
|
||||
Call obs_data_reset and meas_data_reset on obs_data and meas_data
|
||||
if you want to use fresh instances.
|
||||
*/
|
||||
|
||||
void enkf_obs_get_obs_and_measure_data(const enkf_obs_type * enkf_obs,
|
||||
enkf_fs_type * fs,
|
||||
const local_obsdata_type * local_obsdata ,
|
||||
state_enum state,
|
||||
const int_vector_type * ens_active_list ,
|
||||
const enkf_state_type ** ensemble ,
|
||||
meas_data_type * meas_data,
|
||||
obs_data_type * obs_data) {
|
||||
|
||||
|
||||
int iobs;
|
||||
for (iobs = 0; iobs < local_obsdata_get_size( local_obsdata ); iobs++) {
|
||||
const local_obsdata_node_type * obs_node = local_obsdata_iget( local_obsdata , iobs );
|
||||
enkf_obs_get_obs_and_measure_node( enkf_obs ,
|
||||
fs ,
|
||||
obs_node ,
|
||||
state ,
|
||||
ens_active_list ,
|
||||
ensemble ,
|
||||
meas_data ,
|
||||
obs_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void enkf_obs_get_obs_and_measure(const enkf_obs_type * enkf_obs,
|
||||
enkf_fs_type * fs,
|
||||
const int_vector_type * step_list ,
|
||||
@ -395,51 +471,30 @@ void enkf_obs_get_obs_and_measure(const enkf_obs_type * enkf_obs,
|
||||
obs_data_type * obs_data,
|
||||
const local_obsset_type * obsset) {
|
||||
|
||||
double_vector_type * work_value = double_vector_alloc( 0 , -1 );
|
||||
double_vector_type * work_std = double_vector_alloc( 0 , -1 );
|
||||
|
||||
hash_iter_type * iter = local_obsset_alloc_obs_iter( obsset );
|
||||
while ( !hash_iter_is_complete(iter) ) {
|
||||
const char * obs_key = hash_iter_get_next_key( iter );
|
||||
obs_vector_type * obs_vector = hash_get( enkf_obs->obs_hash , obs_key );
|
||||
obs_impl_type obs_type = obs_vector_get_impl_type( obs_vector );
|
||||
if ((obs_type == SUMMARY_OBS)) //&& ((end_step - start_step) > 1))
|
||||
/* The measure_summary() function fails for normal non-merged EnKF updates. */
|
||||
enkf_obs_get_obs_and_measure_summary( enkf_obs ,
|
||||
obs_vector ,
|
||||
fs ,
|
||||
step_list ,
|
||||
state ,
|
||||
ens_active_list ,
|
||||
ensemble ,
|
||||
meas_data ,
|
||||
obs_data ,
|
||||
obsset ,
|
||||
work_value,
|
||||
work_std);
|
||||
|
||||
else {
|
||||
for (int i=0; i < int_vector_size( step_list ); i++) {
|
||||
int report_step = int_vector_iget( step_list , i );
|
||||
if (obs_vector_iget_active(obs_vector , report_step)) { /* The observation is active for this report step. */
|
||||
const active_list_type * active_list = local_obsset_get_obs_active_list( obsset , obs_key );
|
||||
obs_vector_iget_observations(obs_vector , report_step , obs_data , active_list); /* Collect the observed data in the obs_data instance. */
|
||||
/* Could be multithreaded */
|
||||
for (int iens_index = 0; iens_index < int_vector_size( ens_active_list ); iens_index++) {
|
||||
const int iens = int_vector_iget( ens_active_list , iens_index );
|
||||
obs_vector_measure(obs_vector , fs , state , report_step , iens_index , ensemble[iens] , meas_data , active_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
local_obsdata_type * local_obsdata = local_obsdata_alloc( "OBS-SET" );
|
||||
{
|
||||
hash_iter_type * iter = local_obsset_alloc_obs_iter( obsset );
|
||||
while ( !hash_iter_is_complete(iter) ) {
|
||||
const char * obs_key = hash_iter_get_next_key( iter );
|
||||
const active_list_type * active_list = local_obsset_get_obs_active_list( obsset , obs_key);
|
||||
local_obsdata_node_type * obs_node = local_obsdata_node_alloc( obs_key );
|
||||
|
||||
local_obsdata_node_copy_active_list( obs_node , active_list );
|
||||
for (int i=0; i < int_vector_size( step_list ); i++)
|
||||
local_obsdata_node_add_tstep( obs_node , int_vector_iget( step_list , i ));
|
||||
|
||||
local_obsdata_add_node( local_obsdata , obs_node );
|
||||
}
|
||||
hash_iter_free( iter );
|
||||
}
|
||||
hash_iter_free(iter);
|
||||
double_vector_free( work_value );
|
||||
double_vector_free( work_std );
|
||||
enkf_obs_get_obs_and_measure_data(enkf_obs , fs , local_obsdata , state , ens_active_list , ensemble , meas_data , obs_data );
|
||||
local_obsdata_free( local_obsdata );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void enkf_obs_reload( enkf_obs_type * enkf_obs ,
|
||||
const history_type * history ,
|
||||
const ecl_grid_type * grid ,
|
||||
@ -948,6 +1003,17 @@ stringlist_type * enkf_obs_alloc_matching_keylist(const enkf_obs_type * enkf_obs
|
||||
}
|
||||
|
||||
|
||||
stringlist_type * enkf_obs_alloc_keylist(enkf_obs_type * enkf_obs ) {
|
||||
stringlist_type * vars = stringlist_alloc_new();
|
||||
hash_iter_type * iter = hash_iter_alloc(enkf_obs->obs_hash);
|
||||
const char * key = hash_iter_get_next_key(iter);
|
||||
while ( key != NULL) {
|
||||
stringlist_append_copy(vars , key);
|
||||
key = hash_iter_get_next_key(iter);
|
||||
}
|
||||
hash_iter_free(iter);
|
||||
return vars;
|
||||
}
|
||||
|
||||
/**
|
||||
This function allocates a hash table which looks like this:
|
||||
|
100
ThirdParty/Ert/devel/libenkf/src/enkf_state.c
vendored
100
ThirdParty/Ert/devel/libenkf/src/enkf_state.c
vendored
@ -299,10 +299,10 @@ void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs , co
|
||||
{
|
||||
if (enkf_node_initialize(param_node, iens, enkf_state->rng)) {
|
||||
enkf_node_store(param_node, fs, true, node_id);
|
||||
state_map_iset(state_map , iens , STATE_INITIALIZED);
|
||||
}
|
||||
}
|
||||
}
|
||||
state_map_update_matching(state_map , iens , STATE_UNDEFINED | STATE_LOAD_FAILURE , STATE_INITIALIZED);
|
||||
enkf_fs_fsync(fs);
|
||||
}
|
||||
}
|
||||
@ -712,7 +712,6 @@ static bool enkf_state_internalize_dynamic_eclipse_results(enkf_state_type * enk
|
||||
{
|
||||
/* Looking for summary files on disk, and loading them. */
|
||||
ecl_sum_type * summary = enkf_state_load_ecl_sum( enkf_state , msg_list , result );
|
||||
|
||||
/** OK - now we have actually loaded the ecl_sum instance, or ecl_sum == NULL. */
|
||||
if (summary != NULL) {
|
||||
|
||||
@ -787,6 +786,7 @@ static bool enkf_state_internalize_dynamic_results(enkf_state_type * enkf_state
|
||||
bool eclipse_load = enkf_state_internalize_dynamic_eclipse_results( enkf_state , fs , model_config , result, interactive , msg_list);
|
||||
if (!eclipse_load)
|
||||
fprintf(stderr , "** Warning: could not load ECLIPSE summary data from %s - this will probably fail later ...\n" , enkf_state->run_info->run_path);
|
||||
|
||||
return eclipse_load;
|
||||
} else
|
||||
return false;
|
||||
@ -1765,7 +1765,7 @@ static void enkf_state_init_eclipse(enkf_state_type *enkf_state, enkf_fs_type *
|
||||
|
||||
bool enkf_state_complete_forward_modelOK__(void * arg );
|
||||
bool enkf_state_complete_forward_modelEXIT__(void * arg );
|
||||
|
||||
bool enkf_state_complete_forward_modelRETRY__(void * arg );
|
||||
|
||||
static void enkf_state_start_forward_model(enkf_state_type * enkf_state , enkf_fs_type * fs) {
|
||||
run_info_type * run_info = enkf_state->run_info;
|
||||
@ -1776,6 +1776,8 @@ static void enkf_state_start_forward_model(enkf_state_type * enkf_state , enkf_f
|
||||
enkf_state_init_eclipse( enkf_state , fs );
|
||||
|
||||
if (run_info->run_mode != INIT_ONLY) {
|
||||
// The job_queue_node will take ownership of this arg_pack; and destroy it when
|
||||
// the job_queue_node is discarded.
|
||||
arg_pack_type * load_arg = arg_pack_alloc();
|
||||
|
||||
/*
|
||||
@ -1787,7 +1789,8 @@ static void enkf_state_start_forward_model(enkf_state_type * enkf_state , enkf_f
|
||||
run_info->queue_index = job_queue_add_job_mt( shared_info->job_queue ,
|
||||
site_config_get_job_script( site_config ),
|
||||
enkf_state_complete_forward_modelOK__ ,
|
||||
enkf_state_complete_forward_modelEXIT__ ,
|
||||
enkf_state_complete_forward_modelRETRY__ ,
|
||||
enkf_state_complete_forward_modelEXIT__,
|
||||
load_arg ,
|
||||
ecl_config_get_num_cpu( shared_info->ecl_config ),
|
||||
run_info->run_path ,
|
||||
@ -2023,42 +2026,6 @@ static bool enkf_state_complete_forward_modelOK(enkf_state_type * enkf_state , e
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static bool enkf_state_complete_forward_modelEXIT(enkf_state_type * enkf_state , enkf_fs_type * fs) {
|
||||
const shared_info_type * shared_info = enkf_state->shared_info;
|
||||
run_info_type * run_info = enkf_state->run_info;
|
||||
const member_config_type * my_config = enkf_state->my_config;
|
||||
const int iens = member_config_get_iens( my_config );
|
||||
/*
|
||||
The external queue system has said that the job failed - we
|
||||
might give it another try from this scope, possibly involving a
|
||||
resampling.
|
||||
*/
|
||||
|
||||
if (enkf_state_can_retry( enkf_state )) {
|
||||
enkf_state_internal_retry( enkf_state , fs , false);
|
||||
return true;
|
||||
} else {
|
||||
/*
|
||||
No more attempts for this job.
|
||||
*/
|
||||
log_add_fmt_message( shared_info->logh , 1 , NULL , "[%03d:%04d-%04d] FAILED COMPLETELY." , iens , run_info->step1, run_info->step2);
|
||||
if (run_info->run_status != JOB_LOAD_FAILURE)
|
||||
run_info->run_status = JOB_RUN_FAILURE;
|
||||
{
|
||||
state_map_type * state_map = enkf_fs_get_state_map( fs );
|
||||
int iens = member_config_get_iens( enkf_state->my_config );
|
||||
state_map_iset( state_map , iens , STATE_LOAD_FAILURE );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool enkf_state_complete_forward_modelOK__(void * arg ) {
|
||||
enkf_state_type * enkf_state;
|
||||
enkf_fs_type * fs;
|
||||
@ -2067,31 +2034,62 @@ bool enkf_state_complete_forward_modelOK__(void * arg ) {
|
||||
enkf_state = arg_pack_iget_ptr( arg_pack , 0 );
|
||||
fs = arg_pack_iget_ptr( arg_pack , 1 );
|
||||
|
||||
{
|
||||
bool callbackOK = enkf_state_complete_forward_modelOK( enkf_state , fs );
|
||||
if (callbackOK)
|
||||
arg_pack_free( arg_pack );
|
||||
|
||||
return callbackOK;
|
||||
}
|
||||
return enkf_state_complete_forward_modelOK( enkf_state , fs );
|
||||
}
|
||||
|
||||
|
||||
bool enkf_state_complete_forward_modelEXIT__(void * arg ) {
|
||||
|
||||
static bool enkf_state_complete_forward_model_EXIT_handler__(enkf_state_type * enkf_state , enkf_fs_type * fs, bool is_retry) {
|
||||
const shared_info_type * shared_info = enkf_state->shared_info;
|
||||
run_info_type * run_info = enkf_state->run_info;
|
||||
const member_config_type * my_config = enkf_state->my_config;
|
||||
const int iens = member_config_get_iens( my_config );
|
||||
/*
|
||||
The external queue system has said that the job failed - we
|
||||
might give it another try from this scope, possibly involving a
|
||||
resampling.
|
||||
*/
|
||||
|
||||
if (is_retry) {
|
||||
if (enkf_state_can_retry(enkf_state)) {
|
||||
enkf_state_internal_retry(enkf_state, fs, false);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
log_add_fmt_message(shared_info->logh, 1, NULL, "[%03d:%04d-%04d] FAILED COMPLETELY.", iens, run_info->step1, run_info->step2);
|
||||
|
||||
if (run_info->run_status != JOB_LOAD_FAILURE)
|
||||
run_info->run_status = JOB_RUN_FAILURE;
|
||||
|
||||
state_map_type * state_map = enkf_fs_get_state_map(fs);
|
||||
int iens = member_config_get_iens(enkf_state->my_config);
|
||||
state_map_iset(state_map, iens, STATE_LOAD_FAILURE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool enkf_state_complete_forward_model_EXIT_handler(void * arg, bool allow_retry ) {
|
||||
enkf_state_type * enkf_state;
|
||||
enkf_fs_type * fs;
|
||||
{
|
||||
arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
|
||||
enkf_state = arg_pack_iget_ptr( arg_pack , 0 );
|
||||
fs = arg_pack_iget_ptr( arg_pack , 1 );
|
||||
arg_pack_free( arg_pack );
|
||||
}
|
||||
|
||||
return enkf_state_complete_forward_modelEXIT( enkf_state , fs );
|
||||
return enkf_state_complete_forward_model_EXIT_handler__( enkf_state , fs, allow_retry );
|
||||
}
|
||||
|
||||
|
||||
bool enkf_state_complete_forward_modelEXIT__(void * arg ) {
|
||||
return enkf_state_complete_forward_model_EXIT_handler(arg, false );
|
||||
}
|
||||
|
||||
bool enkf_state_complete_forward_modelRETRY__(void * arg ) {
|
||||
return enkf_state_complete_forward_model_EXIT_handler(arg, true );
|
||||
}
|
||||
|
||||
|
||||
void * enkf_state_start_forward_model__(void * arg) {
|
||||
@ -2115,8 +2113,6 @@ void enkf_state_invalidate_cache( enkf_state_type * enkf_state ) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
|
100
ThirdParty/Ert/devel/libenkf/src/local_obsdata.c
vendored
Normal file
100
ThirdParty/Ert/devel/libenkf/src/local_obsdata.c
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'local_obsdata.c'
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/vector.h>
|
||||
#include <ert/util/hash.h>
|
||||
|
||||
#include <ert/enkf/local_obsdata.h>
|
||||
|
||||
|
||||
#define LOCAL_OBSDATA_TYPE_ID 86331309
|
||||
|
||||
struct local_obsdata_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
hash_type * nodes_map;
|
||||
vector_type * nodes_list;
|
||||
char * name;
|
||||
};
|
||||
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( local_obsdata , LOCAL_OBSDATA_TYPE_ID )
|
||||
|
||||
local_obsdata_type * local_obsdata_alloc( const char * name) {
|
||||
local_obsdata_type * data = util_malloc( sizeof * data );
|
||||
UTIL_TYPE_ID_INIT( data , LOCAL_OBSDATA_TYPE_ID );
|
||||
data->nodes_list = vector_alloc_new();
|
||||
data->nodes_map = hash_alloc();
|
||||
data->name = util_alloc_string_copy( name );
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
local_obsdata_type * local_obsdata_alloc_wrapper( local_obsdata_node_type * node ) {
|
||||
local_obsdata_type * data = local_obsdata_alloc( local_obsdata_node_get_key( node ));
|
||||
local_obsdata_add_node( data , node );
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
void local_obsdata_free( local_obsdata_type * data ) {
|
||||
vector_free( data->nodes_list );
|
||||
hash_free( data->nodes_map );
|
||||
free( data->name );
|
||||
free( data );
|
||||
}
|
||||
|
||||
const char * local_obsdata_get_name( const local_obsdata_type * data) {
|
||||
return data->name;
|
||||
}
|
||||
|
||||
|
||||
int local_obsdata_get_size( const local_obsdata_type * data ) {
|
||||
return vector_get_size( data->nodes_list );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
The @data instance will assume ownership of the node; i.e. calling
|
||||
scope should NOT call local_obsdata_node_free().
|
||||
*/
|
||||
|
||||
bool local_obsdata_add_node( local_obsdata_type * data , local_obsdata_node_type * node ) {
|
||||
const char * key = local_obsdata_node_get_key( node );
|
||||
if (local_obsdata_has_node(data , key))
|
||||
return false;
|
||||
else {
|
||||
vector_append_owned_ref( data->nodes_list , node , local_obsdata_node_free__ );
|
||||
hash_insert_ref( data->nodes_map , key , node );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const local_obsdata_node_type * local_obsdata_iget( const local_obsdata_type * data , int index) {
|
||||
return vector_iget_const( data->nodes_list , index );
|
||||
}
|
||||
|
||||
|
||||
bool local_obsdata_has_node( const local_obsdata_type * data , const char * key) {
|
||||
return hash_has_key( data->nodes_map , key );
|
||||
}
|
96
ThirdParty/Ert/devel/libenkf/src/local_obsdata_node.c
vendored
Normal file
96
ThirdParty/Ert/devel/libenkf/src/local_obsdata_node.c
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'local_obsdata_node.c'
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/int_vector.h>
|
||||
|
||||
#include <ert/enkf/obs_tstep_list.h>
|
||||
#include <ert/enkf/local_obsdata_node.h>
|
||||
|
||||
|
||||
#define LOCAL_OBSDATA_NODE_TYPE_ID 84441309
|
||||
|
||||
struct local_obsdata_node_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
char * obs_key;
|
||||
active_list_type * active_list;
|
||||
obs_tstep_list_type * tstep_list;
|
||||
};
|
||||
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( local_obsdata_node , LOCAL_OBSDATA_NODE_TYPE_ID )
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION( local_obsdata_node , LOCAL_OBSDATA_NODE_TYPE_ID )
|
||||
|
||||
local_obsdata_node_type * local_obsdata_node_alloc( const char * obs_key ) {
|
||||
local_obsdata_node_type * node = util_malloc( sizeof * node );
|
||||
UTIL_TYPE_ID_INIT( node , LOCAL_OBSDATA_NODE_TYPE_ID );
|
||||
node->obs_key = util_alloc_string_copy( obs_key );
|
||||
node->active_list = active_list_alloc( );
|
||||
node->tstep_list = obs_tstep_list_alloc( );
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
void local_obsdata_node_copy_active_list( local_obsdata_node_type * node , const active_list_type * active_list) {
|
||||
active_list_copy( node->active_list , active_list );
|
||||
}
|
||||
|
||||
|
||||
const char * local_obsdata_node_get_key( const local_obsdata_node_type * node ) {
|
||||
return node->obs_key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void local_obsdata_node_free( local_obsdata_node_type * node ) {
|
||||
active_list_free( node->active_list );
|
||||
obs_tstep_list_free( node->tstep_list );
|
||||
free( node->obs_key );
|
||||
free( node );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void local_obsdata_node_free__( void * arg ) {
|
||||
local_obsdata_node_type * node = local_obsdata_node_safe_cast( arg );
|
||||
local_obsdata_node_free( node );
|
||||
}
|
||||
|
||||
|
||||
active_list_type * local_obsdata_node_get_active_list( const local_obsdata_node_type * node ) {
|
||||
return node->active_list;
|
||||
}
|
||||
|
||||
|
||||
const obs_tstep_list_type * local_obsdata_node_get_tstep_list( const local_obsdata_node_type * node) {
|
||||
return node->tstep_list;
|
||||
}
|
||||
|
||||
|
||||
void local_obsdata_node_add_tstep( local_obsdata_node_type * node, int tstep) {
|
||||
obs_tstep_list_add_tstep( node->tstep_list , tstep );
|
||||
}
|
||||
|
||||
|
||||
void local_obsdata_node_add_range( local_obsdata_node_type * node, int step1 , int step2) {
|
||||
obs_tstep_list_add_range( node->tstep_list , step1 , step2);
|
||||
}
|
101
ThirdParty/Ert/devel/libenkf/src/obs_tstep_list.c
vendored
Normal file
101
ThirdParty/Ert/devel/libenkf/src/obs_tstep_list.c
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'obs_tstep_list.c'
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/int_vector.h>
|
||||
|
||||
#include <ert/enkf/obs_tstep_list.h>
|
||||
|
||||
|
||||
#define OBS_TSTEP_LIST_TYPE_ID 84865209
|
||||
|
||||
struct obs_tstep_list_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
bool all_active;
|
||||
int_vector_type * tstep_list;
|
||||
};
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( obs_tstep_list , OBS_TSTEP_LIST_TYPE_ID )
|
||||
|
||||
|
||||
obs_tstep_list_type * obs_tstep_list_alloc() {
|
||||
obs_tstep_list_type * list = util_malloc( sizeof * list );
|
||||
UTIL_TYPE_ID_INIT( list , OBS_TSTEP_LIST_TYPE_ID );
|
||||
list->all_active = true;
|
||||
list->tstep_list = int_vector_alloc(0,0);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
void obs_tstep_list_free( obs_tstep_list_type * list ) {
|
||||
free( list );
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool obs_tstep_list_all_active( const obs_tstep_list_type * list ) {
|
||||
return list->all_active;
|
||||
}
|
||||
|
||||
|
||||
bool obs_tstep_list_contains( const obs_tstep_list_type * list , int tstep) {
|
||||
if (int_vector_index_sorted( list->tstep_list , tstep) == -1)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void obs_tstep_list_add_tstep( obs_tstep_list_type * list , int tstep) {
|
||||
if (!obs_tstep_list_contains( list , tstep)) {
|
||||
if (int_vector_size( list->tstep_list )) {
|
||||
int last = int_vector_get_last( list->tstep_list );
|
||||
int_vector_append( list->tstep_list , tstep );
|
||||
if (tstep < last)
|
||||
int_vector_sort( list->tstep_list);
|
||||
} else
|
||||
int_vector_append( list->tstep_list , tstep );
|
||||
}
|
||||
list->all_active = false;
|
||||
}
|
||||
|
||||
|
||||
void obs_tstep_list_add_range( obs_tstep_list_type * list , int step1 , int step2) {
|
||||
int tstep;
|
||||
for (tstep = step1; tstep <= step2; tstep++)
|
||||
obs_tstep_list_add_tstep( list , tstep );
|
||||
}
|
||||
|
||||
|
||||
int obs_tstep_list_get_size( const obs_tstep_list_type * list ) {
|
||||
return int_vector_size( list->tstep_list );
|
||||
}
|
||||
|
||||
|
||||
int obs_tstep_list_iget( const obs_tstep_list_type * list , int index) {
|
||||
return int_vector_iget( list->tstep_list , index);
|
||||
}
|
||||
|
||||
|
||||
int obs_tstep_list_get_last( const obs_tstep_list_type * list ) {
|
||||
return int_vector_get_last( list->tstep_list );
|
||||
}
|
98
ThirdParty/Ert/devel/libenkf/src/pca_plot_data.c
vendored
Normal file
98
ThirdParty/Ert/devel/libenkf/src/pca_plot_data.c
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
The file 'pca_plot_data.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/vector.h>
|
||||
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
#include <ert/enkf/pca_plot_vector.h>
|
||||
|
||||
#define PCA_PLOT_DATA_TYPE_ID 61442098
|
||||
|
||||
struct pca_plot_data_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
char * name;
|
||||
vector_type * pca_vectors;
|
||||
int ens_size;
|
||||
};
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( pca_plot_data , PCA_PLOT_DATA_TYPE_ID )
|
||||
static UTIL_SAFE_CAST_FUNCTION( pca_plot_data , PCA_PLOT_DATA_TYPE_ID )
|
||||
|
||||
static void pca_plot_data_add_vectors(pca_plot_data_type * plot_data , const matrix_type * PC , const matrix_type * PC_obs) {
|
||||
int component;
|
||||
for (component = 0; component < matrix_get_rows( PC ); component++) {
|
||||
pca_plot_vector_type * vector = pca_plot_vector_alloc( component , PC , PC_obs );
|
||||
vector_append_owned_ref( plot_data->pca_vectors , vector , pca_plot_vector_free__);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pca_plot_data_type * pca_plot_data_alloc( const char * name,
|
||||
const matrix_type * PC ,
|
||||
const matrix_type * PC_obs) {
|
||||
pca_plot_data_type * plot_data = NULL;
|
||||
|
||||
if (pca_plot_assert_input( PC , PC_obs)) {
|
||||
plot_data = util_malloc( sizeof * plot_data );
|
||||
UTIL_TYPE_ID_INIT( plot_data , PCA_PLOT_DATA_TYPE_ID );
|
||||
plot_data->name = util_alloc_string_copy( name );
|
||||
plot_data->pca_vectors = vector_alloc_new();
|
||||
plot_data->ens_size = matrix_get_columns( PC );
|
||||
pca_plot_data_add_vectors( plot_data , PC , PC_obs );
|
||||
}
|
||||
return plot_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void pca_plot_data_free( pca_plot_data_type * plot_data ) {
|
||||
vector_free( plot_data->pca_vectors );
|
||||
free( plot_data->name );
|
||||
free( plot_data );
|
||||
}
|
||||
|
||||
void pca_plot_data_free__( void * arg ) {
|
||||
pca_plot_data_type * plot_data = pca_plot_data_safe_cast( arg );
|
||||
pca_plot_data_free( plot_data );
|
||||
}
|
||||
|
||||
int pca_plot_data_get_size( const pca_plot_data_type * plot_data ) {
|
||||
return vector_get_size( plot_data->pca_vectors );
|
||||
}
|
||||
|
||||
|
||||
int pca_plot_data_get_ens_size( const pca_plot_data_type * plot_data ) {
|
||||
return plot_data->ens_size;
|
||||
}
|
||||
|
||||
const pca_plot_vector_type * pca_plot_data_iget_vector( const pca_plot_data_type * plot_data , int ivec) {
|
||||
return vector_iget_const( plot_data->pca_vectors , ivec );
|
||||
}
|
||||
|
||||
|
||||
const char * pca_plot_data_get_name( const pca_plot_data_type * plot_data ) {
|
||||
return plot_data->name;
|
||||
}
|
100
ThirdParty/Ert/devel/libenkf/src/pca_plot_vector.c
vendored
Normal file
100
ThirdParty/Ert/devel/libenkf/src/pca_plot_vector.c
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
The file 'pca_plot_vector.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/enkf/pca_plot_vector.h>
|
||||
|
||||
#define PCA_PLOT_VECTOR_TYPE_ID 61743098
|
||||
|
||||
struct pca_plot_vector_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
int size;
|
||||
double obs_value;
|
||||
double * sim_data;
|
||||
};
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( pca_plot_vector , PCA_PLOT_VECTOR_TYPE_ID )
|
||||
static UTIL_SAFE_CAST_FUNCTION( pca_plot_vector , PCA_PLOT_VECTOR_TYPE_ID )
|
||||
|
||||
bool pca_plot_assert_input( const matrix_type * PC, const matrix_type * PC_obs) {
|
||||
if ((matrix_get_rows(PC) == matrix_get_rows( PC_obs )) &&
|
||||
(matrix_get_columns(PC_obs) == 1))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static void pca_plot_vector_init_data( pca_plot_vector_type * plot_vector , int component, const matrix_type * PC , const matrix_type * PC_obs) {
|
||||
int iens;
|
||||
|
||||
for (iens = 0; iens < matrix_get_columns( PC ); iens++)
|
||||
plot_vector->sim_data[iens] = matrix_iget( PC, component , iens );
|
||||
|
||||
plot_vector->obs_value = matrix_iget( PC_obs , component , 0 );
|
||||
}
|
||||
|
||||
pca_plot_vector_type * pca_plot_vector_alloc( int component ,
|
||||
const matrix_type * PC ,
|
||||
const matrix_type * PC_obs) {
|
||||
pca_plot_vector_type * plot_vector = NULL;
|
||||
|
||||
if (pca_plot_assert_input( PC , PC_obs) && (component < matrix_get_rows( PC ))) {
|
||||
|
||||
plot_vector = util_malloc( sizeof * plot_vector );
|
||||
UTIL_TYPE_ID_INIT( plot_vector , PCA_PLOT_VECTOR_TYPE_ID );
|
||||
plot_vector->obs_value = matrix_iget( PC_obs , component , 0 );
|
||||
plot_vector->size = matrix_get_columns( PC );
|
||||
plot_vector->sim_data = util_calloc( plot_vector->size , sizeof * plot_vector->sim_data );
|
||||
pca_plot_vector_init_data( plot_vector , component , PC , PC_obs );
|
||||
}
|
||||
|
||||
return plot_vector;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void pca_plot_vector_free( pca_plot_vector_type * plot_vector ) {
|
||||
free( plot_vector->sim_data );
|
||||
free( plot_vector );
|
||||
}
|
||||
|
||||
|
||||
void pca_plot_vector_free__( void * arg ) {
|
||||
pca_plot_vector_type * vector = pca_plot_vector_safe_cast( arg );
|
||||
pca_plot_vector_free( vector );
|
||||
}
|
||||
|
||||
|
||||
int pca_plot_vector_get_size( const pca_plot_vector_type * vector ) {
|
||||
return vector->size;
|
||||
}
|
||||
|
||||
double pca_plot_vector_get_obs_value( const pca_plot_vector_type * vector ) {
|
||||
return vector->obs_value;
|
||||
}
|
||||
|
||||
|
||||
double pca_plot_vector_iget_sim_value( const pca_plot_vector_type * vector , int sim_index) {
|
||||
return vector->sim_data[ sim_index ];
|
||||
}
|
@ -42,7 +42,7 @@ scalar_config_type * scalar_config_alloc_empty(int size) {
|
||||
scalar_config_type *scalar_config = util_malloc(sizeof *scalar_config);
|
||||
UTIL_TYPE_ID_INIT( scalar_config , SCALAR_CONFIG_TYPE_ID );
|
||||
scalar_config->data_size = size;
|
||||
scalar_config->active_list = active_list_alloc( ALL_ACTIVE );
|
||||
scalar_config->active_list = active_list_alloc( );
|
||||
|
||||
scalar_config->transform = util_calloc(scalar_config->data_size , sizeof * scalar_config->transform );
|
||||
return scalar_config;
|
||||
|
12
ThirdParty/Ert/devel/libenkf/src/state_map.c
vendored
12
ThirdParty/Ert/devel/libenkf/src/state_map.c
vendored
@ -144,13 +144,21 @@ void state_map_iset( state_map_type * map ,int index , realisation_state_enum st
|
||||
pthread_rwlock_unlock( &map->rw_lock );
|
||||
}
|
||||
|
||||
void state_map_update_undefined( state_map_type * map , int index , realisation_state_enum new_state) {
|
||||
|
||||
void state_map_update_matching( state_map_type * map , int index , int state_mask , realisation_state_enum new_state) {
|
||||
realisation_state_enum current_state = state_map_iget( map , index );
|
||||
if (current_state == STATE_UNDEFINED)
|
||||
if (current_state & state_mask)
|
||||
state_map_iset( map , index , new_state );
|
||||
}
|
||||
|
||||
|
||||
void state_map_update_undefined( state_map_type * map , int index , realisation_state_enum new_state) {
|
||||
state_map_update_matching( map , index , STATE_UNDEFINED , new_state );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void state_map_fwrite( state_map_type * map , const char * filename) {
|
||||
pthread_rwlock_rdlock( &map->rw_lock );
|
||||
{
|
||||
|
@ -7,6 +7,9 @@ target_link_libraries( enkf_site_config enkf test_util )
|
||||
add_executable( enkf_time_map enkf_time_map.c )
|
||||
target_link_libraries( enkf_time_map enkf test_util )
|
||||
|
||||
add_executable( enkf_pca_plot enkf_pca_plot.c )
|
||||
target_link_libraries( enkf_pca_plot enkf test_util)
|
||||
add_test( enkf_pca_plot ${EXECUTABLE_OUTPUT_PATH}/enkf_pca_plot)
|
||||
|
||||
add_executable( enkf_cases_config enkf_cases_config.c )
|
||||
target_link_libraries( enkf_cases_config enkf test_util )
|
||||
@ -14,7 +17,14 @@ add_test( enkf_cases_config ${EXECUTABLE_OUTPUT_PATH}/enkf_cases_config )
|
||||
|
||||
add_executable( enkf_analysis_config enkf_analysis_config.c )
|
||||
target_link_libraries( enkf_analysis_config enkf test_util )
|
||||
add_test( enkf_analysis ${EXECUTABLE_OUTPUT_PATH}/enkf_analysis_config )
|
||||
add_test( enkf_analysis ${EXECUTABLE_OUTPUT_PATH}/enkf_analysis_config)
|
||||
|
||||
add_executable( enkf_analysis_config_ext_module enkf_analysis_config_ext_module.c )
|
||||
target_link_libraries( enkf_analysis_config_ext_module enkf test_util )
|
||||
add_test( enkf_analysis_config_ext_module ${EXECUTABLE_OUTPUT_PATH}/enkf_analysis_config_ext_module
|
||||
rml_enkf ${LIBRARY_OUTPUT_PATH}/rml_enkf.so
|
||||
rmli_enkf ${LIBRARY_OUTPUT_PATH}/rmli_enkf.so )
|
||||
|
||||
|
||||
add_executable( enkf_state_map enkf_state_map.c )
|
||||
target_link_libraries( enkf_state_map enkf test_util )
|
||||
@ -28,6 +38,22 @@ target_link_libraries( enkf_ensemble_GEN_PARAM enkf test_util )
|
||||
add_executable( enkf_ensemble enkf_ensemble.c )
|
||||
target_link_libraries( enkf_ensemble enkf test_util )
|
||||
|
||||
add_executable( enkf_local_obsdata_node enkf_local_obsdata_node.c )
|
||||
target_link_libraries( enkf_local_obsdata_node enkf test_util)
|
||||
add_test( enkf_local_obsdata_node ${EXECUTABLE_OUTPUT_PATH}/enkf_local_obsdata_node )
|
||||
|
||||
add_executable( enkf_local_obsdata enkf_local_obsdata.c )
|
||||
target_link_libraries( enkf_local_obsdata enkf test_util)
|
||||
add_test( enkf_local_obsdata ${EXECUTABLE_OUTPUT_PATH}/enkf_local_obsdata )
|
||||
|
||||
add_executable( enkf_active_list enkf_active_list.c )
|
||||
target_link_libraries( enkf_active_list enkf test_util)
|
||||
add_test( enkf_active_list ${EXECUTABLE_OUTPUT_PATH}/enkf_active_list )
|
||||
|
||||
add_executable( enkf_obs_tstep_list enkf_obs_tstep_list.c )
|
||||
target_link_libraries( enkf_obs_tstep_list enkf test_util)
|
||||
add_test( enkf_obs_tstep_list ${EXECUTABLE_OUTPUT_PATH}/enkf_obs_tstep_list )
|
||||
|
||||
add_executable( enkf_main enkf_main.c )
|
||||
target_link_libraries( enkf_main enkf test_util )
|
||||
add_test( enkf_main ${EXECUTABLE_OUTPUT_PATH}/enkf_main )
|
||||
|
65
ThirdParty/Ert/devel/libenkf/tests/enkf_active_list.c
vendored
Normal file
65
ThirdParty/Ert/devel/libenkf/tests/enkf_active_list.c
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'enkf_active_list.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/enkf/active_list.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
active_list_type * active_list1 = active_list_alloc( );
|
||||
active_list_type * active_list2 = active_list_alloc( );
|
||||
|
||||
|
||||
test_assert_true( active_list_is_instance( active_list1 ));
|
||||
|
||||
test_assert_true( active_list_equal( active_list1 , active_list2 ));
|
||||
|
||||
active_list_add_index( active_list1 , 11 );
|
||||
test_assert_false(active_list_equal( active_list1 , active_list2 ));
|
||||
|
||||
active_list_add_index( active_list1 , 12 );
|
||||
test_assert_false(active_list_equal( active_list1 , active_list2 ));
|
||||
|
||||
active_list_add_index( active_list2 , 11 );
|
||||
test_assert_false(active_list_equal( active_list1 , active_list2 ));
|
||||
|
||||
active_list_add_index( active_list2 , 12 );
|
||||
test_assert_true(active_list_equal( active_list1 , active_list2 ));
|
||||
|
||||
active_list_add_index( active_list2 , 13 );
|
||||
test_assert_false(active_list_equal( active_list1 , active_list2 ));
|
||||
|
||||
active_list_add_index( active_list1 , 13 );
|
||||
test_assert_true(active_list_equal( active_list1 , active_list2 ));
|
||||
|
||||
active_list_add_index( active_list2 , 27 );
|
||||
test_assert_false(active_list_equal( active_list1 , active_list2 ));
|
||||
active_list_copy( active_list1 , active_list2 );
|
||||
test_assert_true(active_list_equal( active_list1 , active_list2 ));
|
||||
|
||||
active_list_free( active_list1 );
|
||||
active_list_free( active_list2 );
|
||||
exit(0);
|
||||
}
|
||||
|
@ -73,11 +73,35 @@ void test_continue( ) {
|
||||
}
|
||||
|
||||
|
||||
void test_current_module_options() {
|
||||
analysis_config_type * ac = create_analysis_config( );
|
||||
test_assert_NULL( analysis_config_get_active_module( ac ));
|
||||
analysis_config_load_internal_module(ac , "STD_ENKF" , "std_enkf_symbol_table");
|
||||
|
||||
test_assert_false( analysis_config_get_module_option( ac , ANALYSIS_SCALE_DATA));
|
||||
test_assert_true(analysis_config_select_module(ac , "STD_ENKF"));
|
||||
test_assert_false( analysis_config_select_module(ac , "DOES_NOT_EXIST"));
|
||||
|
||||
test_assert_true( analysis_module_is_instance( analysis_config_get_active_module( ac )));
|
||||
test_assert_true( analysis_config_get_module_option( ac , ANALYSIS_SCALE_DATA));
|
||||
test_assert_false( analysis_config_get_module_option( ac , ANALYSIS_ITERABLE));
|
||||
analysis_config_free( ac );
|
||||
}
|
||||
|
||||
void test_stop_long_running( ) {
|
||||
analysis_config_type * ac = create_analysis_config( );
|
||||
test_assert_bool_equal( false , analysis_config_get_stop_long_running( ac ) );
|
||||
analysis_config_set_stop_long_running( ac , true );
|
||||
test_assert_bool_equal( true , analysis_config_get_stop_long_running( ac ) );
|
||||
analysis_config_free( ac );
|
||||
}
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_create();
|
||||
test_min_realisations();
|
||||
test_continue();
|
||||
test_current_module_options();
|
||||
test_stop_long_running();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
65
ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_config_ext_module.c
vendored
Normal file
65
ThirdParty/Ert/devel/libenkf/tests/enkf_analysis_config_ext_module.c
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'enkf_analysis_config_ext_module.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/rng.h>
|
||||
|
||||
#include <ert/enkf/analysis_config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/rng.h>
|
||||
|
||||
#include <ert/enkf/analysis_config.h>
|
||||
|
||||
|
||||
void test_load_external_module( analysis_config_type * ac , const char * user_name , const char * lib_name) {
|
||||
test_assert_true( analysis_config_load_external_module(ac , user_name , lib_name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
rng_type * rng = rng_alloc(MZRAN , INIT_DEFAULT);
|
||||
analysis_config_type * analysis_config = analysis_config_alloc(rng);
|
||||
|
||||
for (int i = 1; i < argc; i+= 2) {
|
||||
const char * user_name = argv[i];
|
||||
const char * lib_name = argv[i + 1];
|
||||
test_load_external_module( analysis_config , user_name , lib_name );
|
||||
}
|
||||
|
||||
analysis_config_free(analysis_config);
|
||||
rng_free( rng );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ int main(int argc , char ** argv) {
|
||||
const char * config_file = argv[2];
|
||||
const char * init_file = argv[3];
|
||||
const char * forward_init_string = argv[4];
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file , false);
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file );
|
||||
test_work_area_copy_directory_content( work_area , root_path );
|
||||
test_work_area_install_file( work_area , init_file );
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ int main(int argc , char ** argv) {
|
||||
const char * root_path = argv[1];
|
||||
const char * config_file = argv[2];
|
||||
const char * forward_init_string = argv[3];
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file , false);
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file );
|
||||
test_work_area_copy_directory_content( work_area , root_path );
|
||||
{
|
||||
bool forward_init;
|
||||
|
@ -48,7 +48,7 @@ int main(int argc , char ** argv) {
|
||||
const char * root_path = argv[1];
|
||||
const char * config_file = argv[2];
|
||||
const char * forward_init_string = argv[3];
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file , false);
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file );
|
||||
test_work_area_copy_directory_content( work_area , root_path );
|
||||
{
|
||||
bool forward_init;
|
||||
|
@ -49,7 +49,7 @@ int main(int argc , char ** argv) {
|
||||
const char * config_file = argv[2];
|
||||
const char * init_file = argv[3];
|
||||
const char * forward_init_string = argv[4];
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file , false);
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file );
|
||||
|
||||
test_work_area_copy_directory_content( work_area , root_path );
|
||||
test_work_area_install_file( work_area , init_file );
|
||||
|
63
ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata.c
vendored
Normal file
63
ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata.c
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'enkf_local_obsdata.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/enkf/local_obsdata.h>
|
||||
#include <ert/enkf/local_obsdata_node.h>
|
||||
|
||||
|
||||
void test_wrapper() {
|
||||
local_obsdata_node_type * node = local_obsdata_node_alloc("KEY");
|
||||
local_obsdata_type * data = local_obsdata_alloc_wrapper( node );
|
||||
test_assert_true( local_obsdata_is_instance( data ));
|
||||
test_assert_int_equal( 1 , local_obsdata_get_size( data ));
|
||||
test_assert_ptr_equal( node , local_obsdata_iget( data , 0 ));
|
||||
test_assert_true( local_obsdata_has_node( data , "KEY" ));
|
||||
test_assert_false( local_obsdata_has_node( data , "KEYX" ));
|
||||
test_assert_string_equal( local_obsdata_node_get_key( node ) , local_obsdata_get_name( data ));
|
||||
local_obsdata_free( data );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
local_obsdata_type * obsdata;
|
||||
|
||||
obsdata = local_obsdata_alloc( "KEY");
|
||||
test_assert_true( local_obsdata_is_instance( obsdata ));
|
||||
test_assert_int_equal( 0 , local_obsdata_get_size( obsdata ));
|
||||
test_assert_string_equal( "KEY" , local_obsdata_get_name( obsdata ));
|
||||
|
||||
{
|
||||
local_obsdata_node_type * obsnode = local_obsdata_node_alloc( "KEY" );
|
||||
test_assert_true( local_obsdata_add_node( obsdata , obsnode ) );
|
||||
test_assert_false( local_obsdata_add_node( obsdata , obsnode ) );
|
||||
test_assert_int_equal( 1 , local_obsdata_get_size( obsdata ));
|
||||
test_assert_ptr_equal( obsnode , local_obsdata_iget( obsdata , 0));
|
||||
}
|
||||
|
||||
local_obsdata_free( obsdata );
|
||||
|
||||
test_wrapper();
|
||||
exit(0);
|
||||
}
|
||||
|
79
ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata_node.c
vendored
Normal file
79
ThirdParty/Ert/devel/libenkf/tests/enkf_local_obsdata_node.c
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'enkf_local_obsdata_node.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/enkf/obs_tstep_list.h>
|
||||
#include <ert/enkf/local_obsdata_node.h>
|
||||
#include <ert/enkf/active_list.h>
|
||||
|
||||
|
||||
void test_content( local_obsdata_node_type * node ) {
|
||||
const active_list_type * active_list = local_obsdata_node_get_active_list( node );
|
||||
|
||||
test_assert_not_NULL( active_list );
|
||||
test_assert_true( active_list_is_instance( active_list ));
|
||||
test_assert_true( obs_tstep_list_is_instance( local_obsdata_node_get_tstep_list( node )));
|
||||
|
||||
{
|
||||
active_list_type * new_active_list = active_list_alloc( );
|
||||
|
||||
active_list_add_index( new_active_list , 1098 );
|
||||
|
||||
test_assert_false( active_list_equal( new_active_list , local_obsdata_node_get_active_list( node )));
|
||||
local_obsdata_node_copy_active_list( node , new_active_list );
|
||||
test_assert_true( active_list_equal( new_active_list , local_obsdata_node_get_active_list( node )));
|
||||
|
||||
}
|
||||
{
|
||||
const obs_tstep_list_type * tstep = local_obsdata_node_get_tstep_list( node );
|
||||
|
||||
local_obsdata_node_add_tstep( node , 10 );
|
||||
local_obsdata_node_add_tstep( node , 10 ); // Second add - ignored
|
||||
local_obsdata_node_add_tstep( node , 20 );
|
||||
|
||||
test_assert_int_equal( 2 , obs_tstep_list_get_size( tstep ));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * obs_key = "1234";
|
||||
|
||||
{
|
||||
local_obsdata_node_type * node = local_obsdata_node_alloc( obs_key );
|
||||
|
||||
test_assert_true( local_obsdata_node_is_instance( node ));
|
||||
test_assert_string_equal( obs_key , local_obsdata_node_get_key( node ));
|
||||
test_content( node );
|
||||
local_obsdata_node_free( node );
|
||||
}
|
||||
|
||||
{
|
||||
void * node = local_obsdata_node_alloc( obs_key );
|
||||
local_obsdata_node_free__( node );
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
40
ThirdParty/Ert/devel/libenkf/tests/enkf_main.c
vendored
40
ThirdParty/Ert/devel/libenkf/tests/enkf_main.c
vendored
@ -20,14 +20,46 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/test_work_area.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/enkf/enkf_main.h>
|
||||
#include <ert/enkf/model_config.h>
|
||||
|
||||
|
||||
|
||||
|
||||
void test_case_initialized() {
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf_main_case_initialized" );
|
||||
{
|
||||
enkf_main_type * enkf_main = enkf_main_alloc_empty();
|
||||
model_config_type * model_config = enkf_main_get_model_config(enkf_main);
|
||||
const char * new_case = "fs/case";
|
||||
char * mount_point = util_alloc_sprintf("%s/%s" , model_config_get_enspath(model_config) , new_case);
|
||||
enkf_fs_create_fs(mount_point , BLOCK_FS_DRIVER_ID , NULL);
|
||||
|
||||
test_assert_false(enkf_main_case_is_initialized(enkf_main , "does/not/exist" , NULL));
|
||||
test_assert_true(enkf_main_case_is_initialized(enkf_main , new_case , NULL));
|
||||
|
||||
enkf_main_free(enkf_main);
|
||||
}
|
||||
test_work_area_free(work_area);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_create() {
|
||||
enkf_main_type * enkf_main = enkf_main_alloc_empty();
|
||||
test_assert_true( enkf_main_is_instance( enkf_main ) );
|
||||
enkf_main_free( enkf_main );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
{
|
||||
enkf_main_type * enkf_main = enkf_main_alloc_empty();
|
||||
enkf_main_free( enkf_main );
|
||||
}
|
||||
test_create();
|
||||
test_case_initialized();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
84
ThirdParty/Ert/devel/libenkf/tests/enkf_obs_tstep_list.c
vendored
Normal file
84
ThirdParty/Ert/devel/libenkf/tests/enkf_obs_tstep_list.c
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'enkf_obs_tstep_list.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 <stdio.h>
|
||||
|
||||
#include <ert/enkf/obs_tstep_list.h>
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
|
||||
void test_range( ) {
|
||||
obs_tstep_list_type * tstep_list = obs_tstep_list_alloc();
|
||||
|
||||
obs_tstep_list_add_range( tstep_list , 10 , 12 );
|
||||
test_assert_int_equal( 3, obs_tstep_list_get_size( tstep_list ));
|
||||
obs_tstep_list_free( tstep_list );
|
||||
}
|
||||
|
||||
void test_contains() {
|
||||
obs_tstep_list_type * tstep_list = obs_tstep_list_alloc();
|
||||
|
||||
test_assert_false( obs_tstep_list_contains( tstep_list , 0 ));
|
||||
test_assert_false( obs_tstep_list_contains( tstep_list , 10 ));
|
||||
test_assert_false( obs_tstep_list_contains( tstep_list , 12 ));
|
||||
test_assert_false( obs_tstep_list_contains( tstep_list , 15 ));
|
||||
|
||||
obs_tstep_list_add_range( tstep_list , 10 , 12 );
|
||||
test_assert_false( obs_tstep_list_contains( tstep_list , 0 ));
|
||||
test_assert_true( obs_tstep_list_contains( tstep_list , 10 ));
|
||||
test_assert_true( obs_tstep_list_contains( tstep_list , 12 ));
|
||||
test_assert_false( obs_tstep_list_contains( tstep_list , 15 ));
|
||||
|
||||
obs_tstep_list_free( tstep_list );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
obs_tstep_list_type * tstep_list;
|
||||
|
||||
tstep_list = obs_tstep_list_alloc();
|
||||
test_assert_true( obs_tstep_list_is_instance( tstep_list ));
|
||||
test_assert_true( obs_tstep_list_all_active( tstep_list ));
|
||||
test_assert_int_equal( 0 , obs_tstep_list_get_size( tstep_list ));
|
||||
|
||||
obs_tstep_list_add_tstep( tstep_list , 100 );
|
||||
test_assert_int_equal( 1 , obs_tstep_list_get_size( tstep_list ));
|
||||
test_assert_false( obs_tstep_list_all_active( tstep_list ));
|
||||
|
||||
obs_tstep_list_add_tstep( tstep_list , 101 );
|
||||
test_assert_int_equal( 2 , obs_tstep_list_get_size( tstep_list ));
|
||||
|
||||
obs_tstep_list_add_tstep( tstep_list , 101 );
|
||||
test_assert_int_equal( 2 , obs_tstep_list_get_size( tstep_list ));
|
||||
|
||||
obs_tstep_list_add_tstep( tstep_list , 1 );
|
||||
test_assert_int_equal( 3 , obs_tstep_list_get_size( tstep_list ));
|
||||
|
||||
test_assert_int_equal( 1 , obs_tstep_list_iget( tstep_list , 0 ));
|
||||
test_assert_int_equal( 100 , obs_tstep_list_iget( tstep_list , 1 ));
|
||||
test_assert_int_equal( 101 , obs_tstep_list_iget( tstep_list , 2 ));
|
||||
|
||||
test_assert_int_equal( 101 , obs_tstep_list_get_last( tstep_list ));
|
||||
obs_tstep_list_free( tstep_list );
|
||||
|
||||
|
||||
test_range();
|
||||
test_contains();
|
||||
exit(0);
|
||||
}
|
||||
|
119
ThirdParty/Ert/devel/libenkf/tests/enkf_pca_plot.c
vendored
Normal file
119
ThirdParty/Ert/devel/libenkf/tests/enkf_pca_plot.c
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'enkf_pca_plot.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/matrix.h>
|
||||
#include <ert/util/rng.h>
|
||||
|
||||
#include <ert/enkf/pca_plot_data.h>
|
||||
#include <ert/enkf/pca_plot_vector.h>
|
||||
|
||||
|
||||
|
||||
pca_plot_data_type * create_data() {
|
||||
matrix_type * PC = matrix_alloc( 3 , 10);
|
||||
matrix_type * PC_obs = matrix_alloc( 3 , 1 );
|
||||
pca_plot_data_type * data = pca_plot_data_alloc("KEY" , PC , PC_obs);
|
||||
|
||||
matrix_free( PC );
|
||||
matrix_free( PC_obs );
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_create_data() {
|
||||
matrix_type * PC = matrix_alloc( 3 , 10);
|
||||
matrix_type * PC_obs = matrix_alloc( 3 , 1 );
|
||||
{
|
||||
pca_plot_data_type * data = pca_plot_data_alloc("KEY" , PC , PC_obs);
|
||||
test_assert_true( pca_plot_data_is_instance( data ));
|
||||
test_assert_int_equal( 3 , pca_plot_data_get_size( data ));
|
||||
test_assert_int_equal( 10 , pca_plot_data_get_ens_size( data ));
|
||||
test_assert_string_equal( "KEY" , pca_plot_data_get_name( data ));
|
||||
pca_plot_data_free( data );
|
||||
}
|
||||
matrix_resize( PC , 4 , 10 , false);
|
||||
test_assert_NULL( pca_plot_data_alloc( "KEY" , PC , PC_obs ));
|
||||
|
||||
matrix_resize( PC_obs , 3 , 2 , false);
|
||||
test_assert_NULL( pca_plot_data_alloc( "KEY" , PC , PC_obs ));
|
||||
|
||||
matrix_free( PC );
|
||||
matrix_free( PC_obs );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_create_vector() {
|
||||
matrix_type * PC = matrix_alloc( 3 , 10);
|
||||
matrix_type * PC_obs = matrix_alloc( 3 , 1 );
|
||||
{
|
||||
pca_plot_vector_type * vector = pca_plot_vector_alloc(0 , PC , PC_obs);
|
||||
test_assert_true( pca_plot_vector_is_instance( vector ));
|
||||
pca_plot_vector_free( vector );
|
||||
}
|
||||
matrix_free( PC );
|
||||
matrix_free( PC_obs );
|
||||
}
|
||||
|
||||
|
||||
void test_get_vector() {
|
||||
pca_plot_data_type * data = create_data();
|
||||
test_assert_true( pca_plot_vector_is_instance( pca_plot_data_iget_vector( data , 0 )));
|
||||
pca_plot_data_free( data );
|
||||
}
|
||||
|
||||
|
||||
void test_content() {
|
||||
rng_type * rng = rng_alloc(MZRAN , INIT_DEFAULT);
|
||||
matrix_type * PC = matrix_alloc( 3 , 10);
|
||||
matrix_type * PC_obs = matrix_alloc( 3 , 1 );
|
||||
matrix_random_init( PC , rng );
|
||||
matrix_random_init( PC_obs , rng );
|
||||
{
|
||||
pca_plot_data_type * data = pca_plot_data_alloc("KEY" , PC , PC_obs);
|
||||
for (int i=0; i < matrix_get_rows( PC ); i++) {
|
||||
const pca_plot_vector_type * vector = pca_plot_data_iget_vector( data , i );
|
||||
|
||||
test_assert_double_equal( matrix_iget( PC_obs , i , 0) ,
|
||||
pca_plot_vector_get_obs_value( vector ) );
|
||||
|
||||
for (int j=0; j < matrix_get_columns( PC ); j++)
|
||||
test_assert_double_equal( matrix_iget( PC , i , j ) , pca_plot_vector_iget_sim_value( vector , j ));
|
||||
|
||||
test_assert_int_equal( matrix_get_columns( PC ) , pca_plot_vector_get_size( vector ));
|
||||
|
||||
}
|
||||
pca_plot_data_free( data );
|
||||
}
|
||||
|
||||
matrix_free( PC );
|
||||
matrix_free( PC_obs );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_create_data();
|
||||
test_create_vector();
|
||||
test_get_vector();
|
||||
test_content();
|
||||
exit(0);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
int main(int argc , char ** argv) {
|
||||
unsigned int rand1,rand2;
|
||||
{
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf-rng-0", false);
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf-rng-0");
|
||||
{
|
||||
enkf_main_type * enkf_main = enkf_main_alloc_empty();
|
||||
enkf_main_resize_ensemble( enkf_main , 10 );
|
||||
@ -58,7 +58,7 @@ int main(int argc , char ** argv) {
|
||||
/*****************************************************************/
|
||||
|
||||
{
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf-rng-1" , false );
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf-rng-1" );
|
||||
const char * seed_file = "seed";
|
||||
{
|
||||
enkf_main_type * enkf_main = enkf_main_alloc_empty();
|
||||
@ -99,7 +99,7 @@ int main(int argc , char ** argv) {
|
||||
{
|
||||
const char * config_path = argv[1];
|
||||
const char * config_file = argv[2];
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf-rng-2" , false );
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf-rng-2" );
|
||||
test_work_area_copy_directory_content( work_area , config_path );
|
||||
{
|
||||
enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , config_file , true , true );
|
||||
|
@ -99,7 +99,7 @@ int main(int argc , char ** argv) {
|
||||
}
|
||||
|
||||
{
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf_runpath_list" , true);
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf_runpath_list" );
|
||||
const char *filename = "runpath_list.txt";
|
||||
{
|
||||
FILE * stream = util_fopen( filename, "w");
|
||||
|
@ -107,7 +107,7 @@ void test_copy() {
|
||||
|
||||
|
||||
void test_io( ) {
|
||||
test_work_area_type * work_area = test_work_area_alloc( "enkf-state-map" , false );
|
||||
test_work_area_type * work_area = test_work_area_alloc( "enkf-state-map" );
|
||||
{
|
||||
state_map_type * state_map = state_map_alloc();
|
||||
state_map_type * copy1 , *copy2;
|
||||
@ -153,6 +153,29 @@ void test_update_undefined( ) {
|
||||
}
|
||||
|
||||
|
||||
void test_update_matching( ) {
|
||||
state_map_type * map = state_map_alloc( );
|
||||
|
||||
state_map_iset( map , 10 , STATE_INITIALIZED );
|
||||
state_map_iset( map , 3 , STATE_PARENT_FAILURE );
|
||||
test_assert_int_equal( STATE_UNDEFINED , state_map_iget( map , 5 ) );
|
||||
test_assert_int_equal( STATE_INITIALIZED , state_map_iget( map , 10 ) );
|
||||
|
||||
state_map_update_matching( map , 5 , STATE_UNDEFINED | STATE_LOAD_FAILURE , STATE_INITIALIZED );
|
||||
state_map_update_matching( map , 10 , STATE_UNDEFINED | STATE_LOAD_FAILURE , STATE_INITIALIZED );
|
||||
state_map_update_matching( map , 3 , STATE_UNDEFINED | STATE_LOAD_FAILURE , STATE_INITIALIZED );
|
||||
|
||||
test_assert_int_equal( STATE_INITIALIZED , state_map_iget( map , 5 ) );
|
||||
test_assert_int_equal( STATE_INITIALIZED , state_map_iget( map , 10 ) );
|
||||
test_assert_int_equal( STATE_PARENT_FAILURE , state_map_iget( map , 3 ) );
|
||||
|
||||
state_map_update_undefined( map , 10 , STATE_INITIALIZED );
|
||||
test_assert_int_equal( STATE_INITIALIZED , state_map_iget( map , 10 ) );
|
||||
|
||||
state_map_free( map );
|
||||
}
|
||||
|
||||
|
||||
void test_select_matching( ) {
|
||||
state_map_type * map = state_map_alloc( );
|
||||
bool_vector_type * mask1 = bool_vector_alloc(0 , false);
|
||||
|
@ -55,7 +55,7 @@ int main(int argc , char ** argv) {
|
||||
|
||||
test_assert_true( util_sscanf_bool( compatible_str , &check_compatible));
|
||||
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file , false);
|
||||
test_work_area_type * work_area = test_work_area_alloc(config_file );
|
||||
test_work_area_copy_directory_content( work_area , root_path );
|
||||
|
||||
bool strict = true;
|
||||
|
@ -57,7 +57,7 @@ void ecl_test( const char * ecl_case ) {
|
||||
|
||||
void simple_test() {
|
||||
time_map_type * time_map = time_map_alloc( );
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf_time_map" , true);
|
||||
test_work_area_type * work_area = test_work_area_alloc("enkf_time_map" );
|
||||
const char * mapfile = "map";
|
||||
|
||||
test_assert_true( time_map_update( time_map , 0 , 100 ) );
|
||||
|
@ -34,6 +34,7 @@ typedef void * (arg_node_copyc_ftype) (const void *);
|
||||
arg_pack_type * arg_pack_alloc();
|
||||
UTIL_SAFE_CAST_HEADER( arg_pack );
|
||||
UTIL_SAFE_CAST_HEADER_CONST( arg_pack );
|
||||
UTIL_IS_INSTANCE_HEADER( arg_pack );
|
||||
|
||||
void arg_pack_free(arg_pack_type * );
|
||||
void arg_pack_free__(void *);
|
||||
@ -56,6 +57,8 @@ typedef void * (arg_node_copyc_ftype) (const void *);
|
||||
void * arg_pack_iget_ptr(const arg_pack_type * , int);
|
||||
void * arg_pack_iget_adress(const arg_pack_type * , int);
|
||||
node_ctype arg_pack_iget_ctype(const arg_pack_type * arg_pack ,int index);
|
||||
|
||||
int arg_pack_size( const arg_pack_type * arg_pack );
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
@ -34,6 +34,7 @@ extern "C" {
|
||||
|
||||
typedef struct matrix_struct matrix_type;
|
||||
|
||||
bool matrix_check_dims( const matrix_type * m , int rows , int columns);
|
||||
void matrix_fscanf_data( matrix_type * matrix , bool row_major_order , FILE * stream );
|
||||
void matrix_fprintf( const matrix_type * matrix , const char * fmt , FILE * stream );
|
||||
void matrix_pretty_fprint(const matrix_type * matrix , const char * name , const char * fmt , FILE * stream);
|
||||
|
@ -103,6 +103,8 @@ typedef int ( string_cmp_ftype) (const void * , const void *);
|
||||
int stringlist_select_matching(stringlist_type * names , const char * pattern);
|
||||
#endif
|
||||
int stringlist_select_matching_files(stringlist_type * names , const char * path , const char * file_pattern);
|
||||
int stringlist_select_matching_elements(stringlist_type * target , const stringlist_type * src , const char * pattern);
|
||||
int stringlist_append_matching_elements(stringlist_type * target , const stringlist_type * src , const char * pattern);
|
||||
UTIL_IS_INSTANCE_HEADER(stringlist);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -26,9 +26,15 @@ extern "C" {
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
typedef struct test_work_area_struct test_work_area_type;
|
||||
|
||||
test_work_area_type * test_work_area_alloc(const char * test_name , bool store);
|
||||
test_work_area_type * test_work_area_alloc(const char * test_name );
|
||||
test_work_area_type * test_work_area_alloc_with_prefix(const char * prefix , const char * test_name);
|
||||
test_work_area_type * test_work_area_alloc__(const char * prefix , const char * test_path);
|
||||
void test_work_area_set_store( test_work_area_type * work_area , bool store);
|
||||
|
||||
void test_work_area_free(test_work_area_type * work_area);
|
||||
const char * test_work_area_get_cwd( const test_work_area_type * work_area );
|
||||
const char * test_work_area_get_original_cwd( const test_work_area_type * work_area );
|
||||
@ -36,6 +42,11 @@ extern "C" {
|
||||
void test_work_area_copy_directory( test_work_area_type * work_area , const char * input_directory);
|
||||
void test_work_area_copy_directory_content( test_work_area_type * work_area , const char * input_directory);
|
||||
void test_work_area_copy_file( test_work_area_type * work_area , const char * input_file);
|
||||
bool test_work_area_copy_parent_directory( test_work_area_type * work_area , const char * input_path);
|
||||
bool test_work_area_copy_parent_content( test_work_area_type * work_area , const char * input_path);
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( test_work_area );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -253,6 +253,7 @@ typedef enum {left_pad = 0,
|
||||
char ** util_alloc_stringlist_copy(const char **, int );
|
||||
void util_split_string(const char *, const char *, int *, char ***);
|
||||
void util_path_split(const char * , int *, char ***);
|
||||
char * util_alloc_parent_path( const char * path);
|
||||
void util_binary_split_string(const char * , const char * , bool , char ** , char ** );
|
||||
void util_binary_split_string_from_max_length(const char * , const char * , int , char ** , char ** );
|
||||
char * util_alloc_joined_string(const char ** , int , const char * );
|
||||
@ -378,7 +379,7 @@ typedef enum {left_pad = 0,
|
||||
void util_unsetenv( const char * variable);
|
||||
char * util_alloc_envvar( const char * value );
|
||||
bool util_is_link(const char * ); // Will always return false on windows
|
||||
|
||||
int util_chdir(const char * path);
|
||||
|
||||
|
||||
#define UTIL_FWRITE_SCALAR(s,stream) { if (fwrite(&s , sizeof s , 1 , stream) != 1) util_abort("%s: write failed: %s\n",__func__ , strerror(errno)); }
|
||||
|
@ -111,7 +111,8 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@);
|
||||
int @TYPE@_vector_count_equal( const @TYPE@_vector_type * vector , @TYPE@ cmp_value);
|
||||
int @TYPE@_vector_element_size( const @TYPE@_vector_type * vector );
|
||||
|
||||
UTIL_SAFE_CAST_HEADER( @TYPE@_vector );
|
||||
//UTIL_SAFE_CAST_HEADER( @TYPE@_vector );
|
||||
UTIL_IS_INSTANCE_HEADER( @TYPE@_vector );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
set(source_files rng.c lookup_table.c statistics.c mzran.c set.c hash_node.c hash_sll.c hash.c node_data.c node_ctype.c util.c thread_pool.c msg.c arg_pack.c path_fmt.c menu.c subst_list.c subst_func.c vector.c parser.c stringlist.c matrix.c buffer.c log.c template.c timer.c time_interval.c string_util.c type_vector_functions.c)
|
||||
set(source_files rng.c lookup_table.c statistics.c mzran.c set.c hash_node.c hash_sll.c hash.c node_data.c node_ctype.c util.c thread_pool.c msg.c arg_pack.c path_fmt.c menu.c subst_list.c subst_func.c vector.c parser.c stringlist.c matrix.c buffer.c log.c template.c timer.c time_interval.c string_util.c type_vector_functions.c test_work_area.c)
|
||||
|
||||
set(header_files ssize_t.h type_macros.h rng.h lookup_table.h statistics.h mzran.h set.h hash.h hash_node.h hash_sll.h node_data.h node_ctype.h util.h thread_pool.h msg.h arg_pack.h path_fmt.h stringlist.h menu.h subst_list.h subst_func.h vector.h parser.h matrix.h buffer.h log.h template.h timer.h time_interval.h string_util.h type_vector_functions.h)
|
||||
set(header_files ssize_t.h type_macros.h rng.h lookup_table.h statistics.h mzran.h set.h hash.h hash_node.h hash_sll.h node_data.h node_ctype.h util.h thread_pool.h msg.h arg_pack.h path_fmt.h stringlist.h menu.h subst_list.h subst_func.h vector.h parser.h matrix.h buffer.h log.h template.h timer.h time_interval.h string_util.h type_vector_functions.h test_work_area.h)
|
||||
|
||||
set( test_source test_util.c test_work_area.c )
|
||||
set( test_source test_util.c )
|
||||
set( test_headers test_util.h )
|
||||
|
||||
|
||||
#set_property(SOURCE hash.c PROPERTY COMPILE_FLAGS "-Wno-error")
|
||||
if (CMAKE_COMPILER_IS_GNUCC)
|
||||
set_property(SOURCE hash.c PROPERTY COMPILE_FLAGS "-Wno-error")
|
||||
endif()
|
||||
|
||||
|
||||
if (WITH_LATEX)
|
||||
@ -91,6 +93,7 @@ endif()
|
||||
#-----------------------------------------------------------------
|
||||
if (INSTALL_ERT)
|
||||
install(TARGETS ert_util DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
foreach(header ${header_files})
|
||||
install(FILES ../include/ert/util/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/util)
|
||||
endforeach()
|
||||
|
@ -335,6 +335,7 @@ static void arg_node_fprintf(const arg_node_type * node , FILE * stream) {
|
||||
|
||||
UTIL_SAFE_CAST_FUNCTION( arg_pack , ARG_PACK_TYPE_ID)
|
||||
UTIL_SAFE_CAST_FUNCTION_CONST( arg_pack , ARG_PACK_TYPE_ID)
|
||||
UTIL_IS_INSTANCE_FUNCTION(arg_pack , ARG_PACK_TYPE_ID)
|
||||
|
||||
static void __arg_pack_assert_index(const arg_pack_type * arg , int iarg) {
|
||||
if (iarg < 0 || iarg >= arg->size)
|
||||
@ -558,7 +559,9 @@ void arg_pack_append_owned_ptr(arg_pack_type * arg_pack, void * ptr, arg_node_fr
|
||||
arg_pack_iset_owned_ptr( arg_pack , arg_pack->size , ptr , freef);
|
||||
}
|
||||
|
||||
|
||||
int arg_pack_size( const arg_pack_type * arg_pack ) {
|
||||
return arg_pack->size;
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
/* Functions for formatted reading/writing of arg_pack instances. */
|
||||
|
@ -1427,6 +1427,13 @@ double matrix_trace(const matrix_type *matrix) {
|
||||
}
|
||||
|
||||
|
||||
bool matrix_check_dims( const matrix_type * m , int rows , int columns) {
|
||||
if ((m->rows == rows) && (m->columns == columns))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
double matrix_diag_std(const matrix_type * Sk,double mean)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ void path_stack_free( path_stack_type * path_stack ) {
|
||||
|
||||
bool path_stack_push( path_stack_type * path_stack , const char * path ) {
|
||||
if (path != NULL)
|
||||
if (chdir( path ) != 0)
|
||||
if (util_chdir( path ) != 0)
|
||||
return false;
|
||||
|
||||
path_stack_push_cwd( path_stack );
|
||||
@ -98,7 +98,7 @@ void path_stack_push_cwd( path_stack_type * path_stack ) {
|
||||
|
||||
const char * path_stack_pop( path_stack_type * path_stack ) {
|
||||
char * path = stringlist_pop( path_stack->stack );
|
||||
if (chdir( path ) == 0)
|
||||
if (util_chdir( path ) == 0)
|
||||
return path;
|
||||
else {
|
||||
// The directory has become inaccesible ...
|
||||
|
@ -732,7 +732,23 @@ int stringlist_select_matching_files(stringlist_type * names , const char * path
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int stringlist_append_matching_elements(stringlist_type * target , const stringlist_type * src , const char * pattern) {
|
||||
int ielm;
|
||||
int match_count = 0;
|
||||
for (ielm = 0; ielm < stringlist_get_size( src ); ielm++) {
|
||||
const char * item = stringlist_iget( src , ielm );
|
||||
if (util_fnmatch( pattern , item ) == 0) {
|
||||
stringlist_append_copy( target , item );
|
||||
match_count++;
|
||||
}
|
||||
}
|
||||
return match_count;
|
||||
}
|
||||
|
||||
int stringlist_select_matching_elements(stringlist_type * target , const stringlist_type * src , const char * pattern) {
|
||||
stringlist_clear( target );
|
||||
return stringlist_append_matching_elements( target , src , pattern );
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -16,15 +16,19 @@
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_GETUID
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include <ert/util/test_work_area.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/test_work_area.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/rng.h>
|
||||
|
||||
/*
|
||||
@ -38,7 +42,7 @@
|
||||
problems, to achieve this the directories created will be per user.
|
||||
|
||||
When creating the work area you pass in a boolean flag whether you
|
||||
want the area to be retained when the destructor is called. After
|
||||
want the area to be storeed when the destructor is called. After
|
||||
the the work_area is destroyed the cwd is changed back to the value
|
||||
it had before the area was created.
|
||||
|
||||
@ -70,59 +74,88 @@
|
||||
...
|
||||
|
||||
-- Destroy test_work_area structure; since the work_area is created
|
||||
-- with input flag @retain set to true the are on disk will not be
|
||||
-- with input flag @store set to true the are on disk will not be
|
||||
-- cleared. After the test_work_area_free( ) function has been
|
||||
-- called the original cwd will be restored.
|
||||
|
||||
test_work_area_free( work_area );
|
||||
*/
|
||||
|
||||
#define DEFAULT_STORE false
|
||||
#define DEFAULT_PREFIX "/tmp"
|
||||
|
||||
#define PATH_FMT "/tmp/%s/ert-test/%s/%08d" /* /tmp/username/ert-test/test_name/random-integer */
|
||||
#define TEST_PATH_FMT "%s/ert-test/%s/%08d" /* username/ert-test/test_name/random-integer */
|
||||
#define FULL_PATH_FMT "%s/%s" /* prefix/test-path */
|
||||
|
||||
#define TEST_WORK_AREA_TYPE_ID 1107355
|
||||
|
||||
struct test_work_area_struct {
|
||||
bool retain;
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
bool store;
|
||||
char * cwd;
|
||||
char * original_cwd;
|
||||
};
|
||||
|
||||
|
||||
static test_work_area_type * test_work_area_alloc__(const char * path , bool retain) {
|
||||
util_make_path( path );
|
||||
if (true) {
|
||||
test_work_area_type * work_area = util_malloc( sizeof * work_area );
|
||||
work_area->retain = retain;
|
||||
work_area->cwd = util_alloc_string_copy( path );
|
||||
work_area->original_cwd = util_alloc_cwd();
|
||||
chdir( work_area->cwd );
|
||||
|
||||
return work_area;
|
||||
}
|
||||
test_work_area_type * test_work_area_alloc__(const char * prefix , const char * test_path) {
|
||||
test_work_area_type * work_area = NULL;
|
||||
|
||||
if (util_is_directory( prefix )) {
|
||||
char * test_cwd = util_alloc_sprintf(FULL_PATH_FMT , prefix , test_path );
|
||||
util_make_path( test_cwd );
|
||||
if (true) {
|
||||
work_area = util_malloc( sizeof * work_area );
|
||||
|
||||
UTIL_TYPE_ID_INIT( work_area , TEST_WORK_AREA_TYPE_ID );
|
||||
work_area->original_cwd = util_alloc_cwd();
|
||||
work_area->cwd = test_cwd;
|
||||
util_chdir( work_area->cwd );
|
||||
test_work_area_set_store( work_area , DEFAULT_STORE);
|
||||
} else
|
||||
free( test_cwd );
|
||||
}
|
||||
return work_area;
|
||||
}
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( test_work_area , TEST_WORK_AREA_TYPE_ID)
|
||||
|
||||
test_work_area_type * test_work_area_alloc(const char * test_name, bool retain) {
|
||||
test_work_area_type * test_work_area_alloc_with_prefix(const char * prefix , const char * test_name) {
|
||||
if (test_name) {
|
||||
rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM );
|
||||
#ifdef HAVE_GETUID
|
||||
uid_t uid = getuid();
|
||||
struct passwd * pw = getpwuid( uid );
|
||||
rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM );
|
||||
char * path = util_alloc_sprintf( PATH_FMT , pw->pw_name , test_name , rng_get_int( rng , 100000000 ));
|
||||
test_work_area_type * work_area = test_work_area_alloc__( path , retain );
|
||||
free( path );
|
||||
char * user_name = util_alloc_string_copy( pw->pw_name );
|
||||
#else
|
||||
char * user_name = util_alloc_sprintf("ert-test-%08d" , rng_get_int(rng , 100000000));
|
||||
#endif
|
||||
char * test_path = util_alloc_sprintf( TEST_PATH_FMT , user_name , test_name , rng_get_int( rng , 100000000 ));
|
||||
test_work_area_type * work_area = test_work_area_alloc__( prefix , test_path);
|
||||
free( test_path );
|
||||
rng_free( rng );
|
||||
free( user_name );
|
||||
return work_area;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
test_work_area_type * test_work_area_alloc(const char * test_name) {
|
||||
return test_work_area_alloc_with_prefix( DEFAULT_PREFIX , test_name);
|
||||
}
|
||||
|
||||
|
||||
void test_work_area_set_store( test_work_area_type * work_area , bool store) {
|
||||
work_area->store = store;
|
||||
}
|
||||
|
||||
|
||||
void test_work_area_free(test_work_area_type * work_area) {
|
||||
if (!work_area->retain)
|
||||
if (!work_area->store)
|
||||
util_clear_directory( work_area->cwd , true , true );
|
||||
|
||||
chdir( work_area->original_cwd );
|
||||
|
||||
util_chdir( work_area->original_cwd );
|
||||
free( work_area->original_cwd );
|
||||
free( work_area->cwd );
|
||||
free( work_area );
|
||||
@ -139,6 +172,7 @@ const char * test_work_area_get_original_cwd( const test_work_area_type * work_a
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The point of this function is that the test code should be able to
|
||||
access the file @input_file independent of the fact that it has
|
||||
@ -214,3 +248,40 @@ void test_work_area_copy_file( test_work_area_type * work_area , const char * in
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool test_work_area_copy_parent__( test_work_area_type * work_area , const char * input_path, bool copy_content) {
|
||||
char * full_path;
|
||||
|
||||
if (util_is_abs_path( input_path ))
|
||||
full_path = util_alloc_string_copy( input_path );
|
||||
else
|
||||
full_path = util_alloc_filename( work_area->original_cwd , input_path , NULL);
|
||||
|
||||
if (util_entry_exists( full_path)) {
|
||||
char * parent_path = NULL;
|
||||
|
||||
parent_path = util_alloc_parent_path( full_path );
|
||||
|
||||
if (copy_content)
|
||||
test_work_area_copy_directory_content( work_area , parent_path );
|
||||
else
|
||||
test_work_area_copy_directory( work_area , parent_path );
|
||||
|
||||
free( full_path );
|
||||
free( parent_path );
|
||||
return true;
|
||||
} else {
|
||||
free( full_path );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool test_work_area_copy_parent_directory( test_work_area_type * work_area , const char * input_path) {
|
||||
return test_work_area_copy_parent__( work_area , input_path , false );
|
||||
}
|
||||
|
||||
|
||||
bool test_work_area_copy_parent_content( test_work_area_type * work_area , const char * input_path) {
|
||||
return test_work_area_copy_parent__( work_area , input_path , true );
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user