ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occurence) { if (ecl_file_get_num_named_kw( rst_file , INTEHEAD_KW) > occurence) { const ecl_kw_type * intehead_kw = ecl_file_iget_named_kw( rst_file , INTEHEAD_KW , occurence); ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); { const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw ); rsthead->day = data[INTEHEAD_DAY_INDEX]; rsthead->month = data[INTEHEAD_MONTH_INDEX]; rsthead->year = data[INTEHEAD_YEAR_INDEX]; rsthead->version = data[INTEHEAD_IPROG_INDEX]; rsthead->phase_sum = data[INTEHEAD_PHASE_INDEX]; rsthead->nx = data[INTEHEAD_NX_INDEX]; rsthead->ny = data[INTEHEAD_NY_INDEX]; rsthead->nz = data[INTEHEAD_NZ_INDEX]; rsthead->nactive = data[INTEHEAD_NACTIVE_INDEX]; rsthead->nwells = data[INTEHEAD_NWELLS_INDEX]; rsthead->niwelz = data[INTEHEAD_NIWELZ_INDEX]; rsthead->nzwelz = data[INTEHEAD_NZWELZ_INDEX]; rsthead->nsconz = data[INTEHEAD_NSCONZ_INDEX]; rsthead->niconz = data[INTEHEAD_NICONZ_INDEX]; rsthead->ncwmax = data[INTEHEAD_NCWMAX_INDEX]; rsthead->nisegz = data[INTEHEAD_NISEGZ_INDEX]; rsthead->nsegmx = data[INTEHEAD_NSEGMX_INDEX]; rsthead->nswlmx = data[INTEHEAD_NSWLMX_INDEX]; rsthead->nrsegz = data[INTEHEAD_NRSEGZ_INDEX]; // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } if (ecl_file_get_num_named_kw(rst_file, DOUBHEAD_KW) > occurence) { const ecl_kw_type * doubhead_kw = ecl_file_iget_named_kw( rst_file , DOUBHEAD_KW , occurence); rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); } if (ecl_file_get_num_named_kw(rst_file, LOGIHEAD_KW) > occurence) { const ecl_kw_type * logihead_kw = ecl_file_iget_named_kw( rst_file , LOGIHEAD_KW , occurence); rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); } else rsthead->dualp = false; return rsthead; } else return NULL; }
ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_type * intehead_kw , const ecl_kw_type * doubhead_kw , const ecl_kw_type * logihead_kw ) { ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); rsthead->report_step = report_step; { const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw ); rsthead->day = data[INTEHEAD_DAY_INDEX]; rsthead->month = data[INTEHEAD_MONTH_INDEX]; rsthead->year = data[INTEHEAD_YEAR_INDEX]; rsthead->version = data[INTEHEAD_IPROG_INDEX]; rsthead->phase_sum = data[INTEHEAD_PHASE_INDEX]; rsthead->nx = data[INTEHEAD_NX_INDEX]; rsthead->ny = data[INTEHEAD_NY_INDEX]; rsthead->nz = data[INTEHEAD_NZ_INDEX]; rsthead->nactive = data[INTEHEAD_NACTIVE_INDEX]; rsthead->nwells = data[INTEHEAD_NWELLS_INDEX]; rsthead->niwelz = data[INTEHEAD_NIWELZ_INDEX]; rsthead->nzwelz = data[INTEHEAD_NZWELZ_INDEX]; rsthead->nsconz = data[INTEHEAD_NSCONZ_INDEX]; rsthead->niconz = data[INTEHEAD_NICONZ_INDEX]; rsthead->ncwmax = data[INTEHEAD_NCWMAX_INDEX]; rsthead->nisegz = data[INTEHEAD_NISEGZ_INDEX]; rsthead->nsegmx = data[INTEHEAD_NSEGMX_INDEX]; rsthead->nswlmx = data[INTEHEAD_NSWLMX_INDEX]; rsthead->nrsegz = data[INTEHEAD_NRSEGZ_INDEX]; // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); } if (doubhead_kw) rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); if (logihead_kw) rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); return rsthead; }
time_t ecl_rsthead_date( const ecl_kw_type * intehead_kw ) { return rsthead_date( ecl_kw_iget_int( intehead_kw , INTEHEAD_DAY_INDEX) , ecl_kw_iget_int( intehead_kw , INTEHEAD_MONTH_INDEX) , ecl_kw_iget_int( intehead_kw , INTEHEAD_YEAR_INDEX) ); }