IO changes

parent 4feb9499
......@@ -478,6 +478,6 @@ export Dw!, DwdagDw!, g5Dw!, pfrandomize!, Csw!
include("DiracIO.jl")
export read_prop, save_prop
export read_prop, save_prop, read_dpar
end
"""
read_prop(psi, lp::SpaceParm{4,M,B,D},)
read_prop(fname::String)
Reads propagator from file `fname` using the native (BDIO) format.
"""
......@@ -129,4 +129,55 @@ function save_prop(fname::String, psi, lp::SpaceParm{4,M,B,D}, dpar::DiracParam;
BDIO_close!(fb)
return nothing
end
"""
read_dpar(fname::String)
Reads Dirac parameters from file `fname` using the native (BDIO) format. Returns DiracParam and SpaceParm.
"""
function read_dpar(fname::String)
UID_HDR = 14
fb = BDIO_open(fname, "r")
while BDIO_get_uinfo(fb) != UID_HDR
BDIO_seek!(fb)
end
ihdr = Vector{Int32}(undef, 2)
BDIO_read(fb, ihdr)
if (ihdr[1] != convert(Int32, 1753996112)) && (ihdr[2] != convert(Int32, 5))
error("Wrong file format [header]")
end
run = BDIO.BDIO_read_str(fb)
while BDIO_get_uinfo(fb) != 1
BDIO_seek!(fb)
end
ifoo = Vector{Int32}(undef, 2)
BDIO_read(fb, ifoo)
ndim = convert(Int64, ifoo[1])
npls = convert(Int64, round(ndim*(ndim-1)/2))
ibc = convert(Int64, ifoo[2])
ifoo = Vector{Int32}(undef, ndim+convert(Int32, npls))
BDIO_read(fb, ifoo)
iL = ntuple(i -> convert(Int64, ifoo[i]),ndim)
ntw = ntuple(i -> convert(Int64, ifoo[i+ndim]), npls)
foopars = Vector{Float64}(undef, 4)
BDIO_read(fb, foopars)
footh = Vector{Float64}(undef, 4)
lp = SpaceParm{ndim}(iL, (4,4,4,4), ibc, ntw)
dpar = DiracParam{Float64}(SU3fund,foopars[1],foopars[2],ntuple(i -> footh[i], 4),foopars[3])
BDIO_close!(fb)
return dpar, lp
end
\ No newline at end of file
......@@ -45,7 +45,7 @@ export Eoft_clover, Eoft_plaq, Qtop
export FlowIntr, wfl_euler, zfl_euler, wfl_rk2, zfl_rk2, wfl_rk3, zfl_rk3
export flw, flw_adapt
export sfcoupling, bndfield, setbndfield
export import_lex64, import_cern64, import_bsfqcd, save_cnfg, read_cnfg
export import_lex64, import_cern64, import_bsfqcd, save_cnfg, read_cnfg, read_gp
include("Spinors/Spinors.jl")
......@@ -58,7 +58,7 @@ include("Dirac/Dirac.jl")
using .Dirac
export DiracWorkspace, DiracParam
export Dw!, DwdagDw!, pfrandomize!, g5Dw!, Csw!
export read_prop, save_prop
export read_prop, save_prop, read_dpar
include("Solvers/Solvers.jl")
using .Solvers
......
......@@ -10,7 +10,7 @@
###
"""
read_cnfg(U, lp::SpaceParm{4,M,B,D},)
read_cnfg(fname::String)
Reads configuration from file `fname` using the native (BDIO) format.
"""
......@@ -117,6 +117,13 @@ function save_cnfg(fname::String, U, lp::SpaceParm{4,M,B,D}, gp::GaugeParm; run:
BDIO_write!(fb, [convert(Int32, lp.iL[i]) for i in 1:4])
BDIO_write!(fb, [convert(Int32, lp.ntw[i]) for i in 1:M])
BDIO_write!(fb, [gp.beta, gp.c0, gp.cG[1], gp.cG[2]])
for i in 1:4
for a in fieldnames(SU3)
BDIO_write!(fb,[getfield(gp.Ubnd[i],a)])
end
end
end
BDIO_write_hash!(fb)
......@@ -297,3 +304,49 @@ function import_cern64(fname, ibc, lp::SpaceParm; log=true)
return CuArray(Ucpu)
end
"""
read_gp(fname::String)
Reads Gauge parameters from file `fname` using the native (BDIO) format. Returns GaugeParm and SpaceParm.
"""
function read_gp(fname::String)
UID_HDR = 14
fb = BDIO_open(fname, "r")
while BDIO_get_uinfo(fb) != UID_HDR
BDIO_seek!(fb)
end
ihdr = Vector{Int32}(undef, 2)
BDIO_read(fb, ihdr)
if (ihdr[1] != convert(Int32, 1653996111)) && (ihdr[2] != convert(Int32, 2))
error("Wrong file format [header]")
end
run = BDIO.BDIO_read_str(fb)
while BDIO_get_uinfo(fb) != 1
BDIO_seek!(fb)
end
ifoo = Vector{Int32}(undef, 4)
BDIO_read(fb, ifoo)
ndim = convert(Int64, ifoo[1])
npls = convert(Int64, round(ndim*(ndim-1)/2))
ibc = convert(Int64, ifoo[2])
nf = ifoo[4]
ifoo = Vector{Int32}(undef, ndim+convert(Int32, npls))
BDIO_read(fb, ifoo)
iL = ntuple(i -> convert(Int64, ifoo[i]),ndim)
ntw = ntuple(i -> convert(Int64, ifoo[i+ndim]), npls)
dfoo = Vector{Float64}(undef, 4)
BDIO_read(fb, dfoo)
lp = SpaceParm{ndim}(iL, (4,4,4,4), ibc, ntw)
gp = GaugeParm{Float64}(SU3{Float64}, dfoo[1], dfoo[2])
return gp, lp
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment