Specialize @dynare macro if one model is processed.

In this case importall is used instead of import.
time-shift
Stéphane Adjemian (Hermes) 2016-05-19 16:34:47 +02:00
parent bcd39ef2f7
commit c3b5aee714
4 changed files with 43 additions and 5 deletions

View File

@ -34,10 +34,16 @@ end
macro dynare(modfiles...)
ex = Expr(:toplevel)
for modfile in modfiles
eval(:(compile($modfile)))
basename = split(modfile, ".mod"; keep=false)
push!(ex.args, Expr(:import, symbol(basename[1])))
if length(modfiles)>1
for modfile in modfiles
eval(:(compile($modfile)))
basename = split(modfile, ".mod"; keep=false)
push!(ex.args, Expr(:import, symbol(basename[1])))
end
else
eval(:(compile($modfiles)))
basename = split(modfiles[1], ".mod"; keep=false)
push!(ex.args, Expr(:importall, symbol(basename[1])))
end
return ex
end

16
tests/julia/rbc/test1.jl Normal file
View File

@ -0,0 +1,16 @@
#clear workspace
workspace()
# Modification of the path (for packages). Should be done in ~/.juliarc.jl with a fixed path instead.
if isempty(findin([abspath("../../../julia")], LOAD_PATH))
unshift!(LOAD_PATH, abspath("../../../julia"))
end
# Load Dynare package
importall Dynare
# Compile the rbc.mod file -> produce a module with the model definition.
@dynare "rbc1.mod"
print(model.fname)

17
tests/julia/rbc/test2.jl Normal file
View File

@ -0,0 +1,17 @@
#clear workspace
workspace()
# Modification of the path (for packages). Should be done in ~/.juliarc.jl with a fixed path instead.
if isempty(findin([abspath("../../../julia")], LOAD_PATH))
unshift!(LOAD_PATH, abspath("../../../julia"))
end
# Load Dynare package
importall Dynare
# Compile the rbc.mod file -> produce a module with the model definition.
@dynare "rbc2.mod"
print(model.fname)

View File

@ -19,6 +19,5 @@ importall Dynare
# @compile "rbc1.mod"
# using rbc1
print(rbc1.model.fname)
print(rbc2.model.fname)