Initial commit of ResInsight version 0.4.8

This commit is contained in:
Alf B. Rustad
2012-05-18 09:45:23 +02:00
parent a680bf941e
commit dfe97efb1b
657 changed files with 176690 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
#The source code for ERT is located in :
cd /home/builder/src/ert/devel/
# We only use libecl and libutil
# libutil must be built first
# First you might want to check what has happened since last update:
cd libutil
svn log -r BASE:HEAD
cd ../libecl
svn log -r BASE:HEAD
cd ..
# Then update and build the code:
# using cmake
svn up
cmake-gui
# Enter the following in the gui:
# Source code: /home/builder/src/ert/devel/
# Binaries: /home/builder/src/ert/ErtCmakeBuild
# Then press configure, and edit the following variables:
# BLAS_LIBRARY: /usr/lib64/libblas.so.3
# INSTALL_ROOT: /home/builder/Projects/ResInsight/ThirdParty/Ert/
# then press Configure and then Generate
# at the prompt:
cd /home/builder/src/ert/ErtCmakeBuild
make clean
make
# make your copy of the library editable by checking it out
#p4 edit -c default /home/builder/Projects/ResInsight/ThirdParty/Ert/...
rm -r /home/builder/Projects/ResInsight/ThirdParty/Ert/ecl/*
rm -r /home/builder/Projects/ResInsight/ThirdParty/Ert/util/*
rm -r /home/builder/Projects/ResInsight/ThirdParty/Ert/geometry/*
rm -r /home/builder/Projects/ResInsight/ThirdParty/Ert/well/*
make install
# Then check in if appropriate
# Finished.
############################################################################
# Old build system using SCons.
# At that time the installation directories was
# called libecl and libutil, not ecl and util so this must be taken into
# accont if this approach is tested
# First clean up
cd libutil
scons -c
rm -r include
rm -r lib
cd ..
cd libecl
scons -c
rm -r include
rm -r lib
cd ..
# update and build
svn up
cd libutil
scons -k
cd ..
cd libecl
scons -k
cd ..
# Copy the new lib files and includes into our repository
# make your copy of the library editable by checking it out
#p4 edit -c default /home/builder/Projects/ResInsight/ThirdParty/Ert/...
rm -r /home/builder/Projects/ResInsight/ThirdParty/Ert/libecl/*
rm -r /home/builder/Projects/ResInsight/ThirdParty/Ert/libutil/*
cp -v -r libecl/include /home/builder/Projects/ResInsight/ThirdParty/Ert/libecl/include
cp -v -r libecl/lib /home/builder/Projects/ResInsight/ThirdParty/Ert/libecl/lib
cp -v -r libutil/include /home/builder/Projects/ResInsight/ThirdParty/Ert/libutil/include
cp -v -r libutil/lib /home/builder/Projects/ResInsight/ThirdParty/Ert/libutil/lib
# Then check in if appropriate

48
ThirdParty/Ert/ecl/include/ecl_box.h vendored Normal file
View File

@@ -0,0 +1,48 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_box.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_BOX_H__
#define __ECL_BOX_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ecl_grid.h>
typedef struct ecl_box_struct ecl_box_type;
void ecl_box_set_size (ecl_box_type * , int , int , int , int , int , int );
ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int i1,int i2 , int j1 , int j2 , int k1, int k2);
void ecl_box_free (ecl_box_type * );
void ecl_box_set_values(const ecl_box_type * , char * , const char * , int );
int ecl_box_get_total_size(const ecl_box_type * );
int ecl_box_get_active_size( const ecl_box_type * ecl_box );
const int * ecl_box_get_active_list( const ecl_box_type * ecl_box );
int ecl_box_get_global_size( const ecl_box_type * ecl_box );
const int * ecl_box_get_global_list( const ecl_box_type * ecl_box );
bool ecl_box_contains(const ecl_box_type * box , int i , int j , int k);
UTIL_IS_INSTANCE_HEADER( ecl_box );
UTIL_SAFE_CAST_HEADER( ecl_box );
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,60 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_endian_flip.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_ENDIAN_FLIP_H__
#define __ECL_ENDIAN_FLIP_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
/**
This header file checks if the ECLIPSE endianness and the hardware
endianness are equal, and defines the macro ECL_ENDIAN_FLIP
accordingly.
All the ecl_xxx functions will use the ECL_ENDIAN_FLIP macro to
determine whether the endian flip should be performed. When opening
a fortio instance explicitly you can use the ECL_ENDIAN_FLIP macro
to get the endianness correct (for ECLIPSE usage that is).
*/
#define ECLIPSE_BYTE_ORDER __BIG_ENDIAN // Alternatively: __LITTLE_ENDIAN
#ifdef BYTE_ORDER
#if BYTE_ORDER == ECLIPSE_BYTE_ORDER
#define ECL_ENDIAN_FLIP false
#else
#define ECL_ENDIAN_FLIP true
#endif
#else
#ifdef WIN32
#define ECL_ENDIAN_FLIP true // Unconditional byte flip on Windows.
#else
#error: The macro BYTE_ORDER is not defined?
#endif
#endif
#undef ECLIPSE_BYTE_ORDER
#ifdef __cplusplus
}
#endif
#endif

114
ThirdParty/Ert/ecl/include/ecl_file.h vendored Normal file
View File

@@ -0,0 +1,114 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_file.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_FILE_H__
#define __ECL_FILE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <time.h>
#include <ecl_kw.h>
#include <ecl_file_kw.h>
#include <fortio.h>
#include <ecl_util.h>
typedef struct ecl_file_struct ecl_file_type;
void ecl_file_load_all( ecl_file_type * ecl_file );
void ecl_file_push_block( ecl_file_type * ecl_file );
void ecl_file_pop_block( ecl_file_type * ecl_file );
ecl_file_type * ecl_file_open( const char * filename );
ecl_file_type * ecl_file_open_writable( const char * filename );
void ecl_file_close( ecl_file_type * ecl_file );
void ecl_file_fortio_detach( ecl_file_type * ecl_file );
void ecl_file_free__(void * arg);
ecl_kw_type * ecl_file_icopy_named_kw( const ecl_file_type * ecl_file , const char * kw, int ith);
ecl_kw_type * ecl_file_icopy_kw( const ecl_file_type * ecl_file , int index);
bool ecl_file_has_kw( const ecl_file_type * ecl_file , const char * kw);
int ecl_file_get_num_named_kw(const ecl_file_type * ecl_file , const char * kw);
int ecl_file_get_size( const ecl_file_type * ecl_file );
int ecl_file_get_num_distinct_kw(const ecl_file_type * ecl_file);
const char * ecl_file_iget_distinct_kw(const ecl_file_type * ecl_file , int index);
const char * ecl_file_get_src_file( const ecl_file_type * ecl_file );
int ecl_file_iget_occurence( const ecl_file_type * ecl_file , int index);
ecl_version_enum ecl_file_get_ecl_version( const ecl_file_type * file );
void ecl_file_fwrite_fortio(const ecl_file_type * ec_file , fortio_type * fortio , int offset);
void ecl_file_fwrite(const ecl_file_type * ecl_file , const char * , bool fmt_file );
void ecl_file_replace_kw( ecl_file_type * ecl_file , ecl_kw_type * old_kw , ecl_kw_type * new_kw , bool insert_copy);
int ecl_file_get_phases( const ecl_file_type * init_file );
void ecl_file_fprintf_kw_list( const ecl_file_type * ecl_file , FILE * stream );
ecl_file_kw_type * ecl_file_iget_file_kw( const ecl_file_type * file , int global_index);
ecl_file_kw_type * ecl_file_iget_named_file_kw( const ecl_file_type * file , const char * kw, int ith);
ecl_kw_type * ecl_file_iget_kw( const ecl_file_type * file , int global_index);
ecl_type_enum ecl_file_iget_type( const ecl_file_type * file , int global_index);
int ecl_file_iget_size( const ecl_file_type * file , int global_index);
const char * ecl_file_iget_header( const ecl_file_type * file , int global_index);
ecl_kw_type * ecl_file_iget_named_kw( const ecl_file_type * file , const char * kw, int ith);
ecl_type_enum ecl_file_iget_named_type( const ecl_file_type * file , const char * kw , int ith);
int ecl_file_iget_named_size( const ecl_file_type * file , const char * kw , int ith);
bool ecl_file_subselect_block( ecl_file_type * ecl_file , const char * kw , int occurence);
bool ecl_file_select_block( ecl_file_type * ecl_file , const char * kw , int occurence);
void ecl_file_select_global( ecl_file_type * ecl_file );
bool ecl_file_writable( const ecl_file_type * ecl_file );
void ecl_file_save_kw( const ecl_file_type * ecl_file , const ecl_kw_type * ecl_kw);
bool ecl_file_has_kw_ptr( const ecl_file_type * ecl_file , const ecl_kw_type * ecl_kw);
/*****************************************************************/
/* R E S T A R T F I L E S */
time_t ecl_file_iget_restart_sim_date( const ecl_file_type * restart_file , int occurence );
int ecl_file_get_restart_index( const ecl_file_type * restart_file , time_t sim_time);
bool ecl_file_has_report_step( const ecl_file_type * ecl_file , int report_step);
bool ecl_file_has_sim_time( const ecl_file_type * ecl_file , time_t sim_time);
bool ecl_file_select_rstblock_sim_time( ecl_file_type * ecl_file , time_t sim_time);
bool ecl_file_select_rstblock_report_step( ecl_file_type * ecl_file , int report_step);
bool ecl_file_iselect_rstblock( ecl_file_type * ecl_file , int seqnum_index );
ecl_file_type * ecl_file_open_rstblock_report_step( const char * filename , int report_step );
ecl_file_type * ecl_file_open_rstblock_sim_time( const char * filename , time_t sim_time);
ecl_file_type * ecl_file_iopen_rstblock( const char * filename , int seqnum_index);
ecl_file_type * ecl_file_open_rstblock_report_step_writable( const char * filename , int report_step );
ecl_file_type * ecl_file_open_rstblock_sim_time_writable( const char * filename , time_t sim_time);
ecl_file_type * ecl_file_iopen_rstblock_writable( const char * filename , int seqnum_index);
/*****************************************************************/
/* SUMMARY FILES */
bool ecl_file_select_smryblock( ecl_file_type * ecl_file , int ministep_nr );
ecl_file_type * ecl_file_open_smryblock( const char * filename , int ministep_nr );
UTIL_IS_INSTANCE_HEADER( ecl_file )
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,55 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_file_kw.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_FILE_KW_H__
#define __ECL_FILE_KW_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <ecl_kw.h>
#include <fortio.h>
typedef struct ecl_file_kw_struct ecl_file_kw_type;
typedef struct inv_map_struct inv_map_type;
inv_map_type * inv_map_alloc();
ecl_file_kw_type * inv_map_get_file_kw( inv_map_type * inv_map , const ecl_kw_type * ecl_kw );
void inv_map_free( inv_map_type * map );
ecl_file_kw_type * ecl_file_kw_alloc( const ecl_kw_type * ecl_kw , long offset);
void ecl_file_kw_free( ecl_file_kw_type * file_kw );
void ecl_file_kw_free__( void * arg );
ecl_kw_type * ecl_file_kw_get_kw( ecl_file_kw_type * file_kw , fortio_type * fortio, inv_map_type * inv_map);
ecl_file_kw_type * ecl_file_kw_alloc_copy( const ecl_file_kw_type * src );
const char * ecl_file_kw_get_header( const ecl_file_kw_type * file_kw );
int ecl_file_kw_get_size( const ecl_file_kw_type * file_kw );
ecl_type_enum ecl_file_kw_get_type( const ecl_file_kw_type * file_kw);
bool ecl_file_kw_ptr_eq( const ecl_file_kw_type * file_kw , const ecl_kw_type * ecl_kw);
void ecl_file_kw_replace_kw( ecl_file_kw_type * file_kw , fortio_type * target , ecl_kw_type * new_kw );
void ecl_file_kw_fskip_data( const ecl_file_kw_type * file_kw , fortio_type * fortio);
void ecl_file_kw_inplace_fwrite( ecl_file_kw_type * file_kw , fortio_type * fortio);
#ifdef __cplusplus
}
#endif
#endif

46
ThirdParty/Ert/ecl/include/ecl_grav.h vendored Normal file
View File

@@ -0,0 +1,46 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_grav.h' is part of ERT - Ensemble based
Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_GRAV_H__
#define __ECL_GRAV_H__
#ifdef __plusplus
extern "C" {
#endif
#include <ecl_file.h>
#include <ecl_grid.h>
#include <ecl_region.h>
typedef struct ecl_grav_struct ecl_grav_type;
typedef struct ecl_grav_survey_struct ecl_grav_survey_type;
void ecl_grav_free( ecl_grav_type * ecl_grav_config );
ecl_grav_type * ecl_grav_alloc( const ecl_grid_type * ecl_grid, const ecl_file_type * init_file );
ecl_grav_survey_type * ecl_grav_add_survey_FIP( ecl_grav_type * grav , const char * name , const ecl_file_type * restart_file );
ecl_grav_survey_type * ecl_grav_add_survey_PORMOD( ecl_grav_type * grav , const char * name , const ecl_file_type * restart_file );
ecl_grav_survey_type * ecl_grav_add_survey_RPORV( ecl_grav_type * grav , const char * name , const ecl_file_type * restart_file );
double ecl_grav_eval( const ecl_grav_type * grav , const char * base, const char * monitor , ecl_region_type * region , double utm_x, double utm_y , double depth, int phase_mask);
void ecl_grav_new_std_density( ecl_grav_type * grav , ecl_phase_enum phase , double default_density);
void ecl_grav_add_std_density( ecl_grav_type * grav , ecl_phase_enum phase , int pvtnum , double density);
#ifdef __plusplus
}
#endif
#endif

View File

@@ -0,0 +1,47 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_grav.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_GRAV_CALC_H__
#define __ECL_GRAV_CALC_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ecl_kw.h>
#include <ecl_grid.h>
#include <ecl_file.h>
double ecl_grav_phase_deltag( double utm_x ,
double utm_y ,
double tvd,
const ecl_grid_type * grid,
const ecl_file_type * init_file ,
const ecl_kw_type * sat_kw1,
const ecl_kw_type * rho_kw1,
const ecl_kw_type * porv_kw1,
const ecl_kw_type * sat_kw2,
const ecl_kw_type * rho_kw2,
const ecl_kw_type * porv_kw2);
#ifdef __cplusplus
}
#endif
#endif

146
ThirdParty/Ert/ecl/include/ecl_grid.h vendored Normal file
View File

@@ -0,0 +1,146 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_grid.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_GRID_H__
#define __ECL_GRID_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <double_vector.h>
#include <int_vector.h>
#include <ecl_kw.h>
#include <stringlist.h>
//typedef enum {
// NO_HINT = 0,
// NORTH = 1,
// CENTRAL = 2,
// SOUTH = 4,
//
typedef double (block_function_ftype) ( const double_vector_type *);
typedef struct ecl_grid_struct ecl_grid_type;
void ecl_grid_get_column_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j, double_vector_type * column);
int ecl_grid_get_global_index_from_xy_top( const ecl_grid_type * ecl_grid , double x , double y);
int ecl_grid_get_global_index_from_xy_bottom( const ecl_grid_type * ecl_grid , double x , double y);
void ecl_grid_get_corner_xyz3(const ecl_grid_type * grid , int i , int j , int k, int corner_nr , double * xpos , double * ypos , double * zpos );
void ecl_grid_get_corner_xyz1(const ecl_grid_type * grid , int global_index , int corner_nr , double * xpos , double * ypos , double * zpos );
double ecl_grid_get_cell_thickness3( const ecl_grid_type * grid , int i , int j , int k);
double ecl_grid_get_cell_thickness1( const ecl_grid_type * grid , int global_index );
double ecl_grid_get_cdepth1(const ecl_grid_type * grid , int global_index);
double ecl_grid_get_cdepth3(const ecl_grid_type * grid , int i, int j , int k);
double ecl_grid_get_depth3(const ecl_grid_type * grid , int i, int j , int k);
int ecl_grid_get_global_index_from_xy( const ecl_grid_type * ecl_grid , int k , bool lower_layer , double x , double y);
bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_index , double x , double y , double z);
bool ecl_grid_cell_contains_xyz3( const ecl_grid_type * ecl_grid , int i , int j , int k, double x , double y , double z );
double ecl_grid_get_cell_volume1( const ecl_grid_type * ecl_grid, int global_index );
double ecl_grid_get_cell_volume3( const ecl_grid_type * ecl_grid, int i , int j , int k);
bool ecl_grid_cell_contains1(const ecl_grid_type * grid , int global_index , double x , double y , double z);
bool ecl_grid_cell_contains3(const ecl_grid_type * grid , int i , int j ,int k , double x , double y , double z);
int ecl_grid_get_global_index_from_xyz(ecl_grid_type * grid , double x , double y , double z , int start_index);
const char * ecl_grid_get_name( const ecl_grid_type * );
int ecl_grid_get_active_index3(const ecl_grid_type * ecl_grid , int i , int j , int k);
int ecl_grid_get_active_index1(const ecl_grid_type * ecl_grid , int global_index);
bool ecl_grid_cell_active3(const ecl_grid_type * , int , int , int );
bool ecl_grid_cell_active1(const ecl_grid_type * , int);
bool ecl_grid_ijk_valid(const ecl_grid_type * , int , int , int );
int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int );
int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index);
ecl_grid_type * ecl_grid_alloc_GRDECL_kw( const ecl_kw_type * gridhead_kw , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw );
ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes);
ecl_grid_type * ecl_grid_alloc(const char * );
ecl_grid_type * ecl_grid_load_case( const char * case_input );
bool ecl_grid_exists( const char * case_input );
char * ecl_grid_alloc_case_filename( const char * case_input );
void ecl_grid_free(ecl_grid_type * );
void ecl_grid_free__( void * arg );
void ecl_grid_get_dims(const ecl_grid_type * , int *, int * , int * , int *);
int ecl_grid_get_nz( const ecl_grid_type * grid );
int ecl_grid_get_nx( const ecl_grid_type * grid );
int ecl_grid_get_ny( const ecl_grid_type * grid );
int ecl_grid_get_active_index(const ecl_grid_type * , int , int , int );
void ecl_grid_summarize(const ecl_grid_type * );
void ecl_grid_get_ijk1(const ecl_grid_type * , int global_index , int *, int * , int *);
void ecl_grid_get_ijk1A(const ecl_grid_type * , int active_index, int *, int * , int *);
void ecl_grid_get_ijk_from_active_index(const ecl_grid_type *, int , int *, int * , int * );
void ecl_grid_get_xyz3(const ecl_grid_type * , int , int , int , double * , double * , double *);
void ecl_grid_get_xyz1(const ecl_grid_type * grid , int global_index , double *xpos , double *ypos , double *zpos);
void ecl_grid_get_xyz1A(const ecl_grid_type * grid , int active_index , double *xpos , double *ypos , double *zpos);
int ecl_grid_get_global_size( const ecl_grid_type * ecl_grid );
bool ecl_grid_compare(const ecl_grid_type * g1 , const ecl_grid_type * g2);
int ecl_grid_get_active_size( const ecl_grid_type * ecl_grid );
double ecl_grid_get_bottom1(const ecl_grid_type * grid , int global_index);
double ecl_grid_get_bottom3(const ecl_grid_type * grid , int i, int j , int k);
double ecl_grid_get_bottom1A(const ecl_grid_type * grid , int active_index);
double ecl_grid_get_top1(const ecl_grid_type * grid , int global_index);
double ecl_grid_get_top3(const ecl_grid_type * grid , int i, int j , int k);
double ecl_grid_get_top1A(const ecl_grid_type * grid , int active_index);
double ecl_grid_get_top2(const ecl_grid_type * grid , int i, int j);
double ecl_grid_get_bottom2(const ecl_grid_type * grid , int i, int j);
int ecl_grid_locate_depth( const ecl_grid_type * grid , double depth , int i , int j );
void ecl_grid_alloc_blocking_variables(ecl_grid_type * , int );
void ecl_grid_init_blocking(ecl_grid_type * );
double ecl_grid_block_eval2d(ecl_grid_type * grid , int i, int j , block_function_ftype * blockf );
double ecl_grid_block_eval3d(ecl_grid_type * grid , int i, int j , int k ,block_function_ftype * blockf );
int ecl_grid_get_block_count3d(const ecl_grid_type * ecl_grid , int i , int j, int k);
int ecl_grid_get_block_count2d(const ecl_grid_type * ecl_grid , int i , int j);
bool ecl_grid_block_value_2d(ecl_grid_type * , double , double ,double );
bool ecl_grid_block_value_3d(ecl_grid_type * , double , double ,double , double);
bool ecl_grid_cell_invalid1(const ecl_grid_type * ecl_grid , int global_index);
bool ecl_grid_cell_invalid3(const ecl_grid_type * ecl_grid , int i , int j , int k);
double ecl_grid_cell_invalid1A(const ecl_grid_type * grid , int active_index);
void ecl_grid_dump(const ecl_grid_type * grid , FILE * stream);
/* lgr related functions */
const ecl_grid_type * ecl_grid_get_cell_lgr3(const ecl_grid_type * grid , int i, int j , int k);
const ecl_grid_type * ecl_grid_get_cell_lgr1A(const ecl_grid_type * grid , int active_index);
const ecl_grid_type * ecl_grid_get_cell_lgr1(const ecl_grid_type * grid , int global_index );
int ecl_grid_get_num_lgr(const ecl_grid_type * main_grid );
int ecl_grid_get_grid_nr( const ecl_grid_type * ecl_grid );
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid , int lgr_nr);
ecl_grid_type * ecl_grid_get_lgr(const ecl_grid_type * main_grid, const char * __lgr_name);
bool ecl_grid_has_lgr(const ecl_grid_type * main_grid, const char * __lgr_name);
stringlist_type * ecl_grid_alloc_lgr_name_list(const ecl_grid_type * ecl_grid);
int ecl_grid_get_parent_cell1( const ecl_grid_type * grid , int global_index);
int ecl_grid_get_parent_cell3( const ecl_grid_type * grid , int i , int j , int k);
const ecl_grid_type * ecl_grid_get_global_grid( const ecl_grid_type * grid );
bool ecl_grid_is_lgr( const ecl_grid_type * ecl_grid );
double ecl_grid_get_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k);
float ecl_grid_get_float_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k);
double ecl_grid_get_double_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k);
int ecl_grid_get_int_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k);
void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , FILE * stream , double double_default);
bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid );
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,102 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_INTEHEAD.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_INTEHEAD_H__
#define __ECL_INTEHEAD_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <ecl_kw.h>
#define INTEHEAD_KW "INTEHEAD" /* Long array with lots of data. */
typedef struct {
int day;
int year;
int month;
time_t sim_time;
int version; // 100, 300, 500 (Eclipse300-Thermal)
int phase_sum; // Oil = 1 Gas = 2 Water = 4
int nx;
int ny;
int nz;
int nactive;
/*-----------------------------------------------------------------*/
/* All fields below the line are taken literally (apart from
lowercasing) from the section about restart files in the
ECLIPSE File Formats Reference Manual. The elements typically
serve as dimensions in the ?WEL, ?SEG and ?CON arrays.
*/
// Pure well properties
int nwells; // Number of wells
int niwelz; // Number of elements pr well in IWEL array
int nzwelz; // Number of 8 character words pr well in ZWEL array
// Connection properties
int niconz; // Number of elements per completion in ICON array
int ncwmax; // Maximum number of completions per well
// Segment properties
int nisegz; // Number of entries pr segment in the ISEG array
int nsegmx; // The maximum number of segments pr well
int nswlmx; // The maximum number of segmented wells
int nlbrmx; // The maximum number of lateral branches pr well
int nilbrz; // The number of entries pr segment in ILBR array
} ecl_intehead_type;
/* Some magic indices used to look up in the INTEHEAD keyword. */
#define INTEHEAD_DAY_INDEX 64
#define INTEHEAD_MONTH_INDEX 65
#define INTEHEAD_YEAR_INDEX 66
#define INTEHEAD_NX_INDEX 8
#define INTEHEAD_NY_INDEX 9
#define INTEHEAD_NZ_INDEX 10
#define INTEHEAD_NACTIVE_INDEX 11
#define INTEHEAD_PHASE_INDEX 14
#define INTEHEAD_VERSION_INDEX 94 /* This is ECLIPSE100 || ECLIPSE300 - not temporal version. */
#define INTEHEAD_NWELLS_INDEX 16
#define INTEHEAD_NIWELZ_INDEX 24
#define INTEHEAD_NZWELZ_INDEX 27
#define INTEHEAD_NCWMAX_INDEX 17
#define INTEHEAD_NICONZ_INDEX 32
#define INTEHEAD_NSWLMX_INDEX 175
#define INTEHEAD_NSEGMX_INDEX 176
#define INTEHEAD_NLBRMX_INDEX 177
#define INTEHEAD_NISEGZ_INDEX 178
#define INTEHEAD_NILBRZ_INDEX 180
void ecl_intehead_free( ecl_intehead_type * intehead );
ecl_intehead_type * ecl_intehead_alloc( const ecl_kw_type * intehead_kw );
time_t ecl_intehead_date( const ecl_kw_type * intehead_kw );
void ecl_intehead_fprintf( const ecl_intehead_type * header , FILE * stream);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,41 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_io_config.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_IO_CONFIG_H__
#define __ECL_IO_CONFIG_H__
typedef struct ecl_io_config_struct ecl_io_config_type;
/* Modifiers */
void ecl_io_config_set_formatted(ecl_io_config_type *, bool );
void ecl_io_config_set_unified_restart(ecl_io_config_type *, bool );
void ecl_io_config_set_unified_summary(ecl_io_config_type *, bool );
/* Accesors */
bool ecl_io_config_get_formatted(ecl_io_config_type *);
bool ecl_io_config_get_unified_restart(ecl_io_config_type *);
bool ecl_io_config_get_unified_summary(ecl_io_config_type *);
/* Allocater & destructor */
ecl_io_config_type * ecl_io_config_alloc(bool ,bool ,bool);
void ecl_io_config_free(ecl_io_config_type * );
#endif

221
ThirdParty/Ert/ecl/include/ecl_kw.h vendored Normal file
View File

