int main(int argc , char ** argv) { int i; ecl_kw_type * ecl_kw = ecl_kw_alloc("HEAD" , 10 , ECL_INT_TYPE); for (i=0; i < 10; i++) ecl_kw_iset_int(ecl_kw , i , i ); { test_work_area_type * work_area = test_work_area_alloc("ecl_kw_grdecl" , true); FILE * stream = util_fopen( "FILE.grdecl" , "w"); ecl_kw_fprintf_grdecl(ecl_kw , stream ); fclose(stream); stream = util_fopen( "FILE.grdecl" , "r"); { ecl_kw_type * ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD" , 10 , ECL_INT_TYPE); test_assert_not_NULL( ecl_kw2 ); test_assert_true( ecl_kw_equal( ecl_kw , ecl_kw2)); ecl_kw_free( ecl_kw2 ); } fclose( stream ); stream = util_fopen( "FILE.grdecl" , "w"); ecl_kw_fprintf_grdecl__(ecl_kw , "HEAD1234" , stream ); fclose( stream ); stream = util_fopen( "FILE.grdecl" , "r"); { ecl_kw_type * ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD" , 10 , ECL_INT_TYPE); test_assert_NULL( ecl_kw2 ); ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD1234" , 10 , ECL_INT_TYPE); test_assert_not_NULL( ecl_kw2 ); test_assert_string_equal( ecl_kw_get_header( ecl_kw2 ) , "HEAD1234" ); test_assert_true( ecl_kw_content_equal( ecl_kw , ecl_kw2 )); ecl_kw_free( ecl_kw2 ); } fclose( stream ); test_work_area_free( work_area ); } ecl_kw_free( ecl_kw ); exit(0); }
void test_kw_io_charlength() { test_work_area_type * work_area = test_work_area_alloc("ecl_kw_io_charlength"); { const char * KW0 = "QWERTYUI"; const char * KW1 = "ABCDEFGHIJTTTTTTTTTTTTTTTTTTTTTTABCDEFGHIJKLMNOP"; ecl_kw_type * ecl_kw_out0 = ecl_kw_alloc(KW0 , 5, ECL_FLOAT); ecl_kw_type * ecl_kw_out1 = ecl_kw_alloc(KW1 , 5, ECL_FLOAT); for (int i=0; i < ecl_kw_get_size( ecl_kw_out1); i++) { ecl_kw_iset_float( ecl_kw_out0 , i , i*1.5 ); ecl_kw_iset_float( ecl_kw_out1 , i , i*1.5 ); } { fortio_type * f = fortio_open_writer( "TEST1" , false, ECL_ENDIAN_FLIP ); test_assert_true( ecl_kw_fwrite( ecl_kw_out0, f )); test_assert_false(ecl_kw_fwrite( ecl_kw_out1, f )); fortio_fclose( f ); } { test_assert_false( util_file_exists( "TEST1")); } { FILE * file = util_fopen("TEST2", "w"); ecl_kw_fprintf_grdecl(ecl_kw_out1 , file); fclose(file); } { FILE * file = util_fopen("TEST2", "r"); ecl_kw_type * ecl_kw_in = ecl_kw_fscanf_alloc_grdecl( file , KW1 , -1 , ECL_FLOAT); test_assert_string_equal(KW1, ecl_kw_get_header(ecl_kw_in) ); test_assert_int_equal(5, ecl_kw_get_size( ecl_kw_in) ); test_assert_double_equal(ecl_kw_iget_as_double(ecl_kw_in, 0), 0.0); test_assert_double_equal(ecl_kw_iget_as_double(ecl_kw_in, 4), 6.0); fclose(file); } ecl_kw_free( ecl_kw_out0 ); ecl_kw_free( ecl_kw_out1 ); } test_work_area_free( work_area ); }
int main(int argc , char ** argv) { const char * grid_file = argv[1]; const char * fault_blk_file = argv[2]; ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_file ); ecl_kw_type * fault_blk_kw; { FILE * stream = util_fopen( fault_blk_file , "r"); fault_blk_kw = ecl_kw_fscanf_alloc_grdecl( stream , "FAULTBLK" , ecl_grid_get_global_size( ecl_grid ) , ECL_INT); fclose( stream ); } test_create( ecl_grid , fault_blk_kw ); ecl_grid_free( ecl_grid ); ecl_kw_free( fault_blk_kw ); exit(0); }