diff --git a/src/parallel_io.c b/src/parallel_io.c index 47f2e893f9046dc9f517c1d362b57217a520a318..5e358c34f70065255e1eab61295b21487f07f77d 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -39,9 +39,9 @@ #include "common_io.h" #include "engine.h" #include "error.h" -#include "hydro_properties.h" #include "gravity_io.h" #include "hydro_io.h" +#include "hydro_properties.h" #include "io_properties.h" #include "kernel_hydro.h" #include "part.h" @@ -706,6 +706,39 @@ void write_output_parallel(struct engine* e, const char* baseName, /* Print the system of Units used internally */ writeUnitSystem(h_file, internal_units, "InternalCodeUnits"); + /* Tell the user if a conversion will be needed */ + if (e->verbose && mpi_rank == 0) { + if (units_are_equal(snapshot_units, internal_units)) { + + message("Snapshot and internal units match. No conversion needed."); + + } else { + + message("Conversion needed from:"); + message("(Snapshot) Unit system: U_M = %e g.", + snapshot_units->UnitMass_in_cgs); + message("(Snapshot) Unit system: U_L = %e cm.", + snapshot_units->UnitLength_in_cgs); + message("(Snapshot) Unit system: U_t = %e s.", + snapshot_units->UnitTime_in_cgs); + message("(Snapshot) Unit system: U_I = %e A.", + snapshot_units->UnitCurrent_in_cgs); + message("(Snapshot) Unit system: U_T = %e K.", + snapshot_units->UnitTemperature_in_cgs); + message("to:"); + message("(internal) Unit system: U_M = %e g.", + internal_units->UnitMass_in_cgs); + message("(internal) Unit system: U_L = %e cm.", + internal_units->UnitLength_in_cgs); + message("(internal) Unit system: U_t = %e s.", + internal_units->UnitTime_in_cgs); + message("(internal) Unit system: U_I = %e A.", + internal_units->UnitCurrent_in_cgs); + message("(internal) Unit system: U_T = %e K.", + internal_units->UnitTemperature_in_cgs); + } + } + /* Loop over all particle types */ for (int ptype = 0; ptype < NUM_PARTICLE_TYPES; ptype++) { diff --git a/src/serial_io.c b/src/serial_io.c index 7bb829174c04545913a7ea560af1b4993526a0c5..0134fa3e52cd0df7341cbc88f11f4182b1c02949 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -39,9 +39,9 @@ #include "common_io.h" #include "engine.h" #include "error.h" -#include "hydro_properties.h" #include "gravity_io.h" #include "hydro_io.h" +#include "hydro_properties.h" #include "io_properties.h" #include "kernel_hydro.h" #include "part.h" @@ -764,6 +764,39 @@ void write_output_serial(struct engine* e, const char* baseName, /* Print the system of Units used internally */ writeUnitSystem(h_file, internal_units, "InternalCodeUnits"); + /* Tell the user if a conversion will be needed */ + if (e->verbose) { + if (units_are_equal(snapshot_units, internal_units)) { + + message("Snapshot and internal units match. No conversion needed."); + + } else { + + message("Conversion needed from:"); + message("(Snapshot) Unit system: U_M = %e g.", + snapshot_units->UnitMass_in_cgs); + message("(Snapshot) Unit system: U_L = %e cm.", + snapshot_units->UnitLength_in_cgs); + message("(Snapshot) Unit system: U_t = %e s.", + snapshot_units->UnitTime_in_cgs); + message("(Snapshot) Unit system: U_I = %e A.", + snapshot_units->UnitCurrent_in_cgs); + message("(Snapshot) Unit system: U_T = %e K.", + snapshot_units->UnitTemperature_in_cgs); + message("to:"); + message("(internal) Unit system: U_M = %e g.", + internal_units->UnitMass_in_cgs); + message("(internal) Unit system: U_L = %e cm.", + internal_units->UnitLength_in_cgs); + message("(internal) Unit system: U_t = %e s.", + internal_units->UnitTime_in_cgs); + message("(internal) Unit system: U_I = %e A.", + internal_units->UnitCurrent_in_cgs); + message("(internal) Unit system: U_T = %e K.", + internal_units->UnitTemperature_in_cgs); + } + } + /* Loop over all particle types */ for (int ptype = 0; ptype < NUM_PARTICLE_TYPES; ptype++) { diff --git a/src/single_io.c b/src/single_io.c index de7b96812365e136a078645511328338f8c4e8e3..3f634737194bf8bfdc780e662262b228ebc5c737 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -38,9 +38,9 @@ #include "common_io.h" #include "engine.h" #include "error.h" -#include "hydro_properties.h" #include "gravity_io.h" #include "hydro_io.h" +#include "hydro_properties.h" #include "io_properties.h" #include "kernel_hydro.h" #include "part.h" @@ -610,6 +610,39 @@ void write_output_single(struct engine* e, const char* baseName, /* Print the system of Units used internally */ writeUnitSystem(h_file, internal_units, "InternalCodeUnits"); + /* Tell the user if a conversion will be needed */ + if (e->verbose) { + if (units_are_equal(snapshot_units, internal_units)) { + + message("Snapshot and internal units match. No conversion needed."); + + } else { + + message("Conversion needed from:"); + message("(Snapshot) Unit system: U_M = %e g.", + snapshot_units->UnitMass_in_cgs); + message("(Snapshot) Unit system: U_L = %e cm.", + snapshot_units->UnitLength_in_cgs); + message("(Snapshot) Unit system: U_t = %e s.", + snapshot_units->UnitTime_in_cgs); + message("(Snapshot) Unit system: U_I = %e A.", + snapshot_units->UnitCurrent_in_cgs); + message("(Snapshot) Unit system: U_T = %e K.", + snapshot_units->UnitTemperature_in_cgs); + message("to:"); + message("(internal) Unit system: U_M = %e g.", + internal_units->UnitMass_in_cgs); + message("(internal) Unit system: U_L = %e cm.", + internal_units->UnitLength_in_cgs); + message("(internal) Unit system: U_t = %e s.", + internal_units->UnitTime_in_cgs); + message("(internal) Unit system: U_I = %e A.", + internal_units->UnitCurrent_in_cgs); + message("(internal) Unit system: U_T = %e K.", + internal_units->UnitTemperature_in_cgs); + } + } + /* Loop over all particle types */ for (int ptype = 0; ptype < NUM_PARTICLE_TYPES; ptype++) {