diff --git a/examples/main.c b/examples/main.c index 116d422c9adae14d4b14ec4467378c65a53aa0da..32798b2ee4f3958f5f0e3f91f228dc6b24b5d397 100644 --- a/examples/main.c +++ b/examples/main.c @@ -713,9 +713,11 @@ int main(int argc, char *argv[]) { else bzero(&gravity_properties, sizeof(struct gravity_props)); - /* Read particles and space information from (GADGET) ICs */ + /* Read particles and space information from ICs */ char ICfileName[200] = ""; parser_get_param_string(params, "InitialConditions:file_name", ICfileName); + const int periodic = + parser_get_param_int(params, "InitialConditions:periodic"); const int replicate = parser_get_opt_param_int(params, "InitialConditions:replicate", 1); clean_smoothing_length_values = parser_get_opt_param_int( @@ -726,10 +728,14 @@ int main(int argc, char *argv[]) { params, "InitialConditions:cleanup_velocity_factors", 0); const int generate_gas_in_ics = parser_get_opt_param_int( params, "InitialConditions:generate_gas_in_ics", 0); + + /* Some checks that we are not doing something stupid */ if (generate_gas_in_ics && flag_entropy_ICs) error("Can't generate gas if the entropy flag is set in the ICs."); if (generate_gas_in_ics && !with_cosmology) error("Can't generate gas if the run is not cosmological."); + + /* Be verbose about what happens next */ if (myrank == 0) message("Reading ICs from file '%s'", ICfileName); if (myrank == 0 && cleanup_h) message("Cleaning up h-factors (h=%f)", cosmo.h); @@ -740,20 +746,19 @@ int main(int argc, char *argv[]) { /* Get ready to read particles of all kinds */ size_t Ngas = 0, Ngpart = 0, Nspart = 0; double dim[3] = {0., 0., 0.}; - int periodic = 0; if (myrank == 0) clocks_gettime(&tic); #if defined(HAVE_HDF5) #if defined(WITH_MPI) #if defined(HAVE_PARALLEL_HDF5) read_ic_parallel(ICfileName, &us, dim, &parts, &gparts, &sparts, &Ngas, - &Ngpart, &Nspart, &periodic, &flag_entropy_ICs, with_hydro, + &Ngpart, &Nspart, &flag_entropy_ICs, with_hydro, (with_external_gravity || with_self_gravity), with_stars, cleanup_h, cleanup_sqrt_a, cosmo.h, cosmo.a, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL, nr_threads, dry_run); #else read_ic_serial(ICfileName, &us, dim, &parts, &gparts, &sparts, &Ngas, - &Ngpart, &Nspart, &periodic, &flag_entropy_ICs, with_hydro, + &Ngpart, &Nspart, &flag_entropy_ICs, with_hydro, (with_external_gravity || with_self_gravity), with_stars, cleanup_h, cleanup_sqrt_a, cosmo.h, cosmo.a, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL, nr_threads, @@ -761,7 +766,7 @@ int main(int argc, char *argv[]) { #endif #else read_ic_single(ICfileName, &us, dim, &parts, &gparts, &sparts, &Ngas, - &Ngpart, &Nspart, &periodic, &flag_entropy_ICs, with_hydro, + &Ngpart, &Nspart, &flag_entropy_ICs, with_hydro, (with_external_gravity || with_self_gravity), with_stars, cleanup_h, cleanup_sqrt_a, cosmo.h, cosmo.a, nr_threads, dry_run); diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index e1773154328fdbcb2ced4efae3e4787257dd022f..1264ad56959feb5fca664f6e31614045719803cd 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -104,6 +104,7 @@ Statistics: # Parameters related to the initial conditions InitialConditions: file_name: SedovBlast/sedov.hdf5 # The file to read + periodic: 1 # Are we runing with periodic ICs? generate_gas_in_ics: 0 # (Optional) Generate gas particles from the DM-only ICs (e.g. from panphasia). cleanup_h_factors: 0 # (Optional) Clean up the h-factors used in the ICs (e.g. in Gadget files). cleanup_velocity_factors: 0 # (Optional) Clean up the scale-factors used in the definition of the velocity variable in the ICs (e.g. in Gadget files). diff --git a/src/parallel_io.c b/src/parallel_io.c index cb02d1806c6ede5edfeaeb13d61cbecb09ac57e6..816a1d8667d7fc91bd6dfd3758c4c8bb2c32d017 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -618,7 +618,6 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, * @param Ngas (output) The number of particles read from the file. * @param Ngparts (output) The number of particles read from the file. * @param Nstars (output) The number of particles read from the file. - * @param periodic (output) 1 if the volume is periodic, 0 if not. * @param flag_entropy (output) 1 if the ICs contained Entropy in the * InternalEnergy field * @param with_hydro Are we running with hydro ? @@ -640,11 +639,11 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, void read_ic_parallel(char* fileName, const struct unit_system* internal_units, double dim[3], struct part** parts, struct gpart** gparts, struct spart** sparts, size_t* Ngas, size_t* Ngparts, - size_t* Nstars, int* periodic, int* flag_entropy, - int with_hydro, int with_gravity, int with_stars, - int cleanup_h, int cleanup_sqrt_a, double h, double a, - int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info, - int n_threads, int dry_run) { + size_t* Nstars, int* flag_entropy, int with_hydro, + int with_gravity, int with_stars, int cleanup_h, + int cleanup_sqrt_a, double h, double a, int mpi_rank, + int mpi_size, MPI_Comm comm, MPI_Info info, int n_threads, + int dry_run) { hid_t h_file = 0, h_grp = 0; /* GADGET has only cubic boxes (in cosmological mode) */ @@ -664,17 +663,6 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units, h_file = H5Fopen(fileName, H5F_ACC_RDONLY, h_plist_id); if (h_file < 0) error("Error while opening file '%s'.", fileName); - /* Open header to read simulation properties */ - /* message("Reading runtime parameters..."); */ - h_grp = H5Gopen(h_file, "/RuntimePars", H5P_DEFAULT); - if (h_grp < 0) error("Error while opening runtime parameters\n"); - - /* Read the relevant information */ - io_read_attribute(h_grp, "PeriodicBoundariesOn", INT, periodic); - - /* Close runtime parameters */ - H5Gclose(h_grp); - /* Open header to read simulation properties */ /* message("Reading file header..."); */ h_grp = H5Gopen(h_file, "/Header", H5P_DEFAULT); diff --git a/src/parallel_io.h b/src/parallel_io.h index 668b6f83443fe4c39ddf3269c8d2236e72588e32..1805d9c4a99fdf3bb55959fbb238aeffbee18615 100644 --- a/src/parallel_io.h +++ b/src/parallel_io.h @@ -25,9 +25,7 @@ #if defined(HAVE_HDF5) && defined(WITH_MPI) && defined(HAVE_PARALLEL_HDF5) /* MPI headers. */ -#ifdef WITH_MPI #include <mpi.h> -#endif /* Includes. */ #include "engine.h" @@ -37,10 +35,10 @@ void read_ic_parallel(char* fileName, const struct unit_system* internal_units, double dim[3], struct part** parts, struct gpart** gparts, struct spart** sparts, size_t* Ngas, size_t* Ngparts, - size_t* Nsparts, int* periodic, int* flag_entropy, - int with_hydro, int with_gravity, int with_stars, - int cleanup_h, int cleanup_sqrt_a, double h, double a, - int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info, + size_t* Nsparts, int* flag_entropy, int with_hydro, + int with_gravity, int with_stars, int cleanup_h, + int cleanup_sqrt_a, double h, double a, int mpi_rank, + int mpi_size, MPI_Comm comm, MPI_Info info, int nr_threads, int dry_run); void write_output_parallel(struct engine* e, const char* baseName, diff --git a/src/serial_io.c b/src/serial_io.c index 32329a296f98687f4a44ad806b52eb259e65207c..ed9b022561d51e4c732f7086c9aba6a49ac2bc0b 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -398,7 +398,6 @@ void writeArray(const struct engine* e, hid_t grp, char* fileName, * @param Ngas (output) The number of #part read from the file on that node. * @param Ngparts (output) The number of #gpart read from the file on that node. * @param Nstars (output) The number of #spart read from the file on that node. - * @param periodic (output) 1 if the volume is periodic, 0 if not. * @param flag_entropy (output) 1 if the ICs contained Entropy in the * InternalEnergy field * @param with_hydro Are we reading gas particles ? @@ -427,11 +426,11 @@ void writeArray(const struct engine* e, hid_t grp, char* fileName, void read_ic_serial(char* fileName, const struct unit_system* internal_units, double dim[3], struct part** parts, struct gpart** gparts, struct spart** sparts, size_t* Ngas, size_t* Ngparts, - size_t* Nstars, int* periodic, int* flag_entropy, - int with_hydro, int with_gravity, int with_stars, - int cleanup_h, int cleanup_sqrt_a, double h, double a, - int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info, - int n_threads, int dry_run) { + size_t* Nstars, int* flag_entropy, int with_hydro, + int with_gravity, int with_stars, int cleanup_h, + int cleanup_sqrt_a, double h, double a, int mpi_rank, + int mpi_size, MPI_Comm comm, MPI_Info info, int n_threads, + int dry_run) { hid_t h_file = 0, h_grp = 0; /* GADGET has only cubic boxes (in cosmological mode) */ @@ -455,17 +454,6 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units, if (h_file < 0) error("Error while opening file '%s' for initial read.", fileName); - /* Open header to read simulation properties */ - /* message("Reading runtime parameters..."); */ - h_grp = H5Gopen(h_file, "/RuntimePars", H5P_DEFAULT); - if (h_grp < 0) error("Error while opening runtime parameters\n"); - - /* Read the relevant information */ - io_read_attribute(h_grp, "PeriodicBoundariesOn", INT, periodic); - - /* Close runtime parameters */ - H5Gclose(h_grp); - /* Open header to read simulation properties */ /* message("Reading file header..."); */ h_grp = H5Gopen(h_file, "/Header", H5P_DEFAULT); @@ -560,7 +548,6 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units, /* Now need to broadcast that information to all ranks. */ MPI_Bcast(flag_entropy, 1, MPI_INT, 0, comm); - MPI_Bcast(periodic, 1, MPI_INT, 0, comm); MPI_Bcast(&N_total, swift_type_count, MPI_LONG_LONG_INT, 0, comm); MPI_Bcast(dim, 3, MPI_DOUBLE, 0, comm); MPI_Bcast(ic_units, sizeof(struct unit_system), MPI_BYTE, 0, comm); diff --git a/src/serial_io.h b/src/serial_io.h index 6644e34bb32bcbd63250f25502563155eda0a293..f6280085e2ac294301017768126eec8c8f2c3d0e 100644 --- a/src/serial_io.h +++ b/src/serial_io.h @@ -37,11 +37,11 @@ void read_ic_serial(char* fileName, const struct unit_system* internal_units, double dim[3], struct part** parts, struct gpart** gparts, struct spart** sparts, size_t* Ngas, size_t* Ngparts, - size_t* Nstars, int* periodic, int* flag_entropy, - int with_hydro, int with_gravity, int with_stars, - int cleanup_h, int cleanup_sqrt_a, double h, double a, - int mpi_rank, int mpi_size, MPI_Comm comm, MPI_Info info, - int nr_threads, int dry_run); + size_t* Nstars, int* flag_entropy, int with_hydro, + int with_gravity, int with_stars, int cleanup_h, + int cleanup_sqrt_a, double h, double a, int mpi_rank, + int mpi_size, MPI_Comm comm, MPI_Info info, int nr_threads, + int dry_run); void write_output_serial(struct engine* e, const char* baseName, const struct unit_system* internal_units, diff --git a/src/single_io.c b/src/single_io.c index 764d58cf7411e58a10b6003edf0b4d3a9d5caef7..b7a31962f0bd483f3adbc49fd52decbb5575920b 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -314,7 +314,6 @@ void writeArray(const struct engine* e, hid_t grp, char* fileName, * @param Ngas (output) number of Gas particles read. * @param Ngparts (output) The number of #gpart read. * @param Nstars (output) The number of #spart read. - * @param periodic (output) 1 if the volume is periodic, 0 if not. * @param flag_entropy (output) 1 if the ICs contained Entropy in the * InternalEnergy field * @param with_hydro Are we reading gas particles ? @@ -339,10 +338,10 @@ void read_ic_single(const char* fileName, const struct unit_system* internal_units, double dim[3], struct part** parts, struct gpart** gparts, struct spart** sparts, size_t* Ngas, size_t* Ngparts, - size_t* Nstars, int* periodic, int* flag_entropy, - int with_hydro, int with_gravity, int with_stars, - int cleanup_h, int cleanup_sqrt_a, double h, double a, - int n_threads, int dry_run) { + size_t* Nstars, int* flag_entropy, int with_hydro, + int with_gravity, int with_stars, int cleanup_h, + int cleanup_sqrt_a, double h, double a, int n_threads, + int dry_run) { hid_t h_file = 0, h_grp = 0; /* GADGET has only cubic boxes (in cosmological mode) */ @@ -359,17 +358,6 @@ void read_ic_single(const char* fileName, h_file = H5Fopen(fileName, H5F_ACC_RDONLY, H5P_DEFAULT); if (h_file < 0) error("Error while opening file '%s'.", fileName); - /* Open header to read simulation properties */ - /* message("Reading runtime parameters..."); */ - h_grp = H5Gopen(h_file, "/RuntimePars", H5P_DEFAULT); - if (h_grp < 0) error("Error while opening runtime parameters\n"); - - /* Read the relevant information */ - io_read_attribute(h_grp, "PeriodicBoundariesOn", INT, periodic); - - /* Close runtime parameters */ - H5Gclose(h_grp); - /* Open header to read simulation properties */ /* message("Reading file header..."); */ h_grp = H5Gopen(h_file, "/Header", H5P_DEFAULT); diff --git a/src/single_io.h b/src/single_io.h index a0ce8370dfa1009f28e7c399b3f1db345c23de49..09d5d40e5ec5aa5f384ea751039128f258b65c09 100644 --- a/src/single_io.h +++ b/src/single_io.h @@ -33,10 +33,10 @@ void read_ic_single(const char* fileName, const struct unit_system* internal_units, double dim[3], struct part** parts, struct gpart** gparts, struct spart** sparts, size_t* Ngas, size_t* Ndm, - size_t* Nstars, int* periodic, int* flag_entropy, - int with_hydro, int with_gravity, int with_stars, - int cleanup_h, int cleanup_sqrt_a, double h, double a, - int nr_threads, int dry_run); + size_t* Nstars, int* flag_entropy, int with_hydro, + int with_gravity, int with_stars, int cleanup_h, + int cleanup_sqrt_a, double h, double a, int nr_threads, + int dry_run); void write_output_single(struct engine* e, const char* baseName, const struct unit_system* internal_units,