Commit 7c9e1bb0 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Eliminate branches.

* Now that the X/Y distinction is available for arithmetic, the offset can
  be computed.
parent 76537e0b
...@@ -506,11 +506,8 @@ cdfDefTrajLatLon(stream_t *streamptr, int gridID, int gridindex, ...@@ -506,11 +506,8 @@ cdfDefTrajLatLon(stream_t *streamptr, int gridID, int gridindex,
if ( dimlen != 1 ) if ( dimlen != 1 )
Error("%c size isn't 1 for %s grid!", dimtype, gridNamePtr(gridInqType(gridID))); Error("%c size isn't 1 for %s grid!", dimtype, gridNamePtr(gridInqType(gridID)));
int ncvarid = CDI_UNDEFID; int ncvarid
if ( dimtype == 'X' ) = ncgrid[gridindex].ncIDs[dimtype == 'X' ? CDF_DIMID_X : CDF_DIMID_Y];
ncvarid = ncgrid[gridindex].ncIDs[CDF_DIMID_X];
else
ncvarid = ncgrid[gridindex].ncIDs[CDF_DIMID_Y];
if ( ncvarid == CDI_UNDEFID ) if ( ncvarid == CDI_UNDEFID )
{ {
...@@ -528,10 +525,8 @@ cdfDefTrajLatLon(stream_t *streamptr, int gridID, int gridindex, ...@@ -528,10 +525,8 @@ cdfDefTrajLatLon(stream_t *streamptr, int gridID, int gridindex,
} }
ncgrid[gridindex].gridID = gridID; ncgrid[gridindex].gridID = gridID;
if ( dimtype == 'X' ) /* var ID for trajectory !!! */
ncgrid[gridindex].ncIDs[CDF_DIMID_X] = ncvarid; /* var ID for trajectory !!! */ ncgrid[gridindex].ncIDs[dimtype == 'X' ? CDF_DIMID_X : CDF_DIMID_Y] = ncvarid;
else
ncgrid[gridindex].ncIDs[CDF_DIMID_Y] = ncvarid; /* var ID for trajectory !!! */
} }
static static
...@@ -690,7 +685,8 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims, ...@@ -690,7 +685,8 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
if ( IS_EQUAL(inqVal(gridID0, 0), inqVal(gridID, 0)) && if ( IS_EQUAL(inqVal(gridID0, 0), inqVal(gridID, 0)) &&
IS_EQUAL(inqVal(gridID0, (int)dimlen-1), inqVal(gridID, (int)dimlen-1)) ) IS_EQUAL(inqVal(gridID0, (int)dimlen-1), inqVal(gridID, (int)dimlen-1)) )
{ {
dimID = (dimKey == CDI_KEY_XDIMNAME) ? ncgrid[index].ncIDs[CDF_DIMID_X] : ncgrid[index].ncIDs[CDF_DIMID_Y]; dimID = ncgrid[index].ncIDs[dimKey == CDI_KEY_XDIMNAME
? CDF_DIMID_X : CDF_DIMID_Y];
break; break;
} }
} }
...@@ -782,10 +778,8 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims, ...@@ -782,10 +778,8 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
} }
ncgrid[gridindex].gridID = gridID; ncgrid[gridindex].gridID = gridID;
if ( dimKey == CDI_KEY_XDIMNAME ) ncgrid[gridindex].ncIDs[dimKey == CDI_KEY_XDIMNAME
ncgrid[gridindex].ncIDs[CDF_DIMID_X] = dimID; ? CDF_DIMID_X : CDF_DIMID_Y] = dimID;
else
ncgrid[gridindex].ncIDs[CDF_DIMID_Y] = dimID;
} }
static static
...@@ -2077,8 +2071,8 @@ void cdfDefVars(stream_t *streamptr) ...@@ -2077,8 +2071,8 @@ void cdfDefVars(stream_t *streamptr)
for ( int index = 0; index < 2*ngrids; ++index ) for ( int index = 0; index < 2*ngrids; ++index )
{ {
streamptr->ncgrid[index].gridID = CDI_UNDEFID; streamptr->ncgrid[index].gridID = CDI_UNDEFID;
streamptr->ncgrid[index].ncIDs[CDF_DIMID_X] = CDI_UNDEFID; for (size_t i = 0; i < CDF_SIZE_ncIDs; ++i)
streamptr->ncgrid[index].ncIDs[CDF_DIMID_Y] = CDI_UNDEFID; streamptr->ncgrid[index].ncIDs[i] = CDI_UNDEFID;
streamptr->ncgrid[index].xvarID = CDI_UNDEFID; streamptr->ncgrid[index].xvarID = CDI_UNDEFID;
streamptr->ncgrid[index].yvarID = CDI_UNDEFID; streamptr->ncgrid[index].yvarID = CDI_UNDEFID;
streamptr->ncgrid[index].avarID = CDI_UNDEFID; streamptr->ncgrid[index].avarID = CDI_UNDEFID;
......
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