diff --git a/docs/Contributors_Guide/dev_details/tmp_file_use.rst b/docs/Contributors_Guide/dev_details/tmp_file_use.rst index cb5703c53f..3e2525abdb 100644 --- a/docs/Contributors_Guide/dev_details/tmp_file_use.rst +++ b/docs/Contributors_Guide/dev_details/tmp_file_use.rst @@ -39,23 +39,17 @@ those observations, and writes the result to a NetCDF output file. PB2NC creates the following temporary files when running: -* :code:`tmp_pb2nc_blk_{PID}`, :code:`tmp_pb2nc_meta_blk_{PID}`, - :code:`tmp_pb2nc_tbl_blk_{PID}` +* :code:`tmp_pb2nc_blk_{PID}` PB2NC assumes that each input binary file requires Fortran blocking prior to being read by the BUFRLIB library. It applies Fortran blocking, writes the result to this temporary file, and uses BUFRLIB to read its contents. -* :code:`tmp_pb2nc_bufr_{PID}_tbl`: PB2NC extracts Bufr table data +* :code:`tmp_pb2nc_blk_{PID}_tbl`: PB2NC extracts Bufr table data that is embedded in input files and writes it to this temporary file for later use. -.. note:: - The first 3 files listed above are identical. They are all - Fortran-blocked versions of the same input file. Recommend - modifying the logic to only apply Fortran blocking once. - .. _tmp_files_point2grid: Point2Grid Tool diff --git a/src/basic/vx_cal/time_array.h b/src/basic/vx_cal/time_array.h index baa834675f..807aec977e 100644 --- a/src/basic/vx_cal/time_array.h +++ b/src/basic/vx_cal/time_array.h @@ -20,6 +20,8 @@ #include +typedef long long unixtime; + //////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_cal/vx_cal.h b/src/basic/vx_cal/vx_cal.h index 1784cfb5d1..f7d553a55b 100644 --- a/src/basic/vx_cal/vx_cal.h +++ b/src/basic/vx_cal/vx_cal.h @@ -19,9 +19,6 @@ #include "concat_string.h" - -typedef long long unixtime; - #include "time_array.h" diff --git a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc index 6a7cfaef48..36c5479921 100644 --- a/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc +++ b/src/libcode/vx_data2d_nc_cf/data2d_nc_cf.cc @@ -77,7 +77,7 @@ MetNcCFDataFile & MetNcCFDataFile::operator=(const MetNcCFDataFile &) { void MetNcCFDataFile::nccf_init_from_scratch() { - _file = (NcCfFile *) 0; + _file = (NcCfFile *) nullptr; _cur_time_index = -1; close(); diff --git a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc index 3de1882c7a..5018f62e8c 100644 --- a/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc +++ b/src/libcode/vx_data2d_nc_cf/nc_cf_file.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -23,7 +21,6 @@ using namespace std; #include #include -using namespace netCDF; #include "vx_math.h" #include "vx_cal.h" @@ -31,6 +28,9 @@ using namespace netCDF; #include "nc_cf_file.h" +using namespace std; +using namespace netCDF; + //////////////////////////////////////////////////////////////////////// @@ -221,7 +221,6 @@ bool NcCfFile::open(const char * filepath) Nvars = get_var_names(_ncFile, &varNames); Var = new NcVarInfo [Nvars]; - NcDim dim; for (int j=0; jValidTime.n(); static const string method_name = "MetUGridDataFile::data_plane(VarInfo &, DataPlane &) -> "; @@ -229,15 +228,13 @@ bool MetUGridDataFile::data_plane(VarInfo &vinfo, DataPlane &plane, NcVarInfo *d plane.clear(); - int zdim_slot = bad_data_int; - int time_dim_slot = bad_data_int; NumArray dim_value = vinfo_nc->dim_value(); LongArray dimension(vinfo_nc->dimension()); BoolArray is_offset(vinfo_nc->is_offset()); if (nullptr != data_var) { - zdim_slot = data_var->z_slot; - time_dim_slot = data_var->t_slot; + int zdim_slot = data_var->z_slot; + int time_dim_slot = data_var->t_slot; // Adjust dimension and is_offset int dim_size = dimension.n_elements(); @@ -310,7 +307,6 @@ int MetUGridDataFile::data_plane_array(VarInfo &vinfo, DataPlaneArray &plane_array) { int n_rec = 0; DataPlane plane; - bool status = false; static const string method_name = "MetUGridDataFile::data_plane_array(VarInfo &, DataPlaneArray &) -> "; @@ -320,7 +316,6 @@ int MetUGridDataFile::data_plane_array(VarInfo &vinfo, LevelInfo level = vinfo.level(); long lvl_lower = level.lower(); long lvl_upper = level.upper(); - const int debug_level = 7; ConcatString req_name = vinfo.req_name(); NcVarInfo *data_vinfo = _file->find_by_name(req_name.c_str()); if (level.type() == LevelType_Time) { @@ -328,6 +323,7 @@ int MetUGridDataFile::data_plane_array(VarInfo &vinfo, << "LevelType_Time for unstructured grid is not enabled\n\n"; exit(1); /* Not enabled + const int debug_level = 7; LongArray time_offsets = collect_time_offsets(vinfo); if (0 < time_offsets.n_elements()) { for (int idx=0; idxz_slot >= 0) { int zdim_size = get_dim_size(data_vinfo->var, data_vinfo->z_slot); if (tmp_lower >= zdim_size) tmp_lower = zdim_size - 1; diff --git a/src/libcode/vx_data2d_ugrid/ugrid_file.cc b/src/libcode/vx_data2d_ugrid/ugrid_file.cc index 13cfde1f6f..21d5a2227d 100644 --- a/src/libcode/vx_data2d_ugrid/ugrid_file.cc +++ b/src/libcode/vx_data2d_ugrid/ugrid_file.cc @@ -195,7 +195,6 @@ bool UGridFile::open(const char * filepath) bool UGridFile::open_metadata(const char * filepath) { unixtime ut = 0; - int sec_per_unit; const char *method_name = "UGridFile::open_metadata() -> "; // Open the file @@ -319,6 +318,8 @@ bool UGridFile::open_metadata(const char * filepath) ValidTime.add(ut); } else { + int sec_per_unit; + // Store the dimension for the time variable as the time dimension ConcatString units; bool use_bounds_var = false; @@ -374,7 +375,6 @@ bool UGridFile::open_metadata(const char * filepath) else { if (use_bounds_var) { double bounds_diff; - double time_fraction; for(int i=0; i observations, const bool do_header) { int prev_hdr_idx = -1; - string prev_header_type = ""; - string prev_station_id = ""; ConcatString obs_qty; int headerOffset = data_buffer.cur_hdr_idx; const string method_name = " write_obs_data()"; diff --git a/src/libcode/vx_nc_util/nc_utils.cc b/src/libcode/vx_nc_util/nc_utils.cc index 2cd3e9aa56..6a86c236b5 100644 --- a/src/libcode/vx_nc_util/nc_utils.cc +++ b/src/libcode/vx_nc_util/nc_utils.cc @@ -199,9 +199,9 @@ bool get_att_value_chars(const NcAtt *att, ConcatString &value) { att->getValues(att_value); value = att_value[0]; } - catch (exceptions::NcException &ex) { + catch (exceptions::NcException &ex2) { mlog << Warning << "\n" << method_name - << "Exception: " << ex.what() << "\n" + << "Exception: " << ex2.what() << "\n" << "Fail to read " << GET_NC_NAME_P(att) << " attribute (" << GET_NC_TYPE_NAME_P(att) << " type).\n" << "Please check the encoding of the "<< GET_NC_NAME_P(att) << " attribute.\n\n"; @@ -1273,7 +1273,7 @@ float get_float_var(NcVar * var, const int index) { exit(1); } } - else if ((index > dim_size) && (0 < dim_size)){ + else if (index > dim_size){ NcDim nc_dim = get_nc_dim(var, dim_idx); mlog << Error << "\n" << method_name << "The start offset (" << index << ") exceeds the dimension " << dim_size << " " @@ -1391,11 +1391,10 @@ bool get_nc_data(NcVar *var, float *data) { { double *packed_data = new double[cell_count]; if (get_nc_data_t(var, packed_data)) { - double a_data; double fill_value; bool has_fill_value = get_var_fill_value(var, fill_value); for (int idx=0; idxisNull())) +#define IS_VALID_NC_P(ncObjPtr) ((ncObjPtr != nullptr && !ncObjPtr->isNull())) #define IS_INVALID_NC(ncObj) ncObj.isNull() -#define IS_INVALID_NC_P(ncObjPtr) (ncObjPtr == 0 || ncObjPtr->isNull()) +#define IS_INVALID_NC_P(ncObjPtr) (ncObjPtr == nullptr || ncObjPtr->isNull()) #define GET_NC_NAME(ncObj) ncObj.getName() #define GET_NC_NAME_P(ncObjPtr) ncObjPtr->getName() diff --git a/src/libcode/vx_nc_util/nc_utils.hpp b/src/libcode/vx_nc_util/nc_utils.hpp index 9c87db76cb..4a6c0a1a92 100644 --- a/src/libcode/vx_nc_util/nc_utils.hpp +++ b/src/libcode/vx_nc_util/nc_utils.hpp @@ -396,7 +396,7 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, T met_missing, const long dim, co exit(1); } } - else if (((cur+dim) > dim_size) && (0 < dim_size)) { + else if ((cur+dim) > dim_size) { netCDF::NcDim nc_dim = get_nc_dim(var, dim_idx); mlog << Error << "\n" << method_name << "The start offset and count (" << cur << " + " << dim << ") exceeds the dimension " << dim_size << " " @@ -433,7 +433,7 @@ bool get_nc_data_(netCDF::NcVar *var, T *data, T met_missing, const long dim, co template bool get_nc_data_(netCDF::NcVar *var, T *data, T bad_data, const LongArray &curs) { bool return_status = false; - const char *method_name = "get_nc_data_(*curs) "; + //const char *method_name = "get_nc_data_(*curs) "; if (IS_VALID_NC_P(var)) { @@ -559,11 +559,12 @@ void copy_nc_data_t(netCDF::NcVar *var, double *data, const T *packed_data, const int cell_count, const char *data_type, double add_offset, double scale_factor, bool has_missing, T missing_value) { - int unpacked_count = 0; const char *method_name = "copy_nc_data_t(double) "; if (cell_count > 0) { - int idx, first_idx; + int idx; + int first_idx; + int unpacked_count = 0; double min_value, max_value; bool do_scale_factor = has_scale_factor_attr(var) || has_add_offset_attr(var); diff --git a/src/libcode/vx_nc_util/write_netcdf.cc b/src/libcode/vx_nc_util/write_netcdf.cc index a3614167cb..b9d5e2bdc5 100644 --- a/src/libcode/vx_nc_util/write_netcdf.cc +++ b/src/libcode/vx_nc_util/write_netcdf.cc @@ -9,7 +9,6 @@ /////////////////////////////////////////////////////////////////////////////// -using namespace std; #include #include @@ -21,7 +20,6 @@ using namespace std; #include #include -using namespace netCDF; #include "vx_log.h" #include "vx_cal.h" @@ -29,6 +27,9 @@ using namespace netCDF; #include "write_netcdf.h" #include "grid_output.h" +using namespace std; +using namespace netCDF; + /////////////////////////////////////////////////////////////////////////////// static void write_netcdf_latlon_1d(NcFile *, NcDim *, NcDim *, const Grid &); @@ -107,10 +108,13 @@ void write_netcdf_latlon(NcFile *f_out, NcDim *lat_dim, NcDim *lon_dim, void write_netcdf_latlon_1d(NcFile *f_out, NcDim *lat_dim, NcDim *lon_dim, const Grid &grid) { int i; - double lat, lon; - NcVar lat_var, lon_var; - float *lat_data = (float *) 0; - float *lon_data = (float *) 0; + double lat; + double lon; + NcVar lat_var; + NcVar lon_var; + // Allocate space for lat/lon values + float *lat_data = new float [grid.ny()]; + float *lon_data = new float [grid.nx()]; // Define Variables lat_var = f_out->addVar("lat", ncFloat, *lat_dim); @@ -125,10 +129,6 @@ void write_netcdf_latlon_1d(NcFile *f_out, NcDim *lat_dim, NcDim *lon_dim, add_att(&lon_var, units_att_name, "degrees_east"); add_att(&lon_var, standard_name_att_name, "longitude"); - // Allocate space for lat/lon values - lat_data = new float [grid.ny()]; - lon_data = new float [grid.nx()]; - // Compute latitude values for(i=0; igetSize(), 0); - if ( lat_data ) { delete [] lat_data; lat_data = 0; } - if ( lon_data ) { delete [] lon_data; lon_data = 0; } + if ( lat_data ) { delete [] lat_data; lat_data = nullptr; } + if ( lon_data ) { delete [] lon_data; lon_data = nullptr; } return; } @@ -160,11 +160,12 @@ void write_netcdf_latlon_2d(NcFile *f_out, NcDim *lat_dim, NcDim *lon_dim, int i, x, y; double lat, lon; NcVar lat_var, lon_var; - float *lat_data = (float *) 0; - float *lon_data = (float *) 0; vector dims; long counts[2] = {grid.ny(), grid.nx()}; long offsets[2] = {0 , 0}; + // Allocate space for lat/lon values + float *lat_data = new float [grid.nx()*grid.ny()]; + float *lon_data = new float [grid.nx()*grid.ny()]; // Define Variables dims.push_back(*lat_dim); @@ -181,10 +182,6 @@ void write_netcdf_latlon_2d(NcFile *f_out, NcDim *lat_dim, NcDim *lon_dim, add_att(&lon_var, units_att_name, "degrees_east"); add_att(&lon_var, standard_name_att_name, "longitude"); - // Allocate space for lat/lon values - lat_data = new float [grid.nx()*grid.ny()]; - lon_data = new float [grid.nx()*grid.ny()]; - // Compute lat/lon values for(x=0; x dims; vector count; + // Allocate space for weight values + float *wgt_data = new float [wgt_dp.nx()*wgt_dp.ny()]; // Define Variables dims.push_back(*lat_dim); @@ -247,12 +244,10 @@ void write_netcdf_grid_weight(NcFile *f_out, NcDim *lat_dim, NcDim *lon_dim, break; } - // Allocate space for weight values - wgt_data = new float [wgt_dp.nx()*wgt_dp.ny()]; // Store weight values - for(x=0; x #include #include @@ -24,6 +22,8 @@ using namespace std; #include "vx_log.h" #include "copy_bytes.h" +using namespace std; + ////////////////////////////////////////////////////////////////////////////////// @@ -40,15 +40,12 @@ void copy_bytes(int in, int out, int N) { -int bytes, bytes_left; -int n_read, n_written; - - -bytes_left = N; +int bytes_left = N; while ( bytes_left > 0 ) { - - bytes = bytes_left; + int n_read; + int n_written; + int bytes = bytes_left; if ( bytes > buf_size ) bytes = buf_size; diff --git a/src/libcode/vx_pointdata_python/python_pointdata.cc b/src/libcode/vx_pointdata_python/python_pointdata.cc index 8133f81ac7..1b34915bf8 100644 --- a/src/libcode/vx_pointdata_python/python_pointdata.cc +++ b/src/libcode/vx_pointdata_python/python_pointdata.cc @@ -195,7 +195,7 @@ bool process_point_data(PyObject *python_met_point_data, { int int_value; -PyObject *python_value = 0; +PyObject *python_value; ConcatString cs, user_dir, user_base; const char *method_name = "process_point_data -> "; const char *method_name_s = "process_point_data()"; @@ -289,7 +289,6 @@ bool process_point_data_list(PyObject *python_point_data, MetPointDataPython &me Observation obs; time_t vld_time; int hid, vid, qid, sid, typ_idx, vld_idx; - double lat, lon, elv, hgt, level, obs_value; double prev_lat, prev_lon, prev_elv, prev_vld, prev_typ, prev_sid; Python3_List list(python_point_data); const char *method_name = "process_point_data_list -> "; @@ -325,9 +324,9 @@ bool process_point_data_list(PyObject *python_point_data, MetPointDataPython &me } obs.set(py_value); - lat = obs.getLatitude(); - lon = obs.getLongitude(); - elv = obs.getElevation(); + double lat = obs.getLatitude(); + double lon = obs.getLongitude(); + double elv = obs.getElevation(); if(filters) { if (filters->is_filtered(lat, lon)) continue; if (filters->is_filtered_sid(obs.getStationId().c_str())) continue; @@ -441,8 +440,7 @@ bool straight_python_point_data(const char * script_name, int script_argc, char { int int_value; -PyObject *module_obj = 0; -PyObject *python_value = 0; +PyObject *module_obj; ConcatString cs, user_dir, user_base; const char *method_name = "straight_python_point_data -> "; @@ -530,7 +528,7 @@ if ( PyErr_Occurred() ) { << "an error occurred importing module \"" << script_name << "\"\n\n"; - return ( false ); + return false; } @@ -540,7 +538,7 @@ if ( ! module_obj ) { << "error running python script \"" << script_name << "\"\n\n"; - return ( false ); + return false; } @@ -579,7 +577,7 @@ int status; ConcatString command; ConcatString path; ConcatString tmp_nc_path; -const char * tmp_dir = 0; +const char * tmp_dir = nullptr; Wchar_Argv wa; const char *method_name = "tmp_nc_point_obs() -> "; diff --git a/src/libcode/vx_summary/summary_calc.cc b/src/libcode/vx_summary/summary_calc.cc index 35e6822538..9f05153c32 100644 --- a/src/libcode/vx_summary/summary_calc.cc +++ b/src/libcode/vx_summary/summary_calc.cc @@ -10,12 +10,13 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "summary_calc.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_summary/summary_calc_max.cc b/src/libcode/vx_summary/summary_calc_max.cc index 6ea4f77a70..d796bd1589 100644 --- a/src/libcode/vx_summary/summary_calc_max.cc +++ b/src/libcode/vx_summary/summary_calc_max.cc @@ -10,12 +10,13 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "summary_calc_max.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_summary/summary_calc_max.h b/src/libcode/vx_summary/summary_calc_max.h index 11d897eb7a..1196f12ba1 100644 --- a/src/libcode/vx_summary/summary_calc_max.h +++ b/src/libcode/vx_summary/summary_calc_max.h @@ -32,7 +32,7 @@ class SummaryCalcMax : public SummaryCalc SummaryCalcMax(); virtual ~SummaryCalcMax(); - virtual string getType() const + virtual std::string getType() const { return "MAX"; } diff --git a/src/libcode/vx_summary/summary_calc_mean.cc b/src/libcode/vx_summary/summary_calc_mean.cc index 5ddb2f2e10..aa384a9c7a 100644 --- a/src/libcode/vx_summary/summary_calc_mean.cc +++ b/src/libcode/vx_summary/summary_calc_mean.cc @@ -10,12 +10,13 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "summary_calc_mean.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_summary/summary_calc_mean.h b/src/libcode/vx_summary/summary_calc_mean.h index 034cf14784..4144dbfe75 100644 --- a/src/libcode/vx_summary/summary_calc_mean.h +++ b/src/libcode/vx_summary/summary_calc_mean.h @@ -32,7 +32,7 @@ class SummaryCalcMean : public SummaryCalc SummaryCalcMean(); virtual ~SummaryCalcMean(); - virtual string getType() const + virtual std::string getType() const { return "MEAN"; } diff --git a/src/libcode/vx_summary/summary_calc_median.cc b/src/libcode/vx_summary/summary_calc_median.cc index f87f94c0f3..c027253ac6 100644 --- a/src/libcode/vx_summary/summary_calc_median.cc +++ b/src/libcode/vx_summary/summary_calc_median.cc @@ -10,13 +10,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include "summary_calc_median.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_summary/summary_calc_min.cc b/src/libcode/vx_summary/summary_calc_min.cc index 12c0bd9b53..8c998e3837 100644 --- a/src/libcode/vx_summary/summary_calc_min.cc +++ b/src/libcode/vx_summary/summary_calc_min.cc @@ -10,12 +10,13 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "summary_calc_min.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_summary/summary_calc_min.h b/src/libcode/vx_summary/summary_calc_min.h index b1ed0277de..9b17e61dd0 100644 --- a/src/libcode/vx_summary/summary_calc_min.h +++ b/src/libcode/vx_summary/summary_calc_min.h @@ -32,7 +32,7 @@ class SummaryCalcMin : public SummaryCalc SummaryCalcMin(); virtual ~SummaryCalcMin(); - virtual string getType() const + virtual std::string getType() const { return "MIN"; } diff --git a/src/libcode/vx_summary/summary_calc_percentile.cc b/src/libcode/vx_summary/summary_calc_percentile.cc index c6a0b4d288..26ef0ba620 100644 --- a/src/libcode/vx_summary/summary_calc_percentile.cc +++ b/src/libcode/vx_summary/summary_calc_percentile.cc @@ -10,13 +10,14 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include "summary_calc_percentile.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_summary/summary_calc_percentile.h b/src/libcode/vx_summary/summary_calc_percentile.h index 353ef963ae..1dcfc4bb3f 100644 --- a/src/libcode/vx_summary/summary_calc_percentile.h +++ b/src/libcode/vx_summary/summary_calc_percentile.h @@ -29,10 +29,10 @@ class SummaryCalcPercentile : public SummaryCalc public: - SummaryCalcPercentile(const string &type_string); + SummaryCalcPercentile(const std::string &type_string); virtual ~SummaryCalcPercentile(); - virtual string getType() const + virtual std::string getType() const { return _type; } @@ -49,7 +49,7 @@ class SummaryCalcPercentile : public SummaryCalc protected: double _percentile; - string _type; + std::string _type; }; diff --git a/src/libcode/vx_summary/summary_calc_range.cc b/src/libcode/vx_summary/summary_calc_range.cc index ca207ed396..83da9fb483 100644 --- a/src/libcode/vx_summary/summary_calc_range.cc +++ b/src/libcode/vx_summary/summary_calc_range.cc @@ -10,12 +10,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "summary_calc_range.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_summary/summary_calc_range.h b/src/libcode/vx_summary/summary_calc_range.h index 043cf882a2..fbb6bdfbbf 100644 --- a/src/libcode/vx_summary/summary_calc_range.h +++ b/src/libcode/vx_summary/summary_calc_range.h @@ -32,7 +32,7 @@ class SummaryCalcRange : public SummaryCalc SummaryCalcRange(); virtual ~SummaryCalcRange(); - virtual string getType() const + virtual std::string getType() const { return "RANGE"; } diff --git a/src/libcode/vx_summary/summary_calc_stdev.cc b/src/libcode/vx_summary/summary_calc_stdev.cc index 87e0a79f48..07e2d1d81c 100644 --- a/src/libcode/vx_summary/summary_calc_stdev.cc +++ b/src/libcode/vx_summary/summary_calc_stdev.cc @@ -10,12 +10,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "summary_calc_stdev.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_summary/summary_calc_stdev.h b/src/libcode/vx_summary/summary_calc_stdev.h index 6076839c7a..db02988e30 100644 --- a/src/libcode/vx_summary/summary_calc_stdev.h +++ b/src/libcode/vx_summary/summary_calc_stdev.h @@ -32,7 +32,7 @@ class SummaryCalcStdev : public SummaryCalc SummaryCalcStdev(); virtual ~SummaryCalcStdev(); - virtual string getType() const + virtual std::string getType() const { return "SDEV"; } diff --git a/src/libcode/vx_summary/summary_calc_sum.cc b/src/libcode/vx_summary/summary_calc_sum.cc index 79587f0f80..daed7306df 100644 --- a/src/libcode/vx_summary/summary_calc_sum.cc +++ b/src/libcode/vx_summary/summary_calc_sum.cc @@ -10,12 +10,12 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include "summary_calc_sum.h" +using namespace std; + //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_summary/summary_calc_sum.h b/src/libcode/vx_summary/summary_calc_sum.h index daec131260..d3e149c22d 100644 --- a/src/libcode/vx_summary/summary_calc_sum.h +++ b/src/libcode/vx_summary/summary_calc_sum.h @@ -32,7 +32,7 @@ class SummaryCalcSum : public SummaryCalc SummaryCalcSum(); virtual ~SummaryCalcSum(); - virtual string getType() const + virtual std::string getType() const { return "SUM"; } diff --git a/src/libcode/vx_summary/summary_key.cc b/src/libcode/vx_summary/summary_key.cc index 9e6d1e519b..62b207dcb1 100644 --- a/src/libcode/vx_summary/summary_key.cc +++ b/src/libcode/vx_summary/summary_key.cc @@ -10,10 +10,10 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; +#include "summary_key.h" -#include "summary_key.h" +using namespace std; //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_summary/summary_key.h b/src/libcode/vx_summary/summary_key.h index 84716eabf5..ee693a6bfe 100644 --- a/src/libcode/vx_summary/summary_key.h +++ b/src/libcode/vx_summary/summary_key.h @@ -27,12 +27,12 @@ class SummaryKey public: - SummaryKey(const string &header_type, - const string &station_id, + SummaryKey(const std::string &header_type, + const std::string &station_id, const double lat, const double lon, const double elev, const int var_code, const double height_m, const double pressure_level, - const string &var_name = ""); + const std::string &var_name = ""); virtual ~SummaryKey(); @@ -41,12 +41,12 @@ class SummaryKey // Access methods // //////////////////// - string getHeaderType() const + std::string getHeaderType() const { return _headerType; } - string getStationId() const + std::string getStationId() const { return _stationId; } @@ -91,7 +91,7 @@ class SummaryKey return _pressureLevel; } - string getVarName() const + std::string getVarName() const { return _varName; } @@ -154,8 +154,8 @@ class SummaryKey // Protected members // /////////////////////// - string _headerType; - string _stationId; + std::string _headerType; + std::string _stationId; double _latitude; double _longitude; double _elevation; @@ -163,7 +163,7 @@ class SummaryKey int hdrIndex; double _height; double _pressureLevel; - string _varName; + std::string _varName; }; diff --git a/src/libcode/vx_summary/summary_obs.cc b/src/libcode/vx_summary/summary_obs.cc index d1f7336421..8aa8f4a3eb 100644 --- a/src/libcode/vx_summary/summary_obs.cc +++ b/src/libcode/vx_summary/summary_obs.cc @@ -10,8 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -29,6 +27,9 @@ using namespace std; #include "summary_key.h" #include "summary_obs.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// SummaryObs::SummaryObs(): diff --git a/src/libcode/vx_summary/time_summary_interval.cc b/src/libcode/vx_summary/time_summary_interval.cc index 73a3224deb..c1d8c8a656 100644 --- a/src/libcode/vx_summary/time_summary_interval.cc +++ b/src/libcode/vx_summary/time_summary_interval.cc @@ -10,10 +10,10 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; +#include "time_summary_interval.h" -#include "time_summary_interval.h" +using namespace std; //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/pcp_combine/pcp_combine.cc b/src/tools/core/pcp_combine/pcp_combine.cc index 8993c2891a..06a4b2287d 100644 --- a/src/tools/core/pcp_combine/pcp_combine.cc +++ b/src/tools/core/pcp_combine/pcp_combine.cc @@ -755,9 +755,9 @@ int search_pcp_dir(const char *cur_dir, const unixtime cur_ut, cur_file << cs_erase << cur_dir << '/' << dirp->d_name; Met2dDataFileFactory factory; - Met2dDataFile * mtddf = (Met2dDataFile *) nullptr; + Met2dDataFile * mtddf; VarInfoFactory var_fac; - VarInfo * cur_var = (VarInfo *) nullptr; + VarInfo * cur_var; // // Create a data file object. @@ -1145,13 +1145,13 @@ void do_derive_command() { for(j=0; j #include #include @@ -29,6 +26,9 @@ using namespace std; #include "aeronet_handler.h" +using namespace std; + + static bool test_AOD_550 = false; static const char *AERONET_NA_STR = "N/A"; static const char *AERONET_V3_STR = "AERONET Version 3"; diff --git a/src/tools/other/ascii2nc/aeronet_handler.h b/src/tools/other/ascii2nc/aeronet_handler.h index e835a91602..a602ba41ce 100644 --- a/src/tools/other/ascii2nc/aeronet_handler.h +++ b/src/tools/other/ascii2nc/aeronet_handler.h @@ -31,24 +31,24 @@ class AeronetHandler : public FileHandler public: - AeronetHandler(const string &program_name); + AeronetHandler(const std::string &program_name); virtual ~AeronetHandler(); virtual bool isFileType(LineDataFile &ascii_file) const; void setFormatVersion(int version); - static string getFormatString() + static std::string getFormatString() { return "aeronet"; } - static string getFormatString_v2() + static std::string getFormatString_v2() { return "aeronetv2"; } - static string getFormatString_v3() + static std::string getFormatString_v3() { return "aeronetv3"; } @@ -69,7 +69,7 @@ class AeronetHandler : public FileHandler // The header type for these observations - static const string HEADER_TYPE; + static const std::string HEADER_TYPE; // Grib codes for the different fields @@ -83,7 +83,7 @@ class AeronetHandler : public FileHandler // Unchanging header information - string _stationId; + std::string _stationId; double _stationLat; double _stationLon; double _stationAlt; @@ -111,13 +111,13 @@ class AeronetHandler : public FileHandler virtual bool _readObservations(LineDataFile &ascii_file); // Extract the height from the field name - double extract_height(string hdr_field); + double extract_height(std::string hdr_field); // Get the number of headers int get_header_count_v3(StringArray hdr_tokens); // Make the variable name from header (field name) - string make_var_name_from_header(string hdr_field); + std::string make_var_name_from_header(std::string hdr_field); }; diff --git a/src/tools/other/ascii2nc/airnow_handler.cc b/src/tools/other/ascii2nc/airnow_handler.cc index 74525c6139..033d2419d3 100644 --- a/src/tools/other/ascii2nc/airnow_handler.cc +++ b/src/tools/other/ascii2nc/airnow_handler.cc @@ -10,9 +10,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - - #include #include #include @@ -25,6 +22,9 @@ using namespace std; #include "airnow_handler.h" +using namespace std; + + static const char *AIRNOW_NA_STR = "N/A"; static const char *airnow_stations_env = "MET_AIRNOW_STATIONS"; @@ -421,16 +421,12 @@ bool AirnowHandler::_parseObservationLineAqobs(const string &data_line, } // fill in expected things - double lat, lon, elev; + double elev = 0.0; string stationId = tokens[stationIdPtr]; - string col; - - lat = atof(tokens[latPtr].c_str()); - lon = atof(tokens[lonPtr].c_str()); + double lat = atof(tokens[latPtr].c_str()); + double lon = atof(tokens[lonPtr].c_str()); if (elevPtr >= 0) { elev = atof(tokens[elevPtr].c_str()); - } else { - elev = 0.0; } _addHourlyAqobsObs(tokens, header_type, stationId, valid_time, lat, lon, elev, @@ -496,20 +492,15 @@ void AirnowHandler::_addHourlyAqobsObs(const vector &data_line, const st int measuredPtr, int aqiPtr, int valuePtr, int unitPtr, const string &varname) { - string col; - int status; - int aqi; - double value; - string units; - // averging period is 1-hour int avgPeriodSec = 3600; - status = atoi(data_line[measuredPtr].c_str()); + int status = atoi(data_line[measuredPtr].c_str()); if (status == 1) { - aqi = atoi(data_line[aqiPtr].c_str()); + double value; + int aqi = atoi(data_line[aqiPtr].c_str()); if (doubleOrMissing(data_line[valuePtr], value)) { - units = data_line[unitPtr]; + string units = data_line[unitPtr]; // add the observation _addObservations(Observation(header_type, stationId, valid_time, @@ -528,15 +519,13 @@ void AirnowHandler::_addHourlyAqobsObs(const vector &data_line, const st double lat, double lon, double elev, int valuePtr, int unitPtr, const string &varname) { - string col; double value; - string units; // averging period is 1-hour int avgPeriodSec = 3600; if (doubleOrMissing(data_line[valuePtr], value)) { - units = data_line[unitPtr]; + string units = data_line[unitPtr]; // add the observation _addObservations(Observation(header_type, stationId, valid_time, diff --git a/src/tools/other/ascii2nc/airnow_handler.h b/src/tools/other/ascii2nc/airnow_handler.h index beef7bf0d5..94c7007807 100644 --- a/src/tools/other/ascii2nc/airnow_handler.h +++ b/src/tools/other/ascii2nc/airnow_handler.h @@ -32,24 +32,24 @@ class AirnowHandler : public FileHandler public: - AirnowHandler(const string &program_name); + AirnowHandler(const std::string &program_name); virtual ~AirnowHandler(); virtual bool isFileType(LineDataFile &ascii_file) const; void setFormatVersion(int version); - static string getFormatStringDailyV2() + static std::string getFormatStringDailyV2() { return "airnowdaily_v2"; } - static string getFormatStringHourlyAqObs() + static std::string getFormatStringHourlyAqObs() { return "airnowhourlyaqobs"; } - static string getFormatStringHourly() + static std::string getFormatStringHourly() { return "airnowhourly"; } @@ -82,7 +82,7 @@ class AirnowHandler : public FileHandler // Unchanging header information - string _stationId; + std::string _stationId; double _stationLat; double _stationLon; double _stationAlt; @@ -132,7 +132,7 @@ class AirnowHandler : public FileHandler int so2Ptr; int so2UnitPtr; - string monitoringSiteFileName; + std::string monitoringSiteFileName; AirnowLocations locations; @@ -154,43 +154,43 @@ class AirnowHandler : public FileHandler bool _determineFileType(LineDataFile &ascii_file); - void _addHourlyAqobsObs(const vector &data_line, const string &header_type, - const string &stationId, const time_t &valid_time, + void _addHourlyAqobsObs(const std::vector &data_line, const std::string &header_type, + const std::string &stationId, const time_t &valid_time, double lat, double lon, double elev, int measuredPtr, int aqiPtr, int valuePtr, - int unitPtr, const string &varname); - void _addHourlyAqobsObs(const vector &data_line, const string &header_type, - const string &stationId, const time_t &valid_time, + int unitPtr, const std::string &varname); + void _addHourlyAqobsObs(const std::vector &data_line, const std::string &header_type, + const std::string &stationId, const time_t &valid_time, double lat, double lon, double elev, - int valuePtr, int unitPtr, const string &varname); + int valuePtr, int unitPtr, const std::string &varname); // Get the observation valid time from the given observation line - time_t _getValidTime(const vector &data_line) const; + time_t _getValidTime(const std::vector &data_line) const; time_t _getValidTime(const DataLine &data_line) const; - time_t _getValidTime(const string &dateStr, const string &timeStr) const; + time_t _getValidTime(const std::string &dateStr, const std::string &timeStr) const; // Read the observations from the given file and add them to the // _observations vector. virtual bool _readObservations(LineDataFile &ascii_file); - bool _readObservationsHourlyAqobs(LineDataFile &ascii_file, int column_cnt, const string &delimiter, - const string &header_type); - bool _readObservationsStandard(LineDataFile &ascii_file, int column_cnt, const string &delimiter, - const string &header_type); + bool _readObservationsHourlyAqobs(LineDataFile &ascii_file, int column_cnt, const std::string &delimiter, + const std::string &header_type); + bool _readObservationsStandard(LineDataFile &ascii_file, int column_cnt, const std::string &delimiter, + const std::string &header_type); bool _parseObservationLineStandard(DataLine &data_line, - const string &filename, + const std::string &filename, int column_cnt, - const string &header_type); - bool _parseObservationLineAqobs(const string &data_line, int column_cnt, - const string &header_type, int lineNumber, - const string &filename); + const std::string &header_type); + bool _parseObservationLineAqobs(const std::string &data_line, int column_cnt, + const std::string &header_type, int lineNumber, + const std::string &filename); void _initializeColumnPointers(); - string _extractColumn(const DataLine &data_line, int ptr) const; - int _getVarIndex(const string &, const string &); + std::string _extractColumn(const DataLine &data_line, int ptr) const; + int _getVarIndex(const std::string &, const std::string &); }; diff --git a/src/tools/other/ascii2nc/airnow_locations.cc b/src/tools/other/ascii2nc/airnow_locations.cc index 5e66fa9018..5063cf59c0 100644 --- a/src/tools/other/ascii2nc/airnow_locations.cc +++ b/src/tools/other/ascii2nc/airnow_locations.cc @@ -8,8 +8,6 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include @@ -22,6 +20,9 @@ using namespace std; #include "airnow_locations.h" +using namespace std; + + //////////////////////////////////////////////////////////////////////// // diff --git a/src/tools/other/ascii2nc/airnow_locations.h b/src/tools/other/ascii2nc/airnow_locations.h index 3ad1908622..74dbb76e0c 100644 --- a/src/tools/other/ascii2nc/airnow_locations.h +++ b/src/tools/other/ascii2nc/airnow_locations.h @@ -28,25 +28,25 @@ class AirnowLocations AirnowLocations(); virtual ~AirnowLocations(); - bool initialize(const string &locationsFile); - bool lookupLatLonElev(const string aqsid, double &lat, double &lon, double &elev) const; + bool initialize(const std::string &locationsFile); + bool lookupLatLonElev(const std::string aqsid, double &lat, double &lon, double &elev) const; private: - bool _setPtr(DataLine &data_line, const string &headerName, int &ptr) const; + bool _setPtr(DataLine &data_line, const std::string &headerName, int &ptr) const; - string monitoringSiteFileName; + std::string monitoringSiteFileName; // all the AQSID's from the monitoring site file, set only for Hourly format. // and all the associated location information from the monitoring site file, in the same order // 3 different AQSID's are found in the lookup file: stationId, Aqsid, FullAqsid // - vector monitoringSiteStationId; - vector monitoringSiteAqsid; - vector monitoringSiteFullAqsid; - vector monitoringSiteLat; - vector monitoringSiteLon; - vector monitoringSiteElev; + std::vector monitoringSiteStationId; + std::vector monitoringSiteAqsid; + std::vector monitoringSiteFullAqsid; + std::vector monitoringSiteLat; + std::vector monitoringSiteLon; + std::vector monitoringSiteElev; }; diff --git a/src/tools/other/ascii2nc/file_handler.cc b/src/tools/other/ascii2nc/file_handler.cc index 74020804f0..5afa7b5dc8 100644 --- a/src/tools/other/ascii2nc/file_handler.cc +++ b/src/tools/other/ascii2nc/file_handler.cc @@ -10,13 +10,10 @@ //////////////////////////////////////////////////////////////////////// -using namespace std; - #include #include #include -using namespace netCDF; #include "vx_math.h" #include "vx_nc_util.h" @@ -31,6 +28,10 @@ using namespace netCDF; #include "summary_calc_range.h" #include "summary_calc_stdev.h" +using namespace std; +using namespace netCDF; + + const float FileHandler::FILL_VALUE = -9999.f; const int DEF_DEFALTE_LEVEL = 2; @@ -263,7 +264,6 @@ bool FileHandler::_openNetcdf(const string &nc_filename) bool FileHandler::_addObservations(const Observation &obs) { - double grid_x, grid_y; // // Apply the grid mask, the area mask, and the polyline mask diff --git a/src/tools/other/ascii2nc/file_handler.h b/src/tools/other/ascii2nc/file_handler.h index 8358411f36..8994afb4e5 100644 --- a/src/tools/other/ascii2nc/file_handler.h +++ b/src/tools/other/ascii2nc/file_handler.h @@ -47,7 +47,7 @@ class FileHandler public: - FileHandler(const string &program_name); + FileHandler(const std::string &program_name); virtual ~FileHandler(); virtual bool isFileType(LineDataFile &ascii_file) const = 0; @@ -56,10 +56,10 @@ class FileHandler void setAreaMask(MaskPlane &a); void setPolyMask(MaskPoly &p); void setSIDMask (StringArray &s); - void setMessageTypeMap(map m); + void setMessageTypeMap(std::map m); - virtual bool readAsciiFiles(const vector< ConcatString > &ascii_filename_list); - bool writeNetcdfFile(const string &nc_filename); + virtual bool readAsciiFiles(const std::vector< ConcatString > &ascii_filename_list); + bool writeNetcdfFile(const std::string &nc_filename); bool summarizeObs(const TimeSummaryInfo &summary_info); @@ -81,7 +81,7 @@ class FileHandler // Protected members // /////////////////////// - string _programName; + std::string _programName; // Variables for writing output NetCDF file @@ -95,11 +95,11 @@ class FileHandler MaskFilters filters; - map _messageTypeMap; + std::map _messageTypeMap; // List of observations read from the ascii files - vector< Observation > _observations; + std::vector< Observation > _observations; bool use_var_id; StringArray obs_names; StringArray obs_units; @@ -124,7 +124,7 @@ class FileHandler void _countHeaders(); - time_t _getValidTime(const string &time_string) const; + time_t _getValidTime(const std::string &time_string) const; // Read the observations from the given file. @@ -141,8 +141,8 @@ class FileHandler bool _writeObservations(); void _closeNetcdf(); - bool _openNetcdf(const string &nc_filename); - void debug_print_observations(vector< Observation >, string); + bool _openNetcdf(const std::string &nc_filename); + void debug_print_observations(std::vector< Observation >, std::string); }; inline void FileHandler::setCompressionLevel(int compressoion_level) { deflate_level = compressoion_level; } @@ -150,7 +150,7 @@ inline void FileHandler::setGridMask(Grid &g) { filters.set_grid_mask(&g) inline void FileHandler::setAreaMask(MaskPlane &a) { filters.set_area_mask(&a); } inline void FileHandler::setPolyMask(MaskPoly &p) { filters.set_poly_mask(&p); } inline void FileHandler::setSIDMask (StringArray &s) { filters.set_sid_mask(&s); } -inline void FileHandler::setMessageTypeMap(map m) { +inline void FileHandler::setMessageTypeMap(std::map m) { _messageTypeMap = m; } diff --git a/src/tools/other/ascii2nc/python_handler.cc b/src/tools/other/ascii2nc/python_handler.cc index a5a55e0f94..ae91a80200 100644 --- a/src/tools/other/ascii2nc/python_handler.cc +++ b/src/tools/other/ascii2nc/python_handler.cc @@ -68,14 +68,13 @@ PythonHandler::PythonHandler(const char * program_name, const char * ascii_filen { -int j; ConcatString s = ascii_filename; StringArray a = s.split(" "); user_script_filename = a[0]; -for (j=1; j<(a.n()); ++j) { // j starts at one here, not zero +for (int j=1; j<(a.n()); ++j) { // j starts at one here, not zero user_script_args.add(a[j]); @@ -117,7 +116,7 @@ bool PythonHandler::isFileType(LineDataFile &ascii_file) const { -return ( false ); +return false; } @@ -153,8 +152,7 @@ if ( ! PyList_Check(obj) ) { } -int j; -PyObject * a = 0; +PyObject * a = nullptr; Python3_List list(obj); Observation obs; @@ -164,7 +162,7 @@ Observation obs; use_var_id = false; -for (j=0; j<(list.size()); ++j) { +for (int j=0; j<(list.size()); ++j) { a = list[j]; diff --git a/src/tools/other/madis2nc/madis2nc.cc b/src/tools/other/madis2nc/madis2nc.cc index 0035ee5012..f23272a533 100644 --- a/src/tools/other/madis2nc/madis2nc.cc +++ b/src/tools/other/madis2nc/madis2nc.cc @@ -697,12 +697,12 @@ void convert_wind_wdir_to_u_v(float wind, float wdir, //////////////////////////////////////////////////////////////////////// bool check_masks(double lat, double lon, const char *sid) { - double grid_x, grid_y; // // Check grid masking. // if(mask_grid.nx() > 0 || mask_grid.ny() > 0) { + double grid_x, grid_y; mask_grid.latlon_to_xy(lat, -1.0*lon, grid_x, grid_y); if(grid_x < 0 || grid_x >= mask_grid.nx() || grid_y < 0 || grid_y >= mask_grid.ny()) { @@ -3330,7 +3330,6 @@ void process_madis_acarsProfiles(NcFile *&f_in) { // // Loop through each record and get the header data. // - int data_cnt; for(i_hdr_s=rec_beg; i_hdr_s BUFFER_SIZE) ? BUFFER_SIZE: (my_rec_end - i_hdr_s); @@ -3355,7 +3354,7 @@ void process_madis_acarsProfiles(NcFile *&f_in) { cur[0] = i_hdr_s; dim[0] = buf_size; dim[1] = maxLevels; - data_cnt = buf_size * maxLevels; + int data_cnt = buf_size * maxLevels; get_nc_data(&in_hdr_vld_var, tmp_dbl_arr, dim, cur); get_nc_data(&in_hdr_lat_var, (float *)hdr_lat_arr, dim, cur); diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index c4eecb213f..f46fce3bb0 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -117,33 +117,34 @@ static const char * default_config_filename = "MET_BASE/config/PB2NCConfig_defau static const char *program_name = "pb2nc"; static const char *not_assigned = "not_assigned"; +static const char *tmp_pb2nc_base = "tmp_pb2nc_blk"; -constexpr static float fill_value = -9999.f; -constexpr static int missing_cycle_minute = -1; +constexpr float fill_value = -9999.f; +constexpr int missing_cycle_minute = -1; // Constants used to interface to Fortran subroutines // Missing value for BUFR data -static const double r8bfms = 1.0E10; +constexpr double r8bfms = 1.0E10; // Maximum number of BUFR parameters -static const int mxr8pm = 10; +constexpr int mxr8pm = 10; // Maximum number of BUFR levels -static const int mxr8lv_small = 255; -static const int mxr8lv = 1023; // was 255; +constexpr int mxr8lv_small = 255; +constexpr int mxr8lv = 1023; // was 255; // Maximum number of BUFR event sequences -static const int mxr8vn = 10; +constexpr int mxr8vn = 10; // Maximum number of BUFR variable types -static const int mxr8vt = 6; +constexpr int mxr8vt = 6; // Maximum length of BUFR variable name -static const int mxr8nm = 8; +constexpr int mxr8nm = 8; // Maximum number of BUFR variable types -static const int COUNT_THRESHOLD = 16; +constexpr int COUNT_THRESHOLD = 16; // File unit number for opening the PrepBufr file -static const int file_unit = 11; +constexpr int file_unit = 11; // 2nd file unit number for opening the PrepBufr file -static const int dump_unit = 22; +constexpr int dump_unit = 22; // Grib codes corresponding to the variable types const std::array var_gc = { @@ -187,9 +188,9 @@ static float pbl_data_ugrd[MAX_PBL_LEVEL]; static float pbl_data_vgrd[MAX_PBL_LEVEL]; // PREPBUFR VIRTMP program code -static const double virtmp_prog_code = 8.0; -static const int MIN_FORTRAN_FILE_ID = 1; -static const int MAX_FORTRAN_FILE_ID = 99; +constexpr double virtmp_prog_code = 8.0; +constexpr int MIN_FORTRAN_FILE_ID = 1; +constexpr int MAX_FORTRAN_FILE_ID = 99; //////////////////////////////////////////////////////////////////////// @@ -238,15 +239,15 @@ static double hdr[mxr8pm]; static double evns[mxr8vt][mxr8vn][mxr8lv][mxr8pm]; static int nlev; -static const int BUFR_NUMBER_START = 13; -static const int BUFR_NAME_START = 2; -static const int BUFR_NAME_LEN = 8; -static const int BUFR_DESCRIPTION_START = 22; -static const int BUFR_DESCRIPTION_LEN = 56; -static const int BUFR_UNIT_START = 40; -static const int BUFR_UNIT_LEN = 25; -static const int BUFR_SEQUENCE_START = 13; -static const int BUFR_SEQUENCE_LEN = 66; +constexpr int BUFR_NUMBER_START = 13; +constexpr int BUFR_NAME_START = 2; +constexpr int BUFR_NAME_LEN = 8; +constexpr int BUFR_DESCRIPTION_START = 22; +constexpr int BUFR_DESCRIPTION_LEN = 56; +constexpr int BUFR_UNIT_START = 40; +constexpr int BUFR_UNIT_LEN = 25; +constexpr int BUFR_SEQUENCE_START = 13; +constexpr int BUFR_SEQUENCE_LEN = 66; static const char *prepbufr_p_event = "POB PQM PPC PRC PFC PAN CAT"; static const char *prepbufr_q_event = "QOB QQM QPC QRC QFC QAN CAT"; @@ -271,7 +272,7 @@ static const char *bufr_avail_latlon_names = "XOB CLON CLONH YOB CLAT CLATH"; static const char *derived_mlcape = "D_MLCAPE"; static const char *derived_cape = "D_CAPE"; static const char *derived_pbl = "D_PBL"; -static const float MLCAPE_INTERVAL = 3000.; +constexpr float MLCAPE_INTERVAL = 3000.; static double bufr_obs[mxr8lv][mxr8pm]; static double bufr_obs_extra[mxr8lv][mxr8pm]; @@ -308,7 +309,7 @@ static vector< Observation > observations; // // Output NetCDF file, dimensions, and variables // -static NcFile *f_out = (NcFile *) 0; +static NcFile *f_out = (NcFile *) nullptr; //////////////////////////////////////////////////////////////////////// @@ -460,8 +461,6 @@ derive_var_cfg &derive_var_cfg::operator=(const derive_var_cfg &a) noexcept { int met_main(int argc, char *argv[]) { - int i; - // Initialize static variables initialize(); @@ -470,7 +469,7 @@ int met_main(int argc, char *argv[]) { if (collect_metadata) { // Process each PrepBufr file - for(i=0; i MAX_FORTRAN_FILE_ID || _file_id < MIN_FORTRAN_FILE_ID) { @@ -673,9 +672,7 @@ ConcatString save_bufr_table_to_file(const char *blk_file, int _file_id) { openpb_(blk_file, &_file_id); dump_tbl_(blk_file, &_file_id, tbl_filename.c_str(), &len); closepb_(&_file_id); - - // Delete the temporary blocked file - remove_temp_file((string)blk_file); + return tbl_filename; } @@ -689,7 +686,7 @@ bool is_prepbufr_file(const StringArray *events) { //////////////////////////////////////////////////////////////////////// -void get_variable_info(const char* tbl_filename) { +void get_variable_info(ConcatString blk_file, int unit) { static const char *method_name = " get_variable_info()"; FILE * fp; @@ -704,8 +701,9 @@ void get_variable_info(const char* tbl_filename) { tableB_vars.clear(); tableB_descs.clear(); - fp = fopen(tbl_filename, "r"); - ConcatString input_data; + ConcatString tbl_filename = save_bufr_table_to_file(blk_file.c_str(), unit); + + fp = fopen(tbl_filename.c_str(), "r"); if (fp != nullptr) { char var_name[BUFR_NAME_LEN+1]; char var_desc[max(BUFR_DESCRIPTION_LEN,BUFR_SEQUENCE_LEN)+1]; @@ -822,6 +820,8 @@ void get_variable_info(const char* tbl_filename) { if (line) free(line); } + + remove_temp_file(tbl_filename); return; } @@ -839,7 +839,7 @@ void open_netcdf() { << "trouble opening output file: " << ncfile << "\n\n"; delete f_out; - f_out = (NcFile *) 0; + f_out = (NcFile *) nullptr; exit(1); } @@ -858,21 +858,22 @@ void open_netcdf() { void process_pbfile(int i_pb) { int npbmsg, npbmsg_total, unit, yr, mon, day, hr, min, sec; - int i, i_msg, i_read, n_file_obs, i_ret, i_date, n_hdr_obs; + int i, i_msg, n_file_obs, i_ret, i_date, n_hdr_obs; int rej_typ, rej_sid, rej_vld, rej_grid, rej_poly; int rej_elv, rej_pb_rpt, rej_in_rpt, rej_itp, rej_nobs; - int lv, ev, ev_temp, kk, len1, len2; + int lv, ev, ev_temp, kk; int n_derived_obs; - double x, y; + double x; + double y; int cycle_minute; - unixtime file_ut = (unixtime) 0; + unixtime file_ut; unixtime adjusted_file_ut; unixtime msg_ut, beg_ut, end_ut; unixtime min_msg_ut, max_msg_ut; - beg_ut = end_ut = (unixtime) 0; + file_ut = beg_ut = end_ut = (unixtime) 0; ConcatString file_name, blk_prefix, blk_file, log_message; ConcatString prefix; @@ -894,7 +895,7 @@ void process_pbfile(int i_pb) { float pqtzuv[mxr8vt], pqtzuv_qty[mxr8vt]; const int debug_level_for_performance = 3; - int start_t, end_t, method_start, method_end; + clock_t start_t, end_t, method_start, method_end; start_t = end_t = method_start = method_end = clock(); IntArray diff_file_times; @@ -922,7 +923,7 @@ void process_pbfile(int i_pb) { file_name << pbfile[i_pb]; // Build the temporary block file name - blk_prefix << conf_info.tmp_dir << "/" << "tmp_pb2nc_blk"; + blk_prefix << conf_info.tmp_dir << "/" << tmp_pb2nc_base; blk_file = make_temp_file_name(blk_prefix.c_str(), nullptr); mlog << Debug(1) << "Blocking Bufr file to:\t" << blk_file << "\n"; @@ -1007,11 +1008,12 @@ void process_pbfile(int i_pb) { int nlev_max_req = mxr8lv; if (0 < conf_info.end_level && conf_info.end_level < mxr8lv) { - nlev_max_req = conf_info.end_level; + nlev_max_req = (int)conf_info.end_level; mlog << Debug(4) << "Request up to " << nlev_max_req << " vertical levels\n"; } - int grib_code, bufr_var_index; + int grib_code; + int bufr_var_index; map message_type_map = conf_info.getMessageTypeMap(); int bin_count = nint(npbmsg/20.0); @@ -1036,7 +1038,6 @@ void process_pbfile(int i_pb) { float cape_qm = bad_data_float; // To compute PBL - int pbl_level = 0; int pbl_code = -1; float pbl_p, pbl_h; float pbl_qm = bad_data_float; @@ -1048,7 +1049,7 @@ void process_pbfile(int i_pb) { bool cal_mlcape = bufr_obs_name_arr.has(derived_mlcape, mlcape_code, false); bool is_same_header; - unixtime prev_hdr_vld_ut = (unixtime) 0; + auto prev_hdr_vld_ut = (unixtime) 0; char prev_hdr_typ[max_str_len], prev_hdr_sid[max_str_len]; double prev_hdr_lat, prev_hdr_lon, prev_hdr_elv; map pqtzuv_map_tq; @@ -1063,14 +1064,13 @@ void process_pbfile(int i_pb) { mlcape_cnt_missing_values = mlcape_cnt_zero_values = 0; if (cal_pbl) { - is_same_header = false; prev_hdr_vld_ut = -1; m_strncpy(prev_hdr_typ, not_assigned, m_strlen(not_assigned), method_name_s, "prev_hdr_typ"); m_strncpy(prev_hdr_sid, not_assigned, m_strlen(not_assigned), method_name_s, "prev_hdr_sid"); } IMM = JMM =1; - p1d = t1d = q1d = r8bfms * 10; + p1d = t1d = q1d = (float)r8bfms * 10; cape_h = pbl_h = 0; cape_p = pbl_p = bad_data_float; @@ -1088,7 +1088,7 @@ void process_pbfile(int i_pb) { for (int idx=0; idx 0) { if(bin_count > 0 && (i_read+1)%bin_count == 0) { @@ -1167,7 +1167,8 @@ void process_pbfile(int i_pb) { } if (!is_prepbufr) { - int index, req_hdr_level = 1; + int index; + int req_hdr_level = 1; ConcatString tmp_str; //Read header (station id, lat, lon, ele, time) @@ -1286,11 +1287,9 @@ void process_pbfile(int i_pb) { // Include the area mask rejection counts with the polyline since // it is specified using the mask.poly config option. - if(apply_area_mask) { - if(!conf_info.area_mask.s_is_on(nint(x), nint(y))) { - rej_poly++; - continue; - } + if(apply_area_mask && !conf_info.area_mask.s_is_on(nint(x), nint(y))) { + rej_poly++; + continue; } } @@ -1385,9 +1384,6 @@ void process_pbfile(int i_pb) { } do_pbl = cal_pbl && 0 == strcmp("ADPUPA", hdr_typ); - if (do_pbl) { - pbl_level = 0; - } // Search through the vertical levels for(lv=0, n_hdr_obs = 0; lv MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { + mlog << Error << "\n" << method_name << " -> " + << "Invalid file ID [" << unit << "] between 1 and 99 for BUFR table.\n\n"; + } + get_variable_info(blk_file, unit); - // Assume that the input PrepBufr file is unblocked. - // Block the PrepBufr file and open it for reading. + // The input PrepBufr file is blocked already. unit = dump_unit + i_pb; - blk_file = make_temp_file_name(blk_prefix.c_str(), nullptr); - pblock(file_name.c_str(), blk_file.c_str(), block); if (unit > MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { mlog << Error << "\n" << method_name << " -> " << "Invalid file ID [" << unit << "] between 1 and 99.\n\n"; @@ -2169,9 +2161,6 @@ void process_pbfile_metadata(int i_pb) { mlog << Debug(1) << method_name << " -> " << "the number of records: " << npbmsg << "\n"; - // Open the blocked temp PrepBufr file for reading - openpb_(blk_file.c_str(), &unit); - // Use the number of records requested by the user if there // are enough present. if(nmsg >= 0 && nmsg <= npbmsg) { @@ -2189,16 +2178,17 @@ void process_pbfile_metadata(int i_pb) { << "No Bufr messages to process in file: " << pbfile[i_pb] << "\n\n"; - closepb_(&unit); - // Delete the temporary blocked file remove_temp_file(blk_file); return; } + // Open the blocked temp PrepBufr file for reading + openpb_(blk_file.c_str(), &unit); + // Initialize counts - i_ret = i_msg = 0; + i_ret = 0; StringArray headers; StringArray tmp_hdr_array; headers.add(prepbufr_hdrs);