changes from double to float to check if
error is indeed cancellation error
This commit is contained in:
@@ -197,6 +197,38 @@ void Hdf5Writer::write(const blitz::Array<double, 5>& data, std::string path) {
|
||||
H5Fclose(file);
|
||||
}
|
||||
|
||||
void Hdf5Writer::write(const blitz::Array<float, 5>& data, std::string path) {
|
||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
||||
|
||||
blitz::TinyVector<int, 5> size = data.extent();
|
||||
blitz::TinyVector<int, 5> start(0, 0, 0, 0, 0);
|
||||
|
||||
hid_t filespace =
|
||||
H5Screate_simple(5, blitz::TinyVector<hsize_t, 5>(size).data(), NULL);
|
||||
|
||||
hid_t lcpl = H5Pcreate(H5P_LINK_CREATE);
|
||||
H5Pset_create_intermediate_group(lcpl, 1);
|
||||
|
||||
// turn of error report by hdf5 because of check H5Dopen2
|
||||
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
||||
hid_t dataset;
|
||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||
if (dataset < 0) {
|
||||
dataset = H5Dcreate2(file, path.c_str(), H5T_NATIVE_FLOAT, filespace, lcpl,
|
||||
H5P_DEFAULT, H5P_DEFAULT);
|
||||
}
|
||||
// turn error report back onby hdf5 because of check H5Dopen2
|
||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
||||
|
||||
H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, filespace, H5P_DEFAULT,
|
||||
data.data());
|
||||
|
||||
H5Dclose(dataset);
|
||||
H5Pclose(lcpl);
|
||||
H5Sclose(filespace);
|
||||
H5Fclose(file);
|
||||
}
|
||||
|
||||
void Hdf5Writer::write(const blitz::Array<long int, 4>& data,
|
||||
std::string path) {
|
||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
||||
|
||||
@@ -27,6 +27,16 @@ void CpuSynchronizer::sumToAll(blitz::Array<double, 5>& array,
|
||||
last_sync_array += delta;
|
||||
}
|
||||
|
||||
void CpuSynchronizer::sumToAll(blitz::Array<float, 5>& array,
|
||||
blitz::Array<float, 5>& last_sync_array) {
|
||||
int size = array.size();
|
||||
blitz::Array<float, 5> delta(array.extent());
|
||||
delta = array - last_sync_array;
|
||||
MPI_Allreduce(MPI_IN_PLACE, delta.data(), size, MPI_FLOAT,
|
||||
MPI_SUM, MPI_COMM_WORLD);
|
||||
last_sync_array += delta;
|
||||
}
|
||||
|
||||
void CpuSynchronizer::sumToAll(blitz::Array<long int, 4>& array,
|
||||
blitz::Array<long int, 4>& last_sync_array) {
|
||||
int size = array.size();
|
||||
|
||||
@@ -61,7 +61,7 @@ DynamicDensityField::DynamicDensityField(
|
||||
energy_binning_(energy_binning),
|
||||
pitch_angle_binning_(pitch_angle_binning),
|
||||
timer_(timer),
|
||||
time_in_bin_s_(initiate5DArray<double>(
|
||||
time_in_bin_s_(initiate5DArray<float>(
|
||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||
position_binning.radial_binning.binIndexMax()),
|
||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
||||
@@ -72,7 +72,7 @@ DynamicDensityField::DynamicDensityField(
|
||||
pitch_angle_binning.binIndexMax()),
|
||||
blitz::Range(energy_binning.binIndexMin(),
|
||||
energy_binning.binIndexMax()))),
|
||||
sync_time_in_bin_s_(initiate5DArray<double>(
|
||||
sync_time_in_bin_s_(initiate5DArray<float>(
|
||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||
position_binning.radial_binning.binIndexMax()),
|
||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
||||
@@ -209,7 +209,7 @@ void DynamicDensityField::logMovement(const Coordinate& position,
|
||||
const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
||||
|
||||
time_in_bin_s_(position_bin(0), position_bin(1), position_bin(2),
|
||||
pitch_angle_bin, energy_bin) += weight;
|
||||
pitch_angle_bin, energy_bin) += static_cast<float>(weight);
|
||||
}
|
||||
|
||||
// void DynamicDensityField::logDeletion(const Coordinate& position,
|
||||
@@ -251,7 +251,7 @@ blitz::Array<double, 4> DynamicDensityField::spectrumArray() {
|
||||
return density_per_m3_;
|
||||
}
|
||||
|
||||
blitz::Array<double, 5> DynamicDensityField::timeInBinArray() const {
|
||||
blitz::Array<float, 5> DynamicDensityField::timeInBinArray() const {
|
||||
return time_in_bin_s_;
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ blitz::Array<double, 1> DynamicDensityField::
|
||||
energy_binning_.binIndexMax()-1)).copy();
|
||||
}
|
||||
|
||||
blitz::Array<double, 1> DynamicDensityField::
|
||||
blitz::Array<float, 1> DynamicDensityField::
|
||||
sliceTimeInBinArray(const Coordinate& position, double energy_eV) const {
|
||||
blitz::TinyVector<int, 3> position_bin =
|
||||
position_binning_.bin(position.cylinderEntries());
|
||||
|
||||
@@ -67,7 +67,7 @@ CartesianVector VelocityDistributionFromDensityField::rollVelocity(
|
||||
|
||||
// draw pitch angle from DynamicDensityField
|
||||
|
||||
blitz::Array<double, 1> pitchAngleValues = density_field_->
|
||||
blitz::Array<float, 1> pitchAngleValues = density_field_->
|
||||
sliceTimeInBinArray(position, energy_eV);
|
||||
|
||||
std::piecewise_constant_distribution<double> pitchAngle_dist(
|
||||
@@ -113,7 +113,7 @@ CartesianVector VelocityDistributionFromDensityField::rollVelocity(
|
||||
|
||||
// draw pitch angle from DynamicDensityField
|
||||
|
||||
blitz::Array<double, 1> pitchAngleValues = density_field_->
|
||||
blitz::Array<float, 1> pitchAngleValues = density_field_->
|
||||
sliceTimeInBinArray(position, energy_eV);
|
||||
|
||||
std::piecewise_constant_distribution<double> pitchAngle_dist(
|
||||
|
||||
Reference in New Issue
Block a user