User: reisswig Date: 2012/05/26 05:10 PM
Modified: /PITTNullCode/SphericalHarmonicReconASCII/src/ sph_database.cc, sph_database.hh
Log: SphericalHarmonicReconASCII: Cleared all warnings from gcc/g++.
File Changes:
Directory: /PITTNullCode/SphericalHarmonicReconASCII/src/ =========================================================
File [modified]: sph_database.cc Delta lines: +17 -32 =================================================================== --- PITTNullCode/SphericalHarmonicReconASCII/src/sph_database.cc 2012-05-26 21:14:22 UTC (rev 68) +++ PITTNullCode/SphericalHarmonicReconASCII/src/sph_database.cc 2012-05-26 22:10:29 UTC (rev 69) @@ -33,7 +33,7 @@ { cout << "SPH_db_ASCII " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back() << endl; _delta_t = 0; - for (int i=1; i < _times.size(); ++i) + for (size_t i=1; i < _times.size(); ++i) { if (fabs(_times[i] - _times[i-1]) < 1e-8 || _times[i] < _times[i-1]) { ostringstream str; @@ -157,7 +157,7 @@
// read all modes on all extraction spheres for a given timestep and variable number into array -void SPH_db_ASCII::read(const int timestep, const int varno, +void SPH_db_ASCII::read(const size_t timestep, const size_t varno, vector<vector<vector<CCTK_COMPLEX> > >& coeff) const { //cout << _fname << ": reading timestep " << timestep << ", variable " << varno << endl; @@ -171,7 +171,7 @@
// set up cache if (setup_cache) { - for (int t=0; t < cache.size(); ++t) { + for (size_t t=0; t < cache.size(); ++t) { cache[t].resize(_n_variables); for (int v=0; v < _n_variables; ++v) { cache[t][v].resize(_n_spheres); @@ -199,7 +199,7 @@ istringstream instream; // input string-stream string s;
- double val, val_re, val_im; + double val; int sphere = 0, l = 0, m = 0; int t = 0;
@@ -209,7 +209,7 @@ else byte_block_end = byte_offset[timestep+cache.size()];
- while (file.good() && file.tellg() < byte_block_end) + while (file.good() && (size_t)file.tellg() < byte_block_end) { if (file.tellg() >= byte_offset[timestep+t+1]) { @@ -226,9 +226,6 @@ // read line from file (max 10000 chars) file.getline(line_buffer, 10000);
- // store length of input line - int line_length = strlen(line_buffer); - // set input -stringstream to line-buffer string s = (const char*) line_buffer; instream.str(s); @@ -307,7 +304,7 @@ record_t this_line; // the extracted data-info of the current line record_t prev_line; // the extracted data-info of the previous line
- int datasets_per_line; // the number of the actual data in one line + int datasets_per_line = -1; // the number of the actual data in one line int first_line = 1;
if (!file || !file.good()) @@ -340,9 +337,6 @@ // read line from file (max 10000 chars) file.getline(line_buffer, 10000);
- // store length of input line - int line_length = strlen(line_buffer); - // set input -stringstream to line-buffer string s = (const char*) line_buffer; instream.str(s); @@ -486,7 +480,7 @@ const int col_data_) : SPH_database(cached_timesteps), _fname(fname_), _col_time(col_time_), _col_iteration(col_iteration_), _col_radius(col_radius_), _col_lmax(col_lmax_), - columns_assigned(0), _col_n_variables(col_n_variables_), _col_data(col_data_) + _col_n_variables(col_n_variables_), _col_data(col_data_), columns_assigned(0) { _lmax = lmax_; _n_spheres = 1; @@ -525,7 +519,7 @@ { cout << "SPH_db_DAT " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back() << endl; _delta_t = 0; - for (int i=1; i < _times.size(); ++i) + for (size_t i=1; i < _times.size(); ++i) { if (fabs(_times[i] - _times[i-1]) < 1e-8 || _times[i] < _times[i-1]) { ostringstream str; @@ -544,7 +538,7 @@ }
// read all modes on all extraction spheres for a given timestep and variable number into array -void SPH_db_DAT::read(const int timestep, const int varno, +void SPH_db_DAT::read(const size_t timestep, const size_t varno, vector<vector<vector<CCTK_COMPLEX> > >& coeff) const { //cout << _fname << ": reading timestep " << timestep << ", variable " << varno << endl; @@ -558,7 +552,7 @@
// set up cache if (setup_cache) { - for (int t=0; t < cache.size(); ++t) { + for (size_t t=0; t < cache.size(); ++t) { cache[t].resize(2*_n_variables); for (int v=0; v < 2*_n_variables; ++v) { cache[t][v].resize(_n_spheres); @@ -588,7 +582,7 @@ istringstream instream; // input string-stream string s;
- double val, val_re, val_im; + double val; int sphere = 0, l = 0, m = 0; int t = 0; int v = 0; @@ -601,7 +595,7 @@
int column = _col_data;
- while (file.good() && file.tellg() < byte_block_end) + while (file.good() && (size_t)file.tellg() < byte_block_end) { if (file.tellg() >= byte_offset[timestep+t+1]) { @@ -618,9 +612,6 @@ // read line from file (max 1000000 chars) file.getline(line_buffer, 1000000);
- // store length of input line - int line_length = strlen(line_buffer); - // set input -stringstream to line-buffer string s = (const char*) line_buffer; instream.str(s); @@ -737,10 +728,6 @@ istringstream instream; // input string-stream string s;
- - - int n_blank_lines = 0; - int n_lines = 0; _n_spheres = 1; // we assume we have at least one sphere in that file while (file.good()) { @@ -755,9 +742,6 @@ // read line from file (max 1000000 chars) file.getline(line_buffer, 1000000);
- // store length of input line - int line_length = strlen(line_buffer); - // set input -stringstream to line-buffer string s = (const char*) line_buffer; instream.str(s); @@ -959,7 +943,7 @@ { cout << "SPH_db_SpEC_H5 " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back() << endl; _delta_t = 0; - for (int i=1; i < _times.size(); ++i) + for (size_t i=1; i < _times.size(); ++i) { if (fabs(_times[i] - _times[i-1]) < 1e-8 || _times[i] < _times[i-1]) { ostringstream str; @@ -983,7 +967,7 @@
-void SPH_db_SpEC_H5::read(const int timestep, const int varno, +void SPH_db_SpEC_H5::read(const size_t timestep, const size_t varno, vector<vector<vector<CCTK_COMPLEX> > >& coeff) const { if (timestep >= steps.size()) { @@ -1046,12 +1030,13 @@ // pick one variable and browse through entire file // to find out how many (and what) cycles and times there are // (assuming that all variables are present at the same timesteps) - herr_t status = H5Literate_by_name (file, varname_table[0][0].c_str(), H5_INDEX_NAME, H5_ITER_NATIVE, NULL, H5iter, this, H5P_DEFAULT); + H5Literate_by_name (file, varname_table[0][0].c_str(), H5_INDEX_NAME, H5_ITER_NATIVE, NULL, H5iter, this, H5P_DEFAULT); + // sort 'steps' vector //sort(steps.begin(), steps.end()); _iterations.resize(steps.size()); _times.resize(steps.size()); - for (int i=0; i < steps.size(); ++i) { + for (size_t i=0; i < steps.size(); ++i) { //cout << steps[i].name << " " << steps[i].time << endl; _iterations[i] = i; _times[i] = steps[i].time;
File [modified]: sph_database.hh Delta lines: +38 -32 =================================================================== --- PITTNullCode/SphericalHarmonicReconASCII/src/sph_database.hh 2012-05-26 21:14:22 UTC (rev 68) +++ PITTNullCode/SphericalHarmonicReconASCII/src/sph_database.hh 2012-05-26 22:10:29 UTC (rev 69) @@ -39,14 +39,16 @@ { public : SPH_database() - : _delta_t(0), _lmax(0), _n_spheres(0), _radii(0), - _n_variables(0), _times(vector<CCTK_REAL>(0)), - _iterations(vector<CCTK_INT>(0)), cache(1), cached_first_timestep(0), setup_cache(true) { }; + : _times(vector<CCTK_REAL>(0)), _iterations(vector<CCTK_INT>(0)), _radii(0), + cache(1), cached_first_timestep(0), setup_cache(true), + _delta_t(0), _lmax(0), _n_spheres(0), + _n_variables(0) { };
- SPH_database(const int cached_timesteps) - : _delta_t(0), _lmax(0), _n_spheres(0), _radii(0), - _n_variables(0), _times(vector<CCTK_REAL>(0)), - _iterations(vector<CCTK_INT>(0)), cache(cached_timesteps), cached_first_timestep(0), setup_cache(true) { assert(cached_timesteps >= 1); }; + SPH_database(const size_t cached_timesteps) + : _times(vector<CCTK_REAL>(0)),_iterations(vector<CCTK_INT>(0)), _radii(0), + cache(cached_timesteps), cached_first_timestep(0), setup_cache(true), + _delta_t(0), _lmax(0), _n_spheres(0), + _n_variables(0) { assert(cached_timesteps >= 1); };
virtual ~SPH_database() { };
@@ -54,21 +56,21 @@ int n_variables() const { return _n_variables; } int n_spheres() const { return _n_spheres; } int n_timesteps() const { return _times.size(); } - CCTK_REAL time(int n) const { assert(n < _times.size()); return _times[n]; } - CCTK_INT iteration(int n) const { assert(n < _iterations.size()); return _iterations[n]; } + CCTK_REAL time(size_t n) const { assert(n < _times.size()); return _times[n]; } + CCTK_INT iteration(size_t n) const { assert(n < _iterations.size()); return _iterations[n]; } CCTK_REAL delta_t() const { return _delta_t; } - CCTK_REAL radius(const int sphere_number) { if (_radii.size() <= sphere_number) return -1; return _radii[sphere_number]; } + CCTK_REAL radius(const size_t sphere_number) { if (_radii.size() <= sphere_number) return -1; return _radii[sphere_number]; }
// scan file for timesteps, variables, extraction spheres, l-modes virtual void scan() = 0;
// read all modes on all extraction spheres for a given timestep and variable number (i.e. column number) into array - virtual void read(const int timestep, const int varno, + virtual void read(const size_t timestep, const size_t varno, vector<vector<vector<CCTK_COMPLEX> > >& coeff) const = 0;
// checks if requested timestep and variable is in cache. // If yes, it will be put into coeff array - bool is_in_cache(const int timestep, const int varno, + bool is_in_cache(const size_t timestep, const size_t varno, vector<vector<vector<CCTK_COMPLEX> > >& coeff) const { if (setup_cache) return false; @@ -97,19 +99,20 @@ // we always cache at least one timestep so that the the various variables do not need to be read in again. mutable vector<vector<vector<vector<vector<CCTK_REAL> > > > > cache; // start timestep of cache - mutable int cached_first_timestep; + mutable size_t cached_first_timestep; // at first read operation, cache must be setup mutable bool setup_cache;
// the timestep size found in file CCTK_REAL _delta_t;
+ // number of l-modes + int _lmax; // number of extraction spheres int _n_spheres; // number of variables int _n_variables; - // number of l-modes - int _lmax; + };
@@ -131,7 +134,7 @@ virtual void scan();
// read all modes on all extraction spheres for a given timestep and variable number into array - virtual void read(const int timestep, const int varno, + virtual void read(const size_t timestep, const size_t varno, vector<vector<vector<CCTK_COMPLEX> > >& coeff) const;
private : @@ -145,7 +148,7 @@ int _col_radius; // a structure holding the data of one line - typedef struct + struct record_t { unsigned long long byte_offset; // the byte position of this line in file int line_length; // byte length of line @@ -154,8 +157,10 @@ int it; double radius; + record_t() : byte_offset(0), line_length(0), time(-100000), it(0), radius(0) { } + //vector<double> columns; - } record_t; + };
int num_columns; @@ -180,8 +185,6 @@
void new_dataset(const record_t& tl) { - int found_new = 0; - _times.push_back(tl.time); _iterations.push_back(tl.it); byte_offset.push_back(tl.byte_offset); @@ -215,7 +218,7 @@ virtual void scan();
// read all modes on all extraction spheres for a given timestep and variable number into array - virtual void read(const int timestep, const int varno, + virtual void read(const size_t timestep, const size_t varno, vector<vector<vector<CCTK_COMPLEX> > >& coeff) const;
private : @@ -232,7 +235,7 @@ int _col_data; // a structure holding the data of one line - typedef struct + struct record_t { unsigned long long byte_offset; // the byte position of this line in file int line_length; // byte length of line @@ -243,8 +246,11 @@ int lmax; int n_variables; + record_t() : byte_offset(0), line_length(0), time(-100000), it(0), radius(0), + lmax(-1), n_variables(-1) { } + //vector<double> columns; - } record_t; + };
int num_columns; @@ -269,8 +275,6 @@
void new_dataset(const record_t& tl) { - int found_new = 0; - _times.push_back(tl.time); _iterations.push_back(tl.it); byte_offset.push_back(tl.byte_offset); @@ -296,7 +300,7 @@ virtual void scan();
// read all modes on all extraction spheres for a given timestep and variable number into array - virtual void read(const int timestep, const int varno, + virtual void read(const size_t timestep, const size_t varno, vector<vector<vector<CCTK_COMPLEX> > >& coeff) const;
private : @@ -360,10 +364,13 @@ const int sphere_no_, const SPH_database& db_, const MPI_Comm comm_world_) - : cctkGH(cctkGH_), _lmax(db_.lmax()), - _n_timelevels(n_timelevels_), _time_fd_order(time_fd_order_), _dt(dt_), + : _lmax(db_.lmax()), + _n_timelevels(n_timelevels_), _n_timelevels_for_coeff_in_file(n_timelevels_for_coeff_in_file_), - _varno(varno_), _sphere_no(sphere_no_), _timelevel(timelevel_), _db(db_), + _varno(varno_), _sphere_no(sphere_no_), _timelevel(timelevel_), _time_fd_order(time_fd_order_), + _db(db_), + _dt(dt_), + cctkGH(cctkGH_), _comm_world(comm_world_) { // we will do 2nd-order centered time-derivative @@ -512,10 +519,9 @@ CCTK_COMPLEX get_mode_dt(const int l, const int m) const { assert(_time_fd_order == 2 || _time_fd_order ==4); - cout << "bla--------------------!!!!!!!!!!!!!!!!!!!!!" << endl;
- CCTK_REAL re; - CCTK_REAL im; + CCTK_REAL re = -1e6; + CCTK_REAL im = -1e6; if (_time_fd_order == 2) { assert(_n_timelevels == 3);