diff --git a/src/cooling.c b/src/cooling.c index b6450615e4dec25b8fdd41c01d622fa457f6160a..2db367031ac73291faf82fa5d77045399ca3a514 100644 --- a/src/cooling.c +++ b/src/cooling.c @@ -60,14 +60,12 @@ void cooling_print(const struct cooling_function_data* cooling) { * @param p the struct * @param stream the file stream */ -void cooling_struct_dump(const struct cooling_function_data* cooling, - FILE *stream) { - restart_write_blocks((void *) cooling, - sizeof(struct cooling_function_data), - 1, stream, "cooling function"); +void cooling_struct_dump(const struct cooling_function_data* cooling, + FILE* stream) { + restart_write_blocks((void*)cooling, sizeof(struct cooling_function_data), 1, + stream, "cooling function"); } - /** * @brief Restore a hydro_props struct from the given FILE as a stream of * bytes. @@ -76,7 +74,7 @@ void cooling_struct_dump(const struct cooling_function_data* cooling, * @param stream the file stream */ void cooling_struct_restore(const struct cooling_function_data* cooling, - FILE *stream) { - restart_read_blocks((void *)cooling, sizeof(struct cooling_function_data), - 1, stream, "cooling function"); + FILE* stream) { + restart_read_blocks((void*)cooling, sizeof(struct cooling_function_data), 1, + stream, "cooling function"); } diff --git a/src/cooling.h b/src/cooling.h index 979bcb60446d7f724cca4d4001e2928c7688b425..5547b57ff574e06c415d4369736296302671bde6 100644 --- a/src/cooling.h +++ b/src/cooling.h @@ -49,7 +49,9 @@ void cooling_init(const struct swift_params* parameter_file, void cooling_print(const struct cooling_function_data* cooling); /* Dump/restore. */ -void cooling_struct_dump(const struct cooling_function_data* cooling, FILE *stream); -void cooling_struct_restore(const struct cooling_function_data* cooling, FILE *stream); +void cooling_struct_dump(const struct cooling_function_data* cooling, + FILE* stream); +void cooling_struct_restore(const struct cooling_function_data* cooling, + FILE* stream); #endif /* SWIFT_COOLING_H */ diff --git a/src/engine.c b/src/engine.c index d217e6e90d53e091842f20147bc75937c55158d8..54a9a7602564a7a753e8427a306f54ba0334f44a 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5638,7 +5638,7 @@ void engine_clean(struct engine *e) { void engine_struct_dump(struct engine *e, FILE *stream) { /* Dump our signature and version. */ - restart_write_blocks(SWIFT_RESTART_SIGNATURE,strlen(SWIFT_RESTART_SIGNATURE), + restart_write_blocks(SWIFT_RESTART_SIGNATURE, strlen(SWIFT_RESTART_SIGNATURE), 1, stream, "SWIFT signature"); restart_write_blocks((void *)package_version(), strlen(package_version()), 1, stream, "SWIFT version"); @@ -5648,7 +5648,6 @@ void engine_struct_dump(struct engine *e, FILE *stream) { /* And all the engine pointed data, these use their own dump functions. */ space_struct_dump(e->s, stream); - e->s->e = e; units_struct_dump(e->internal_units, stream); units_struct_dump(e->snapshotUnits, stream); partition_struct_dump(e->reparttype, stream); @@ -5671,9 +5670,9 @@ void engine_struct_dump(struct engine *e, FILE *stream) { void engine_struct_restore(struct engine *e, FILE *stream) { /* Get our version and signature back. These should match. */ - char signature[10]; - restart_write_blocks(signature, strlen(SWIFT_RESTART_SIGNATURE), 1, stream, - "SWIFT signature"); + char signature[strlen(SWIFT_RESTART_SIGNATURE) + 1]; + restart_read_blocks(signature, strlen(SWIFT_RESTART_SIGNATURE), 1, stream, + "SWIFT signature"); if (strcmp(signature, SWIFT_RESTART_SIGNATURE) != 0) error("Do not recognise this as a SWIFT restart file"); @@ -5682,14 +5681,17 @@ void engine_struct_restore(struct engine *e, FILE *stream) { "SWIFT version"); /* XXX error or warning, it might work! */ if (strcmp(version, package_version()) != 0) - message("WARNING: restoring from a different version of SWIFT. You have:" - " %s, and the restarts file where created using: %s. This may fail" - " badly", version, package_version()); + message( + "WARNING: restoring from a different version of SWIFT. You have:" + " %s, and the restarts file where created using: %s. This may fail" + " badly", + version, package_version()); /* Now the engine. */ restart_read_blocks(e, sizeof(struct engine), 1, stream, "engine struct"); /* XXX Re-initializations as necessary. XXX */ + /* XXX Reopen output files and append... XXX */ /* runners */ /* scheduler */ /* threadpool */ @@ -5703,21 +5705,55 @@ void engine_struct_restore(struct engine *e, FILE *stream) { /* links */ - /* Now for the other pointers, these use their own restore functions. */ - /* XXX struct leaky memory allocations, or need static decls from main.c, - * like engine_init() */ - space_struct_restore(e->s, stream); - units_struct_restore(e->internal_units, stream); - units_struct_restore(e->snapshotUnits, stream); - partition_struct_restore(e->reparttype, stream); - phys_const_struct_restore(e->physical_constants, stream); - hydro_props_struct_restore(e->hydro_properties, stream); - gravity_props_struct_restore(e->gravity_properties, stream); - potential_struct_restore(e->external_potential, stream); - cooling_struct_restore(e->cooling_func, stream); - sourceterms_struct_restore(e->sourceterms, stream); + /* Note all this memory leaks, but is used once. */ + struct space *s = malloc(sizeof(struct space)); + space_struct_restore(s, stream); + e->s = s; + s->e = e; + + struct unit_system *us = malloc(sizeof(struct unit_system)); + units_struct_restore(us, stream); + e->internal_units = us; + + us = malloc(sizeof(struct unit_system)); + units_struct_restore(us, stream); + e->snapshotUnits = us; + + struct repartition *reparttype = malloc(sizeof(struct repartition)); + partition_struct_restore(reparttype, stream); + e->reparttype = reparttype; + + struct phys_const *physical_constants = malloc(sizeof(struct phys_const)); + phys_const_struct_restore(physical_constants, stream); + e->physical_constants = physical_constants; + + struct hydro_props *hydro_properties = malloc(sizeof(struct hydro_props)); + hydro_props_struct_restore(hydro_properties, stream); + e->hydro_properties = hydro_properties; + + struct gravity_props *gravity_properties = + malloc(sizeof(struct gravity_props)); + gravity_props_struct_restore(gravity_properties, stream); + e->gravity_properties = gravity_properties; + + struct external_potential *external_potential = + malloc(sizeof(struct external_potential)); + potential_struct_restore(external_potential, stream); + e->external_potential = external_potential; + + struct cooling_function_data *cooling_func = + malloc(sizeof(struct cooling_function_data)); + cooling_struct_restore(cooling_func, stream); + e->cooling_func = cooling_func; + + struct sourceterms *sourceterms = malloc(sizeof(struct sourceterms)); + sourceterms_struct_restore(sourceterms, stream); + e->sourceterms = sourceterms; + + struct swift_params *parameter_file = malloc(sizeof(struct swift_params)); parser_struct_restore(e->parameter_file, stream); + e->parameter_file = parameter_file; /* Want to force a rebuild before using this engine. Wait to repartition.*/ e->forcerebuild = 1; diff --git a/src/engine.h b/src/engine.h index 97a0c0521ab898c21e4dba1ea20019989609bb92..13906e96d5c5fa9115e6497e910e3463d2ae6b3b 100644 --- a/src/engine.h +++ b/src/engine.h @@ -336,5 +336,4 @@ int engine_estimate_nr_tasks(struct engine *e); void engine_struct_dump(struct engine *e, FILE *stream); void engine_struct_restore(struct engine *e, FILE *stream); - #endif /* SWIFT_ENGINE_H */ diff --git a/src/gravity_properties.c b/src/gravity_properties.c index ce0bf1581e6c071974fd756379c775879a171167..11c44284e3ffdc36724a786742bfa2fdb7e0f358 100644 --- a/src/gravity_properties.c +++ b/src/gravity_properties.c @@ -104,11 +104,10 @@ void gravity_props_print_snapshot(hid_t h_grpgrav, * @param stream the file stream */ void gravity_props_struct_dump(const struct gravity_props *p, FILE *stream) { - restart_write_blocks((void *) p, sizeof(struct gravity_props), - 1, stream, "gravity props"); + restart_write_blocks((void *)p, sizeof(struct gravity_props), 1, stream, + "gravity props"); } - /** * @brief Restore a gravity_props struct from the given FILE as a stream of * bytes. @@ -117,6 +116,6 @@ void gravity_props_struct_dump(const struct gravity_props *p, FILE *stream) { * @param stream the file stream */ void gravity_props_struct_restore(const struct gravity_props *p, FILE *stream) { - restart_read_blocks((void *)p, sizeof(struct gravity_props), - 1, stream, "gravity props"); + restart_read_blocks((void *)p, sizeof(struct gravity_props), 1, stream, + "gravity props"); } diff --git a/src/hydro_properties.c b/src/hydro_properties.c index dbbbed6455d15c2b5c485215f44a38fe1a52d1d0..4f3422f5ba4bcb4a1d702694eea80c22016e4e45 100644 --- a/src/hydro_properties.c +++ b/src/hydro_properties.c @@ -135,11 +135,10 @@ void hydro_props_print_snapshot(hid_t h_grpsph, const struct hydro_props *p) { * @param stream the file stream */ void hydro_props_struct_dump(const struct hydro_props *p, FILE *stream) { - restart_write_blocks((void *) p, sizeof(struct hydro_props), - 1, stream, "hydro props"); + restart_write_blocks((void *)p, sizeof(struct hydro_props), 1, stream, + "hydro props"); } - /** * @brief Restore a hydro_props struct from the given FILE as a stream of * bytes. @@ -148,6 +147,6 @@ void hydro_props_struct_dump(const struct hydro_props *p, FILE *stream) { * @param stream the file stream */ void hydro_props_struct_restore(const struct hydro_props *p, FILE *stream) { - restart_read_blocks((void *)p, sizeof(struct hydro_props), - 1, stream, "hydro props"); + restart_read_blocks((void *)p, sizeof(struct hydro_props), 1, stream, + "hydro props"); } diff --git a/src/parser.c b/src/parser.c index f7355d4a4a0be8f2ed4cfa7b6e16d21fcf1c5ba1..cedfeeb246169b99b708caa114c473369e6243b4 100644 --- a/src/parser.c +++ b/src/parser.c @@ -786,7 +786,6 @@ void parser_write_params_to_hdf5(const struct swift_params *params, hid_t grp) { } #endif - /** * @brief Write a swift_params struct to the given FILE as a stream of bytes. * @@ -794,11 +793,10 @@ void parser_write_params_to_hdf5(const struct swift_params *params, hid_t grp) { * @param stream the file stream */ void parser_struct_dump(const struct swift_params *params, FILE *stream) { - restart_write_blocks((void *) params, sizeof(struct swift_params), - 1, stream, "parameters"); + restart_write_blocks((void *)params, sizeof(struct swift_params), 1, stream, + "parameters"); } - /** * @brief Restore a swift_params struct from the given FILE as a stream of * bytes. @@ -807,6 +805,6 @@ void parser_struct_dump(const struct swift_params *params, FILE *stream) { * @param stream the file stream */ void parser_struct_restore(const struct swift_params *params, FILE *stream) { - restart_read_blocks((void *)params, sizeof(struct swift_params), - 1, stream, "parameters"); + restart_read_blocks((void *)params, sizeof(struct swift_params), 1, stream, + "parameters"); } diff --git a/src/parser.h b/src/parser.h index e22a456dbc56706bb9411d1d4843e97aa75a12eb..4e61b16ab53b3688e60f85a42e786c44b095120a 100644 --- a/src/parser.h +++ b/src/parser.h @@ -87,5 +87,4 @@ void parser_write_params_to_hdf5(const struct swift_params *params, hid_t grp); void parser_struct_dump(const struct swift_params *params, FILE *stream); void parser_struct_restore(const struct swift_params *params, FILE *stream); - #endif /* SWIFT_PARSER_H */ diff --git a/src/partition.c b/src/partition.c index 70777fe1a6f7d70688605747cd89437e29c48801..f5fcfbe0af4ae75bd5941b960f93542222544d3b 100644 --- a/src/partition.c +++ b/src/partition.c @@ -1259,11 +1259,10 @@ int partition_space_to_space(double *oldh, double *oldcdim, int *oldnodeIDs, * @param stream the file stream */ void partition_struct_dump(struct repartition *reparttype, FILE *stream) { - restart_write_blocks(reparttype, sizeof(struct repartition), 1, stream, + restart_write_blocks(reparttype, sizeof(struct repartition), 1, stream, "repartition params"); } - /** * @brief Restore a repartition struct from the given FILE as a stream of * bytes. diff --git a/src/physical_constants.c b/src/physical_constants.c index 06c53d4ea096cc5687eb2408a52a4472ac04ee9b..e8edf7df0b4411ef303a341dd94b9afef8cc94dc 100644 --- a/src/physical_constants.c +++ b/src/physical_constants.c @@ -35,8 +35,8 @@ * @param us The current internal system of units. * @param internal_const The physical constants to initialize. */ -void phys_const_init(struct unit_system* us, - struct phys_const* internal_const) { +void phys_const_init(struct unit_system *us, + struct phys_const *internal_const) { /* Units are declared as {U_M, U_L, U_t, U_I, U_T} */ @@ -106,7 +106,7 @@ void phys_const_init(struct unit_system* us, units_general_cgs_conversion_factor(us, dimension_length); } -void phys_const_print(struct phys_const* internal_const) { +void phys_const_print(struct phys_const *internal_const) { message("%25s = %e", "Gravitational constant", internal_const->const_newton_G); @@ -131,11 +131,10 @@ void phys_const_print(struct phys_const* internal_const) { */ void phys_const_struct_dump(const struct phys_const *internal_const, FILE *stream) { - restart_write_blocks((void *) internal_const, sizeof(struct phys_const), - 1, stream, "phys_const params"); + restart_write_blocks((void *)internal_const, sizeof(struct phys_const), 1, + stream, "phys_const params"); } - /** * @brief Restore a phys_const struct from the given FILE as a stream of * bytes. @@ -145,6 +144,6 @@ void phys_const_struct_dump(const struct phys_const *internal_const, */ void phys_const_struct_restore(const struct phys_const *internal_const, FILE *stream) { - restart_read_blocks((void *)internal_const, sizeof(struct phys_const), - 1, stream, "phys_const params"); + restart_read_blocks((void *)internal_const, sizeof(struct phys_const), 1, + stream, "phys_const params"); } diff --git a/src/physical_constants.h b/src/physical_constants.h index 79f341a8b81b6bf85c5f7613abd081454e8b4995..39c6c52cba311228d6152fd59e8a6001d11a3ac1 100644 --- a/src/physical_constants.h +++ b/src/physical_constants.h @@ -83,7 +83,9 @@ void phys_const_init(struct unit_system* us, struct phys_const* internal_const); void phys_const_print(struct phys_const* internal_const); /* Dump/restore. */ -void phys_const_struct_dump(const struct phys_const* internal_const, FILE *stream); -void phys_const_struct_restore(const struct phys_const* internal_const, FILE *stream); +void phys_const_struct_dump(const struct phys_const* internal_const, + FILE* stream); +void phys_const_struct_restore(const struct phys_const* internal_const, + FILE* stream); #endif /* SWIFT_PHYSICAL_CONSTANTS_H */ diff --git a/src/potential.c b/src/potential.c index 72950721f8f36b73a50d44a8529be73d4db93491..38d99c6df9c4e53247f2b8e774ab6d662fba41f1 100644 --- a/src/potential.c +++ b/src/potential.c @@ -53,20 +53,19 @@ void potential_print(const struct external_potential* potential) { potential_print_backend(potential); } - /** - * @brief Write an external_potential struct to the given FILE as a stream of bytes. + * @brief Write an external_potential struct to the given FILE as a stream of + * bytes. * * @param potential the struct * @param stream the file stream */ -void potential_struct_dump(const struct external_potential *potential, - FILE *stream) { - restart_write_blocks((void *) potential, sizeof(struct external_potential), - 1, stream, "external potential"); +void potential_struct_dump(const struct external_potential* potential, + FILE* stream) { + restart_write_blocks((void*)potential, sizeof(struct external_potential), 1, + stream, "external potential"); } - /** * @brief Restore a external_potential struct from the given FILE as a stream of * bytes. @@ -74,8 +73,8 @@ void potential_struct_dump(const struct external_potential *potential, * @param p the struct * @param stream the file stream */ -void potential_struct_restore(const struct external_potential *potential, - FILE *stream) { - restart_read_blocks((void *) potential, sizeof(struct external_potential), - 1, stream, "external potential"); +void potential_struct_restore(const struct external_potential* potential, + FILE* stream) { + restart_read_blocks((void*)potential, sizeof(struct external_potential), 1, + stream, "external potential"); } diff --git a/src/potential.h b/src/potential.h index b09c1417b7cbbe33c459e42c18691d87cd83bd99..bcb3fd284021fba339ba494c90b81c91bd2ce72f 100644 --- a/src/potential.h +++ b/src/potential.h @@ -51,7 +51,9 @@ void potential_init(const struct swift_params* parameter_file, void potential_print(const struct external_potential* potential); /* Dump/restore. */ -void potential_struct_dump(const struct external_potential* potential, FILE *stream); -void potential_struct_restore(const struct external_potential* potential, FILE *stream); +void potential_struct_dump(const struct external_potential* potential, + FILE* stream); +void potential_struct_restore(const struct external_potential* potential, + FILE* stream); #endif /* SWIFT_POTENTIAL_H */ diff --git a/src/restart.c b/src/restart.c index cf32e82f47d39413cdde3f268876f1e70cec312a..689c111635e18a10b78f69d1cd637e82b6acf2ea 100644 --- a/src/restart.c +++ b/src/restart.c @@ -27,10 +27,10 @@ /* Standard headers. */ #include <errno.h> +#include <glob.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <glob.h> #include "engine.h" #include "error.h" @@ -47,8 +47,8 @@ * * @result 0 if the string was large enough. */ -int restart_genname(const char *dir, const char *basename, - int nodeID, char *name, int size) { +int restart_genname(const char *dir, const char *basename, int nodeID, + char *name, int size) { int n = snprintf(name, size, "%s/%s_%04d.rst", dir, basename, nodeID); message("name = %s", name); return (n >= size); @@ -64,8 +64,7 @@ int restart_genname(const char *dir, const char *basename, * @result pointer to an array of strings with all the filenames found, * release by calling restart_locate_free(). */ -char **restart_locate(const char *dir, const char *basename, - int *nfiles) { +char **restart_locate(const char *dir, const char *basename, int *nfiles) { *nfiles = 0; /* Construct the glob pattern for locating files. */ @@ -90,7 +89,6 @@ char **restart_locate(const char *dir, const char *basename, return NULL; } - /** * @brief Release the memory allocated to hold the restart file names. * @@ -99,12 +97,11 @@ char **restart_locate(const char *dir, const char *basename, */ void restart_locate_free(int nfiles, char **files) { for (int i = 0; i < nfiles; i++) { - free(files[i]); + free(files[i]); } free(files); } - /** * @brief Write a restart file for the given engine struct. */ diff --git a/src/restart.h b/src/restart.h index e75776eb9961e340c3f8e3c62195f5b871c92d37..631e403a5882013e560a1d261be13ab9edab7ef9 100644 --- a/src/restart.h +++ b/src/restart.h @@ -33,11 +33,12 @@ void restart_read(struct engine *e, const char *filename); char **restart_locate(const char *dir, const char *basename, int *nfiles); void restart_locate_free(int nfiles, char **files); -int restart_genname(const char *dir, const char *basename, - int nodeID, char *name, int size); +int restart_genname(const char *dir, const char *basename, int nodeID, + char *name, int size); void restart_read_blocks(void *ptr, size_t size, size_t nblocks, FILE *stream, const char *errstr); + void restart_write_blocks(void *ptr, size_t size, size_t nblocks, FILE *stream, const char *errstr); diff --git a/src/sourceterms.c b/src/sourceterms.c index 8d438e8ffe369c9d2dcc193762bb0bf656fbb60b..3b89e5dcfb893bb128ea40fe79381943d0cccd6f 100644 --- a/src/sourceterms.c +++ b/src/sourceterms.c @@ -36,8 +36,8 @@ * @param us The current internal system of units * @param source the structure that has all the source term properties */ -void sourceterms_init(const struct swift_params* parameter_file, - struct unit_system* us, struct sourceterms* source) { +void sourceterms_init(const struct swift_params *parameter_file, + struct unit_system *us, struct sourceterms *source) { #ifdef SOURCETERMS_SN_FEEDBACK supernova_init(parameter_file, us, source); #endif /* SOURCETERMS_SN_FEEDBACK */ @@ -47,7 +47,7 @@ void sourceterms_init(const struct swift_params* parameter_file, * @brief Prints the properties of the source terms to stdout * @param source the structure that has all the source term properties */ -void sourceterms_print(struct sourceterms* source) { +void sourceterms_print(struct sourceterms *source) { #ifdef SOURCETERMS_NONE error(" no sourceterms defined yet you ran with -F"); #ifdef SOURCETERMS_SN_FEEDBACK @@ -67,11 +67,10 @@ void sourceterms_print(struct sourceterms* source) { */ void sourceterms_struct_dump(const struct sourceterms *sourceterms, FILE *stream) { - restart_write_blocks((void *) sourceterms, sizeof(struct sourceterms), - 1, stream, "sourceterms"); + restart_write_blocks((void *)sourceterms, sizeof(struct sourceterms), 1, + stream, "sourceterms"); } - /** * @brief Restore a sourceterms struct from the given FILE as a stream of * bytes. @@ -81,6 +80,6 @@ void sourceterms_struct_dump(const struct sourceterms *sourceterms, */ void sourceterms_struct_restore(const struct sourceterms *sourceterms, FILE *stream) { - restart_read_blocks((void *)sourceterms, sizeof(struct sourceterms), - 1, stream, "sourceterms"); + restart_read_blocks((void *)sourceterms, sizeof(struct sourceterms), 1, + stream, "sourceterms"); } diff --git a/src/sourceterms.h b/src/sourceterms.h index 361c53be9a35a08443ab63c854518c3a128aefd1..a5d0c3c727d70d50fb3388d5e5e3cc3d6362276f 100644 --- a/src/sourceterms.h +++ b/src/sourceterms.h @@ -46,9 +46,8 @@ void sourceterms_init(const struct swift_params* parameter_file, void sourceterms_print(struct sourceterms* source); /* Dump/restore. */ -void sourceterms_struct_dump(const struct sourceterms *source, FILE *stream); -void sourceterms_struct_restore(const struct sourceterms *source, FILE *stream); - +void sourceterms_struct_dump(const struct sourceterms* source, FILE* stream); +void sourceterms_struct_restore(const struct sourceterms* source, FILE* stream); /** * @brief Routines related to source terms diff --git a/src/space.c b/src/space.c index a4fbd1f4eae83a59214426f9ad6223c6b71e03bc..26b6cdd1a4ebcf94d3c20507b8be47c5b7efff48 100644 --- a/src/space.c +++ b/src/space.c @@ -3251,14 +3251,18 @@ void space_struct_dump(struct space *s, FILE *stream) { /* More things to write. */ if (s->nr_parts > 0) { - restart_write_blocks(s->parts, s->nr_parts, sizeof(struct part), stream, "parts"); - restart_write_blocks(s->xparts, s->nr_parts, sizeof(struct xpart), stream, "xparts"); + restart_write_blocks(s->parts, s->nr_parts, sizeof(struct part), stream, + "parts"); + restart_write_blocks(s->xparts, s->nr_parts, sizeof(struct xpart), stream, + "xparts"); } if (s->nr_gparts > 0) - restart_write_blocks(s->gparts, s->nr_gparts, sizeof(struct gpart), stream, "gparts"); + restart_write_blocks(s->gparts, s->nr_gparts, sizeof(struct gpart), stream, + "gparts"); if (s->nr_sparts > 0) - restart_write_blocks(s->sparts, s->nr_sparts, sizeof(struct spart), stream, "sparts"); + restart_write_blocks(s->sparts, s->nr_sparts, sizeof(struct spart), stream, + "sparts"); } /** @@ -3299,15 +3303,18 @@ void space_struct_restore(struct space *s, FILE *stream) { s->size_parts * sizeof(struct xpart)) != 0) error("Failed to allocate restore xpart array."); - restart_read_blocks(s->parts, s->nr_parts, sizeof(struct part), stream, "parts"); - restart_read_blocks(s->xparts, s->nr_parts, sizeof(struct xpart), stream, "xparts"); + restart_read_blocks(s->parts, s->nr_parts, sizeof(struct part), stream, + "parts"); + restart_read_blocks(s->xparts, s->nr_parts, sizeof(struct xpart), stream, + "xparts"); } if (s->nr_gparts > 0) { if (posix_memalign((void *)&s->gparts, gpart_align, s->size_gparts * sizeof(struct gpart)) != 0) error("Failed to allocate restore gpart array."); - restart_read_blocks(s->gparts, s->nr_gparts, sizeof(struct gpart), stream, "gparts"); + restart_read_blocks(s->gparts, s->nr_gparts, sizeof(struct gpart), stream, + "gparts"); } if (s->nr_sparts > 0) { @@ -3315,10 +3322,10 @@ void space_struct_restore(struct space *s, FILE *stream) { s->size_sparts * sizeof(struct spart)) != 0) error("Failed to allocate restore spart array."); - restart_read_blocks(s->sparts, s->nr_sparts, sizeof(struct spart), stream, "sparts"); + restart_read_blocks(s->sparts, s->nr_sparts, sizeof(struct spart), stream, + "sparts"); } - /* XXX need to reconnect the gravity parts to their hydro and star particles. XXX */ - - + /* XXX need to reconnect the gravity parts to their hydro and star particles. + * XXX */ } diff --git a/src/space.h b/src/space.h index 85a9fd7e5bf2f5d03c9a9621acaaf865e98bd352..02038468a5199aba19f55ab84348e012b53b7bf0 100644 --- a/src/space.h +++ b/src/space.h @@ -240,5 +240,4 @@ void space_free_cells(struct space *s); void space_struct_dump(struct space *s, FILE *stream); void space_struct_restore(struct space *s, FILE *stream); - #endif /* SWIFT_SPACE_H */ diff --git a/src/units.c b/src/units.c index 79971815920700e7ab5dbe08d8d760e7527bb3cf..d928e20286d2fac4246c289fda7a213ef7d6aa04 100644 --- a/src/units.c +++ b/src/units.c @@ -604,26 +604,24 @@ void units_print(const struct unit_system* us) { 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, +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, +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 7f74e2b19fcda73d3e22167b3d4bd6cc3b166f46..5ac70a909a77146ba5f7a441d7747acfc80c3dfa 100644 --- a/src/units.h +++ b/src/units.h @@ -140,7 +140,7 @@ 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); +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 */