Skip to content

Commit

Permalink
some more refactoring, before trying to do something about execs
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed May 23, 2018
1 parent 58dfa59 commit a4e2a64
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/DFControl.jl
Expand Up @@ -38,7 +38,6 @@ module DFControl
export setrunflags!
export runflags
export setexecflags!
export execflags
export inputs
export input
export setfilename!
Expand Down
6 changes: 6 additions & 0 deletions src/input.jl
Expand Up @@ -223,5 +223,11 @@ function setdataoption!(input::DFInput, name::Symbol, option::Symbol; print=true
return input
end

execs(input::DFInput, exec::String) = filter(x -> contains(x.exec, exec), [input.exec, input.runcommand])
execflags(input::DFInput, exec::String) = [x.flags for x in execs(input, exec)]
setexecflags!(input::DFInput, exec::String, flags...) = setflags!.(execs(input, exec), flags...)

outfile(input::DFInput{QE}) = splitext(input.filename)[1]*".out"
outfile(input::DFInput{Wannier90}) = splitext(input.filename)[1]*".wout"

setflow!(input::DFInput, run) = input.run = run
27 changes: 3 additions & 24 deletions src/job.jl
Expand Up @@ -137,7 +137,7 @@ function DFJob(job::DFJob, flagstoset...;
newjob.name = name
end

setflags!!(newjob, flagstoset...)
setflags!(newjob, flagstoset...)
return newjob
end

Expand Down Expand Up @@ -468,14 +468,7 @@ setflow!(job::DFJob, should_runs::Vector{Bool}) = setflow!(job, [calc.filename =
Goes throug the calculation filenames and sets whether it should run or not.
"""
function setflow!(job::DFJob, filenames::Vector{String}, should_run)
UNDO_JOBS[job.id] = deepcopy(job)

for calc in inputs(job, filenames)
calc.run = should_run
end
return job
end
setflow!(job::DFJob, filenames::Vector{String}, should_run) = setflow!.(inputs(job, filenames), should_run)

"""
setruncommand!(job::DFJob, inputnames, runcommand::Exec)
Expand Down Expand Up @@ -519,26 +512,12 @@ function setrunflags!(job::DFJob, inputnames, flags...)
end
end

"Returns the runcommand flags."
runflags(job::DFJob, inputname) = input(job, inputname).runcommand[2]

"""
setexecflags!(job::DFJob, inputnames, flags...)
Goes through the calculations of the job and if the name contains any of the `inputnames` it sets the exec flags to the specified ones.
"""
function setexecflags!(job::DFJob, inputnames, flags...)
calcs = inputs(job, inputnames)
for calc in calcs
for (f,v) in flags
calc.exec.flags[f] = v
end
dfprintln("run flags of calculation $(calc.filename) are now $(calc.exec.flags).")
end
end

"Returns the runcommand flags."
execflags(job::DFJob, inputname) = input(job, inputname).exec.flags
setexecflags!(job::DFJob, inputnames, flags...) = setexecflags!.(inputs(job, inputnames), flags...)

"""
setinputinfo!(job::DFJob, filenames, block::Block)
Expand Down
7 changes: 7 additions & 0 deletions src/types.jl
Expand Up @@ -28,3 +28,10 @@ end
Exec(exec::String) = Exec(exec, "~/bin/", SymAnyDict())
Exec(exec::String, dir::String) = Exec(exec, dir, SymAnyDict())
Exec(exec::String, dir::String, flags...) = Exec(exec, dir, SymAnyDict(flags))

function setflags!(exec::Exec, flags...)
for (f, val) in flags
exec.flags[f] = val
end
exec.flags
end

0 comments on commit a4e2a64

Please sign in to comment.