Example #1
0
matrix_type * matrix_alloc_shared(const matrix_type * src , int row , int column , int rows , int columns) {
  if (((row + rows) > src->rows) || ((column + columns) > src->columns))
    util_abort("%s: Invalid matrix subsection src:[%d,%d]  Offset:[%d,%d]  SubSize:[%d,%d] \n",
               __func__,
               src->rows , src->columns,
               row,column,
               rows,columns);
  
  {
    matrix_type * matrix = matrix_alloc_empty();
    
    matrix_init_header( matrix , rows , columns , src->row_stride , src->column_stride);
    matrix->data          = &src->data[ GET_INDEX(src , row , column) ];
    matrix->data_owner    = false;
    
    return matrix;
  }
}
Example #2
0
File: lsb.c Project: rolk/ert
int lsb_initialize( const lsb_type * lsb) {
    /*
      The environment variable LSF_ENVDIR must be set to point the
      directory containing LSF configuration information, the whole
      thing will crash and burn if this is not properly set.
    */
    printf("Calling initialize ... \n");
    if ( lsb->lsb_init(NULL) != 0 ) {
        fprintf(stderr,"LSF_ENVDIR: ");
        if (getenv("LSF_ENVDIR") != NULL)
            fprintf(stderr,"%s\n", getenv("LSF_ENVDIR"));
        else
            fprintf(stderr, "not set\n");

        util_abort("%s failed to initialize LSF environment : %s  \n",__func__ , lsb->sys_msg() );
    }
    return 0;
}
Example #3
0
void gen_data_export(const gen_data_type * gen_data , const char * full_path , gen_data_file_format_type export_type , fortio_type * fortio) {
  switch (export_type) {
  case(ASCII):
    gen_data_ecl_write_ASCII(gen_data , full_path , export_type);
    break;
  case(ASCII_TEMPLATE):
    gen_data_ecl_write_ASCII(gen_data , full_path , export_type);
    break;
  case(BINARY_DOUBLE):
    gen_data_ecl_write_binary(gen_data , full_path , ECL_DOUBLE);
    break;
  case(BINARY_FLOAT):
    gen_data_ecl_write_binary(gen_data , full_path , ECL_FLOAT);
    break;
  default:
    util_abort("%s: internal error - export type is not set.\n",__func__);
  }
}
void @TYPE@_vector_iset(@TYPE@_vector_type * vector , int index , @TYPE@ value) {
  @TYPE@_vector_assert_writable( vector );
  {
    if (index < 0)
      util_abort("%s: Sorry - can NOT set negative indices. called with index:%d \n",__func__ , index);
    {
      if (vector->alloc_size <= index)
        @TYPE@_vector_realloc_data__(vector , 2 * (index + 1));  /* Must have ( + 1) here to ensure we are not doing 2*0 */
      vector->data[index] = value;
      if (index >= vector->size) {
        int i;
        for (i=vector->size; i < index; i++)
          vector->data[i] = vector->default_value;
        vector->size = index + 1;
      }
    }
  }
}
Example #5
0
menu_item_type * menu_get_item(const menu_type * menu, char cmd) {
    int item_index = 0;
    menu_item_type * item = NULL;
    while (item_index < vector_get_size(menu->items)) {
        menu_item_type * current_item = vector_iget(menu->items , item_index);
        if (!current_item->separator || !current_item->helptext) {
            if (strchr(current_item->key_set , cmd) != NULL) {
                item = current_item;
                break;
            }
            item_index++;
        }
    }

    if (item == NULL)
        util_abort("%s: could not locate item with key: %c \n",__func__ , cmd);
    return item;
}
Example #6
0
static int file_map_iget_occurence( const file_map_type * file_map , int global_index) {
  const ecl_file_kw_type * file_kw = vector_iget_const( file_map->kw_list , global_index);
  const char * header              = ecl_file_kw_get_header( file_kw );
  const int_vector_type * index_vector = hash_get( file_map->kw_index , header );
  const int * index_data = int_vector_get_const_ptr( index_vector );
  
  int occurence = -1;
  {
    /* Manual reverse lookup. */
    int i;
    for (i=0; i < int_vector_size( index_vector ); i++)
      if (index_data[i] == global_index)
        occurence = i;
  }
  if (occurence < 0)
    util_abort("%s: internal error ... \n" , __func__);

  return occurence;
}
Example #7
0
enkf_config_node_type * ensemble_config_add_summary(ensemble_config_type * ensemble_config , const char * key , load_fail_type load_fail) {
  enkf_config_node_type * config_node = NULL;

  if (hash_has_key(ensemble_config->config_nodes, key)) {
    config_node = hash_get(ensemble_config->config_nodes, key);
    if (enkf_config_node_get_impl_type( config_node ) != SUMMARY) {
      util_abort("%s: ensemble key:%s already exists - but it is not of summary type\n",__func__ , key);
    }

    summary_config_type * summary_config = enkf_config_node_get_ref( config_node );
    summary_config_update_load_fail_mode( summary_config , load_fail );

  } else {
    config_node = enkf_config_node_alloc_summary( key , load_fail);
    ensemble_config_add_node(ensemble_config , config_node );
  }

  return config_node;
}
Example #8
0
File: fs_types.c Project: akva2/ert
const char * fs_types_get_driver_name(fs_driver_enum driver_type) {
  switch( driver_type ) {
  case(DRIVER_PARAMETER):
    return "PARAMETER";
    break;
  case(DRIVER_DYNAMIC_FORECAST):
    return "FORECAST";
    break;
  case(DRIVER_DYNAMIC_ANALYZED):
    return "ANALYZED";
    break;
  case(DRIVER_INDEX):
    return "INDEX";
    break;
  default:
    util_abort("%s: driver_id:%d not recognized. \n",__func__ , driver_type );
    return NULL;
  }
}
Example #9
0
subst_list_type * subst_list_alloc(const void * input_arg) {
  subst_list_type * subst_list = util_malloc(sizeof * subst_list );
  UTIL_TYPE_ID_INIT( subst_list , SUBST_LIST_TYPE_ID);
  subst_list->parent           = NULL;
  subst_list->func_pool        = NULL;
  subst_list->string_data      = vector_alloc_new();
  subst_list->func_data        = vector_alloc_new();

  if (input_arg != NULL) {
    if (subst_list_is_instance( input_arg )) 
      subst_list_set_parent( subst_list , input_arg );
    else if (subst_func_pool_is_instance( input_arg ))
      subst_list->func_pool = input_arg;
    else
      util_abort("%s: run_time cast failed - invalid type on input argument.\n",__func__);
  }
  
  return subst_list;
}
Example #10
0
const char * enkf_types_get_var_name(enkf_var_type var_type) {
  switch(var_type) {
  case(INVALID):
    return "INVALID";
    break;
  case PARAMETER:
    return "PARAMETER";
    break;
  case DYNAMIC_STATE:
    return "DYNAMIC_STATE";
    break;
  case DYNAMIC_RESULT:
    return "DYNAMIC_RESULT";
    break;
  default:
    util_abort("%s: internal error - unrecognized var type: %d - aborting \n",__func__ , var_type);
    return NULL;
  }
}
Example #11
0
static ecl_grav_survey_type * ecl_grav_survey_alloc_RPORV(ecl_grav_type * ecl_grav , 
                                                          const ecl_file_type * restart_file , 
                                                          const char * name ) {
  ecl_grav_survey_type * survey = ecl_grav_survey_alloc_empty( ecl_grav , name , GRAV_CALC_RPORV);
  if (ecl_file_has_kw( restart_file , RPORV_KW)) {
    ecl_kw_type * rporv_kw = ecl_file_iget_named_kw( restart_file , RPORV_KW , 0);
    int iactive;
    for (iactive = 0; iactive < ecl_kw_get_size( rporv_kw ); iactive++) 
      survey->porv[ iactive ] = ecl_kw_iget_as_double( rporv_kw , iactive );
  } else 
    util_abort("%s: restart file did not contain %s keyword??\n",__func__ , RPORV_KW);
  
  {
    const ecl_file_type * init_file = ecl_grav->init_file;
    ecl_grav_survey_assert_RPORV( survey , init_file );
    ecl_grav_survey_add_phases( ecl_grav , survey ,  restart_file , GRAV_CALC_RPORV);
  }
  return survey;
}
Example #12
0
static bool matrix_resize__(matrix_type * matrix , int rows , int columns , bool copy_content , bool safe_mode) {
  if (!matrix->data_owner)
    util_abort("%s: sorry - can not resize shared matrizes. \n",__func__);
  {
    bool resize_OK = true;

    if ((rows != matrix->rows) || (columns != matrix->columns)) {
      int copy_rows            = util_int_min( rows    , matrix->rows );
      int copy_columns         = util_int_min( columns , matrix->columns);
      matrix_type * copy_view  = NULL;
      matrix_type * copy       = NULL;

      if (copy_content) {
        copy_view = matrix_alloc_shared( matrix , 0 , 0 , copy_rows , copy_columns);         /* This is the part of the old matrix which should be copied over to the new. */
        copy      = matrix_alloc_copy__( copy_view , safe_mode );                            /* Now copy contains the part of the old matrix which should be copied over - with private storage. */
      }
      {
        int old_rows , old_columns, old_row_stride , old_column_stride;
        matrix_get_dims( matrix , &old_rows , &old_columns , &old_row_stride , &old_column_stride);        /* Storing the old header information - in case the realloc() fails. */

        matrix_init_header(matrix , rows , columns , 1 , rows);                                            /* Resetting the header for the matrix */
        matrix_realloc_data__(matrix , safe_mode);
        if (matrix->data != NULL) {  /* Realloc succeeded */
          if (copy_content) {
            matrix_type * target_view = matrix_alloc_shared(matrix , 0 , 0 , copy_rows , copy_columns);
            matrix_assign( target_view , copy);
            matrix_free( target_view );
          }
        } else {
          /* Failed to realloc new storage; RETURNING AN INVALID MATRIX */
          matrix_init_header(matrix , old_rows , old_columns , old_row_stride , old_column_stride);
          resize_OK = false;
        }
      }

      if (copy_content) {
        matrix_free(copy_view);
        matrix_free(copy);
      }
    }
    return resize_OK;
  }
}
Example #13
0
static void @TYPE@_vector_realloc_data__(@TYPE@_vector_type * vector , int new_alloc_size) {
  if (new_alloc_size != vector->alloc_size) {
    if (vector->data_owner) {
      if (new_alloc_size > 0) {
        int i;
        vector->data = util_realloc(vector->data , new_alloc_size * sizeof * vector->data );
        for (i=vector->alloc_size;  i < new_alloc_size; i++)
          vector->data[i] = vector->default_value;
      } else {
        if (vector->alloc_size > 0) {
          free(vector->data);
          vector->data = NULL;
        }
      }
      vector->alloc_size = new_alloc_size;
    } else
      util_abort("%s: tried to change the storage are for a shared data segment \n",__func__);
  }
}
Example #14
0
bool smspec_node_init_lgr( smspec_node_type * smspec_node ,
                           ecl_smspec_var_type var_type ,
                           const char * wgname  ,
                           const char * keyword ,
                           const char * unit    ,
                           const char * lgr ,
                           const char * key_join_string ,
                           int   lgr_i, int lgr_j , int lgr_k
                         ) {
    bool initOK = true;
    bool wgnameOK = true;
    if ((wgname != NULL) && (IS_DUMMY_WELL(wgname)))
        wgnameOK = false;

    smspec_node_common_init( smspec_node , var_type , keyword , unit );
    switch (var_type) {
    case(ECL_SMSPEC_LOCAL_WELL_VAR):
        if (wgnameOK) {
            smspec_node_set_wgname( smspec_node , wgname );
            smspec_node_set_lgr_name( smspec_node , lgr );
        } else
            initOK = false;
        break;
    case(ECL_SMSPEC_LOCAL_BLOCK_VAR):
        smspec_node_set_lgr_name( smspec_node , lgr );
        smspec_node_set_lgr_ijk( smspec_node , lgr_i, lgr_j , lgr_k );
        break;
    case(ECL_SMSPEC_LOCAL_COMPLETION_VAR):
        if (wgnameOK) {
            smspec_node_set_lgr_name( smspec_node , lgr );
            smspec_node_set_wgname( smspec_node , wgname );
            smspec_node_set_lgr_ijk( smspec_node , lgr_i, lgr_j , lgr_k );
        } else
            initOK = false;
        break;
    default:
        util_abort("%s: internal error:  in LGR function with  non-LGR keyword:%s \n",__func__ , keyword);
    }
    if (initOK)
        smspec_node_set_gen_keys( smspec_node , key_join_string );
    return initOK;
}
Example #15
0
static size_t buffer_fread__(buffer_type * buffer , void * target_ptr , size_t item_size , size_t items, bool abort_on_error) {
  size_t remaining_size  = buffer->content_size - buffer->pos;
  size_t remaining_items = remaining_size / item_size;
  size_t read_items      = util_size_t_min( items , remaining_items );
  size_t read_bytes      = read_items * item_size;
  
  memcpy( target_ptr , &buffer->data[buffer->pos] , read_bytes );
  buffer->pos += read_bytes;
  
  if (read_items < items) {
    /* The buffer was not large enough - what to do now???? */
    if (abort_on_error) 
      util_abort("%s: tried to read beyond the length of the buffer: Wanted:%ld Size:%ld \n",__func__ , items , read_items);
    else 
      /* OK we emulate fread() behaviour - setting errno to EOVERFLOW*/
      errno = ENOMEM;//EOVERFLOW;
  }
  
  return read_items;
}
Example #16
0
static char dgesvd_get_vector_job( dgesvd_vector_enum vector_job) {
  char job = 'X';
  switch (vector_job) {
  case(DGESVD_ALL):
    job = 'A';
    break;
  case(DGESVD_MIN_RETURN):
    job = 'S';
    break;
  case(DGESVD_MIN_OVERWRITE):
    job = 'O';
    break;
  case(DGESVD_NONE):
    job = 'N';
    break;
  default:
    util_abort("%s: internal error - unrecognized code:%d \n",vector_job);
  }
  return job;
}
Example #17
0
static void smspec_node_set_num( smspec_node_type * index , const int grid_dims[3] , int num) {
    if (num == SMSPEC_NUMS_INVALID)
        util_abort("%s: explicitly trying to set nums == SMSPEC_NUMS_INVALID - seems like a bug?!\n",__func__);

    index->num = num;
    if ((index->var_type == ECL_SMSPEC_COMPLETION_VAR) || (index->var_type == ECL_SMSPEC_BLOCK_VAR)) {
        int global_index = num - 1;
        index->ijk = util_calloc( 3 , sizeof * index->ijk );

        index->ijk[2] = global_index / ( grid_dims[0] * grid_dims[1] );
        global_index -= index->ijk[2] * (grid_dims[0] * grid_dims[1]);
        index->ijk[1] = global_index /  grid_dims[0] ;
        global_index -= index->ijk[1] * grid_dims[0];
        index->ijk[0] = global_index;

        index->ijk[0] += 1;
        index->ijk[1] += 1;
        index->ijk[2] += 1;
    }
}
Example #18
0
trans_func_type * trans_func_fscanf_alloc( FILE * stream ) {
  trans_func_type * trans_func;
  char            * func_name;

  func_name = util_fscanf_alloc_token(stream);
  if (func_name == NULL) {
    char * filename = "????";
#ifdef HAVE_FORK
      filename = util_alloc_filename_from_stream( stream );
#endif
    fprintf(stderr,"Problem at file:line: %s:%d \n", filename, util_get_current_linenr( stream ));
    util_abort("%s: could not locate name of transformation - aborting \n",__func__);
  }
  
  trans_func = trans_func_alloc( func_name );
  arg_pack_fscanf( trans_func->params , stream );
  
  free( func_name );
  return trans_func;
}
Example #19
0
double matrix_det3( const matrix_type * A) {
  if ((A->rows == 3) && (A->columns == 3)) {
    double a = A->data[GET_INDEX(A,0,0)];
    double b = A->data[GET_INDEX(A,0,1)];
    double c = A->data[GET_INDEX(A,0,2)];

    double d = A->data[GET_INDEX(A,1,0)];
    double e = A->data[GET_INDEX(A,1,1)];
    double f = A->data[GET_INDEX(A,1,2)];

    double g = A->data[GET_INDEX(A,2,0)];
    double h = A->data[GET_INDEX(A,2,1)];
    double i = A->data[GET_INDEX(A,2,2)];

    return a*e*i + b*f*g + c*d*h - c*e*g - b*d*i - a*f*h;
  } else {
    util_abort("%s: hardcoded for 3x3 matrices A is: %d x %d \n",__func__, A->rows , A->columns);
    return 0;
  }
}
Example #20
0
void thread_pool_restart( thread_pool_type * tp ) {
  if (tp->accepting_jobs) 
    util_abort("%s: fatal error - tried restart already running thread pool\n",__func__);
  {
    tp->join           = false;
    tp->queue_index    = 0;
    tp->queue_size     = 0;
    {
      int i;
      for (i=0; i < tp->max_running; i++) {
        tp->job_slots[i].run_count = 0;
        tp->job_slots[i].running   = false;
      }
    }
    
    /* Starting the dispatch thread. */
    pthread_create( &tp->dispatch_thread , NULL , thread_pool_main_loop , tp );
    tp->accepting_jobs = true;
  }
}
Example #21
0
bool field_config_is_valid( const field_config_type * field_config ) {
    bool valid = true;

    switch( field_config->type ) {
    case ECLIPSE_PARAMETER:
        if (field_config->export_format == UNDEFINED_FORMAT)
            valid = false;
        break;
    case ECLIPSE_RESTART:
        break;
    case GENERAL:
        if (field_config->export_format == UNDEFINED_FORMAT)
            valid = false;
        break;
    default:
        util_abort("%s: internal fuckup \n",__func__);
    }
    return valid;

}
Example #22
0
static void site_config_set_job_queue__( site_config_type * site_config , job_driver_type driver_type) {
  site_config->driver_type = driver_type;
  if (site_config->job_queue != NULL) {
    switch (driver_type) {
    case(LSF_DRIVER):
      site_config_select_LSF_job_queue( site_config );
      break;
    case(RSH_DRIVER):
      site_config_select_RSH_job_queue( site_config );
      break;
    case(LOCAL_DRIVER):
      site_config_select_LOCAL_job_queue( site_config );
      break;
    default:
      util_abort("%s: internal error \n",__func__);
    }
  }
  if (!site_config->user_mode)
    site_config->driver_type_site = driver_type;
}
Example #23
0
void gen_data_config_assert_size(gen_data_config_type * config , int data_size, int report_step) {
  pthread_mutex_lock( &config->update_lock );
  {
    int current_size = int_vector_safe_iget( config->data_size_vector , report_step );
    if (current_size < 0) {
      int_vector_iset( config->data_size_vector , report_step , data_size );
      current_size = data_size;
    }
    
    if (current_size != data_size) {
      util_abort("%s: Size mismatch when loading:%s from file - got %d elements - expected:%d [report_step:%d] \n",
                 __func__ , 
                 gen_data_config_get_key( config ),
                 data_size , 
                 current_size , 
                 report_step);
    }
  }
  pthread_mutex_unlock( &config->update_lock );
}
Example #24
0
File: enkf_fs.c Project: shulNN/ert
static void * enkf_fs_select_driver(enkf_fs_type * fs , enkf_var_type var_type, state_enum state , const char * key) {
  void * driver = NULL;
  switch (var_type) {
  case(PARAMETER):
    driver = fs->parameter;
    break;
  case(DYNAMIC_RESULT):
    driver = select_dynamic_driver( fs , state );
    break;
  case(DYNAMIC_STATE):
    driver = select_dynamic_driver( fs , state );
    break;
  case(STATIC_STATE):
    driver = fs->eclipse_static;
    break;
  default:
    util_abort("%s: fatal internal error - could not determine enkf_fs driver for object:%s[integer type:%d] - aborting.\n",__func__, key , var_type);
  }
  return driver;
}
Example #25
0
File: enkf_fs.c Project: shulNN/ert
void enkf_fs_create_fs( const char * mount_point, fs_driver_impl driver_id , void * arg) {
  const int num_drivers = 32;
  FILE * stream = fs_driver_open_fstab( mount_point , true );
  if (stream != NULL) {
    fs_driver_init_fstab( stream, driver_id);
    {
      switch( driver_id ) {
      case( BLOCK_FS_DRIVER_ID ):
        enkf_fs_create_block_fs( stream , num_drivers , mount_point , arg );
        break;
      case( PLAIN_DRIVER_ID ):
        enkf_fs_create_plain_fs( stream , arg );
        break;
      default:
        util_abort("%s: Invalid driver_id value:%d \n",__func__ , driver_id );
      }
    }
    fclose( stream );
  }
}
Example #26
0
bool layer_trace_block_edge( const layer_type * layer , int start_i , int start_j , int value , struct_vector_type * corner_list , int_vector_type * cell_list) {
  int g = layer_get_global_cell_index( layer , start_i , start_j); 
  cell_type * cell = &layer->data[g];
  if ((cell->cell_value == value)) {
    int i = start_i;
    int j = start_j;
    
    if (layer_find_edge( layer , &i , &j , value)) {
      int_point2d_type start_corner;

      g = layer_get_global_cell_index( layer , i , j); 
      cell = &layer->data[g];

      start_corner.i = i;
      start_corner.j = j;
      struct_vector_reset( corner_list );
      int_vector_reset( cell_list );

      
      if (cell->edges[BOTTOM_EDGE] == value) {
        point_shift( &start_corner , 0 , 0 );
        layer_trace_block_edge__(layer , start_corner , i , j , value , BOTTOM_EDGE , corner_list , cell_list);
      } else if (cell->edges[RIGHT_EDGE] == value) {
        point_shift( &start_corner , 1 , 0 );
        layer_trace_block_edge__(layer , start_corner , i , j , value , RIGHT_EDGE , corner_list , cell_list);
      } else if (cell->edges[TOP_EDGE] == -value) {
        point_shift( &start_corner , 1 , 1 );
        layer_trace_block_edge__(layer , start_corner , i , j , value , TOP_EDGE , corner_list , cell_list);
      } else if (cell->edges[LEFT_EDGE] == -value) {
        point_shift( &start_corner , 0 , 1 );
        layer_trace_block_edge__(layer , start_corner , i  , j , value , LEFT_EDGE , corner_list , cell_list);
      } else
        util_abort("%s: what the f**k - internal error \n",__func__);
  
      int_vector_select_unique( cell_list );
      return true;
    }
  } 
  
  return false;
}
Example #27
0
bool ranking_table_fwrite_ranking( const ranking_table_type * ranking_table , const char * ranking_key, const char * filename ) {
  if (hash_has_key( ranking_table->ranking_table , ranking_key)) {
    void * ranking = hash_get( ranking_table->ranking_table , ranking_key );

    FILE * file = util_mkdir_fopen(filename, "w");

    if (data_ranking_is_instance( ranking )) {
      data_ranking_type * data_ranking = data_ranking_safe_cast( ranking );
      data_ranking_display( data_ranking , file );
    } else if (misfit_ranking_is_instance( ranking )) {
      misfit_ranking_type * misfit_ranking = misfit_ranking_safe_cast( ranking );
      misfit_ranking_display( misfit_ranking , file );
    } else
      util_abort("%s: internal error \n",__func__);

    util_fclose(file);

    return true;
  } else
    return false;
}
Example #28
0
enkf_config_node_type * ensemble_config_add_summary(ensemble_config_type * ensemble_config , const char * key , load_fail_type load_fail) {
  enkf_config_node_type * config_node = NULL;

  if (hash_has_key(ensemble_config->config_nodes, key)) {
    config_node = hash_get(ensemble_config->config_nodes, key);
    if (enkf_config_node_get_impl_type( config_node ) != SUMMARY)
      util_abort("%s: ensemble key:%s already exists - but it is not of summary type\n",__func__ , key);
    {
      summary_config_type * summary_config = enkf_config_node_get_ref( config_node );
      summary_config_update_load_fail_mode( summary_config , load_fail );
    }
  } else {
    if ((ensemble_config->refcase == NULL) || (ecl_sum_has_general_var( ensemble_config->refcase , key ))) {
      config_node = enkf_config_node_alloc_summary( key , load_fail);
      ensemble_config_add_node(ensemble_config , config_node );
    } else
      fprintf(stderr,"** warning: the refcase:%s does not contain the summary key:\"%s\" - will be ignored.\n", ecl_sum_get_case( ensemble_config->refcase ) , key);
  }

  return config_node;
}
Example #29
0
File: gen_kw.c Project: blattms/ert
bool gen_kw_initialize(gen_kw_type *gen_kw , int iens , const char * init_file , rng_type * rng ) {
  if (!init_file && !rng)
    util_abort("%s internal error: both init_file and rng are NULL", __func__); 
  
  bool ret = false; 
  
  if (init_file) 
    ret = gen_kw_fload(gen_kw , init_file );
  else {
    const double mean = 0.0; /* Mean and std are hardcoded - the variability should be in the transformation. */
    const double std  = 1.0; 
    const int    data_size = gen_kw_config_get_data_size( gen_kw->config );
    int i;
    
    for (i=0; i < data_size; i++) 
      gen_kw->data[i] = enkf_util_rand_normal(mean , std , rng);
   
    ret = true; 
  }
  return ret;
}
Example #30
0
/* Implements assignement: A = B */
void matrix_assign(matrix_type * A , const matrix_type * B) {
  if ((A->rows == B->rows) && (A->columns == B->columns)) {
    int i,j;

    if (A->row_stride == B->row_stride) {
      if (A->columns == A->row_stride)  /** Memory is just one continous block */
        memcpy( A->data , B->data , A->rows * A->columns * sizeof * A->data);
      else {
        /* Copying columns of data */
        for (j = 0; j < A->columns; j++)
          memcpy( &A->data[ GET_INDEX(A , 0 , j)] , &B->data[ GET_INDEX(B , 0 , j) ] , A->rows * sizeof * A->data);
      }
    } else {
      /* Copying element by element */
      for (j = 0; j < A->columns; j++)
        for (i=0; i < A->rows; i++)
          A->data[ GET_INDEX(A,i,j) ] = B->data[ GET_INDEX(B,i,j) ];
    }
  } else
    util_abort("%s: size mismatch A:[%d,%d]  B:[%d,%d] \n",__func__ , A->rows , A->columns , B->rows , B->columns);
}