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

renamed GRID_NUMBER to GRID_REFERENCE

parent 8fb8573e
2011-02-06 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* vlistDestroy: fix memory leak [report: Luis Kornblueh]
* vlistDestroy: fix memory leak
2011-01-25 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......@@ -8,7 +8,7 @@
2011-01-21 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* added grid type GRID_NUMBER
* added grid type GRID_REFERENCE
* changed grid name GRID_CELL to GRID_UNSTRUCTURED
2011-01-19 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
......@@ -260,7 +260,7 @@ void printGridInfo(int vlistID)
nd = gridInqGMEnd(gridID);
fprintf(stdout, "size : dim = %d nd = %d ni = %d\n", gridsize, nd, ni);
}
else if ( gridtype == GRID_NUMBER )
else if ( gridtype == GRID_REFERENCE )
{
int number, position;
number = gridInqNumber(gridID);
......@@ -268,6 +268,13 @@ void printGridInfo(int vlistID)
fprintf(stdout, "size : dim = %d\n", gridsize);
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "grid : number = %d position = %d\n", number, position);
if ( gridInqReference(gridID, NULL) )
{
char reference_link[8192];
gridInqReference(gridID, reference_link);
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, "path : %s\n", reference_link);
}
}
else if ( gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED )
{
......
......@@ -126,7 +126,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 /* Number of grid */
#define GRID_REFERENCE 15 /* Reference to the grid */
/* ZAXIS types */
......@@ -622,11 +622,13 @@ void gridDefGMEni2(int gridID, int ni2);
int gridInqGMEni3(int gridID);
void gridDefGMEni3(int gridID, int ni3);
/* Number grid */
/* Reference grid */
int gridInqNumber(int gridID);
void gridDefNumber(int gridID, int number);
int gridInqPosition(int gridID);
void gridDefPosition(int gridID, int position);
int gridInqReference(int gridID, char *reference);
void gridDefReference(int gridID, const char *reference);
/* Lambert Conformal Conic grid (GRIB version) */
......
......@@ -36,7 +36,7 @@ char *Grids[] = {
/* 12 */ "lcc2",
/* 13 */ "laea",
/* 14 */ "sinusoidal",
/* 15 */ "number",
/* 15 */ "reference",
};
......@@ -210,6 +210,7 @@ void grid_init_entry(grid_t *gridptr)
gridptr->ni3 = 0;
gridptr->number = 0;
gridptr->position = 0;
gridptr->reference = NULL;
gridptr->prec = 0;
gridptr->size = 0;
gridptr->xsize = 0;
......@@ -476,7 +477,7 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
The valid CDI grid types are @func{GRID_GENERIC}, @func{GRID_GAUSSIAN},
@func{GRID_LONLAT}, @func{GRID_LCC}, @func{GRID_SPECTRAL},
@func{GRID_GME}, @func{GRID_CURVILINEAR}, @func{GRID_UNSTRUCTURED} and
@func{GRID_NUMBER}
@func{GRID_REFERENCE}
@Item size Number of gridpoints.
@Description
......@@ -627,14 +628,15 @@ void gridDestroy(int gridID)
grid_check_ptr(gridID, gridptr);
if ( gridptr->mask ) free(gridptr->mask);
if ( gridptr->mask_gme ) free(gridptr->mask_gme);
if ( gridptr->xvals ) free(gridptr->xvals);
if ( gridptr->yvals ) free(gridptr->yvals);
if ( gridptr->area ) free(gridptr->area);
if ( gridptr->xbounds ) free(gridptr->xbounds);
if ( gridptr->ybounds ) free(gridptr->ybounds);
if ( gridptr->rowlon ) free(gridptr->rowlon);
if ( gridptr->mask ) free(gridptr->mask);
if ( gridptr->mask_gme ) free(gridptr->mask_gme);
if ( gridptr->xvals ) free(gridptr->xvals);
if ( gridptr->yvals ) free(gridptr->yvals);
if ( gridptr->area ) free(gridptr->area);
if ( gridptr->xbounds ) free(gridptr->xbounds);
if ( gridptr->ybounds ) free(gridptr->ybounds);
if ( gridptr->rowlon ) free(gridptr->rowlon);
if ( gridptr->reference ) free(gridptr->reference);
grid_delete_entry(gridptr);
}
......@@ -1033,7 +1035,7 @@ The function @func{gridInqType} returns the type of a Grid.
one of the set of predefined CDI grid types.
The valid CDI grid types are @func{GRID_GENERIC}, @func{GRID_GAUSSIAN},
@func{GRID_LONLAT}, @func{GRID_LCC}, @func{GRID_SPECTRAL}, @func{GRID_GME},
@func{GRID_CURVILINEAR}, @func{GRID_UNSTRUCTURED} and @func{GRID_NUMBER}.
@func{GRID_CURVILINEAR}, @func{GRID_UNSTRUCTURED} and @func{GRID_REFERENCE}.
@EndFunction
*/
......@@ -2556,10 +2558,11 @@ int gridGenerate(grid_t grid)
gridDefGMEni3(gridID, grid.ni3);
break;
}
case GRID_NUMBER:
case GRID_REFERENCE:
{
gridDefNumber(gridID, grid.number);
gridDefPosition(gridID, grid.position);
if ( grid.reference ) gridDefReference(gridID, grid.reference);
break;
}
/*
......@@ -3378,10 +3381,16 @@ void gridPrint(int gridID, int opt)
fprintf(fp, "ni = %d\n", gridInqGMEni(gridID));
break;
}
case GRID_NUMBER:
case GRID_REFERENCE:
{
fprintf(fp, "number = %d\n", gridInqNumber(gridID));
fprintf(fp, "position = %d\n", gridInqPosition(gridID));
if ( gridInqReference(gridID, NULL) )
{
char reference_link[8192];
gridInqReference(gridID, reference_link);
fprintf(fp, "path = %d\n", reference_link);
}
break;
}
default:
......@@ -3707,3 +3716,45 @@ void gridDefPosition(int gridID, int position)
gridptr->position = position;
}
int gridInqReference(int gridID, char *reference)
{
grid_t *gridptr;
int len = 0;
gridptr = grid_to_pointer(gridID);
grid_check_ptr(gridID, gridptr);
if ( gridptr->reference )
{
len = (int) strlen(gridptr->reference);
if ( reference )
strcpy(reference, gridptr->reference);
}
return (len);
}
void gridDefReference(int gridID, const char *reference)
{
grid_t *gridptr;
gridptr = grid_to_pointer(gridID);
grid_check_ptr(gridID, gridptr);
if ( reference )
{
if ( gridptr->reference )
{
free(gridptr->reference);
gridptr->reference = NULL;
}
gridptr->reference = strdupx(reference);
}
}
......@@ -43,7 +43,8 @@ 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 number, position; /* parameter for GRID_REFERENCE */
char *reference;
int trunc; /* parameter for GRID_SPECTEAL */
int nvertex;
int *rowlon;
......
......@@ -1938,6 +1938,7 @@ int streamNtsteps(int streamID)
return (streamptr->ntsteps);
}
off_t streamNvals(int streamID)
{
stream_t *streamptr;
......
......@@ -107,7 +107,7 @@ int cgribexGetTimeUnit(int *isec1)
default:
if ( lprint )
{
Message("Time unit %d unsupported", ISEC1_TimeUnit);
Message("GRIB time unit %d unsupported!", ISEC1_TimeUnit);
lprint = FALSE;
}
}
......@@ -148,7 +148,7 @@ int cgribexGetTsteptype(int timerange)
default:
if ( lprint )
{
Message("Time range %d unsupported", timerange);
Message("GRIB time range %d unsupported!", timerange);
lprint = FALSE;
}
}
......
......@@ -84,7 +84,7 @@ int gribapiGetGridType(grib_handle *gh)
}
case GRIB2_GTYPE_SPECTRAL: { gridtype = GRID_SPECTRAL; break; }
case GRIB2_GTYPE_GME: { gridtype = GRID_GME; break; }
case GRIB2_GTYPE_NUMBER: { gridtype = GRID_NUMBER; break; }
case GRIB2_GTYPE_NUMBER: { gridtype = GRID_REFERENCE; break; }
}
}
......@@ -571,11 +571,17 @@ void gribapiAddRecord(int streamID, int param, grib_handle *gh,
break;
}
case GRID_NUMBER:
case GRID_REFERENCE:
{
char reference_link[8192];
size_t len = sizeof(reference_link);
reference_link[0] = 0;
grid.size = numberOfPoints;
if ( grib_get_long(gh, "numberOfGridUsed", &lpar) == 0 ) grid.number = lpar;
if ( grib_get_long(gh, "numberOfGridInReference", &lpar) == 0 ) grid.position = lpar;
if ( grib_get_string(gh, "gridDescriptionFile", reference_link, &len) == 0 )
grid.reference = strdupx(reference_link);
break;
}
......@@ -2012,7 +2018,7 @@ void gribapiDefGrid(grib_handle *gh, int gridID, int ljpeg)
GRIB_CHECK(grib_get_long(gh, "editionNumber", &editionNumber), 0);
if ( editionNumber <= 1 )
if ( gridtype == GRID_GME || gridtype == GRID_NUMBER )
if ( gridtype == GRID_GME || gridtype == GRID_REFERENCE )
gridtype = -1;
// ISEC1_GridDefinition = 255;
......@@ -2284,14 +2290,14 @@ void gribapiDefGrid(grib_handle *gh, int gridID, int ljpeg)
break;
}
case GRID_NUMBER:
case GRID_REFERENCE:
{
static int warning = 1;
status = grib_set_long(gh, "gridDefinitionTemplateNumber", GRIB2_GTYPE_NUMBER);
if ( status != 0 && warning )
{
warning = 0;
Warning("Can not write grid number!");
Warning("Can not write reference grid!");
Warning("gridDefinitionTemplateNumber %d not found (grib2/template.3.%d.def)!",
GRIB2_GTYPE_NUMBER, GRIB2_GTYPE_NUMBER);
}
......
......@@ -908,13 +908,16 @@ void vlistDefVarName(int vlistID, int varID, const char *name)
vlistCheckVarID(__func__, vlistID, varID);
if ( vlistptr->vars[varID].name )
if ( name )
{
free(vlistptr->vars[varID].name);
vlistptr->vars[varID].name = 0;
}
if ( vlistptr->vars[varID].name )
{
free(vlistptr->vars[varID].name);
vlistptr->vars[varID].name = NULL;
}
if ( name ) vlistptr->vars[varID].name = strdupx(name);
vlistptr->vars[varID].name = strdupx(name);
}
}
/*
......@@ -940,13 +943,16 @@ void vlistDefVarLongname(int vlistID, int varID, const char *longname)
vlistCheckVarID(__func__, vlistID, varID);
if ( vlistptr->vars[varID].longname )
if ( longname )
{
free(vlistptr->vars[varID].longname);
vlistptr->vars[varID].longname = 0;
}
if ( vlistptr->vars[varID].longname )
{
free(vlistptr->vars[varID].longname);
vlistptr->vars[varID].longname = 0;
}
if ( longname ) vlistptr->vars[varID].longname = strdupx(longname);
vlistptr->vars[varID].longname = strdupx(longname);
}
}
/*
......@@ -972,13 +978,16 @@ void vlistDefVarStdname(int vlistID, int varID, const char *stdname)
vlistCheckVarID(__func__, vlistID, varID);
if ( vlistptr->vars[varID].stdname )
if ( stdname )
{
free(vlistptr->vars[varID].stdname);
vlistptr->vars[varID].stdname = 0;
}
if ( vlistptr->vars[varID].stdname )
{
free(vlistptr->vars[varID].stdname);
vlistptr->vars[varID].stdname = 0;
}
if ( stdname ) vlistptr->vars[varID].stdname = strdupx(stdname);
vlistptr->vars[varID].stdname = strdupx(stdname);
}
}
/*
......@@ -1004,13 +1013,16 @@ void vlistDefVarUnits(int vlistID, int varID, const char *units)
vlistCheckVarID(__func__, vlistID, varID);
if ( vlistptr->vars[varID].units )
if ( units )
{
free(vlistptr->vars[varID].units);
vlistptr->vars[varID].units = 0;
}
if ( vlistptr->vars[varID].units )
{
free(vlistptr->vars[varID].units);
vlistptr->vars[varID].units = 0;
}
if ( units ) vlistptr->vars[varID].units = strdupx(units);
vlistptr->vars[varID].units = strdupx(units);
}
}
/*
......
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