Skip to content

Commit 27f5353

Browse files
authored
Merge pull request #160 from milankl/return_time
return time instead of progn vars
2 parents ee4c1f2 + a005cba commit 27f5353

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/default_parameters.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
output_dt::Real=24 # output time step [hours]
109109
outpath::String=pwd() # path to output folder
110110
compression_level::Int=3 # compression level
111+
return_time::Bool=false # return time of simulation of progn vars?
111112

112113
# INITIAL CONDITIONS
113114
initial_cond::String="rest" # "rest" or "ncfile" for restart from file

src/feedback.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@with_kw mutable struct Feedback
22
t0::Float64=time() # start time
33
t1::Float64=time() # time for duration estimation
4+
tend::Float64=t0 # end time
45
nans_detected::Bool=false # did NaNs occur in the simulation?
56
progress_txt::Union{IOStream,Nothing} # txt is a Nothing in case of no output
67
output::Bool # output to netCDF?
@@ -161,7 +162,11 @@ end
161162
function feedback_end!(feedback::Feedback)
162163
@unpack output,t0,progress_txt = feedback
163164

164-
s = " Integration done in "*readable_secs(time()-t0)*"."
165+
# time when the simulation ends
166+
tend = time()
167+
feedback.tend = tend # store in struct
168+
169+
s = " Integration done in "*readable_secs(tend-t0)*"."
165170
println(s)
166171
if output
167172
write(progress_txt,"\n"*s[2:end]*"\n") # close txt file with last output

src/time_integration.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,11 @@ function time_integration( Prog::PrognosticVars{Tprog},
292292
feedback_end!(feedback)
293293
output_close!(netCDFfiles,feedback,S)
294294

295-
return PrognosticVars{Tprog}(remove_halo(u,v,η,sst,S)...)
295+
if S.parameters.return_time
296+
return feedback.tend - feedback.t0
297+
else
298+
return PrognosticVars{Tprog}(remove_halo(u,v,η,sst,S)...)
299+
end
296300
end
297301

298302
"""Add to a x multiplied with b. a += x*b """

0 commit comments

Comments
 (0)