Skip to content

Commit

Permalink
Multiple ecl_x.c files converted to ecl_x.cpp.
Browse files Browse the repository at this point in the history
ecl_file_kw, ecl_file_view -> CPP.

ecl_grav, ecl_grav_calc -> CPP.

ecl_grid -> CPP.

...

ecl_grid: added source files to header.

ecl_grav.h: set to __cplusplus.

ecl_grid_cache, ecl_grid_dims -> CPP.

ecl_io_config, ecl_kw, ecl_kw_functions -> CPP.

ecl_kw_grdecl, ecl_nnc_data, ecl_nnc_export -> CPP.

ecl_kw.h: added more functions from source files.

ecl_io_config.h set in extern 'c' mode.

ecl_nnc_geometry, ecl_region, ecl_rft_cell -> CPP.

ecl_rft_file -> CPP, ecl_nnc_geometry.cpp: appveyor fix.

ecl_rft_node, ecl_rst_file, ecl_rsthead -> CPP.

ecl_smspec, ecl_subsidece, ecl_sum -> CPP.

...
  • Loading branch information
Steinar Foss committed Apr 24, 2018
1 parent fed0710 commit 4ff7f76
Show file tree
Hide file tree
Showing 36 changed files with 329 additions and 280 deletions.
50 changes: 25 additions & 25 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,42 +95,42 @@ add_library(ecl util/rng.cpp
util/test_util.cpp
${opt_srcs}

ecl/ecl_rsthead.c
ecl/ecl_rsthead.cpp
ecl/ecl_sum_tstep.c
ecl/ecl_rst_file.c
ecl/ecl_rst_file.cpp
ecl/ecl_init_file.c
ecl/ecl_grid_cache.c
ecl/ecl_grid_cache.cpp
ecl/smspec_node.c
ecl/ecl_kw_grdecl.c
ecl/ecl_file_kw.c
ecl/ecl_file_view.c
ecl/ecl_grav.c
ecl/ecl_grav_calc.c
ecl/ecl_smspec.c
ecl/ecl_kw_grdecl.cpp
ecl/ecl_file_kw.cpp
ecl/ecl_file_view.cpp
ecl/ecl_grav.cpp
ecl/ecl_grav_calc.cpp
ecl/ecl_smspec.cpp
ecl/ecl_sum_data.c
ecl/ecl_util.c
ecl/ecl_kw.c
ecl/ecl_sum.c
ecl/ecl_kw.cpp
ecl/ecl_sum.cpp
ecl/ecl_sum_vector.c
ecl/fortio.c
ecl/ecl_rft_file.c
ecl/ecl_rft_node.c
ecl/ecl_rft_cell.c
ecl/ecl_grid.c
ecl/ecl_coarse_cell.c
ecl/ecl_box.c
ecl/ecl_io_config.c
ecl/ecl_file.c
ecl/ecl_region.c
ecl/ecl_subsidence.c
ecl/ecl_grid_dims.c
ecl/ecl_rft_file.cpp
ecl/ecl_rft_node.cpp
ecl/ecl_rft_cell.cpp
ecl/ecl_grid.cpp
ecl/ecl_coarse_cell.cpp
ecl/ecl_box.cpp
ecl/ecl_io_config.cpp
ecl/ecl_file.cpp
ecl/ecl_region.cpp
ecl/ecl_subsidence.cpp
ecl/ecl_grid_dims.cpp
ecl/grid_dims.c
ecl/nnc_info.c
ecl/ecl_grav_common.c
ecl/nnc_vector.c
ecl/ecl_nnc_export.c
ecl/ecl_nnc_data.c
ecl/ecl_nnc_geometry.c
ecl/ecl_nnc_export.cpp
ecl/ecl_nnc_data.cpp
ecl/ecl_nnc_geometry.cpp
ecl/layer.c
ecl/fault_block.c
ecl/fault_block_layer.c
Expand Down
8 changes: 4 additions & 4 deletions lib/ecl/ecl_box.c → lib/ecl/ecl_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ UTIL_SAFE_CAST_FUNCTION( ecl_box , ECL_BOX_TYPE_ID)
*/

ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int __i1,int __i2 , int __j1 , int __j2 , int __k1, int __k2) {
ecl_box_type * ecl_box = util_malloc(sizeof * ecl_box );
ecl_box_type * ecl_box = (ecl_box_type *)util_malloc(sizeof * ecl_box );
UTIL_TYPE_ID_INIT( ecl_box , ECL_BOX_TYPE_ID);
ecl_box->parent_grid = ecl_grid;
/* Properties of the parent grid. */
Expand Down Expand Up @@ -102,8 +102,8 @@ ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int __i1,int __i2
int global_counter = 0;
int i,j,k;
ecl_box->active_size = 0;
ecl_box->active_list = util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->active_list );
ecl_box->global_list = util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->global_list );
ecl_box->active_list = (int*)util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->active_list );
ecl_box->global_list = (int*)util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->global_list );
for (k=k1; k <= k2; k++)
for (j=j1; j <= j2; j++)
for (i=i1; i <= i2; i++) {
Expand All @@ -121,7 +121,7 @@ ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int __i1,int __i2
}
}

