Commit 9fb3716f authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added support for LONLAT and CURVILINEAR grids.

parent 3b31cfbc
......@@ -235,20 +235,23 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
int gengridcell(int gridID1, int gridsize2, int *cellidx)
{
char xname[CDI_MAX_NAME], xlongname[CDI_MAX_NAME], xunits[CDI_MAX_NAME];
char yname[CDI_MAX_NAME], ylongname[CDI_MAX_NAME], yunits[CDI_MAX_NAME];
int gridID2 = -1;
int gridtype = gridInqType(gridID1);
int gridsize1 = gridInqSize(gridID1);
int prec = gridInqPrec(gridID1);
/* printf("gridsize1 = %d, gridsize2 = %d\n", gridsize1, gridsize2); */
int gridtype = gridInqType(gridID1);
int prec = gridInqPrec(gridID1);
if ( gridtype == GRID_CURVILINEAR ) gridtype = GRID_UNSTRUCTURED;
int gridID2 = gridCreate(gridtype, gridsize2);
if ( gridtype == GRID_UNSTRUCTURED )
gridID2 = gridCreate(gridtype, gridsize2);
else
return gridID2;
gridDefPrec(gridID2, prec);
char xname[CDI_MAX_NAME], xlongname[CDI_MAX_NAME], xunits[CDI_MAX_NAME];
char yname[CDI_MAX_NAME], ylongname[CDI_MAX_NAME], yunits[CDI_MAX_NAME];
gridInqXname(gridID1, xname);
gridInqXlongname(gridID1, xlongname);
gridInqXunits(gridID1, xunits);
......@@ -279,9 +282,6 @@ int gengridcell(int gridID1, int gridsize2, int *cellidx)
yvals2[i] = yvals1[cellidx[i]];
}
if ( cdoVerbose )
for ( int i = 0; i < gridsize2; i++ ) printf("lat/lon : %d %g %g\n", i+1, yvals2[i], xvals2[i]);
gridDefXvals(gridID2, xvals2);
gridDefYvals(gridID2, yvals2);
......
......@@ -34,14 +34,20 @@ int gengridcell(int gridID1, int gridsize2, int *cellidx);
static
int genindexgrid(int gridID1, int gridsize2, int *cellidx)
{
int gridID0 = gridID1;
int gridtype1 = gridInqType(gridID1);
int gridtype = (gridsize2 == 1) ? GRID_LONLAT : GRID_UNSTRUCTURED;
if ( gridtype1 == GRID_LONLAT || gridtype1 == GRID_GAUSSIAN || gridtype1 == GRID_PROJECTION )
{
gridID1 = gridToCurvilinear(gridID1, 0);
gridtype1 = GRID_CURVILINEAR;
}
int gridID2 = -1;
if ( gridtype1 == GRID_UNSTRUCTURED ) gridID2 = gengridcell(gridID1, gridsize2, cellidx);
if ( gridtype1 == GRID_UNSTRUCTURED || gridtype1 == GRID_CURVILINEAR )
gridID2 = gengridcell(gridID1, gridsize2, cellidx);
if ( gridID2 == -1 ) cdoAbort("Unsupported grid!");
if ( gridID0 != gridID1 ) gridDestroy(gridID1);
return gridID2;
}
......@@ -125,6 +131,12 @@ void *Selindex(void *argument)
}
gridID2 = genindexgrid(gridID1, nind, indarr);
if ( gridID2 == -1 )
{
cdoWarning("Unsupported grid type >%s<, skipped grid %d!", gridNamePtr(gridtype), index+1);
continue;
}
sindex[index].gridID1 = gridID1;
sindex[index].gridID2 = gridID2;
......
Supports Markdown
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