@@ -0,0 +1,221 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_kw.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_KW_H__
#define __ECL_KW_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <buffer.h>
#include <fortio.h>
#include <ecl_util.h>
UTIL_IS_INSTANCE_HEADER(ecl_kw);
typedef struct ecl_kw_struct ecl_kw_type;
void ecl_kw_set_data_ptr(ecl_kw_type * ecl_kw , char * data);
void ecl_kw_fwrite_data(const ecl_kw_type *_ecl_kw , fortio_type *fortio);
void ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio);
ecl_type_enum ecl_kw_get_type(const ecl_kw_type *);
const char * ecl_kw_get_header8(const ecl_kw_type *);
const char * ecl_kw_get_header(const ecl_kw_type * ecl_kw );
ecl_kw_type * ecl_kw_alloc_empty();
bool ecl_kw_fread_header(ecl_kw_type *, fortio_type *);
void ecl_kw_set_header_name(ecl_kw_type * , const char * );
void ecl_kw_set_header(ecl_kw_type * , const char * , int , const char *);
void ecl_kw_set_header_alloc(ecl_kw_type * , const char * , int , const char *);
bool ecl_kw_grdecl_fseek_kw(const char * , bool , bool , FILE * );
ecl_kw_type * ecl_kw_fscanf_alloc_grdecl_dynamic( FILE * stream , const char * kw , ecl_type_enum ecl_type);
ecl_kw_type * ecl_kw_fscanf_alloc_grdecl_dynamic__( FILE * stream , const char * kw , bool strict , ecl_type_enum ecl_type);
bool ecl_kw_fseek_kw(const char * , bool , bool , fortio_type *);
bool ecl_kw_fseek_last_kw(const char * , bool , fortio_type *);
void ecl_kw_inplace_update_file(const ecl_kw_type * , const char * , int ) ;
void ecl_kw_fskip(fortio_type *);
void ecl_kw_alloc_data(ecl_kw_type *);
void ecl_kw_alloc_double_data(ecl_kw_type * ecl_kw , double * values);
void ecl_kw_alloc_float_data(ecl_kw_type * ecl_kw , float * values);
bool ecl_kw_fread_realloc(ecl_kw_type *, fortio_type *);
void ecl_kw_fread(ecl_kw_type * , fortio_type * );
ecl_kw_type * ecl_kw_fscanf_alloc_grdecl_data(FILE * , int , ecl_type_enum );
void ecl_kw_fprintf_grdecl(const ecl_kw_type * , FILE * stream);
ecl_kw_type * ecl_kw_fread_alloc(fortio_type *);
void ecl_kw_free_data(ecl_kw_type *);
void ecl_kw_free(ecl_kw_type *);
void ecl_kw_free__(void *);
ecl_kw_type * ecl_kw_alloc_copy (const ecl_kw_type *);
const void * ecl_kw_copyc__(const void *);
ecl_kw_type * ecl_kw_alloc_slice_copy( const ecl_kw_type * src, int index1, int index2, int stride);
//void * ecl_kw_get_data_ref(const ecl_kw_type *);
void * ecl_kw_alloc_data_copy(const ecl_kw_type * );
void ecl_kw_memcpy(ecl_kw_type *, const ecl_kw_type *);
void ecl_kw_get_memcpy_data(const ecl_kw_type *, void *);
void ecl_kw_get_memcpy_float_data(const ecl_kw_type *ecl_kw , float *target);
void ecl_kw_get_memcpy_double_data(const ecl_kw_type *ecl_kw , double *target);
void ecl_kw_get_memcpy_int_data(const ecl_kw_type *ecl_kw , int *target);
void ecl_kw_set_memcpy_data(ecl_kw_type * , const void *);
void ecl_kw_fwrite(const ecl_kw_type *, fortio_type *);
void ecl_kw_iget(const ecl_kw_type *, int , void *);
void ecl_kw_iset_char_ptr( ecl_kw_type * ecl_kw , int index, const char * s);
const char * ecl_kw_iget_char_ptr( const ecl_kw_type * ecl_kw , int i);
void * ecl_kw_iget_ptr(const ecl_kw_type *, int);
int ecl_kw_get_size(const ecl_kw_type *);
bool ecl_kw_header_eq(const ecl_kw_type *, const char *);
bool ecl_kw_ichar_eq(const ecl_kw_type *, int , const char *);
ecl_kw_type * ecl_kw_alloc_new(const char * , int , ecl_type_enum , const void * );
ecl_kw_type * ecl_kw_alloc_new_shared(const char * , int , ecl_type_enum , void * );
void ecl_kw_fwrite_param(const char * , bool , const char * , ecl_type_enum , int , void * );
void ecl_kw_fwrite_param_fortio(fortio_type *, const char * , ecl_type_enum , int , void * );
void ecl_kw_summarize(const ecl_kw_type * ecl_kw);
void ecl_kw_fread_double_param(const char * , bool , double *);
float ecl_kw_iget_as_float(const ecl_kw_type * ecl_kw , int i);
double ecl_kw_iget_as_double(const ecl_kw_type * ecl_kw , int i);
void ecl_kw_get_data_as_double(const ecl_kw_type *, double *);
void ecl_kw_get_data_as_float(const ecl_kw_type * ecl_kw , float * float_data);
bool ecl_kw_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2);
bool ecl_kw_data_equal( const ecl_kw_type * ecl_kw , const void * data);
void ecl_kw_fskip_data__( ecl_type_enum ecl_type , int size , fortio_type * fortio);
void ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio);
void ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio);
void ecl_kw_fskip_header( fortio_type * fortio);
bool ecl_kw_is_grdecl_file(FILE * );
bool ecl_kw_is_kw_file(FILE * , bool );
void ecl_kw_inplace_sub(ecl_kw_type * , const ecl_kw_type * );
void ecl_kw_inplace_mul(ecl_kw_type * , const ecl_kw_type * );
void ecl_kw_inplace_div(ecl_kw_type * , const ecl_kw_type * );
double ecl_kw_element_sum_float( const ecl_kw_type * ecl_kw );
void ecl_kw_inplace_inv(ecl_kw_type * my_kw);
void ecl_kw_element_sum(const ecl_kw_type * , void * );
void ecl_kw_max_min(const ecl_kw_type * , void * , void *);
void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw);
double ecl_kw_iget_as_double(const ecl_kw_type * , int );
ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer);
void ecl_kw_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer);
void ecl_kw_memcpy_data( ecl_kw_type * target , const ecl_kw_type * src);
bool ecl_kw_assert_numeric( const ecl_kw_type * kw );
bool ecl_kw_assert_binary( const ecl_kw_type * kw1, const ecl_kw_type * kw2);
void ecl_kw_scalar_set__(ecl_kw_type * ecl_kw , const void * value);
void ecl_kw_scalar_set_float_or_double( ecl_kw_type * ecl_kw , double value );
#define ECL_KW_SCALAR_SET_TYPED_HEADER( ctype ) void ecl_kw_scalar_set_ ## ctype( ecl_kw_type * ecl_kw , ctype value);
ECL_KW_SCALAR_SET_TYPED_HEADER( int )
ECL_KW_SCALAR_SET_TYPED_HEADER( float )
ECL_KW_SCALAR_SET_TYPED_HEADER( double )
#undef ECL_KW_SCALAR_SET_TYPED_HEADER
ecl_kw_type * ecl_kw_alloc_scatter_copy( const ecl_kw_type * src_kw , int target_size , const int * mapping, void * def_value);
void ecl_kw_inplace_add( ecl_kw_type * target_kw , const ecl_kw_type * add_kw);
void ecl_kw_inplace_add_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * add_kw);
void ecl_kw_inplace_sub_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * sub_kw);
void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * index_set , const ecl_kw_type * src_kw);
bool ecl_kw_assert_binary_numeric( const ecl_kw_type * kw1, const ecl_kw_type * kw2);
#define ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( ctype ) bool ecl_kw_assert_binary_ ## ctype( const ecl_kw_type * kw1 , const ecl_kw_type * kw2);
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( int )
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( float )
ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER( double )
#undef ECL_KW_ASSERT_TYPED_BINARY_OP_HEADER
#define ECL_KW_SCALE_TYPED_HEADER( ctype ) void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor);
ECL_KW_SCALE_TYPED_HEADER( int )
ECL_KW_SCALE_TYPED_HEADER( float )
ECL_KW_SCALE_TYPED_HEADER( double )
#undef ECL_KW_SCALE_TYPED_HEADER
void ecl_kw_scale_float_or_double( ecl_kw_type * ecl_kw , double scale_factor );
#define ECL_KW_SHIFT_TYPED_HEADER( ctype ) void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_factor);
ECL_KW_SHIFT_TYPED_HEADER( int )
ECL_KW_SHIFT_TYPED_HEADER( float )
ECL_KW_SHIFT_TYPED_HEADER( double )
#undef ECL_KW_SHIFT_TYPED_HEADER
void ecl_kw_shift_float_or_double( ecl_kw_type * ecl_kw , double shift_value );
#define ECL_KW_IGET_TYPED_HEADER(type) type ecl_kw_iget_ ## type(const ecl_kw_type * , int);
ECL_KW_IGET_TYPED_HEADER(double);
ECL_KW_IGET_TYPED_HEADER(float);
ECL_KW_IGET_TYPED_HEADER(int);
#undef ECL_KW_IGET_TYPED_HEADER
bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i );
#define ECL_KW_ISET_TYPED_HEADER(type) void ecl_kw_iset_ ## type(ecl_kw_type * , int , type );
ECL_KW_ISET_TYPED_HEADER(double);
ECL_KW_ISET_TYPED_HEADER(float);
ECL_KW_ISET_TYPED_HEADER(int);
#undef ECL_KW_ISET_TYPED_HEADER
void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value);
#define ECL_KW_GET_TYPED_PTR_HEADER(type) type * ecl_kw_get_ ## type ## _ptr(const ecl_kw_type *);
ECL_KW_GET_TYPED_PTR_HEADER(double);
ECL_KW_GET_TYPED_PTR_HEADER(float);
ECL_KW_GET_TYPED_PTR_HEADER(int);
ECL_KW_GET_TYPED_PTR_HEADER(bool);
#undef ECL_KW_GET_TYPED_PTR_HEADER
#define ECL_KW_SET_INDEXED_HEADER(ctype ) void ecl_kw_set_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype value);
ECL_KW_SET_INDEXED_HEADER( double );
ECL_KW_SET_INDEXED_HEADER( float );
ECL_KW_SET_INDEXED_HEADER( int );
#undef ECL_KW_SET_INDEXED_HEADER
#define ECL_KW_SHIFT_INDEXED_HEADER(ctype) void ecl_kw_shift_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype shift);
ECL_KW_SHIFT_INDEXED_HEADER( int )
ECL_KW_SHIFT_INDEXED_HEADER( float )
ECL_KW_SHIFT_INDEXED_HEADER( double )
#undef ECL_KW_SHIFT_INDEXED_HEADER
#define ECL_KW_SCALE_INDEXED_HEADER(ctype) void ecl_kw_scale_indexed_ ## ctype( ecl_kw_type * ecl_kw, const int_vector_type * index_list , ctype scale);
ECL_KW_SCALE_INDEXED_HEADER( int )
ECL_KW_SCALE_INDEXED_HEADER( float )
ECL_KW_SCALE_INDEXED_HEADER( double )
#undef ECL_KW_SCALE_INDEXED_HEADER
#define ECL_KW_MAX_MIN_HEADER( ctype ) void ecl_kw_max_min_ ## ctype( const ecl_kw_type * ecl_kw , ctype * _max , ctype * _min);
ECL_KW_MAX_MIN_HEADER( int )
ECL_KW_MAX_MIN_HEADER( float )
ECL_KW_MAX_MIN_HEADER( double )
#undef ECL_KW_MAX_MIN_HEADER
#include <ecl_kw_grdecl.h>
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,36 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_kw_grdecl.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.
*/
// This header does not define datatypes; just a couple of functions. It should
// be included from the ecl_kw.h header, so application do not need to include this
// header explicitly.
#ifndef __ECL_KW_GRDECL_H__
#define __ECL_KW_GRDECL_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,172 @@
#ifndef __ECL_KW_MAGIC_H__
#define __ECL_KW_MAGIC_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
This header file contains names and indices of ECLIPSE keywords
which have special significance in various files; everything
related to the INTEHEAD keyword is in the ecl_intehead.h header
file.
*/
/*****************************************************************/
/* INIT and RESTART files: */
/*****************************************************************/
#define SEQNUM_KW "SEQNUM" /* Contains the report step as the only data;
not present in non-unified files, where the
report step can be inferred from the filename. */
#define IWEL_KW "IWEL"
#define ZWEL_KW "ZWEL"
#define ICON_KW "ICON"
#define ISEG_KW "ISEG"
#define PORV_KW "PORV"
#define AQUIFER_KW "AQUIFERN"
/*****************************************************************/
/* Summary files */
/*****************************************************************/
/* Summary header file */
#define STARTDAT_KW "STARTDAT" /* Intgere keyword containing day,month,year. */
#define WGNAMES_KW "WGNAMES" /* The names of wells/groups for the summary vectors. */
#define KEYWORDS_KW "KEYWORDS" /* The variable type for the various summary vectors. */
#define UNITS_KW "UNITS" /* The units, i.e SM^3/DAY the summary vectors. */
#define DIMENS_KW "DIMENS" /* The dimensions of the grid - also used in the GRID files. */
#define NUMS_KW "NUMS" /* Extra numeric qualifiers for the summary variables, like cell number. */
#define LGRS_KW "LGRS" /* The lgr name for a vector originating from an lgr. */
#define NUMLX_KW "NUMLX" /* For block variables defined in a an lgr this is i coordinate in the lgr. */
#define NUMLY_KW "NUMLY" /* ... j coordinate in the lgr. */
#define NUMLZ_KW "NUMLZ" /* ... k coordinate in the lgr. */
/* Magic indices used to locate day,month,year from the STARTDAT keyword. */
#define STARTDAT_DAY_INDEX 0
#define STARTDAT_MONTH_INDEX 1
#define STARTDAT_YEAR_INDEX 2
/* Magic indices uset to locate the grid dimensions from the DIMENS
keyword in the SMSPEC files. Observe that these magic indices
differ from the magic indices used to look up grid dimensions from
the DIMENS keyword in GRID files. */
#define DIMENS_SMSPEC_NX_INDEX 1
#define DIMENS_SMSPEC_NY_INDEX 2
#define DIMENS_SMSPEC_NZ_INDEX 3
/* Summary data files: */
#define SEQHDR_KW "SEQHDR" // Contains a single 'magic' integer - not used in libecl.
#define PARAMS_KW "PARAMS" // Contains the actual summary data for one timestep.
#define MINISTEP_KW "MINISTEP" // Scalar integer - contains the timestep number.
/*
There are no magic indices in the summary data files, for all
interesting data the table created from the ecl_smspec file must be
consulted.
*/
/*****************************************************************/
/* RFT Files */
/*****************************************************************/
/* The files with extension .RFT can contain three quite different
types of information: RFT / PLT / SEGMENT, this is indicated by an
element of the WELLETC keyword. The keywords below are organized in
common keywords, keywords for RFTs and keywords for PLTs. The
special information for SEGMENT data is not internalized at all,
and there are also several additional keywords for the PLTs which
are not internalized. */
/* Common keywords */
#define TIME_KW "TIME" /* The days since simulation start when
an RFT is performed, also used as
block header when splitting an RFT
file into different wells and timesteps. */
#define DATE_KW "DATE" /* The date of an RFT as integers: (day,month,year). */
#define WELLETC_KW "WELLETC" /* The type of date RFT|PLT|SEGMENT and well name are
extracted from this keyword. */
#define CONIPOS_KW "CONIPOS" /* The i-index of the connections in the well. */
#define CONJPOS_KW "CONJPOS" /* The j-index ... */
#define CONKPOS_KW "CONKPOS" /* The k-index ... */
/* RFT keywords */
#define SWAT_KW "SWAT" /* The kewyord containing SWAT. */
#define SGAS_KW "SGAS" /* The kewyord containing SGAS. */
#define PRESSURE_KW "PRESSURE" /* The kewyord containing PRESSURE. */
#define DEPTH_KW "DEPTH" /* The depth of the connection. */
/* PLT keywords */
#define CONDEPTH_KW "CONDEPTH" /* The depth of the connection. */
#define CONWRAT_KW "CONWRAT" /* Water rate in a connection. */
#define CONGRAT_KW "CONGRAT" /* Gas ... */
#define CONORAT_KW "CONORAT" /* Oil ... */
#define CONPRES_KW "CONPRES" /* Pressure ... */
#define WELLETC_TYPE_INDEX 5 /* At this keyword the WELLETC keyword contains a string
containing 'R', 'P' , or 'S' for RFT, PLT or SEGMENT data
respectively.*/
#define WELLETC_NAME_INDEX 1 /* The name of well being investigated is on this index of
the WELLETC keyword. */
/* Magic indices used to get day,month,year from the DATE
keyword. */
#define DATE_DAY_INDEX 0
#define DATE_MONTH_INDEX 1
#define DATE_YEAR_INDEX 2
/*****************************************************************/
/* GRID and EGRID files. */
/*****************************************************************/
/* GRID and EGRID files have very different structure, and only a few
keywords are shared. */
/* Common keywords */
#define MAPAXES_KW "MAPAXES" /* Keyword used to transform from grid coordinates to
world coordinates. */
#define LGR_KW "LGR" /* Name of LGR; for GRID files it can contain two elements,
the second element will be the name of the parent. */
/* EGRID keywords */
#define LGR_PARENT_KW "LGRPARNT" /* The name of the parent for an LGR. */
#define COORDS_KW "COORDS" /* The (x,y) coordinates of the top and bottom of the pillars constituting the grid. */
#define ZCORN_KW "ZCORN" /* Z coordinate where pillars cross planes. */
#define ACTNUM_KW "ACTNUM" /* Integer flag of with active=0,1. */
#define HOSTNUM_KW "HOSTNUM" /* For cells in LGR - pointing back to cell nr in
parent grid. */
/* GRID keywords */
#define GRIDHEAD_KW "GRIDHEAD" /* Header information for GRID files. */
#define COORD_KW "COORD" /* Header information for one cell in GRID file. */
#define CORNERS_KW "CORNERS" /* Vector containing (x,y,z) x 8 elements - all corners in a cell. */
#define DIMENS_KW "DIMENS" /* The dimensions of the grid. */
#define GLOBAL_STRING "GLOBAL"
#define GRIDHEAD_TYPE_INDEX 0
#define GRIDHEAD_NX_INDEX 1
#define GRIDHEAD_NY_INDEX 2
#define GRIDHEAD_NZ_INDEX 3
/* Observe that these indices are one value lower the values used
in the ecl_smspec file. */
#define DIMENS_NX_INDEX 0
#define DIMENS_NY_INDEX 1
#define DIMENS_NZ_INDEX 2
#ifdef __cplusplus
}
#endif
#endif

181
ThirdParty/Ert/ecl/include/ecl_region.h vendored Normal file
View File

@@ -0,0 +1,181 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_region.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_REGION_H__
#define __ECL_REGION_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ecl_box.h>
#include <ecl_grid.h>
#include <stdbool.h>
#include <int_vector.h>
#include <geo_polygon.h>
typedef enum {
SELECT_ALL = 0,
DESELECT_ALL = 1,
SELECT_FROM_IJK = 2,
DESELECT_FROM_IJK = 3,
SELECT_FROM_I = 4,
DSELECT_FROM_I = 5,
SELECT_FROM_J = 6,
DSELECT_FROM_J = 7,
SELECT_FROM_K = 8,
DSELECT_FROM_K = 9,
SELECT_EQUAL = 10,
DESELECT_EQUAL = 11,
SELECT_IN_INTERVAL = 12,
DESELECT_IN_INTERVAL = 13,
INVERT_SELECTION = 14
} ecl_region_select_cmd;
typedef struct ecl_region_struct ecl_region_type;
void ecl_region_unlock( ecl_region_type * region );
void ecl_region_lock( ecl_region_type * region );
void ecl_region_reset( ecl_region_type * ecl_region );
ecl_region_type * ecl_region_alloc_copy( const ecl_region_type * ecl_region );
ecl_region_type * ecl_region_alloc( const ecl_grid_type * ecl_grid , bool preselect);
void ecl_region_free( ecl_region_type * region );
void ecl_region_free__( void * __region );
const int_vector_type * ecl_region_get_active_list( ecl_region_type * region );
const int_vector_type * ecl_region_get_global_list( ecl_region_type * region );
const int_vector_type * ecl_region_get_global_active_list( ecl_region_type * region );
bool ecl_region_contains_ijk( const ecl_region_type * ecl_region , int i , int j , int k);
bool ecl_region_contains_global( const ecl_region_type * ecl_region , int global_index);
bool ecl_region_contains_active( const ecl_region_type * ecl_region , int active_index);
void ecl_region_invert_selection( ecl_region_type * region );
void ecl_region_select_all( ecl_region_type * region);
void ecl_region_deselect_all( ecl_region_type * region );
void ecl_region_select_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value);
void ecl_region_deselect_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value);
void ecl_region_select_equal( ecl_region_type * region , const ecl_kw_type * ecl_kw, int value);
void ecl_region_deselect_equal( ecl_region_type * region , const ecl_kw_type * ecl_kw, int value);
void ecl_region_select_inactive_cells( ecl_region_type * region );
void ecl_region_deselect_inactive_cells( ecl_region_type * region );
void ecl_region_select_active_cells( ecl_region_type * region );
void ecl_region_deselect_active_cells( ecl_region_type * region );
void ecl_region_select_from_box( ecl_region_type * region , const ecl_box_type * ecl_box );
void ecl_region_deselect_from_box( ecl_region_type * region , const ecl_box_type * ecl_box );
void ecl_region_select_from_ijkbox( ecl_region_type * region , int i1 , int i2 , int j1 , int j2 , int k1 , int k2);
void ecl_region_deselect_from_ijkbox( ecl_region_type * region , int i1 , int i2 , int j1 , int j2 , int k1 , int k2);
void ecl_region_select_i1i2( ecl_region_type * region , int i1 , int i2);
void ecl_region_deselect_i1i2( ecl_region_type * region , int i1 , int i2);
void ecl_region_select_j1j2( ecl_region_type * region , int j1 , int j2);
void ecl_region_deselect_j1j2( ecl_region_type * region , int j1 , int i2);
void ecl_region_select_k1k2( ecl_region_type * region , int k1 , int k2);
void ecl_region_deselect_k1k2( ecl_region_type * region , int k1 , int i2);
void ecl_region_select_shallow_cells( ecl_region_type * region , double depth_limit );
void ecl_region_deselect_shallow_cells( ecl_region_type * region , double depth_limit );
void ecl_region_select_deep_cells( ecl_region_type * region , double depth_limit );
void ecl_region_deselect_deep_cells( ecl_region_type * region , double depth_limit );
void ecl_region_select_thin_cells( ecl_region_type * ecl_region , double dz_limit );
void ecl_region_deselect_thin_cells( ecl_region_type * ecl_region , double dz_limit );
void ecl_region_select_thick_cells( ecl_region_type * ecl_region , double dz_limit );
void ecl_region_deselect_thick_cells( ecl_region_type * ecl_region , double dz_limit );
void ecl_region_select_small_cells( ecl_region_type * ecl_region , double volum_limit );
void ecl_region_deselect_small_cells( ecl_region_type * ecl_region , double volum_limit );
void ecl_region_select_large_cells( ecl_region_type * ecl_region , double volum_limit );
void ecl_region_deselect_large_cells( ecl_region_type * ecl_region , double volum_limit );
void ecl_region_select_global_index( ecl_region_type * ecl_region , int global_index);
void ecl_region_deselect_global_index( ecl_region_type * ecl_region , int global_index);
void ecl_region_select_active_index( ecl_region_type * ecl_region , int active_index);
void ecl_region_deselect_active_index( ecl_region_type * ecl_region , int active_index);
void ecl_region_intersection( ecl_region_type * region , const ecl_region_type * new_region );
void ecl_region_union( ecl_region_type * region , const ecl_region_type * new_region );
void ecl_region_subtract( ecl_region_type * region , const ecl_region_type * new_region);
void ecl_region_xor( ecl_region_type * region , const ecl_region_type * new_region);
void ecl_region_select_smaller( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit);
void ecl_region_deselect_smaller( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit);
void ecl_region_select_larger( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit);
void ecl_region_deselect_larger( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , float limit);
void ecl_region_cmp_select_less( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2);
void ecl_region_cmp_deselect_less( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2);
void ecl_region_cmp_select_more( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2);
void ecl_region_cmp_deselect_more( ecl_region_type * ecl_region , const ecl_kw_type * kw1 , const ecl_kw_type * kw2);
void ecl_region_select_in_cylinder( ecl_region_type * region , double x0 , double y0, double R);
void ecl_region_deselect_in_cylinder( ecl_region_type * region , double x0 , double y0, double R);
void ecl_region_select_in_zcylinder( ecl_region_type * region , double x0 , double y0, double R , double z1 , double z2);
void ecl_region_deselect_in_zcylinder( ecl_region_type * region , double x0 , double y0, double R, double z1 , double z2);
void ecl_region_select_above_plane( ecl_region_type * region, const double n[3] , const double p[3]);
void ecl_region_select_below_plane( ecl_region_type * region, const double n[3] , const double p[3]);
void ecl_region_deselect_above_plane( ecl_region_type * region, const double n[3] , const double p[3]);
void ecl_region_deselect_below_plane( ecl_region_type * region, const double n[3] , const double p[3]);
void ecl_region_select_inside_polygon( ecl_region_type * region , const geo_polygon_type * polygon);
void ecl_region_deselect_inside_polygon( ecl_region_type * region , const geo_polygon_type * polygon);
void ecl_region_select_outside_polygon( ecl_region_type * region , const geo_polygon_type * polygon);
void ecl_region_deselect_outside_polygon( ecl_region_type * region , const geo_polygon_type * polygon);
/*****************************************************************/
/* Functions to manipulate ecl_kw instances . */
void ecl_region_set_kw_int( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , int value, bool force_active);
void ecl_region_set_kw_float( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , float value , bool force_active);
void ecl_region_set_kw_double( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , double value , bool force_active);
void ecl_region_kw_copy( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , const ecl_kw_type * src_kw , bool force_active);
int ecl_region_get_kw_size( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , bool force_active);
/*****************************************************************/
/* set/get the name */
void ecl_region_set_name( ecl_region_type * region , const char * name );
const char * ecl_region_get_name( const ecl_region_type * region );
/*****************************************************************/
/* Stupid cpp compat/legacy/cruft functions. */
int ecl_region_get_active_size_cpp( ecl_region_type * region );
int ecl_region_get_global_size_cpp( ecl_region_type * region );
const int * ecl_region_get_active_list_cpp( ecl_region_type * region );
const int * ecl_region_get_global_list_cpp( ecl_region_type * region );
/*****************************************************************/
UTIL_IS_INSTANCE_HEADER( ecl_region );
UTIL_SAFE_CAST_HEADER( ecl_region );
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,58 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_rft_file.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_RFT_FILE_H__
#define __ECL_RFT_FILE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <ecl_rft_node.h>
#include <stringlist.h>
typedef struct ecl_rft_file_struct ecl_rft_file_type;
char * ecl_rft_file_alloc_case_filename(const char * case_input );
const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file );
ecl_rft_file_type * ecl_rft_file_alloc_case(const char * case_input );
bool ecl_rft_file_case_has_rft(const char * case_input );
bool ecl_rft_file_case_has_rft( const char * case_input );
ecl_rft_file_type * ecl_rft_file_alloc(const char * );
void ecl_rft_file_free(ecl_rft_file_type * );
void ecl_rft_file_block(const ecl_rft_file_type * , double , const char * , int , const double * , int * , int * , int *);
void ecl_rft_file_fprintf_rft_obs(const ecl_rft_file_type * , double , const char * , const char *, const char * , double);
ecl_rft_node_type * ecl_rft_file_get_node(const ecl_rft_file_type * , const char * );
void ecl_rft_file_summarize(const ecl_rft_file_type * , bool );
void ecl_rft_file_xml_summary( const ecl_rft_file_type * rft_file );
const ecl_rft_node_type * ecl_rft_file_get_well_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time);
int ecl_rft_file_get_size__( const ecl_rft_file_type * rft_file, const char * well_pattern , time_t recording_time);
int ecl_rft_file_get_size( const ecl_rft_file_type * rft_file);
const ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , int index);
const ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, int index);
bool ecl_rft_file_has_well( const ecl_rft_file_type * rft_file , const char * well);
int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const char * well);
stringlist_type * ecl_rft_file_alloc_well_list(const ecl_rft_file_type * rft_file );
int ecl_rft_file_get_num_wells( const ecl_rft_file_type * rft_file );
void ecl_rft_file_free__( void * arg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,60 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_rft_node.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_RFT_NODE_H__
#define __ECL_RFT_NODE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ecl_file.h>
#include <stdbool.h>
typedef enum { RFT = 1 ,
PLT = 2 ,
SEGMENT = 3 /* Not really implemented */ } ecl_rft_enum;
typedef struct ecl_rft_node_struct ecl_rft_node_type;
int ecl_rft_node_lookup_ijk( const ecl_rft_node_type * rft_node , int i, int j , int k);
void ecl_rft_node_fprintf_rft_obs(const ecl_rft_node_type * , double , const char * , const char * , double );
ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_type * file_map );
const char * ecl_rft_node_get_well_name(const ecl_rft_node_type * );
void ecl_rft_node_free(ecl_rft_node_type * );
void ecl_rft_node_free__(void * );
void ecl_rft_node_block2(const ecl_rft_node_type * , int , const double * , const double * , int * , int * , int *);
void ecl_rft_node_block(const ecl_rft_node_type * , double , int , const double * , int * , int * , int *);
time_t ecl_rft_node_get_date(const ecl_rft_node_type * );
int ecl_rft_node_get_size(const ecl_rft_node_type * );
void ecl_rft_node_summarize(const ecl_rft_node_type * , bool );
const char * ecl_rft_node_get_well_name( const ecl_rft_node_type * rft_node );
void ecl_rft_node_iget_ijk( const ecl_rft_node_type * rft_node , int index , int *i , int *j , int *k);
void ecl_rft_node_export_DEPTH(const ecl_rft_node_type * , const char * );
double ecl_rft_node_iget_pressure( const ecl_rft_node_type * rft_node , int index);
double ecl_rft_node_iget_depth( const ecl_rft_node_type * rft_node , int index);
double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index);
double ecl_rft_node_iget_grat( const ecl_rft_node_type * rft_node , int index);
double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index);
double ecl_rft_node_iget_swat( const ecl_rft_node_type * rft_node , int index);
double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index);
#ifdef __cplusplus
}
#endif
#endif

