Skip to content

Commit

Permalink
Per issue #2232, added some new global variables to keep track of uni…
Browse files Browse the repository at this point in the history
…que output variables names. SL ci-skip-all
  • Loading branch information
Seth Linden committed Oct 25, 2022
1 parent 011f6ab commit 5fcae49
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/tools/other/grid_diag/grid_diag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ void process_command_line(int argc, char **argv) {
conf_info.read_config(default_config_file.c_str(),
config_file.c_str());

cout << "CHECK1" << endl;

// Determine the number of data fields
conf_info.set_n_data();

Expand All @@ -179,6 +181,8 @@ void process_command_line(int argc, char **argv) {
// Process the input data file lists
for(int i=0; i<data_files.size(); i++) {

cout << "CHECK2, inside loop over data files" << endl;

// Parse the data file list
data_files[i] = parse_file_list(data_files[i]);

Expand Down Expand Up @@ -210,10 +214,14 @@ void process_command_line(int argc, char **argv) {
}

} // end for i


cout << "CHECK3" << endl;

// Process the configuration
conf_info.process_config(file_types);

cout << "CHECK4" << endl;

// Determine the verification grid
grid = parse_vx_grid(conf_info.data_info[0]->regrid(),
&data_grid, &data_grid);
Expand Down Expand Up @@ -443,8 +451,14 @@ 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<long long>();
init_pdf(n_bins, histograms[i_var_str]);

// Keep track of unique output variable names
if(nc_var_sa.has( data_info->magic_str_attr() )) unique_variable_names = false;
nc_var_sa.add(data_info->magic_str_attr());

} // for i_var
}

Expand Down Expand Up @@ -529,11 +543,20 @@ void setup_nc_file(void) {

VarInfo *data_info = conf_info.data_info[i_var];


// This is the section we need to fix SL

cout << "multiple_data_sources = " << multiple_data_sources << endl;
cout << "unique_variable_names = " << unique_variable_names << endl;

// Set variable NetCDF name
ConcatString var_name = data_info->name_attr();
cout << "Initial var_name = " << var_name << endl;
var_name.add("_");
var_name.add(data_info->level_attr());
cout << "Output var_name = " << var_name << endl;


// Define histogram dimensions
NcDim var_dim = add_dim(nc_out, var_name,
(long) data_info->n_bins());
Expand Down Expand Up @@ -816,6 +839,7 @@ void usage() {

void set_data_files(const StringArray & a) {
data_files.push_back(a);
if(data_files.size() > 0) multiple_data_sources = true;
}

////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 6 additions & 0 deletions src/tools/other/grid_diag/grid_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ vector<netCDF::NcDim> data_var_dims;
vector<netCDF::NcVar> hist_vars;
vector<netCDF::NcVar> joint_hist_vars;

static bool multiple_data_sources = false;
static bool unique_variable_names = true;

// List of output NetCDF variable names
static StringArray nc_var_sa;

////////////////////////////////////////////////////////////////////////
//
// Miscellaneous Variables
Expand Down

0 comments on commit 5fcae49

Please sign in to comment.