diff --git a/src/clib/grackle_chemistry_data_fields.def b/src/clib/grackle_chemistry_data_fields.def index bcc8aa4a..9124b3df 100644 --- a/src/clib/grackle_chemistry_data_fields.def +++ b/src/clib/grackle_chemistry_data_fields.def @@ -208,6 +208,10 @@ ENTRY(collisional_ionisation_rates, INT, 1) //Collisional ionisation ENTRY(recombination_cooling_rates, INT, 1) //Recombination cooling ENTRY(bremsstrahlung_cooling_rates, INT, 1) //Bremsstrahlung cooling +/* Flag to specify unit-handling. Use the GR_UNIT_HANDLING_LEGACY and + GR_UNIT_HANDLING_AUTOMATIC to set the flag values */ +ENTRY(unit_handling, INT, -3) + /* maximum number of subcycle iterations for solve_chemistry */ ENTRY(max_iterations, INT, 10000) diff --git a/src/clib/initialize_chemistry_data.c b/src/clib/initialize_chemistry_data.c index ed51108b..f045f8d7 100644 --- a/src/clib/initialize_chemistry_data.c +++ b/src/clib/initialize_chemistry_data.c @@ -236,6 +236,21 @@ int local_initialize_chemistry_data(chemistry_data *my_chemistry, //omp_set_schedule( omp_sched_auto, chunk_size ); # endif + if (my_chemistry->unit_handling == -3) { + if (grackle_verbose) { + fprintf(stderr, ("WARNING: unit_handling is unset. Defaulting to legacy " + "handling.\n")); + } + my_chemistry->unit_handling = GR_UNIT_HANDLING_LEGACY; + } else if ((my_chemistry->unit_handling != GR_UNIT_HANDLING_LEGACY) && + (my_chemistry->unit_handling != GR_UNIT_HANDLING_AUTOMATIC)) { + fprintf(stderr, "unit_handling has an invalid value\n"); + return GR_FAIL; + } + + /* store a copy of the initial units */ + my_rates->initial_units = *my_units; + /* Only allow a units to be one with proper coordinates. */ if (my_units->comoving_coordinates == FALSE && my_units->a_units != 1.0) { @@ -342,8 +357,6 @@ int local_initialize_chemistry_data(chemistry_data *my_chemistry, return GR_FAIL; } - /* store a copy of the initial units */ - my_rates->initial_units = *my_units; if (grackle_verbose) { time_t timer; diff --git a/src/include/grackle.h b/src/include/grackle.h index 3796e787..14e1e3d5 100644 --- a/src/include/grackle.h +++ b/src/include/grackle.h @@ -26,6 +26,9 @@ extern "C" { #define GR_FAIL 0 #define GR_SPECIFY_INITIAL_A_VALUE -1 +#define GR_UNIT_HANDLING_LEGACY -2 +#define GR_UNIT_HANDLING_AUTOMATIC -1 + extern int grackle_verbose; diff --git a/src/include/grackle_chemistry_data.h b/src/include/grackle_chemistry_data.h index 22ce5007..9a2cc223 100644 --- a/src/include/grackle_chemistry_data.h +++ b/src/include/grackle_chemistry_data.h @@ -176,6 +176,9 @@ typedef struct int recombination_cooling_rates; //Recombination cooling int bremsstrahlung_cooling_rates; //Bremsstrahlung cooling + /* Flag to specify unit-handling */ + int unit_handling; + /* maximum number of subcycle iterations for solve_chemistry */ int max_iterations;