132
ThirdParty/Ert/ecl/include/ecl_smspec.h vendored Normal file
View File

@@ -0,0 +1,132 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_smspec.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_SMSPEC__
#define __ECL_SMSPEC__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <stdbool.h>
#include <stringlist.h>
typedef struct ecl_smspec_struct ecl_smspec_type;
/**
These are the different variable types, see table 3.4 in the
ECLIPFE file format docuemntation for naming conventions.
Only the variable types marked with "X" below are supported in the
remaining implementation. To add support for a new variable type
the functions smspec_node_alloc(), ecl_smsepec_fread_header() and
ecl_smspec_install_gen_key() must be updated.
*/
typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
ECL_SMSPEC_AQUIFER_VAR = 1 ,
ECL_SMSPEC_WELL_VAR = 2 , /* X */
ECL_SMSPEC_REGION_VAR = 3 , /* X */
ECL_SMSPEC_FIELD_VAR = 4 , /* X */
ECL_SMSPEC_GROUP_VAR = 5 , /* X */
ECL_SMSPEC_BLOCK_VAR = 6 , /* X */
ECL_SMSPEC_COMPLETION_VAR = 7 , /* X */
ECL_SMSPEC_LOCAL_BLOCK_VAR = 8 , /* X */
ECL_SMSPEC_LOCAL_COMPLETION_VAR = 9 , /* X */
ECL_SMSPEC_LOCAL_WELL_VAR = 10 , /* X */
ECL_SMSPEC_NETWORK_VAR = 11 ,
ECL_SMSPEC_REGION_2_REGION_VAR = 12 ,
ECL_SMSPEC_SEGMENT_VAR = 13 , /* X */
ECL_SMSPEC_MISC_VAR = 14 /* X */} ecl_smspec_var_type;
ecl_smspec_var_type ecl_smspec_iget_var_type( const ecl_smspec_type * smspec , int index );
bool ecl_smspec_needs_num( ecl_smspec_var_type var_type );
bool ecl_smspec_needs_wgname( ecl_smspec_var_type var_type );
const char * ecl_smspec_get_var_type_name( ecl_smspec_var_type var_type );
ecl_smspec_var_type ecl_smspec_identify_var_type(const ecl_smspec_type * smspec , const char * );
bool ecl_smspec_general_is_total(const ecl_smspec_type * ecl_smspec , const char * gen_key);
bool ecl_smspec_is_rate(const ecl_smspec_type * smspec , int kw_index);
ecl_smspec_type * ecl_smspec_fread_alloc(const char * , const char *, bool include_restart);
void ecl_smspec_free( ecl_smspec_type *);
void ecl_smspec_set_time_info( const ecl_smspec_type * , const float * , double * , time_t * );
int ecl_smspec_get_well_var_index(const ecl_smspec_type * ecl_smspec , const char * well , const char *var);
bool ecl_smspec_has_well_var(const ecl_smspec_type * ecl_smspec , const char * well , const char *var);
int ecl_smspec_get_group_var_index(const ecl_smspec_type * ecl_smspec , const char * group , const char *var);
bool ecl_smspec_has_group_var(const ecl_smspec_type * ecl_smspec , const char * group , const char *var);
int ecl_smspec_get_field_var_index(const ecl_smspec_type * ecl_smspec , const char *var);
bool ecl_smspec_has_field_var(const ecl_smspec_type * ecl_smspec , const char *var);
int ecl_smspec_get_block_var_index(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
bool ecl_smspec_has_block_var(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
int ecl_smspec_get_block_var_index_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);
bool ecl_smspec_has_block_var_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);
int ecl_smspec_get_region_var_index(const ecl_smspec_type * ecl_smspec , int region_nr , const char *var);
bool ecl_smspec_has_region_var(const ecl_smspec_type * ecl_smspec , int region_nr , const char *var);
int ecl_smspec_get_misc_var_index(const ecl_smspec_type * ecl_smspec , const char *var);
bool ecl_smspec_has_misc_var(const ecl_smspec_type * ecl_smspec , const char *var);
int ecl_smspec_get_well_completion_var_index(const ecl_smspec_type * ecl_smspec , const char * well , const char *var, int cell_nr);
bool ecl_smspec_has_well_completion_var(const ecl_smspec_type * ecl_smspec , const char * well , const char *var, int cell_nr);
int ecl_smspec_get_general_var_index(const ecl_smspec_type * ecl_smspec , const char * lookup_kw);
bool ecl_smspec_has_general_var(const ecl_smspec_type * ecl_smspec , const char * lookup_kw);
const char * ecl_smspec_get_general_var_unit( const ecl_smspec_type * ecl_smspec , const char * lookup_kw);
ecl_smspec_var_type ecl_smspec_iget_var_type( const ecl_smspec_type * smspec , int index );
const char * ecl_smspec_iget_unit( const ecl_smspec_type * smspec , int index );
int ecl_smspec_iget_num( const ecl_smspec_type * smspec , int index );
const char * ecl_smspec_iget_wgname( const ecl_smspec_type * smspec , int index );
const char * ecl_smspec_iget_keyword( const ecl_smspec_type * smspec , int index );
void ecl_smspec_select_matching_general_var_list( const ecl_smspec_type * smspec , const char * pattern , stringlist_type * keys);
stringlist_type * ecl_smspec_alloc_matching_general_var_list(const ecl_smspec_type * smspec , const char * pattern);
time_t ecl_smspec_get_start_time(const ecl_smspec_type * );
/*****************************************************************/
bool ecl_smspec_get_formatted( const ecl_smspec_type * ecl_smspec);
const char * ecl_smspec_get_header_file( const ecl_smspec_type * ecl_smspec );
const char * ecl_smspec_get_simulation_case(const ecl_smspec_type * );
stringlist_type * ecl_smspec_alloc_well_list( const ecl_smspec_type * smspec , const char * pattern);
stringlist_type * ecl_smspec_alloc_group_list( const ecl_smspec_type * smspec , const char * pattern);
stringlist_type * ecl_smspec_alloc_well_var_list( const ecl_smspec_type * smspec );
const char * ecl_smspec_get_simulation_path(const ecl_smspec_type * ecl_smspec);
const char * ecl_smspec_get_base_name( const ecl_smspec_type * ecl_smspec);
const stringlist_type * ecl_smspec_get_restart_list( const ecl_smspec_type * ecl_smspec);
const char * ecl_smspec_get_join_string( const ecl_smspec_type * smspec);
int ecl_smspec_get_param_size( const ecl_smspec_type * smspec );
const char * ecl_smspec_iget_general_key( const ecl_smspec_type * smspec , int index);
#ifdef __cplusplus
}
#endif
#endif

168
ThirdParty/Ert/ecl/include/ecl_sum.h vendored Normal file
View File

@@ -0,0 +1,168 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_sum.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_SUM_H__
#define __ECL_SUM_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <stringlist.h>
#include <ecl_smspec.h>
#include <time_t_vector.h>
#include <stringlist.h>
#include <double_vector.h>
typedef struct ecl_sum_struct ecl_sum_type;
bool ecl_sum_check_sim_time( const ecl_sum_type * sum , time_t sim_time);
bool ecl_sum_check_sim_days( const ecl_sum_type * sum , double sim_days);
const char * ecl_sum_get_keyword( const ecl_sum_type * sum , const char * gen_key );
const char * ecl_sum_get_wgname( const ecl_sum_type * sum , const char * gen_key );
const char * ecl_sum_get_unit( const ecl_sum_type * sum , const char * gen_key );
int ecl_sum_get_num( const ecl_sum_type * sum , const char * gen_key );
double ecl_sum_iiget( const ecl_sum_type * ecl_sum , int internal_index , int param_index);
const char * ecl_sum_iget_unit( const ecl_sum_type * ecl_sum , int param_index);
int ecl_sum_iget_num( const ecl_sum_type * sum , int param_index );
const char * ecl_sum_iget_wgname( const ecl_sum_type * sum , int param_index );
const char * ecl_sum_iget_keyword( const ecl_sum_type * sum , int param_index );
int ecl_sum_get_data_length( const ecl_sum_type * ecl_sum );
double ecl_sum_iget_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , int param_index);
double ecl_sum_iget_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , int param_index );
void ecl_sum_summarize( const ecl_sum_type * ecl_sum , FILE * stream );
bool ecl_sum_general_is_total(const ecl_sum_type * ecl_sum , const char * gen_key);
bool ecl_sum_var_is_total(const ecl_sum_type * ecl_sum , const char * gen_key);
void ecl_sum_free_data(ecl_sum_type * );
void ecl_sum_free__(void * );
void ecl_sum_free(ecl_sum_type * );
ecl_sum_type * ecl_sum_fread_alloc(const char * , const stringlist_type * data_files, const char * key_join_string);
ecl_sum_type * ecl_sum_fread_alloc_case(const char * , const char * key_join_string);
ecl_sum_type * ecl_sum_fread_alloc_case__(const char * , const char * key_join_string , bool include_restart);
/* Accessor functions : */
double ecl_sum_get_well_var(const ecl_sum_type * ecl_sum , int time_index , const char * well , const char *var);
int ecl_sum_get_well_var_index(const ecl_sum_type * ecl_sum , const char * well , const char *var);
bool ecl_sum_has_well_var(const ecl_sum_type * ecl_sum , const char * well , const char *var);
double ecl_sum_get_well_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * well , const char * var);
double ecl_sum_get_well_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * well , const char * var);
double ecl_sum_get_group_var(const ecl_sum_type * ecl_sum , int time_index , const char * group , const char *var);
int ecl_sum_get_group_var_index(const ecl_sum_type * ecl_sum , const char * group , const char *var);
bool ecl_sum_has_group_var(const ecl_sum_type * ecl_sum , const char * group , const char *var);
double ecl_sum_get_field_var(const ecl_sum_type * ecl_sum , int time_index , const char *var);
int ecl_sum_get_field_var_index(const ecl_sum_type * ecl_sum , const char *var);
bool ecl_sum_has_field_var(const ecl_sum_type * ecl_sum , const char *var);
double ecl_sum_get_field_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var);
double ecl_sum_get_field_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var);
double ecl_sum_get_block_var(const ecl_sum_type * ecl_sum , int time_index , const char * block_var , int block_nr);
int ecl_sum_get_block_var_index(const ecl_sum_type * ecl_sum , const char * block_var , int block_nr);
bool ecl_sum_has_block_var(const ecl_sum_type * ecl_sum , const char * block_var , int block_nr);
double ecl_sum_get_block_var_ijk(const ecl_sum_type * ecl_sum , int time_index , const char * block_var , int i , int j , int k);
int ecl_sum_get_block_var_index_ijk(const ecl_sum_type * ecl_sum , const char * block_var , int i , int j , int k);
bool ecl_sum_has_block_var_ijk(const ecl_sum_type * ecl_sum , const char * block_var , int i , int j , int k);
double ecl_sum_get_region_var(const ecl_sum_type * ecl_sum , int time_index , int region_nr , const char *var);
int ecl_sum_get_region_var_index(const ecl_sum_type * ecl_sum , int region_nr , const char *var);
bool ecl_sum_has_region_var(const ecl_sum_type * ecl_sum , int region_nr , const char *var);
double ecl_sum_get_misc_var(const ecl_sum_type * ecl_sum , int time_index , const char *var);
int ecl_sum_get_misc_var_index(const ecl_sum_type * ecl_sum , const char *var);
bool ecl_sum_has_misc_var(const ecl_sum_type * ecl_sum , const char *var);
double ecl_sum_get_well_completion_var(const ecl_sum_type * ecl_sum , int time_index , const char * well , const char *var, int cell_nr);
int ecl_sum_get_well_completion_var_index(const ecl_sum_type * ecl_sum , const char * well , const char *var, int cell_nr);
bool ecl_sum_has_well_completion_var(const ecl_sum_type * ecl_sum , const char * well , const char *var, int cell_nr);
double ecl_sum_get_general_var(const ecl_sum_type * ecl_sum , int time_index , const char * lookup_kw);
int ecl_sum_get_general_var_index(const ecl_sum_type * ecl_sum , const char * lookup_kw);
bool ecl_sum_has_general_var(const ecl_sum_type * ecl_sum , const char * lookup_kw);
double ecl_sum_get_general_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var);
double ecl_sum_get_general_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var);
const char * ecl_sum_get_general_var_unit( const ecl_sum_type * ecl_sum , const char * var);
/***************/
void ecl_sum_fprintf(const ecl_sum_type * , FILE * , const stringlist_type * , bool report_only , bool print_header);
/* Time related functions */
int ecl_sum_get_first_gt( const ecl_sum_type * ecl_sum , int param_index , double limit);
int ecl_sum_get_first_lt( const ecl_sum_type * ecl_sum , int param_index , double limit);
int ecl_sum_get_last_report_step( const ecl_sum_type * ecl_sum );
int ecl_sum_get_first_report_step( const ecl_sum_type * ecl_sum );
bool ecl_sum_has_report_step(const ecl_sum_type * ecl_sum , int report_step );
time_t ecl_sum_get_report_time( const ecl_sum_type * ecl_sum , int report_step );
time_t ecl_sum_iget_sim_time( const ecl_sum_type * ecl_sum , int index );
double ecl_sum_iget_sim_days( const ecl_sum_type * ecl_sum , int time_index);
int ecl_sum_iget_report_step( const ecl_sum_type * ecl_sum , int internal_index );
int ecl_sum_iget_mini_step( const ecl_sum_type * ecl_sum , int internal_index );
double ecl_sum_iget_general_var(const ecl_sum_type * ecl_sum , int internal_index , const char * lookup_kw);
void ecl_sum_init_data_vector( const ecl_sum_type * ecl_sum , double_vector_type * data_vector , int data_index , bool report_only );
double_vector_type * ecl_sum_alloc_data_vector( const ecl_sum_type * ecl_sum , int data_index , bool report_only);
time_t_vector_type * ecl_sum_alloc_time_vector( const ecl_sum_type * ecl_sum , bool report_only);
time_t ecl_sum_get_data_start( const ecl_sum_type * ecl_sum );
time_t ecl_sum_get_end_time( const ecl_sum_type * ecl_sum);
time_t ecl_sum_get_start_time(const ecl_sum_type * );
const char * ecl_sum_get_case(const ecl_sum_type * );
bool ecl_sum_same_case( const ecl_sum_type * ecl_sum , const char * input_file );
void ecl_sum_resample_from_sim_days( const ecl_sum_type * ecl_sum , const double_vector_type * sim_days , double_vector_type * value , const char * gen_key);
void ecl_sum_resample_from_sim_time( const ecl_sum_type * ecl_sum , const time_t_vector_type * sim_time , double_vector_type * value , const char * gen_key);
time_t ecl_sum_time_from_days( const ecl_sum_type * ecl_sum , double sim_days );
double ecl_sum_days_from_time( const ecl_sum_type * ecl_sum , time_t sim_time );
double ecl_sum_get_sim_length( const ecl_sum_type * ecl_sum ) ;
double ecl_sum_get_first_day( const ecl_sum_type * ecl_sum );
/*****************************************************************/
stringlist_type * ecl_sum_alloc_well_list( const ecl_sum_type * ecl_sum , const char * pattern);
stringlist_type * ecl_sum_alloc_group_list( const ecl_sum_type * ecl_sum , const char * pattern);
stringlist_type * ecl_sum_alloc_well_var_list( const ecl_sum_type * ecl_sum );
stringlist_type * ecl_sum_alloc_matching_general_var_list(const ecl_sum_type * ecl_sum , const char * pattern);
void ecl_sum_select_matching_general_var_list( const ecl_sum_type * ecl_sum , const char * pattern , stringlist_type * keys);
const ecl_smspec_type * ecl_sum_get_smspec( const ecl_sum_type * ecl_sum );
ecl_smspec_var_type ecl_sum_identify_var_type(const ecl_sum_type * ecl_sum , const char * var);
ecl_smspec_var_type ecl_sum_get_var_type( const ecl_sum_type * ecl_sum , const char * gen_key);
bool ecl_sum_var_is_rate( const ecl_sum_type * ecl_sum , const char * gen_key);
bool ecl_sum_var_is_total( const ecl_sum_type * ecl_sum , const char * gen_key);
int ecl_sum_iget_report_end( const ecl_sum_type * ecl_sum , int report_step );
int ecl_sum_iget_report_start( const ecl_sum_type * ecl_sum , int report_step );
UTIL_IS_INSTANCE_HEADER( ecl_sum );
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,75 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_sum_data.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_SUM_DATA_H__
#define __ECL_SUM_DATA_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <time.h>
#include <time_t_vector.h>
#include <double_vector.h>
#include <stringlist.h>
typedef struct ecl_sum_data_struct ecl_sum_data_type ;
bool ecl_sum_data_check_sim_time( const ecl_sum_data_type * data , time_t sim_time);
bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_days);
int ecl_sum_data_get_num_ministep( const ecl_sum_data_type * data );
double_vector_type * ecl_sum_data_alloc_data_vector( const ecl_sum_data_type * data , int data_index , bool report_only);
void ecl_sum_data_init_data_vector( const ecl_sum_data_type * data , double_vector_type * data_vector , int data_index , bool report_only);
void ecl_sum_data_init_time_vector( const ecl_sum_data_type * data , time_t_vector_type * time_vector , bool report_only);
time_t_vector_type * ecl_sum_data_alloc_time_vector( const ecl_sum_data_type * data , bool report_only);
time_t ecl_sum_data_get_data_start( const ecl_sum_data_type * data );
double ecl_sum_data_get_first_day( const ecl_sum_data_type * data);
time_t ecl_sum_data_get_sim_start ( const ecl_sum_data_type * data );
time_t ecl_sum_data_get_sim_end ( const ecl_sum_data_type * data );
double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data );
void ecl_sum_data_summarize(const ecl_sum_data_type * data , FILE * stream);
double ecl_sum_data_iget( const ecl_sum_data_type * data , int internal_index , int params_index );
double ecl_sum_data_iget_sim_days( const ecl_sum_data_type * , int );
time_t ecl_sum_data_iget_sim_time( const ecl_sum_data_type * , int );
bool ecl_sum_data_has_report_step(const ecl_sum_data_type * , int );
ecl_sum_data_type * ecl_sum_data_fread_alloc(const ecl_smspec_type * , const stringlist_type * filelist , bool include_restart);
void ecl_sum_data_free( ecl_sum_data_type * );
int ecl_sum_data_get_last_report_step( const ecl_sum_data_type * data );
int ecl_sum_data_get_first_report_step( const ecl_sum_data_type * data );
int ecl_sum_data_get_first_ministep( const ecl_sum_data_type * data );
int ecl_sum_data_get_last_ministep( const ecl_sum_data_type * data );
double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , int params_index);
double ecl_sum_data_get_from_sim_days( const ecl_sum_data_type * data , double sim_days , int params_index);
int ecl_sum_data_get_length( const ecl_sum_data_type * data );
int ecl_sum_data_iget_report_step(const ecl_sum_data_type * data , int internal_index);
int ecl_sum_data_iget_mini_step(const ecl_sum_data_type * data , int internal_index);
int ecl_sum_data_iget_report_end( const ecl_sum_data_type * data , int report_step );
int ecl_sum_data_iget_report_start( const ecl_sum_data_type * data , int report_step );
#ifdef __cplusplus
}
#endif
#endif

184
ThirdParty/Ert/ecl/include/ecl_util.h vendored Normal file
View File

@@ -0,0 +1,184 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'ecl_util.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __ECL_UTIL_H__
#define __ECL_UTIL_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <time.h>
#include <stringlist.h>
typedef enum { ECL_OTHER_FILE = 0 ,
ECL_RESTART_FILE = 1 ,
ECL_UNIFIED_RESTART_FILE = 2 ,
ECL_SUMMARY_FILE = 4 ,
ECL_UNIFIED_SUMMARY_FILE = 8 ,
ECL_SUMMARY_HEADER_FILE = 16 ,
ECL_GRID_FILE = 32 ,
ECL_EGRID_FILE = 64 ,
ECL_INIT_FILE = 128 ,
ECL_RFT_FILE = 256 ,
ECL_DATA_FILE = 512 } ecl_file_enum;
#define ECL_FILE_ENUM_DEFS {.value = 0 , .name="ECL_OTHER_FILE"}, \
{.value = 1 , .name="ECL_RESTART_FILE"}, \
{.value = 2 , .name="ECL_UNIFIED_RESTART_FILE"}, \
{.value = 4 , .name="ECL_SUMMARY_FILE"}, \
{.value = 8 , .name="ECL_UNIFIED_SUMMARY_FILE"}, \
{.value = 16 , .name="ECL_SUMMARY_HEADER_FILE"}, \
{.value = 32 , .name="ECL_GRID_FILE"}, \
{.value = 64 , .name="ECL_EGRID_FILE"}, \
{.value = 128 , .name="ECL_INIT_FILE"}, \
{.value = 256 , .name="ECL_RFT_FILE"}, \
{.value = 512 , .name="ECL_DATA_FILE"}
#define ECL_FILE_ENUM_SIZE 11
/*
This enum enumerates the four different ways summary and restart information
can be stored.
*/
typedef enum { ECL_INVALID_STORAGE = 0,
ECL_BINARY_UNIFIED = 1,
ECL_FORMATTED_UNIFIED = 2,
ECL_BINARY_NON_UNIFIED = 4,
ECL_FORMATTED_NON_UNIFIED = 8} ecl_storage_enum;
/*
Character data in ECLIPSE files comes as an array of fixed-length
string. Each of these strings is 8 characters long. The type name,
i.e. 'REAL', 'INTE', ... , come as 4 character strings.
*/
#define ECL_STRING_LENGTH 8
#define ECL_TYPE_LENGTH 4
/*****************************************************************/
/*
Observe that these type identidiers are (ab)used in both the rms and
ert/enkf libraries in situations where ECLIPSE is not at all involved.
*/
typedef enum {
ECL_CHAR_TYPE = 0,
ECL_FLOAT_TYPE = 1,
ECL_DOUBLE_TYPE = 2,
ECL_INT_TYPE = 3,
ECL_BOOL_TYPE = 4,
ECL_MESS_TYPE = 5
} ecl_type_enum;
#define ECL_TYPE_ENUM_DEFS {.value = 0 , .name = "ECL_CHAR_TYPE"}, \
{.value = 1 , .name = "ECL_FLOAT_TYPE"} , \
{.value = 2 , .name = "ECL_DOUBLE_TYPE"}, \
{.value = 3 , .name = "ECL_INT_TYPE"}, \
{.value = 4 , .name = "ECL_BOOL_TYPE"}, \
{.value = 5 , .name = "ECL_MESS_TYPE"}
#define ECL_TYPE_ENUM_SIZE 6
/*
The libecl library has been built and tested 99.5% with ECLIPSE100
as context, but in thye gravity code there is some very limited
functionality related to ECLIPSE100 versus ECLIPSE300 functionality.
*/
typedef enum {
ECLIPSE_UNDEFINED = 0,
ECLIPSE100 = 1,
ECLIPSE300 = 2
} ecl_version_enum;
/*
Observe that the numerical enum VALUES matches those found in item
14 in the INTEHEAD keyword in the ECLIPSE INIT files; i.e. the
distribution of numerical values 1,2,4 can NOT BE CHANGED.
The function ecl_util_get_phase_name() can be used to lookup a
string name from an enum value.
The phases in a simulation will typically be a sum of these
fundamental phases, and represented as an integer.
*/
typedef enum {
ECL_OIL_PHASE = 1,
ECL_GAS_PHASE = 2,
ECL_WATER_PHASE = 4
} ecl_phase_enum;
#define ECL_PHASE_ENUM_DEFS {.value = 1 , .name = "ECL_OIL_PHASE"}, {.value = 2 , .name = "ECL_GAS_PHASE"} , {.value = 4 , .name = "ECL_WATER_PHASE"}
#define ECL_PHASE_ENUM_SIZE 3
// For unformatted files:
#define ECL_BOOL_TRUE_INT -1 // Binary representation: 11111111 11111111 11111111 1111111
#define ECL_BOOL_FALSE_INT 0 // Binary representation: 00000000 00000000 00000000 0000000
#define ECL_COMMENT_STRING "--"
#define ECL_DATA_TERMINATION "/"
int ecl_util_get_sizeof_ctype(ecl_type_enum );
ecl_type_enum ecl_util_get_type_from_name( const char * type_name );
const char * ecl_util_get_type_name( ecl_type_enum ecl_type );
/*****************************************************************/
void ecl_util_init_stdin(const char * , const char *);
const char * ecl_util_file_type_name( ecl_file_enum file_type );
char * ecl_util_alloc_base_guess(const char *);
int ecl_util_filename_report_nr(const char *);
ecl_file_enum ecl_util_get_file_type(const char * , bool * , int * );
ecl_file_enum ecl_util_inspect_extension(const char * ext , bool *_fmt_file, int * _report_nr);
char * ecl_util_alloc_filename(const char * /* path */, const char * /* base */, ecl_file_enum , bool /* fmt_file */ , int /*report_nr*/);
char * ecl_util_alloc_exfilename(const char * /* path */, const char * /* base */, ecl_file_enum , bool /* fmt_file */ , int /*report_nr*/);
void ecl_util_memcpy_typed_data(void *, const void * , ecl_type_enum , ecl_type_enum , int );
void ecl_util_escape_kw(char * kw);
bool ecl_util_alloc_summary_files(const char * , const char * , const char * , char ** , stringlist_type * );
void ecl_util_alloc_summary_data_files(const char * path , const char * base , bool fmt_file , stringlist_type * filelist);
void ecl_util_alloc_restart_files(const char * , const char * , char *** , int * , bool * , bool *);
time_t ecl_util_get_start_date(const char * );
int ecl_util_get_num_cpu(const char * data_file);
bool ecl_util_fmt_file(const char *);
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);
bool ecl_util_valid_basename( const char * basename );
const char * ecl_util_get_phase_name( ecl_phase_enum phase );
const char * ecl_util_file_enum_iget( int index, int * value);
int ecl_util_select_filelist( const char * path , const char * base , ecl_file_enum file_type , bool fmt_file , stringlist_type * filelist);
#ifdef __cplusplus
}
#endif
#endif

