Skip to content

Commit

Permalink
Merge #30
Browse files Browse the repository at this point in the history
30: fix: write namelist and paramlist to file r=charleskawczynski a=haakon-e

Store namelist and paramlist in output folder together with the NetCDF datafile.

Co-authored-by: Haakon Ludvig Langeland Ervik <45243236+haakon-e@users.noreply.github.com>
  • Loading branch information
bors[bot] and haakon-e committed Jul 20, 2021
2 parents bdd61d3 + 0df92b6 commit bea3d33
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
12 changes: 6 additions & 6 deletions integration_tests/utils/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ mutable struct Simulation1d
Stats
end

function Simulation1d(namelist, paramlist, inpath = pwd())
function Simulation1d(namelist, paramlist)
Gr = TurbulenceConvection.Grid(namelist)
Ref = TurbulenceConvection.ReferenceState(Gr)
GMV = TurbulenceConvection.GridMeanVariables(namelist, Gr, Ref)
Case = Cases.CasesFactory(namelist, paramlist, Gr, Ref)
Turb = TurbulenceConvection.ParameterizationFactory(namelist, paramlist, Gr, Ref)
TS = TurbulenceConvection.TimeStepping(namelist)
Stats = TurbulenceConvection.NetCDFIO_Stats(namelist, paramlist, Gr, inpath)
Stats = TurbulenceConvection.NetCDFIO_Stats(namelist, paramlist, Gr)
return Simulation1d(Gr, Ref, GMV, Case, Turb, TS, Stats)
end

Expand Down Expand Up @@ -94,12 +94,12 @@ function force_io(self::Simulation1d)
return
end

function main(namelist, paramlist, inpath = pwd(); kwargs...)
main1d(namelist, paramlist, inpath; kwargs...)
function main(namelist, paramlist; kwargs...)
main1d(namelist, paramlist; kwargs...)
end

function main1d(namelist, paramlist, inpath = pwd(); time_run = false)
Simulation = Simulation1d(namelist, paramlist, inpath)
function main1d(namelist, paramlist; time_run = false)
Simulation = Simulation1d(namelist, paramlist)
TurbulenceConvection.initialize(Simulation, namelist)
if time_run
@time run(Simulation)
Expand Down
14 changes: 9 additions & 5 deletions src/NetCDFIO.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NCDatasets
using JSON

# TODO: remove `vars` hack that avoids https://github.com/Alexander-Barth/NCDatasets.jl/issues/135

Expand All @@ -13,7 +14,7 @@ mutable struct NetCDFIO_Stats
stats_path::String
path_plus_file::String
vars::Dict{String, Any} # Hack to avoid https://github.com/Alexander-Barth/NCDatasets.jl/issues/135
function NetCDFIO_Stats(namelist, paramlist, Gr::Grid, inpath = pwd())
function NetCDFIO_Stats(namelist, paramlist, Gr::Grid)

# Initialize properties with valid type:
tmp = tempname()
Expand Down Expand Up @@ -52,10 +53,13 @@ mutable struct NetCDFIO_Stats
# end
# end

# Copy namefile and paramfile to output directory
# TODO: this was commented:
# cp(joinpath(inpath, "$simname.in"), joinpath(outpath, "$simname.in"))
# cp(joinpath(inpath, "paramlist_$casename.in"), joinpath(outpath, "paramlist_$casename.in"))
# Write namefile and paramfile to output directory
open(joinpath(outpath, "$simname.in"), "w") do io
JSON.print(io, namelist, 4)
end
open(joinpath(outpath, "paramlist_$casename.in"), "w") do io
JSON.print(io, namelist, 4)
end

# TODO: make cell centers and cell faces different sizes
cinterior = Gr.cinterior
Expand Down

0 comments on commit bea3d33

Please sign in to comment.