After some experiment and searching, I figured out 2 ways of creating a shared module that holds some constant values.
SCHEME A:
# in file sharedconstants.jl:
module sharedconstants
kelvin = 273.15
end
# -------------------------
# in file main.jl:
include("./sharedconstants.jl");
using .sharedconstants
print(sharedconstants.kelvin, "\n");
# -------------------------
SCHEME B:
# in file sharedconstants.jl:
module sharedconstants
kelvin = 273.15
end
# -------------------------
# in file main.jl:
import sharedconstants
print(sharedconstants.kelvin, "\n");
# -------------------------
Scheme B does not always work and when it fails it throws
the error of not finding sharedconstants in current Path. Plus, Scheme B
requires the name of module (sharedconstants) the same as the trunk of
the file name. I wonder which way of the above is better in terms of
compiling and execution. Also is there any other approach to do the job?
I transferred from FORTRAN and I am quite used to simply
use sharedconstants in my code.