From a6e3bbd6109826988c4fd24973f7c91d46c1e491 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 2 May 2013 19:04:09 +0200 Subject: [PATCH] Updated calls to ecl_util_fmt_file() - result is by reference --- opm/core/io/eclipse/EclipseGridParser.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/opm/core/io/eclipse/EclipseGridParser.cpp b/opm/core/io/eclipse/EclipseGridParser.cpp index 8a1905ec..ed4b246c 100644 --- a/opm/core/io/eclipse/EclipseGridParser.cpp +++ b/opm/core/io/eclipse/EclipseGridParser.cpp @@ -966,9 +966,16 @@ ecl_grid_type * EclipseGridParser::newGrid( ) { void EclipseGridParser::saveEGRID( const std::string & filename) const { bool endian_flip = true;//ECL_ENDIAN_FLIP; - bool fmt_file = ecl_util_fmt_file( filename.c_str() ); + bool fmt_file; struct grdecl grdecl = get_grdecl(); - fortio_type * fortio = fortio_open_writer( filename.c_str() , fmt_file , endian_flip ); + fortio_type * fortio; + + if (!ecl_util_fmt_file( filename.c_str() , &fmt_file)) { + cerr << "Could not determine formatted/unformatted status of file:" << filename << " non-standard name?" << endl; + throw exception(); + } + + fortio = fortio_open_writer( filename.c_str() , fmt_file , endian_flip ); { float * mapaxes = NULL; if (grdecl.mapaxes != NULL) { @@ -1023,9 +1030,16 @@ void EclipseGridParser::save_kw( fortio_type * fortio , const std::string & kw , void EclipseGridParser::saveINIT( const std::string & filename , const ecl_grid_type * ecl_grid) { int phases = ECL_OIL_PHASE + ECL_WATER_PHASE; - bool fmt_file = ecl_util_fmt_file( filename.c_str() ); bool endian_flip = true;//ECL_ENDIAN_FLIP; - fortio_type * fortio = fortio_open_writer( filename.c_str() , fmt_file , endian_flip ); + bool fmt_file; + fortio_type * fortio; + + if (!ecl_util_fmt_file( filename.c_str() , &fmt_file)) { + cerr << "Could not determine formatted/unformatted status of file:" << filename << " non-standard name?" << endl; + throw exception(); + } + fortio = fortio_open_writer( filename.c_str() , fmt_file , endian_flip ); + { ecl_kw_type * poro_kw = newEclKW( PORO_KW , ECL_FLOAT_TYPE ); time_t start_date;