Skip to content

Commit

Permalink
made exec handling better
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Oct 29, 2019
1 parent 6976350 commit 77d90e9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/fileio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ function read_job_line(line)
execs = Exec[]
for (e, flags) in exec_and_flags
dir, efile = splitdir(e)
if occursin("mpirun", e)
if occursin("mpi", e)
push!(execs, Exec(efile, dir, parse_mpi_flags(flags)))
elseif efile == "wannier90.x"
push!(execs, Exec(efile, dir, parse_wan_execflags(flags)))
elseif any(occursin.(QE_EXECS, (efile,)))
elseif any(occursin.(QE_EXECS, (efile,))) && !occursin("pw2wannier90", efile)
push!(execs, Exec(efile, dir, parse_qeexecflags(flags)))
elseif any(occursin.(ELK_EXECS, (efile,)))
input = "elk.in"
Expand Down
4 changes: 2 additions & 2 deletions src/inputAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ function gencalc_projwfc(template::DFInput, Emin, Emax, DeltaE, extraflags...; n
end
tdegaussflag = flag(template, :degauss)
degauss = tdegaussflag != nothing ? tdegaussflag : 0.0
if hasexec(template, "mpirun")
excs = [exec(template, "mpirun"), Exec("projwfc.x", execs(template)[end].dir)]
if length(execs(template)) == 2
excs = [execs(template)[1], Exec("projwfc.x", execs(template)[end].dir)]
else
excs = [Exec("projwfc.x", execs(template)[end].dir)]
end
Expand Down
15 changes: 12 additions & 3 deletions src/qe/constants.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const QE_EXECS = [
"projwfc.x",
"pp.x",
"ld1.x",
"ph.x"
"ph.x",
"pw2wannier90.x"
]
#REVIEW: Should we make the flag name a String?
#QE calls these flags
Expand Down Expand Up @@ -132,7 +133,15 @@ function qe_block_variable(exec::AbstractString, flagname)
return :error, QEFlagInfo()
end

qe_block_variable(input::DFInput, flagname) = qe_block_variable(execs(input)[2].exec, flagname)
function qe_exec(input::DFInput{QE})
exec = getfirst(x -> x.exec QE_EXECS, execs(input))
if exec === nothing
error("Input $input does not have a valid QE executable, please set it first.")
end
return exec
end

qe_block_variable(input::DFInput, flagname) = qe_block_variable(qe_exec(input).exec, flagname)

flagtype(input::DFInput{QE}, flag) = eltype(qe_flaginfo(execs(input)[2], flag))
flagtype(input::DFInput{QE}, flag) = eltype(qe_flaginfo(qe_exec(input), flag))
flagtype(::Type{QE}, exec, flag) = eltype(qe_flaginfo(exec, flag))
4 changes: 2 additions & 2 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function parse_mpi_flags(line::Vector{<:SubString})
eflags
end

const RUN_EXECS = ["mpirun"]
const RUN_EXECS = ["mpirun","mpi","mpiexec"]
allexecs() = vcat(RUN_EXECS, QE_EXECS, WAN_EXECS, ELK_EXECS)
parseable_execs() = vcat(QE_EXECS, WAN_EXECS, ELK_EXECS)
has_parseable_exec(l::String) = occursin(">", l) && any(occursin.(parseable_execs(), (l,)))
Expand Down Expand Up @@ -207,7 +207,7 @@ isparseable(exec::Exec) = exec.exec ∈ parseable_execs()
is_qe_exec(exec::Exec) = exec.exec QE_EXECS
is_wannier_exec(exec::Exec) = exec.exec WAN_EXECS
is_elk_exec(exec::Exec) = exec.exec ELK_EXECS
is_mpi_exec(exec::Exec) = exec.exec == "mpirun"
is_mpi_exec(exec::Exec) = occursin("mpi", exec.exec)

function inputparser(exec::Exec)
if is_qe_exec(exec)
Expand Down
4 changes: 2 additions & 2 deletions test/job_control_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ setflow!(job, ""=>false)
setflow!(job, "nscf" => true, "bands" => true)
@test job.inputs[3].run


@show job.inputs
save(job)
job2 = DFJob(local_dir)

@show job2.inputs
begin
for (calc, calc2) in zip(job.inputs, job2.inputs)

Expand Down
2 changes: 1 addition & 1 deletion test/jobfromcif_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bands_data = Dict(:kpoints => [[0.5, 0.5, 0.5, 100.],
:flags => [:verbosity => "high", :nbnd => 8])

nscf_data = merge(bands_data, Dict(:kpoints => [10, 10, 10]))
calculations = [:vc_relax => (excs, scf_data), :scf => (excs, scf_data), :bands => (excs, bands_data), :nscf =>(excs, nscf_data), :blabla => ([Exec(), Exec()], Dict())]
calculations = [:vc_relax => (excs, scf_data), :scf => (excs, scf_data), :bands => (excs, bands_data), :nscf =>(excs, nscf_data)]

job = DFJob(name, local_dir, joinpath(testjobpath, "Pt.cif"), calculations,
:prefix => "$name",
Expand Down

0 comments on commit 77d90e9

Please sign in to comment.