Skip to content

Commit

Permalink
feat: add storage options to default_namelist
Browse files Browse the repository at this point in the history
  • Loading branch information
haakon-e committed Nov 5, 2021
1 parent d25be1b commit 261450f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions integration_tests/utils/generate_namelist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ function default_namelist(::Nothing)
return default_namelist(case_name)
end

function default_namelist(case_name::String)
function default_namelist(case_name::String; root::String = ".", write::Bool = true)

namelist_defaults = Dict()
namelist_defaults["meta"] = Dict()
namelist_defaults["meta"]["uuid"] = basename(tempname())

namelist_defaults["turbulence"] = Dict()
namelist_defaults["turbulence"]["Ri_bulk_crit"] = 0.2
Expand Down Expand Up @@ -187,7 +188,9 @@ function default_namelist(case_name::String)
error("Not a valid case name")
end

write_file(namelist)
if write
write_file(namelist, root)
end
return namelist
end
function Soares(namelist_defaults)
Expand Down Expand Up @@ -410,14 +413,14 @@ function LES_driven_SCM(namelist_defaults)
return namelist
end

function write_file(namelist)
function write_file(namelist, root::String = ".")
mkpath(root)

@assert haskey(namelist, "meta")
@assert haskey(namelist["meta"], "simname")

namelist["meta"]["uuid"] = basename(tempname())

open("namelist_" * namelist["meta"]["casename"] * ".in", "w") do io
casename = namelist["meta"]["casename"]
open(joinpath(root, "namelist_$casename.in"), "w") do io
JSON.print(io, namelist, 4)
end

Expand Down

0 comments on commit 261450f

Please sign in to comment.