Skip to content

Commit

Permalink
#1795 Create DataCube for 2D or 3D only, not both to avoid memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Soh committed May 21, 2021
1 parent 8d9128c commit c8449c3
Showing 1 changed file with 38 additions and 34 deletions.
72 changes: 38 additions & 34 deletions met/src/tools/tc_utils/rmw_analysis/rmw_analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,48 +243,52 @@ void setup() {
// Initialize statistical data cube lists
for(int i_var = 0; i_var < data_names.size(); i_var++) {

// Size data cubes
DataCube* data_count_2d = new DataCube();
DataCube* data_count_3d = new DataCube();
DataCube* data_mean_2d = new DataCube();
DataCube* data_mean_3d = new DataCube();
DataCube* data_stdev_2d = new DataCube();
DataCube* data_stdev_3d = new DataCube();
DataCube* data_max_2d = new DataCube();
DataCube* data_max_3d = new DataCube();
DataCube* data_min_2d = new DataCube();
DataCube* data_min_3d = new DataCube();

data_count_2d->set_size(n_range, n_azimuth, 1);
data_count_3d->set_size(n_range, n_azimuth, n_level);
data_mean_2d->set_size(n_range, n_azimuth, 1);
data_mean_3d->set_size(n_range, n_azimuth, n_level);
data_stdev_2d->set_size(n_range, n_azimuth, 1);
data_stdev_3d->set_size(n_range, n_azimuth, n_level);
data_max_2d->set_size(n_range, n_azimuth, 1);
data_max_3d->set_size(n_range, n_azimuth, n_level);
data_min_2d->set_size(n_range, n_azimuth, 1);
data_min_3d->set_size(n_range, n_azimuth, n_level);

data_count_2d->set_constant(0);
data_count_3d->set_constant(0);
data_mean_2d->set_constant(0);
data_mean_3d->set_constant(0);
data_stdev_2d->set_constant(0);
data_stdev_3d->set_constant(0);
data_max_2d->set_constant(-1.0e6);
data_max_3d->set_constant(-1.0e6);
data_min_2d->set_constant(1.0e6);
data_min_3d->set_constant(1.0e6);

if (data_n_dims[i_var] == 2) {
// Size data cubes
DataCube* data_count_2d = new DataCube();
DataCube* data_mean_2d = new DataCube();
DataCube* data_stdev_2d = new DataCube();
DataCube* data_max_2d = new DataCube();
DataCube* data_min_2d = new DataCube();

data_count_2d->set_size(n_range, n_azimuth, 1);
data_mean_2d->set_size(n_range, n_azimuth, 1);
data_stdev_2d->set_size(n_range, n_azimuth, 1);
data_max_2d->set_size(n_range, n_azimuth, 1);
data_min_2d->set_size(n_range, n_azimuth, 1);

data_count_2d->set_constant(0);
data_mean_2d->set_constant(0);
data_stdev_2d->set_constant(0);
data_max_2d->set_constant(-1.0e6);
data_min_2d->set_constant(1.0e6);

data_counts.push_back(data_count_2d);
data_means.push_back(data_mean_2d);
data_stdevs.push_back(data_stdev_2d);
data_mins.push_back(data_min_2d);
data_maxs.push_back(data_max_2d);
}
if (data_n_dims[i_var] == 3) {
// Size data cubes
DataCube* data_count_3d = new DataCube();
DataCube* data_mean_3d = new DataCube();
DataCube* data_stdev_3d = new DataCube();
DataCube* data_max_3d = new DataCube();
DataCube* data_min_3d = new DataCube();

data_count_3d->set_size(n_range, n_azimuth, n_level);
data_mean_3d->set_size(n_range, n_azimuth, n_level);
data_stdev_3d->set_size(n_range, n_azimuth, n_level);
data_max_3d->set_size(n_range, n_azimuth, n_level);
data_min_3d->set_size(n_range, n_azimuth, n_level);

data_count_3d->set_constant(0);
data_mean_3d->set_constant(0);
data_stdev_3d->set_constant(0);
data_max_3d->set_constant(-1.0e6);
data_min_3d->set_constant(1.0e6);

data_counts.push_back(data_count_3d);
data_means.push_back(data_mean_3d);
data_stdevs.push_back(data_stdev_3d);
Expand Down

0 comments on commit c8449c3

Please sign in to comment.