Commit fda6564b authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

remapgrid_alloc: replace Realloc by Malloc

parent a2ec60a8
......@@ -102,7 +102,7 @@ struct kdNode *gs_create_kdtree(unsigned n, const double *restrict lons, const d
{
struct kd_point *pointlist = (struct kd_point *) Malloc(n * sizeof(struct kd_point));
// see example_cartesian.c
if ( cdoVerbose) printf("kdtree lib init 3D: n=%d nthreads=%d\n", n, ompNumThreads);
if ( cdoVerbose ) printf("kdtree lib init 3D: n=%d nthreads=%d\n", n, ompNumThreads);
float min[3], max[3];
min[0] = min[1] = min[2] = 1e9;
max[0] = max[1] = max[2] = -1e9;
......@@ -315,6 +315,7 @@ unsigned gs_nearest_nearpt3(struct gsNear *near, double lon, double lat, double
unsigned index = GS_NOT_FOUND;
if ( near == NULL ) return index;
#if defined(ENABLE_NEARPT3)
float range0 = gs_set_range(prange);
float point[3];
......@@ -325,7 +326,6 @@ unsigned gs_nearest_nearpt3(struct gsNear *near, double lon, double lat, double
q[1] = NPT3SCALE(point[1]);
q[2] = NPT3SCALE(point[2]);
#if defined(ENABLE_NEARPT3)
int closestpt = nearpt3_query(near->nearpt3, q);
if ( closestpt >= 0 )
......@@ -340,6 +340,10 @@ unsigned gs_nearest_nearpt3(struct gsNear *near, double lon, double lat, double
*prange = range;
}
}
#else
UNUSED(lon);
UNUSED(lat);
UNUSED(prange);
#endif
return index;
......
......@@ -16,7 +16,7 @@
void remapgrid_init(remapgrid_t *grid);
void remapGridRealloc(int map_type, remapgrid_t *grid);
void remapgrid_alloc(int map_type, remapgrid_t *grid);
#if defined(HAVE_LIBNETCDF)
......@@ -633,8 +633,8 @@ void read_remap_scrip(const char *interp_file, int gridID1, int gridID2, int *ma
gridID1_gme_c = gridToUnstructured(gridID1, 1);
}
remapGridRealloc(rv->map_type, src_grid);
remapGridRealloc(rv->map_type, tgt_grid);
remapgrid_alloc(rv->map_type, src_grid);
remapgrid_alloc(rv->map_type, tgt_grid);
if ( gridInqType(gridID1) == GRID_GME ) gridInqMaskGME(gridID1_gme_c, src_grid->vgpm);
......
......@@ -184,28 +184,28 @@ void remapgrid_init(remapgrid_t *grid)
/*****************************************************************************/
void remapGridRealloc(int map_type, remapgrid_t *grid)
void remapgrid_alloc(int map_type, remapgrid_t *grid)
{
long nalloc;
if ( grid->nvgp )
grid->vgpm = (int*) Realloc(grid->vgpm, grid->nvgp*sizeof(int));
grid->vgpm = (int*) Malloc(grid->nvgp*sizeof(int));
grid->mask = (int*) Realloc(grid->mask, grid->size*sizeof(int));
grid->mask = (int*) Malloc(grid->size*sizeof(int));
if ( remap_write_remap == TRUE || grid->remap_grid_type != REMAP_GRID_TYPE_REG2D )
{
grid->cell_center_lon = (double*) Realloc(grid->cell_center_lon, grid->size*sizeof(double));
grid->cell_center_lat = (double*) Realloc(grid->cell_center_lat, grid->size*sizeof(double));
grid->cell_center_lon = (double*) Malloc(grid->size*sizeof(double));
grid->cell_center_lat = (double*) Malloc(grid->size*sizeof(double));
}
if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONSERV_YAC )
{
grid->cell_area = (double*) Realloc(grid->cell_area, grid->size*sizeof(double));
grid->cell_area = (double*) Malloc(grid->size*sizeof(double));
memset(grid->cell_area, 0, grid->size*sizeof(double));
}
grid->cell_frac = (double*) Realloc(grid->cell_frac, grid->size*sizeof(double));
grid->cell_frac = (double*) Malloc(grid->size*sizeof(double));
memset(grid->cell_frac, 0, grid->size*sizeof(double));
if ( grid->lneed_cell_corners )
......@@ -218,10 +218,10 @@ void remapGridRealloc(int map_type, remapgrid_t *grid)
{
nalloc = grid->num_cell_corners*grid->size;
grid->cell_corner_lon = (double*) Realloc(grid->cell_corner_lon, nalloc*sizeof(double));
grid->cell_corner_lon = (double*) Malloc(nalloc*sizeof(double));
memset(grid->cell_corner_lon, 0, nalloc*sizeof(double));
grid->cell_corner_lat = (double*) Realloc(grid->cell_corner_lat, nalloc*sizeof(double));
grid->cell_corner_lat = (double*) Malloc(nalloc*sizeof(double));
memset(grid->cell_corner_lat, 0, nalloc*sizeof(double));
}
}
......@@ -687,7 +687,7 @@ void remap_define_grid(int map_type, int gridID, remapgrid_t *grid)
else
grid->num_cell_corners = 4;
remapGridRealloc(map_type, grid);
remapgrid_alloc(map_type, grid);
/* Initialize logical mask */
......@@ -1057,7 +1057,6 @@ void resize_remap_vars(remapvars_t *rv, int increment)
} /* resize_remap_vars */
/*
-----------------------------------------------------------------------
......
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