diff --git a/src/Persephone.jl b/src/Persephone.jl index 8849be701726aa67b42a152c210424bc0c84c1db..b45406d43a4701695bf769f440a13e2f41120aa1 100644 --- a/src/Persephone.jl +++ b/src/Persephone.jl @@ -25,12 +25,9 @@ using ## define exported functions and variables export #types - LandCover, - EventType, Pixel, FarmEvent, FarmPlot, - Sex, Animal, Farmer, #functions diff --git a/src/core/input.jl b/src/core/input.jl index 9d31152cb79af872bdc1994a278f9224c794411e..cb1c9f9297011868862425f17e9ebcb9de3e982b 100644 --- a/src/core/input.jl +++ b/src/core/input.jl @@ -9,8 +9,11 @@ ##XXX Does it make sense to move the settings dict into the model object itself? ## (It could be integrated into the properties dict.) Advantage: we have less ## global state lying around, and serialising becomes easier (if we want to do -## that). Disadvantage: only functions that have access to the model object can -## access the settings - this may give problems during initialisation. +## that). Also, during testing we often need to change individual parameters, +## which is currently impossible. Disadvantage: immutability of parameters at +## runtime is intended, and some start-up functions may have problems if they need +## access to parameters before the model object has been created. +##TODO -> yes, changing this is probably sensible let settings::Dict{String, Dict{String, Any}} """ initsettings(configfile) diff --git a/src/core/output.jl b/src/core/output.jl index 87afd9704eba6d577636e8e22391e93540708f33..830303f6f454e24c3aca08615c6469171dfe66e4 100644 --- a/src/core/output.jl +++ b/src/core/output.jl @@ -16,14 +16,21 @@ Creates the output directory and copies relevant files into it. function setupdatadir() # Check whether the output directory already exists and handle conflicts if isdir(param("core.outdir")) - @warn "The chosen output directory $(param("core.outdir")) already exists." - println("Type 'yes' to overwrite this directory. Otherwise, the simulation will abort.") - print("Overwrite? ") - answer = readline() - (answer != "yes") && Base.error("Output directory exists, will not overwrite. Aborting.") - else - mkpath(param("core.outdir")) + overwrite = param("core.overwrite") + if param("core.overwrite") == "ask" + println("The chosen output directory $(param("core.outdir")) already exists.") + println("Type 'yes' to overwrite this directory. Otherwise, the simulation will abort.") + print("Overwrite? ") + answer = readline() + (answer == "yes") && (overwrite = true) + end + if !overwrite + Base.error("Output directory exists, will not overwrite. Aborting.") + else + @warn "Overwriting existing output directory $(param("core.outdir"))." + end end + mkpath(param("core.outdir")) # Setup the logging system and logfile loglevel = Logging.Info if param("core.loglevel") == "debug" diff --git a/src/parameters.toml b/src/parameters.toml index 69677aaaebdf3b3736b5e0226397dc0e24ca738f..33efc7d54db84631f3ed7789e3ec92521c61f279 100644 --- a/src/parameters.toml +++ b/src/parameters.toml @@ -11,6 +11,7 @@ configfile = "src/parameters.toml" # location of the configuration file landcovermap = "data/landcover_jena.tif" # location of the landcover map farmfieldsmap = "data/fields_jena.tif" # location of the field geometry map outdir = "results" # location and name of the output folder +overwrite = "ask" # overwrite the output directory? (true/false/"ask") loglevel = "debug" # verbosity level: "debug", "info", "quiet" seed = 0 # seed value for the RNG (0 -> random value) # dates to start and end the simulation