Skip to content

Commit 1016eaf

Browse files
committed
fixed hp parsing
1 parent 47524fc commit 1016eaf

File tree

3 files changed

+25
-33
lines changed

3 files changed

+25
-33
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "DFControl"
22
uuid = "1e31e15d-4957-550d-a244-318eced754ae"
33
authors = ["Louis Ponet <[email protected]>"]
44
repo = "https://github.com/louisponet/DFControl.jl.git"
5-
version = "0.5.28"
5+
version = "0.5.29"
66

77
[deps]
88
ANSIColoredPrinters = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"

src/Client/job.jl

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -357,27 +357,24 @@ Finds the output files for each of the calculations of a [`Job`](@ref), and grou
357357
function outputdata(job::Job; calcs=map(x->x.name, job.calculations), extra_parse_funcs=Dict())
358358
server = Server(job.server)
359359
out = Dict{String, Dict{Symbol, Any}}()
360-
for c in calcs
361-
calculation = job[c]
362-
p = joinpath(job, calculation.outfile)
363-
if ispath(server, p)
364-
if Calculations.isprojwfc(calculation)
365-
dos_files = filter(x->any(y-> occursin(string(y.name), x), job.structure.atoms), searchdir(job, "pdos_a"))
366-
extra_files = String[]
367-
dir = mkdir(tempname())
368-
for e in dos_files
369-
tfp = joinpath(dir, splitpath(e)[end])
370-
write(tfp, read(server, e))
371-
push!(extra_files, tfp)
360+
calculations = map(x->job[x], calcs)
361+
tdir = tempname()
362+
RemoteHPC.pull(job, tdir, infiles=false, calcs=calculations)
363+
for c in calculations
364+
of = Calculations.outfiles(c)
365+
main_file = joinpath(tdir, of[1])
366+
if ispath(main_file)
367+
extra_files = String[]
368+
if length(of) > 1
369+
for f in of[2:end]
370+
append!(extra_files, searchdir(tdir, f))
372371
end
373-
else
374-
extra_files = String[]
375372
end
376373
try
377-
out[c] = FileIO.outputdata(calculation, IOBuffer(read(server, p)), extra_files...; extra_parse_funcs = get(extra_parse_funcs, c, Pair{String}[]))
374+
out[c.name] = FileIO.outputdata(c, IOBuffer(read(main_file)), extra_files...; extra_parse_funcs = get(extra_parse_funcs, c.name, Pair{String}[]))
378375
for strkey in (:initial_structure, :final_structure)
379-
if haskey(out[c], strkey)
380-
for a in out[c][strkey].atoms
376+
if haskey(out[c.name], strkey)
377+
for a in out[c.name][strkey].atoms
381378
a.pseudo.server = job.server
382379
end
383380
end

src/FileIO/qe.jl

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function qe_parse_output(c::Calculation{QE}, files...; kwargs...)
3939
if Calculations.isprojwfc(c)
4040
return qe_parse_projwfc_output(files...)
4141
elseif Calculations.ishp(c)
42-
return qe_parse_hp_output(files[1]; kwargs...)
42+
return qe_parse_hp_output(files...; kwargs...)
4343
elseif Calculations.ispw(c)
4444
return qe_parse_pw_output(files[1]; kwargs...)
4545
end
@@ -874,7 +874,11 @@ end
874874

875875
function qe_parse_pert_at(out, line, f)
876876
sline = split(line)
877-
nat = parse(Int, sline[3])
877+
if sline[1] == "Atom"
878+
nat = 1
879+
else
880+
nat = parse(Int, sline[3])
881+
end
878882
out[:pert_at] = []
879883
readline(f)
880884
for i in 1:nat
@@ -902,19 +906,10 @@ end
902906
const QE_HP_PARSE_FUNCS = ["will be perturbed" => qe_parse_pert_at,
903907
"Hubbard U parameters:" => qe_parse_Hubbard_U]
904908

905-
function qe_parse_hp_output(file; parse_funcs = Pair{String,<:Function}[])
906-
out = parse_file(file, QE_HP_PARSE_FUNCS; extra_parse_funcs = parse_funcs)
907-
dir = splitdir(file)[1]
908-
hub_files = searchdir(dir, ".Hubbard_parameters.dat")
909-
if length(hub_files) > 1
910-
@warn "Found multiple .Hubbard_parameters.dat files. Using $(hub_files[1]) (remove and read again if this is undesired)"
911-
elseif isempty(hub_files)
912-
return out
913-
end
914-
915-
hubbard_file = hub_files[1]
916-
if ispath(hubbard_file)
917-
parse_file(hubbard_file, QE_HP_PARSE_FUNCS; extra_parse_funcs = parse_funcs, out = out)
909+
function qe_parse_hp_output(hp_file, hubbard_files...; parse_funcs = Pair{String,<:Function}[])
910+
out = parse_file(hp_file, QE_HP_PARSE_FUNCS; extra_parse_funcs = parse_funcs)
911+
if !isempty(hubbard_files)
912+
parse_file(hubbard_files[1], QE_HP_PARSE_FUNCS; extra_parse_funcs = parse_funcs, out = out)
918913
end
919914
return out
920915
end

0 commit comments

Comments
 (0)