Skip to content
Snippets Groups Projects
Commit 3a702e24 authored by xo30xoqa's avatar xo30xoqa
Browse files

Added "core.overwrite" parameter

parent 0874ec32
No related branches found
No related tags found
No related merge requests found
......@@ -25,12 +25,9 @@ using
## define exported functions and variables
export
#types
LandCover,
EventType,
Pixel,
FarmEvent,
FarmPlot,
Sex,
Animal,
Farmer,
#functions
......
......@@ -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)
......
......@@ -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"
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment