diff --git a/src/cosmology.c b/src/cosmology.c index 4da9528784b1fb7fdb04761b77a3c0056a32f41a..0cc528c8a095637de1b60a83a15181d63c43b092 100644 --- a/src/cosmology.c +++ b/src/cosmology.c @@ -387,7 +387,7 @@ void cosmology_init_tables(struct cosmology *c) { * @param phys_const The physical constants in the current system of units. * @param c The #cosmology to initialise. */ -void cosmology_init(const struct swift_params *params, +void cosmology_init(struct swift_params *params, const struct unit_system *us, const struct phys_const *phys_const, struct cosmology *c) { diff --git a/src/cosmology.h b/src/cosmology.h index 109b80a57d8dbc4eb942dd4ecbbc0db84198100b..93751fba6f07785d25d8f8fc343d3ac2897fc19b 100644 --- a/src/cosmology.h +++ b/src/cosmology.h @@ -181,7 +181,7 @@ double cosmology_get_therm_kick_factor(const struct cosmology *cosmo, double cosmology_get_delta_time(const struct cosmology *c, double a1, double a2); -void cosmology_init(const struct swift_params *params, +void cosmology_init(struct swift_params *params, const struct unit_system *us, const struct phys_const *phys_const, struct cosmology *c); diff --git a/src/engine.c b/src/engine.c index 14c91997575c218d765eb27f10837255c7917aa0..c62feb434d0eee53b938ee3770aaf87b70d2c859 100644 --- a/src/engine.c +++ b/src/engine.c @@ -5422,7 +5422,7 @@ void engine_unpin(void) { * @param sourceterms The properties of the source terms function. */ void engine_init(struct engine *e, struct space *s, - const struct swift_params *params, long long Ngas, + struct swift_params *params, long long Ngas, long long Ngparts, long long Nstars, int policy, int verbose, struct repartition *reparttype, const struct unit_system *internal_units, @@ -5553,7 +5553,7 @@ void engine_init(struct engine *e, struct space *s, * @param restart_file The name of our restart file. */ void engine_config(int restart, struct engine *e, - const struct swift_params *params, int nr_nodes, int nodeID, + struct swift_params *params, int nr_nodes, int nodeID, int nr_threads, int with_aff, int verbose, const char *restart_file) { diff --git a/src/engine.h b/src/engine.h index c376434c7fa30476f467efe9da6b91bc5d86c794..877dbf362765d78e5aef603d3a0b7caebcfa6380 100644 --- a/src/engine.h +++ b/src/engine.h @@ -315,7 +315,7 @@ struct engine { struct sourceterms *sourceterms; /* The (parsed) parameter file */ - const struct swift_params *parameter_file; + struct swift_params *parameter_file; /* Temporary struct to hold a group of deferable properties (in MPI mode * these are reduced together, but may not be required just yet). */ @@ -355,7 +355,7 @@ void engine_reconstruct_multipoles(struct engine *e); void engine_print_stats(struct engine *e); void engine_dump_snapshot(struct engine *e); void engine_init(struct engine *e, struct space *s, - const struct swift_params *params, long long Ngas, + struct swift_params *params, long long Ngas, long long Ngparts, long long Nstars, int policy, int verbose, struct repartition *reparttype, const struct unit_system *internal_units, @@ -367,7 +367,7 @@ void engine_init(struct engine *e, struct space *s, const struct chemistry_global_data *chemistry, struct sourceterms *sourceterms); void engine_config(int restart, struct engine *e, - const struct swift_params *params, int nr_nodes, int nodeID, + struct swift_params *params, int nr_nodes, int nodeID, int nr_threads, int with_aff, int verbose, const char *restart_file); void engine_launch(struct engine *e); diff --git a/src/gravity_properties.c b/src/gravity_properties.c index afebc604351d3210dc6149742ad47dd1089f5743..05e28dc860a6b8c22c56d0c33fe78e2f8f828afd 100644 --- a/src/gravity_properties.c +++ b/src/gravity_properties.c @@ -38,7 +38,7 @@ #define gravity_props_default_rebuild_frequency 0.01f void gravity_props_init(struct gravity_props *p, - const struct swift_params *params, + struct swift_params *params, const struct cosmology *cosmo) { /* Tree updates */ diff --git a/src/gravity_properties.h b/src/gravity_properties.h index 418e74e715f86bfe7fe333fdcedeb19415bfd394..6f0898a164077adc2af8f624da28ddf75c6951d4 100644 --- a/src/gravity_properties.h +++ b/src/gravity_properties.h @@ -83,7 +83,7 @@ struct gravity_props { void gravity_props_print(const struct gravity_props *p); void gravity_props_init(struct gravity_props *p, - const struct swift_params *params, + struct swift_params *params, const struct cosmology *cosmo); void gravity_update(struct gravity_props *p, const struct cosmology *cosmo); diff --git a/src/hydro_properties.c b/src/hydro_properties.c index e63679eaad3c7f61fe67e63326ca59a04c1caffb..c5448f77353e1859c1f8853394bbefbe26d0a3a9 100644 --- a/src/hydro_properties.c +++ b/src/hydro_properties.c @@ -52,7 +52,7 @@ void hydro_props_init(struct hydro_props *p, const struct phys_const *phys_const, const struct unit_system *us, - const struct swift_params *params) { + struct swift_params *params) { /* Kernel properties */ p->eta_neighbours = parser_get_param_float(params, "SPH:resolution_eta"); diff --git a/src/hydro_properties.h b/src/hydro_properties.h index 2799f6c86eec7f0ebf140643c5ab7fa9b60e6273..64a840692db677704b8617e962d7883505983cc0 100644 --- a/src/hydro_properties.h +++ b/src/hydro_properties.h @@ -86,7 +86,7 @@ void hydro_props_print(const struct hydro_props *p); void hydro_props_init(struct hydro_props *p, const struct phys_const *phys_const, const struct unit_system *us, - const struct swift_params *params); + struct swift_params *params); #if defined(HAVE_HDF5) void hydro_props_print_snapshot(hid_t h_grpsph, const struct hydro_props *p); diff --git a/src/parallel_io.c b/src/parallel_io.c index 69093eb48efc6ebfdc2995f46d3e9551b476db76..039cb85bae56481988b4243c0390fb73536141a0 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -890,7 +890,7 @@ void prepare_file(struct engine* e, const char* baseName, long long N_total[6], const struct xpart* xparts = e->s->xparts; const struct gpart* gparts = e->s->gparts; const struct spart* sparts = e->s->sparts; - const struct swift_params* params = e->parameter_file; + struct swift_params* params = e->parameter_file; FILE* xmfFile = 0; int periodic = e->s->periodic; int numFiles = 1; @@ -1141,7 +1141,7 @@ void write_output_parallel(struct engine* e, const char* baseName, struct gpart* dmparts = NULL; const struct spart* sparts = e->s->sparts; const struct cooling_function_data* cooling = e->cooling_func; - const struct swift_params* params = e->parameter_file; + struct swift_params* params = e->parameter_file; /* Number of unassociated gparts */ const size_t Ndm = Ntot > 0 ? Ntot - (Ngas + Nstars) : 0; diff --git a/src/parser.c b/src/parser.c index 5f789df45a88c42aa335539a5d7a5bc78916735c..78fea7b6260cc742eefd405513eb9758fb8ba1bc 100644 --- a/src/parser.c +++ b/src/parser.c @@ -444,11 +444,10 @@ static void parse_section_param(char *line, int *isFirstParam, * @param name Name of the parameter to be found * @return Value of the parameter found */ -int parser_get_param_int(const struct swift_params *params, const char *name) { +int parser_get_param_int(struct swift_params *params, const char *name) { char str[PARSER_MAX_LINE_SIZE]; int retParam = 0; - struct swift_params *tmp = (struct swift_params*) params; for (int i = 0; i < params->paramCount; i++) { if (!strcmp(name, params->data[i].name)) { @@ -461,7 +460,7 @@ int parser_get_param_int(const struct swift_params *params, const char *name) { } /* this parameter has been used */ - tmp->data[i].used = 1; + params->data[i].used = 1; return retParam; } @@ -479,12 +478,11 @@ int parser_get_param_int(const struct swift_params *params, const char *name) { * @param name Name of the parameter to be found * @return Value of the parameter found */ -char parser_get_param_char(const struct swift_params *params, +char parser_get_param_char(struct swift_params *params, const char *name) { char str[PARSER_MAX_LINE_SIZE]; char retParam = 0; - struct swift_params *tmp = (struct swift_params*) params; for (int i = 0; i < params->paramCount; i++) { if (!strcmp(name, params->data[i].name)) { @@ -497,7 +495,7 @@ char parser_get_param_char(const struct swift_params *params, } /* this parameter has been used */ - tmp->data[i].used = 1; + params->data[i].used = 1; return retParam; } @@ -515,12 +513,11 @@ char parser_get_param_char(const struct swift_params *params, * @param name Name of the parameter to be found * @return Value of the parameter found */ -float parser_get_param_float(const struct swift_params *params, +float parser_get_param_float(struct swift_params *params, const char *name) { char str[PARSER_MAX_LINE_SIZE]; float retParam = 0.f; - struct swift_params *tmp = (struct swift_params*) params; for (int i = 0; i < params->paramCount; i++) { if (!strcmp(name, params->data[i].name)) { @@ -533,7 +530,7 @@ float parser_get_param_float(const struct swift_params *params, } /* this parameter has been used */ - tmp->data[i].used = 1; + params->data[i].used = 1; return retParam; } @@ -551,12 +548,11 @@ float parser_get_param_float(const struct swift_params *params, * @param name Name of the parameter to be found * @return Value of the parameter found */ -double parser_get_param_double(const struct swift_params *params, +double parser_get_param_double(struct swift_params *params, const char *name) { char str[PARSER_MAX_LINE_SIZE]; double retParam = 0.; - struct swift_params *tmp = (struct swift_params*) params; for (int i = 0; i < params->paramCount; i++) { if (!strcmp(name, params->data[i].name)) { @@ -569,7 +565,7 @@ double parser_get_param_double(const struct swift_params *params, } /* this parameter has been used */ - tmp->data[i].used = 1; + params->data[i].used = 1; return retParam; } @@ -587,14 +583,14 @@ double parser_get_param_double(const struct swift_params *params, * @param name Name of the parameter to be found * @param retParam (return) Value of the parameter found */ -void parser_get_param_string(const struct swift_params *params, +void parser_get_param_string(struct swift_params *params, const char *name, char *retParam) { - struct swift_params *tmp = (struct swift_params*) params; + for (int i = 0; i < params->paramCount; i++) { if (!strcmp(name, params->data[i].name)) { strcpy(retParam, params->data[i].value); /* this parameter has been used */ - tmp->data[i].used = 1; + params->data[i].used = 1; return; } } @@ -610,12 +606,11 @@ void parser_get_param_string(const struct swift_params *params, * @param def Default value of the parameter of not found. * @return Value of the parameter found */ -int parser_get_opt_param_int(const struct swift_params *params, +int parser_get_opt_param_int(struct swift_params *params, const char *name, int def) { char str[PARSER_MAX_LINE_SIZE]; int retParam = 0; - struct swift_params *tmp = (struct swift_params*) params; for (int i = 0; i < params->paramCount; i++) { if (!strcmp(name, params->data[i].name)) { @@ -628,7 +623,7 @@ int parser_get_opt_param_int(const struct swift_params *params, } /* this parameter has been used */ - tmp->data[i].used = 1; + params->data[i].used = 1; return retParam; } @@ -638,10 +633,10 @@ int parser_get_opt_param_int(const struct swift_params *params, sprintf(str, "%s: %i", name, def); /* Add it to params */ - parser_set_param(tmp, str); + parser_set_param(params, str); /* Set parameter as used */ - tmp->data[params->paramCount-1].used = 1; + params->data[params->paramCount-1].used = 1; return def; } @@ -654,12 +649,11 @@ int parser_get_opt_param_int(const struct swift_params *params, * @param def Default value of the parameter of not found. * @return Value of the parameter found */ -char parser_get_opt_param_char(const struct swift_params *params, +char parser_get_opt_param_char(struct swift_params *params, const char *name, char def) { char str[PARSER_MAX_LINE_SIZE]; char retParam = 0; - struct swift_params *tmp = (struct swift_params*) params; for (int i = 0; i < params->paramCount; i++) { if (!strcmp(name, params->data[i].name)) { @@ -672,7 +666,7 @@ char parser_get_opt_param_char(const struct swift_params *params, } /* this parameter has been used */ - tmp->data[i].used = 1; + params->data[i].used = 1; return retParam; } @@ -682,10 +676,10 @@ char parser_get_opt_param_char(const struct swift_params *params, sprintf(str, "%s: %c", name, def); /* Add it to params */ - parser_set_param(tmp, str); + parser_set_param(params, str); /* Set parameter as used */ - tmp->data[params->paramCount-1].used = 1; + params->data[params->paramCount-1].used = 1; return def; } @@ -698,12 +692,11 @@ char parser_get_opt_param_char(const struct swift_params *params, * @param def Default value of the parameter of not found. * @return Value of the parameter found */ -float parser_get_opt_param_float(const struct swift_params *params, +float parser_get_opt_param_float(struct swift_params *params, const char *name, float def) { char str[PARSER_MAX_LINE_SIZE]; float retParam = 0.f; - struct swift_params *tmp = (struct swift_params*) params; for (int i = 0; i < params->paramCount; i++) { if (!strcmp(name, params->data[i].name)) { @@ -716,7 +709,7 @@ float parser_get_opt_param_float(const struct swift_params *params, } /* this parameter has been used */ - tmp->data[i].used = 1; + params->data[i].used = 1; return retParam; } @@ -726,10 +719,10 @@ float parser_get_opt_param_float(const struct swift_params *params, sprintf(str, "%s: %f", name, def); /* Add it to params */ - parser_set_param(tmp, str); + parser_set_param(params, str); /* Set parameter as used */ - tmp->data[params->paramCount-1].used = 1; + params->data[params->paramCount-1].used = 1; return def; } @@ -742,12 +735,11 @@ float parser_get_opt_param_float(const struct swift_params *params, * @param def Default value of the parameter of not found. * @return Value of the parameter found */ -double parser_get_opt_param_double(const struct swift_params *params, +double parser_get_opt_param_double(struct swift_params *params, const char *name, double def) { char str[PARSER_MAX_LINE_SIZE]; double retParam = 0.; - struct swift_params *tmp = (struct swift_params*) params; for (int i = 0; i < params->paramCount; i++) { if (!strcmp(name, params->data[i].name)) { @@ -760,7 +752,7 @@ double parser_get_opt_param_double(const struct swift_params *params, } /* this parameter has been used */ - tmp->data[i].used = 1; + params->data[i].used = 1; return retParam; } @@ -770,10 +762,10 @@ double parser_get_opt_param_double(const struct swift_params *params, sprintf(str, "%s: %lf", name, def); /* Add it to params */ - parser_set_param(tmp, str); + parser_set_param(params, str); /* Set parameter as used */ - tmp->data[params->paramCount-1].used = 1; + params->data[params->paramCount-1].used = 1; return def; } @@ -786,16 +778,16 @@ double parser_get_opt_param_double(const struct swift_params *params, * @param def Default value of the parameter of not found. * @param retParam (return) Value of the parameter found */ -void parser_get_opt_param_string(const struct swift_params *params, +void parser_get_opt_param_string(struct swift_params *params, const char *name, char *retParam, const char *def) { - struct swift_params *tmp = (struct swift_params*) params; + for (int i = 0; i < params->paramCount; i++) { if (!strcmp(name, params->data[i].name)) { strcpy(retParam, params->data[i].value); /* this parameter has been used */ - tmp->data[i].used = 1; + params->data[i].used = 1; return; } @@ -806,10 +798,10 @@ void parser_get_opt_param_string(const struct swift_params *params, sprintf(str, "%s: %s", name, def); /* Add it to params */ - parser_set_param(tmp, str); + parser_set_param(params, str); /* Set parameter as used */ - tmp->data[params->paramCount-1].used = 1; + params->data[params->paramCount-1].used = 1; strcpy(retParam, def); } diff --git a/src/parser.h b/src/parser.h index b29454d50f43dd19c640134596981e45c8cf22c2..a45fc381e2dc35288bb818a75d2bc2bee5a4abb2 100644 --- a/src/parser.h +++ b/src/parser.h @@ -64,24 +64,24 @@ void parser_write_params_to_file(const struct swift_params *params, int write_all); void parser_set_param(struct swift_params *params, const char *desc); -char parser_get_param_char(const struct swift_params *params, const char *name); -int parser_get_param_int(const struct swift_params *params, const char *name); -float parser_get_param_float(const struct swift_params *params, +char parser_get_param_char(struct swift_params *params, const char *name); +int parser_get_param_int(struct swift_params *params, const char *name); +float parser_get_param_float(struct swift_params *params, const char *name); -double parser_get_param_double(const struct swift_params *params, +double parser_get_param_double(struct swift_params *params, const char *name); -void parser_get_param_string(const struct swift_params *params, +void parser_get_param_string(struct swift_params *params, const char *name, char *retParam); -char parser_get_opt_param_char(const struct swift_params *params, +char parser_get_opt_param_char(struct swift_params *params, const char *name, char def); -int parser_get_opt_param_int(const struct swift_params *params, +int parser_get_opt_param_int(struct swift_params *params, const char *name, int def); -float parser_get_opt_param_float(const struct swift_params *params, +float parser_get_opt_param_float(struct swift_params *params, const char *name, float def); -double parser_get_opt_param_double(const struct swift_params *params, +double parser_get_opt_param_double(struct swift_params *params, const char *name, double def); -void parser_get_opt_param_string(const struct swift_params *params, +void parser_get_opt_param_string(struct swift_params *params, const char *name, char *retParam, const char *def); diff --git a/src/partition.c b/src/partition.c index 8feae3b7a8dce7c78310a3b35762d31b439c69e3..85a51dddf2797e7d203da95abc42639c29f11aa6 100644 --- a/src/partition.c +++ b/src/partition.c @@ -1041,7 +1041,7 @@ void partition_initial_partition(struct partition *initial_partition, */ void partition_init(struct partition *partition, struct repartition *repartition, - const struct swift_params *params, int nr_nodes) { + struct swift_params *params, int nr_nodes) { #ifdef WITH_MPI diff --git a/src/partition.h b/src/partition.h index 3ad479c6b1b343106ac736e2d9c77aa9bc93cf60..ec7d670a43537c4717090b857b6e6ba9186b8f1c 100644 --- a/src/partition.h +++ b/src/partition.h @@ -76,7 +76,7 @@ int partition_space_to_space(double *oldh, double *oldcdim, int *oldnodeID, struct space *s); void partition_init(struct partition *partition, struct repartition *repartition, - const struct swift_params *params, int nr_nodes); + struct swift_params *params, int nr_nodes); /* Dump/restore. */ void partition_store_celllist(struct space *s, struct repartition *reparttype); diff --git a/src/physical_constants.c b/src/physical_constants.c index b1dbeaeecfbf2e056a68b7866766bb07efb5efba..b0f0df7745fe29b290062d7e039d6b33bdd6ad84 100644 --- a/src/physical_constants.c +++ b/src/physical_constants.c @@ -39,7 +39,7 @@ * @param internal_const The physical constants to initialize. */ void phys_const_init(const struct unit_system *us, - const struct swift_params *params, + struct swift_params *params, struct phys_const *internal_const) { /* Units are declared as {U_M, U_L, U_t, U_I, U_T} */ diff --git a/src/physical_constants.h b/src/physical_constants.h index b0f929632ba8a55a57376975597e444a8344e4fc..75b79bc0a5f19bf0169a505eb82b8dccf2f8042a 100644 --- a/src/physical_constants.h +++ b/src/physical_constants.h @@ -90,7 +90,7 @@ struct phys_const { }; void phys_const_init(const struct unit_system* us, - const struct swift_params* params, + struct swift_params* params, struct phys_const* internal_const); void phys_const_print(const struct phys_const* internal_const); diff --git a/src/serial_io.c b/src/serial_io.c index f7ea4fa110043d29cdccf8052b84e3d1354d46e2..a87495c9358f1dd40b9c67dd70425318df7e298a 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -733,7 +733,7 @@ void write_output_serial(struct engine* e, const char* baseName, struct gpart* dmparts = NULL; const struct spart* sparts = e->s->sparts; const struct cooling_function_data* cooling = e->cooling_func; - const struct swift_params* params = e->parameter_file; + struct swift_params* params = e->parameter_file; FILE* xmfFile = 0; /* Number of unassociated gparts */ diff --git a/src/single_io.c b/src/single_io.c index 4255cd52bf88e9f12653be23205ff6fccc315a2f..58ae7b97b965bc52a56ba3f15735d948cfc61c82 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -600,7 +600,7 @@ void write_output_single(struct engine* e, const char* baseName, struct gpart* dmparts = NULL; const struct spart* sparts = e->s->sparts; const struct cooling_function_data* cooling = e->cooling_func; - const struct swift_params* params = e->parameter_file; + struct swift_params* params = e->parameter_file; /* Number of unassociated gparts */ const size_t Ndm = Ntot > 0 ? Ntot - (Ngas + Nstars) : 0; diff --git a/src/space.c b/src/space.c index 3efb1080c37bb8057ec6712a67370b8ac3a2b39e..83b670710795b5fd64ffbbe3de55c48c84e62fa0 100644 --- a/src/space.c +++ b/src/space.c @@ -2641,7 +2641,7 @@ void space_convert_quantities(struct space *s, int verbose) { * parts with a cutoff below half the cell width are then split * recursively. */ -void space_init(struct space *s, const struct swift_params *params, +void space_init(struct space *s, struct swift_params *params, const struct cosmology *cosmo, double dim[3], struct part *parts, struct gpart *gparts, struct spart *sparts, size_t Npart, size_t Ngpart, size_t Nspart, int periodic, diff --git a/src/space.h b/src/space.h index 75d6b7b113d59dadf6dd0970069595bcfc163542..67fc34e55bb1a0de3e42f243542bfdb6492d1bab 100644 --- a/src/space.h +++ b/src/space.h @@ -200,7 +200,7 @@ void space_gparts_sort(struct gpart *gparts, struct part *parts, void space_sparts_sort(struct spart *sparts, int *ind, int *counts, int num_bins, ptrdiff_t sparts_offset); void space_getcells(struct space *s, int nr_cells, struct cell **cells); -void space_init(struct space *s, const struct swift_params *params, +void space_init(struct space *s, struct swift_params *params, const struct cosmology *cosmo, double dim[3], struct part *parts, struct gpart *gparts, struct spart *sparts, size_t Npart, size_t Ngpart, size_t Nspart, int periodic, diff --git a/src/units.c b/src/units.c index ae33b0c263dc014dbaf5406a8dcdc8ed254d26dd..af11d7de404c9a2060bd533ab4b8c4ecb666ecfa 100644 --- a/src/units.c +++ b/src/units.c @@ -78,7 +78,7 @@ void units_init(struct unit_system* us, double U_M_in_cgs, double U_L_in_cgs, * @param category The section of the parameter file to read from. */ void units_init_from_params(struct unit_system* us, - const struct swift_params* params, + struct swift_params* params, const char* category) { char buffer[200]; @@ -105,7 +105,7 @@ void units_init_from_params(struct unit_system* us, * @param def The default unit system to copy from if required. */ void units_init_default(struct unit_system* us, - const struct swift_params* params, const char* category, + struct swift_params* params, const char* category, const struct unit_system* def) { if (!def) error("Default unit_system not allocated"); diff --git a/src/units.h b/src/units.h index a6169d0a2f0e79156428f21d6096d66da7782837..1f0ef3cbd738176a82d61500e81f32bf8f02cf94 100644 --- a/src/units.h +++ b/src/units.h @@ -98,10 +98,10 @@ enum unit_conversion_factor { void units_init_cgs(struct unit_system*); void units_init(struct unit_system* us, double U_M_in_cgs, double U_L_in_cgs, double U_t_in_cgs, double U_C_in_cgs, double U_T_in_cgs); -void units_init_from_params(struct unit_system*, const struct swift_params*, +void units_init_from_params(struct unit_system*, struct swift_params*, const char* category); void units_init_default(struct unit_system* us, - const struct swift_params* params, const char* category, + struct swift_params* params, const char* category, const struct unit_system* def); int units_are_equal(const struct unit_system* a, const struct unit_system* b);