Commit 54df264b authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Limit scope of variable and shorten statements.

parent ef1d63a6
...@@ -4721,7 +4721,6 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva ...@@ -4721,7 +4721,6 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
int ncvarid, ncvarid2; int ncvarid, ncvarid2;
int i; int i;
int nvatts; int nvatts;
int skipvar;
char name[CDI_MAX_NAME]; char name[CDI_MAX_NAME];
int iatt; int iatt;
int ltwarn = TRUE; int ltwarn = TRUE;
...@@ -4889,7 +4888,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva ...@@ -4889,7 +4888,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
if ( xvarid != UNDEFID ) if ( xvarid != UNDEFID )
{ {
skipvar = TRUE; bool skipvar = true;
islon = ncvars[xvarid].islon; islon = ncvars[xvarid].islon;
ndims = ncvars[xvarid].ndims; ndims = ncvars[xvarid].ndims;
if ( ndims == 2 || ndims == 3 ) if ( ndims == 2 || ndims == 3 )
...@@ -4897,29 +4896,24 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva ...@@ -4897,29 +4896,24 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
ncvars[ncvarid].gridtype = GRID_CURVILINEAR; ncvars[ncvarid].gridtype = GRID_CURVILINEAR;
size = xsize*ysize; size = xsize*ysize;
/* Check size of 2 dimensional coordinate variables */ /* Check size of 2 dimensional coordinate variables */
{ int dimid = ncvars[xvarid].dimids[ndims-2];
int dimid = ncvars[xvarid].dimids[ndims-2]; size_t dimsize1 = ncdims[dimid].len;
size_t dimsize1 = ncdims[dimid].len; dimid = ncvars[xvarid].dimids[ndims-1];
dimid = ncvars[xvarid].dimids[ndims-1]; size_t dimsize2 = ncdims[dimid].len;
size_t dimsize2 = ncdims[dimid].len; skipvar = dimsize1*dimsize2 != size;
if ( dimsize1*dimsize2 == size ) skipvar = FALSE;
}
} }
else if ( ndims == 1 ) else if ( ndims == 1 )
{ {
size = xsize; size = xsize;
/* Check size of 1 dimensional coordinate variables */ /* Check size of 1 dimensional coordinate variables */
{ int dimid = ncvars[xvarid].dimids[0];
int dimid = ncvars[xvarid].dimids[0]; size_t dimsize = ncdims[dimid].len;
size_t dimsize = ncdims[dimid].len; skipvar = dimsize != size;
if ( dimsize == size ) skipvar = FALSE;
}
} }
else if ( ndims == 0 && xsize == 0 ) else if ( ndims == 0 && xsize == 0 )
{ {
xsize = 1; size = xsize = 1;
size = xsize; skipvar = false;
skipvar = FALSE;
} }
if ( skipvar ) if ( skipvar )
...@@ -4955,7 +4949,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva ...@@ -4955,7 +4949,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
if ( yvarid != UNDEFID ) if ( yvarid != UNDEFID )
{ {
skipvar = TRUE; bool skipvar = true;
islat = ncvars[yvarid].islat; islat = ncvars[yvarid].islat;
ndims = ncvars[yvarid].ndims; ndims = ncvars[yvarid].ndims;
if ( ndims == 2 || ndims == 3 ) if ( ndims == 2 || ndims == 3 )
...@@ -4970,7 +4964,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva ...@@ -4970,7 +4964,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
dimsize1 = ncdims[dimid].len; dimsize1 = ncdims[dimid].len;
dimid = ncvars[yvarid].dimids[ndims-1]; dimid = ncvars[yvarid].dimids[ndims-1];
dimsize2 = ncdims[dimid].len; dimsize2 = ncdims[dimid].len;
if ( dimsize1*dimsize2 == size ) skipvar = FALSE; skipvar = dimsize1*dimsize2 != size;
} }
} }
else if ( ndims == 1 ) else if ( ndims == 1 )
...@@ -4984,14 +4978,13 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva ...@@ -4984,14 +4978,13 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
size_t dimsize; size_t dimsize;
dimid = ncvars[yvarid].dimids[0]; dimid = ncvars[yvarid].dimids[0];
dimsize = ncdims[dimid].len; dimsize = ncdims[dimid].len;
if ( dimsize == size ) skipvar = FALSE; skipvar = dimsize != size;
} }
} }
else if ( ndims == 0 && ysize == 0 ) else if ( ndims == 0 && ysize == 0 )
{ {
ysize = 1; size = ysize = 1;
size = ysize; skipvar = false;
skipvar = FALSE;
} }
if ( skipvar ) if ( skipvar )
......
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