Commit 6f73055c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Selbox: changed memcmp to strncmp

parent 64029f0a
......@@ -117,18 +117,18 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
{
if ( lxvals && lyvals )
{
xvals1 = malloc(nlon1*nlat1*sizeof(double));
yvals1 = malloc(nlon1*nlat1*sizeof(double));
xvals2 = malloc(nlon2*nlat2*sizeof(double));
yvals2 = malloc(nlon2*nlat2*sizeof(double));
xvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
yvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
xvals2 = (double*) malloc(nlon2*nlat2*sizeof(double));
yvals2 = (double*) malloc(nlon2*nlat2*sizeof(double));
}
}
else
{
if ( lxvals ) xvals1 = malloc(nlon1*sizeof(double));
if ( lyvals ) yvals1 = malloc(nlat1*sizeof(double));
if ( lxvals ) xvals2 = malloc(nlon2*sizeof(double));
if ( lyvals ) yvals2 = malloc(nlat2*sizeof(double));
if ( lxvals ) xvals1 = (double*) malloc(nlon1*sizeof(double));
if ( lyvals ) yvals1 = (double*) malloc(nlat1*sizeof(double));
if ( lxvals ) xvals2 = (double*) malloc(nlon2*sizeof(double));
if ( lyvals ) yvals2 = (double*) malloc(nlat2*sizeof(double));
}
pxvals2 = xvals2;
......@@ -160,7 +160,7 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
{
for ( i = lon21; i <= lon22; i++ ) *pxvals2++ = xvals1[i];
for ( i = lon11; i <= lon12; i++ ) *pxvals2++ = xvals1[i];
if ( memcmp(xunits, "degree", 6) == 0 ) correct_xvals(nlon2, 1, xvals2);
if ( strncmp(xunits, "degree", 6) == 0 ) correct_xvals(nlon2, 1, xvals2);
}
if ( lyvals ) for ( i = lat1; i <= lat2; i++ ) *pyvals2++ = yvals1[i];
......@@ -181,17 +181,17 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
{
if ( gridtype == GRID_CURVILINEAR )
{
xbounds1 = malloc(4*nlon1*nlat1*sizeof(double));
ybounds1 = malloc(4*nlon1*nlat1*sizeof(double));
xbounds2 = malloc(4*nlon2*nlat2*sizeof(double));
ybounds2 = malloc(4*nlon2*nlat2*sizeof(double));
xbounds1 = (double*) malloc(4*nlon1*nlat1*sizeof(double));
ybounds1 = (double*) malloc(4*nlon1*nlat1*sizeof(double));
xbounds2 = (double*) malloc(4*nlon2*nlat2*sizeof(double));
ybounds2 = (double*) malloc(4*nlon2*nlat2*sizeof(double));
}
else
{
xbounds1 = malloc(2*nlon1*sizeof(double));
ybounds1 = malloc(2*nlat1*sizeof(double));
xbounds2 = malloc(2*nlon2*sizeof(double));
ybounds2 = malloc(2*nlat2*sizeof(double));
xbounds1 = (double*) malloc(2*nlon1*sizeof(double));
ybounds1 = (double*) malloc(2*nlat1*sizeof(double));
xbounds2 = (double*) malloc(2*nlon2*sizeof(double));
ybounds2 = (double*) malloc(2*nlat2*sizeof(double));
}
pxbounds2 = xbounds2;
......@@ -224,7 +224,7 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
for ( i = 2*lon11; i < 2*(lon12+1); i++ ) *pxbounds2++ = xbounds1[i];
for ( i = 2*lat1; i < 2*(lat2+1); i++ ) *pybounds2++ = ybounds1[i];
if ( memcmp(xunits, "degree", 6) == 0 )
if ( strncmp(xunits, "degree", 6) == 0 )
{
correct_xvals(nlon2, 2, xbounds2);
correct_xvals(nlon2, 2, xbounds2+1);
......@@ -284,10 +284,10 @@ int gengridcell(int gridID1, int gridsize2, int *cellidx)
if ( gridInqXvals(gridID1, NULL) && gridInqYvals(gridID1, NULL) )
{
xvals1 = malloc(gridsize1*sizeof(double));
yvals1 = malloc(gridsize1*sizeof(double));
xvals2 = malloc(gridsize2*sizeof(double));
yvals2 = malloc(gridsize2*sizeof(double));
xvals1 = (double*) malloc(gridsize1*sizeof(double));
yvals1 = (double*) malloc(gridsize1*sizeof(double));
xvals2 = (double*) malloc(gridsize2*sizeof(double));
yvals2 = (double*) malloc(gridsize2*sizeof(double));
gridInqXvals(gridID1, xvals1);
gridInqYvals(gridID1, yvals1);
......@@ -314,10 +314,10 @@ int gengridcell(int gridID1, int gridsize2, int *cellidx)
{
nv = gridInqNvertex(gridID1);
xbounds1 = malloc(nv*gridsize1*sizeof(double));
ybounds1 = malloc(nv*gridsize1*sizeof(double));
xbounds2 = malloc(nv*gridsize2*sizeof(double));
ybounds2 = malloc(nv*gridsize2*sizeof(double));
xbounds1 = (double*) malloc(nv*gridsize1*sizeof(double));
ybounds1 = (double*) malloc(nv*gridsize1*sizeof(double));
xbounds2 = (double*) malloc(nv*gridsize2*sizeof(double));
ybounds2 = (double*) malloc(nv*gridsize2*sizeof(double));
gridInqXbounds(gridID1, xbounds1);
gridInqYbounds(gridID1, ybounds1);
......@@ -444,13 +444,13 @@ void genlonlatbox(int argc_offset, int gridID1, int *lat1, int *lat2, int *lon11
if ( gridtype == GRID_CURVILINEAR )
{
xvals1 = malloc(nlon1*nlat1*sizeof(double));
yvals1 = malloc(nlon1*nlat1*sizeof(double));
xvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
yvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
}
else
{
xvals1 = malloc(nlon1*sizeof(double));
yvals1 = malloc(nlat1*sizeof(double));
xvals1 = (double*) malloc(nlon1*sizeof(double));
yvals1 = (double*) malloc(nlat1*sizeof(double));
}
gridInqXvals(gridID1, xvals1);
......@@ -459,8 +459,8 @@ void genlonlatbox(int argc_offset, int gridID1, int *lat1, int *lat2, int *lon11
gridInqXunits(gridID1, xunits);
gridInqYunits(gridID1, yunits);
if ( memcmp(xunits, "radian", 6) == 0 ) xfact = RAD2DEG;
if ( memcmp(yunits, "radian", 6) == 0 ) yfact = RAD2DEG;
if ( strncmp(xunits, "radian", 6) == 0 ) xfact = RAD2DEG;
if ( strncmp(yunits, "radian", 6) == 0 ) yfact = RAD2DEG;
if ( gridtype == GRID_CURVILINEAR )
{
......@@ -592,7 +592,7 @@ int gencellgrid(int gridID1, int *gridsize2, int **cellidx)
int cellinc = 4096;
char xunits[CDI_MAX_NAME];
char yunits[CDI_MAX_NAME];
double xfact, yfact;
double xfact = 1, yfact = 1;
int argc_offset = 0;
operatorCheckArgc(argc_offset+4);
......@@ -611,8 +611,8 @@ int gencellgrid(int gridID1, int *gridsize2, int **cellidx)
if ( gridtype != GRID_UNSTRUCTURED ) cdoAbort("Internal problem, wrong grid type!");
xvals1 = malloc(gridsize1*sizeof(double));
yvals1 = malloc(gridsize1*sizeof(double));
xvals1 = (double*) malloc(gridsize1*sizeof(double));
yvals1 = (double*) malloc(gridsize1*sizeof(double));
gridInqXvals(gridID1, xvals1);
gridInqYvals(gridID1, yvals1);
......@@ -620,15 +620,8 @@ int gencellgrid(int gridID1, int *gridsize2, int **cellidx)
gridInqXunits(gridID1, xunits);
gridInqYunits(gridID1, yunits);
if ( memcmp(xunits, "radian", 6) == 0 )
xfact = RAD2DEG;
else
xfact = 1;
if ( memcmp(yunits, "radian", 6) == 0 )
yfact = RAD2DEG;
else
yfact = 1;
if ( strncmp(xunits, "radian", 6) == 0 ) xfact = RAD2DEG;
if ( strncmp(yunits, "radian", 6) == 0 ) yfact = RAD2DEG;
/* find gridsize2 */
*cellidx = NULL;
......@@ -859,11 +852,11 @@ void *Selbox(void *argument)
vlistDefTaxis(vlistID2, taxisID2);
nvars = vlistNvars(vlistID1);
vars = malloc(nvars*sizeof(int));
vars = (int*) malloc(nvars*sizeof(int));
for ( varID = 0; varID < nvars; varID++ ) vars[varID] = FALSE;
ngrids = vlistNgrids(vlistID1);
sbox = malloc(ngrids*sizeof(sbox_t));
sbox = (sbox_t*) malloc(ngrids*sizeof(sbox_t));
for ( index = 0; index < ngrids; index++ )
{
......@@ -925,11 +918,11 @@ void *Selbox(void *argument)
gridsize = vlistGridsizeMax(vlistID1);
if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
array1 = malloc(gridsize*sizeof(double));
array1 = (double*) malloc(gridsize*sizeof(double));
gridsize2 = vlistGridsizeMax(vlistID2);
if ( vlistNumber(vlistID2) != CDI_REAL ) gridsize2 *= 2;
array2 = malloc(gridsize2*sizeof(double));
array2 = (double*) malloc(gridsize2*sizeof(double));
tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
......
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