Example #1
0
void ecl_rft_node_fwrite(const ecl_rft_node_type * rft_node, fortio_type * fortio, ert_ecl_unit_enum unit_set){
  ecl_rft_enum type = ecl_rft_node_get_type(rft_node);
  if (type != RFT)
    util_abort("%s: sorry - only writing of simple RFT is currently implemented",__func__);
  
  {
    ecl_kw_type * time = ecl_kw_alloc(TIME_KW, 1, ECL_FLOAT_TYPE);
    ecl_kw_iset_float(time, 0, ecl_rft_node_get_days(rft_node));
    ecl_kw_fwrite(time, fortio);
    ecl_kw_free(time);
  }

  {
    ecl_kw_type * datevalue = ecl_kw_alloc(DATE_KW, 3, ECL_INT_TYPE);
    time_t date = ecl_rft_node_get_date(rft_node);
    int day;
    int month;
    int year;
    ecl_util_set_date_values(date , &day , &month , &year);
    ecl_kw_iset_int(datevalue, 0, day);
    ecl_kw_iset_int(datevalue, 1, month);
    ecl_kw_iset_int(datevalue, 2, year);
    ecl_kw_fwrite(datevalue, fortio);
    ecl_kw_free(datevalue);
  }

  {
    ecl_kw_type * welletc = ecl_kw_alloc(WELLETC_KW, 16, ECL_CHAR_TYPE);
    ecl_rft_enum type = ecl_rft_node_get_type(rft_node);

    ecl_kw_iset_string8(welletc, 1, ecl_rft_node_get_well_name(rft_node));

    if(type == PLT) {
      ecl_kw_iset_string8(welletc, 5, "P");
    }else if(type == RFT){
      ecl_kw_iset_string8(welletc, 5, "R");
    }else if(type == SEGMENT){
      ecl_kw_iset_string8(welletc, 5, "S");
    }
    ecl_rft_node_fill_welletc(welletc, unit_set);
    ecl_kw_fwrite(welletc, fortio);
    ecl_kw_free(welletc);
  }

  {
    int size_cells = ecl_rft_node_get_size(rft_node);
    ecl_kw_type * conipos = ecl_kw_alloc(CONIPOS_KW, size_cells, ECL_INT_TYPE);
    ecl_kw_type * conjpos = ecl_kw_alloc(CONJPOS_KW, size_cells, ECL_INT_TYPE);
    ecl_kw_type * conkpos = ecl_kw_alloc(CONKPOS_KW, size_cells, ECL_INT_TYPE);
    ecl_kw_type * hostgrid = ecl_kw_alloc(HOSTGRID_KW, size_cells, ECL_CHAR_TYPE);
    ecl_kw_type * depth = ecl_kw_alloc(DEPTH_KW, size_cells, ECL_FLOAT_TYPE);
    ecl_kw_type * pressure = ecl_kw_alloc(PRESSURE_KW, size_cells, ECL_FLOAT_TYPE);
    ecl_kw_type * swat = ecl_kw_alloc(SWAT_KW, size_cells, ECL_FLOAT_TYPE);
    ecl_kw_type * sgas = ecl_kw_alloc(SGAS_KW, size_cells, ECL_FLOAT_TYPE);
    int i;

    for(i =0;i<size_cells;i++){
      const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , i);
      ecl_kw_iset_int(conipos, i, ecl_rft_cell_get_i(cell)+1);
      ecl_kw_iset_int(conjpos, i, ecl_rft_cell_get_j(cell)+1);
      ecl_kw_iset_int(conkpos, i, ecl_rft_cell_get_k(cell)+1);
      ecl_kw_iset_float(depth, i, ecl_rft_cell_get_depth(cell));
      ecl_kw_iset_float(pressure, i, ecl_rft_cell_get_pressure(cell));
      ecl_kw_iset_float(swat, i, ecl_rft_cell_get_swat(cell));
      ecl_kw_iset_float(sgas, i, ecl_rft_cell_get_sgas(cell));
    }
    ecl_kw_fwrite(conipos, fortio);
    ecl_kw_fwrite(conjpos, fortio);
    ecl_kw_fwrite(conkpos, fortio);
    ecl_kw_fwrite(hostgrid, fortio);
    ecl_kw_fwrite(depth, fortio);
    ecl_kw_fwrite(pressure, fortio);
    ecl_kw_fwrite(swat, fortio);
    ecl_kw_fwrite(sgas, fortio);

    ecl_kw_free(conipos);
    ecl_kw_free(conjpos);
    ecl_kw_free(conkpos);
    ecl_kw_free(hostgrid);
    ecl_kw_free(depth);
    ecl_kw_free(pressure);
    ecl_kw_free(swat);
    ecl_kw_free(sgas);
  }
}
Example #2
0
void test_rft_read_write(const char * rft_file){
    ecl_rft_file_type * rft = ecl_rft_file_alloc( rft_file );
    ecl_rft_node_type  ** nodes =(ecl_rft_node_type  **) malloc(sizeof(ecl_rft_node_type *) * 3);
    int size = ecl_rft_file_get_size(rft);
    for(int i =0;i<size;i++){
        const ecl_rft_node_type * rft_node = ecl_rft_file_iget_node(rft, i);
        nodes[i] =rft_node;
    }
    ecl_rft_node_type * old_node = ecl_rft_file_iget_node(rft, 0);
    ecl_rft_node_type * new_node = ecl_rft_node_alloc_new("DUMMY", "R", ecl_rft_node_get_date(old_node), ecl_rft_node_get_days(old_node));
    nodes[2]=new_node;
    test_work_area_type * work_area = test_work_area_alloc("RFT_RW");
    
    ecl_rft_file_update("eclipse.rft", nodes,3, ERT_ECL_METRIC_UNITS);
    test_work_area_free(work_area);
    free(nodes);
}