Improved output and config

This commit is contained in:
Yohai Meiron 2020-03-31 22:06:04 -04:00
parent 5cb4282be4
commit 62b0d7e491
6 changed files with 126 additions and 107 deletions

14
io.cpp
View file

@ -142,7 +142,7 @@ void h5_read(const std::string file_name, int *step_num, int *N, double *t, doub
#endif
}
void h5_write(const std::string file_name, const int step_num, const int N, const double t, const double *m, const double3 *x, const double3 *v, const double *pot, const double3 *acc, const double3 *jrk, const int write_mode=0, const bool use_double_precision=true)
void h5_write(const std::string file_name, const int step_num, const int N, const double t, const double *m, const double3 *x, const double3 *v, const double *pot, const double3 *acc, const double3 *jrk, const int extra_mode=0, const bool use_double_precision=true)
{
#ifdef HAS_HDF5
hid_t file_id, group_id, attribute_id, dataset_id, dataspace_id;
@ -151,13 +151,7 @@ void h5_write(const std::string file_name, const int step_num, const int N, cons
hid_t h5_float_type;
if (use_double_precision) h5_float_type = H5T_IEEE_F64LE;
else h5_float_type = H5T_IEEE_F32LE;
// static int zzz = 5;
file_id = H5Fcreate(file_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
// file_id = H5Fcreate(std::to_string(zzz).c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
// zzz++;
char group_name[32];
sprintf(group_name, "/Step#%d", step_num);
group_id = H5Gcreate2(file_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
@ -180,9 +174,9 @@ void h5_write(const std::string file_name, const int step_num, const int N, cons
write_dataset("X", 2, (double*)x);
write_dataset("V", 2, (double*)v);
bool write_pot = (write_mode ) % 2;
bool write_acc = (write_mode >> 1) % 2;
bool write_jrk = (write_mode >> 2) % 2;
bool write_pot = (extra_mode ) % 2;
bool write_acc = (extra_mode >> 1) % 2;
bool write_jrk = (extra_mode >> 2) % 2;
if (write_pot) write_dataset("POT", 1, (double*)pot);
if (write_acc) write_dataset("ACC", 2, (double*)acc);
if (write_jrk) write_dataset("JRK", 2, (double*)jrk);