diff --git a/examples/EAGLE_6/eagle_6.yml b/examples/EAGLE_6/eagle_6.yml index 65d9c094ac635febb2b0cf21529231155b270a33..a8d43bf4df18d2106150925f33546af806231e3b 100644 --- a/examples/EAGLE_6/eagle_6.yml +++ b/examples/EAGLE_6/eagle_6.yml @@ -6,12 +6,13 @@ InternalUnitSystem: UnitCurrent_in_cgs: 1 # Amperes UnitTemp_in_cgs: 1 # Kelvin -# Structure finding on the fly options +# Structure finding options StructureFinding: - config_file_name: stf_input.cfg - output_file_name: ./halo/stf - output_time_format: 1 - output_times: 1e-5 + config_file_name: stf_input.cfg # Name of the STF config file. + basename: ./halo/stf # Common part of the name of output files. + output_time_format: 1 # Specifies format of delta_time. 0 for simulation steps and 1 for simulation time intervals. + time_first: 0. # Time of the first structure finding output (in internal units). + delta_time: 1e-5 # Time difference between consecutive structure finding outputs (in internal units). Can either be given in simulation steps or simulation time intervals. # Define the system of units to use int VELOCIraptor. VelociraptorUnitSystem: diff --git a/examples/main.c b/examples/main.c index 74b8d9ddda186ac8a701d4e472c67a38deb03275..a5912292eda963eeb0acc9ad3d7fa250a93d925c 100644 --- a/examples/main.c +++ b/examples/main.c @@ -476,7 +476,7 @@ int main(int argc, char *argv[]) { * directory exists and is searchable and writable. */ if(with_structure_finding) { char stfbasename[PARSER_MAX_LINE_SIZE]; - parser_get_param_string(params, "StructureFinding:output_file_name", stfbasename); + parser_get_param_string(params, "StructureFinding:basename", stfbasename); const char *stfdirp = dirname(stfbasename); if (access(stfdirp, W_OK | X_OK) != 0) { error("Cannot write stf catalogues in directory %s (%s)", stfdirp, strerror(errno)); diff --git a/src/common_io.h b/src/common_io.h index 49358d8a374553d803de144f1135df6eee80cf15..9a7602db0137e00c082c473b6187563c0af795b8 100644 --- a/src/common_io.h +++ b/src/common_io.h @@ -31,6 +31,8 @@ #define PARTICLE_GROUP_BUFFER_SIZE 50 #define FILENAME_BUFFER_SIZE 150 #define IO_BUFFER_ALIGNMENT 1024 +#define IO_STF_OUTPUT_FREQ_FORMAT_STEPS 0 +#define IO_STF_OUTPUT_FREQ_FORMAT_TIME 1 /* Avoid cyclic inclusion problems */ struct io_props; diff --git a/src/engine.c b/src/engine.c index b974447277cc6eaced3b99a2eb20a4466ea9cdee..842832a9e0bcf61810dba034ecfe55847b9040c2 100644 --- a/src/engine.c +++ b/src/engine.c @@ -4491,9 +4491,9 @@ void engine_step(struct engine *e) { /* Do we want to perform structure finding? */ if ((e->policy & engine_policy_structure_finding)) { - if(e->stf_output_time_format == 0 && e->step%(int)e->delta_time_stf_freq == 0) + if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_STEPS && e->step%(int)e->delta_time_stf_freq == 0) e->run_stf = 1; - else if(e->stf_output_time_format == 1 && e->ti_end_min >= e->ti_nextSTF && e->ti_nextSTF > 0) + else if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_TIME && e->ti_end_min >= e->ti_nextSTF && e->ti_nextSTF > 0) e->run_stf = 1; } @@ -4534,7 +4534,7 @@ void engine_step(struct engine *e) { velociraptor_invoke(e); /* ... and find the next output time */ - if(e->stf_output_time_format == 1) engine_compute_next_stf_time(e); + if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_TIME) engine_compute_next_stf_time(e); e->run_stf = 0; } @@ -5357,22 +5357,23 @@ void engine_config(int restart, struct engine *e, e->restart_next = 0; e->restart_dt = 0; e->delta_time_stf_freq = 0; - e->stf_output_time_format = 0; + e->stf_output_freq_format = 0; e->ti_nextSTF = 0; e->run_stf = 0; engine_rank = nodeID; /* Initialise VELOCIraptor. */ if (e->policy & engine_policy_structure_finding) { + parser_get_param_string(params, "StructureFinding:basename", e->stfBaseName); velociraptor_init(e); - e->stf_output_time_format = parser_get_param_int(params, "StructureFinding:output_time_format"); - if(e->stf_output_time_format == 0) { - e->delta_time_stf_freq = (double)parser_get_param_int(params, "StructureFinding:output_times"); + e->stf_output_freq_format = parser_get_param_int(params, "StructureFinding:output_time_format"); + if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_STEPS) { + e->delta_time_stf_freq = (double)parser_get_param_int(params, "StructureFinding:delta_time"); } - else if(e->stf_output_time_format == 1) { - e->delta_time_stf_freq = parser_get_param_double(params, "StructureFinding:output_times"); + else if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_TIME) { + e->delta_time_stf_freq = parser_get_param_double(params, "StructureFinding:delta_time"); } - else error("Invalid flag (%d) set for output time format of structure finding.", e->stf_output_time_format); + else error("Invalid flag (%d) set for output time format of structure finding.", e->stf_output_freq_format); } /* Get the number of queues */ @@ -5642,7 +5643,7 @@ void engine_config(int restart, struct engine *e, e->timeFirstSnapshot, e->time_begin); /* Find the time of the first stf output */ - if(e->stf_output_time_format == 1) { + if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_TIME) { engine_compute_next_stf_time(e); message("Next STF step will be: %lld", e->ti_nextSTF); } diff --git a/src/engine.h b/src/engine.h index 5da122ce96c99c918fd64e4b13348418a402dfcd..2a9c275f01349ad854761959b7e672505dbb362d 100644 --- a/src/engine.h +++ b/src/engine.h @@ -203,9 +203,10 @@ struct engine { /* Structure finding information */ int run_stf; - int stf_output_time_format; + int stf_output_freq_format; double delta_time_stf_freq; integertime_t ti_nextSTF; + char stfBaseName[PARSER_MAX_LINE_SIZE]; /* Statistics information */ FILE *file_stats; diff --git a/src/velociraptor_interface.c b/src/velociraptor_interface.c index 699e403586f18d44745f6da653c41a9875ea31b7..4587a465979976f9e33f05eabb0071ce84c77ad6 100644 --- a/src/velociraptor_interface.c +++ b/src/velociraptor_interface.c @@ -165,13 +165,16 @@ void velociraptor_invoke(struct engine *e) { //for(int i=0; i<nr_gparts; i++) message("Potential: %f", gparts[i].potential); - /* Read output base name and append with the step number */ - char outputbasename[PARSER_MAX_LINE_SIZE]; - parser_get_param_string(e->parameter_file, "StructureFinding:output_file_name", outputbasename); - + /* Append base name with either the step number or time depending on what format is specified in the parameter file. */ char outputFileName[FILENAME_BUFFER_SIZE]; - snprintf(outputFileName, FILENAME_BUFFER_SIZE, "%s_%04i.VELOCIraptor", outputbasename, + if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_STEPS) { + snprintf(outputFileName, FILENAME_BUFFER_SIZE, "%s_%04i.VELOCIraptor", e->stfBaseName, e->step); + } + else if(e->stf_output_freq_format == IO_STF_OUTPUT_FREQ_FORMAT_TIME) { + snprintf(outputFileName, FILENAME_BUFFER_SIZE, "%s_%04e.VELOCIraptor", e->stfBaseName, + e->time); + } InvokeVelociraptor(nr_gparts, gparts, cell_node_ids, outputFileName);