Commit 747295e3 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added CDI_KEY_MAPPING.

parent 17afa9e2
......@@ -266,189 +266,214 @@ void print_xyvals2D(int gridID, int dig)
}
static
void printGridInfo(int vlistID)
void printGridInfoKernel(int gridID, int index, bool lproj)
{
unsigned char uuidOfHGrid[CDI_UUID_SIZE];
int ngrids = vlistNgrids(vlistID);
for ( int index = 0; index < ngrids; index++ )
int gridtype = gridInqType(gridID);
if ( lproj && gridtype != GRID_PROJECTION )
fprintf(stderr, "Internal problem (%s): sub grid not equal GRID_PROJECTION!\n", __func__);
int trunc = gridInqTrunc(gridID);
int gridsize = gridInqSize(gridID);
int xsize = gridInqXsize(gridID);
int ysize = gridInqYsize(gridID);
int xysize = xsize*ysize;
// int prec = gridInqPrec(gridID);
// int dig = (prec == DATATYPE_FLT64) ? 15 : 7;
int dig = 7;
if ( lproj )
fprintf(stdout, " %24s", gridNamePtr(gridtype));
else
fprintf(stdout, " %4d : %-24s", index+1, gridNamePtr(gridtype));
if ( gridtype == GRID_LONLAT ||
gridtype == GRID_LCC2 ||
gridtype == GRID_LAEA ||
gridtype == GRID_SINUSOIDAL ||
gridtype == GRID_GENERIC ||
gridtype == GRID_GAUSSIAN ||
gridtype == GRID_GAUSSIAN_REDUCED )
{
int gridID = vlistGrid(vlistID, index);
int gridtype = gridInqType(gridID);
int trunc = gridInqTrunc(gridID);
int gridsize = gridInqSize(gridID);
int xsize = gridInqXsize(gridID);
int ysize = gridInqYsize(gridID);
int xysize = xsize*ysize;
// int prec = gridInqPrec(gridID);
// int dig = (prec == DATATYPE_FLT64) ? 15 : 7;
int dig = 7;
fprintf(stdout, " %4d : %-24s", index+1, gridNamePtr(gridtype));
if ( gridtype == GRID_LONLAT ||
gridtype == GRID_LCC2 ||
gridtype == GRID_LAEA ||
gridtype == GRID_SINUSOIDAL ||
gridtype == GRID_GENERIC ||
gridtype == GRID_GAUSSIAN ||
gridtype == GRID_GAUSSIAN_REDUCED )
{
fprintf(stdout, " : points=%d", gridsize);
if ( gridtype == GRID_GAUSSIAN_REDUCED )
fprintf(stdout, " nlat=%d", ysize);
else if ( xysize )
fprintf(stdout, " (%dx%d)", xsize, ysize);
fprintf(stdout, " : points=%d", gridsize);
if ( gridtype == GRID_GAUSSIAN_REDUCED )
fprintf(stdout, " nlat=%d", ysize);
else if ( xysize )
fprintf(stdout, " (%dx%d)", xsize, ysize);
if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED )
fprintf(stdout, " np=%d", gridInqNP(gridID));
if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED )
fprintf(stdout, " np=%d", gridInqNP(gridID));
fprintf(stdout, "\n");
fprintf(stdout, "\n");
print_xvals(gridID, dig);
print_yvals(gridID, dig);
print_xvals(gridID, dig);
print_yvals(gridID, dig);
if ( gridIsRotated(gridID) )
{
double lonpole = gridInqXpole(gridID);
double latpole = gridInqYpole(gridID);
double angle = gridInqAngle(gridID);
fprintf(stdout, "%33s : lon=%.*g lat=%.*g", "northpole", dig, lonpole, dig, latpole);
if ( IS_NOT_EQUAL(angle, 0) ) fprintf(stdout, " angle=%.*g", dig, angle);
fprintf(stdout, "\n");
}
if ( gridIsRotated(gridID) )
{
double lonpole = gridInqXpole(gridID);
double latpole = gridInqYpole(gridID);
double angle = gridInqAngle(gridID);
fprintf(stdout, "%33s : lon=%.*g lat=%.*g", "northpole", dig, lonpole, dig, latpole);
if ( IS_NOT_EQUAL(angle, 0) ) fprintf(stdout, " angle=%.*g", dig, angle);
fprintf(stdout, "\n");
}
if ( gridInqXbounds(gridID, NULL) || gridInqYbounds(gridID, NULL) )
{
fprintf(stdout, "%33s :", "available");
if ( gridInqXbounds(gridID, NULL) && gridInqYbounds(gridID, NULL) ) fprintf(stdout, " cellbounds");
if ( gridHasArea(gridID) ) fprintf(stdout, " area");
if ( gridInqMask(gridID, NULL) ) fprintf(stdout, " mask");
fprintf(stdout, "\n");
}
if ( gridInqXbounds(gridID, NULL) || gridInqYbounds(gridID, NULL) )
{
fprintf(stdout, "%33s :", "available");
if ( gridInqXbounds(gridID, NULL) && gridInqYbounds(gridID, NULL) ) fprintf(stdout, " cellbounds");
if ( gridHasArea(gridID) ) fprintf(stdout, " area");
if ( gridInqMask(gridID, NULL) ) fprintf(stdout, " mask");
fprintf(stdout, "\n");
}
if ( gridtype == GRID_LAEA )
{
double a, lon_0, lat_0;
gridInqLaea(gridID, &a, &lon_0, &lat_0);
fprintf(stdout, "%33s : a=%g lon_0=%g lat_0=%g\n", "projpar", a, lon_0, lat_0);
}
if ( gridtype == GRID_LAEA )
{
double a, lon_0, lat_0;
gridInqLaea(gridID, &a, &lon_0, &lat_0);
fprintf(stdout, "%33s : a=%g lon_0=%g lat_0=%g\n", "projpar", a, lon_0, lat_0);
}
if ( gridtype == GRID_LCC2 )
{
double a, lon_0, lat_0, lat_1, lat_2;
gridInqLcc2(gridID, &a, &lon_0, &lat_0, &lat_1, &lat_2);
fprintf(stdout, "%33s : a=%7.0f lon_0=%g lat_0=%g lat_1=%g lat_2=%g\n",
"projpar", a, lon_0, lat_0, lat_1, lat_2);
}
}
else if ( gridtype == GRID_SPECTRAL )
{
fprintf(stdout, " : points=%d nsp=%d truncation=%d", gridsize, gridsize/2, trunc);
if ( gridInqComplexPacking(gridID) ) fprintf(stdout, " complexPacking");
fprintf(stdout, "\n");
}
else if ( gridtype == GRID_FOURIER )
{
fprintf(stdout, " : points=%d nfc=%d truncation=%d\n", gridsize, gridsize/2, trunc);
}
else if ( gridtype == GRID_GME )
{
int ni = gridInqGMEni(gridID);
int nd = gridInqGMEnd(gridID);
fprintf(stdout, " : points=%d nd=%d ni=%d\n", gridsize, nd, ni);
}
else if ( gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED )
{
if ( gridtype == GRID_CURVILINEAR )
fprintf(stdout, " : points=%d (%dx%d)", gridsize, xsize, ysize);
else
fprintf(stdout, " : points=%d", gridsize);
if ( gridtype == GRID_LCC2 )
{
double a, lon_0, lat_0, lat_1, lat_2;
gridInqLcc2(gridID, &a, &lon_0, &lat_0, &lat_1, &lat_2);
fprintf(stdout, "%33s : a=%7.0f lon_0=%g lat_0=%g lat_1=%g lat_2=%g\n",
"projpar", a, lon_0, lat_0, lat_1, lat_2);
}
}
else if ( gridtype == GRID_SPECTRAL )
{
fprintf(stdout, " : points=%d nsp=%d truncation=%d", gridsize, gridsize/2, trunc);
if ( gridInqComplexPacking(gridID) ) fprintf(stdout, " complexPacking");
fprintf(stdout, "\n");
}
else if ( gridtype == GRID_FOURIER )
{
fprintf(stdout, " : points=%d nfc=%d truncation=%d\n", gridsize, gridsize/2, trunc);
}
else if ( gridtype == GRID_GME )
{
int ni = gridInqGMEni(gridID);
int nd = gridInqGMEnd(gridID);
fprintf(stdout, " : points=%d nd=%d ni=%d\n", gridsize, nd, ni);
}
else if ( gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED )
{
if ( gridtype == GRID_CURVILINEAR )
fprintf(stdout, " : points=%d (%dx%d)", gridsize, xsize, ysize);
else
fprintf(stdout, " : points=%d", gridsize);
if ( gridtype == GRID_UNSTRUCTURED && gridInqNvertex(gridID) > 0 )
fprintf(stdout, " nvertex=%d", gridInqNvertex(gridID));
if ( gridtype == GRID_UNSTRUCTURED && gridInqNvertex(gridID) > 0 )
fprintf(stdout, " nvertex=%d", gridInqNvertex(gridID));
fprintf(stdout, "\n");
fprintf(stdout, "\n");
if ( gridtype == GRID_UNSTRUCTURED )
{
int number = gridInqNumber(gridID);
int position = gridInqPosition(gridID);
if ( number > 0 )
fprintf(stdout, "%33s : number=%d position=%d\n", "grid", number, position);
if ( gridtype == GRID_UNSTRUCTURED )
{
int number = gridInqNumber(gridID);
int position = gridInqPosition(gridID);
if ( number > 0 )
fprintf(stdout, "%33s : number=%d position=%d\n", "grid", number, position);
if ( gridInqReference(gridID, NULL) )
{
char reference_link[8192];
gridInqReference(gridID, reference_link);
fprintf(stdout, "%33s : %s\n", "uri", reference_link);
}
if ( gridInqReference(gridID, NULL) )
{
char reference_link[8192];
gridInqReference(gridID, reference_link);
fprintf(stdout, "%33s : %s\n", "uri", reference_link);
}
}
print_xyvals2D(gridID, dig);
}
else if ( gridtype == GRID_LCC )
{
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
int projflag, scanflag;
print_xyvals2D(gridID, dig);
}
else if ( gridtype == GRID_LCC )
{
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
int projflag, scanflag;
gridInqLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
gridInqLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
fprintf(stdout, " : points=%d (%dx%d) ", gridsize, xsize, ysize);
if ( (projflag&128) == 0 )
fprintf(stdout, "North Pole\n");
else
fprintf(stdout, "South Pole\n");
fprintf(stdout, " : points=%d (%dx%d) ", gridsize, xsize, ysize);
if ( (projflag&128) == 0 )
fprintf(stdout, "North Pole\n");
else
fprintf(stdout, "South Pole\n");
fprintf(stdout, "%33s : originLon=%g originLat=%g lonParY=%g\n", " ", originLon, originLat, lonParY);
fprintf(stdout, "%33s : lat1=%g lat2=%g xinc=%g m yinc=%g m\n", " ", lat1, lat2, xincm, yincm);
}
else if ( gridtype == GRID_PROJECTION )
fprintf(stdout, "%33s : originLon=%g originLat=%g lonParY=%g\n", " ", originLon, originLat, lonParY);
fprintf(stdout, "%33s : lat1=%g lat2=%g xinc=%g m yinc=%g m\n", " ", lat1, lat2, xincm, yincm);
}
else if ( gridtype == GRID_PROJECTION )
{
if ( lproj )
{
if ( ysize == 0 )
fprintf(stdout, " : points=%d\n", gridsize);
else
fprintf(stdout, " : points=%d (%dx%d)\n", gridsize, xsize, ysize);
print_xvals(gridID, dig);
print_yvals(gridID, dig);
char name[CDI_MAX_NAME]; name[0] = 0;
cdiGridInqKeyStr(gridID, CDI_KEY_MAPPING, CDI_MAX_NAME, name);
if ( name[0] == 0 ) strcpy(name, "undefined");
fprintf(stdout, " : %s\n", name);
}
else /* if ( gridtype == GRID_GENERIC ) */
{
if ( ysize == 0 )
fprintf(stdout, " : points=%d\n", gridsize);
else
else
{
if ( ysize == 0 )
fprintf(stdout, " : points=%d\n", gridsize);
else
fprintf(stdout, " : points=%d (%dx%d)\n", gridsize, xsize, ysize);
}
}
if ( gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED || gridtype == GRID_LCC )
{
if ( gridHasArea(gridID) ||
gridInqXbounds(gridID, NULL) || gridInqYbounds(gridID, NULL) )
{
fprintf(stdout, "%33s :", "available");
if ( gridInqXbounds(gridID, NULL) && gridInqYbounds(gridID, NULL) ) fprintf(stdout, " cellbounds");
if ( gridHasArea(gridID) ) fprintf(stdout, " area");
if ( gridInqMask(gridID, NULL) ) fprintf(stdout, " mask");
fprintf(stdout, "\n");
}
}
print_xvals(gridID, dig);
print_yvals(gridID, dig);
}
else /* if ( gridtype == GRID_GENERIC ) */
{
if ( ysize == 0 )
fprintf(stdout, " : points=%d\n", gridsize);
else
fprintf(stdout, " : points=%d (%dx%d)\n", gridsize, xsize, ysize);
}
gridInqUUID(gridID, uuidOfHGrid);
if ( !cdiUUIDIsNull(uuidOfHGrid) )
if ( gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED || gridtype == GRID_LCC )
{
if ( gridHasArea(gridID) ||
gridInqXbounds(gridID, NULL) || gridInqYbounds(gridID, NULL) )
{
char uuidOfHGridStr[37];
cdiUUID2Str(uuidOfHGrid, uuidOfHGridStr);
if ( uuidOfHGridStr[0] != 0 && strlen(uuidOfHGridStr) == 36 )
{
fprintf(stdout, "%33s : %s\n", "uuid", uuidOfHGridStr);
}
fprintf(stdout, "%33s :", "available");
if ( gridInqXbounds(gridID, NULL) && gridInqYbounds(gridID, NULL) ) fprintf(stdout, " cellbounds");
if ( gridHasArea(gridID) ) fprintf(stdout, " area");
if ( gridInqMask(gridID, NULL) ) fprintf(stdout, " mask");
fprintf(stdout, "\n");
}
}
unsigned char uuidOfHGrid[CDI_UUID_SIZE];
gridInqUUID(gridID, uuidOfHGrid);
if ( !cdiUUIDIsNull(uuidOfHGrid) )
{
char uuidOfHGridStr[37];
cdiUUID2Str(uuidOfHGrid, uuidOfHGridStr);
if ( uuidOfHGridStr[0] != 0 && strlen(uuidOfHGridStr) == 36 )
{
fprintf(stdout, "%33s : %s\n", "uuid", uuidOfHGridStr);
}
}
}
static
void printGridInfo(int vlistID)
{
int ngrids = vlistNgrids(vlistID);
for ( int index = 0; index < ngrids; index++ )
{
int gridID = vlistGrid(vlistID, index);
printGridInfoKernel(gridID, index, false);
int projID = gridInqProj(gridID);
if ( projID != CDI_UNDEFID )
printGridInfoKernel(projID, index, true);
}
}
static
void printZaxisInfo(int vlistID)
{
......
......@@ -769,6 +769,7 @@ int gridInqYvals(int gridID, double yvals[]);
#define CDI_KEY_YLONGNAME 907 // Y-axis longname
#define CDI_KEY_XUNITS 908 // X-axis units
#define CDI_KEY_YUNITS 909 // Y-axis units
#define CDI_KEY_MAPPING 920 // Grid mapping name
// cdiGridDefKeyStr: Define a CDI grid string value from a key
int cdiGridDefKeyStr(int gridID, int key, int size, const char *mesg);
......
......@@ -621,6 +621,7 @@ void *grid_key_to_ptr(grid_t *gridptr, int key)
case CDI_KEY_XDIMNAME: keyptr = (void*)gridptr->x.dimname; break;
case CDI_KEY_YDIMNAME: keyptr = (void*)gridptr->y.dimname; break;
case CDI_KEY_VDIMNAME: keyptr = (void*)gridptr->vdimname; break;
case CDI_KEY_MAPPING: keyptr = (void*)gridptr->mapping; break;
}
return keyptr;
......
......@@ -123,6 +123,7 @@ struct grid_t {
bool lcomplex;
bool hasdims;
char vdimname[CDI_MAX_NAME];
char mapping[CDI_MAX_NAME];
char *name;
struct gridaxis_t x;
struct gridaxis_t y;
......
......@@ -2659,6 +2659,7 @@ void cdf_define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int
{
cdfGetAttText(ncid, gmapvarid, "grid_mapping_name", attstringlen, attstring);
printf("grid_mapping_name: %s\n", attstring);
cdiGridDefKeyStr(projID, CDI_KEY_MAPPING, (int)(strlen(attstring)+1), attstring);
}
else
{
......
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