Ejemplo n.º 1
0
void * status_job__( void * arg ) {
  const int usleep_time = 10000;
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  job_type * job = job_safe_cast( arg_pack_iget_ptr( arg_pack , 0 ) );
  job_queue_type * queue = arg_pack_iget_ptr( arg_pack , 1 );
  char * run_file = util_alloc_filename( job->run_path , "RUNNING" , NULL);

  while (true) {
    if (job->queue_index >= 0) {
      job_status_type status;
      if (util_is_file(run_file)) {
        status = job_queue_iget_job_status(queue, job->queue_index);
        if (util_is_file(run_file))
          test_assert_true( (status == JOB_QUEUE_RUNNING) || (status == JOB_QUEUE_SUBMITTED) );
      }
      status = job_queue_iget_job_status(queue, job->queue_index);
      if (status == JOB_QUEUE_SUCCESS)
        break;
    }
    usleep( usleep_time );
  }

  free( run_file );
  return NULL;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
void * submit_job__( void * arg ) {
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  job_type * job = job_safe_cast( arg_pack_iget_ptr( arg_pack , 0 ) );
  job_queue_type * queue = arg_pack_iget_ptr( arg_pack , 1 );
  job->queue_index = job_queue_add_job( queue  , job->cmd , callback , NULL , NULL , job , 1 , job->run_path , job->run_path , job->argc , (const char **) job->argv );
  usleep( job->submit_usleep );
  return NULL;
}
Ejemplo n.º 5
0
void * ensemble_add_case__( void * arg ) {
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  ensemble_type * ensemble = arg_pack_iget_ptr( arg , 0 );
  const char * data_file   = arg_pack_iget_ptr( arg , 1 );
  ensemble_add_case( ensemble , data_file );
  arg_pack_free( arg_pack );
  return NULL;
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
void enkf_tui_analysis_select_module__(void * arg) {
  int prompt_len = 50;
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  enkf_main_type * enkf_main = arg_pack_iget_ptr( arg_pack , 0 );
  menu_type * menu = arg_pack_iget_ptr( arg_pack , 1 );

  const analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main);
  char module_name[256];
  util_printf_prompt("Name module to select" , prompt_len , '=' , "=> ");
  scanf("%s", module_name);
  if (analysis_config_select_module( analysis_config , module_name ))
    enkf_tui_analysis_update_title( enkf_main , menu );
}
Ejemplo n.º 11
0
static void enkf_tui_ranking_make_misfit_ensemble( void * arg) {
  arg_pack_type * arg_pack                     = arg_pack_safe_cast( arg );
  enkf_main_type  * enkf_main                  = arg_pack_iget_ptr( arg_pack , 0 );

  enkf_fs_type               * fs              = enkf_main_get_fs(enkf_main);
  enkf_obs_type              * enkf_obs        = enkf_main_get_obs( enkf_main );
  const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main);
  const int history_length                     = enkf_main_get_history_length( enkf_main );
  const int ens_size                           = enkf_main_get_ensemble_size( enkf_main );
  
    
  misfit_ensemble_type * misfit_ensemble = enkf_fs_get_misfit_ensemble( fs );
  misfit_ensemble_update( misfit_ensemble , ensemble_config , enkf_obs , fs , ens_size , history_length );
  {
    menu_item_type * obs_item                    = arg_pack_iget_ptr( arg_pack , 1 ); 
    menu_item_enable( obs_item );
  }
}
Ejemplo n.º 12
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;
}
Ejemplo n.º 13
0
void enkf_tui_fs_select_case(void * arg)
{
  int    prompt_len = 40;
  char * new_case;
  char * menu_title;

  arg_pack_type  * arg_pack     = arg_pack_safe_cast( arg );
  enkf_main_type * enkf_main    = enkf_main_safe_cast( arg_pack_iget_ptr(arg_pack, 0) );
  menu_type      * menu         = arg_pack_iget_ptr(arg_pack, 1);
  new_case = enkf_tui_fs_alloc_existing_case( enkf_main , "Name of case" , prompt_len);
  if (new_case != NULL) {
    enkf_main_select_fs( enkf_main ,  new_case );
    
    menu_title = util_alloc_sprintf("Manage cases. Current: %s", enkf_main_get_current_fs( enkf_main ));
    menu_set_title(menu, menu_title);
    free(menu_title);
    free(new_case);
  }
}
Ejemplo n.º 14
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;
}
Ejemplo n.º 15
0
void enkf_tui_fs_create_case(void * arg)
{
  int prompt_len = 50;
  char new_case[256];
  char * menu_title;

  arg_pack_type  * arg_pack     = arg_pack_safe_cast( arg );
  enkf_main_type   * enkf_main  = enkf_main_safe_cast( arg_pack_iget_ptr(arg_pack, 0) );
  menu_type      * menu         = arg_pack_iget_ptr(arg_pack, 1);

  util_printf_prompt("Name of new case" , prompt_len , '=' , "=> ");
  if (fgets(new_case, prompt_len, stdin) != NULL){
    char *newline = strchr(new_case, '\n');
    if (newline)
      *newline = 0;

    if(strlen(new_case) != 0)
      enkf_main_select_fs( enkf_main , new_case );

  }
  menu_title = util_alloc_sprintf("Manage cases. Current: %s", enkf_main_get_current_fs(enkf_main));
  menu_set_title(menu, menu_title);
  free(menu_title);
}
Ejemplo n.º 16
0
void call_add_job( void * arg ) {
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  job_list_type * job_list = arg_pack_iget_ptr( arg_pack , 0 );
  job_queue_node_type * node = arg_pack_iget_ptr( arg_pack , 1 );
  job_list_add_job( job_list , node );
}
Ejemplo n.º 17
0
void arg_pack_free__(void * __arg_pack) {
  arg_pack_type * arg_pack = arg_pack_safe_cast( __arg_pack );
  arg_pack_free( arg_pack );
}
Ejemplo n.º 18
0
void * test_argpack_is_stringlist( void * arg ) {
  arg_pack_type * arg_pack = arg_pack_safe_cast( arg );
  void * arg0 = arg_pack_iget_ptr( arg_pack , 0 );
  test_assert_true( stringlist_is_instance( arg0 ) );
  return NULL;
}