From 107586289a28551df70500dae046029f46060d72 Mon Sep 17 00:00:00 2001 From: "Fernando P. Panadero" Date: Tue, 21 Nov 2023 16:39:25 +0100 Subject: [PATCH] read_gp function --- src/LatticeGPU.jl | 2 +- src/YM/YM.jl | 2 +- src/YM/YMio.jl | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/LatticeGPU.jl b/src/LatticeGPU.jl index 6eccf5c..6c615b1 100644 --- a/src/LatticeGPU.jl +++ b/src/LatticeGPU.jl @@ -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") diff --git a/src/YM/YM.jl b/src/YM/YM.jl index 490a434..f279b1a 100644 --- a/src/YM/YM.jl +++ b/src/YM/YM.jl @@ -147,6 +147,6 @@ include("YMsf.jl") export sfcoupling, bndfield, setbndfield include("YMio.jl") -export import_lex64, import_cern64, import_bsfqcd, save_cnfg, read_cnfg +export import_lex64, import_cern64, import_bsfqcd, save_cnfg, read_cnfg, read_gp end diff --git a/src/YM/YMio.jl b/src/YM/YMio.jl index 41e6132..f492497 100644 --- a/src/YM/YMio.jl +++ b/src/YM/YMio.jl @@ -297,3 +297,50 @@ 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