diff --git a/doc/RTD/source/GettingStarted/parameter_file.rst b/doc/RTD/source/GettingStarted/parameter_file.rst index b4c55b6752e9c2413a7b3bba7fd3a8921192e124..1bf4cbd3940a104c126aa256759edc24ca996338 100644 --- a/doc/RTD/source/GettingStarted/parameter_file.rst +++ b/doc/RTD/source/GettingStarted/parameter_file.rst @@ -15,11 +15,11 @@ the run time parameters. Output List ~~~~~~~~~~~ -In the sections ``Snapshots`` and ``Statistics``, you can specify the option ``output_list`` which receives a filename. -This file consists in a list of time where you want to output either a snapshot or a statistic. -With the header, you can choose between writing redshifts, scale factors or times. +In the sections ``Snapshots`` and ``Statistics``, you can specify the options ``output_list_on`` and ``output_list`` which receive an int and a filename. +The ``output_list_on`` enable or not the output list and ``output_list`` is the filename containing the output times. +With the file header, you can choose between writing redshifts, scale factors or times. -Example of file containing with times: +Example of file containing with times (in internal units): :: # Time 0.5 diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index 94e58ee5ce4d98f97a2ecefe5ad54000f1ef22bf..5d03e04c6be8c34998597b687f6101099721ffe5 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -81,7 +81,8 @@ Snapshots: UnitVelocity_in_cgs: 1 # (Optional) Unit system for the outputs (Centimeters per second) UnitCurrent_in_cgs: 1 # (Optional) Unit system for the outputs (Amperes) UnitTemp_in_cgs: 1 # (Optional) Unit system for the outputs (Kelvin) - output_list: "" # (Optional) File containing the output times (see documentation in "Parameter File" section) + output_list_on: 0 # (Optional) Enable the output list + output_list: snaplist.txt # (Optional) File containing the output times (see documentation in "Parameter File" section) # Parameters governing the conserved quantities statistics Statistics: @@ -90,7 +91,8 @@ Statistics: time_first: 0. # (Optional) Time of the first stats output if non-cosmological time-integration (in internal units) energy_file_name: energy # (Optional) File name for energy output timestep_file_name: timesteps # (Optional) File name for timing information output. Note: No underscores "_" allowed in file name - output_list: "" # (Optional) File containing the output times (see documentation in "Parameter File" section) + output_list_on: 0 # (Optional) Enable the output list + output_list: statlist.txt # (Optional) File containing the output times (see documentation in "Parameter File" section) # Parameters related to the initial conditions InitialConditions: diff --git a/src/engine.c b/src/engine.c index 91332f1820513e76a8332136dafa012d90abba41..1cb4e0c22c810a7797933725c92b9980077e2486 100644 --- a/src/engine.c +++ b/src/engine.c @@ -6750,15 +6750,16 @@ void engine_read_outputlist_files(struct engine *e, const struct swift_params *p cosmo = e->cosmology; /* Deal with snapshots */ - e->outputlist_snapshots = (struct outputlist*) malloc(sizeof(struct outputlist)); - list = e->outputlist_snapshots; - - strcpy(filename, ""); - parser_get_opt_param_string(params, "Snapshots:output_list", - filename, ""); + int outputlist_on = parser_get_opt_param_int(params, "Snapshots:output_list_on", 0); /* Read outputlist for snapshots */ - if (strcmp(filename, "")) { + if (outputlist_on) { + e->outputlist_snapshots = (struct outputlist*) malloc(sizeof(struct outputlist)); + list = e->outputlist_snapshots; + + parser_get_param_string(params, "Snapshots:output_list", + filename); + message("Reading snapshots output file."); outputlist_read_file(list, filename, cosmo); @@ -6777,15 +6778,17 @@ void engine_read_outputlist_files(struct engine *e, const struct swift_params *p } /* Deal with stats */ - e->outputlist_stats = (struct outputlist*) malloc(sizeof(struct outputlist)); - list = e->outputlist_stats; - strcpy(filename, ""); - parser_get_opt_param_string(params, "Statistics:output_list", - filename, ""); + outputlist_on = parser_get_opt_param_int(params, "Statistics:output_list_on", 0); /* Read outputlist for stats */ - if (strcmp(filename, "")) { + if (outputlist_on) { + e->outputlist_stats = (struct outputlist*) malloc(sizeof(struct outputlist)); + list = e->outputlist_stats; + + parser_get_param_string(params, "Statistics:output_list", + filename); + message("Reading statistics output file."); outputlist_read_file(list, filename, cosmo);