Commit e88b9d98 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

added grid type GRID_NUMBER

parent 7f4a7b59
2011-01-21 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added grid type GRID_NUMBER
* changed grid name GRID_CELL to GRID_UNSTRUCTURED
2011-01-19 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
......@@ -120,6 +120,7 @@ extern "C" {
#define GRID_LCC2 12 /* Lambert Conformal Conic (PROJ) */
#define GRID_LAEA 13 /* Lambert Azimuthal Equal Area */
#define GRID_SINUSOIDAL 14 /* Sinusoidal */
#define GRID_NUMBER 15
/* ZAXIS types */
......@@ -615,6 +616,13 @@ void gridDefGMEni2(int gridID, int ni2);
int gridInqGMEni3(int gridID);
void gridDefGMEni3(int gridID, int ni3);
/* Number grid */
int gridInqNumber(int gridID);
void gridDefNumber(int gridID, int number);
int gridInqPosition(int gridID);
void gridDefPosition(int gridID, int position);
/* Lambert Conformal Conic grid (GRIB version) */
void gridDefLCC(int gridID, double originLon, double originLat, double lonParY, double lat1, double lat2, double xinc, double yinc, int projflag, int scanflag);
void gridInqLCC(int gridID, double *originLon, double *originLat, double *lonParY, double *lat1, double *lat2, double *xinc, double *yinc, int *projflag, int *scanflag);
......
......@@ -29,7 +29,7 @@
#define GRIBAPI_GTYPE_LCC 30 /* Lambert conformal */
#define GRIBAPI_GTYPE_SPECTRAL 50 /* spherical harmonics */
#define GRIBAPI_GTYPE_GME 100 /* hexagonal GME grid */
#define GRIBAPI_GTYPE_CELL 101 /* General Unstructured Grid */
#define GRIBAPI_GTYPE_NUMBER 101 /* General Unstructured Grid */
const char *gribapiLibraryVersion(void);
void gribapiDefHandles(int streamID);
......
......@@ -207,6 +207,8 @@ void grid_init_entry(grid_t *gridptr)
gridptr->ni = 0;
gridptr->ni2 = 0;
gridptr->ni3 = 0;
gridptr->number = 0;
gridptr->position = 0;
gridptr->prec = 0;
gridptr->size = 0;
gridptr->xsize = 0;
......@@ -3134,13 +3136,13 @@ void gridPrint(int gridID, int opt)
if ( type != GRID_GME )
{
if ( gridptr->xname[0] ) fprintf(fp, "xname = %s\n", gridptr->xname);
if ( gridptr->xlongname[0] ) fprintf(fp, "xlongname = %s\n", gridptr->xlongname);
if ( gridptr->xunits[0] ) fprintf(fp, "xunits = %s\n", gridptr->xunits);
if ( gridptr->yname[0] ) fprintf(fp, "yname = %s\n", gridptr->yname);
if ( gridptr->ylongname[0] ) fprintf(fp, "ylongname = %s\n", gridptr->ylongname);
if ( gridptr->yunits[0] ) fprintf(fp, "yunits = %s\n", gridptr->yunits);
if ( type == GRID_UNSTRUCTURED ) fprintf(fp, "nvertex = %d\n", nvertex);
if ( gridptr->xname[0] ) fprintf(fp, "xname = %s\n", gridptr->xname);
if ( gridptr->xlongname[0] ) fprintf(fp, "xlongname = %s\n", gridptr->xlongname);
if ( gridptr->xunits[0] ) fprintf(fp, "xunits = %s\n", gridptr->xunits);
if ( gridptr->yname[0] ) fprintf(fp, "yname = %s\n", gridptr->yname);
if ( gridptr->ylongname[0] ) fprintf(fp, "ylongname = %s\n", gridptr->ylongname);
if ( gridptr->yunits[0] ) fprintf(fp, "yunits = %s\n", gridptr->yunits);
if ( type == GRID_UNSTRUCTURED ) fprintf(fp, "nvertex = %d\n", nvertex);
}
switch (type)
......@@ -3368,6 +3370,12 @@ void gridPrint(int gridID, int opt)
fprintf(fp, "ni = %d\n", gridInqGMEni(gridID));
break;
}
case GRID_NUMBER:
{
fprintf(fp, "number = %d\n", gridInqNumber(gridID));
fprintf(fp, "position = %d\n", gridInqPosition(gridID));
break;
}
default:
{
fprintf(stderr, "Unsupported grid type: %s\n", gridNamePtr(type));
......@@ -3642,3 +3650,52 @@ int gridInqComplexPacking(int gridID)
return (lcomplex);
}
int gridInqNumber(int gridID)
{
grid_t *gridptr;
gridptr = grid_to_pointer(gridID);
grid_check_ptr(gridID, gridptr);
return (gridptr->number);
}
void gridDefNumber(int gridID, int number)
{
grid_t *gridptr;
gridptr = grid_to_pointer(gridID);
grid_check_ptr(gridID, gridptr);
gridptr->number = number;
}
int gridInqPosition(int gridID)
{
grid_t *gridptr;
gridptr = grid_to_pointer(gridID);
grid_check_ptr(gridID, gridptr);
return (gridptr->position);
}
void gridDefPosition(int gridID, int position)
{
grid_t *gridptr;
gridptr = grid_to_pointer(gridID);
grid_check_ptr(gridID, gridptr);
gridptr->position = position;
}
......@@ -43,6 +43,7 @@ typedef struct {
int xdef; /* 0: undefined 1:xvals 2:x0+xinc */
int ydef; /* 0: undefined 1:yvals 2:y0+yinc */
int nd, ni, ni2, ni3; /* parameter for GRID_GME */
int number, position; /* parameter for GRID_NUMBER */
int trunc; /* parameter for GRID_SPECTEAL */
int nvertex;
int *rowlon;
......
......@@ -74,9 +74,9 @@ int gribapiGetGridType(grib_handle *gh, int gribgridtype)
gridtype = GRID_GME;
break;
}
case GRIBAPI_GTYPE_CELL:
case GRIBAPI_GTYPE_NUMBER:
{
gridtype = GRID_UNSTRUCTURED;
gridtype = GRID_NUMBER;
break;
}
default:
......@@ -571,14 +571,11 @@ void gribapiAddRecord(int streamID, int param, grib_handle *gh,
break;
}
case GRID_UNSTRUCTURED:
case GRID_NUMBER:
{
int n1 = 0, n2 = 0;
grid.size = numberOfPoints;
if ( grib_get_long(gh, "numberOfGridUsed", &lpar) == 0 ) n1 = lpar;
if ( grib_get_long(gh, "numberOfGridInReference", &lpar) == 0 ) n2 = lpar;
gridtype = GRID_GENERIC;
if ( grib_get_long(gh, "numberOfGridUsed", &lpar) == 0 ) grid.number = lpar;
if ( grib_get_long(gh, "numberOfGridInReference", &lpar) == 0 ) grid.position = lpar;
break;
}
......@@ -2218,21 +2215,21 @@ void gribapiDefGrid(grib_handle *gh, int gridID, int ljpeg)
break;
}
case GRID_UNSTRUCTURED:
case GRID_NUMBER:
{
static int warning = 1;
status = grib_set_long(gh, "gridDefinitionTemplateNumber", GRIBAPI_GTYPE_CELL);
status = grib_set_long(gh, "gridDefinitionTemplateNumber", GRIBAPI_GTYPE_NUMBER);
if ( status != 0 && warning )
{
warning = 0;
Warning("Can not write grid number!");
Warning("gridDefinitionTemplateNumber %d not found (grib2/template.3.%d.def)!",
GRIBAPI_GTYPE_CELL, GRIBAPI_GTYPE_CELL);
GRIBAPI_GTYPE_NUMBER, GRIBAPI_GTYPE_NUMBER);
}
else
{
GRIB_CHECK(grib_set_long(gh, "numberOfGridUsed", 0), 0);
GRIB_CHECK(grib_set_long(gh, "numberOfGridInReference", 0), 0);
GRIB_CHECK(grib_set_long(gh, "numberOfGridUsed", gridInqNumber(gridID)), 0);
GRIB_CHECK(grib_set_long(gh, "numberOfGridInReference", gridInqPosition(gridID)), 0);
}
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment