diff --git a/src/common_io.c b/src/common_io.c index 53ca5cc4b72d57756e3cf3cd406108923ae81659..67326817397118568e060f5dff49421bb32fba4d 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -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 */ /** diff --git a/src/common_io.h b/src/common_io.h index c317238160e45a9d141619d313e47c715adf8537..49358d8a374553d803de144f1135df6eee80cf15 100644 --- a/src/common_io.h +++ b/src/common_io.h @@ -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, diff --git a/src/engine.c b/src/engine.c index c48510b657a2eae3420dc9f3d95624d47b719812..df55ac42ce90dc19b7d8ae7790d6d90b7dc22ced 100644 --- a/src/engine.c +++ b/src/engine.c @@ -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 diff --git a/src/parallel_io.c b/src/parallel_io.c index 315c187e65f1a30b0401cb9368944f8f9968223a..e6e1dfd703084a7de1eac20864940b129cad4fcb 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -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, diff --git a/src/serial_io.c b/src/serial_io.c index 047c3d3f88ba56eca8720fa06bba9bf5c3db07b7..6747b345db1dac9bff51e4d9c4d888105a01a90f 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -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, diff --git a/src/single_io.c b/src/single_io.c index 4ba85c2b1b6970469b17ac2d475e297b848604c6..862851378d0cc82f775c144f10a47e8fdbe6591e 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -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,