Skip to content

Commit 7a19158

Browse files
committed
get id mode fill
1 parent b1f51db commit 7a19158

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/DefaultParameters.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
initpath::String=outpath # folder where to pick the restart files from
9999
init_run_id::Int=0 # run id for restart from run number
100100
init_starti::Int=-1 # timestep to start from (-1 meaning last)
101+
get_id_mode::String="continue" # "continue" or "fill"
101102

102103
# ASSERT - CHECK THAT THE INPUT PARAMETERS MAKE SENSE
103104
@assert all((nx,Lx,L_ratio) .> 0.) "nx, Lx, L_ratio have to be >0"
@@ -130,4 +131,5 @@
130131
@assert initial_cond in ["rest", "ncfile"] "Initial conditions '$initial_cond' unsupported."
131132
@assert init_run_id >= 0 "Initial condition run id, init_run_id, has to be >= 0, $init_run_id given."
132133
@assert init_starti > 0 || init_starti == -1 "Start index, init_starti, has to be >0 || -1, $init_starti given."
134+
@assert get_id_mode in ["continue","fill"] "get_id_mode $get_id_mode unsupported."
133135
end

src/Output.jl

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,10 @@ function gap(a::Array{Int,1})
145145
end
146146

147147
"""Checks output folders to determine a 4-digit run id number."""
148-
function get_run_id_path( S::ModelSetup,
149-
order::String="continue",
150-
run_id::Union{Int,Nothing}=nothing)
151-
152-
@unpack output,outpath = S.parameters
148+
function get_run_id_path(S::ModelSetup)
153149

150+
@unpack output,outpath,get_id_mode = S.parameters
151+
154152
if output
155153
runlist = filter(x->startswith(x,"run"),readdir(outpath))
156154
existing_runs = [parse(Int,id[4:end]) for id in runlist]
@@ -159,26 +157,26 @@ function get_run_id_path( S::ModelSetup,
159157
mkdir(runpath)
160158
return 0,runpath
161159
else # create next folder
162-
if order == "fill" # find the smallest gap in runfolders
160+
if get_id_mode == "fill" # find the smallest gap in runfolders
163161
run_id = gap(existing_runs)
164162
runpath = joinpath(outpath,"run"*@sprintf("%04d",run_id))
165163
mkdir(runpath)
166164

167-
elseif order == "specific" # specify the run_id as input argument
168-
runpath = joinpath(outpath,"run"*@sprintf("%04d",run_id))
169-
try # create folder if not existent
170-
mkdir(runpath)
171-
catch # else rm folder and create new one
172-
rm(runpath,recursive=true)
173-
mkdir(runpath)
174-
end
165+
# elseif order == "specific" # specify the run_id as input argument
166+
# runpath = joinpath(outpath,"run"*@sprintf("%04d",run_id))
167+
# try # create folder if not existent
168+
# mkdir(runpath)
169+
# catch # else rm folder and create new one
170+
# rm(runpath,recursive=true)
171+
# mkdir(runpath)
172+
# end
175173

176-
elseif order == "continue" # find largest folder and count one up
174+
elseif get_id_mode == "continue" # find largest folder and count one up
177175
run_id = maximum(existing_runs)+1
178176
runpath = joinpath(outpath,"run"*@sprintf("%04d",run_id))
179177
mkdir(runpath)
180178
else
181-
throw(error("Order '$order' is not valid for get_run_id_path(), chose continue, specific or fill."))
179+
throw(error("Order '$get_id_mode' is not valid for get_run_id_path(), choose continue or fill."))
182180
end
183181
return run_id,runpath
184182
end

src/RunModel.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ julia> u,v,η,sst = RunModel(Float64,nx=200,output=true)
1010
```
1111
"""
1212
function RunModel(::Type{T}=Float32; # number format
13-
kwargs... # all additional parameters
13+
kwargs... # all additional parameters
1414
) where {T<:AbstractFloat}
1515

1616
P = Parameter(T=T;kwargs...)

0 commit comments

Comments
 (0)