Exemplo n.º 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;
}
Exemplo n.º 2
0
void test_iget_as_int() {
  stringlist_type * s = stringlist_alloc_new();
  stringlist_append_copy(s , "1000" );
  stringlist_append_copy(s , "1000X" );
  stringlist_append_copy(s , "XXXX" );

  {
    int value;
    bool valid;

    value = stringlist_iget_as_int( s , 0 , &valid);
    test_assert_int_equal( value , 1000);
    test_assert_true( valid );

    value = stringlist_iget_as_int( s , 1 , &valid);
    test_assert_int_equal( value , -1);
    test_assert_false( valid );

    value = stringlist_iget_as_int( s , 2 , NULL);
    test_assert_int_equal( value , -1);
  }
}