Beispiel #1
0
void * enkf_main_rank_on_data_JOB(void * self, const stringlist_type * args) {
  enkf_main_type * enkf_main = enkf_main_safe_cast( self );
  const char * ranking_name  = stringlist_iget(args, 0);
  const char * data_key      = stringlist_iget(args, 1);
  bool valid = true;
  bool sort_increasing       = stringlist_iget_as_bool(args, 2, &valid);

  if (!valid) {
    fprintf(stderr,"** Third argument \"sort increasing\" not recognized as bool value, job not started\n");
    return NULL;
  }

  int report_step = (stringlist_get_size(args) > 3) ? stringlist_iget_as_int(args, 3, &valid) : enkf_main_get_history_length(enkf_main) ;
  if (!valid) {
    fprintf(stderr,"** Fourth argument \"step\" not recognized as integer value, job not started\n");
    return NULL;
  }

  if (report_step < 0) {
    fprintf(stderr,"** Negative report step, job not started\n");
    return NULL;
  }

  enkf_main_rank_on_data(enkf_main, ranking_name, data_key, sort_increasing, report_step);
  return NULL;
}
Beispiel #2
0
static void * enkf_main_smoother_JOB__( void * self , int iter , const stringlist_type * args ) {
  enkf_main_type   * enkf_main = enkf_main_safe_cast( self );
  int ens_size                 = enkf_main_get_ensemble_size( enkf_main );
  bool_vector_type * iactive   = bool_vector_alloc( ens_size , true );
  bool valid                   = true;
  const char * target_case;
  enkf_fs_type * target_fs     = enkf_main_get_fs( enkf_main );


  // Argument 0: Which case to write to. Default current case.
  if (stringlist_get_size(args)) {
    target_case = stringlist_iget( args , 0 );
    if (strcmp( target_case , CURRENT_CASE_STRING) == 0)
      target_case = enkf_fs_get_case_name(target_fs);
  } else
    target_case = enkf_fs_get_case_name(target_fs);

  //Argument 1: Rerun. Default false.
  bool rerun = (stringlist_get_size(args) >= 2) ? stringlist_iget_as_bool(args, 1, &valid) : false;

  if (!valid) {
      fprintf(stderr, "** Warning: Function %s : Second argument must be a bool value. Exiting job\n", __func__);
      return NULL;
  }
  enkf_main_run_smoother( enkf_main , target_case , iactive , iter , rerun);
  bool_vector_free( iactive );
  return NULL;
}
Beispiel #3
0
static void * enkf_main_smoother_JOB__( void * self , int iter , const stringlist_type * args ) {
  enkf_main_type   * enkf_main = enkf_main_safe_cast( self );
  int ens_size                 = enkf_main_get_ensemble_size( enkf_main );
  bool_vector_type * iactive   = bool_vector_alloc( ens_size , true );
  bool valid                   = true;
  const char * target_case     = stringlist_iget( args , 0 );
  enkf_fs_type * source_fs     = enkf_main_job_get_fs( enkf_main );
  //Argument 2: Rerun. Default false.
  bool rerun = (stringlist_get_size(args) >= 2) ? stringlist_iget_as_bool(args, 1, &valid) : false;

  if (!valid) {
      fprintf(stderr, "** Warning: Function %s : Second argument must be a bool value. Exiting job\n", __func__);
      return NULL;
  }
  enkf_main_run_smoother( enkf_main , source_fs , target_case , iactive , iter , rerun);
  bool_vector_free( iactive );
  return NULL;
}
void test_iget_as_bool() {
  stringlist_type * s = stringlist_alloc_new();
  stringlist_append_copy(s , "TRUE" );
  stringlist_append_copy(s , "True" );
  stringlist_append_copy(s , "true" );
  stringlist_append_copy(s , "T" );
  stringlist_append_copy(s , "1" );

  stringlist_append_copy(s , "FALSE" );
  stringlist_append_copy(s , "False" );
  stringlist_append_copy(s , "false" );
  stringlist_append_copy(s , "F" );
  stringlist_append_copy(s , "0" );

  stringlist_append_copy(s , "not_so_bool" );
  stringlist_append_copy(s , "8" );


  {
    bool value = false;
    bool valid = false;

    value = stringlist_iget_as_bool( s , 0 , &valid);
    test_assert_true( value );
    test_assert_true( valid );

    value = stringlist_iget_as_bool( s , 1 , &valid);
    test_assert_true( value );
    test_assert_true( valid );

    value = stringlist_iget_as_bool( s , 2 , &valid);
    test_assert_true( value );
    test_assert_true( valid );

    value = stringlist_iget_as_bool( s , 3 , &valid);
    test_assert_true( value );
    test_assert_true( valid );


    value = stringlist_iget_as_bool( s , 4 , &valid);
    test_assert_true( value );
    test_assert_true( valid );

    value = stringlist_iget_as_bool( s , 5 , &valid);
    test_assert_false( value );
    test_assert_true( valid );

    value = stringlist_iget_as_bool( s , 6 , &valid);
    test_assert_false( value );
    test_assert_true( valid );

    value = stringlist_iget_as_bool( s , 7 , &valid);
    test_assert_false( value );
    test_assert_true( valid );

    value = stringlist_iget_as_bool( s , 8 , &valid);
    test_assert_false( value );
    test_assert_true( valid );

    value = stringlist_iget_as_bool( s , 9 , &valid);
    test_assert_false( value );
    test_assert_true( valid );

    value = stringlist_iget_as_bool( s , 10 , &valid);
    test_assert_false( value );
    test_assert_false( valid );

    value = stringlist_iget_as_bool( s , 11 , &valid);
    test_assert_false( value );
    test_assert_false( valid );
  }
}