From 81d2952d1f0ce27766b813bd523d7b95e47b8e1f Mon Sep 17 00:00:00 2001 From: lhausamm <loic_hausammann@hotmail.com> Date: Fri, 8 Jun 2018 11:18:56 +0200 Subject: [PATCH] Add additional parameter for outputlist --- .../source/GettingStarted/parameter_file.rst | 8 ++--- examples/parameter_example.yml | 6 ++-- src/engine.c | 29 ++++++++++--------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/doc/RTD/source/GettingStarted/parameter_file.rst b/doc/RTD/source/GettingStarted/parameter_file.rst index b4c55b6752..1bf4cbd394 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 94e58ee5ce..5d03e04c6b 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 91332f1820..1cb4e0c22c 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); -- GitLab