예제 #1
0
void test_create_invalid() {
  enkf_config_node_type * config_node = enkf_config_node_alloc_summary( "WWCT" , LOAD_FAIL_SILENT);
  enkf_plot_gen_kw_type * gen_kw = enkf_plot_gen_kw_alloc( config_node );

  test_assert_NULL( gen_kw );
  enkf_config_node_free( config_node );
}
예제 #2
0
파일: ecl_rsthead.c 프로젝트: Ensembles/ert
void test_file( const char * filename , int occurence , bool exists , const ecl_rsthead_type * true_header) {
  int report_step = ecl_util_filename_report_nr( filename );
  ecl_file_type * rst_file = ecl_file_open( filename , 0);
  ecl_file_enum file_type = ecl_util_get_file_type( filename , NULL , NULL );
  ecl_file_view_type * rst_view;
  ecl_rsthead_type * rst_head;

  if (file_type == ECL_RESTART_FILE)
    rst_view = ecl_file_get_global_view( rst_file );
  else
    rst_view = ecl_file_get_restart_view( rst_file , occurence , -1 , -1 , -1 );

  if (exists) {
    test_assert_not_NULL( rst_view );
    rst_head = ecl_rsthead_alloc( rst_view , report_step);
    test_assert_not_NULL( rst_head );

    if (occurence == 0) {
      ecl_rsthead_type * rst_head0 = ecl_rsthead_alloc( rst_view , report_step );

      test_assert_true( ecl_rsthead_equal( rst_head , rst_head0 ));
      ecl_rsthead_free( rst_head0 );
    }
    test_assert_true( ecl_rsthead_equal( rst_head , true_header ));

    ecl_rsthead_free( rst_head );
  } else
    test_assert_NULL( rst_view );

}
예제 #3
0
파일: ecl_file.c 프로젝트: Ensembles/ert
void test_truncated() {
  test_work_area_type * work_area = test_work_area_alloc("ecl_file_truncated" );
  {
    ecl_grid_type * grid = ecl_grid_alloc_rectangular(20,20,20,1,1,1,NULL);
    ecl_grid_fwrite_EGRID2( grid , "TEST.EGRID", ECL_METRIC_UNITS );
    ecl_grid_free( grid );
  }
  {
    ecl_file_type * ecl_file = ecl_file_open("TEST.EGRID" , 0 );
    test_assert_true( ecl_file_is_instance( ecl_file ) );
    ecl_file_close( ecl_file );
  }

  {
    offset_type file_size = util_file_size( "TEST.EGRID");
    FILE * stream = util_fopen("TEST.EGRID" , "r+");
    util_ftruncate( stream , file_size / 2 );
    fclose( stream );
  }
  {
    ecl_file_type * ecl_file = ecl_file_open("TEST.EGRID" , 0 );
    test_assert_NULL( ecl_file );
  }
  test_work_area_free( work_area );
}
예제 #4
0
void test_create_invalid( const ecl_grid_type * grid ) {
  ecl_kw_type * fault_blk_kw = ecl_kw_alloc("FAULTBLK" , ecl_grid_get_global_size( grid ) - 1, ECL_INT_TYPE );
  
  test_assert_NULL( fault_block_layer_alloc( grid , 7 ));
  
  ecl_kw_free( fault_blk_kw );
}
예제 #5
0
void test_write( const char * filename , bool path_exists) {
  fortio_type * fortio = fortio_open_writer( filename , false , ECL_ENDIAN_FLIP);
  if (path_exists) {
    test_assert_not_NULL( fortio );
    fortio_fclose( fortio );
  } else
    test_assert_NULL( fortio );
}
예제 #6
0
void test_time_before() {
  ecl_sum_type * ecl_sum = test_alloc_ecl_sum();
  time_t_vector_type * t = time_t_vector_alloc( 0 , 0 );
  time_t_vector_append(t, util_make_date_utc( 1,1,2009 ));
  test_assert_NULL( ecl_sum_alloc_resample(ecl_sum, "kk", t) );
  time_t_vector_free(t);
  ecl_sum_free(ecl_sum);
}
예제 #7
0
int main(int argc , char ** argv) {
  test_install_SIGNALS();

  double * rseg_data = util_calloc( 100 , sizeof * rseg_data );
  well_segment_collection_type * sc = well_segment_collection_alloc();
  test_assert_not_NULL( sc );
  test_assert_int_equal( well_segment_collection_get_size( sc ) , 0 );

  {
    int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
    int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
    well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data);
    
    well_segment_collection_add( sc , ws );
    test_assert_int_equal( well_segment_collection_get_size( sc ) , 1);
    test_assert_ptr_equal( well_segment_collection_iget( sc , 0 ) , ws );
    
    test_assert_false( well_segment_collection_has_segment( sc , 451 ));
    test_assert_true( well_segment_collection_has_segment( sc , 89 ));
    test_assert_ptr_equal( well_segment_collection_get( sc , 89 ) , ws );
  }

  {
    int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
    int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
    well_segment_type * ws = well_segment_alloc(90 , outlet_segment_id , branch_nr , rseg_data);
    
    well_segment_collection_add( sc , ws );
    test_assert_int_equal( well_segment_collection_get_size( sc ) , 2);
    test_assert_ptr_equal( well_segment_collection_iget( sc , 1 ) , ws );
    
    test_assert_false( well_segment_collection_has_segment( sc , 451 ));
    test_assert_true( well_segment_collection_has_segment( sc , 89 ));
    test_assert_true( well_segment_collection_has_segment( sc , 90 ));
    test_assert_ptr_equal( well_segment_collection_get( sc , 90 ) , ws );
    test_assert_NULL( well_segment_collection_get( sc , 76 ));
  }

  {
    int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
    int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
    well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data);
    
    well_segment_collection_add( sc , ws );
    test_assert_int_equal( well_segment_collection_get_size( sc ) , 2);
    test_assert_ptr_equal( well_segment_collection_iget( sc , 0 ) , ws );
    
    test_assert_false( well_segment_collection_has_segment( sc , 451 ));
    test_assert_true( well_segment_collection_has_segment( sc , 89 ));
    test_assert_ptr_equal( well_segment_collection_get( sc , 89 ) , ws );
  }
  
  free( rseg_data );
  well_segment_collection_free( sc );
  
  exit(0);
}
예제 #8
0
int main(int argc , char ** argv) {
  int lgr_nr = 77;
  nnc_info_type * nnc_info = nnc_info_alloc(lgr_nr);   

  test_assert_int_equal( 0 , nnc_info_get_total_size( nnc_info ));
  test_assert_int_equal( lgr_nr , nnc_info_get_lgr_nr(  nnc_info ));
  test_assert_true(nnc_info_is_instance(nnc_info));
  test_assert_not_NULL(nnc_info); 
  
  nnc_info_add_nnc(nnc_info, lgr_nr, 110 , 0);
  test_assert_int_equal( 1, nnc_info_get_total_size( nnc_info ));
  
  nnc_info_add_nnc(nnc_info, 1, 110 , 1);
  nnc_info_add_nnc(nnc_info, 1, 111 , 2);
  test_assert_int_equal( 3, nnc_info_get_total_size( nnc_info ));
  

  nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1);
  const int_vector_type * nnc_cells = nnc_info_get_grid_index_list(nnc_info, 1); 
  test_assert_int_equal(int_vector_size(nnc_cells), 2); 
  test_assert_ptr_equal( nnc_cells , nnc_vector_get_grid_index_list( nnc_vector ));


  nnc_vector_type * nnc_vector_null  = nnc_info_get_vector( nnc_info , 2);
  const int_vector_type * nnc_cells_null = nnc_info_get_grid_index_list(nnc_info, 2); 
  test_assert_NULL(nnc_cells_null); 
  test_assert_NULL(nnc_vector_null); 
  
  nnc_vector_type * nnc_vector_self  = nnc_info_get_self_vector( nnc_info );
  const nnc_vector_type * nnc_vector_77  = nnc_info_get_vector( nnc_info , lgr_nr );
  test_assert_ptr_equal( nnc_vector_77 , nnc_vector_self );

  const int_vector_type * nnc_cells_77 = nnc_info_get_grid_index_list(nnc_info, lgr_nr); 
  const int_vector_type * nnc_cells_self = nnc_info_get_self_grid_index_list(nnc_info); 
  test_assert_ptr_equal( nnc_cells_77 , nnc_cells_self );


  test_assert_int_equal( 2 , nnc_info_get_size( nnc_info ));
  test_assert_ptr_equal( nnc_info_get_vector( nnc_info , 1 ) , nnc_info_iget_vector( nnc_info , 1 ));
  nnc_info_free(nnc_info);
  

  exit(0);
}
예제 #9
0
void test_create_invalid(const char * config_file) {
  char * cwd0 = util_alloc_cwd();
  ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT" , config_file , NULL );
  test_assert_true( ert_test_context_is_instance( test_context ));
  test_assert_NULL( ert_test_context_get_main( test_context ));
  {
    char * cwd1 = util_alloc_cwd();
    test_assert_string_equal(cwd1 , cwd0);
    free( cwd1 );
  }
  free( cwd0 );
  ert_test_context_free( test_context );
}
예제 #10
0
void test_create_data() {
  matrix_type * PC = matrix_alloc( 3 , 10);
  matrix_type * PC_obs = matrix_alloc( 3 , 1 );
  double_vector_type * singular_values = double_vector_alloc(3 , 1);
  {
    pca_plot_data_type * data = pca_plot_data_alloc("KEY" , PC , PC_obs , singular_values);
    test_assert_true( pca_plot_data_is_instance( data ));
    test_assert_int_equal( 3 , pca_plot_data_get_size( data ));
    test_assert_int_equal( 10 , pca_plot_data_get_ens_size( data ));
    test_assert_string_equal( "KEY" , pca_plot_data_get_name( data ));
    pca_plot_data_free( data );
  }
  matrix_resize( PC , 4 , 10 , false);
  test_assert_NULL( pca_plot_data_alloc( "KEY" , PC , PC_obs , singular_values));

  matrix_resize( PC_obs , 3 , 2 , false);
  test_assert_NULL( pca_plot_data_alloc( "KEY" , PC , PC_obs , singular_values));

  double_vector_free( singular_values );
  matrix_free( PC );
  matrix_free( PC_obs );
}
예제 #11
0
void test_truncated(const char * filename , offset_type truncate_size) {
  {
    FILE * stream = util_fopen(filename , "r+");
    util_ftruncate( stream , truncate_size);
    fclose( stream );
  }
  {
    fortio_type * fortio = fortio_open_reader( filename , false , true );
    ecl_kw_type * kw2 = ecl_kw_fread_alloc( fortio );
    test_assert_NULL( kw2 );
    fortio_fclose(fortio);
  }
}
예제 #12
0
void test_current_module_options() {
  analysis_config_type * ac = create_analysis_config( );
  test_assert_NULL( analysis_config_get_active_module( ac ));
  analysis_config_load_internal_module(ac , "STD_ENKF" , "std_enkf_symbol_table");

  test_assert_false( analysis_config_get_module_option( ac , ANALYSIS_SCALE_DATA));
  test_assert_true(analysis_config_select_module(ac , "STD_ENKF"));
  test_assert_false( analysis_config_select_module(ac , "DOES_NOT_EXIST"));

  test_assert_true( analysis_module_is_instance( analysis_config_get_active_module( ac )));
  test_assert_true( analysis_config_get_module_option( ac , ANALYSIS_SCALE_DATA));
  test_assert_false( analysis_config_get_module_option( ac , ANALYSIS_ITERABLE));
  analysis_config_free( ac );
}
예제 #13
0
void test_create( const ecl_grid_type * grid , const ecl_kw_type * fault_block_kw) {
  test_assert_NULL( fault_block_layer_alloc( grid ,  -1 ));
  test_assert_NULL( fault_block_layer_alloc( grid ,  ecl_grid_get_nz( grid )));
  
  { 
    int k;
    for (k = 0; k < ecl_grid_get_nz( grid ); k++) {
      fault_block_layer_type * layer = fault_block_layer_alloc( grid , k);
      test_assert_true( fault_block_layer_is_instance( layer ));
      
      fault_block_layer_scan_kw( layer , fault_block_kw);
      {
        int max_block_id = fault_block_layer_get_max_id( layer ); 
        int block_id;

        for (block_id = 0; block_id <= max_block_id; block_id++) {
          if (fault_block_layer_has_block( layer , block_id)) {
            fault_block_type * block = fault_block_layer_get_block( layer , block_id );
            fault_block_get_xc( block );
            fault_block_get_yc( block );
          }
        }
      }
      
      {
        int index;
        for (index = 0; index < fault_block_layer_get_size( layer ); index++) {
          fault_block_type * block = fault_block_layer_iget_block( layer , index );
          fault_block_get_xc( block );
          fault_block_get_yc( block );
        }
      }
      
      fault_block_layer_free( layer );
    }
  }
}
예제 #14
0
void test_filename() {
  const char * src_file1 = "/some/very/long/path/file1.txt";
  const char * src_file2 = "relative/path/file2";
  const char * src_file3 = "/tmp";

  char * file1 = util_split_alloc_filename( src_file1 );
  char * file2 = util_split_alloc_filename( src_file2 );
  char * file3 = util_split_alloc_filename( src_file3 );

  test_assert_string_equal( "file1.txt" , file1);
  test_assert_string_equal( "file2" , file2);
  test_assert_NULL( file3 );
  free( file1 );
  free( file2 );

}
예제 #15
0
void test_with_prefix() {
  test_work_area_type * work_area = test_work_area_alloc( "with-prefix" );

  util_make_path( "PREFIX" );
  {
    test_work_area_type * sub_area = test_work_area_alloc_relative("PREFIX" , "sub-work" );
    test_assert_true( test_work_area_is_instance( sub_area ));
    test_work_area_free( sub_area );
    test_assert_true( util_entry_exists("PREFIX/sub-work"));
  }
  {
    test_work_area_type * sub_area = test_work_area_alloc_relative("DoesNotExist" , "sub-work" );
    test_assert_NULL( sub_area );
  }
  test_work_area_free( work_area );
}
예제 #16
0
void test_dirname() {
  const char * src_file1 = "/some/very/long/path/file.txt";
  const char * src_file2 = "relative/path/file.txt";
  const char * src_file3 = "file.txt";

  char * path1 = util_split_alloc_dirname( src_file1 );
  char * path2 = util_split_alloc_dirname( src_file2 );
  char * path3 = util_split_alloc_dirname( src_file3 );

  test_assert_string_equal( "/some/very/long/path" , path1);
  test_assert_string_equal( "relative/path" , path2);
  test_assert_NULL( path3 );

  free( path1 );
  free( path2 );
}
예제 #17
0
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);
}
예제 #18
0
파일: ecl_file.c 프로젝트: Ensembles/ert
void test_close_stream1(const char * src_file , const char * target_file ) {
  util_copy_file( src_file , target_file );

  ecl_file_type * ecl_file = ecl_file_open( target_file , ECL_FILE_CLOSE_STREAM );
  ecl_kw_type * kw0 = ecl_file_iget_kw( ecl_file , 0 );
  ecl_kw_type * kw1 = ecl_file_iget_kw( ecl_file , 1 );
  unlink( target_file );
  ecl_kw_type * kw1b = ecl_file_iget_kw( ecl_file , 1 );

  test_assert_not_NULL( kw0 );
  test_assert_not_NULL( kw1 );
  test_assert_ptr_equal( kw1 , kw1b );

  ecl_kw_type * kw2 = ecl_file_iget_kw( ecl_file , 2 );
  test_assert_NULL( kw2 );

  test_assert_false( ecl_file_writable( ecl_file ));

  ecl_file_close( ecl_file );

}
예제 #19
0
int main(int argc , char ** argv) {
  const char * Xfile = argv[1];
  ecl_file_type * rst_file = ecl_file_open( Xfile , 0 );
  ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file );
  const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 );
  const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 );
  const ecl_kw_type * rseg_kw = ecl_file_iget_named_kw( rst_file , RSEG_KW , 0 );
  const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );

  test_install_SIGNALS();
  test_assert_not_NULL( rst_file );
  test_assert_not_NULL( rst_head );
  {
    int well_nr;
    for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) {
      well_conn_collection_type * connections = well_conn_collection_alloc();
      well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , well_nr , rst_head);
      {
        well_segment_collection_type * segments = well_segment_collection_alloc();

        if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_kw , rst_head )) {
          well_branch_collection_type * branches = well_branch_collection_alloc();

          test_assert_true( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head));
          well_segment_collection_link( segments );
          {
            int is;
            for (is=0; is < well_segment_collection_get_size( segments ); is++) {
              well_segment_type * segment = well_segment_collection_iget( segments , is );

              if (well_segment_nearest_wellhead( segment ))
                test_assert_NULL( well_segment_get_outlet( segment ));
              else
                test_assert_not_NULL( well_segment_get_outlet( segment ));

              test_assert_ptr_not_equal( segment , well_segment_get_outlet( segment ));
            }
          }

          well_segment_collection_add_branches( segments , branches );
          {
            int ib;
            for (ib = 0; ib < well_branch_collection_get_size( branches ); ib++) {
              const well_segment_type * start_segment = well_branch_collection_iget_start_segment( branches , ib );
              const well_segment_type * segment = start_segment;

              printf("Branch %d/%d " , ib , well_branch_collection_get_size( branches ) );
              while (segment) {
                printf("[%p]%d -> \n",segment , well_segment_get_id( segment ));
                segment = well_segment_get_outlet( segment );
              }
              printf("\n");
              sleep(1);
            }
          }
          well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections );
          well_branch_collection_free( branches );
        } else
          test_assert_false( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head ));

        well_segment_collection_free( segments );
      }
      well_conn_collection_free( connections );
    }
  }

  ecl_file_close( rst_file );
  ecl_rsthead_free( rst_head );
  exit(0);
}
예제 #20
0
void test_create_invalid() {
  test_assert_NULL( matrix_alloc(0, 100));
  test_assert_NULL( matrix_alloc(100, 0));
  test_assert_NULL( matrix_alloc(0, 0));
  test_assert_NULL( matrix_alloc(-1, -1));
}
예제 #21
0
void test_create_invalid_data(ecl_grid_type * grid) {
  void * data_config = NULL;
  test_assert_NULL(block_obs_alloc( "ObsKey" , data_config , grid ));
}
예제 #22
0
int main( int argc , char ** argv) {
  const char * exjob_file = "job";
  const char * bin_path = argv[1];
  const char * internal_workflow = argv[2];
  test_work_area_type * work_area = test_work_area_alloc( "job_workflow_test" );

  signal(SIGSEGV , util_abort_signal);    
  create_exjob( exjob_file , bin_path );
  {
    
    int int_value = rand();
    int read_value = 100;
    workflow_joblist_type * joblist = workflow_joblist_alloc();
    
    if (!workflow_joblist_add_job_from_file( joblist , "CREATE_FILE" , exjob_file)) {
      remove( exjob_file );
      {
        config_type * job_config = workflow_joblist_get_job_config( joblist );
        config_fprintf_errors( job_config , true , stdout );
      }
      test_error_exit("Loading job CREATE_FILE failed\n");
    } else
      remove( exjob_file );
    
    if (!workflow_joblist_add_job_from_file( joblist , "READ_FILE"   , internal_workflow))
      test_error_exit("Loading job READ_FILE failed\n");
    
    {
      config_type * workflow_compiler = workflow_joblist_get_compiler( joblist );
      if (config_get_schema_size( workflow_compiler ) != 2)
        test_error_exit("Config compiler - wrong size \n");
    }
    
    
    {
      const char * workflow_file = "workflow";
      const char * tmp_file = "fileX";
      workflow_type * workflow;
      
      create_workflow( workflow_file , tmp_file , int_value );
      workflow = workflow_alloc(workflow_file , joblist );
      unlink( workflow_file );
      
      {
        bool runOK;
        runOK = workflow_run( workflow , &read_value , false , NULL);
        if (runOK) {
          if (int_value != read_value)
            test_error_exit("Wrong numeric value read back \n");

          test_assert_int_equal( workflow_get_stack_size( workflow ) , 2 );
          test_assert_not_NULL( workflow_iget_stack_ptr( workflow , 0 ) );
          test_assert_NULL( workflow_iget_stack_ptr( workflow , 1 ) );
          
          {
            void * return_value = workflow_iget_stack_ptr( workflow , 0 );
            int return_int = *((int *) return_value);
            if (int_value != return_int)
              test_error_exit("Wrong numeric value read back \n");
            
            test_assert_not_NULL( workflow_pop_stack( workflow ));
            test_assert_NULL( workflow_pop_stack( workflow ));
            test_assert_int_equal( workflow_get_stack_size( workflow ) , 0 );
            
            free( return_value );
          }

          
          
        } else {
          config_type * workflow_compiler = workflow_joblist_get_compiler( joblist );
          config_fprintf_errors( workflow_compiler , true ,stdout);
          unlink( tmp_file );
          test_error_exit("Workflow did not run\n");
        }
        unlink( tmp_file );
      }
    }
    workflow_joblist_free( joblist );
    
  }
  {
    workflow_joblist_type * joblist = workflow_joblist_alloc();
    const char * workflow_file = "workflow";
    const char * tmp_file = "fileX";
    int read_value;
    int int_value = 100;
    workflow_type * workflow;
    
    create_workflow( workflow_file , tmp_file , int_value );
    workflow = workflow_alloc(workflow_file , joblist );
    unlink( workflow_file );

    test_assert_false( workflow_run( workflow , &read_value , false , NULL) );
    test_assert_int_equal( workflow_get_stack_size( workflow ) , 0 );
  }
  test_work_area_free( work_area );
  exit(0);
}
예제 #23
0
void test_get_tran(const char * name) {
  char * grid_file_name = ecl_util_alloc_filename(NULL , name , ECL_EGRID_FILE , false  , -1);
  char * init_file_name = ecl_util_alloc_filename(NULL , name , ECL_INIT_FILE , false  , -1);
  ecl_grid_type * grid = ecl_grid_alloc( grid_file_name );
  ecl_file_type * grid_file = ecl_file_open( grid_file_name , 0 );
  ecl_file_type * init_file = ecl_file_open( init_file_name , 0 );

  /* Get global */
  {
    ecl_kw_type * tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , 0 );
    test_assert_true( ecl_kw_is_instance( tran_kw ));
    test_assert_double_equal( 0.85582769 , ecl_kw_iget_as_double( tran_kw , 0 ));
    test_assert_double_equal( 0.24635284 , ecl_kw_iget_as_double( tran_kw , 7184 ));
  }
  test_assert_NULL( ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , 0 ));
  test_assert_NULL( ecl_nnc_export_get_tran_kw( init_file , TRANLL_KW , 0 ));
  test_assert_NULL( ecl_nnc_export_get_tran_kw( init_file , "INVALID" , 1));


  /* Get lgr_nr: 48 */
  {
    ecl_kw_type * tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , 48 );
    test_assert_true( ecl_kw_is_instance( tran_kw ));
    test_assert_int_equal( 0 , ecl_kw_get_size( tran_kw ));

    tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , 48 );
    test_assert_int_equal( 282 , ecl_kw_get_size( tran_kw ));
    test_assert_double_equal( 22.922695 , ecl_kw_iget_as_double( tran_kw , 0 ));
    test_assert_double_equal( 16.720325 , ecl_kw_iget_as_double( tran_kw , 281 ));
  }

  /* Get lgr_nr: 99 */
  {
    ecl_kw_type * tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , 99 );
    test_assert_true( ecl_kw_is_instance( tran_kw ));
    test_assert_int_equal( 0 , ecl_kw_get_size( tran_kw ));

    tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , 99 );
    test_assert_int_equal( 693 , ecl_kw_get_size( tran_kw ));
    test_assert_double_equal( 0.25534782 , ecl_kw_iget_as_double( tran_kw , 0 ));
    test_assert_double_equal( 0.12677453 , ecl_kw_iget_as_double( tran_kw ,  692 ));
  }


  /* Get lgr_nr: 10 */
  {
    ecl_kw_type * tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , 10 );
    test_assert_true( ecl_kw_is_instance( tran_kw ));
    test_assert_int_equal( 0 , ecl_kw_get_size( tran_kw ));

    tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , 10 );
    test_assert_int_equal( 260 , ecl_kw_get_size( tran_kw ));
    test_assert_double_equal( 0.87355447 , ecl_kw_iget_as_double( tran_kw , 0 ));
    test_assert_double_equal( 26.921568 , ecl_kw_iget_as_double( tran_kw ,  259 ));
  }


  /* Get lgr_nr: 110 */
  {
    ecl_kw_type * tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANNNC_KW , 110 );
    test_assert_true( ecl_kw_is_instance( tran_kw ));
    test_assert_int_equal( 0 , ecl_kw_get_size( tran_kw ));

    tran_kw = ecl_nnc_export_get_tran_kw( init_file , TRANGL_KW , 110 );
    test_assert_int_equal( 208 , ecl_kw_get_size( tran_kw ));
    test_assert_double_equal( 17.287283 , ecl_kw_iget_as_double( tran_kw , 0 ));
    test_assert_double_equal( 569.26312 , ecl_kw_iget_as_double( tran_kw ,  207 ));
  }


  free( init_file_name );
  free(grid_file_name);
  ecl_grid_free( grid );
  ecl_file_close( grid_file );
  ecl_file_close( init_file );
}
예제 #24
0
int main(int argc , char ** argv) {
  const char * Xfile = argv[1];
  ecl_file_type * rst_file = ecl_file_open( Xfile , 0 );
  ecl_file_view_type * rst_view = ecl_file_get_active_view( rst_file );
  ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_view , ecl_util_filename_report_nr(Xfile));
  const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 );
  const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 );
  well_rseg_loader_type * rseg_loader = well_rseg_loader_alloc(rst_view);
  const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
  const ecl_kw_type * scon_kw = NULL;
  const ecl_kw_type * xcon_kw = NULL;

  test_install_SIGNALS();
  test_assert_not_NULL( rst_file );
  test_assert_not_NULL( rst_head );
  { 
    int well_nr;
    for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) {
      well_conn_collection_type * connections = well_conn_collection_alloc();
      well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , scon_kw, xcon_kw, well_nr , rst_head);
      {
        well_segment_collection_type * segments = well_segment_collection_alloc();
        bool load_segment_information = true;
        bool is_MSW_well = false;
                
        if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_loader , rst_head , load_segment_information , &is_MSW_well)) {
          well_branch_collection_type * branches = well_branch_collection_alloc();
          
          test_assert_true( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head));
          well_segment_collection_link( segments );
          {
            int is;
            for (is=0; is < well_segment_collection_get_size( segments ); is++) {
              well_segment_type * segment = well_segment_collection_iget( segments , is );
              
              if (well_segment_nearest_wellhead( segment )) 
                test_assert_NULL( well_segment_get_outlet( segment ));
              else
                test_assert_not_NULL( well_segment_get_outlet( segment ));

              test_assert_int_not_equal( well_segment_get_id( segment ) , well_segment_get_outlet_id( segment ));
              test_assert_ptr_not_equal( segment , well_segment_get_outlet( segment ));
            }
          }
          well_segment_collection_add_branches( segments , branches );
          {
            int ib;
            for (ib = 0; ib < well_branch_collection_get_size( branches ); ib++) {
              const well_segment_type * start_segment = well_branch_collection_iget_start_segment( branches , ib );
              const well_segment_type * segment = start_segment;
              
              printf("Branch %d " , ib );
              while (segment) {
                printf("%d -> ",well_segment_get_id( segment ));
                segment = well_segment_get_outlet( segment );
              }
              printf(" X \n");
            } 
          }
          well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections ); 
          well_branch_collection_free( branches );
        } else
          test_assert_false( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head ));

        well_segment_collection_free( segments );
      }
      well_conn_collection_free( connections );
    }
  }

  ecl_file_close( rst_file );
  ecl_rsthead_free( rst_head );
  exit(0);
}
예제 #25
0
void test_not_existing_read() {
  fortio_type * fortio = fortio_open_reader( "/does/not/exist" , false , ECL_ENDIAN_FLIP);
  test_assert_NULL( fortio );
}
예제 #26
0
void test_input() {
  test_work_area_type * work_area = test_work_area_alloc( NULL );
  test_assert_NULL( work_area );
}
예제 #27
0
void test_path_does_not_exist() {
  job_queue_node_type * node = job_queue_node_alloc_simple( "name" , "does-not-exist" , "/bin/ls" , 0 , NULL);
  test_assert_NULL( node );
}
예제 #28
0
int main(int argc , char ** argv) {
  int i = 10;
  int j = 5;
  int k = 16;
  double CF = 0;
  bool open = true;
  test_install_SIGNALS();

  {
    well_conn_dir_enum dir = well_conn_dirX;
    well_conn_type * conn = well_conn_alloc(i,j,k,CF,dir,open);
    well_conn_type * conn2 = well_conn_alloc(i,j,k,CF,dir,open);
    well_conn_type * conn3 = well_conn_alloc(i,j,k+1,CF,dir,open);
    test_assert_not_NULL( conn );
    test_assert_true( well_conn_is_instance( conn ));
    test_assert_int_equal( i , well_conn_get_i( conn ));
    test_assert_int_equal( j , well_conn_get_j( conn ));
    test_assert_int_equal( k , well_conn_get_k( conn ));
    test_assert_int_equal( dir , well_conn_get_dir( conn ));
    test_assert_bool_equal( open , well_conn_open( conn ));
    test_assert_false( well_conn_MSW( conn ));
    test_assert_true( well_conn_matrix_connection( conn ));
    test_assert_true( well_conn_equal( conn , conn2 ));
    test_assert_false( well_conn_equal( conn , conn3 ));
    test_assert_double_equal( CF , well_conn_get_connection_factor( conn ));
    well_conn_free( conn3 );
    well_conn_free( conn2 );
    well_conn_free( conn );
  }

  {
    well_conn_dir_enum dir = well_conn_fracX;
    well_conn_type * conn = well_conn_alloc(i,j,k,CF,dir,open);
    test_assert_NULL( conn );
  }


  {
    well_conn_dir_enum dir = well_conn_fracX;
    well_conn_type * conn = well_conn_alloc_fracture(i,j,k,CF,dir,open);
    test_assert_not_NULL( conn );
    test_assert_int_equal( i , well_conn_get_i( conn ));
    test_assert_int_equal( j , well_conn_get_j( conn ));
    test_assert_int_equal( k , well_conn_get_k( conn ));
    test_assert_bool_equal( open , well_conn_open( conn ));
    test_assert_int_equal( dir , well_conn_get_dir( conn ));
    test_assert_false( well_conn_MSW( conn ));
    test_assert_false( well_conn_matrix_connection( conn ));
    test_assert_true( well_conn_fracture_connection( conn ));
    well_conn_free( conn );
  }


  {
    well_conn_dir_enum dir = well_conn_dirX;
    well_conn_type * conn = well_conn_alloc_fracture(i,j,k,CF,dir,open);
    test_assert_not_NULL( conn );
    well_conn_free( conn );
  }

  {
    int segment = 16;
    well_conn_dir_enum dir = well_conn_dirX;
    well_conn_type * conn = well_conn_alloc_MSW(i,j,k,CF,dir,open,segment);
    test_assert_not_NULL( conn );
    test_assert_int_equal( i , well_conn_get_i( conn ));
    test_assert_int_equal( j , well_conn_get_j( conn ));
    test_assert_int_equal( k , well_conn_get_k( conn ));
    test_assert_int_equal( segment , well_conn_get_segment_id( conn ));
    test_assert_bool_equal( open , well_conn_open( conn ));
    test_assert_int_equal( dir , well_conn_get_dir( conn ));
    test_assert_true( well_conn_MSW( conn ));
    test_assert_true( well_conn_matrix_connection( conn ));
    well_conn_free( conn );
  }


  {
    int segment = 16;
    well_conn_dir_enum dir = well_conn_fracX;
    well_conn_type * conn = well_conn_alloc_fracture_MSW(i,j,k,CF,dir,open,segment);
    test_assert_not_NULL( conn );
    test_assert_int_equal( i , well_conn_get_i( conn ));
    test_assert_int_equal( j , well_conn_get_j( conn ));
    test_assert_int_equal( k , well_conn_get_k( conn ));
    test_assert_int_equal( segment , well_conn_get_segment_id( conn ));
    test_assert_bool_equal( open , well_conn_open( conn ));
    test_assert_int_equal( dir , well_conn_get_dir( conn ));
    test_assert_true( well_conn_MSW( conn ));
    test_assert_false( well_conn_matrix_connection( conn ));
    well_conn_free( conn );
  }

  test_conn_rate();

}