using Pkg
Pkg.activate("./")

using LatticeGPU
using TOML
using TimerOutputs
using ArgParse
using CUDA
using InteractiveUtils
using BDIO
using MD5

reset_timer!()

include("./src/io.jl")
include("./src/meas.jl")
include("./src/mc.jl")

@timeit "Input reading and space allocation" begin
    read_input()
    load_structs()
    global log_file = open("./output/"*params["Run"]["name"]*".log","a")
    write_log()
    load_fields()
    therm_or_readlist()
end

while RUN_ON

    @timeit "HMC" Gauge_update()

    @timeit "Two point functions" begin
        Frontflow_pt()
        Two_pt_lagrange()
    end

    @timeit "One point function" Backflow_pt()

    @timeit "Saving" save_data()

    check_run_status()

end

print_timer(log_file)

flush(log_file)
close(log_file)
