Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix 1886 main_v10.0 grid_diag #1887

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) {
double delta = (max - min) / nbin;
double width = 10;

vector<int> pdf;
vector<long long> pdf;

init_pdf(nbin, pdf);

Expand Down
14 changes: 7 additions & 7 deletions met/src/libcode/vx_series_data/series_pdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

void init_pdf(
int n,
vector<int>& pdf) {
vector<long long>& pdf) {

for(int k = 0; k < n; k++) {
pdf.push_back(0);
Expand All @@ -35,7 +35,7 @@ void init_pdf(
double min,
double max,
double delta,
vector<int>& pdf) {
vector<long long>& pdf) {

int n = (max - min) / delta;
for(int k = 0; k < n; k++) {
Expand All @@ -48,7 +48,7 @@ void init_pdf(
void init_joint_pdf(
int n_A,
int n_B,
vector<int>& pdf) {
vector<long long>& pdf) {

for(int k = 0; k < n_A * n_B; k++) {
pdf.push_back(0);
Expand All @@ -60,7 +60,7 @@ void init_joint_pdf(
void update_pdf(
double min,
double delta,
vector<int>& pdf,
vector<long long>& pdf,
const DataPlane& dp,
const MaskPlane& mp) {

Expand All @@ -86,7 +86,7 @@ void update_joint_pdf(
double min_B,
double delta_A,
double delta_B,
vector<int>& pdf,
vector<long long>& pdf,
const DataPlane& dp_A,
const DataPlane& dp_B,
const MaskPlane& mp) {
Expand Down Expand Up @@ -115,7 +115,7 @@ void update_joint_pdf(
void print_pdf(
double min,
double delta,
const vector<int>& pdf) {
const vector<long long>& pdf) {

for(int k = 0; k < pdf.size(); k++) {
double bin_min = min + k * delta;
Expand All @@ -132,7 +132,7 @@ void write_nc_pdf(
const VarInfo& info,
double min,
double delta,
const vector<int>& pdf) {
const vector<long long>& pdf) {

vector<double> bin_min;
vector<double> bin_max;
Expand Down
14 changes: 7 additions & 7 deletions met/src/libcode/vx_series_data/series_pdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,29 @@ using namespace netCDF;

void init_pdf(
int n,
vector<int>& pdf);
vector<long long>& pdf);

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

void init_pdf(
double min,
double max,
double delta,
vector<int>& pdf);
vector<long long>& pdf);

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

void init_joint_pdf(
int n_A,
int n_B,
vector<int>& pdf);
vector<long long>& pdf);

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

void update_pdf(
double min,
double delta,
vector<int>& pdf,
vector<long long>& pdf,
const DataPlane&,
const MaskPlane&);

Expand All @@ -65,7 +65,7 @@ void update_joint_pdf(
double min_B,
double delta_A,
double delta_B,
vector<int>& pdf,
vector<long long>& pdf,
const DataPlane&,
const DataPlane&,
const MaskPlane&);
Expand All @@ -75,7 +75,7 @@ void update_joint_pdf(
void print_pdf(
double min,
double delta,
const vector<int>& pdf);
const vector<long long>& pdf);

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

Expand All @@ -84,7 +84,7 @@ void write_nc_pdf(
const VarInfo& info,
double min,
double delta,
const vector<int>& pdf);
const vector<long long>& pdf);

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

Expand Down
15 changes: 8 additions & 7 deletions met/src/tools/other/grid_diag/grid_diag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// 000 10/01/19 Fillmore New
// 001 07/28/20 Halley Gotway Updates for #1391.
// 002 03/04/21 Halley Gotway Bugfix #1694.
// 003 08/20/21 Halley Gotway Bugfix #1886 for integer overflow.
//
////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -426,7 +427,7 @@ void setup_histograms(void) {
<< "Initializing " << data_info->magic_str_attr()
<< " histogram with " << n_bins << " bins from "
<< min << " to " << max << ".\n";
histograms[i_var_str] = vector<int>();
histograms[i_var_str] = vector<long long>();
init_pdf(n_bins, histograms[i_var_str]);
} // for i_var
}
Expand Down Expand Up @@ -456,7 +457,7 @@ void setup_joint_histograms(void) {
<< "Initializing " << data_info->magic_str_attr() << "_"
<< joint_info->magic_str_attr() << " joint histogram with "
<< n_bins << " x " << n_joint_bins << " bins.\n";
joint_histograms[ij_var_str] = vector<int>();
joint_histograms[ij_var_str] = vector<long long>();

init_joint_pdf(n_bins, n_joint_bins,
joint_histograms[ij_var_str]);
Expand Down Expand Up @@ -568,7 +569,7 @@ void setup_nc_file(void) {
ConcatString hist_name("hist_");
hist_name.add(var_name);
NcDim var_dim = data_var_dims[i_var];
NcVar hist_var = add_var(nc_out, hist_name, ncInt, var_dim,
NcVar hist_var = add_var(nc_out, hist_name, ncInt64, var_dim,
deflate_level);
hist_vars.push_back(hist_var);

Expand Down Expand Up @@ -602,7 +603,7 @@ void setup_nc_file(void) {
dims.push_back(var_dim);
dims.push_back(joint_dim);

NcVar hist_var = add_var(nc_out, hist_name, ncInt, dims,
NcVar hist_var = add_var(nc_out, hist_name, ncInt64, dims,
deflate_level);
joint_hist_vars.push_back(hist_var);

Expand All @@ -620,7 +621,7 @@ void write_nc_var_int(const char *var_name, const char *long_name,
int n) {

// Add the variable
NcVar var = add_var(nc_out, var_name, ncInt);
NcVar var = add_var(nc_out, var_name, ncInt64);
add_att(&var, "long_name", long_name);

if(!put_nc_data(&var, &n)) {
Expand Down Expand Up @@ -650,7 +651,7 @@ void write_histograms(void) {
VarInfo *data_info = conf_info.data_info[i_var];
NcVar hist_var = hist_vars[i_var];

int *hist = histograms[i_var_str].data();
long long *hist = histograms[i_var_str].data();

hist_var.putVar(hist);
}
Expand All @@ -676,7 +677,7 @@ void write_joint_histograms(void) {
<< "VAR" << i_var << "_"
<< "VAR" << j_var;

int *hist = joint_histograms[ij_var_str].data();
long long *hist = joint_histograms[ij_var_str].data();

offsets.clear();
counts.clear();
Expand Down
4 changes: 2 additions & 2 deletions met/src/tools/other/grid_diag/grid_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ vector<double> var_mins;
vector<double> var_maxs;

// Variable histogram map
map<ConcatString, vector<int> > histograms;
map<ConcatString, vector<int> > joint_histograms;
map<ConcatString, vector<long long> > histograms;
map<ConcatString, vector<long long> > joint_histograms;
map<ConcatString, vector<double> > bin_mins;
map<ConcatString, vector<double> > bin_maxs;
map<ConcatString, vector<double> > bin_mids;
Expand Down