User: reisswig Date: 2015/07/09 07:47 AM
Added: /PITTNullCode/SphericalHarmonicReconGen/src/ vars.cc
Modified: /PITTNullCode/SphericalHarmonicReconGen/src/ get.cc, make.code.defn, read.cc, sph_database.cc, startup.cc
Log: SphericalHarmonicReconstructGen: Don't use cout, make sure to abort with proper error (don't use assert), make sure all extern "C" functions are starting with SphericalHarmonicReconstructGen_*, consolidated global variables in namspace SHR in file vars.cc.
File Changes:
Directory: /PITTNullCode/SphericalHarmonicReconGen/src/ =======================================================
File [modified]: get.cc Delta lines: +0 -15 =================================================================== --- PITTNullCode/SphericalHarmonicReconGen/src/get.cc 2015-07-09 11:55:34 UTC (rev 123) +++ PITTNullCode/SphericalHarmonicReconGen/src/get.cc 2015-07-09 12:47:48 UTC (rev 124) @@ -8,21 +8,6 @@ #include "vars.hh"
-namespace SHR { - - -vector<SPH_database*> db(NUM_METRIC_COMPONENTS*3, NULL); - -vector<spherical_decomposed_variable<CCTK_REAL>* > C(NUM_METRIC_COMPONENTS, NULL); -vector<spherical_decomposed_variable<CCTK_REAL>* > Cr(NUM_METRIC_COMPONENTS, NULL); -vector<spherical_decomposed_variable<CCTK_REAL>* > Ct(NUM_METRIC_COMPONENTS, NULL); - -int timelevel = 0; - - - -} - extern "C" {
File [modified]: make.code.defn Delta lines: +1 -1 =================================================================== --- PITTNullCode/SphericalHarmonicReconGen/src/make.code.defn 2015-07-09 11:55:34 UTC (rev 123) +++ PITTNullCode/SphericalHarmonicReconGen/src/make.code.defn 2015-07-09 12:47:48 UTC (rev 124) @@ -2,7 +2,7 @@ # $Header:$
# Source files in this directory -SRCS = get.cc read.cc startup.cc sph_database.cc +SRCS = get.cc read.cc startup.cc sph_database.cc vars.cc
# Subdirectories containing source files SUBDIRS =
File [modified]: read.cc Delta lines: +8 -15 =================================================================== --- PITTNullCode/SphericalHarmonicReconGen/src/read.cc 2015-07-09 11:55:34 UTC (rev 123) +++ PITTNullCode/SphericalHarmonicReconGen/src/read.cc 2015-07-09 12:47:48 UTC (rev 124) @@ -9,17 +9,7 @@
#include "vars.hh"
-namespace SHR {
-/* state info vars */ -int initialized = 0; -int read_data = 0; - -int iteration_in_file = 0; - - -} - using namespace std;
namespace @@ -33,14 +23,17 @@ int iteration = SHR::C[0]->get_iteration(time + SHR::initial_time_in_file);
if (iteration < 0) { - cout << "Error: iteration = -1. time = "<<time << ", SHR::initial_time_in_file="<<SHR::initial_time_in_file << endl; - assert(iteration >= 0); + stringstream str; + str << "Error: iteration = -1. time = "<<time << ", SHR::initial_time_in_file="<<SHR::initial_time_in_file; + CCTK_ERROR(str.str().c_str()); }
if (iteration < 2) { - if(allow_offcentered_time_stencils) iteration=2; - else cout << "Error: there are not enough iterations before interpolation target time to do the interpolation!" << endl; - assert(iteration >= 2); + if(allow_offcentered_time_stencils) + iteration=2; + else { + CCTK_ERROR("Error: there are not enough iterations before interpolation target time to do the interpolation!"); + } }
// set all modes from file necessary for 5th-order time interpolation
File [modified]: sph_database.cc Delta lines: +124 -30 =================================================================== --- PITTNullCode/SphericalHarmonicReconGen/src/sph_database.cc 2015-07-09 11:55:34 UTC (rev 123) +++ PITTNullCode/SphericalHarmonicReconGen/src/sph_database.cc 2015-07-09 12:47:48 UTC (rev 124) @@ -47,7 +47,9 @@ // check continuity and delta_t of timesteps if (_times.size() > 1) { - cout << "SPH_db_ASCII " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back() << endl; + stringstream str; + str << "SPH_db_ASCII " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back(); + CCTK_INFO(str.str().c_str()); _delta_t = 0; for (size_t i=1; i < _times.size(); ++i) { @@ -58,8 +60,10 @@ } if (verbose && fabs(_times[i] - _times[i-1] - _delta_t) >= 1e-8) { + stringstream str; _delta_t = _times[i]-_times[i-1]; - cout << "SPH_db_ASCII " << _fname << ": t = " << _times[i-1] << ", delta_t = " << _delta_t << endl; + str << "SPH_db_ASCII " << _fname << ": t = " << _times[i-1] << ", delta_t = " << _delta_t; + CCTK_INFO(str.str().c_str()); } } // set _delta_t to correspond to initial delta_t @@ -340,14 +344,37 @@
file.clear();
- cout << "SPH_db_ASCII " << _fname << ": n_spheres = " << _n_spheres << endl; + { + stringstream str; + str << "SPH_db_ASCII " << _fname << ": n_spheres = " << _n_spheres; + CCTK_INFO(str.str().c_str()); + } if (_col_radius >= 0) - for (int i=0; i < _n_spheres; ++i) - cout << "SPH_db_ASCII " << _fname << ": radius[" << i << "] = " << _radii[i] << endl; - cout << "SPH_db_ASCII " << _fname << ": n_columns = " << _n_variables << endl; - cout << "SPH_db_ASCII " << _fname << ": n_variables = " << _n_variables << endl; - cout << "SPH_db_ASCII " << _fname << ": lmax = " << _lmax << endl; - cout << "SPH_db_ASCII " << _fname << ": timesteps = " << _iterations.size() << endl; + for (int i=0; i < _n_spheres; ++i) { + stringstream str; + str << "SPH_db_ASCII " << _fname << ": radius[" << i << "] = " << _radii[i]; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_ASCII " << _fname << ": n_columns = " << _n_variables; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_ASCII " << _fname << ": n_variables = " << _n_variables; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_ASCII " << _fname << ": lmax = " << _lmax; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_ASCII " << _fname << ": timesteps = " << _iterations.size(); + CCTK_INFO(str.str().c_str()); + }
// we append to byte_offset the end of the file byte_offset.push_back(file.tellg()); @@ -400,9 +427,11 @@
// at least (0,0) mode of one variable (real and imag part) must be there columns_assigned += 2; + + stringstream str; + str << "SPH_db_DAT " << _fname << ": Expecting at least " << columns_assigned << " columns in boundary data file."; + CCTK_INFO(str.str().c_str());
- cout << "SPH_db_DAT " << _fname << ": Expecting at least " << columns_assigned << " columns in boundary data file." << endl; - file.open(fname_.c_str()); scan(); } @@ -420,7 +449,9 @@ // check continuity and delta_t of timesteps if (_times.size() > 1) { - cout << "SPH_db_DAT " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back() << endl; + stringstream str; + str << "SPH_db_DAT " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back(); + CCTK_INFO(str.str().c_str()); _delta_t = 0; for (size_t i=1; i < _times.size(); ++i) { @@ -432,7 +463,9 @@ if (verbose && fabs(_times[i] - _times[i-1] - _delta_t) >= 1e-8) { _delta_t = _times[i]-_times[i-1]; - cout << "SPH_db_DAT " << _fname << ": t = " << _times[i-1] << ", delta_t = " << _delta_t << endl; + ostringstream str; + str << "SPH_db_DAT " << _fname << ": t = " << _times[i-1] << ", delta_t = " << _delta_t; + CCTK_INFO(str.str().c_str()); } } // set _delta_t to correspond to initial delta_t @@ -700,11 +733,31 @@
file.clear();
- cout << "SPH_db_DAT " << _fname << ": n_spheres = " << _n_spheres << endl; - cout << "SPH_db_DAT " << _fname << ": n_columns = " << num_columns << endl; - cout << "SPH_db_DAT " << _fname << ": n_variables = " << _n_variables << endl; - cout << "SPH_db_DAT " << _fname << ": lmax = " << _lmax << endl; - cout << "SPH_db_DAT " << _fname << ": timesteps = " << _iterations.size() << endl; + { + stringstream str; + str << "SPH_db_DAT " << _fname << ": n_spheres = " << _n_spheres; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_DAT " << _fname << ": n_columns = " << num_columns; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_DAT " << _fname << ": n_variables = " << _n_variables; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_DAT " << _fname << ": lmax = " << _lmax; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_DAT " << _fname << ": timesteps = " << _iterations.size(); + CCTK_INFO(str.str().c_str()); + }
// we append to byte_offset the end of the file byte_offset.push_back(file.tellg()); @@ -818,7 +871,9 @@ // check continuity and delta_t of timesteps if (_times.size() > 1) { - cout << "SPH_db_SpEC_H5 " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back() << endl; + stringstream str; + str << "SPH_db_SpEC_H5 " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back(); + CCTK_INFO(str.str().c_str()); _delta_t = 0; for (size_t i=1; i < _times.size(); ++i) { @@ -832,7 +887,9 @@ if (verbose && fabs(_times[i] - _times[i-1] - _delta_t) >= 1e-8) { _delta_t = _times[i]-_times[i-1]; - cout << "SPH_db_SpEC_H5 " << _fname << ": t = " << _times[i-1] << ", delta_t = " << _delta_t << endl; + stringstream str; + str << "SPH_db_SpEC_H5 " << _fname << ": t = " << _times[i-1] << ", delta_t = " << _delta_t; + CCTK_INFO(str.str().c_str()); } } // set _delta_t to correspond to initial delta_t @@ -938,10 +995,27 @@
// display some info - cout << "SPH_db_SpEC_H5 " << _fname << ": n_spheres = " << _n_spheres << endl; - cout << "SPH_db_SpEC_H5 " << _fname << ": n_variables = " << _n_variables << endl; - cout << "SPH_db_SpEC_H5 " << _fname << ": lmax = " << _lmax << endl; - cout << "SPH_db_SpEC_H5 " << _fname << ": timesteps = " << _iterations.size() << endl; + + { + stringstream str; + str << "SPH_db_SpEC_H5 " << _fname << ": n_spheres = " << _n_spheres; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_SpEC_H5 " << _fname << ": n_variables = " << _n_variables; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_SpEC_H5 " << _fname << ": lmax = " << _lmax; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_SpEC_H5 " << _fname << ": timesteps = " << _iterations.size(); + CCTK_INFO(str.str().c_str()); + } }
@@ -1036,7 +1110,9 @@ // check continuity and delta_t of timesteps if (_times.size() > 1) { - cout << "SPH_db_SpEC_H5 " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back() << endl; + stringstream str; + str << "SPH_db_SpEC_H5 " << _fname << ": t_0 = " << _times[0] << ", t_final = " << _times.back(); + CCTK_INFO(str.str().c_str()); _delta_t = 0; for (size_t i=1; i < _times.size(); ++i) { @@ -1050,7 +1126,9 @@ if (verbose && fabs(_times[i] - _times[i-1] - _delta_t) >= 1e-8) { _delta_t = _times[i]-_times[i-1]; - cout << "SPH_db_SpEC_H5_v2 " << _fname << ": t = " << _times[i-1] << ", delta_t = " << _delta_t << endl; + stringstream str; + str << "SPH_db_SpEC_H5_v2 " << _fname << ": t = " << _times[i-1] << ", delta_t = " << _delta_t; + CCTK_INFO(str.str().c_str()); } } // set _delta_t to correspond to initial delta_t @@ -1186,10 +1264,26 @@
// display some info - cout << "SPH_db_SpEC_H5_v2 " << _fname << ": n_spheres = " << _n_spheres << endl; - cout << "SPH_db_SpEC_H5_v2 " << _fname << ": n_variables = " << _n_variables << endl; - cout << "SPH_db_SpEC_H5_v2 " << _fname << ": lmax = " << _lmax << endl; - cout << "SPH_db_SpEC_H5_v2 " << _fname << ": timesteps = " << _iterations.size() << endl; + { + stringstream str; + str << "SPH_db_SpEC_H5_v2 " << _fname << ": n_spheres = " << _n_spheres; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_SpEC_H5_v2 " << _fname << ": n_variables = " << _n_variables; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_SpEC_H5_v2 " << _fname << ": lmax = " << _lmax; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << "SPH_db_SpEC_H5_v2 " << _fname << ": timesteps = " << _iterations.size(); + CCTK_INFO(str.str().c_str()); + }
}
File [modified]: startup.cc Delta lines: +15 -16 =================================================================== --- PITTNullCode/SphericalHarmonicReconGen/src/startup.cc 2015-07-09 11:55:34 UTC (rev 123) +++ PITTNullCode/SphericalHarmonicReconGen/src/startup.cc 2015-07-09 12:47:48 UTC (rev 124) @@ -8,19 +8,7 @@
#include "vars.hh"
-namespace SHR {
-int time_derivative_in_file = 0; -MPI_Comm comm_world = MPI_COMM_NULL; - -// initial time found in boundary data files. -CCTK_REAL initial_time_in_file = 0; -int starting_iteration = 0; - -bool use_Condon_Shortley_phase_factor = false; - -} - using namespace std;
extern "C" void SphericalHarmonicReconGeneric_Startup(CCTK_ARGUMENTS) @@ -32,8 +20,11 @@
SHR::initialized = 1;
- if (verbose) - cout << "char. dt = " << cctk_delta_time << endl; + if (verbose) { + stringstream str; + str << "char. dt = " << cctk_delta_time << endl; + CCTK_INFO(str.str().c_str()); + }
if (CCTK_IsFunctionAliased("GetMPICommWorld")) { @@ -148,8 +139,16 @@ else CCTK_INFO("Time step-size of harmonic amplitudes of Cauchy variables is smaller than characteristic time step-size!"); - cout << " (intitial) Cauchy dt = " << SHR::db[i]->delta_t() << endl; - cout << " char. dt = " << CCTK_DELTA_TIME << endl; + { + stringstream str; + str << " (intitial) Cauchy dt = " << SHR::db[i]->delta_t() << endl; + CCTK_INFO(str.str().c_str()); + } + { + stringstream str; + str << " char. dt = " << CCTK_DELTA_TIME << endl; + CCTK_INFO(str.str().c_str()); + } if (!time_interpolate) CCTK_WARN(0, "Time interpolation has not been requested! Stopping.");
File [added]: vars.cc Delta lines: +26 -0 =================================================================== --- PITTNullCode/SphericalHarmonicReconGen/src/vars.cc (rev 0) +++ PITTNullCode/SphericalHarmonicReconGen/src/vars.cc 2015-07-09 12:47:48 UTC (rev 124) @@ -0,0 +1,26 @@ +#include "vars.hh" + +namespace SHR { + +/* state info vars */ +int initialized; +int read_data; + +int time_derivative_in_file; + +int starting_iteration; +int iteration_in_file; +CCTK_REAL initial_time_in_file; + +vector<SPH_database*> db; + +vector<spherical_decomposed_variable<CCTK_REAL>* > C; +vector<spherical_decomposed_variable<CCTK_REAL>* > Cr; +vector<spherical_decomposed_variable<CCTK_REAL>* > Ct; + +bool use_Condon_Shortley_phase_factor; + +MPI_Comm comm_world; + +} +