diff --git a/src/stream_cgribex.c b/src/stream_cgribex.c index 9263609d1a3178f16586c93795d0032555b4698d..d7afade355023aa8ff3e8ebc4253eea7ad18f889 100644 --- a/src/stream_cgribex.c +++ b/src/stream_cgribex.c @@ -1636,14 +1636,23 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI } else if ( gridtype == GRID_CURVILINEAR ) { - static bool lwarning = true; - if ( lwarning && gridInqSize(gridID) > 1 ) - { - lwarning = false; - Warning("Curvilinear grids are unsupported in GRIB1! Created wrong Grid Description Section!"); - } - gridtype = GRID_LONLAT; - lcurvi = true; + int projID = gridInqProj(gridID); + if ( projID != CDI_UNDEFID && gridInqType(projID) == GRID_PROJECTION ) + { + gridID = projID; + gridtype = GRID_PROJECTION; + } + else + { + static bool lwarning = true; + if ( lwarning && gridInqSize(gridID) > 1 ) + { + lwarning = false; + Warning("Curvilinear grid is unsupported in GRIB1! Created wrong Grid Description Section!"); + } + lcurvi = true; + gridtype = GRID_LONLAT; + } } if ( gridtype == GRID_PROJECTION && gridInqProjType(gridID) == CDI_PROJ_RLL ) diff --git a/src/stream_gribapi.c b/src/stream_gribapi.c index 759b854522cb8764b21bcf6fea1f99d9a8b3afc7..8dd6a920b576330de730c4dd68e5b2925afe929e 100644 --- a/src/stream_gribapi.c +++ b/src/stream_gribapi.c @@ -20,10 +20,10 @@ #include "subtype.h" -# include "cgribex.h" /* gribGetSize, gribRead, gribGetZip, GRIB1_LTYPE_99 */ -# include "gribapi.h" +#include "cgribex.h" /* gribGetSize, gribRead, gribGetZip, GRIB1_LTYPE_99 */ +#include "gribapi.h" -# include <grib_api.h> +#include <grib_api.h> extern int cdiInventoryMode; @@ -1918,14 +1918,23 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype } else if ( gridtype == GRID_CURVILINEAR ) { - static bool lwarning = true; - if ( lwarning && gridsize > 1 ) - { - lwarning = false; - Warning("Curvilinear grids are unsupported in GRIB format! Created wrong Grid Description Section!"); - } - gridtype = GRID_LONLAT; - lcurvi = true; + int projID = gridInqProj(gridID); + if ( projID != CDI_UNDEFID && gridInqType(projID) == GRID_PROJECTION ) + { + gridID = projID; + gridtype = GRID_PROJECTION; + } + else + { + static bool lwarning = true; + if ( lwarning && gridsize > 1 ) + { + lwarning = false; + Warning("Curvilinear grid is unsupported in GRIB format! Created wrong Grid Description Section!"); + } + lcurvi = true; + gridtype = GRID_LONLAT; + } } if ( gridtype == GRID_PROJECTION && gridInqProjType(gridID) == CDI_PROJ_RLL )