ecl_box->active_list = util_realloc( ecl_box->active_list , ecl_box->active_size * sizeof * ecl_box->active_list );
ecl_box->active_list = (int*)util_realloc( ecl_box->active_list , ecl_box->active_size * sizeof * ecl_box->active_list );
}
}
return ecl_box;
Expand Down
2 changes: 1 addition & 1 deletion lib/ecl/ecl_coarse_cell.c → lib/ecl/ecl_coarse_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void ecl_coarse_cell_assert( ecl_coarse_cell_type * coarse_cell ) {

ecl_coarse_cell_type * ecl_coarse_cell_alloc() {
const int LARGE = 1 << 30;
ecl_coarse_cell_type * coarse_cell = util_malloc( sizeof * coarse_cell );
ecl_coarse_cell_type * coarse_cell = (ecl_coarse_cell_type *) util_malloc( sizeof * coarse_cell );
UTIL_TYPE_ID_INIT( coarse_cell , ECL_COARSE_CELL_TYPE_ID );

coarse_cell->ijk[0] = LARGE;
Expand Down
5 changes: 2 additions & 3 deletions lib/ecl/ecl_file.c → lib/ecl/ecl_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_file , ECL_FILE_ID)


ecl_file_type * ecl_file_alloc_empty( int flags ) {
ecl_file_type * ecl_file = util_malloc( sizeof * ecl_file );
ecl_file_type * ecl_file = (ecl_file_type *)util_malloc( sizeof * ecl_file );
UTIL_TYPE_ID_INIT(ecl_file , ECL_FILE_ID);
ecl_file->map_stack = vector_alloc_new();
ecl_file->inv_view = inv_map_alloc( );
Expand Down Expand Up @@ -800,7 +800,6 @@ ecl_version_enum ecl_file_get_ecl_version( const ecl_file_type * file ) {
return FRONTSIM;

util_abort("%s: Simulator version value:%d not recognized \n",__func__ , int_value );
return -1;
}

/*
Expand Down Expand Up @@ -887,7 +886,7 @@ void ecl_file_push_block( ecl_file_type * ecl_file ) {
}

void ecl_file_pop_block( ecl_file_type * ecl_file ) {
ecl_file->active_view = vector_pop_back( ecl_file->map_stack );
ecl_file->active_view = (ecl_file_view_type *)vector_pop_back( ecl_file->map_stack );
}


Expand Down
8 changes: 4 additions & 4 deletions lib/ecl/ecl_file_kw.c → lib/ecl/ecl_file_kw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct ecl_file_kw_struct {
/*****************************************************************/

inv_map_type * inv_map_alloc() {
inv_map_type * map = util_malloc( sizeof * map );
inv_map_type * map = (inv_map_type *)util_malloc( sizeof * map );
map->file_kw_ptr = size_t_vector_alloc( 0 , 0 );
map->ecl_kw_ptr = size_t_vector_alloc( 0 , 0 );
map->sorted = false;
Expand Down Expand Up @@ -137,7 +137,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_file_kw , ECL_FILE_KW_TYPE_ID )


ecl_file_kw_type * ecl_file_kw_alloc0( const char * header , ecl_data_type data_type , int size , offset_type offset) {
ecl_file_kw_type * file_kw = util_malloc( sizeof * file_kw );
ecl_file_kw_type * file_kw = (ecl_file_kw_type *)util_malloc( sizeof * file_kw );
UTIL_TYPE_ID_INIT( file_kw , ECL_FILE_KW_TYPE_ID );

file_kw->header = util_alloc_string_copy( header );
Expand Down Expand Up @@ -370,7 +370,7 @@ ecl_file_kw_type ** ecl_file_kw_fread_alloc_multiple( FILE * stream , int num) {

size_t file_kw_size = ECL_STRING8_LENGTH + 2 * sizeof(int) + sizeof(offset_type) + sizeof(size_t);
size_t buffer_size = num * file_kw_size;
char * buffer = util_malloc( buffer_size * sizeof * buffer );
char * buffer = (char*)util_malloc( buffer_size * sizeof * buffer );
size_t num_read = fread( buffer, 1 , buffer_size , stream);

if (num_read != buffer_size) {
Expand All @@ -379,7 +379,7 @@ ecl_file_kw_type ** ecl_file_kw_fread_alloc_multiple( FILE * stream , int num) {
}

{
ecl_file_kw_type ** kw_list = util_malloc( num * sizeof * kw_list );
ecl_file_kw_type ** kw_list = (ecl_file_kw_type **)util_malloc( num * sizeof * kw_list );
for (int ikw = 0; ikw < num; ikw++) {
int buffer_offset = ikw * file_kw_size;
char header[ECL_STRING8_LENGTH + 1];
Expand Down
34 changes: 17 additions & 17 deletions lib/ecl/ecl_file_view.c → lib/ecl/ecl_file_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const char * ecl_file_view_get_src_file( const ecl_file_view_type * file_view )


ecl_file_view_type * ecl_file_view_alloc( fortio_type * fortio , int * flags , inv_map_type * inv_map , bool owner ) {
ecl_file_view_type * ecl_file_view = util_malloc( sizeof * ecl_file_view );
ecl_file_view_type * ecl_file_view = (ecl_file_view_type*)util_malloc( sizeof * ecl_file_view );
ecl_file_view->kw_list = vector_alloc_new();
ecl_file_view->kw_index = hash_alloc();
ecl_file_view->distinct_kw = stringlist_alloc_new();
Expand All @@ -84,7 +84,7 @@ ecl_file_view_type * ecl_file_view_alloc( fortio_type * fortio , int * flags , i
}

int ecl_file_view_get_global_index( const ecl_file_view_type * ecl_file_view , const char * kw , int ith) {
const int_vector_type * index_vector = hash_get(ecl_file_view->kw_index , kw);
const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw);
int global_index = int_vector_iget( index_vector , ith);
return global_index;
}
Expand All @@ -106,7 +106,7 @@ void ecl_file_view_make_index( ecl_file_view_type * ecl_file_view ) {
{
int i;
for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) {
const ecl_file_kw_type * file_kw = vector_iget_const( ecl_file_view->kw_list , i);
const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i);
const char * header = ecl_file_kw_get_header( file_kw );
if ( !hash_has_key( ecl_file_view->kw_index , header )) {
int_vector_type * index_vector = int_vector_alloc( 0 , -1 );
Expand All @@ -115,7 +115,7 @@ void ecl_file_view_make_index( ecl_file_view_type * ecl_file_view ) {
}

{
int_vector_type * index_vector = hash_get( ecl_file_view->kw_index , header);
int_vector_type * index_vector = (int_vector_type*)hash_get( ecl_file_view->kw_index , header);
int_vector_append( index_vector , i);
}
}
Expand All @@ -128,7 +128,7 @@ bool ecl_file_view_has_kw( const ecl_file_view_type * ecl_file_view, const char


ecl_file_kw_type * ecl_file_view_iget_file_kw( const ecl_file_view_type * ecl_file_view , int global_index) {
ecl_file_kw_type * file_kw = vector_iget( ecl_file_view->kw_list , global_index);
ecl_file_kw_type * file_kw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , global_index);
return file_kw;
}

Expand Down Expand Up @@ -185,7 +185,7 @@ void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, cons
int ecl_file_view_find_kw_value( const ecl_file_view_type * ecl_file_view , const char * kw , const void * value) {
int global_index = -1;
if ( ecl_file_view_has_kw( ecl_file_view , kw)) {
const int_vector_type * index_list = hash_get( ecl_file_view->kw_index , kw );
const int_vector_type * index_list = (const int_vector_type*)hash_get( ecl_file_view->kw_index , kw );
int index = 0;
while (index < int_vector_size( index_list )) {
const ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( index_list , index ));
Expand Down Expand Up @@ -247,7 +247,7 @@ int ecl_file_view_iget_named_size( const ecl_file_view_type * ecl_file_view , co
void ecl_file_view_replace_kw( ecl_file_view_type * ecl_file_view , ecl_kw_type * old_kw , ecl_kw_type * new_kw , bool insert_copy) {
int index = 0;
while (index < vector_get_size( ecl_file_view->kw_list )) {
ecl_file_kw_type * ikw = vector_iget( ecl_file_view->kw_list , index );
ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index );
if (ecl_file_kw_ptr_eq( ikw , old_kw)) {
/*
Found it; observe that the vector_iset() function will
Expand All @@ -274,7 +274,7 @@ bool ecl_file_view_load_all( ecl_file_view_type * ecl_file_view ) {
if (fortio_assert_stream_open( ecl_file_view->fortio )) {
int index;
for (index = 0; index < vector_get_size( ecl_file_view->kw_list); index++) {
ecl_file_kw_type * ikw = vector_iget( ecl_file_view->kw_list , index );
ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index );
ecl_file_kw_get_kw( ikw , ecl_file_view->fortio , ecl_file_view->inv_map);
}
loadOK = true;
Expand Down Expand Up @@ -314,7 +314,7 @@ void ecl_file_view_free__( void * arg ) {

int ecl_file_view_get_num_named_kw(const ecl_file_view_type * ecl_file_view , const char * kw) {
if (hash_has_key(ecl_file_view->kw_index , kw)) {
const int_vector_type * index_vector = hash_get(ecl_file_view->kw_index , kw);
const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw);
return int_vector_size( index_vector );
} else
return 0;
Expand All @@ -332,9 +332,9 @@ void ecl_file_view_fwrite( const ecl_file_view_type * ecl_file_view , fortio_typ


int ecl_file_view_iget_occurence( const ecl_file_view_type * ecl_file_view , int global_index) {
const ecl_file_kw_type * file_kw = vector_iget_const( ecl_file_view->kw_list , global_index);
const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , global_index);
const char * header = ecl_file_kw_get_header( file_kw );
const int_vector_type * index_vector = hash_get( ecl_file_view->kw_index , header );
const int_vector_type * index_vector = (const int_vector_type*)hash_get( ecl_file_view->kw_index , header );
const int * index_data = int_vector_get_const_ptr( index_vector );

int occurence = -1;
Expand All @@ -354,7 +354,7 @@ int ecl_file_view_iget_occurence( const ecl_file_view_type * ecl_file_view , int
void ecl_file_view_fprintf_kw_list(const ecl_file_view_type * ecl_file_view , FILE * stream) {
int i;
for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) {
const ecl_file_kw_type * file_kw = vector_iget_const( ecl_file_view->kw_list , i );
const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i );
char * type_name = ecl_type_alloc_name(ecl_file_kw_get_data_type(file_kw));
fprintf(stream , "%-8s %7d:%s\n",
ecl_file_kw_get_header( file_kw ) ,
Expand All @@ -376,7 +376,7 @@ ecl_file_view_type * ecl_file_view_alloc_blockview2(const ecl_file_view_type * e
kw_index = ecl_file_view_get_global_index( ecl_file_view , start_kw , occurence );

{
ecl_file_kw_type * file_kw = vector_iget( ecl_file_view->kw_list , kw_index );
ecl_file_kw_type * file_kw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , kw_index );
while (true) {
ecl_file_view_add_kw( block_map , file_kw );

Expand All @@ -385,7 +385,7 @@ ecl_file_view_type * ecl_file_view_alloc_blockview2(const ecl_file_view_type * e
break;
else {
if (end_kw) {
file_kw = vector_iget(ecl_file_view->kw_list , kw_index);
file_kw = (ecl_file_kw_type*)vector_iget(ecl_file_view->kw_list , kw_index);
if (strcmp( end_kw , ecl_file_kw_get_header( file_kw )) == 0)
break;
}
Expand Down Expand Up @@ -589,7 +589,7 @@ double ecl_file_view_iget_restart_sim_days(const ecl_file_view_type * ecl_file_v
int ecl_file_view_find_sim_time(const ecl_file_view_type * ecl_file_view , time_t sim_time) {
int seqnum_index = -1;
if ( ecl_file_view_has_kw( ecl_file_view , INTEHEAD_KW)) {
const int_vector_type * intehead_index_list = hash_get( ecl_file_view->kw_index , INTEHEAD_KW );
const int_vector_type * intehead_index_list = (const int_vector_type *)hash_get( ecl_file_view->kw_index , INTEHEAD_KW );
int index = 0;
while (index < int_vector_size( intehead_index_list )) {
const ecl_kw_type * intehead_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( intehead_index_list , index ));
Expand Down Expand Up @@ -807,10 +807,10 @@ ecl_file_view_type * ecl_file_view_fread_alloc( fortio_type * fortio , int * fla


ecl_file_transaction_type * ecl_file_view_start_transaction(ecl_file_view_type * file_view) {
ecl_file_transaction_type * t = util_malloc(sizeof * t);
ecl_file_transaction_type * t = (ecl_file_transaction_type *)util_malloc(sizeof * t);
int size = ecl_file_view_get_size(file_view);
t->file_view = file_view;
t->ref_count = util_malloc( size * sizeof * t->ref_count );
t->ref_count = (int*)util_malloc( size * sizeof * t->ref_count );
for (int i = 0; i < size; i++) {
ecl_file_kw_type * file_kw = ecl_file_view_iget_file_kw(file_view, i);
ecl_file_kw_start_transaction(file_kw, &t->ref_count[i]);
Expand Down
Loading

0 comments on commit 4ff7f76

Please sign in to comment.