Skip to content

Commit

Permalink
Implement code to read new defaults parameter file
Browse files Browse the repository at this point in the history
  • Loading branch information
smutch committed Jan 31, 2024
1 parent d08d897 commit b8bdca4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 200 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ endif()

if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
add_subdirectory(src/tests)
endif()


Expand Down
5 changes: 2 additions & 3 deletions input/params/defaults.par
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ ReionMaxHeatingRedshift : 30.
BirthCloudLifetime : 10e6 # yr
TargetSnaps : -1
RestBands : 1550,1650
BetaBands :
BetaBands :
InstantSfIII : 0 # 0 -> Continuous Pop.III SF, 1 -> Instantaneous Pop.III SF (crucial when computing the luminosity of PopIII galaxies)
DeltaT : 1.0 # Time at which the burst of PopIII SF happens since in the beginning of the snapshot (in Myr)
# Required only if InstantSfIII = 1
DeltaT : 1.0 # Time at which the burst of PopIII SF happens since in the beginning of the snapshot (in Myr). Required only if InstantSfIII = 1
3 changes: 2 additions & 1 deletion input/params/input.par
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FileNameGalaxies : meraxes
DefaultsFile : @INPUT_FILE_DIR@/Tiamat.par
DefaultsFile : @INPUT_FILE_DIR@/defaults.par
SimParamsFile : @INPUT_FILE_DIR@/simulations/Genesis_L10_N2048_PopIII.par
OutputSnapshots : -1
OutputDir : output
PhotometricTablesDir : @INPUT_FILE_DIR@/photometric_tables
Expand Down
194 changes: 0 additions & 194 deletions input/params/velociraptor_test.par

This file was deleted.

15 changes: 14 additions & 1 deletion src/core/read_params.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "meraxes.h"
#include "mlog.h"
#include "parse_paramfile.h"
#include <string.h>

Expand Down Expand Up @@ -148,6 +149,11 @@ void read_parameter_file(char* fname, int mode)
required_tag[n_param] = 1;
params_type[n_param++] = PARAM_TYPE_STRING;

strncpy(params_tag[n_param], "SimParamsFile", tag_length);
params_addr[n_param] = run_params->SimParamsFile;
required_tag[n_param] = 1;
params_type[n_param++] = PARAM_TYPE_STRING;

strncpy(params_tag[n_param], "OutputDir", tag_length);
params_addr[n_param] = run_params->OutputDir;
required_tag[n_param] = 1;
Expand Down Expand Up @@ -304,7 +310,7 @@ void read_parameter_file(char* fname, int mode)

strncpy(params_tag[n_param], "FFTW3WisdomDir", tag_length);
params_addr[n_param] = &(run_params->FFTW3WisdomDir);
required_tag[n_param] = 1;
required_tag[n_param] = 0;
params_type[n_param++] = PARAM_TYPE_STRING;
*(run_params->FFTW3WisdomDir) = '\0';

Expand Down Expand Up @@ -1227,10 +1233,17 @@ void read_parameter_file(char* fname, int mode)
// Parse the user parameter file first
n_entries = parse_paramfile(fname, entry);
store_params(entry, n_entries, params_tag, n_param, used_tag, params_type, params_addr);
mlog("Read input.par", MLOG_MESG);

// Now parse the default parameter file
n_entries = parse_paramfile(run_params->DefaultsFile, entry);
store_params(entry, n_entries, params_tag, n_param, used_tag, params_type, params_addr);
mlog("Read defaults.par", MLOG_MESG);

// Finally, parse the simulation parameter file
n_entries = parse_paramfile(run_params->SimParamsFile, entry);
store_params(entry, n_entries, params_tag, n_param, used_tag, params_type, params_addr);
mlog("Read sims file", MLOG_MESG);

// Check to see if we are missing any required parameters
for (ii = 0; ii < n_param; ii++)
Expand Down
1 change: 1 addition & 0 deletions src/meraxes.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ enum tree_ids
typedef struct run_params_t
{
char DefaultsFile[STRLEN];
char SimParamsFile[STRLEN];
char OutputDir[STRLEN];
char FileNameGalaxies[STRLEN];
char SimName[STRLEN];
Expand Down

0 comments on commit b8bdca4

Please sign in to comment.