Пример #1
0
int main( int argc , char ** argv) {
  const char * egrid_file = argv[1];

  ecl_grid_type * grid = ecl_grid_alloc( egrid_file );
  ecl_file_type * gfile = ecl_file_open( egrid_file , 0 );
  const ecl_kw_type * nnc1_kw = ecl_file_iget_named_kw( gfile , "NNC1" ,0 );
  const ecl_kw_type * nnc2_kw = ecl_file_iget_named_kw( gfile , "NNC2" ,0 );
  const int_vector_type * index_list = ecl_grid_get_nnc_index_list( grid );
  
  {
    int_vector_type * nnc = int_vector_alloc(0,0);
    
    int_vector_set_many( nnc , 0 , ecl_kw_get_ptr( nnc1_kw ) , ecl_kw_get_size( nnc1_kw ));
    int_vector_append_many( nnc , ecl_kw_get_ptr( nnc2_kw ) , ecl_kw_get_size( nnc2_kw ));
    int_vector_select_unique( nnc );
    test_assert_int_equal( int_vector_size( index_list ) , int_vector_size( nnc ));
    
    {
      int i;
      for (i=0; i < int_vector_size( nnc ); i++)
        test_assert_int_equal( int_vector_iget( nnc , i ) - 1 , int_vector_iget(index_list , i ));
    }
    int_vector_free( nnc );
  }
  
  ecl_file_close( gfile );
  ecl_grid_free( grid );

  exit(0);
}
Пример #2
0
void int_vector_append_many(int_vector_type * vector , const int * data , int length) {
  int_vector_set_many( vector , int_vector_size( vector ) , data , length);
}
Пример #3
0
void test_export_runpath_files(const char * config_file,
                               const char * config_file_iterations,
                               const char * job_file_export_runpath) {

  stringlist_type * args = stringlist_alloc_new();
  const char * job_name  = "export_job";

  ert_test_context_type * test_context_iterations = create_context( config_file_iterations, "enkf_workflow_job_test_export_runpath_iter" );

  {
    int_vector_type * iens_values = int_vector_alloc(5,0);
    const int iens[5] = {0,1,2,3,4};
    int_vector_set_many(iens_values, 0, &iens[0], 5);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);
  }
  {
    stringlist_append_copy( args, "0-2"); //realization range

    int_vector_type * iens_values = int_vector_alloc(3,0);
    const int iens[] = {0,1,2};
    int_vector_set_many(iens_values, 0, &iens[0], 3);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }
  {
    stringlist_append_copy( args, "0,3-5"); //realization range

    int_vector_type * iens_values = int_vector_alloc(4,0);
    const int iens[] = {0,3,4,5};
    int_vector_set_many(iens_values, 0, &iens[0], 4);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }
  {
    stringlist_append_copy( args, "1-2"); //realization range
    stringlist_append_copy( args, "|");   //delimiter
    stringlist_append_copy( args, "1-3"); //iteration range

    int_vector_type * iens_values = int_vector_alloc(2,0);
    int iens[] = {1,2};
    int_vector_set_many(iens_values, 0, &iens[0], 2);
    int_vector_type * iter_values = int_vector_alloc(3,0);
    int iter[] = {1,2,3};
    int_vector_set_many(iter_values, 0, &iter[0], 3);

    test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }
  {
    stringlist_append_copy( args, "*");   //realization range
    stringlist_append_copy( args, "|");   //delimiter
    stringlist_append_copy( args, "*");   //iteration range

    int_vector_type * iens_values = int_vector_alloc(5,0);
    int iens[] = {0,1,2,3,4};
    int_vector_set_many(iens_values, 0, &iens[0], 5);
    int_vector_type * iter_values = int_vector_alloc(4,0);
    int iter[] = {0,1,2,3};
    int_vector_set_many(iter_values, 0, &iter[0], 4);

    test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }

  ert_test_context_free(test_context_iterations);
  ert_test_context_type * test_context = create_context( config_file, "enkf_workflow_job_test_export_runpath" );

  {
    int_vector_type * iens_values = int_vector_alloc(1,0);
    int_vector_init_range(iens_values, 0, 25, 1);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }
  {
    stringlist_append_copy( args, "1-3"); //realization range

    int_vector_type * iens_values = int_vector_alloc(3,0);
    int iens[] = {1,2,3};
    int_vector_set_many(iens_values, 0, &iens[0], 3);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }
  {
    stringlist_append_copy( args, "1,2"); //realization range
    stringlist_append_copy( args, "|");   //delimiter
    stringlist_append_copy( args, "1-3"); //iteration range

    int_vector_type * iens_values = int_vector_alloc(2,0);
    int iens[] = {1,2};
    int_vector_set_many(iens_values, 0, &iens[0], 2);
    int_vector_type * iter_values = int_vector_alloc(1,0);

    test_export_runpath_file(test_context, job_name, job_file_export_runpath, args, iens_values, iter_values);

    int_vector_free(iens_values);
    int_vector_free(iter_values);

    stringlist_clear(args);
  }


  ert_test_context_free(test_context);


  stringlist_free( args );
}