77
ThirdParty/Ert/ecl/include/fortio.h vendored Normal file
View File

@@ -0,0 +1,77 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'fortio.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 __FORTIO_H__
#define __FORTIO_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
typedef enum {
FORTIO_NOENTRY = 0, /* File does not exists at all - application error. */
FORTIO_EOF = 1, /* The file / record is empty */
FORTIO_OK = 2, /* The file / record is OK with: [32 bit header | data | 32 bit footer] */
FORTIO_MISSING_DATA = 3,
FORTIO_MISSING_TAIL = 4,
FORTIO_HEADER_MISMATCH = 5
} fortio_status_type;
#define FORTIO_READ 1
#define FORTIO_WRITE 2
typedef struct fortio_struct fortio_type;
fortio_status_type fortio_check_buffer( FILE * stream , bool endian_flip , size_t buffer_size );
fortio_status_type fortio_check_file( const char * filename , bool endian_flip);
bool fortio_guess_endian_flip(const char * , bool *);
bool fortio_is_fortran_file(const char * , bool * );
void fortio_copy_record(fortio_type * , fortio_type * , int , void * , bool *);
fortio_type * fortio_alloc_FILE_wrapper(const char * , bool , bool , FILE * );
fortio_type * fortio_open_reader(const char *, bool , bool);
fortio_type * fortio_open_writer(const char *, bool , bool);
fortio_type * fortio_open_readwrite(const char *, bool , bool);
void fortio_free_FILE_wrapper(fortio_type *);
void fortio_fclose(fortio_type *);
int fortio_init_read(fortio_type *);
void fortio_complete_read(fortio_type *);
void fortio_init_write(fortio_type * , int);
void fortio_complete_write(fortio_type *);
void fortio_fskip_buffer(fortio_type *, int );
int fortio_fskip_record(fortio_type *);
int fortio_fread_record(fortio_type * , char *buffer);
void fortio_fread_buffer(fortio_type * , char * , int );
void fortio_fwrite_record(fortio_type * , const char *, int);
FILE * fortio_get_FILE(const fortio_type *);
void fortio_fflush(fortio_type * ) ;
int fortio_get_record_size(const fortio_type *);
bool fortio_is_fortio_file(fortio_type * );
void fortio_rewind(const fortio_type *fortio);
const char * fortio_filename_ref(const fortio_type * );
bool fortio_fmt_file(const fortio_type *);
long fortio_ftell( const fortio_type * fortio );
int fortio_fseek( fortio_type * fortio , long offset , int whence);
int fortio_get_mode( const fortio_type * fortio );
#ifdef __cplusplus
}
#endif
#endif

BIN
ThirdParty/Ert/ecl/lib/libecl.a vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,42 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'geo_pointset.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 __GEO_POINTSET_H__
#define __GEO_POINTSET_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct geo_pointset_struct geo_pointset_type;
geo_pointset_type * geo_pointset_alloc( bool external_z );
void geo_pointset_free( geo_pointset_type * pointset );
void geo_pointset_add_xy( geo_pointset_type * pointset , double x , double y);
void geo_pointset_add_xyz( geo_pointset_type * pointset , double x , double y, double z);
int geo_pointset_get_size( const geo_pointset_type * pointset );
void geo_pointset_iget_xy( const geo_pointset_type * pointset , int index , double * x , double * y);
const double * geo_pointset_get_zcoord( const geo_pointset_type * pointset );
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,40 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'geo_polygon.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 __GEO_POLYGON_H__
#define __GEO_POLYGON_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
typedef struct geo_polygon_struct geo_polygon_type;
geo_polygon_type * geo_polygon_alloc( );
void geo_polygon_free( geo_polygon_type * polygon );
void geo_polygon_free__( void * arg );
void geo_polygon_add_point( geo_polygon_type * polygon , double x , double y );
geo_polygon_type * geo_polygon_fload_alloc_irap( const char * filename );
bool geo_polygon_contains_point( const geo_polygon_type * polygon , double x , double y);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,56 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'geo_region.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.
*/
#include <stdlib.h>
#include <stdbool.h>
#include <util.h>
#include <geo_pointset.h>
#include <geo_polygon.h>
#ifndef __GEO_REGION_H__
#define __GEO_REGION_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct geo_region_struct geo_region_type;
geo_region_type * geo_region_alloc( const geo_pointset_type * pointset , bool preselect);
void geo_region_free( geo_region_type * region );
void geo_region_free__( void * arg );
void geo_region_reset( geo_region_type * region );
const int_vector_type * geo_region_get_index_list( geo_region_type * region );
void geo_region_select_inside_polygon( geo_region_type * region , const geo_polygon_type * polygon);
void geo_region_select_outside_polygon( geo_region_type * region , const geo_polygon_type * polygon);
void geo_region_deselect_inside_polygon( geo_region_type * region , const geo_polygon_type * polygon);
void geo_region_deselect_outside_polygon( geo_region_type * region , const geo_polygon_type * polygon);
void geo_region_select_above_line( geo_region_type * region, const double xcoords[2] , const double ycoords[2]);
void geo_region_select_below_line( geo_region_type * region, const double xcoords[2] , const double ycoords[2]);
void geo_region_deselect_above_line( geo_region_type * region, const double xcoords[2] , const double ycoords[2]);
void geo_region_deselect_below_line( geo_region_type * region, const double xcoords[2] , const double ycoords[2]);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,46 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'geo_surface.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 __GEO_SURFACE_H__
#define __GEO_SURFACE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <geo_pointset.h>
typedef struct geo_surface_struct geo_surface_type;
void geo_surface_free( geo_surface_type * geo_surface );
void geo_surface_free__( void * arg);
geo_pointset_type * geo_surface_get_pointset( const geo_surface_type * surface );
geo_surface_type * geo_surface_fload_alloc_irap( const char * filename , bool loadz);
void geo_surface_fload_irap_zcoord( const geo_surface_type * surface, const char * filename, double *zlist);
int geo_surface_get_size( const geo_surface_type * surface );
void geo_surface_fprintf_irap( const geo_surface_type * surface, const char * filename );
void geo_surface_fprintf_irap_external_zcoord( const geo_surface_type * surface, const char * filename , const double * zcoord);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,37 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'geo_util.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 __GEO_UTIL_H__
#define __GEO_UTIL_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
bool geo_util_inside_polygon(const double * xlist , const double * ylist , int num_points , double x0 , double y0);
#ifdef __cplusplus
}
#endif
#endif

Binary file not shown.

90
ThirdParty/Ert/util/include/arg_pack.h vendored Normal file
View File

@@ -0,0 +1,90 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'arg_pack.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 __ARG_PACK_H__
#define __ARG_PACK_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdbool.h>
#include <node_ctype.h>
#include <util.h>
typedef struct arg_pack_struct arg_pack_type;
typedef void (arg_node_free_ftype) (void *);
typedef void * (arg_node_copyc_ftype) (void *);
arg_pack_type * arg_pack_alloc();
UTIL_SAFE_CAST_HEADER( arg_pack );
void arg_pack_free(arg_pack_type * );
void arg_pack_free__(void *);
void arg_pack_clear(arg_pack_type *);
void arg_pack_lock(arg_pack_type *);
void arg_pack_fscanf(arg_pack_type * arg , FILE * stream);
void arg_pack_fprintf(const arg_pack_type * , FILE * );
void arg_pack_append_ptr(arg_pack_type * , const void *);
void arg_pack_append_owned_ptr(arg_pack_type * , void * , arg_node_free_ftype *);
void arg_pack_append_copy(arg_pack_type * , void * , arg_node_copyc_ftype * , arg_node_free_ftype *);
void arg_pack_iset_copy(arg_pack_type * arg_pack , int index , void * ptr, arg_node_copyc_ftype * copyc , arg_node_free_ftype * freef);
void arg_pack_iset_ptr(arg_pack_type * arg_pack, int index , const void * ptr);
void arg_pack_iset_owned_ptr(arg_pack_type * arg_pack, int index , void * ptr, arg_node_free_ftype * freef);
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);
/*****************************************************************/
#define APPEND_TYPED_HEADER(type) void arg_pack_append_ ## type (arg_pack_type * , type);
#define IGET_TYPED_HEADER(type) type arg_pack_iget_ ## type( const arg_pack_type * , int );
#define ISET_TYPED_HEADER(type) void arg_pack_iset_ ## type( arg_pack_type * , int , type value);
APPEND_TYPED_HEADER(int)
APPEND_TYPED_HEADER(bool)
APPEND_TYPED_HEADER(char)
APPEND_TYPED_HEADER(float)
APPEND_TYPED_HEADER(double)
APPEND_TYPED_HEADER(size_t)
IGET_TYPED_HEADER(int)
IGET_TYPED_HEADER(bool)
IGET_TYPED_HEADER(char)
IGET_TYPED_HEADER(float)
IGET_TYPED_HEADER(double)
IGET_TYPED_HEADER(size_t)
ISET_TYPED_HEADER(int)
ISET_TYPED_HEADER(bool)
ISET_TYPED_HEADER(char)
ISET_TYPED_HEADER(float)
ISET_TYPED_HEADER(double)
ISET_TYPED_HEADER(size_t)
#undef APPEND_TYPED_HEADER
#undef GET_TYPED_HEADER
#ifdef __cplusplus
}
#endif
#endif

63
ThirdParty/Ert/util/include/block_fs.h vendored Normal file
View File

@@ -0,0 +1,63 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'block_fs.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 __BLOCK_FS__
#define __BLOCK_FS__
#include <buffer.h>
#include <util.h>
#include <vector.h>
typedef struct block_fs_struct block_fs_type;
typedef struct user_file_node_struct user_file_node_type;
typedef enum {
NO_SORT = 0,
STRING_SORT = 1,
OFFSET_SORT = 2
} block_fs_sort_type;
size_t block_fs_get_cache_usage( const block_fs_type * block_fs );
double block_fs_get_fragmentation( const block_fs_type * block_fs );
bool block_fs_rotate( block_fs_type * block_fs , double fragmentation_limit);
void block_fs_fsync( block_fs_type * block_fs );
bool block_fs_is_mount( const char * mount_file );
block_fs_type * block_fs_mount( const char * mount_file , int block_size , int max_cache_size , float fragmentation_limit , int fsync_interval , bool preload , bool read_only);
void block_fs_close( block_fs_type * block_fs , bool unlink_empty);
void block_fs_fwrite_file(block_fs_type * block_fs , const char * filename , const void * ptr , size_t byte_size);
void block_fs_fwrite_buffer(block_fs_type * block_fs , const char * filename , const buffer_type * buffer);
void block_fs_fread_file( block_fs_type * block_fs , const char * filename , void * ptr);
int block_fs_get_filesize( block_fs_type * block_fs , const char * filename);
void block_fs_fread_realloc_buffer( block_fs_type * block_fs , const char * filename , buffer_type * buffer);
void block_fs_sync( block_fs_type * block_fs );
void block_fs_unlink_file( block_fs_type * block_fs , const char * filename);
bool block_fs_has_file( block_fs_type * block_fs , const char * filename);
vector_type * block_fs_alloc_filelist( block_fs_type * block_fs , const char * pattern , block_fs_sort_type sort_mode , bool include_free_nodes );
void block_fs_defrag( block_fs_type * block_fs );
long int user_file_node_get_node_offset( const user_file_node_type * user_file_node );
long int user_file_node_get_data_offset( const user_file_node_type * user_file_node );
int user_file_node_get_node_size( const user_file_node_type * user_file_node );
int user_file_node_get_data_size( const user_file_node_type * user_file_node );
bool user_file_node_in_use( const user_file_node_type * user_file_node );
const char * user_file_node_get_filename( const user_file_node_type * user_file_node );
UTIL_IS_INSTANCE_HEADER( block_fs );
#endif

View File

@@ -0,0 +1,116 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector_template.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 __bool_VECTOR_H__
#define __bool_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <buffer.h>
#include <util.h>
typedef struct bool_vector_struct bool_vector_type;
typedef bool (bool_ftype) (bool);
int bool_vector_lookup_bin( const bool_vector_type * limits , bool value , int guess);
int bool_vector_lookup_bin__( const bool_vector_type * limits , bool value , int guess);
void bool_vector_inplace_div( bool_vector_type * vector , const bool_vector_type * inv_factor);
void bool_vector_inplace_mul( bool_vector_type * vector , const bool_vector_type * factor);
void bool_vector_inplace_add( bool_vector_type * vector , const bool_vector_type * delta);
void bool_vector_set_read_only( bool_vector_type * vector , bool read_only);
bool bool_vector_get_read_only( const bool_vector_type * vector );
void bool_vector_resize( bool_vector_type * vector , int new_alloc_size );
void bool_vector_memcpy( bool_vector_type * target , const bool_vector_type * src);
void bool_vector_memcpy_data_block( bool_vector_type * target , const bool_vector_type * src , int target_offset , int src_offset , int len);
bool bool_vector_growable( const bool_vector_type * vector);
void bool_vector_select_unique(bool_vector_type * vector);
bool_vector_type * bool_vector_alloc( int init_size , bool );
bool_vector_type * bool_vector_alloc_private_wrapper(int init_size, bool default_value , bool * data , int alloc_size);
bool_vector_type * bool_vector_alloc_shared_wrapper(int init_size, bool default_value , bool * data , int alloc_size);
bool_vector_type * bool_vector_alloc_strided_copy( const bool_vector_type * src , int start , int stop , int stride );
bool_vector_type * bool_vector_alloc_copy( const bool_vector_type * src);
void bool_vector_imul(bool_vector_type * vector, int index, bool factor);
void bool_vector_scale(bool_vector_type * vector, bool factor);
bool bool_vector_iget(const bool_vector_type * , int);
bool bool_vector_safe_iget(const bool_vector_type * , int);
bool bool_vector_get_min(const bool_vector_type * vector);
bool bool_vector_get_max(const bool_vector_type * vector);
int bool_vector_get_min_index(const bool_vector_type * vector, bool reverse);
int bool_vector_get_max_index(const bool_vector_type * vector, bool reverse);
bool bool_vector_iadd( bool_vector_type * vector , int index , bool delta);
void bool_vector_iset(bool_vector_type * , int , bool);
void bool_vector_idel_block( bool_vector_type * vector , int index , int block_size);
bool bool_vector_idel( bool_vector_type * vector , int index);
void bool_vector_append(bool_vector_type * , bool);
void bool_vector_free(bool_vector_type *);
void bool_vector_free__(void *);
void bool_vector_free_data(bool_vector_type *);
void bool_vector_reset(bool_vector_type *);
void bool_vector_reset__(void * __vector);
int bool_vector_size(const bool_vector_type * );
bool bool_vector_pop(bool_vector_type * vector);
bool bool_vector_get_first(const bool_vector_type * vector);
bool bool_vector_get_last(const bool_vector_type * );
bool * bool_vector_get_ptr(const bool_vector_type * );
bool * bool_vector_alloc_data_copy( const bool_vector_type * vector );
const bool * bool_vector_get_const_ptr(const bool_vector_type * );
void bool_vector_set_many(bool_vector_type * , int , const bool * , int );
void bool_vector_set_all(bool_vector_type * vector , bool value);
void bool_vector_append_many(bool_vector_type * vector , const bool * data , int length);
void bool_vector_shrink(bool_vector_type * );
bool bool_vector_sum(const bool_vector_type * );
bool bool_vector_get_default(const bool_vector_type * );
void bool_vector_set_default(bool_vector_type * vector, bool default_value);
void bool_vector_append_default(bool_vector_type * vector , bool default_value);
void bool_vector_iset_default(bool_vector_type * vector , int index , bool default_value);
bool bool_vector_is_sorted( const bool_vector_type * vector , bool reverse);
int bool_vector_index(const bool_vector_type * vector , bool value);
int bool_vector_index_sorted(const bool_vector_type * vector , bool value);
void bool_vector_sort(bool_vector_type * vector);
void bool_vector_rsort(bool_vector_type * vector);
void bool_vector_permute(bool_vector_type * vector , const int * perm);
int * bool_vector_alloc_sort_perm(const bool_vector_type * vector);
int * bool_vector_alloc_rsort_perm(const bool_vector_type * vector);
void bool_vector_fprintf(const bool_vector_type * vector , FILE * stream , const char * name , const char * fmt);
void bool_vector_fwrite(const bool_vector_type * vector , FILE * stream);
void bool_vector_buffer_fread(bool_vector_type * vector , buffer_type * buffer);
bool_vector_type * bool_vector_fread_alloc( FILE * stream );
bool_vector_type * bool_vector_buffer_fread_alloc( buffer_type * buffer );
void bool_vector_buffer_fwrite(const bool_vector_type * vector , buffer_type * buffer);
void bool_vector_fread( bool_vector_type * vector , FILE * stream );
void bool_vector_fwrite_data( const bool_vector_type * vector , FILE * stream );
void bool_vector_fread_data( bool_vector_type * vector , int size, FILE * stream);
bool bool_vector_equal(const bool_vector_type * vector1 , const bool_vector_type * vector2);
void bool_vector_apply(bool_vector_type * vector , bool_ftype *func);
int bool_vector_count_equal( const bool_vector_type * vector , bool cmp_value);
int bool_vector_element_size( const bool_vector_type * vector );
UTIL_SAFE_CAST_HEADER( bool_vector );
#ifdef __cplusplus
}
#endif
#endif
//

95
ThirdParty/Ert/util/include/buffer.h vendored Normal file
View File

@@ -0,0 +1,95 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'buffer.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 __BUFFER_H__
#define __BUFFER_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>
typedef struct buffer_struct buffer_type;
bool buffer_replace( buffer_type * buffer , const char * old_string , const char * new_string);
void buffer_shrink_to_fit( buffer_type * buffer );
void buffer_memshift(buffer_type * buffer , size_t offset, ssize_t shift);
bool buffer_strstr( buffer_type * buffer , const char * expr );
bool buffer_strchr( buffer_type * buffer , int c);
buffer_type * buffer_alloc( size_t buffer_size );
buffer_type * buffer_alloc_private_wrapper(void * data , size_t buffer_size );
void buffer_free_container( buffer_type * buffer );
void buffer_free( buffer_type * buffer);
size_t buffer_safe_fread(buffer_type * buffer , void * target_ptr , size_t item_size , size_t items);
size_t buffer_fread(buffer_type * buffer , void * target_ptr , size_t item_size , size_t items);
size_t buffer_safe_fwrite(buffer_type * buffer , const void * src_ptr , size_t item_size , size_t items);
size_t buffer_fwrite(buffer_type * buffer , const void * src_ptr , size_t item_size , size_t items);
const char * buffer_fread_string(buffer_type * buffer);
char * buffer_fread_alloc_string(buffer_type * buffer);
void buffer_fwrite_string(buffer_type * buffer , const char * string);
void buffer_summarize(const buffer_type * buffer , const char *);
void buffer_fwrite_char_ptr(buffer_type * buffer , const char * string_ptr );
void buffer_terminate_char_ptr( buffer_type * buffer );
void buffer_fwrite_char(buffer_type * buffer , char value);
void buffer_fwrite_int(buffer_type * buffer , int value);
void buffer_fskip_bool(buffer_type * buffer);
void buffer_fwrite_bool(buffer_type * buffer , bool value);
int buffer_fread_int(buffer_type * buffer );
bool buffer_fread_bool(buffer_type * buffer);
long int buffer_fread_long(buffer_type * buffer);
void buffer_store(const buffer_type * buffer , const char * filename);
size_t buffer_get_offset(const buffer_type * buffer);
size_t buffer_get_alloc_size(const buffer_type * buffer);
size_t buffer_get_size(const buffer_type * buffer);
size_t buffer_get_remaining_size(const buffer_type * buffer);
void * buffer_get_data(const buffer_type * buffer);
void * buffer_alloc_data_copy(const buffer_type * buffer);
void buffer_stream_fwrite( const buffer_type * buffer , FILE * stream );
int buffer_fgetc( buffer_type * buffer );
void buffer_fseek(buffer_type * buffer , ssize_t offset , int whence);
void buffer_fskip(buffer_type * buffer, ssize_t offset);
void buffer_clear( buffer_type * buffer );
void buffer_fskip_int(buffer_type * buffer);
void buffer_fskip_time_t(buffer_type * buffer);
time_t buffer_fread_time_t(buffer_type * buffer);
void buffer_fwrite_time_t(buffer_type * buffer , time_t value);
void buffer_rewind(buffer_type * buffer );
double buffer_fread_double(buffer_type * buffer);
void buffer_fwrite_double(buffer_type * buffer , double value);
size_t buffer_stream_fwrite_n( const buffer_type * buffer , size_t offset , ssize_t write_size , FILE * stream );
void buffer_stream_fprintf( const buffer_type * buffer , FILE * stream );
void buffer_stream_fread( buffer_type * buffer , size_t byte_size , FILE * stream);
buffer_type * buffer_fread_alloc(const char * filename);
void buffer_fread_realloc(buffer_type * buffer , const char * filename);
#ifdef HAVE_ZLIB
size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size);
size_t buffer_fread_compressed(buffer_type * buffer , size_t compressed_size , void * target_ptr , size_t target_size);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,116 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector_template.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 __double_VECTOR_H__
#define __double_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <buffer.h>
#include <util.h>
typedef struct double_vector_struct double_vector_type;
typedef double (double_ftype) (double);
int double_vector_lookup_bin( const double_vector_type * limits , double value , int guess);
int double_vector_lookup_bin__( const double_vector_type * limits , double value , int guess);
void double_vector_inplace_div( double_vector_type * vector , const double_vector_type * inv_factor);
void double_vector_inplace_mul( double_vector_type * vector , const double_vector_type * factor);
void double_vector_inplace_add( double_vector_type * vector , const double_vector_type * delta);
void double_vector_set_read_only( double_vector_type * vector , bool read_only);
bool double_vector_get_read_only( const double_vector_type * vector );
void double_vector_resize( double_vector_type * vector , int new_alloc_size );
void double_vector_memcpy( double_vector_type * target , const double_vector_type * src);
void double_vector_memcpy_data_block( double_vector_type * target , const double_vector_type * src , int target_offset , int src_offset , int len);
bool double_vector_growable( const double_vector_type * vector);
void double_vector_select_unique(double_vector_type * vector);
double_vector_type * double_vector_alloc( int init_size , double );
double_vector_type * double_vector_alloc_private_wrapper(int init_size, double default_value , double * data , int alloc_size);
double_vector_type * double_vector_alloc_shared_wrapper(int init_size, double default_value , double * data , int alloc_size);
double_vector_type * double_vector_alloc_strided_copy( const double_vector_type * src , int start , int stop , int stride );
double_vector_type * double_vector_alloc_copy( const double_vector_type * src);
void double_vector_imul(double_vector_type * vector, int index, double factor);
void double_vector_scale(double_vector_type * vector, double factor);
double double_vector_iget(const double_vector_type * , int);
double double_vector_safe_iget(const double_vector_type * , int);
double double_vector_get_min(const double_vector_type * vector);
double double_vector_get_max(const double_vector_type * vector);
int double_vector_get_min_index(const double_vector_type * vector, bool reverse);
int double_vector_get_max_index(const double_vector_type * vector, bool reverse);
double double_vector_iadd( double_vector_type * vector , int index , double delta);
void double_vector_iset(double_vector_type * , int , double);
void double_vector_idel_block( double_vector_type * vector , int index , int block_size);
double double_vector_idel( double_vector_type * vector , int index);
void double_vector_append(double_vector_type * , double);
void double_vector_free(double_vector_type *);
void double_vector_free__(void *);
void double_vector_free_data(double_vector_type *);
void double_vector_reset(double_vector_type *);
void double_vector_reset__(void * __vector);
int double_vector_size(const double_vector_type * );
double double_vector_pop(double_vector_type * vector);
double double_vector_get_first(const double_vector_type * vector);
double double_vector_get_last(const double_vector_type * );
double * double_vector_get_ptr(const double_vector_type * );
double * double_vector_alloc_data_copy( const double_vector_type * vector );
const double * double_vector_get_const_ptr(const double_vector_type * );
void double_vector_set_many(double_vector_type * , int , const double * , int );
void double_vector_set_all(double_vector_type * vector , double value);
void double_vector_append_many(double_vector_type * vector , const double * data , int length);
void double_vector_shrink(double_vector_type * );
double double_vector_sum(const double_vector_type * );
double double_vector_get_default(const double_vector_type * );
void double_vector_set_default(double_vector_type * vector, double default_value);
void double_vector_append_default(double_vector_type * vector , double default_value);
void double_vector_iset_default(double_vector_type * vector , int index , double default_value);
bool double_vector_is_sorted( const double_vector_type * vector , bool reverse);
int double_vector_index(const double_vector_type * vector , double value);
int double_vector_index_sorted(const double_vector_type * vector , double value);
void double_vector_sort(double_vector_type * vector);
void double_vector_rsort(double_vector_type * vector);
void double_vector_permute(double_vector_type * vector , const int * perm);
int * double_vector_alloc_sort_perm(const double_vector_type * vector);
int * double_vector_alloc_rsort_perm(const double_vector_type * vector);
void double_vector_fprintf(const double_vector_type * vector , FILE * stream , const char * name , const char * fmt);
void double_vector_fwrite(const double_vector_type * vector , FILE * stream);
void double_vector_buffer_fread(double_vector_type * vector , buffer_type * buffer);
double_vector_type * double_vector_fread_alloc( FILE * stream );
double_vector_type * double_vector_buffer_fread_alloc( buffer_type * buffer );
void double_vector_buffer_fwrite(const double_vector_type * vector , buffer_type * buffer);
void double_vector_fread( double_vector_type * vector , FILE * stream );
void double_vector_fwrite_data( const double_vector_type * vector , FILE * stream );
void double_vector_fread_data( double_vector_type * vector , int size, FILE * stream);
bool double_vector_equal(const double_vector_type * vector1 , const double_vector_type * vector2);
void double_vector_apply(double_vector_type * vector , double_ftype *func);
int double_vector_count_equal( const double_vector_type * vector , double cmp_value);
int double_vector_element_size( const double_vector_type * vector );
UTIL_SAFE_CAST_HEADER( double_vector );
#ifdef __cplusplus
}
#endif
#endif
//

