Skip to content

Commit

Permalink
Per #2724, revert back the premature changes in engine.cc. There is l…
Browse files Browse the repository at this point in the history
…ikely a way to make the memory usage for efficient but it'll require a tweak to the logic.
  • Loading branch information
JohnHalleyGotway committed Nov 3, 2023
1 parent 042bf4f commit 5bdf1bd
Showing 1 changed file with 93 additions and 33 deletions.
126 changes: 93 additions & 33 deletions src/libcode/vx_shapedata/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1033,21 +1033,32 @@ void ModeFuzzyEngine::do_matching() {

void ModeFuzzyEngine::do_no_match() {
int j, k, n;
ShapeData cur_shape;
ShapeData * fcst_shape = (ShapeData *) 0;
ShapeData * obs_shape = (ShapeData *) 0;

do_fcst_splitting();
do_obs_splitting();

clear_colors();

fcst_shape = new ShapeData [n_fcst];
obs_shape = new ShapeData [n_obs];

if(!fcst_shape || !obs_shape) {

mlog << Error << "\nModeFuzzyEngine::do_no_match() -> "
<< "memory allocation error\n\n";
exit(1);
}

//
// Do the single features
//
fcst_single.set_size(n_fcst);

for(j=0; j<n_fcst; j++) {
cur_shape = select(*fcst_split, j+1);
fcst_single[j].set(*fcst_raw, *fcst_thresh, cur_shape,
fcst_shape[j] = select(*fcst_split, j+1);
fcst_single[j].set(*fcst_raw, *fcst_thresh, fcst_shape[j],
conf_info.inten_perc_value,
conf_info.Fcst->var_info->is_precipitation());
fcst_single[j].object_number = j+1;
Expand All @@ -1056,8 +1067,8 @@ void ModeFuzzyEngine::do_no_match() {
obs_single.set_size(n_obs);

for(j=0; j<n_obs; j++) {
cur_shape = select(*obs_split, j+1);
obs_single[j].set(*obs_raw, *obs_thresh, cur_shape,
obs_shape[j] = select(*obs_split, j+1);
obs_single[j].set(*obs_raw, *obs_thresh, obs_shape[j],
conf_info.inten_perc_value,
conf_info.Obs->var_info->is_precipitation());
obs_single[j].object_number = j+1;
Expand Down Expand Up @@ -1101,6 +1112,9 @@ void ModeFuzzyEngine::do_no_match() {
// Done
//

delete [] fcst_shape; fcst_shape = (ShapeData *) 0;
delete [] obs_shape; obs_shape = (ShapeData *) 0;

return;
}

Expand All @@ -1109,21 +1123,32 @@ void ModeFuzzyEngine::do_no_match() {
void ModeFuzzyEngine::do_match_merge() {
int j, k, n;
InterestInfo junkinfo;
ShapeData cur_shape;
ShapeData * fcst_shape = (ShapeData *) 0;
ShapeData * obs_shape = (ShapeData *) 0;

do_fcst_splitting();
do_obs_splitting();

clear_colors();

fcst_shape = new ShapeData [n_fcst];
obs_shape = new ShapeData [n_obs];

if(!fcst_shape || !obs_shape) {

mlog << Error << "\nModeFuzzyEngine::do_match_merge() -> "
<< "memory allocation error\n\n";
exit(1);
}

//
// Do the single features
//
fcst_single.set_size(n_fcst);

for(j=0; j<n_fcst; j++) {
cur_shape = select(*fcst_split, j+1);
fcst_single[j].set(*fcst_raw, *fcst_thresh, cur_shape,
fcst_shape[j] = select(*fcst_split, j+1);
fcst_single[j].set(*fcst_raw, *fcst_thresh, fcst_shape[j],
conf_info.inten_perc_value,
conf_info.Fcst->var_info->is_precipitation());
fcst_single[j].object_number = j+1;
Expand All @@ -1132,8 +1157,8 @@ void ModeFuzzyEngine::do_match_merge() {
obs_single.set_size(n_obs);

for(j=0; j<n_obs; j++) {
cur_shape = select(*obs_split, j+1);
obs_single[j].set(*obs_raw, *obs_thresh, cur_shape,
obs_shape[j] = select(*obs_split, j+1);
obs_single[j].set(*obs_raw, *obs_thresh, obs_shape[j],
conf_info.inten_perc_value,
conf_info.Obs->var_info->is_precipitation());
obs_single[j].object_number = j+1;
Expand Down Expand Up @@ -1252,6 +1277,9 @@ void ModeFuzzyEngine::do_match_merge() {
// Done
//

delete [] fcst_shape; fcst_shape = (ShapeData *) 0;
delete [] obs_shape; obs_shape = (ShapeData *) 0;

return;
}

Expand All @@ -1268,8 +1296,6 @@ void ModeFuzzyEngine::do_fcst_merge_thresh() {
int n_fcst_merge, intersection;
int count, first_k;
ShapeData fcst_merge_mask, fcst_merge_split;

// JHG, can this be fixed?
ShapeData * fcst_shape = (ShapeData *) 0;
ShapeData * fcst_merge_shape = (ShapeData *) 0;

Expand Down Expand Up @@ -1393,7 +1419,6 @@ void ModeFuzzyEngine::do_obs_merge_thresh() {
int n_obs_merge, intersection;
int count, first_k;
ShapeData obs_merge_mask, obs_merge_split;
// JHG can this be fixed?
ShapeData * obs_shape = (ShapeData *) 0;
ShapeData * obs_merge_shape = (ShapeData *) 0;

Expand Down Expand Up @@ -1503,15 +1528,13 @@ void ModeFuzzyEngine::do_obs_merge_thresh() {
return;
}

///////////////////////////////////////////////////////////////////////

void ModeFuzzyEngine::do_fcst_merge_thresh(const ShapeData &merge_data) {
int j, k, x, y;
int n_fcst_merge, intersection;
int count, first_k;
//ShapeData fcst_merge_mask;
ShapeData fcst_merge_split;
// JHG can this be fixed?
ShapeData * fcst_shape = (ShapeData *) 0;
ShapeData * fcst_merge_shape = (ShapeData *) 0;

Expand Down Expand Up @@ -1626,15 +1649,12 @@ void ModeFuzzyEngine::do_fcst_merge_thresh(const ShapeData &merge_data) {
return;
}

///////////////////////////////////////////////////////////////////////

void ModeFuzzyEngine::do_obs_merge_thresh(const ShapeData &merge_data) {
int j, k, x, y;
int n_obs_merge, intersection;
int count, first_k;
//ShapeData obs_merge_mask;
ShapeData obs_merge_split;
// JHG can this be fixed?
ShapeData * obs_shape = (ShapeData *) 0;
ShapeData * obs_merge_shape = (ShapeData *) 0;

Expand Down Expand Up @@ -2094,21 +2114,31 @@ void ModeFuzzyEngine::do_obs_merge_engine(const char *default_config,
void ModeFuzzyEngine::do_match_fcst_merge() {
int j, k, n;
InterestInfo junkinfo;
ShapeData cur_shape;
ShapeData * fcst_shape = (ShapeData *) 0;
ShapeData * obs_shape = (ShapeData *) 0;

do_fcst_splitting();
do_obs_splitting();

clear_colors();

fcst_shape = new ShapeData [n_fcst];
obs_shape = new ShapeData [n_obs];

if(!fcst_shape || !obs_shape) {
mlog << Error << "\nModeFuzzyEngine::do_match_fcst_merge() -> "
<< "memory allocation error\n\n";
exit(1);
}

//
// Do the single features
//
fcst_single.set_size(n_fcst);

for(j=0; j<n_fcst; j++) {
cur_shape = select(*fcst_split, j+1);
fcst_single[j].set(*fcst_raw, *fcst_thresh, cur_shape,
fcst_shape[j] = select(*fcst_split, j+1);
fcst_single[j].set(*fcst_raw, *fcst_thresh, fcst_shape[j],
conf_info.inten_perc_value,
conf_info.Fcst->var_info->is_precipitation());
fcst_single[j].object_number = j+1;
Expand All @@ -2117,8 +2147,8 @@ void ModeFuzzyEngine::do_match_fcst_merge() {
obs_single.set_size(n_obs);

for(j=0; j<n_obs; j++) {
cur_shape = select(*obs_split, j+1);
obs_single[j].set(*obs_raw, *obs_thresh, cur_shape,
obs_shape[j] = select(*obs_split, j+1);
obs_single[j].set(*obs_raw, *obs_thresh, obs_shape[j],
conf_info.inten_perc_value,
conf_info.Obs->var_info->is_precipitation());
obs_single[j].object_number = j+1;
Expand Down Expand Up @@ -2245,6 +2275,9 @@ void ModeFuzzyEngine::do_match_fcst_merge() {
// Done
//

delete [] fcst_shape; fcst_shape = (ShapeData *) 0;
delete [] obs_shape; obs_shape = (ShapeData *) 0;

return;
}

Expand All @@ -2258,21 +2291,31 @@ void ModeFuzzyEngine::do_match_fcst_merge() {
void ModeFuzzyEngine::do_match_only() {
int j, k, n;
InterestInfo junkinfo;
ShapeData cur_shape;
ShapeData * fcst_shape = (ShapeData *) 0;
ShapeData * obs_shape = (ShapeData *) 0;

do_fcst_splitting();
do_obs_splitting();

clear_colors();

fcst_shape = new ShapeData [n_fcst];
obs_shape = new ShapeData [n_obs];

if(!fcst_shape || !obs_shape) {
mlog << Error << "\nModeFuzzyEngine::do_match_only() -> "
<< "memory allocation error\n\n";
exit(1);
}

//
// Do the single features
//
fcst_single.set_size(n_fcst);

for(j=0; j<n_fcst; j++) {
cur_shape = select(*fcst_split, j+1);
fcst_single[j].set(*fcst_raw, *fcst_thresh, cur_shape,
fcst_shape[j] = select(*fcst_split, j+1);
fcst_single[j].set(*fcst_raw, *fcst_thresh, fcst_shape[j],
conf_info.inten_perc_value,
conf_info.Fcst->var_info->is_precipitation());
fcst_single[j].object_number = j+1;
Expand All @@ -2281,8 +2324,8 @@ void ModeFuzzyEngine::do_match_only() {
obs_single.set_size(n_obs);

for(j=0; j<n_obs; j++) {
cur_shape = select(*obs_split, j+1);
obs_single[j].set(*obs_raw, *obs_thresh, cur_shape,
obs_shape[j] = select(*obs_split, j+1);
obs_single[j].set(*obs_raw, *obs_thresh, obs_shape[j],
conf_info.inten_perc_value,
conf_info.Obs->var_info->is_precipitation());
obs_single[j].object_number = j+1;
Expand Down Expand Up @@ -2403,6 +2446,9 @@ void ModeFuzzyEngine::do_match_only() {
// Done
//

delete [] fcst_shape; fcst_shape = (ShapeData *) 0;
delete [] obs_shape; obs_shape = (ShapeData *) 0;

return;
}

Expand Down Expand Up @@ -2491,7 +2537,8 @@ void ModeFuzzyEngine::do_obs_clus_splitting() {

void ModeFuzzyEngine::do_cluster_features() {
int j;
ShapeData cur_shape;
ShapeData * fcst_clus_shape = (ShapeData *) 0;
ShapeData * obs_clus_shape = (ShapeData *) 0;

if(need_fcst_clus_split) do_fcst_clus_splitting();
if(need_obs_clus_split) do_obs_clus_splitting();
Expand All @@ -2501,21 +2548,31 @@ void ModeFuzzyEngine::do_cluster_features() {
//
n_clus = collection.n_sets;

fcst_clus_shape = new ShapeData [n_clus];
obs_clus_shape = new ShapeData [n_clus];

if(!fcst_clus_shape || !obs_clus_shape) {

mlog << Error << "\nModeFuzzyEngine::do_cluster_features() -> "
<< "memory allocation error\n\n";
exit(1);
}

//
// Do the single features for clusters
//
fcst_cluster.set_size(n_clus);
obs_cluster.set_size(n_clus);

for(j=0; j<n_clus; j++) {
cur_shape = select(*fcst_clus_split, j+1);
fcst_cluster[j].set(*fcst_raw, *fcst_thresh, cur_shape,
fcst_clus_shape[j] = select(*fcst_clus_split, j+1);
fcst_cluster[j].set(*fcst_raw, *fcst_thresh, fcst_clus_shape[j],
conf_info.inten_perc_value,
conf_info.Fcst->var_info->is_precipitation());
fcst_cluster[j].object_number = j+1;

cur_shape = select(*obs_clus_split, j+1);
obs_cluster[j].set(*obs_raw, *obs_thresh, cur_shape,
obs_clus_shape[j] = select(*obs_clus_split, j+1);
obs_cluster[j].set(*obs_raw, *obs_thresh, obs_clus_shape[j],
conf_info.inten_perc_value,
conf_info.Obs->var_info->is_precipitation());
obs_cluster[j].object_number = j+1;
Expand Down Expand Up @@ -2550,6 +2607,9 @@ void ModeFuzzyEngine::do_cluster_features() {
// Done
//

delete [] fcst_clus_shape; fcst_clus_shape = (ShapeData *) 0;
delete [] obs_clus_shape; obs_clus_shape = (ShapeData *) 0;

return;
}

Expand Down

0 comments on commit 5bdf1bd

Please sign in to comment.