void * enkf_main_std_scale_correlated_obs_JOB(void * self, const stringlist_type * args) { if (stringlist_get_size(args) > 0) { enkf_main_type * enkf_main = enkf_main_safe_cast( self ); int ensemble_size = enkf_main_get_ensemble_size(enkf_main); enkf_fs_type * fs = enkf_main_get_fs( enkf_main ); enkf_obs_type * obs = enkf_main_get_obs( enkf_main ); int_vector_type * realizations = int_vector_alloc(1, 0); local_obsdata_type * obsdata = local_obsdata_alloc( "OBS-JOB" ); int_vector_init_range(realizations, 0, ensemble_size, 1); for (int iarg = 0; iarg < stringlist_get_size(args); iarg++) { const char * arg_key = stringlist_iget( args , iarg ); stringlist_type * key_list = enkf_obs_alloc_matching_keylist(obs, arg_key); for (int iobs=0; iobs < stringlist_get_size( key_list ); iobs++) { const char * obs_key = stringlist_iget( key_list , iobs); const obs_vector_type * obs_vector = enkf_obs_get_vector(obs, obs_key); local_obsdata_add_node( obsdata , obs_vector_alloc_local_node(obs_vector) ); } stringlist_free( key_list ); } if (local_obsdata_get_size(obsdata) > 0) enkf_obs_scale_correlated_std(obs, fs, realizations, obsdata ); local_obsdata_free( obsdata ); } return NULL; }
void * enkf_main_export_runpath_file_JOB(void * self, const stringlist_type * args) { enkf_main_type * enkf_main = enkf_main_safe_cast( self ); int ensemble_size = enkf_main_get_ensemble_size(enkf_main); analysis_config_type * analysis_config = enkf_main_get_analysis_config(enkf_main); analysis_iter_config_type * iter_config = analysis_config_get_iter_config(analysis_config); int num_iterations = analysis_iter_config_get_num_iterations(iter_config); const model_config_type * model_config = enkf_main_get_model_config(enkf_main); int_vector_type * realizations = int_vector_alloc(1, 0); int_vector_init_range(realizations, 0, ensemble_size, 1); int_vector_type * iterations = int_vector_alloc(1, 0); if (stringlist_get_size(args) > 0) { int offset = 0; while (true) { if (offset == stringlist_get_size( args )) break; if (0 == strcmp("|" , stringlist_iget( args, offset ))) break; ++offset; } if (0 != strcmp("*", stringlist_iget(args,0))) { char * range_str = stringlist_alloc_joined_substring( args, 0, offset, ""); string_util_init_value_list(range_str, realizations); free(range_str); } if ((offset < stringlist_get_size(args)) && model_config_runpath_requires_iter(model_config)) { if (0 == strcmp("*", stringlist_iget(args, (offset+1)))) int_vector_init_range(iterations, 0, num_iterations, 1); else { char * range_str = stringlist_alloc_joined_substring( args, offset+1, stringlist_get_size(args), ""); string_util_init_value_list(range_str, iterations); free(range_str); } } } enkf_main_export_runpath_file(enkf_main, realizations, iterations); int_vector_free(realizations); int_vector_free(iterations); return NULL; }
int main(int argc , char ** argv) { int_vector_type * int_vector = int_vector_alloc( 0 , 99); int_vector_iset( int_vector , 2 , 0); int_vector_insert( int_vector , 2 , 77 ); int_vector_iset( int_vector , 5 , -10); int_vector_fprintf( int_vector , stdout , "int_vector" , "%3d"); assert_equal( int_vector_iget(int_vector , 0 ) == 99 ); assert_equal( int_vector_iget(int_vector , 1 ) == 99 ); assert_equal( int_vector_iget(int_vector , 2 ) == 77 ); assert_equal( int_vector_iget(int_vector , 3 ) == 00 ); assert_equal( int_vector_iget(int_vector , 4 ) == 99 ); assert_equal( int_vector_iget(int_vector , 5 ) == -10 ); { int N1 = 100000; int N2 = 10*N1; int_vector_type * v1 = int_vector_alloc( N1 , 0 ); int_vector_type * v2; int * data1 = int_vector_get_ptr( v1 ); int_vector_iset( v1 , N1 - 1, 99); int_vector_free_container( v1 ); v2 = int_vector_alloc( N2 , 0 ); int_vector_iset(v2 , N2 - 1, 77 ); test_assert_int_equal( data1[N1-1] , 99); int_vector_free( v2 ); free( data1 ); } test_assert_true( int_vector_init_range( int_vector , 100 , 1000 , 115 ) ); test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100); test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215); test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330); test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445); test_assert_int_equal( int_vector_get_last( int_vector ) , 1000); test_assert_false( int_vector_init_range( int_vector , 100 , -1000 , 115 ) ); test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100); test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215); test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330); test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445); test_assert_int_equal( int_vector_get_last( int_vector ) , 1000); { int_vector_type * v1 = int_vector_alloc(0,0); int_vector_type * v2 = int_vector_alloc(0,0); int_vector_append(v1 , 10); int_vector_append(v1 , 15); int_vector_append(v1 , 20); int_vector_append(v2 , 1); int_vector_append(v2 , 2); int_vector_append(v2 , 3); int_vector_append_vector( v1 , v2 ); test_assert_int_equal( int_vector_size( v1 ) , 6 ); test_assert_int_equal( int_vector_iget (v1 , 0 ), 10 ); test_assert_int_equal( int_vector_iget (v1 , 1 ), 15 ); test_assert_int_equal( int_vector_iget (v1 , 2 ), 20 ); test_assert_int_equal( int_vector_iget (v1 , 3 ), 1 ); test_assert_int_equal( int_vector_iget (v1 , 4 ), 2 ); test_assert_int_equal( int_vector_iget (v1 , 5 ), 3 ); int_vector_free( v1 ); int_vector_free( v2 ); } exit(0); }
int main(int argc , char ** argv) { int_vector_type * int_vector = int_vector_alloc( 0 , 99); test_abort(); test_assert_int_equal( -1 , int_vector_index(int_vector , 100)); test_assert_int_equal( -1 , int_vector_index_sorted(int_vector , 100)); test_assert_true( int_vector_is_instance( int_vector )); test_assert_false( double_vector_is_instance( int_vector )); int_vector_iset( int_vector , 2 , 0); int_vector_insert( int_vector , 2 , 77 ); int_vector_iset( int_vector , 5 , -10); assert_equal( int_vector_iget(int_vector , 0 ) == 99 ); assert_equal( int_vector_iget(int_vector , 1 ) == 99 ); assert_equal( int_vector_iget(int_vector , 2 ) == 77 ); assert_equal( int_vector_iget(int_vector , 3 ) == 00 ); assert_equal( int_vector_iget(int_vector , 4 ) == 99 ); assert_equal( int_vector_iget(int_vector , 5 ) == -10 ); { int N1 = 100000; int N2 = 10*N1; int_vector_type * v1 = int_vector_alloc( N1 , 0 ); int_vector_type * v2; int * data1 = int_vector_get_ptr( v1 ); int_vector_iset( v1 , N1 - 1, 99); int_vector_free_container( v1 ); v2 = int_vector_alloc( N2 , 0 ); int_vector_iset(v2 , N2 - 1, 77 ); test_assert_int_equal( data1[N1-1] , 99); int_vector_free( v2 ); free( data1 ); } test_assert_true( int_vector_init_range( int_vector , 100 , 1000 , 115 ) ); test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100); test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215); test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330); test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445); test_assert_int_equal( int_vector_get_last( int_vector ) , 1000); test_assert_false( int_vector_init_range( int_vector , 100 , -1000 , 115 ) ); test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100); test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215); test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330); test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445); test_assert_int_equal( int_vector_get_last( int_vector ) , 1000); { int_vector_type * v1 = int_vector_alloc(0,0); int_vector_type * v2 = int_vector_alloc(0,0); int_vector_append(v1 , 10); int_vector_append(v1 , 15); int_vector_append(v1 , 20); int_vector_append(v2 , 1); int_vector_append(v2 , 2); int_vector_append(v2 , 3); int_vector_append_vector( v1 , v2 ); test_assert_int_equal( int_vector_size( v1 ) , 6 ); test_assert_int_equal( int_vector_iget (v1 , 0 ), 10 ); test_assert_int_equal( int_vector_iget (v1 , 1 ), 15 ); test_assert_int_equal( int_vector_iget (v1 , 2 ), 20 ); test_assert_int_equal( int_vector_iget (v1 , 3 ), 1 ); test_assert_int_equal( int_vector_iget (v1 , 4 ), 2 ); test_assert_int_equal( int_vector_iget (v1 , 5 ), 3 ); int_vector_free( v1 ); int_vector_free( v2 ); } test_contains(); test_contains_sorted(); test_shift(); test_alloc(); test_div(); test_memcpy_from_data(); test_idel_insert(); test_del(); test_range_fill(); test_iset_block(); test_resize(); test_empty(); test_insert_double(); exit(0); }
void test_export_runpath_files(const char * config_file, const char * config_file_iterations, const char * job_file_export_runpath) { stringlist_type * args = stringlist_alloc_new(); const char * job_name = "export_job"; ert_test_context_type * test_context_iterations = create_context( config_file_iterations, "enkf_workflow_job_test_export_runpath_iter" ); { int_vector_type * iens_values = int_vector_alloc(5,0); const int iens[5] = {0,1,2,3,4}; int_vector_set_many(iens_values, 0, &iens[0], 5); int_vector_type * iter_values = int_vector_alloc(1,0); test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values); int_vector_free(iens_values); int_vector_free(iter_values); } { stringlist_append_copy( args, "0-2"); //realization range int_vector_type * iens_values = int_vector_alloc(3,0); const int iens[] = {0,1,2}; int_vector_set_many(iens_values, 0, &iens[0], 3); int_vector_type * iter_values = int_vector_alloc(1,0); test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values); int_vector_free(iens_values); int_vector_free(iter_values); stringlist_clear(args); } { stringlist_append_copy( args, "0,3-5"); //realization range int_vector_type * iens_values = int_vector_alloc(4,0); const int iens[] = {0,3,4,5}; int_vector_set_many(iens_values, 0, &iens[0], 4); int_vector_type * iter_values = int_vector_alloc(1,0); test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values); int_vector_free(iens_values); int_vector_free(iter_values); stringlist_clear(args); } { stringlist_append_copy( args, "1-2"); //realization range stringlist_append_copy( args, "|"); //delimiter stringlist_append_copy( args, "1-3"); //iteration range int_vector_type * iens_values = int_vector_alloc(2,0); int iens[] = {1,2}; int_vector_set_many(iens_values, 0, &iens[0], 2); int_vector_type * iter_values = int_vector_alloc(3,0); int iter[] = {1,2,3}; int_vector_set_many(iter_values, 0, &iter[0], 3); test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values); int_vector_free(iens_values); int_vector_free(iter_values); stringlist_clear(args); } { stringlist_append_copy( args, "*"); //realization range stringlist_append_copy( args, "|"); //delimiter stringlist_append_copy( args, "*"); //iteration range int_vector_type * iens_values = int_vector_alloc(5,0); int iens[] = {0,1,2,3,4}; int_vector_set_many(iens_values, 0, &iens[0], 5); int_vector_type * iter_values = int_vector_alloc(4,0); int iter[] = {0,1,2,3}; int_vector_set_many(iter_values, 0, &iter[0], 4); test_export_runpath_file(test_context_iterations, job_name, job_file_export_runpath, args, iens_values, iter_values); int_vector_free(iens_values); int_vector_free(iter_values); stringlist_clear(args); } ert_test_context_free(test_context_iterations); ert_test_context_type * test_context = create_context( config_file, "enkf_workflow_job_test_export_runpath" ); { int_vector_type * iens_values = int_vector_alloc(1,0); int_vector_init_range(iens_values, 0, 25, 1); int_vector_type * iter_values = int_vector_alloc(1,0); test_export_runpath_file(test_context, job_name, job_file_export_runpath, args, iens_values, iter_values); int_vector_free(iens_values); int_vector_free(iter_values); stringlist_clear(args); } { stringlist_append_copy( args, "1-3"); //realization range int_vector_type * iens_values = int_vector_alloc(3,0); int iens[] = {1,2,3}; int_vector_set_many(iens_values, 0, &iens[0], 3); int_vector_type * iter_values = int_vector_alloc(1,0); test_export_runpath_file(test_context, job_name, job_file_export_runpath, args, iens_values, iter_values); int_vector_free(iens_values); int_vector_free(iter_values); stringlist_clear(args); } { stringlist_append_copy( args, "1,2"); //realization range stringlist_append_copy( args, "|"); //delimiter stringlist_append_copy( args, "1-3"); //iteration range int_vector_type * iens_values = int_vector_alloc(2,0); int iens[] = {1,2}; int_vector_set_many(iens_values, 0, &iens[0], 2); int_vector_type * iter_values = int_vector_alloc(1,0); test_export_runpath_file(test_context, job_name, job_file_export_runpath, args, iens_values, iter_values); int_vector_free(iens_values); int_vector_free(iter_values); stringlist_clear(args); } ert_test_context_free(test_context); stringlist_free( args ); }