Пример #1
0
static void * gravity_response_mt( void * arg ) {
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  vector_type * grav_stations          = arg_pack_iget_ptr( arg_pack , 0 );
  const ecl_grid_type * ecl_grid       = arg_pack_iget_ptr( arg_pack , 1 );
  const ecl_file_type * init_file      = arg_pack_iget_ptr( arg_pack , 2 );
  ecl_file_type ** restart_files       = arg_pack_iget_ptr( arg_pack , 3 );
  int station1                         = arg_pack_iget_int( arg_pack , 4 );
  int station2                         = arg_pack_iget_int( arg_pack , 5 );
  int model_phases                     = arg_pack_iget_int( arg_pack , 6 );
  int file_phases                      = arg_pack_iget_int( arg_pack , 7 );
  
  int station_nr;
  for (station_nr = station1; station_nr < station2; station_nr++) {
    grav_station_type * gs = vector_iget( grav_stations , station_nr );
    
    gs->grav_diff = gravity_response( ecl_grid , 
                                      init_file , 
                                      restart_files[0] , 
                                      restart_files[1] , 
                                      gs , 
                                      model_phases , 
                                      file_phases);
  }
  return NULL;
}
Пример #2
0
static void * enkf_main_initialize_from_scratch_mt(void * void_arg) {
    arg_pack_type * arg_pack           = arg_pack_safe_cast( void_arg );
    enkf_main_type * enkf_main         = arg_pack_iget_ptr( arg_pack , 0);
    const stringlist_type * param_list = arg_pack_iget_const_ptr( arg_pack , 1 );
    int iens                          = arg_pack_iget_int( arg_pack , 2 );
    init_mode_type init_mode           = arg_pack_iget_int( arg_pack , 3 );
    enkf_state_type * state = enkf_main_iget_state( enkf_main , iens);
    enkf_state_initialize( state , enkf_main_get_fs( enkf_main ) , param_list , init_mode);
    return NULL;
}
Пример #3
0
void * add_pathlist( void * arg ) {
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  runpath_list_type * list = arg_pack_iget_ptr( arg_pack , 0 );
  int offset = arg_pack_iget_int( arg_pack , 1 );
  int bs = arg_pack_iget_int( arg_pack , 2 );
  
  int i;
  for (i=0; i < bs; i++) 
    runpath_list_add( list , i + offset , 0,  "Path" , "Basename");

  return NULL;
}
Пример #4
0
static void * matrix_inplace_matmul_mt__(void * arg) {

  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  int row_offset         = arg_pack_iget_int( arg_pack , 0 );
  int rows               = arg_pack_iget_int( arg_pack , 1 );
  matrix_type * A        = arg_pack_iget_ptr( arg_pack , 2 );
  const matrix_type * B  = arg_pack_iget_const_ptr( arg_pack , 3 );

  matrix_type * A_view = matrix_alloc_shared( A , row_offset , 0 , rows , matrix_get_columns( A ));
  matrix_inplace_matmul( A_view , B );
  matrix_free( A_view );
  return NULL;
}
Пример #5
0
static void * job_queue_run_EXIT_callback( void * arg ) {
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  job_queue_type * job_queue = arg_pack_iget_ptr( arg_pack , 0 );
  int queue_index = arg_pack_iget_int( arg_pack , 1 );

  job_list_get_rdlock( job_queue->job_list );
  {
    job_queue_node_type * node = job_list_iget_job( job_queue->job_list , queue_index );

    if (job_queue_node_get_submit_attempt( node ) < job_queue->max_submit)
      job_queue_change_node_status( job_queue , node , JOB_QUEUE_WAITING );  /* The job will be picked up for antother go. */
    else {
      bool retry = job_queue_node_run_RETRY_callback( node );

      if (retry) {
        /* OK - we have invoked the retry_callback() - and that has returned true;
           giving this job a brand new start. */
        job_queue_node_reset_submit_attempt( node );
        job_queue_change_node_status(job_queue , node , JOB_QUEUE_WAITING);
      } else {
        // It's time to call it a day

        job_queue_node_run_EXIT_callback( node );
        job_queue_change_node_status(job_queue , node , JOB_QUEUE_FAILED);
      }
    }
    job_queue_node_free_driver_data( node , job_queue->driver );
  }
  job_list_unlock(job_queue->job_list );
  arg_pack_free( arg_pack );

  return NULL;
}
Пример #6
0
static double trans_dunif(double x , const arg_pack_type * arg) {
  double y;
  int    steps = arg_pack_iget_int(arg , 0);
  double min   = arg_pack_iget_double(arg , 1);
  double max   = arg_pack_iget_double(arg , 2);
  
  y = 0.5*(1 + erf(x/sqrt(2.0))); /* 0 - 1 */
  return (floor( y * steps) / (steps - 1)) * (max - min) + min;
}
Пример #7
0
void * job_queue_run_jobs__(void * __arg_pack) {
  arg_pack_type * arg_pack = arg_pack_safe_cast(__arg_pack);
  job_queue_type * queue   = arg_pack_iget_ptr(arg_pack , 0);
  int num_total_run        = arg_pack_iget_int(arg_pack , 1);
  bool verbose             = arg_pack_iget_bool(arg_pack , 2);

  job_queue_run_jobs(queue , num_total_run , verbose);
  arg_pack_free( arg_pack );
  return NULL;
}
Пример #8
0
/* Observe that the argument of the shift should be "+" */
static double trans_derrf(double x , const arg_pack_type * arg) {
  int    steps    = arg_pack_iget_int(arg , 0);
  double min      = arg_pack_iget_double(arg , 1);
  double max      = arg_pack_iget_double(arg , 2);
  double skewness = arg_pack_iget_double(arg , 3);
  double width    = arg_pack_iget_double(arg , 4);
  double y;
  
  y = floor( steps * 0.5*(1 + erf((x + skewness)/(width * sqrt(2.0)))) / (steps - 1) );
  return min + y * (max - min);
}
Пример #9
0
static void * job_queue_run_DO_KILL_callback( void * arg ) {
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  job_queue_type * job_queue = arg_pack_iget_ptr( arg_pack , 0 );
  int queue_index = arg_pack_iget_int( arg_pack , 1 );

  job_list_get_rdlock( job_queue->job_list );
  {
    job_queue_node_type * node = job_list_iget_job( job_queue->job_list , queue_index );
    job_queue_node_free_driver_data( node , job_queue->driver );

    // It's time to call it a day
    job_queue_node_run_EXIT_callback( node );
    job_queue_change_node_status(job_queue, node, JOB_QUEUE_IS_KILLED);
  }
  job_list_unlock(job_queue->job_list );
  arg_pack_free( arg_pack );
  return NULL;
}
Пример #10
0
static void * job_queue_run_DONE_callback( void * arg ) {
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  job_queue_type * job_queue = arg_pack_iget_ptr( arg_pack , 0 );
  int queue_index = arg_pack_iget_int( arg_pack , 1 );
  job_list_get_rdlock( job_queue->job_list );
  {
    job_queue_node_type * node = job_list_iget_job( job_queue->job_list , queue_index );
    bool OK = job_queue_check_node_status_files( job_queue , node );

    if (OK)
      OK = job_queue_node_run_DONE_callback( node );

    if (OK)
      job_queue_change_node_status( job_queue , node , JOB_QUEUE_SUCCESS );
    else
      job_queue_change_node_status( job_queue , node , JOB_QUEUE_EXIT );

    job_queue_node_free_driver_data( node , job_queue->driver );
  }
  job_list_unlock(job_queue->job_list );
  arg_pack_free( arg_pack );
  return NULL;
}