View File

@@ -0,0 +1,116 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector_template.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 __float_VECTOR_H__
#define __float_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <buffer.h>
#include <util.h>
typedef struct float_vector_struct float_vector_type;
typedef float (float_ftype) (float);
int float_vector_lookup_bin( const float_vector_type * limits , float value , int guess);
int float_vector_lookup_bin__( const float_vector_type * limits , float value , int guess);
void float_vector_inplace_div( float_vector_type * vector , const float_vector_type * inv_factor);
void float_vector_inplace_mul( float_vector_type * vector , const float_vector_type * factor);
void float_vector_inplace_add( float_vector_type * vector , const float_vector_type * delta);
void float_vector_set_read_only( float_vector_type * vector , bool read_only);
bool float_vector_get_read_only( const float_vector_type * vector );
void float_vector_resize( float_vector_type * vector , int new_alloc_size );
void float_vector_memcpy( float_vector_type * target , const float_vector_type * src);
void float_vector_memcpy_data_block( float_vector_type * target , const float_vector_type * src , int target_offset , int src_offset , int len);
bool float_vector_growable( const float_vector_type * vector);
void float_vector_select_unique(float_vector_type * vector);
float_vector_type * float_vector_alloc( int init_size , float );
float_vector_type * float_vector_alloc_private_wrapper(int init_size, float default_value , float * data , int alloc_size);
float_vector_type * float_vector_alloc_shared_wrapper(int init_size, float default_value , float * data , int alloc_size);
float_vector_type * float_vector_alloc_strided_copy( const float_vector_type * src , int start , int stop , int stride );
float_vector_type * float_vector_alloc_copy( const float_vector_type * src);
void float_vector_imul(float_vector_type * vector, int index, float factor);
void float_vector_scale(float_vector_type * vector, float factor);
float float_vector_iget(const float_vector_type * , int);
float float_vector_safe_iget(const float_vector_type * , int);
float float_vector_get_min(const float_vector_type * vector);
float float_vector_get_max(const float_vector_type * vector);
int float_vector_get_min_index(const float_vector_type * vector, bool reverse);
int float_vector_get_max_index(const float_vector_type * vector, bool reverse);
float float_vector_iadd( float_vector_type * vector , int index , float delta);
void float_vector_iset(float_vector_type * , int , float);
void float_vector_idel_block( float_vector_type * vector , int index , int block_size);
float float_vector_idel( float_vector_type * vector , int index);
void float_vector_append(float_vector_type * , float);
void float_vector_free(float_vector_type *);
void float_vector_free__(void *);
void float_vector_free_data(float_vector_type *);
void float_vector_reset(float_vector_type *);
void float_vector_reset__(void * __vector);
int float_vector_size(const float_vector_type * );
float float_vector_pop(float_vector_type * vector);
float float_vector_get_first(const float_vector_type * vector);
float float_vector_get_last(const float_vector_type * );
float * float_vector_get_ptr(const float_vector_type * );
float * float_vector_alloc_data_copy( const float_vector_type * vector );
const float * float_vector_get_const_ptr(const float_vector_type * );
void float_vector_set_many(float_vector_type * , int , const float * , int );
void float_vector_set_all(float_vector_type * vector , float value);
void float_vector_append_many(float_vector_type * vector , const float * data , int length);
void float_vector_shrink(float_vector_type * );
float float_vector_sum(const float_vector_type * );
float float_vector_get_default(const float_vector_type * );
void float_vector_set_default(float_vector_type * vector, float default_value);
void float_vector_append_default(float_vector_type * vector , float default_value);
void float_vector_iset_default(float_vector_type * vector , int index , float default_value);
bool float_vector_is_sorted( const float_vector_type * vector , bool reverse);
int float_vector_index(const float_vector_type * vector , float value);
int float_vector_index_sorted(const float_vector_type * vector , float value);
void float_vector_sort(float_vector_type * vector);
void float_vector_rsort(float_vector_type * vector);
void float_vector_permute(float_vector_type * vector , const int * perm);
int * float_vector_alloc_sort_perm(const float_vector_type * vector);
int * float_vector_alloc_rsort_perm(const float_vector_type * vector);
void float_vector_fprintf(const float_vector_type * vector , FILE * stream , const char * name , const char * fmt);
void float_vector_fwrite(const float_vector_type * vector , FILE * stream);
void float_vector_buffer_fread(float_vector_type * vector , buffer_type * buffer);
float_vector_type * float_vector_fread_alloc( FILE * stream );
float_vector_type * float_vector_buffer_fread_alloc( buffer_type * buffer );
void float_vector_buffer_fwrite(const float_vector_type * vector , buffer_type * buffer);
void float_vector_fread( float_vector_type * vector , FILE * stream );
void float_vector_fwrite_data( const float_vector_type * vector , FILE * stream );
void float_vector_fread_data( float_vector_type * vector , int size, FILE * stream);
bool float_vector_equal(const float_vector_type * vector1 , const float_vector_type * vector2);
void float_vector_apply(float_vector_type * vector , float_ftype *func);
int float_vector_count_equal( const float_vector_type * vector , float cmp_value);
int float_vector_element_size( const float_vector_type * vector );
UTIL_SAFE_CAST_HEADER( float_vector );
#ifdef __cplusplus
}
#endif
#endif
//

84
ThirdParty/Ert/util/include/hash.h vendored Normal file
View File

@@ -0,0 +1,84 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'hash.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 __HASH_H__
#define __HASH_H__
#ifdef __cplusplus
extern"C" {
#endif
#include <stdlib.h>
#include <stringlist.h>
typedef struct hash_struct hash_type;
typedef struct hash_iter_struct hash_iter_type;
typedef void (hash_apply_ftype) (void * );
#include <hash_node.h>
void hash_lock (hash_type * );
void hash_unlock(hash_type * );
hash_type * hash_alloc();
hash_type * hash_alloc_unlocked();
hash_type * hash_safe_cast( void * arg);
void hash_iter_complete(hash_type * );
void hash_free(hash_type *);
void hash_free__(void *);
void hash_insert_ref(hash_type * , const char * , const void *);
void hash_insert_copy(hash_type *, const char * , const void *, copyc_ftype *, free_ftype *);
void hash_insert_string(hash_type *, const char *, const char *);
bool hash_has_key(const hash_type *, const char *);
void * hash_pop( hash_type * hash , const char * key);
void * hash_safe_get( const hash_type * hash , const char * key );
void * hash_get(const hash_type *, const char *);
char * hash_get_string(hash_type * , const char *);
void hash_del(hash_type *, const char *);
void hash_safe_del(hash_type * , const char * );
void hash_clear(hash_type *);
int hash_get_size(const hash_type *);
void hash_set_keylist(const hash_type * , char **);
char ** hash_alloc_keylist(hash_type *);
stringlist_type * hash_alloc_stringlist(hash_type * );
char ** hash_alloc_sorted_keylist (hash_type *hash , int ( hash_get_cmp_value ) (const void *));
char ** hash_alloc_key_sorted_list(hash_type *hash, int (*cmp)(const void *, const void *));
bool hash_key_list_compare( hash_type * hash1, hash_type * hash2);
void hash_insert_hash_owned_ref(hash_type *, const char * , const void *, free_ftype *);
void hash_resize(hash_type *hash, int new_size);
hash_iter_type * hash_iter_alloc(const hash_type *);
void hash_iter_free(hash_iter_type *);
bool hash_iter_is_complete(const hash_iter_type *);
const char * hash_iter_get_next_key(hash_iter_type *);
void * hash_iter_get_next_value(hash_iter_type *);
void hash_iter_restart( hash_iter_type * iter );
hash_type * hash_alloc_from_options(const stringlist_type *);
int hash_inc_counter(hash_type * hash , const char * counter_key);
int hash_get_counter(hash_type * hash , const char * key);
void hash_insert_int(hash_type * , const char * , int);
int hash_get_int(hash_type * , const char *);
void hash_insert_double(hash_type * , const char * , double);
double hash_get_double(hash_type * , const char *);
void hash_apply( hash_type * hash , hash_apply_ftype * func);
UTIL_IS_INSTANCE_HEADER(hash);
#ifdef __cplusplus
}
#endif
#endif

48
ThirdParty/Ert/util/include/hash_node.h vendored Normal file
View File

@@ -0,0 +1,48 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'hash_node.h' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __HASH_NODE_H__
#define __HASH_NODE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <inttypes.h>
#include <node_data.h>
typedef struct hash_node_struct hash_node_type;
typedef uint32_t (hashf_type) (const char *key, size_t len);
typedef enum {hash_ref_data , hash_int_data , hash_double_data , hash_string_data} hash_data_type;
bool hash_node_key_eq(const hash_node_type * , uint32_t , const char *);
hash_node_type * hash_node_get_next(const hash_node_type * );
uint32_t hash_node_get_insert_nr(const hash_node_type * );
void hash_node_set_next(hash_node_type * , const hash_node_type * );
hash_node_type * hash_node_alloc_new(const char *, node_data_type * , hashf_type *, uint32_t);
void hash_node_set_insert_nr(hash_node_type *, uint32_t );
uint32_t hash_node_get_table_index(const hash_node_type * );
uint32_t hash_node_get_global_index(const hash_node_type * );
const char * hash_node_get_key(const hash_node_type * );
node_data_type * hash_node_get_data(const hash_node_type *);
void hash_node_free(hash_node_type *);
uint32_t hash_node_set_table_index(hash_node_type *, uint32_t );
#ifdef __cplusplus
}
#endif
#endif

41
ThirdParty/Ert/util/include/hash_sll.h vendored Normal file
View File

@@ -0,0 +1,41 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'hash_sll.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 __HASH_SLL_H__
#define __HASH_SLL_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <hash_node.h>
typedef struct hash_sll_struct hash_sll_type;
hash_sll_type **hash_sll_alloc_table(int );
/*hash_sll_type * hash_sll_alloc(void);*/
void hash_sll_del_node(hash_sll_type * , hash_node_type *);
void hash_sll_add_node(hash_sll_type *, hash_node_type *);
void hash_sll_free(hash_sll_type *);
bool hash_sll_has_key(const hash_sll_type *, uint32_t , const char *);
bool hash_sll_empty(const hash_sll_type * hash_sll);
hash_node_type * hash_sll_get(const hash_sll_type *, uint32_t , const char *);
hash_node_type * hash_sll_get_head(const hash_sll_type *);
#ifdef __cplusplus
}
#endif
#endif

116
ThirdParty/Ert/util/include/int_vector.h vendored Normal file
View File

@@ -0,0 +1,116 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector_template.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 __int_VECTOR_H__
#define __int_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <buffer.h>
#include <util.h>
typedef struct int_vector_struct int_vector_type;
typedef int (int_ftype) (int);
int int_vector_lookup_bin( const int_vector_type * limits , int value , int guess);
int int_vector_lookup_bin__( const int_vector_type * limits , int value , int guess);
void int_vector_inplace_div( int_vector_type * vector , const int_vector_type * inv_factor);
void int_vector_inplace_mul( int_vector_type * vector , const int_vector_type * factor);
void int_vector_inplace_add( int_vector_type * vector , const int_vector_type * delta);
void int_vector_set_read_only( int_vector_type * vector , bool read_only);
bool int_vector_get_read_only( const int_vector_type * vector );
void int_vector_resize( int_vector_type * vector , int new_alloc_size );
void int_vector_memcpy( int_vector_type * target , const int_vector_type * src);
void int_vector_memcpy_data_block( int_vector_type * target , const int_vector_type * src , int target_offset , int src_offset , int len);
bool int_vector_growable( const int_vector_type * vector);
void int_vector_select_unique(int_vector_type * vector);
int_vector_type * int_vector_alloc( int init_size , int );
int_vector_type * int_vector_alloc_private_wrapper(int init_size, int default_value , int * data , int alloc_size);
int_vector_type * int_vector_alloc_shared_wrapper(int init_size, int default_value , int * data , int alloc_size);
int_vector_type * int_vector_alloc_strided_copy( const int_vector_type * src , int start , int stop , int stride );
int_vector_type * int_vector_alloc_copy( const int_vector_type * src);
void int_vector_imul(int_vector_type * vector, int index, int factor);
void int_vector_scale(int_vector_type * vector, int factor);
int int_vector_iget(const int_vector_type * , int);
int int_vector_safe_iget(const int_vector_type * , int);
int int_vector_get_min(const int_vector_type * vector);
int int_vector_get_max(const int_vector_type * vector);
int int_vector_get_min_index(const int_vector_type * vector, bool reverse);
int int_vector_get_max_index(const int_vector_type * vector, bool reverse);
int int_vector_iadd( int_vector_type * vector , int index , int delta);
void int_vector_iset(int_vector_type * , int , int);
void int_vector_idel_block( int_vector_type * vector , int index , int block_size);
int int_vector_idel( int_vector_type * vector , int index);
void int_vector_append(int_vector_type * , int);
void int_vector_free(int_vector_type *);
void int_vector_free__(void *);
void int_vector_free_data(int_vector_type *);
void int_vector_reset(int_vector_type *);
void int_vector_reset__(void * __vector);
int int_vector_size(const int_vector_type * );
int int_vector_pop(int_vector_type * vector);
int int_vector_get_first(const int_vector_type * vector);
int int_vector_get_last(const int_vector_type * );
int * int_vector_get_ptr(const int_vector_type * );
int * int_vector_alloc_data_copy( const int_vector_type * vector );
const int * int_vector_get_const_ptr(const int_vector_type * );
void int_vector_set_many(int_vector_type * , int , const int * , int );
void int_vector_set_all(int_vector_type * vector , int value);
void int_vector_append_many(int_vector_type * vector , const int * data , int length);
void int_vector_shrink(int_vector_type * );
int int_vector_sum(const int_vector_type * );
int int_vector_get_default(const int_vector_type * );
void int_vector_set_default(int_vector_type * vector, int default_value);
void int_vector_append_default(int_vector_type * vector , int default_value);
void int_vector_iset_default(int_vector_type * vector , int index , int default_value);
bool int_vector_is_sorted( const int_vector_type * vector , bool reverse);
int int_vector_index(const int_vector_type * vector , int value);
int int_vector_index_sorted(const int_vector_type * vector , int value);
void int_vector_sort(int_vector_type * vector);
void int_vector_rsort(int_vector_type * vector);
void int_vector_permute(int_vector_type * vector , const int * perm);
int * int_vector_alloc_sort_perm(const int_vector_type * vector);
int * int_vector_alloc_rsort_perm(const int_vector_type * vector);
void int_vector_fprintf(const int_vector_type * vector , FILE * stream , const char * name , const char * fmt);
void int_vector_fwrite(const int_vector_type * vector , FILE * stream);
void int_vector_buffer_fread(int_vector_type * vector , buffer_type * buffer);
int_vector_type * int_vector_fread_alloc( FILE * stream );
int_vector_type * int_vector_buffer_fread_alloc( buffer_type * buffer );
void int_vector_buffer_fwrite(const int_vector_type * vector , buffer_type * buffer);
void int_vector_fread( int_vector_type * vector , FILE * stream );
void int_vector_fwrite_data( const int_vector_type * vector , FILE * stream );
void int_vector_fread_data( int_vector_type * vector , int size, FILE * stream);
bool int_vector_equal(const int_vector_type * vector1 , const int_vector_type * vector2);
void int_vector_apply(int_vector_type * vector , int_ftype *func);
int int_vector_count_equal( const int_vector_type * vector , int cmp_value);
int int_vector_element_size( const int_vector_type * vector );
UTIL_SAFE_CAST_HEADER( int_vector );
#ifdef __cplusplus
}
#endif
#endif
//

49
ThirdParty/Ert/util/include/lars.h vendored Normal file
View File

@@ -0,0 +1,49 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'lars.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 __LARS_H__
#define __LARS_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <matrix.h>
#include <stdbool.h>
typedef struct lars_struct lars_type;
int lars_get_sample( const lars_type * lars );
int lars_get_nvar( const lars_type * lars );
lars_type * lars_alloc1( int nsample , int nvars);
lars_type * lars_alloc2( matrix_type * X , matrix_type * Y , bool internal_copy );
void lars_estimate(lars_type * lars , int max_vars , double max_beta , bool verbose);
void lars_isetX( lars_type * lars, int sample, int var , double value);
void lars_isetY( lars_type * lars, int sample, double value);
void lars_select_beta( lars_type * lars , int beta_index);
void lars_free( lars_type * lars );
double lars_eval1( const lars_type * lars , const matrix_type * x);
double lars_eval2( const lars_type * lars , double * x);
double lars_getY0( const lars_type * lars);
double lars_iget_beta( const lars_type * lars , int index);
#ifdef __cplusplus
}
#endif
#endif

52
ThirdParty/Ert/util/include/log.h vendored Normal file
View File

@@ -0,0 +1,52 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'log.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 __LOG_H__
#define __LOG_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdlib.h>
typedef struct log_struct log_type;
FILE * log_get_stream(log_type * logh );
void log_reset_filename( log_type * logh , const char * filename );
void log_set_file(log_type * , const char *);
log_type * log_alloc_new(const char *filename, int log_level);
log_type * log_alloc_existing(const char *filename, int log_level);
void log_add_message(log_type *logh, int message_level , FILE * dup_stream , char* message, bool free_message);
void log_add_fmt_message(log_type * logh , int message_level , FILE * dup_stream , const char * fmt , ...);
int log_get_level( const log_type * logh);
void log_set_level( log_type * logh , int new_level);
void log_close( log_type * logh );
inline void log_sync(log_type * logh);
const char * log_get_filename( const log_type * logh );
int log_get_level( const log_type * logh);
void log_set_level( log_type * logh , int log_level);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,116 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector_template.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 __long_VECTOR_H__
#define __long_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <buffer.h>
#include <util.h>
typedef struct long_vector_struct long_vector_type;
typedef long (long_ftype) (long);
int long_vector_lookup_bin( const long_vector_type * limits , long value , int guess);
int long_vector_lookup_bin__( const long_vector_type * limits , long value , int guess);
void long_vector_inplace_div( long_vector_type * vector , const long_vector_type * inv_factor);
void long_vector_inplace_mul( long_vector_type * vector , const long_vector_type * factor);
void long_vector_inplace_add( long_vector_type * vector , const long_vector_type * delta);
void long_vector_set_read_only( long_vector_type * vector , bool read_only);
bool long_vector_get_read_only( const long_vector_type * vector );
void long_vector_resize( long_vector_type * vector , int new_alloc_size );
void long_vector_memcpy( long_vector_type * target , const long_vector_type * src);
void long_vector_memcpy_data_block( long_vector_type * target , const long_vector_type * src , int target_offset , int src_offset , int len);
bool long_vector_growable( const long_vector_type * vector);
void long_vector_select_unique(long_vector_type * vector);
long_vector_type * long_vector_alloc( int init_size , long );
long_vector_type * long_vector_alloc_private_wrapper(int init_size, long default_value , long * data , int alloc_size);
long_vector_type * long_vector_alloc_shared_wrapper(int init_size, long default_value , long * data , int alloc_size);
long_vector_type * long_vector_alloc_strided_copy( const long_vector_type * src , int start , int stop , int stride );
long_vector_type * long_vector_alloc_copy( const long_vector_type * src);
void long_vector_imul(long_vector_type * vector, int index, long factor);
void long_vector_scale(long_vector_type * vector, long factor);
long long_vector_iget(const long_vector_type * , int);
long long_vector_safe_iget(const long_vector_type * , int);
long long_vector_get_min(const long_vector_type * vector);
long long_vector_get_max(const long_vector_type * vector);
int long_vector_get_min_index(const long_vector_type * vector, bool reverse);
int long_vector_get_max_index(const long_vector_type * vector, bool reverse);
long long_vector_iadd( long_vector_type * vector , int index , long delta);
void long_vector_iset(long_vector_type * , int , long);
void long_vector_idel_block( long_vector_type * vector , int index , int block_size);
long long_vector_idel( long_vector_type * vector , int index);
void long_vector_append(long_vector_type * , long);
void long_vector_free(long_vector_type *);
void long_vector_free__(void *);
void long_vector_free_data(long_vector_type *);
void long_vector_reset(long_vector_type *);
void long_vector_reset__(void * __vector);
int long_vector_size(const long_vector_type * );
long long_vector_pop(long_vector_type * vector);
long long_vector_get_first(const long_vector_type * vector);
long long_vector_get_last(const long_vector_type * );
long * long_vector_get_ptr(const long_vector_type * );
long * long_vector_alloc_data_copy( const long_vector_type * vector );
const long * long_vector_get_const_ptr(const long_vector_type * );
void long_vector_set_many(long_vector_type * , int , const long * , int );
void long_vector_set_all(long_vector_type * vector , long value);
void long_vector_append_many(long_vector_type * vector , const long * data , int length);
void long_vector_shrink(long_vector_type * );
long long_vector_sum(const long_vector_type * );
long long_vector_get_default(const long_vector_type * );
void long_vector_set_default(long_vector_type * vector, long default_value);
void long_vector_append_default(long_vector_type * vector , long default_value);
void long_vector_iset_default(long_vector_type * vector , int index , long default_value);
bool long_vector_is_sorted( const long_vector_type * vector , bool reverse);
int long_vector_index(const long_vector_type * vector , long value);
int long_vector_index_sorted(const long_vector_type * vector , long value);
void long_vector_sort(long_vector_type * vector);
void long_vector_rsort(long_vector_type * vector);
void long_vector_permute(long_vector_type * vector , const int * perm);
int * long_vector_alloc_sort_perm(const long_vector_type * vector);
int * long_vector_alloc_rsort_perm(const long_vector_type * vector);
void long_vector_fprintf(const long_vector_type * vector , FILE * stream , const char * name , const char * fmt);
void long_vector_fwrite(const long_vector_type * vector , FILE * stream);
void long_vector_buffer_fread(long_vector_type * vector , buffer_type * buffer);
long_vector_type * long_vector_fread_alloc( FILE * stream );
long_vector_type * long_vector_buffer_fread_alloc( buffer_type * buffer );
void long_vector_buffer_fwrite(const long_vector_type * vector , buffer_type * buffer);
void long_vector_fread( long_vector_type * vector , FILE * stream );
void long_vector_fwrite_data( const long_vector_type * vector , FILE * stream );
void long_vector_fread_data( long_vector_type * vector , int size, FILE * stream);
bool long_vector_equal(const long_vector_type * vector1 , const long_vector_type * vector2);
void long_vector_apply(long_vector_type * vector , long_ftype *func);
int long_vector_count_equal( const long_vector_type * vector , long cmp_value);
int long_vector_element_size( const long_vector_type * vector );
UTIL_SAFE_CAST_HEADER( long_vector );
#ifdef __cplusplus
}
#endif
#endif
//

View File

@@ -0,0 +1,46 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'lookup_table.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 __LOOKUP_TABLE_H__
#define __LOOKUP_TABLE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <double_vector.h>
typedef struct lookup_table_struct lookup_table_type;
void lookup_table_set_data( lookup_table_type * lt , double_vector_type * x , double_vector_type * y , bool data_owner );
lookup_table_type * lookup_table_alloc( double_vector_type * x , double_vector_type * y , bool data_owner);
lookup_table_type * lookup_table_alloc_empty();
void lookup_table_append( lookup_table_type * lt , double x , double y);
void lookup_table_free( lookup_table_type * lt );
double lookup_table_interp( lookup_table_type * lt , double x);
double lookup_table_get_max_value( lookup_table_type * lookup_table );
double lookup_table_get_min_value( lookup_table_type * lookup_table );
double lookup_table_get_max_arg( lookup_table_type * lookup_table );
double lookup_table_get_max_arg( lookup_table_type * lookup_table );
int lookup_table_get_size( const lookup_table_type * lt );
#ifdef __cplusplus
}
#endif
#endif

130
ThirdParty/Ert/util/include/matrix.h vendored Normal file
View File

