diff --git a/src/engine.c b/src/engine.c index a0b2ec53f9e479090fbc508e3b602e34e1a6391b..27fcb118102e86efb2e05beb9fb0a8647234b480 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5641,10 +5641,9 @@ void engine_struct_dump(struct engine *e, FILE *stream) { /* Now for the other pointers, these use their own save functions. */ space_struct_dump(e->s, stream); e->s->e = e; + units_struct_dump(e->internal_units, stream); + units_struct_dump(e->snapshotUnits, stream); - - /* internal units */ - /* snapshot units */ /* repartition */ /* physical constants */ /* hydro props */ diff --git a/src/units.c b/src/units.c index c9038924fa540f7df86f44db885cc2ec28672a4e..79971815920700e7ab5dbe08d8d760e7527bb3cf 100644 --- a/src/units.c +++ b/src/units.c @@ -39,6 +39,7 @@ /* Includes. */ #include "adiabatic_index.h" #include "error.h" +#include "restart.h" /** * @brief Initialises the unit_system structure with CGS system @@ -602,3 +603,27 @@ void units_print(const struct unit_system* us) { message("\tUnit Current: %g", us->UnitCurrent_in_cgs); message("\tUnit Temperature: %g", us->UnitTemperature_in_cgs); } + + +/** + * @brief Write a units struct to the given FILE as a stream of bytes. + * + * @param us the units + * @param stream the file stream + */ +void units_struct_dump(const struct unit_system *us, FILE *stream) { + restart_write_blocks((void *)us, sizeof(struct unit_system), 1, stream, + "units"); +} + + +/** + * @brief Restore a units struct from the given FILE as a stream of bytes. + * + * @param us the units + * @param stream the file stream + */ +void units_struct_restore(const struct unit_system *us, FILE *stream) { + restart_read_blocks((void *)us, sizeof(struct unit_system), 1, stream, + "units"); +} diff --git a/src/units.h b/src/units.h index 657b29c070f3816293c18edfc46ad6b960ec9b33..7f74e2b19fcda73d3e22167b3d4bd6cc3b166f46 100644 --- a/src/units.h +++ b/src/units.h @@ -139,4 +139,8 @@ double units_conversion_factor(const struct unit_system* from, void units_print(const struct unit_system* us); +/* Dump/restore. */ +void units_struct_dump(const struct unit_system *us, FILE *stream); +void units_struct_restore(const struct unit_system *us, FILE *stream); + #endif /* SWIFT_UNITS_H */