Commit 2df4bac8 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Print the engine policy to the snapshots.

parent 73e4beb4
......@@ -375,9 +375,8 @@ void io_write_unit_system(hid_t h_file, const struct unit_system* us,
* @param h_file The (opened) HDF5 file in which to write
*/
void io_write_code_description(hid_t h_file) {
hid_t h_grpcode = 0;
h_grpcode = H5Gcreate1(h_file, "/Code", 0);
const hid_t h_grpcode = H5Gcreate1(h_file, "/Code", 0);
if (h_grpcode < 0) error("Error while creating code group");
io_write_attribute_s(h_grpcode, "Code", "SWIFT");
......@@ -409,6 +408,25 @@ void io_write_code_description(hid_t h_file) {
H5Gclose(h_grpcode);
}
/**
* @brief Write the #engine policy to the file.
* @param h_file File to write to.
* @param e The #engine to read the policy from.
*/
void io_write_engine_policy(hid_t h_file, const struct engine* e) {
const hid_t h_grp = H5Gcreate1(h_file, "/Policy", 0);
if (h_grp < 0) error("Error while creating policy group");
for (int i = 1; i <= engine_maxpolicy; ++i)
if (e->policy & (1 << i))
io_write_attribute_i(h_grp, engine_policy_names[i + 1], 1);
else
io_write_attribute_i(h_grp, engine_policy_names[i + 1], 0);
H5Gclose(h_grp);
}
#endif /* HAVE_HDF5 */
/**
......
......@@ -73,6 +73,7 @@ void io_write_attribute_l(hid_t grp, const char* name, long data);
void io_write_attribute_s(hid_t grp, const char* name, const char* str);
void io_write_code_description(hid_t h_file);
void io_write_engine_policy(hid_t h_file, const struct engine* e);
void io_read_unit_system(hid_t h_file, struct unit_system* us, int mpi_rank);
void io_write_unit_system(hid_t h_grp, const struct unit_system* us,
......
......@@ -87,15 +87,15 @@ const char *engine_policy_names[] = {"none",
"steal",
"keep",
"block",
"cpu_tight",
"cpu tight",
"mpi",
"numa_affinity",
"numa affinity",
"hydro",
"self_gravity",
"external_gravity",
"cosmology_integration",
"drift_all",
"reconstruct_mpoles",
"self gravity",
"external gravity",
"cosmological integration",
"drift everything",
"reconstruct multi-poles",
"cooling",
"sourceterms",
"stars"};
......@@ -5759,7 +5759,7 @@ void engine_print_policy(struct engine *e) {
printf("[0000] %s engine_policy: engine policies are [ ",
clocks_get_timesincestart());
for (int k = 0; k <= engine_maxpolicy; k++)
if (e->policy & (1 << k)) printf(" %s ", engine_policy_names[k + 1]);
if (e->policy & (1 << k)) printf(" '%s' ", engine_policy_names[k + 1]);
printf(" ]\n");
fflush(stdout);
}
......@@ -5767,7 +5767,7 @@ void engine_print_policy(struct engine *e) {
printf("%s engine_policy: engine policies are [ ",
clocks_get_timesincestart());
for (int k = 0; k <= engine_maxpolicy; k++)
if (e->policy & (1 << k)) printf(" %s ", engine_policy_names[k + 1]);
if (e->policy & (1 << k)) printf(" '%s' ", engine_policy_names[k + 1]);
printf(" ]\n");
fflush(stdout);
#endif
......
......@@ -899,6 +899,9 @@ void prepare_file(struct engine* e, const char* baseName, long long N_total[6],
/* Print the code version */
io_write_code_description(h_file);
/* Print the run's policy */
io_write_engine_policy(h_file, e);
/* Print the SPH parameters */
if (e->policy & engine_policy_hydro) {
h_grp = H5Gcreate(h_file, "/HydroScheme", H5P_DEFAULT, H5P_DEFAULT,
......
......@@ -807,6 +807,9 @@ void write_output_serial(struct engine* e, const char* baseName,
/* Print the code version */
io_write_code_description(h_file);
/* Print the run's policy */
io_write_engine_policy(h_file, e);
/* Print the SPH parameters */
if (e->policy & engine_policy_hydro) {
h_grp = H5Gcreate(h_file, "/HydroScheme", H5P_DEFAULT, H5P_DEFAULT,
......
......@@ -659,6 +659,9 @@ void write_output_single(struct engine* e, const char* baseName,
/* Print the code version */
io_write_code_description(h_file);
/* Print the run's policy */
io_write_engine_policy(h_file, e);
/* Print the SPH parameters */
if (e->policy & engine_policy_hydro) {
h_grp = H5Gcreate(h_file, "/HydroScheme", H5P_DEFAULT, H5P_DEFAULT,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment