void enkf_analysis_fprintf_obs_summary(const obs_data_type * obs_data , const meas_data_type * meas_data , const int_vector_type * step_list , const char * ministep_name , FILE * stream ) { const char * float_fmt = "%15.3f"; fprintf(stream , "===============================================================================================================================\n"); fprintf(stream , "Report step...: %04d",int_vector_iget( step_list , 0)); if (int_vector_size( step_list ) == 1) fprintf(stream , "\n"); else fprintf(stream , " - %04d \n",int_vector_get_last( step_list )); fprintf(stream , "Ministep......: %s \n",ministep_name); fprintf(stream , "-------------------------------------------------------------------------------------------------------------------------------\n"); { char * obs_fmt = util_alloc_sprintf(" %%-3d : %%-32s %s +/- %s" , float_fmt , float_fmt); char * sim_fmt = util_alloc_sprintf(" %s +/- %s \n" , float_fmt , float_fmt); fprintf(stream , " Observed history | Simulated data \n"); fprintf(stream , "-------------------------------------------------------------------------------------------------------------------------------\n"); { int block_nr; int obs_count = 1; /* Only for printing */ for (block_nr =0; block_nr < obs_data_get_num_blocks( obs_data ); block_nr++) { const obs_block_type * obs_block = obs_data_iget_block_const( obs_data , block_nr); meas_block_type * meas_block = meas_data_iget_block( meas_data , block_nr ); const char * obs_key = obs_block_get_key( obs_block ); for (int iobs = 0; iobs < obs_block_get_size( obs_block ); iobs++) { const char * print_key; if (iobs == 0) print_key = obs_key; else print_key = " ..."; fprintf(stream , obs_fmt , obs_count , print_key , obs_block_iget_value( obs_block , iobs ) , obs_block_iget_std( obs_block , iobs )); { active_type active_mode = obs_block_iget_active_mode( obs_block , iobs ); if (active_mode == ACTIVE) fprintf(stream , " Active |"); else if (active_mode == DEACTIVATED) fprintf(stream , " Inactive |"); else if (active_mode == MISSING) fprintf(stream , " |"); else util_abort("%s: enum_value:%d not handled - internal error\n" , __func__ , active_mode); if (active_mode == MISSING) fprintf(stream , " Missing\n"); else fprintf(stream , sim_fmt, meas_block_iget_ens_mean( meas_block , iobs ) , meas_block_iget_ens_std( meas_block , iobs )); } obs_count++; } } } free( obs_fmt ); free( sim_fmt ); } fprintf(stream , "===============================================================================================================================\n"); fprintf(stream , "\n\n\n"); }
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); }