@@ -0,0 +1,130 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'matrix.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 __MATRIX_H__
#define __MATRIX_H__
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <rng.h>
#include <thread_pool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct matrix_struct matrix_type;
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);
matrix_type * matrix_alloc(int rows, int columns);
matrix_type * matrix_safe_alloc(int rows, int columns);
bool matrix_resize(matrix_type * matrix , int rows , int columns , bool copy_content);
bool matrix_safe_resize(matrix_type * matrix , int rows , int columns , bool copy_content);
matrix_type * matrix_alloc_copy(const matrix_type * src);
matrix_type * matrix_safe_alloc_copy(const matrix_type * src);
matrix_type * matrix_alloc_shared(const matrix_type * src , int row , int column , int rows , int columns);
void matrix_free(matrix_type * matrix);
void matrix_safe_free( matrix_type * matrix );
void matrix_pretty_print(const matrix_type * matrix , const char * name , const char * fmt);
void matrix_set(matrix_type * matrix, double value);
void matrix_set_name( matrix_type * matrix , const char * name);
void matrix_scale(matrix_type * matrix, double value);
void matrix_shift(matrix_type * matrix, double value);
void matrix_assert_finite( const matrix_type * matrix );
void matrix_assign(matrix_type * A , const matrix_type * B);
void matrix_inplace_add(matrix_type * A , const matrix_type * B);
void matrix_inplace_sub(matrix_type * A , const matrix_type * B);
void matrix_inplace_mul(matrix_type * A , const matrix_type * B);
void matrix_inplace_div(matrix_type * A , const matrix_type * B);
void matrix_sub(matrix_type * A , const matrix_type * B , const matrix_type * C);
void matrix_mul( matrix_type * A , const matrix_type * B , const matrix_type * C);
void matrix_transpose(const matrix_type * A , matrix_type * T);
void matrix_iset_safe(matrix_type * matrix , int i , int j, double value);
void matrix_iset(matrix_type * matrix , int i , int j, double value);
double matrix_iget(const matrix_type * matrix , int i , int j);
double matrix_iget_safe(const matrix_type * matrix , int i , int j);
void matrix_iadd(matrix_type * matrix , int i , int j , double value);
void matrix_isub(matrix_type * matrix , int i , int j , double value);
void matrix_imul(matrix_type * matrix , int i , int j , double value);
void matrix_inplace_matmul(matrix_type * A, const matrix_type * B);
void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads);
void matrix_inplace_matmul_mt2(matrix_type * A, const matrix_type * B , thread_pool_type * thread_pool);
void matrix_shift_column(matrix_type * matrix , int column, double shift);
void matrix_shift_row(matrix_type * matrix , int row , double shift);
double matrix_get_column_sum(const matrix_type * matrix , int column);
double matrix_get_row_sum(const matrix_type * matrix , int column);
double matrix_get_column_sum2(const matrix_type * matrix , int column);
double matrix_get_row_abssum(const matrix_type * matrix , int row);
double matrix_get_column_abssum(const matrix_type * matrix , int column);
double matrix_get_row_sum2(const matrix_type * matrix , int column);
void matrix_subtract_row_mean(matrix_type * matrix);
void matrix_subtract_and_store_row_mean(matrix_type * matrix, matrix_type * row_mean);
void matrix_scale_column(matrix_type * matrix , int column , double scale_factor);
void matrix_scale_row(matrix_type * matrix , int row , double scale_factor);
void matrix_set_const_column(matrix_type * matrix , const double value , int column);
void matrix_copy_column(matrix_type * target_matrix, const matrix_type * src_matrix , int src_column, int target_column);
void matrix_set_const_row(matrix_type * matrix , const double value , int row);
double * matrix_get_data(const matrix_type * matrix);
bool matrix_is_finite(const matrix_type * matrix);
double matrix_orthonormality( const matrix_type * matrix );
matrix_type * matrix_alloc_steal_data(int rows , int columns , double * data , int data_size);
void matrix_set_column(matrix_type * matrix , const double * data , int column);
void matrix_set_many_on_column(matrix_type * matrix , int row_offset , int elements , const double * data , int column);
void matrix_ensure_rows(matrix_type * matrix, int rows, bool copy_content);
void matrix_shrink_header(matrix_type * matrix , int rows , int columns);
void matrix_full_size( matrix_type * matrix );
int matrix_get_rows(const matrix_type * matrix);
int matrix_get_columns(const matrix_type * matrix);
int matrix_get_row_stride(const matrix_type * matrix);
int matrix_get_column_stride(const matrix_type * matrix);
void matrix_get_dims(const matrix_type * matrix , int * rows , int * columns , int * row_stride , int * column_stride);
bool matrix_is_quadratic(const matrix_type * matrix);
bool matrix_equal( const matrix_type * m1 , const matrix_type * m2);
void matrix_diag_set_scalar(matrix_type * matrix , double value);
void matrix_diag_set(matrix_type * matrix , const double * diag);
void matrix_random_init(matrix_type * matrix , rng_type * rng);
void matrix_matlab_dump(const matrix_type * matrix, const char * filename);
void matrix_imul_col( matrix_type * matrix , int column , double factor);
double matrix_column_column_dot_product(const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2);
double matrix_row_column_dot_product(const matrix_type * m1 , int row1 , const matrix_type * m2 , int col2);
matrix_type * matrix_alloc_view(double * data , int rows , int columns);
matrix_type * matrix_alloc_transpose( const matrix_type * A);
void matrix_copy_row(matrix_type * target_matrix, const matrix_type * src_matrix , int target_row, int src_row);
void matrix_copy_block( matrix_type * target_matrix , int target_row , int target_column , int rows , int columns,
const matrix_type * src_matrix , int src_row , int src_column);
void matrix_scalar_set( matrix_type * matrix , double value);
UTIL_SAFE_CAST_HEADER( matrix )
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,40 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'matrix_blas.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.
*/
#include <stdbool.h>
#include <matrix.h>
#ifdef __cplusplus
extern "C" {
#endif
void matrix_dgemm(matrix_type *C , const matrix_type *A , const matrix_type * B , bool transA, bool transB , double alpha , double beta);
void matrix_matmul(matrix_type * A, const matrix_type *B , const matrix_type * C);
matrix_type * matrix_alloc_matmul(const matrix_type * A, const matrix_type * B);
void matrix_dgemv(const matrix_type * A , const double * x , double * y , bool transA , double alpha , double beta);
void matrix_mul_vector(const matrix_type * A , const double * x , double * y);
void matrix_gram_set( const matrix_type * X , matrix_type * G, bool col);
matrix_type * matrix_alloc_gram( const matrix_type * X , bool col);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,93 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'matrix_lapack.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 __MATRIX_LAPACK_H__
#define __MATRIX_LAPACK_H__
#include <matrix.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
This enum is just a simple way to label the different ways the
singular vectors in U and VT are returned to the calling scope. The
low level lapack routine uses a character variable, indicated
below.
*/
typedef enum {
/* A */ DGESVD_ALL, /* Returns all the singular vectors in U/VT. */
/* S */ DGESVD_MIN_RETURN, /* Return the first min(m,n) vectors in U/VT. */
/* O */ DGESVD_MIN_OVERWRITE, /* Return the first min(m,n) vectors of U/VT by overwriteing in A. */
/* N */ DGESVD_NONE} /* Do not compute any singular vectors for U/VT */
dgesvd_vector_enum;
typedef enum {
/* A */ DSYEVX_ALL, /* Compute all the eigenvalues */
/* V */ DSYEVX_VALUE_INTERVAL, /* Computes eigenvalues in half open interval <VL , VU] */
/* I */ DSYEVX_INDEX_INTERVAL} /* The IL-th through IU'th eigenvalue will be found. */
dsyevx_eig_enum;
typedef enum {
/* U */ DSYEVX_AUPPER, /* The data is stored in the upper right part of the A matrix. */
/* L */ DSYEVX_ALOWER} /* The data is stored in the lower left part of the A matrix. */
dsyevx_uplo_enum;
void matrix_dgesv(matrix_type * A , matrix_type * B);
void matrix_dgesvd(dgesvd_vector_enum jobv, dgesvd_vector_enum jobvt , matrix_type * A , double * S , matrix_type * U , matrix_type * VT);
int matrix_dsyevx(bool compute_eig_vectors ,
dsyevx_eig_enum which_values ,
dsyevx_uplo_enum uplo,
matrix_type * A ,
double VL ,
double VU ,
int IL ,
int IU ,
double *eig_values ,
matrix_type * Z ) ;
int matrix_dsyevx_all(dsyevx_uplo_enum uplo ,
matrix_type * A ,
double *eig_values ,
matrix_type * Z );
void matrix_dgeqrf(matrix_type * A , double * tau);
void matrix_dorgqr(matrix_type * A , double * tau, int num_reflectors);
double matrix_det( matrix_type *A );
int matrix_inv( matrix_type * A );
#ifdef __cplusplus
}
#endif
#endif

38
ThirdParty/Ert/util/include/menu.h vendored Normal file
View File

@@ -0,0 +1,38 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'menu.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 __MENU_H__
#define __MENU_H__
typedef struct menu_struct menu_type;
typedef struct menu_item_struct menu_item_type;
typedef void (menu_func_type) (void *);
typedef void (arg_free_ftype) (void *);
menu_type * menu_alloc(const char * , const char * , const char *);
void menu_run(const menu_type * );
void menu_free(menu_type * );
menu_item_type * menu_get_item(const menu_type * , char );
menu_item_type * menu_add_item(menu_type *, const char * , const char * , menu_func_type * , void * , arg_free_ftype * );
void menu_add_separator(menu_type * );
menu_item_type * menu_get_item(const menu_type * , char );
void menu_set_title(menu_type *, const char *);
void menu_item_set_label( menu_item_type * , const char *);
#endif

46
ThirdParty/Ert/util/include/msg.h vendored Normal file
View File

@@ -0,0 +1,46 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'msg.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 __MSG_H__
#define __MSG_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <util.h>
#include <stdbool.h>
typedef struct msg_struct msg_type;
msg_type * msg_alloc(const char * , bool debug);
void msg_show(msg_type * );
void msg_free(msg_type * , bool);
void msg_update(msg_type * , const char * );
void msg_update_int(msg_type * , const char * , int );
void msg_hide(msg_type *);
void msg_clear_msg(msg_type * msg);
UTIL_SAFE_CAST_HEADER( msg );
#ifdef __cplusplus
}
#endif
#endif

46
ThirdParty/Ert/util/include/mzran.h vendored Normal file
View File

@@ -0,0 +1,46 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'mzran.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 __MZRAN_H__
#define __MZRAN_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <util.h>
typedef struct mzran_struct mzran_type;
#define MZRAN_MAX_VALUE 4294967296
#define MZRAN_STATE_SIZE 16 /* Size of the seed buffer - in bytes. */
void mzran_fscanf_state( void * __rng , FILE * stream );
unsigned int mzran_forward(void * __rng);
void * mzran_alloc( );
void mzran_set_state(void * __rng , const char * seed_buffer);
double mzran_get_double(mzran_type * rng);
int mzran_get_int( mzran_type * rng, int max);
void mzran_fprintf_state( const void * __rng , FILE * stream);
void mzran_free( void * __rng );
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,50 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'node_ctype.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 __NODE_CTYPE_H__
#define __NODE_CTYPE_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
value : means a scalar which has been packed into the container
object.
pointer: means a (typed) pointer which points to a memory location
outside the container object (however the container can own
the memory).
*/
typedef enum {CTYPE_VOID_POINTER = 1,
CTYPE_INT_VALUE = 2,
CTYPE_DOUBLE_VALUE = 3,
CTYPE_FLOAT_VALUE = 4 ,
CTYPE_CHAR_VALUE = 5 ,
CTYPE_BOOL_VALUE = 6 ,
CTYPE_SIZE_T_VALUE = 7 ,
CTYPE_INVALID = 100} node_ctype;
const char * node_ctype_name(node_ctype );
#ifdef __cplusplus
}
#endif
#endif

57
ThirdParty/Ert/util/include/node_data.h vendored Normal file
View File

@@ -0,0 +1,57 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'node_data.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 __NODE_DATA_H__
#define __NODE_DATA_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
typedef void * ( copyc_ftype ) (const void *);
typedef void ( free_ftype ) (void *);
typedef struct node_data_struct node_data_type;
void node_data_free(node_data_type *);
void node_data_free_container(node_data_type * );
node_data_type * node_data_alloc_deep_copy(const node_data_type * );
node_data_type * node_data_alloc_shallow_copy(const node_data_type * );
node_data_type * node_data_alloc_copy(const node_data_type * node , bool deep_copy);
void * node_data_get_ptr(const node_data_type *);
const void * node_data_get_const_ptr(const node_data_type *);
node_data_type * node_data_alloc_buffer(const void *, int );
node_data_type * node_data_alloc_ptr(const void * , copyc_ftype * , free_ftype *);
node_data_type * node_data_alloc_int(int );
int node_data_get_int( const node_data_type * );
int node_data_fetch_and_inc_int( node_data_type * node_data );
node_data_type * node_data_alloc_double(double );
double node_data_get_double( const node_data_type * );
node_data_type * node_data_alloc_string(const char *);
char * node_data_get_string( const node_data_type * );
#ifdef __cplusplus
}
#endif
#endif

159
ThirdParty/Ert/util/include/parser.h vendored Normal file
View File

@@ -0,0 +1,159 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'parser.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 __PARSER_H__
#define __PARSER_H__
#include <stringlist.h>
typedef struct parser_struct parser_type;
/**
GENERAL OVERVIEW
The parser_type is used to create a series of "tokens"
from a file or string buffer. In it's simplest form,
we define a token as a subset of a string separated by
by some split characters.
For example, if we define the normal space (i.e. " ") as
the only split character, "tokenizing" the string
"I like beer " would give the following result:
Token number 0 is "I"
Token number 1 is "like"
Token number 2 is "beer"
Note that all the white space (i.e. split characters) have been
removed.
COMMENTS
The parser can ignore comments when tokenzing
a file or buffer. To enable this feature, allocate
the parser_type with comment_start and comment_end
different from NULL. For example if we set both
comment_start and comment_end to "##", tokenizing
"I ## really ## like beer" would give:
Token number 0 is "I"
Token number 1 is "like"
Token number 2 is "beer"
SPECIAL CHARACTERS
Some times it can be useful to define a set of characters which
behave like white space in the sense that they separate tokens in
the source, but they do not get dropped. For example, letting "=" be
a special character, tokenzing "key=value" would give:
Token number 0 is "key"
Token number 1 is "="
Token number 2 is "value"
The special characters are given in the "specials" string when
allocating the parser.
QUOTERS
When parsing user input, the user often wants to provide e.g. a
filename with a white-space character in it. To support this, the
parser can be given a set of quoters. For example, letting " " be
white space and adding "'" to the quoters, tokenizing
"my_file = 'my documents with space in.txt'"
would give:
Token number 0 is "my_file"
Token number 1 is "="
Token number 2 is "'my documents with space in.txt'"
If wanted, the quoting characters can be removed
using the strip_quote_marks options when running
the parser on the buffer. The last token
in the example above would then be:
Token number 2 is "my documents with space in.txt"
To use one of the quoter characters in a string,
place a "\" in front of it. Building on our previous
example, let the string be "my_file = 'my \'doc.txt'"
Tokenzing this with strip_quote_marks set to true
would give:
Token number 0 is "my_file"
Token number 1 is "="
Token number 2 is "my 'doc.txt"
Note that the "\" in front of"'" has been removed.
If strip_quote_marks is set to false, the result is:
Token number 0 is "my_file"
Token number 1 is "="
Token number 2 is "'my \'doc.txt'"
*/
parser_type * parser_alloc(
const char * whitespace, /** Set to NULL if not interessting. */
const char * quoters, /** Set to NULL if not interessting. */
const char * specials, /** Set to NULL if not interessting. */
const char * delete_set,
const char * comment_start, /** Set to NULL if not interessting. */
const char * comment_end); /** Set to NULL if not interessting. */
void parser_set_splitters( parser_type * parser , const char * splitters );
void parser_set_quoters( parser_type * parser , const char * quoters );
void parser_set_specials( parser_type * parser , const char * specials );
void parser_set_delete_set( parser_type * parser , const char * delete_set );
void parser_set_comment_start( parser_type * parser , const char * comment_start );
void parser_set_comment_end( parser_type * parser , const char * comment_end );
void parser_free(
parser_type * parser);
stringlist_type * parser_tokenize_buffer(
const parser_type * parser,
const char * buffer,
bool strip_quote_marks);
stringlist_type * parser_tokenize_file(
const parser_type * parser,
const char * filename,
bool strip_quote_marks);
/* Pollution by Joakim: */
void parser_strip_buffer(const parser_type * parser , char ** __buffer);
bool parser_fseek_string(const parser_type * parser , FILE * stream , const char * string , bool skip_string , bool case_sensitive);
char * parser_fread_alloc_file_content(const char * filename , const char * quote_set , const char * delete_set , const char * comment_start , const char * comment_end);
#endif

47
ThirdParty/Ert/util/include/path_fmt.h vendored Normal file
View File

@@ -0,0 +1,47 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'path_fmt.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 __PATH_FMT_H__
#define __PATH_FMT_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <stdbool.h>
#include <node_ctype.h>
typedef struct path_fmt_struct path_fmt_type;
path_fmt_type * path_fmt_safe_cast(const void * arg);
path_fmt_type * path_fmt_alloc_directory_fmt(const char * );
path_fmt_type * path_fmt_alloc_path_fmt(const char * );
path_fmt_type * path_fmt_copyc(const path_fmt_type *);
path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * , bool );
char * path_fmt_alloc_path(const path_fmt_type * , bool , ...);
char * path_fmt_alloc_file(const path_fmt_type * , bool , ...);
void path_fmt_free(path_fmt_type * );
const char * path_fmt_get_fmt(const path_fmt_type * );
void path_fmt_reset_fmt(path_fmt_type * , const char * );
void path_fmt_make_path(const path_fmt_type * );
path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt );
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,36 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'regression.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 __REGRESSION_H__
#define __REGRESSION_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <matrix.h>
double regression_scale( matrix_type * X , matrix_type * Y , matrix_type * X_mean , matrix_type * X_norm);
double regression_unscale(const matrix_type * beta , const matrix_type * X_norm , const matrix_type * X_mean , double Y_mean , matrix_type * beta0);
void regression_OLS(const matrix_type * X , const matrix_type * Y , matrix_type * beta);
#ifdef __cplusplus
}
#endif
#endif

75
ThirdParty/Ert/util/include/rng.h vendored Normal file
View File

@@ -0,0 +1,75 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'rng.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 __RNG_H__
#define __RNG_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <util.h>
typedef enum {
INIT_DEFAULT = 0, /* The rng is initialized with the default seed values. */
INIT_CLOCK = 1, /* Four random seeds are calculated with the util_clock_seed() function. */
INIT_DEV_RANDOM = 2, /* Random content is read with the function util_fread_dev_random(). */
INIT_DEV_URANDOM = 3 /* Random content is read with the function util_fread_dev_urandom(). */
} rng_init_mode;
typedef enum {
MZRAN = 1
} rng_alg_type;
typedef unsigned int ( rng_forward_ftype ) ( void * );
typedef void ( rng_set_state_ftype ) ( void * , const char * );
typedef void * ( rng_alloc_ftype ) ( );
typedef void ( rng_free_ftype ) ( void * );
typedef void ( rng_fscanf_ftype ) ( void * , FILE * );
typedef void ( rng_fprintf_ftype ) ( const void * , FILE * );
typedef struct rng_struct rng_type;
rng_type * rng_alloc( rng_alg_type type , rng_init_mode init_mode );
void rng_free( rng_type * rng);
void rng_free( rng_type * rng);
unsigned int rng_forward( rng_type * rng );
double rng_get_double( rng_type * rng);
void rng_rng_init( rng_type * rng , rng_type * seed_src);
void rng_init( rng_type * rng , rng_init_mode init_mode );
rng_alg_type rng_get_type( const rng_type * rng );
void rng_fprintf_state( rng_type * rng , FILE * stream );
void rng_fscanf_state( rng_type * rng , FILE * stream );
unsigned int rng_forward( rng_type * rng );
double rng_get_double( rng_type * rng );
int rng_get_int( rng_type * rng , int max_value );
double rng_std_normal( rng_type * rng );
void rng_shuffle_int( rng_type * rng , int * data , size_t num_elements);
void rng_shuffle( rng_type * rng , char * data , size_t element_size , size_t num_elements);
UTIL_SAFE_CAST_HEADER( rng );
#ifdef __cplusplus
}
#endif
#endif

61
ThirdParty/Ert/util/include/set.h vendored Normal file
View File

@@ -0,0 +1,61 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'set.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 __SET_H__
#define __SET_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <hash.h>
typedef struct set_struct set_type;
typedef struct set_iter_struct set_iter_type;
void set_clear( set_type * set );
void set_remove_key(set_type * , const char * );
set_type * set_alloc(int , const char ** );
set_type * set_alloc_empty();
bool set_add_key(set_type * , const char * );
bool set_has_key(const set_type * set, const char * );
void set_free(set_type * );
int set_get_size(const set_type *);
char ** set_alloc_keylist(const set_type * );
void set_fwrite(const set_type * , FILE * );
void set_fread(set_type * , FILE * );
set_type * set_fread_alloc(FILE *);
void set_fprintf(const set_type * , const char * sep , FILE * );
void set_intersect(set_type * , const set_type * );
void set_union(set_type * , const set_type * );
void set_minus(set_type * , const set_type * );
set_type * set_copyc(const set_type *);
set_iter_type * set_iter_alloc(const set_type * set);
void set_iter_free(set_iter_type * set_iter);
bool set_iter_is_complete(const set_iter_type * set_iter);
const char * set_iter_get_next_key(set_iter_type * set_iter);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,116 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector_template.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 __size_t_VECTOR_H__
#define __size_t_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <buffer.h>
#include <util.h>
typedef struct size_t_vector_struct size_t_vector_type;
typedef size_t (size_t_ftype) (size_t);
int size_t_vector_lookup_bin( const size_t_vector_type * limits , size_t value , int guess);
int size_t_vector_lookup_bin__( const size_t_vector_type * limits , size_t value , int guess);
void size_t_vector_inplace_div( size_t_vector_type * vector , const size_t_vector_type * inv_factor);
void size_t_vector_inplace_mul( size_t_vector_type * vector , const size_t_vector_type * factor);
void size_t_vector_inplace_add( size_t_vector_type * vector , const size_t_vector_type * delta);
void size_t_vector_set_read_only( size_t_vector_type * vector , bool read_only);
bool size_t_vector_get_read_only( const size_t_vector_type * vector );
void size_t_vector_resize( size_t_vector_type * vector , int new_alloc_size );
void size_t_vector_memcpy( size_t_vector_type * target , const size_t_vector_type * src);
void size_t_vector_memcpy_data_block( size_t_vector_type * target , const size_t_vector_type * src , int target_offset , int src_offset , int len);
bool size_t_vector_growable( const size_t_vector_type * vector);
void size_t_vector_select_unique(size_t_vector_type * vector);
size_t_vector_type * size_t_vector_alloc( int init_size , size_t );
size_t_vector_type * size_t_vector_alloc_private_wrapper(int init_size, size_t default_value , size_t * data , int alloc_size);
size_t_vector_type * size_t_vector_alloc_shared_wrapper(int init_size, size_t default_value , size_t * data , int alloc_size);
size_t_vector_type * size_t_vector_alloc_strided_copy( const size_t_vector_type * src , int start , int stop , int stride );
size_t_vector_type * size_t_vector_alloc_copy( const size_t_vector_type * src);
void size_t_vector_imul(size_t_vector_type * vector, int index, size_t factor);
void size_t_vector_scale(size_t_vector_type * vector, size_t factor);
size_t size_t_vector_iget(const size_t_vector_type * , int);
size_t size_t_vector_safe_iget(const size_t_vector_type * , int);
size_t size_t_vector_get_min(const size_t_vector_type * vector);
size_t size_t_vector_get_max(const size_t_vector_type * vector);
int size_t_vector_get_min_index(const size_t_vector_type * vector, bool reverse);
int size_t_vector_get_max_index(const size_t_vector_type * vector, bool reverse);
size_t size_t_vector_iadd( size_t_vector_type * vector , int index , size_t delta);
void size_t_vector_iset(size_t_vector_type * , int , size_t);
void size_t_vector_idel_block( size_t_vector_type * vector , int index , int block_size);
size_t size_t_vector_idel( size_t_vector_type * vector , int index);
void size_t_vector_append(size_t_vector_type * , size_t);
void size_t_vector_free(size_t_vector_type *);
void size_t_vector_free__(void *);
void size_t_vector_free_data(size_t_vector_type *);
void size_t_vector_reset(size_t_vector_type *);
void size_t_vector_reset__(void * __vector);
int size_t_vector_size(const size_t_vector_type * );
size_t size_t_vector_pop(size_t_vector_type * vector);
size_t size_t_vector_get_first(const size_t_vector_type * vector);
size_t size_t_vector_get_last(const size_t_vector_type * );
size_t * size_t_vector_get_ptr(const size_t_vector_type * );
size_t * size_t_vector_alloc_data_copy( const size_t_vector_type * vector );
const size_t * size_t_vector_get_const_ptr(const size_t_vector_type * );
void size_t_vector_set_many(size_t_vector_type * , int , const size_t * , int );
void size_t_vector_set_all(size_t_vector_type * vector , size_t value);
void size_t_vector_append_many(size_t_vector_type * vector , const size_t * data , int length);
void size_t_vector_shrink(size_t_vector_type * );
size_t size_t_vector_sum(const size_t_vector_type * );
size_t size_t_vector_get_default(const size_t_vector_type * );
void size_t_vector_set_default(size_t_vector_type * vector, size_t default_value);
void size_t_vector_append_default(size_t_vector_type * vector , size_t default_value);
void size_t_vector_iset_default(size_t_vector_type * vector , int index , size_t default_value);
bool size_t_vector_is_sorted( const size_t_vector_type * vector , bool reverse);
int size_t_vector_index(const size_t_vector_type * vector , size_t value);
int size_t_vector_index_sorted(const size_t_vector_type * vector , size_t value);
void size_t_vector_sort(size_t_vector_type * vector);
void size_t_vector_rsort(size_t_vector_type * vector);
void size_t_vector_permute(size_t_vector_type * vector , const int * perm);
int * size_t_vector_alloc_sort_perm(const size_t_vector_type * vector);
int * size_t_vector_alloc_rsort_perm(const size_t_vector_type * vector);
void size_t_vector_fprintf(const size_t_vector_type * vector , FILE * stream , const char * name , const char * fmt);
void size_t_vector_fwrite(const size_t_vector_type * vector , FILE * stream);
void size_t_vector_buffer_fread(size_t_vector_type * vector , buffer_type * buffer);
size_t_vector_type * size_t_vector_fread_alloc( FILE * stream );
size_t_vector_type * size_t_vector_buffer_fread_alloc( buffer_type * buffer );
void size_t_vector_buffer_fwrite(const size_t_vector_type * vector , buffer_type * buffer);
void size_t_vector_fread( size_t_vector_type * vector , FILE * stream );
void size_t_vector_fwrite_data( const size_t_vector_type * vector , FILE * stream );
void size_t_vector_fread_data( size_t_vector_type * vector , int size, FILE * stream);
bool size_t_vector_equal(const size_t_vector_type * vector1 , const size_t_vector_type * vector2);
void size_t_vector_apply(size_t_vector_type * vector , size_t_ftype *func);
int size_t_vector_count_equal( const size_t_vector_type * vector , size_t cmp_value);
int size_t_vector_element_size( const size_t_vector_type * vector );
UTIL_SAFE_CAST_HEADER( size_t_vector );
#ifdef __cplusplus
}
#endif
#endif
//

