diff --git a/src/DFControl.jl b/src/DFControl.jl index 92773844..25cf05f0 100644 --- a/src/DFControl.jl +++ b/src/DFControl.jl @@ -38,7 +38,6 @@ module DFControl export setrunflags! export runflags export setexecflags! - export execflags export inputs export input export setfilename! diff --git a/src/input.jl b/src/input.jl index 36c2811c..cf9fbfd2 100644 --- a/src/input.jl +++ b/src/input.jl @@ -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 diff --git a/src/job.jl b/src/job.jl index 66d11268..2e237541 100644 --- a/src/job.jl +++ b/src/job.jl @@ -137,7 +137,7 @@ function DFJob(job::DFJob, flagstoset...; newjob.name = name end - setflags!!(newjob, flagstoset...) + setflags!(newjob, flagstoset...) return newjob end @@ -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) @@ -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) diff --git a/src/types.jl b/src/types.jl index 704eb90a..24e17950 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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