Commit 56e494e7 authored by Josh Borrow's avatar Josh Borrow

Added with_cosmology option to SelectOutput file check/writing

parent 0d1aad01
......@@ -346,7 +346,7 @@ int main(int argc, char *argv[]) {
/* Write output parameter file */
if (myrank == 0 && output_parameters_filename != NULL) {
io_write_output_field_parameter(output_parameters_filename);
io_write_output_field_parameter(output_parameters_filename, with_cosmology);
printf("End of run.\n");
return 0;
}
......@@ -1090,7 +1090,8 @@ int main(int argc, char *argv[]) {
/* Verify that the fields to dump actually exist */
if (myrank == 0)
io_check_output_fields(output_options->select_output, N_total);
io_check_output_fields(output_options->select_output, N_total,
with_cosmology);
/* Initialize the space with these data. */
if (myrank == 0) clocks_gettime(&tic);
......
......@@ -257,7 +257,8 @@ int main(int argc, char *argv[]) {
/* Write output parameter file */
if (myrank == 0 && output_parameters_filename != NULL) {
io_write_output_field_parameter(output_parameters_filename);
io_write_output_field_parameter(output_parameters_filename,
/*with_cosmology=*/1);
printf("End of run.\n");
return 0;
}
......
......@@ -2274,9 +2274,11 @@ void io_collect_gparts_background_to_write(
* @param params The #swift_params instance corresponding to the select_output
* file.
* @param N_total The total number of each particle type.
* @param with_cosmolgy Ran with cosmology?
*/
void io_check_output_fields(const struct swift_params* params,
const long long N_total[swift_type_count]) {
const long long N_total[swift_type_count],
int with_cosmology) {
/* Loop over all particle types to check the fields */
for (int ptype = 0; ptype < swift_type_count; ptype++) {
......@@ -2296,7 +2298,7 @@ void io_check_output_fields(const struct swift_params* params,
num_fields +=
cooling_write_particles(NULL, NULL, list + num_fields, NULL);
num_fields += tracers_write_particles(NULL, NULL, list + num_fields,
/*with_cosmology=*/1);
with_cosmology);
num_fields +=
star_formation_write_particles(NULL, NULL, list + num_fields);
num_fields += fof_write_parts(NULL, NULL, list + num_fields);
......@@ -2316,18 +2318,17 @@ void io_check_output_fields(const struct swift_params* params,
break;
case swift_type_stars:
stars_write_particles(NULL, list, &num_fields, /*with_cosmology=*/1);
stars_write_particles(NULL, list, &num_fields, with_cosmology);
num_fields += chemistry_write_sparticles(NULL, list + num_fields);
num_fields += tracers_write_sparticles(NULL, list + num_fields,
/*with_cosmology=*/1);
num_fields +=
tracers_write_sparticles(NULL, list + num_fields, with_cosmology);
num_fields += star_formation_write_sparticles(NULL, list + num_fields);
num_fields += fof_write_sparts(NULL, list + num_fields);
num_fields += velociraptor_write_sparts(NULL, list + num_fields);
break;
case swift_type_black_hole:
black_holes_write_particles(NULL, list, &num_fields,
/*with_cosmology=*/1);
black_holes_write_particles(NULL, list, &num_fields, with_cosmology);
num_fields += chemistry_write_bparticles(NULL, list + num_fields);
num_fields += fof_write_bparts(NULL, list + num_fields);
num_fields += velociraptor_write_bparts(NULL, list + num_fields);
......@@ -2400,8 +2401,9 @@ void io_check_output_fields(const struct swift_params* params,
* @brief Write the output field parameters file
*
* @param filename The file to write.
* @param with_cosmology Use cosmological name variant?
*/
void io_write_output_field_parameter(const char* filename) {
void io_write_output_field_parameter(const char* filename, int with_cosmology) {
FILE* file = fopen(filename, "w");
if (file == NULL) error("Error opening file '%s'", filename);
......@@ -2426,7 +2428,7 @@ void io_write_output_field_parameter(const char* filename) {
num_fields +=
cooling_write_particles(NULL, NULL, list + num_fields, NULL);
num_fields += tracers_write_particles(NULL, NULL, list + num_fields,
/*with_cosmology=*/1);
with_cosmology);
num_fields +=
star_formation_write_particles(NULL, NULL, list + num_fields);
num_fields += fof_write_parts(NULL, NULL, list + num_fields);
......@@ -2446,18 +2448,17 @@ void io_write_output_field_parameter(const char* filename) {
break;
case swift_type_stars:
stars_write_particles(NULL, list, &num_fields, /*with_cosmology=*/1);
stars_write_particles(NULL, list, &num_fields, with_cosmology);
num_fields += chemistry_write_sparticles(NULL, list + num_fields);
num_fields += tracers_write_sparticles(NULL, list + num_fields,
/*with_cosmology=*/1);
num_fields +=
tracers_write_sparticles(NULL, list + num_fields, with_cosmology);
num_fields += star_formation_write_sparticles(NULL, list + num_fields);
num_fields += fof_write_sparts(NULL, list + num_fields);
num_fields += velociraptor_write_sparts(NULL, list + num_fields);
break;
case swift_type_black_hole:
black_holes_write_particles(NULL, list, &num_fields,
/*with_cosmology=*/1);
black_holes_write_particles(NULL, list, &num_fields, with_cosmology);
num_fields += chemistry_write_bparticles(NULL, list + num_fields);
num_fields += fof_write_bparts(NULL, list + num_fields);
num_fields += velociraptor_write_bparts(NULL, list + num_fields);
......
......@@ -168,9 +168,9 @@ void io_duplicate_black_holes_gparts(struct threadpool* tp,
size_t Ndm);
void io_check_output_fields(const struct swift_params* params,
const long long N_total[3]);
const long long N_total[3], int with_cosmology);
void io_write_output_field_parameter(const char* filename);
void io_write_output_field_parameter(const char* filename, int with_cosmology);
void io_make_snapshot_subdir(const char* dirname);
......
......@@ -156,7 +156,7 @@ int main(int argc, char *argv[]) {
message("Checking output parameters.");
long long N_total[swift_type_count] = {
(long long)Ngas, (long long)Ngpart, 0, 0, (long long)Nspart, 0};
io_check_output_fields(&param_file, N_total);
io_check_output_fields(&param_file, N_total, /*with_cosmology=*/1);
/* write output file */
message("Writing output.");
......
Markdown is supported
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