View File

@@ -0,0 +1,34 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'statistics.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 __STATISTICS_H__
#define __STATISTICS_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <double_vector.h>
double statistics_mean( const double_vector_type * data_vector );
double statistics_empirical_quantile( double_vector_type * data , double quantile );
double statistics_empirical_quantile__( const double_vector_type * data , double quantile );
#ifdef __cplusplus
}
#endif
#endif

35
ThirdParty/Ert/util/include/stepwise.h vendored Normal file
View File

@@ -0,0 +1,35 @@
#ifndef __STEPWISE_H__
#define __STEPWISE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <matrix.h>
#include <bool_vector.h>
typedef struct stepwise_struct stepwise_type;
stepwise_type * stepwise_alloc2( matrix_type * X , matrix_type * Y , bool internal_copy , rng_type * rng);
stepwise_type * stepwise_alloc1(int nsample, int nvar, rng_type * rng);
stepwise_type * stepwise_alloc0(rng_type * rng);
void stepwise_free( stepwise_type * stepwise);
void stepwise_estimate( stepwise_type * stepwise , double deltaR2_limit , int CV_blocks);
double stepwise_eval( const stepwise_type * stepwise , const matrix_type * x );
void stepwise_set_Y0( stepwise_type * stepwise , matrix_type * Y);
void stepwise_set_X0( stepwise_type * stepwise , matrix_type * X);
void stepwise_set_beta( stepwise_type * stepwise , matrix_type * b);
void stepwise_set_active_set( stepwise_type * stepwise , bool_vector_type * a);
void stepwise_isetY0( stepwise_type * stepwise , int i , double value );
int stepwise_get_nvar( stepwise_type * stepwise );
int stepwise_get_nsample( stepwise_type * stepwise );
#ifdef __cplusplus
}
#endif
#endif

103
ThirdParty/Ert/util/include/stringlist.h vendored Normal file
View File

@@ -0,0 +1,103 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'stringlist.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 __STRINGLIST_H__
#define __STRINGLIST_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdio.h>
#include <int_vector.h>
#include <buffer.h>
typedef struct stringlist_struct stringlist_type;
typedef int ( string_cmp_ftype) (const void * , const void *);
void stringlist_deep_copy( stringlist_type * target , const stringlist_type * src);
stringlist_type * stringlist_alloc_deep_copy_with_limits(const stringlist_type * src , int offset, int num_strings);
stringlist_type * stringlist_alloc_deep_copy_with_offset(const stringlist_type * src , int offset);
stringlist_type * stringlist_alloc_deep_copy( const stringlist_type * src );
stringlist_type * stringlist_alloc_new();
void stringlist_free__(void * );
void stringlist_free(stringlist_type *);
void stringlist_clear(stringlist_type * );
void stringlist_append_copy(stringlist_type * , const char *);
void stringlist_append_ref(stringlist_type * , const char *);
void stringlist_append_owned_ref(stringlist_type * , const char *);
const char * stringlist_safe_iget( const stringlist_type * stringlist , int index);
bool stringlist_iequal( const stringlist_type * stringlist , int index, const char * s );
const char * stringlist_iget(const stringlist_type * , int);
char * stringlist_iget_copy(const stringlist_type * stringlist , int );
char * stringlist_alloc_joined_string(const stringlist_type * , const char * );
char * stringlist_alloc_joined_substring( const stringlist_type * s , int start_index , int end_index , const char * sep );
void stringlist_iset_copy(stringlist_type *, int index , const char *);
void stringlist_iset_ref(stringlist_type *, int index , const char *);
void stringlist_iset_owned_ref(stringlist_type *, int index , const char *);
void stringlist_insert_copy(stringlist_type *, int index , const char *);
void stringlist_insert_ref(stringlist_type *, int index , const char *);
void stringlist_insert_owned_ref(stringlist_type *, int index , const char *);
void stringlist_idel(stringlist_type * stringlist , int index);
int stringlist_get_size(const stringlist_type * );
void stringlist_fprintf(const stringlist_type * , const char * , FILE *);
void stringlist_fprintf_fmt(const stringlist_type * stringlist, const stringlist_type * fmt_list , FILE * stream);
stringlist_type * stringlist_alloc_argv_copy(const char ** , int );
stringlist_type * stringlist_alloc_argv_ref (const char ** , int );
stringlist_type * stringlist_alloc_argv_owned_ref(const char ** argv , int argc);
stringlist_type * stringlist_alloc_shallow_copy(const stringlist_type *);
stringlist_type * stringlist_alloc_shallow_copy_with_offset(const stringlist_type * stringlist, int offset);
stringlist_type * stringlist_alloc_shallow_copy_with_limits(const stringlist_type * stringlist, int offset , int num_strings);
stringlist_type * stringlist_alloc_from_split( const char * input_string , const char * sep );
stringlist_type * stringlist_fread_alloc(FILE * );
void stringlist_append_stringlist_copy(stringlist_type * , const stringlist_type * );
void stringlist_append_stringlist_ref(stringlist_type * , const stringlist_type * );
void stringlist_insert_stringlist_copy(stringlist_type * , const stringlist_type *, int);
bool stringlist_equal(const stringlist_type * , const stringlist_type *);
bool stringlist_contains(const stringlist_type * , const char * );
int_vector_type * stringlist_find(const stringlist_type *, const char *);
int stringlist_find_first(const stringlist_type * , const char * );
int stringlist_get_argc(const stringlist_type * );
char ** stringlist_alloc_char_copy(const stringlist_type * );
void stringlist_fread(stringlist_type * , FILE * );
void stringlist_fwrite(const stringlist_type * , FILE * );
void stringlist_buffer_fread( stringlist_type * s , buffer_type * buffer );
void stringlist_buffer_fwrite( const stringlist_type * s , buffer_type * buffer );
void stringlist_sort(stringlist_type * , string_cmp_ftype * string_cmp);
void stringlist_python_sort( stringlist_type * s , int cmp_flag);
int stringlist_select_matching(stringlist_type * names , const char * pattern);
UTIL_IS_INSTANCE_HEADER(stringlist);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,56 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'subst_func.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 __SUBST_FUNC_H__
#define __SUBST_FUNC_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stringlist.h>
typedef char * (subst_func_ftype) (const stringlist_type * , void * );
typedef struct subst_func_struct subst_func_type;
typedef struct subst_func_pool_struct subst_func_pool_type;
char * subst_func_eval( const subst_func_type * subst_func , const stringlist_type * args);
/*****************************************************************/
subst_func_pool_type * subst_func_pool_alloc( );
void subst_func_pool_free( subst_func_pool_type * pool );
void subst_func_pool_add_func( subst_func_pool_type * pool , const char * func_name , const char * doc_string , subst_func_ftype * func , bool vararg, int argc_min , int argc_max , void * arg);
subst_func_type * subst_func_pool_get_func( const subst_func_pool_type * pool , const char * func_name );
bool subst_func_pool_has_func( const subst_func_pool_type * pool , const char * func_name );
UTIL_IS_INSTANCE_HEADER( subst_func_pool );
/*****************************************************************/
char * subst_func_randint( const stringlist_type * args , void * arg);
char * subst_func_randfloat( const stringlist_type * args , void * arg);
char * subst_func_add( const stringlist_type * args , void * arg);
char * subst_func_mul( const stringlist_type * args , void * arg);
char * subst_func_exp( const stringlist_type * args , void * arg);
char * subst_func_log( const stringlist_type * args , void * arg);
char * subst_func_pow10( const stringlist_type * args , void * arg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,65 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'subst_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 __SUBST_H__
#define __SUBST_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <util.h>
#include <node_data.h>
#include <subst_func.h>
typedef struct subst_list_struct subst_list_type;
void subst_list_update_buffer( const subst_list_type * subst_list , buffer_type * buffer );
void subst_list_insert_func(subst_list_type * subst_list , const char * func_name , const char * local_func_name);
void subst_list_fprintf(const subst_list_type * , FILE * stream);
void subst_list_set_parent( subst_list_type * subst_list , const subst_list_type * parent);
const subst_list_type * subst_list_get_parent( const subst_list_type * subst_list );
subst_list_type * subst_list_alloc( const void * input_arg );
subst_list_type * subst_list_alloc_deep_copy(const subst_list_type * );
void subst_list_free(subst_list_type *);
void subst_list_clear( subst_list_type * subst_list );
void subst_list_append_copy(subst_list_type * , const char * , const char * , const char * doc_string);
void subst_list_append_ref(subst_list_type * , const char * , const char * , const char * doc_string);
void subst_list_append_owned_ref(subst_list_type * , const char * , const char * , const char * doc_string);
void subst_list_prepend_copy(subst_list_type * , const char * , const char * , const char * doc_string);
void subst_list_prepend_ref(subst_list_type * , const char * , const char * , const char * doc_string);
void subst_list_prepend_owned_ref(subst_list_type * , const char * , const char * , const char * doc_string);
void subst_list_filter_file(const subst_list_type * , const char * , const char * );
void subst_list_update_file(const subst_list_type * , const char * );
void subst_list_update_string(const subst_list_type * , char ** );
char * subst_list_alloc_filtered_string(const subst_list_type * , const char * );
void subst_list_filtered_fprintf(const subst_list_type * , const char * , FILE * );
int subst_list_get_size( const subst_list_type *);
const char * subst_list_iget_value( const subst_list_type * subst_list , int index);
const char * subst_list_iget_key( const subst_list_type * subst_list , int index);
const char * subst_list_iget_doc_string( const subst_list_type * subst_list , int index);
char * subst_list_alloc_string_representation( const subst_list_type * subst_list );
int subst_list_add_from_string( subst_list_type * subst_list , const char * arg_string, bool append);
#ifdef __cplusplus
}
#endif
#endif

47
ThirdParty/Ert/util/include/template.h vendored Normal file
View File

@@ -0,0 +1,47 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'template.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 __TEMPLATE_H__
#define __TEMPLATE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <subst_list.h>
typedef struct template_struct template_type;
template_type * template_alloc( const char * template_file , bool internalize_template, subst_list_type * parent_subst);
void template_free( template_type * template );
void template_instansiate( const template_type * template , const char * __target_file , const subst_list_type * arg_list , bool override_symlink);
void template_add_arg( template_type * template , const char * key , const char * value );
void template_clear_args( template_type * template );
int template_add_args_from_string( template_type * template , const char * arg_string);
char * template_get_args_as_string( template_type * template );
void template_set_template_file( template_type * template , const char * template_file);
const char * template_get_template_file( const template_type * template );
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,26 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'thread_pool.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 __THREAD_POOL_H__
#define __THREAD_POOL_H__
#ifdef HAVE_PTHREAD
#define HAVE_THREAD_POOL
#include "thread_pool_posix.h"
#endif
#endif

View File

@@ -0,0 +1,35 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'thread_pool_posix.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.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
typedef struct thread_pool_struct thread_pool_type;
void thread_pool_join(thread_pool_type * );
thread_pool_type * thread_pool_alloc(int , bool start_queue);
void thread_pool_add_job(thread_pool_type * ,void * (*) (void *) , void *);
void thread_pool_free(thread_pool_type *);
void thread_pool_restart( thread_pool_type * tp );
void * thread_pool_iget_return_value( const thread_pool_type * pool , int queue_index );
int thread_pool_get_max_running( const thread_pool_type * pool );
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,116 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector_template.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 __time_t_VECTOR_H__
#define __time_t_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <buffer.h>
#include <util.h>
typedef struct time_t_vector_struct time_t_vector_type;
typedef time_t (time_t_ftype) (time_t);
int time_t_vector_lookup_bin( const time_t_vector_type * limits , time_t value , int guess);
int time_t_vector_lookup_bin__( const time_t_vector_type * limits , time_t value , int guess);
void time_t_vector_inplace_div( time_t_vector_type * vector , const time_t_vector_type * inv_factor);
void time_t_vector_inplace_mul( time_t_vector_type * vector , const time_t_vector_type * factor);
void time_t_vector_inplace_add( time_t_vector_type * vector , const time_t_vector_type * delta);
void time_t_vector_set_read_only( time_t_vector_type * vector , bool read_only);
bool time_t_vector_get_read_only( const time_t_vector_type * vector );
void time_t_vector_resize( time_t_vector_type * vector , int new_alloc_size );
void time_t_vector_memcpy( time_t_vector_type * target , const time_t_vector_type * src);
void time_t_vector_memcpy_data_block( time_t_vector_type * target , const time_t_vector_type * src , int target_offset , int src_offset , int len);
bool time_t_vector_growable( const time_t_vector_type * vector);
void time_t_vector_select_unique(time_t_vector_type * vector);
time_t_vector_type * time_t_vector_alloc( int init_size , time_t );
time_t_vector_type * time_t_vector_alloc_private_wrapper(int init_size, time_t default_value , time_t * data , int alloc_size);
time_t_vector_type * time_t_vector_alloc_shared_wrapper(int init_size, time_t default_value , time_t * data , int alloc_size);
time_t_vector_type * time_t_vector_alloc_strided_copy( const time_t_vector_type * src , int start , int stop , int stride );
time_t_vector_type * time_t_vector_alloc_copy( const time_t_vector_type * src);
void time_t_vector_imul(time_t_vector_type * vector, int index, time_t factor);
void time_t_vector_scale(time_t_vector_type * vector, time_t factor);
time_t time_t_vector_iget(const time_t_vector_type * , int);
time_t time_t_vector_safe_iget(const time_t_vector_type * , int);
time_t time_t_vector_get_min(const time_t_vector_type * vector);
time_t time_t_vector_get_max(const time_t_vector_type * vector);
int time_t_vector_get_min_index(const time_t_vector_type * vector, bool reverse);
int time_t_vector_get_max_index(const time_t_vector_type * vector, bool reverse);
time_t time_t_vector_iadd( time_t_vector_type * vector , int index , time_t delta);
void time_t_vector_iset(time_t_vector_type * , int , time_t);
void time_t_vector_idel_block( time_t_vector_type * vector , int index , int block_size);
time_t time_t_vector_idel( time_t_vector_type * vector , int index);
void time_t_vector_append(time_t_vector_type * , time_t);
void time_t_vector_free(time_t_vector_type *);
void time_t_vector_free__(void *);
void time_t_vector_free_data(time_t_vector_type *);
void time_t_vector_reset(time_t_vector_type *);
void time_t_vector_reset__(void * __vector);
int time_t_vector_size(const time_t_vector_type * );
time_t time_t_vector_pop(time_t_vector_type * vector);
time_t time_t_vector_get_first(const time_t_vector_type * vector);
time_t time_t_vector_get_last(const time_t_vector_type * );
time_t * time_t_vector_get_ptr(const time_t_vector_type * );
time_t * time_t_vector_alloc_data_copy( const time_t_vector_type * vector );
const time_t * time_t_vector_get_const_ptr(const time_t_vector_type * );
void time_t_vector_set_many(time_t_vector_type * , int , const time_t * , int );
void time_t_vector_set_all(time_t_vector_type * vector , time_t value);
void time_t_vector_append_many(time_t_vector_type * vector , const time_t * data , int length);
void time_t_vector_shrink(time_t_vector_type * );
time_t time_t_vector_sum(const time_t_vector_type * );
time_t time_t_vector_get_default(const time_t_vector_type * );
void time_t_vector_set_default(time_t_vector_type * vector, time_t default_value);
void time_t_vector_append_default(time_t_vector_type * vector , time_t default_value);
void time_t_vector_iset_default(time_t_vector_type * vector , int index , time_t default_value);
bool time_t_vector_is_sorted( const time_t_vector_type * vector , bool reverse);
int time_t_vector_index(const time_t_vector_type * vector , time_t value);
int time_t_vector_index_sorted(const time_t_vector_type * vector , time_t value);
void time_t_vector_sort(time_t_vector_type * vector);
void time_t_vector_rsort(time_t_vector_type * vector);
void time_t_vector_permute(time_t_vector_type * vector , const int * perm);
int * time_t_vector_alloc_sort_perm(const time_t_vector_type * vector);
int * time_t_vector_alloc_rsort_perm(const time_t_vector_type * vector);
void time_t_vector_fprintf(const time_t_vector_type * vector , FILE * stream , const char * name , const char * fmt);
void time_t_vector_fwrite(const time_t_vector_type * vector , FILE * stream);
void time_t_vector_buffer_fread(time_t_vector_type * vector , buffer_type * buffer);
time_t_vector_type * time_t_vector_fread_alloc( FILE * stream );
time_t_vector_type * time_t_vector_buffer_fread_alloc( buffer_type * buffer );
void time_t_vector_buffer_fwrite(const time_t_vector_type * vector , buffer_type * buffer);
void time_t_vector_fread( time_t_vector_type * vector , FILE * stream );
void time_t_vector_fwrite_data( const time_t_vector_type * vector , FILE * stream );
void time_t_vector_fread_data( time_t_vector_type * vector , int size, FILE * stream);
bool time_t_vector_equal(const time_t_vector_type * vector1 , const time_t_vector_type * vector2);
void time_t_vector_apply(time_t_vector_type * vector , time_t_ftype *func);
int time_t_vector_count_equal( const time_t_vector_type * vector , time_t cmp_value);
int time_t_vector_element_size( const time_t_vector_type * vector );
UTIL_SAFE_CAST_HEADER( time_t_vector );
#ifdef __cplusplus
}
#endif
#endif
//

45
ThirdParty/Ert/util/include/timer.h vendored Normal file
View File

@@ -0,0 +1,45 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'timer.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 __TIMER_H__
#define __TIMER_H__
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
typedef struct timer_struct timer_type;
timer_type * timer_alloc(const char *, bool );
void timer_free(timer_type *);
void timer_start(timer_type *);
double timer_stop(timer_type *);
void timer_reset(timer_type *);
void timer_report(const timer_type * , FILE *);
void timer_list_report(const timer_type ** , int , FILE *) ;
double timer_get_total_time(const timer_type *timer);
double timer_get_max_time(const timer_type *timer);
double timer_get_min_time(const timer_type *timer);
double timer_get_avg_time(const timer_type *timer);
#endif

500
ThirdParty/Ert/util/include/util.h vendored Normal file
View File

