akio-tomiya / LatticeQCD.jl

A native Julia code for lattice QCD with dynamical fermions in 4 dimension.
https://github.com/akio-tomiya/LatticeQCD.jl
MIT License
131 stars 16 forks source link

`julia src/run.jl PARAMETER_FILE ` fails when `PARAMETER_FILE` is a absolute path #6

Closed terasakisatoshi closed 2 years ago

terasakisatoshi commented 2 years ago

As the title says:

$ julia src/run.jl ~/tmp/LatticeQCD.jl/my_parameters.jl
ERROR: LoadError: SystemError: opening file "/Users/terasaki/tmp/LatticeQCD.jl/Users/terasaki/tmp/LatticeQCD.jl/my_parameters.jl": No such file or directory
Stacktrace:
  [1] systemerror(p::String, errno::Int32; extrainfo::Nothing)
    @ Base ./error.jl:168
  [2] #systemerror#62
    @ ./error.jl:167 [inlined]
  [3] systemerror
    @ ./error.jl:167 [inlined]
  [4] open(fname::String; lock::Bool, read::Nothing, write::Nothing, create::Nothing, truncate::Nothing, append::Nothing)
    @ Base ./iostream.jl:293
  [5] open
    @ ./iostream.jl:282 [inlined]
  [6] open(f::Base.var"#326#327"{String}, args::String; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./io.jl:328
  [7] open
    @ ./io.jl:328 [inlined]
  [8] read
    @ ./io.jl:434 [inlined]
  [9] _include(mapexpr::Function, mod::Module, _path::String)
    @ Base ./loading.jl:1166
 [10] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
 [11] include
    @ ~/tmp/LatticeQCD.jl/src/system/mainrun.jl:1 [inlined]
 [12] run_LQCD(filenamein::String)
    @ Main.LatticeQCD.Mainrun ~/tmp/LatticeQCD.jl/src/system/mainrun.jl:36
 [13] runtest
    @ ~/tmp/LatticeQCD.jl/src/run.jl:19 [inlined]
 [14] top-level scope
    @ ./timing.jl:210
in expression starting at /Users/terasaki/tmp/LatticeQCD.jl/src/run.jl:26

This error causes due to these lines

https://github.com/akio-tomiya/LatticeQCD.jl/blob/63cc7911f880ffc3a8538d322bcd2ee2494cb569/src/system/mainrun.jl#L31-L41

especially include(pwd()*"/"*filename)

here is my suggestion, that is, just use abspath(filename)

help?> abspath
search: abspath isabspath AbstractPattern AbstractDisplay

  abspath(path::AbstractString) -> String

  Convert a path to an absolute path by adding the current directory if necessary. Also
  normalizes the path as in normpath.

  ──────────────────────────────────────────────────────────────────────────────────────

  abspath(path::AbstractString, paths::AbstractString...) -> String

  Convert a set of paths to an absolute path by joining them together and adding the
  current directory if necessary. Equivalent to abspath(joinpath(path, paths...)).