コード例 #1
0
ファイル: enkf_main_jobs.c プロジェクト: atgeirr/ResInsight
void * enkf_main_analysis_update_JOB( void * self , const stringlist_type * args) {
  enkf_main_type   * enkf_main = enkf_main_safe_cast( self );
  enkf_fs_type * target_fs;
  int target_step;
  int_vector_type * step_list;
  bool decrease_ref = false;

  // Argument 0: Which case to write to
  if (stringlist_get_size(args)) {
    const char * target_fs_name = stringlist_iget( args , 0 );
    if (strcmp( target_fs_name , CURRENT_CASE_STRING) == 0)
      target_fs = enkf_main_get_fs( enkf_main );
    else {
      target_fs = enkf_main_mount_alt_fs( enkf_main , target_fs_name , true);
      decrease_ref = true;
    }
  } else
      target_fs = enkf_main_get_fs( enkf_main );
  {


    // Argument 1: The number of the step to write to
    if (stringlist_get_size(args) > 1)
      util_sscanf_int(stringlist_iget( args , 1) , &target_step);
    else
      target_step = 0;

    // Argument 2 - ??: The timesteps to use in the update
    if (stringlist_get_size( args ) > 2) {
      char * step_args = stringlist_alloc_joined_substring(args , 2 , stringlist_get_size(args) , " ");
      step_list = string_util_alloc_active_list( step_args );
      free( step_args );
    } else {
      int stride = 1;
      time_map_type * time_map = enkf_fs_get_time_map( enkf_main_get_fs( enkf_main ));
      step_list = enkf_main_update_alloc_step_list( enkf_main , 0 , time_map_get_last_step( time_map ) , stride);
    }

    enkf_main_UPDATE( enkf_main , step_list , target_fs , target_step , SMOOTHER_UPDATE);

    int_vector_free( step_list );

    if (decrease_ref)
      enkf_fs_decref( target_fs );
  }
  return NULL;
}
コード例 #2
0
ファイル: enkf_main_manage_fs.c プロジェクト: eoia/ert
enkf_fs_type * enkf_main_mount_alt_fs(const enkf_main_type * enkf_main , const char * case_path , bool create) {
    if (enkf_main_case_is_current( enkf_main , case_path )) {
        // Fast path - we just return a reference to the currently selected case;
        // with increased refcount.
        enkf_fs_incref( enkf_main->dbase );
        return enkf_main->dbase;
    } else {
        // We have asked for an alterantive fs - must mount and possibly create that first.
        enkf_fs_type * new_fs = NULL;
        if (case_path != NULL) {
            char * new_mount_point    = enkf_main_alloc_mount_point( enkf_main , case_path );

            if (!enkf_fs_exists( new_mount_point )) {
                if (create)
                    enkf_main_create_fs( enkf_main , case_path );
            }

            new_fs = enkf_fs_mount( new_mount_point );
            if (new_fs) {
                const model_config_type * model_config = enkf_main_get_model_config( enkf_main );
                const ecl_sum_type * refcase = model_config_get_refcase( model_config );

                if (refcase) {
                    time_map_type * time_map = enkf_fs_get_time_map( new_fs );
                    if (time_map_attach_refcase( time_map , refcase))
                        time_map_set_strict( time_map , false );
                    else
                        ert_log_add_fmt_message(1 , stderr , "Warning mismatch between refcase:%s and existing case:%s" , ecl_sum_get_case( refcase ) , new_mount_point);
                }
            }

            free( new_mount_point );
        }
        return new_fs;
    }
}