@@ -0,0 +1,500 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'util.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 __UTIL_H__
#define __UTIL_H__
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdarg.h>
#define UTIL_PATH_SEP_STRING "/" /* A \0 terminated separator used when we want a (char *) instance. */
#define UTIL_PATH_SEP_CHAR '/' /* A simple character used when we want an actual char instance (i.e. not a pointer). */
#define UTIL_NEWLINE_STRING " \n"
#define UTIL_DEFAULT_MKDIR_MODE 0777 /* Directories are by default created with mode a+rwx - and then comes the umask ... */
#ifdef __cplusplus
extern"C" {
#endif
/*****************************************************************/
/**
The four macros UTIL_IS_INSTANCE_FUNCTION, UTIL_SAFE_CAST_FUNTION,
UTIL_TYPE_ID_DECLARATION and UTIL_TYPE_ID_INIT can be used to
implement a simple system for type checking (void *) at
runtime. The system is based on a unique integer for each class,
this must be provided by the user.
The motivation for these functions is to be able to to type-check
the arguments to callback functions like pthread_create.
UTIL_TYPE_ID_DECLARATION: Adds a field "int __type_id;" to the
struct defintion.
UTIL_TYPE_ID_INIT: Should be added to the allocation routine,
inserts a "->__type_id = magic_int;" code line in the alloc
routine.
UTIL_IS_INSTANCE_FUNCTION: This macro will generate a function
<type>_is_instance(void *) which will cast the (void *) input to
(type *), and check the value of __type_id. If this is the
correct value true is returned, otherwise the function will
return false. Observe that the function will accept NULL as
input; in which case it will return false.
UTIL_SAFE_CAST_FUNCTION: This is similar to
UTIL_IS_INSTANCE_FUNCTION, but it will return (type *) if the
cast succeeds, and fail hard if it fails. There is also a _CONST
variety of this function.
*/
#define UTIL_IS_INSTANCE_FUNCTION(type , TYPE_ID) \
bool type ## _is_instance( const void * __arg ) { \
if (__arg == NULL) \
return false; \
else { \
const type ## _type * arg = (type ## _type *) __arg; \
if ( arg->__type_id == TYPE_ID) \
return true; \
else \
return false; \
} \
}
#define UTIL_IS_INSTANCE_HEADER(type) bool type ## _is_instance( const void * __arg );
#define UTIL_SAFE_CAST_FUNCTION(type , TYPE_ID) \
type ## _type * type ## _safe_cast( void * __arg ) { \
if (__arg == NULL) { \
util_abort("%s: runtime cast failed - tried to dereference NULL\n",__func__); \
return NULL; \
} \
type ## _type * arg = (type ## _type *) __arg; \
if ( arg->__type_id == TYPE_ID) \
return arg; \
else { \
util_abort("%s: runtime cast failed: File:%s Line:%d. Got:%d Expected:%d \n", __func__ , __FILE__ , __LINE__ , arg->__type_id , TYPE_ID); \
return NULL; \
} \
}
#define UTIL_SAFE_CAST_HEADER( type ) type ## _type * type ## _safe_cast( void * __arg );
#define UTIL_SAFE_CAST_FUNCTION_CONST(type , TYPE_ID) \
const type ## _type * type ## _safe_cast_const( const void * __arg ) { \
const type ## _type * arg = (const type ## _type *) __arg; \
if ( arg->__type_id == TYPE_ID) \
return arg; \
else { \
util_abort("%s: runtime cast failed: File:%s Line:%d. Got:%d Expected:%d \n", __func__ , __FILE__ , __LINE__ , arg->__type_id , TYPE_ID); \
return NULL; \
} \
}
#define UTIL_SAFE_CAST_HEADER_CONST( type ) const type ## _type * type ## _safe_cast_const( const void * __arg );
#define UTIL_TYPE_ID_DECLARATION int __type_id;
#define UTIL_TYPE_ID_INIT(var , TYPE_ID) var->__type_id = TYPE_ID;
/*****************************************************************/
/*
*/
#define LIBRARY_VERSION(libname) \
const char * libname ## _svn_version() { return SVN_VERSION; } \
const char * libname ## _build_time() { return NULL; }
#define LIBRARY_VERSION_HEADER(libname) \
const char * libname ## _svn_version(); \
const char * libname ## _build_time();
/*****************************************************************/
typedef void (walk_file_callback_ftype) (const char * , /* The current directory */
const char * , /* The current file / directory */
void *); /* Arbitrary argument */
typedef bool (walk_dir_callback_ftype) (const char * , /* The current directory */
const char * , /* The current file / directory */
int , /* The current depth in the file hiearcrcy. */
void *); /* Arbitrary argument */
typedef enum {left_pad = 0,
right_pad = 1,
center = 2} string_alignement_type;
LIBRARY_VERSION_HEADER(libutil);
void util_bitmask_on(int * , int );
time_t util_make_datetime(int , int , int , int , int , int );
void util_fprintf_datetime(time_t , FILE * );
void util_fprintf_date(time_t , FILE * );
time_t util_make_date(int , int , int);
void util_inplace_forward_days(time_t * , double);
double util_difftime(time_t , time_t , int * , int * , int * , int *);
double util_difftime_days(time_t , time_t );
char * util_alloc_date_string( time_t t );
char * util_alloc_date_stamp( );
double util_pow10(double x);
bool util_char_in(char c, int , const char *);
char * util_alloc_sprintf_va(const char * fmt , va_list ap);
char * util_alloc_sprintf(const char * , ...);
char * util_realloc_sprintf(char * , const char * , ...);
void util_fprintf_int(int , int , FILE * );
void util_fprintf_string(const char * , int , string_alignement_type , FILE * );
void util_fprintf_double(double , int , int , char , FILE *);
bool util_fscanf_date(FILE * , time_t *);
bool util_sscanf_date(const char * , time_t *);
char * util_blocking_alloc_stdin_line(unsigned long );
char * util_alloc_stdin_line();
char * util_realloc_stdin_line(char * );
bool util_is_executable(const char * );
bool util_entry_exists( const char * entry );
bool util_file_exists(const char *);
bool util_is_abs_path(const char * );
char * util_alloc_abs_path( const char * path );
bool util_fmt_bit8 (const char *);
bool util_fmt_bit8_stream(FILE * );
void util_make_path (const char *);
char * util_newest_file(const char *, const char *);
double util_file_difftime(const char * , const char *);
bool util_file_update_required(const char *, const char *);
size_t util_file_size(const char *);
void util_clear_directory(const char *path, bool strict_uid , bool unlink_root);
void util_unlink_existing(const char *filename);
void util_strupr(char *);
bool util_string_equal(const char * s1 , const char * s2 );
char * util_alloc_strupr_copy(const char * );
void util_string_tr(char * , char , char);
bool util_copy_stream(FILE *, FILE *, int , void * , bool abort_on_error);
void util_move_file(const char * src_file , const char * target_file);
void util_move_file4( const char * src_name , const char * target_name , const char *src_path , const char * target_path);
bool util_copy_file(const char * , const char * );
void util_copy_directory(const char * , const char * , const char *);
void util_walk_directory(const char * root_path , walk_file_callback_ftype * file_callback , void * file_callback_arg , walk_dir_callback_ftype * dir_callback , void * dir_callback_arg);
char * util_alloc_cwd(void);
char * util_alloc_realpath(const char * );
bool util_string_match(const char * string , const char * pattern);
bool util_string_has_wildcard( const char * s);
#ifdef HAVE_UID_T
uid_t util_get_entry_uid( const char * file );
#endif
bool util_entry_readable( const char * entry );
bool util_addmode_if_owner( const char * filename , mode_t add_mode );
bool util_delmode_if_owner( const char * filename , mode_t del_mode);
bool util_chmod_if_owner( const char * filename , mode_t new_mode);
int util_forward_line(FILE * , bool * );
void util_rewind_line(FILE *);
int util_count_content_file_lines(FILE * );
int util_count_file_lines(FILE * );
FILE * util_mkdir_fopen( const char * filename , const char * mode );
FILE * util_fopen(const char * , const char *);
void util_fclose( FILE * stream );
bool util_fopen_test(const char *, const char *);
void util_alloc_file_components(const char * , char ** , char **, char **);
//char * util_realloc_full_path(char * , const char *, const char *);
char * util_alloc_tmp_file(const char * , const char * , bool );
char * util_fscanf_alloc_line(FILE *, bool *);
char * util_fscanf_realloc_line(FILE *, bool * , char *);
char * util_fscanf_alloc_token(FILE * );
void util_fskip_token(FILE * );
void util_fskip_space(FILE * , bool *);
void util_fskip_chars(FILE * , const char * , bool *);
void util_fskip_cchars(FILE * , const char * , bool *);
bool util_fscanf_int(FILE * , int * );
bool util_fscanf_bool(FILE * stream , bool * value);
bool util_sscanf_bool(const char * , bool *);
bool util_sscanf_octal_int(const char * buffer , unsigned int * value);
int util_strcmp_int( const char * s1 , const char * s2);
int util_strcmp_float( const char * s1 , const char * s2);
bool util_sscanf_int(const char * , int * );
const char * util_parse_int(const char * , int * , bool *);
const char * util_skip_sep(const char * , const char * , bool *);
int util_scanf_int_with_limits(const char * , int , int , int );
char * util_scanf_int_with_limits_return_char(const char * , int , int , int );
void util_printf_prompt(const char * , int , char , const char *);
int util_scanf_int(const char * , int);
char * util_scanf_int_return_char(const char * , int);
double util_scanf_double(const char * prompt , int prompt_len);
char * util_scanf_alloc_string(const char * );
bool util_sscanf_double(const char * , double * );
//char * util_alloc_full_path(const char *, const char *);
char * util_alloc_filename(const char * , const char * , const char * );
char * util_realloc_filename(char * , const char * , const char * , const char * );
char * util_alloc_strip_copy(const char *);
char * util_realloc_strip_copy(char *);
void util_set_strip_copy(char * , const char *);
char * util_alloc_string_sum(const char ** , int);
char * util_strcat_realloc(char *, const char * );
char * util_alloc_string_copy(const char *);
char ** util_stringlist_append_copy(char ** , int , const char * );
char ** util_stringlist_append_ref(char ** , int , const char * );
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 ***);
void util_binary_split_string(const char * , const char * , bool , char ** , char ** );
char * util_alloc_joined_string(const char ** , int , const char * );
char * util_alloc_multiline_string(const char ** , int );
char * util_string_replace_alloc(const char *, const char *, const char *);
char * util_string_replacen_alloc(const char *, int , const char ** , const char **);
int util_string_replace_inplace(char ** , const char * , const char *);
char * util_string_strip_chars_alloc(const char *, const char * );
char * util_realloc_string_copy(char * , const char *);
char * util_realloc_substring_copy(char * , const char *, int );
char * util_realloc_dequoted_string(char *);
char * util_alloc_dequoted_copy(const char *s);
void util_safe_free(void *);
void util_free_stringlist(char **, int );
char * util_alloc_substring_copy(const char *, int );
bool util_is_directory(const char * );
bool util_is_file(const char * );
void util_set_datetime_values(time_t , int * , int * , int * , int * , int * , int *);
void util_set_date_values(time_t , int * , int * , int * );
void util_fread_from_buffer(void * , size_t , size_t , char ** );
unsigned int util_clock_seed( );
void util_fread_dev_random(int , char * );
void util_fread_dev_urandom(int , char * );
char * util_alloc_string_copy(const char *);
void util_enkf_unlink_ensfiles(const char *, const char *, int , bool );
bool util_string_isspace(const char * s);
void util_exit(const char * fmt , ...);
void util_abort(const char * fmt , ...);
void util_abort_signal(int );
void util_abort_append_version_info(const char * );
void util_abort_free_version_info();
void util_abort_set_executable( const char * executable );
void * util_realloc(void * , size_t , const char * );
void * util_malloc(size_t , const char * );
void * util_realloc_copy(void * org_ptr , const void * src , size_t byte_size , const char * caller);
void * util_alloc_copy(const void * , size_t , const char * );
void util_double_to_float(float * , const double * , int );
void util_float_to_double(double * , const float * , int );
int util_get_month_nr(const char * );
char * util_fread_alloc_file_content(const char * , int *);
void util_fwrite_string(const char * , FILE *);
char * util_fread_realloc_string(char * , FILE *);
char * util_fread_alloc_string(FILE *);
void util_fskip_string(FILE *stream);
void util_endian_flip_vector(void *, int , int );
bool util_proc_alive(pid_t pid);
int util_proc_mem_free(void);
void util_apply_int_limits(int * , int , int );
void util_apply_float_limits(float * , float , float );
void util_apply_double_limits(double * , double , double );
double util_double_vector_mean(int , const double * );
double util_double_vector_stddev(int , const double * );
void util_double_vector_max_min(int , const double *, double * , double *);
void util_update_double_max_min(double , double * , double * );
void util_update_float_max_min(float , float * , float * );
void util_update_int_max_min(int , int * , int * );
float util_float_max (float , float );
long int util_long_max(long int a , long int b);
int util_int_max (int , int);
double util_double_max(double , double );
float util_float_min (float , float );
int util_int_min (int , int);
size_t util_size_t_min(size_t a , size_t b);
size_t util_size_t_max(size_t a , size_t b);
time_t util_time_t_min(time_t a , time_t b);
time_t util_time_t_max(time_t a , time_t b);
double util_double_min(double , double );
void util_fskip_lines(FILE * , int);
bool util_same_file(const char * , const char * );
void util_read_path(const char * , int , bool , char * );
char * util_fscanf_alloc_filename(const char * , int , int);
void util_read_string(const char * , int , char * );
void util_fread (void *, size_t , size_t , FILE * , const char * );
void util_fwrite(const void *, size_t , size_t , FILE * , const char * );
time_t util_fread_time_t(FILE * stream);
int util_fread_int(FILE * );
long util_fread_long(FILE * );
bool util_fread_bool(FILE * );
double util_fread_double(FILE * stream);
void util_fwrite_int (int , FILE * );
void util_fwrite_long (long , FILE * );
void util_fwrite_bool (bool , FILE * );
void util_fwrite_time_t (time_t , FILE * );
void util_fwrite_double(double , FILE * );
void util_fwrite_int_vector (const int * , int , FILE * , const char * );
void util_fwrite_double_vector(const double * , int , FILE * , const char * );
void util_fread_char_vector(char * , int , FILE * , const char * );
#define CONTAINS_HEADER(TYPE) int util_sorted_contains_ ## TYPE(const TYPE * data , int size , TYPE value);
CONTAINS_HEADER(int);
CONTAINS_HEADER(time_t);
CONTAINS_HEADER(size_t);
#undef CONTAINS_HEADER
#ifdef HAVE_ZLIB
void util_compress_buffer(const void * , int , void * , unsigned long * );
int util_fread_sizeof_compressed(FILE * stream);
void util_fread_compressed(void * , FILE * );
void * util_fread_alloc_compressed(FILE * );
void util_fwrite_compressed(const void * , int , FILE * );
#endif
void util_block_growing_file(const char * );
void util_block_growing_directory(const char * );
char * util_alloc_realpath(const char * );
bool util_sscanf_bytesize(const char * , size_t *);
void util_sscanf_active_range(const char * , int , bool * );
int * util_sscanf_alloc_active_list(const char * , int * );
int util_get_current_linenr(FILE * stream);
const char * util_update_path_var(const char * , const char * , bool );
int util_get_type( void * data );
void util_fskip_int(FILE * stream);
void util_fskip_long(FILE * stream);
void util_fskip_bool(FILE * stream);
bool util_fseek_string(FILE * stream , const char * string , bool skip_string , bool case_sensitive);
char * util_fscanf_alloc_upto(FILE * stream , const char * stop_string, bool include_stop_string);
bool util_files_equal( const char * file1 , const char * file2 );
double util_kahan_sum(const double *data, size_t N);
int util_fnmatch( const char * pattern , const char * string );
void util_localtime( time_t * t , struct tm * ts );
char * util_alloc_PATH_executable(const char * executable );
char * util_isscanf_alloc_envvar( const char * string , int env_index );
void util_setenv( const char * variable , const char * value);
const char * util_interp_setenv( const char * variable , const char * value);
void util_unsetenv( const char * variable);
char * util_alloc_envvar( const char * value );
#ifdef HAVE_SYMLINK
bool util_is_link(const char * );
void util_make_slink(const char *, const char * );
char * util_alloc_link_target(const char * link);
#ifdef HAVE_READLINKAT
char * util_alloc_atlink_target(const char * path , const char * link);
#endif
#endif
#ifdef HAVE_FORK
#include "util_fork.h"
#endif
#ifdef HAVE_LOCKF
FILE * util_fopen_lockf(const char * , const char * );
bool util_try_lockf(const char * , mode_t , int * );
#endif
#define UTIL_FWRITE_SCALAR(s,stream) { if (fwrite(&s , sizeof s , 1 , stream) != 1) util_abort("%s: write failed: %s\n",__func__ , strerror(errno)); }
#define UTIL_FREAD_SCALAR(s,stream) { if (fread(&s , sizeof s , 1 , stream) != 1) util_abort("%s: read failed: %s\n",__func__ , strerror(errno)); }
#define UTIL_FWRITE_VECTOR(s,n,stream) { if (fwrite(s , sizeof s , (n) , stream) != (n)) util_abort("%s: write failed: %s \n",__func__ , strerror(errno)); }
#define UTIL_FREAD_VECTOR(s,n,stream) { if (fread(s , sizeof s , (n) , stream) != (n)) util_abort("%s: read failed: %s \n",__func__ , strerror(errno)); }
/*****************************************************************/
/*
The code below here is a simple functionality to support 'enum
introspection'; the point is that when calling the library functions
from Python/ctypes it is very valuable to have access to the enum
values from the Python side. The enum defintions is just used during
the compile phase, and then subsequently dropped. It is therefor
impossible to determine enum values by inspecting the resulting
object files.
The approach which has been chosen is that each of the enums which
should support 'introspection' from Python should have a function:
const char * <enum>_iget(int index, int * value) {
...
}
which should take an enum element number as input argument and
return a string representation of the corresponding enum element and
also update the value reference to contain the corresponding enum
value. If index is out of range the function should return NULL and
also set value to -1. The python layer can then create an integer
variable with the correct name and value in the calling module.
The util_enum_element_type and the util_enum_iget() function are
convenience functions which can be used to avoid indirectly
repeating the enum definition in the <enum>_iget() function.
In the example below we create the enum definition in normal way in
the header file, and then in addition we repeat the defintion in a
#define a symbol which is used as argument in the <enum>_iget()
function:
header_file:
------------
enum my_enum {
INVALID = 0,
VALUE1 = 2,
VALUE2 = 17
}
// The enum definition is repeated; but at at least at the very same spot of the code.
#define MY_ENUM_DEF { .value = INVALID, .name="INVALID"} , {.value = VALUE1 , .name="VALUE1"} , {.value = VALUE2 , .name="VALUE2"}
#define MY_ENUM_SIZE 3
source file:
------------
const char * my_enum_iget(int index, int * value) {
return util_enum_iget( index , MY_ENUM_SIZE , (const util_enum_element_type []) MY_ENUM_DEF , value);
}
*/
typedef struct {
int value;
const char * name;
} util_enum_element_type;
const char * util_enum_iget( int index , int size , const util_enum_element_type * enum_defs , int * value);
#ifdef __cplusplus
}
#endif
#endif

84
ThirdParty/Ert/util/include/vector.h vendored Normal file
View File

@@ -0,0 +1,84 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'vector.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 __VECTOR_H__
#define __VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <node_data.h>
typedef void ( vector_func_type ) (void * , void *);
typedef int ( vector_cmp_ftype) (const void * , const void *);
typedef struct vector_struct vector_type;
vector_type * vector_alloc_new();
vector_type * vector_alloc_NULL_initialized( int size );
int vector_append_ref( vector_type * , const void *);
int vector_append_owned_ref( vector_type * , const void * , free_ftype * del);
int vector_append_copy(vector_type * , const void *, copyc_ftype *, free_ftype *);
void vector_iset_ref( vector_type * , int , const void *);
void vector_iset_owned_ref( vector_type * , int , const void * , free_ftype * del);
void vector_iset_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *);
void vector_safe_iset_copy(vector_type * vector , int index , const void * data, copyc_ftype * copyc , free_ftype * del);
void vector_safe_iset_owned_ref(vector_type * vector , int index , const void * data, free_ftype * del);
void vector_safe_iset_ref(vector_type * vector , int index , const void * data);
void vector_insert_ref( vector_type * , int , const void *);
void vector_insert_owned_ref( vector_type * , int , const void * , free_ftype * del);
void vector_insert_copy(vector_type * , int , const void *, copyc_ftype *, free_ftype *);
void vector_insert_buffer(vector_type * vector , int index , const void * buffer, int buffer_size);
void vector_push_ref( vector_type * , const void *);
void vector_push_owned_ref( vector_type * , const void * , free_ftype * del);
void vector_push_copy(vector_type * , const void *, copyc_ftype *, free_ftype *);
void vector_clear(vector_type * vector);
void vector_free(vector_type * );
void vector_free__( void * arg );
void vector_append_buffer(vector_type * , const void * , int);
void vector_push_buffer(vector_type * , const void * , int);
int vector_get_size(const vector_type * );
void * vector_safe_iget(const vector_type * vector, int index);
const void * vector_safe_iget_const(const vector_type * vector, int index);
const void * vector_iget_const(const vector_type * , int );
void * vector_iget(const vector_type * , int );
void vector_idel(vector_type * vector , int index);
void vector_shrink( vector_type * vector , int new_size );
void * vector_get_last(const vector_type * );
const void * vector_get_last_const(const vector_type * );
int vector_get_size( const vector_type * );
void * vector_pop(vector_type * );
void vector_sort(vector_type * vector , vector_cmp_ftype * cmp);
vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy);
void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size);
#ifdef __cplusplus
}
#endif
#endif

BIN
ThirdParty/Ert/util/lib/libutil.a vendored Normal file

Binary file not shown.

68
ThirdParty/Ert/well/include/well_conn.h vendored Normal file
View File

@@ -0,0 +1,68 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'well_conn.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 __WELL_CONN_H__
#define __WELL_CONN_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <ecl_kw.h>
#include <ecl_intehead.h>
typedef enum {
well_conn_dirX = 1,
well_conn_dirY = 2,
well_conn_dirZ = 3,
well_conn_fracX = 4,
well_conn_fracY = 5
} well_conn_dir_enum;
/*
Observe that when the (ijk) values are initialized they are
shifted to zero offset values, to be aligned with the rest of the
ert libraries.
*/
typedef struct {
int i;
int j;
int k;
int branch;
int segment; // -1: Ordinary well
bool open;
well_conn_dir_enum dir;
} well_conn_type;
void well_conn_free( well_conn_type * conn);
void well_conn_free__( void * arg );
well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw , const ecl_kw_type * iseg_kw , const ecl_intehead_type * header , int well_nr , int seg_well_nr , int conn_nr);
well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_intehead_type * header , int well_nr);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,90 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'well_const.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 __WELL_CONST_H__
#define __WELL_CONST_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
Observe that the values given as _ITEM are not indices which can
be directly used in the IWEL or ICON keywords; an offset must be
added.
*/
#define IWEL_HEADI_ITEM 0
#define IWEL_HEADJ_ITEM 1
#define IWEL_HEADK_ITEM 2
#define IWEL_CONNECTIONS_ITEM 4
#define IWEL_TYPE_ITEM 6
#define IWEL_STATUS_ITEM 10
#define IWEL_LGR_ITEM 42
#define IWEL_SEGMENTED_WELL_NR_ITEM 70
#define ISEG_BRANCH_ITEM 3
#define ICON_IC_ITEM 0
#define ICON_I_ITEM 1
#define ICON_J_ITEM 2
#define ICON_K_ITEM 3
#define ICON_STATUS_ITEM 5
#define ICON_DIRECTION_ITEM 13
#define ICON_SEGMENT_ITEM 14
#define ICON_DIRX 1
#define ICON_DIRY 2
#define ICON_DIRZ 3
#define ICON_FRACX 4
#define ICON_FRACY 5
#define ICON_DEFAULT_DIR_VALUE 0
#define ICON_DEFAULT_DIR_TARGET ICON_DIRZ
/*
The ECLIPSE documentation says that a certain item in the IWEL array
should indicate the type of the well, the available types are the
ones given in the enum below. Unfortunately it turns out that when
the well is closed the integer value in the IWEL array can be 0, if
the well is indeed closed we accept this zero - otherwise we fail
hard. Theese hoops are in the well_state_alloc() routine.
*/
#define IWEL_UNDOCUMENTED_ZERO 0
#define IWEL_PRODUCER 1
#define IWEL_OIL_INJECTOR 2
#define IWEL_WATER_INJECTOR 3
#define IWEL_GAS_INJECTOR 4
typedef enum {
UNDOCUMENTED_ZERO = 0,
PRODUCER = 10,
WATER_INJECTOR = 22,
GAS_INJECTOR = 21,
OIL_INJECTOR = 78
} well_type_enum;
#ifdef __cplusplus
}
#endif
#endif

52
ThirdParty/Ert/well/include/well_info.h vendored Normal file
View File

@@ -0,0 +1,52 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'well_info.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#ifndef __WELL_INFO_H__
#define __WELL_INFO_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ecl_file.h>
#include <ecl_grid.h>
#include <well_ts.h>
typedef struct well_info_struct well_info_type;
well_info_type * well_info_alloc(const ecl_grid_type * grid);
void well_info_add_UNRST_wells( well_info_type * well_info , ecl_file_type * rst_file);
void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file , int report_nr );
void well_info_load_rstfile( well_info_type * well_info , const char * filename);
void well_info_free( well_info_type * well_info );
well_ts_type * well_info_get_ts( const well_info_type * well_info , const char *well_name);
int well_info_get_num_wells( const well_info_type * well_info );
const char * well_info_iget_well_name( const well_info_type * well_info, int well_index);
well_state_type * well_info_get_state_from_time( const well_info_type * well_info , const char * well_name , time_t sim_time);
well_state_type * well_info_get_state_from_report( const well_info_type * well_info , const char * well_name , int report_step );
well_state_type * well_info_iget_state_from_report( const well_info_type * well_info , const char * well_name , int time_index);
well_state_type * well_info_iiget_state( const well_info_type * well_info , int well_index , int time_index);
#ifdef __cplusplus
}
#endif
#endif

172
ThirdParty/Ert/well/include/well_state.c vendored Normal file
View File

@@ -0,0 +1,172 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'well_state.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.
*/
/**
The well_state_type structure contains state information about one
well for one particular point in time.
*/
#include <time.h>
#include <stdbool.h>
#include <util.h>
#include <vector.h>
#include <int_vector.h>
#include <ecl_intehead.h>
#include <ecl_file.h>
#include <ecl_kw.h>
#include <ecl_kw_magic.h>
#include <ecl_util.h>
#include <well_const.h>
#include <well_conn.h>
#include <well_state.h>
#define WELL_STATE_TYPE_ID 613307832
struct well_state_struct {
UTIL_TYPE_ID_DECLARATION;
char * name;
time_t valid_from_time;
int valid_from_report;
bool open;
well_conn_type * wellhead;
vector_type * connections;
well_type_enum type;
};
UTIL_IS_INSTANCE_FUNCTION( well_state , WELL_STATE_TYPE_ID)
static well_state_type * well_state_alloc_empty() {
well_state_type * well_state = util_malloc( sizeof * well_state , __func__ );
UTIL_TYPE_ID_INIT( well_state , WELL_STATE_TYPE_ID );
well_state->connections = vector_alloc_new();
return well_state;
}
void well_state_add_conn( well_state_type * well_state , int grid_nr , well_conn_type * conn) {
vector_append_owned_ref( well_state->connections , conn , well_conn_free__);
}
well_state_type * well_state_alloc( const ecl_file_type * ecl_file , const ecl_intehead_type * header , int report_nr , int grid_nr , int well_nr) {
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( ecl_file , IWEL_KW , grid_nr);
const ecl_kw_type * zwel_kw = ecl_file_iget_named_kw( ecl_file , ZWEL_KW , grid_nr);
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( ecl_file , ICON_KW , grid_nr);
{
well_state_type * well_state = well_state_alloc_empty();
const int iwel_offset = header->niwelz * well_nr;
const int zwel_offset = header->nzwelz * well_nr;
well_state->valid_from_time = header->sim_time;
well_state->valid_from_report = report_nr;
well_state->name = util_alloc_strip_copy(ecl_kw_iget_ptr( zwel_kw , zwel_offset )); // Hardwired max 8 characters in Well Name
{
well_state->wellhead = well_conn_alloc_wellhead( iwel_kw , header , well_nr );
}
{
int int_state = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_STATUS_ITEM );
if (int_state > 0)
well_state->open = true;
else
well_state->open = false;
}
{
int num_connections = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_CONNECTIONS_ITEM );
int lgr_index = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_LGR_ITEM );
for (int conn_nr = 0; conn_nr < num_connections; conn_nr++) {
well_conn_type * conn = well_conn_alloc( icon_kw , header , well_nr , conn_nr );
well_state_add_conn( well_state , grid_nr , conn );
}
printf("lgr_index:%d \n",lgr_index);
}
{
int int_type = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_TYPE_ITEM);
switch (int_type) {
case(IWEL_PRODUCER):
well_state->type = PRODUCER;
break;
case(IWEL_OIL_INJECTOR):
well_state->type = OIL_INJECTOR;
break;
case(IWEL_GAS_INJECTOR):
well_state->type = GAS_INJECTOR;
break;
case(IWEL_WATER_INJECTOR):
well_state->type = WATER_INJECTOR;
break;
default:
util_abort("%s: what the ...\n",__func__);
}
}
return well_state;
}
}
void well_state_free( well_state_type * well ) {
vector_free( well->connections );
well_conn_free( well->wellhead );
free( well->name );
free( well );
}
/*****************************************************************/
int well_state_get_report_nr( const well_state_type * well_state ) {
return well_state->valid_from_report;
}
time_t well_state_get_sim_time( const well_state_type * well_state ) {
return well_state->valid_from_time;
}
int well_state_get_num_connections( const well_state_type * well_state ) {
return vector_get_size( well_state->connections );
}
well_conn_type * well_get_wellhead( const well_state_type * well_state ) {
return well_state->wellhead;
}
well_conn_type * well_state_iget_connection( const well_state_type * well_state , int index) {
return vector_iget( well_state->connections , index );
}
well_type_enum well_state_get_type( const well_state_type * well_state){
return well_state->type;
}
bool well_state_is_open( const well_state_type * well_state ) {
return well_state->open;
}
const char * well_state_get_name( const well_state_type * well_state ) {
return well_state->name;
}

View File

@@ -0,0 +1,71 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'well_state.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 __WELL_STATE_H__
#define __WELL_STATE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <time.h>
#include <ecl_file.h>
#include <ecl_intehead.h>
#include <well_conn.h>
#include <well_const.h>
#define GLOBAL_GRID_NAME "GLOBAL" // The name assigned to the global grid for name based lookup.
typedef struct well_state_struct well_state_type;
well_state_type * well_state_alloc( ecl_file_type * ecl_file , int report_step , int well_nr);
void well_state_free( well_state_type * well );
const char * well_state_get_name( const well_state_type * well );
int well_state_get_report_nr( const well_state_type * well_state );
time_t well_state_get_sim_time( const well_state_type * well_state );
well_conn_type * well_state_iget_connection( const well_state_type * well_state , int index);
well_type_enum well_state_get_type( const well_state_type * well_state);
bool well_state_is_open( const well_state_type * well_state );
const well_conn_type * well_state_iget_wellhead( const well_state_type * well_state , int grid_nr);
const well_conn_type * well_state_get_wellhead( const well_state_type * well_state , const char * grid_name);
const well_conn_type ** well_state_iget_lgr_connections(const well_state_type * well_state , int grid_nr , int branch_nr );
const well_conn_type ** well_state_get_lgr_connections(const well_state_type * well_state , const char * lgr_name , int branch_nr);
const well_conn_type ** well_state_get_connections(const well_state_type * well_state , int branch_nr );
int well_state_iget_num_lgr_connections(const well_state_type * well_state , int grid_nr , int branch_nr );
int well_state_get_num_lgr_connections(const well_state_type * well_state , const char * lgr_name , int branch_nr);
int well_state_get_num_connections(const well_state_type * well_state , int branch_nr );
int well_state_iget_lgr_num_branches( const well_state_type * well_state , int grid_nr);
int well_state_get_lgr_num_branches( const well_state_type * well_state , const char * lgr_name);
int well_state_get_num_branches(const well_state_type * well_state );
void well_state_summarize( const well_state_type * well_state , FILE * stream );
UTIL_IS_INSTANCE_HEADER( well_state );
#ifdef __cplusplus
}
#endif
#endif

48
ThirdParty/Ert/well/include/well_ts.h vendored Normal file
View File

@@ -0,0 +1,48 @@
/*
Copyright (C) 2011 Statoil ASA, Norway.
The file 'well_ts.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 __WELL_TS_H__
#define __WELL_TS_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <well_state.h>
typedef struct well_ts_struct well_ts_type;
void well_ts_free( well_ts_type * well_ts );
void well_ts_add_well( well_ts_type * well_ts , well_state_type * well_state );
well_ts_type * well_ts_alloc( const char * well_name );
void well_ts_free__( void * arg );
well_state_type * well_ts_get_state_from_sim_time( const well_ts_type * well_ts , time_t sim_time);
well_state_type * well_ts_get_state_from_report( const well_ts_type * well_ts , int report_nr);
well_state_type * well_ts_iget_state( const well_ts_type * well_ts , int index);
int well_ts_get_size( const well_ts_type * well_ts);
well_state_type * well_ts_get_first_state( const well_ts_type * well_ts);
well_state_type * well_ts_get_last_state( const well_ts_type * well_ts);
#ifdef __cplusplus
}
#endif
#endif

BIN
ThirdParty/Ert/well/lib/libwell.a vendored Normal file

Binary file not shown.