Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Dynare
preprocessor
Commits
6fc6f2f7
Commit
6fc6f2f7
authored
Jul 27, 2015
by
Houtan Bastani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up writing of static model
parent
f3c14ec3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
17 deletions
+34
-17
ComputingTasks.cc
ComputingTasks.cc
+1
-1
ModFile.cc
ModFile.cc
+7
-5
StaticModel.cc
StaticModel.cc
+23
-8
StaticModel.hh
StaticModel.hh
+3
-3
No files found.
ComputingTasks.cc
View file @
6fc6f2f7
...
@@ -1195,7 +1195,7 @@ PlannerObjectiveStatement::computingPass()
...
@@ -1195,7 +1195,7 @@ PlannerObjectiveStatement::computingPass()
void
void
PlannerObjectiveStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
PlannerObjectiveStatement
::
writeOutput
(
ostream
&
output
,
const
string
&
basename
,
bool
minimal_workspace
)
const
{
{
model_tree
->
writeStaticFile
(
basename
+
"_objective"
,
false
,
false
,
false
);
model_tree
->
writeStaticFile
(
basename
+
"_objective"
,
false
,
false
,
false
,
false
);
}
}
BVARDensityStatement
::
BVARDensityStatement
(
int
maxnlags_arg
,
const
OptionsList
&
options_list_arg
)
:
BVARDensityStatement
::
BVARDensityStatement
(
int
maxnlags_arg
,
const
OptionsList
&
options_list_arg
)
:
...
...
ModFile.cc
View file @
6fc6f2f7
...
@@ -810,7 +810,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
...
@@ -810,7 +810,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
{
{
if
(
!
no_static
)
if
(
!
no_static
)
{
{
static_model
.
writeStaticFile
(
basename
,
block
,
byte_code
,
use_dll
);
static_model
.
writeStaticFile
(
basename
,
block
,
byte_code
,
use_dll
,
false
);
static_model
.
writeParamsDerivativesFile
(
basename
);
static_model
.
writeParamsDerivativesFile
(
basename
);
}
}
...
@@ -854,7 +854,7 @@ ModFile::writeExternalFilesC(const string &basename, FileOutputType output) cons
...
@@ -854,7 +854,7 @@ ModFile::writeExternalFilesC(const string &basename, FileOutputType output) cons
dynamic_model
.
writeDynamicFile
(
basename
,
block
,
byte_code
,
use_dll
,
mod_file_struct
.
order_option
);
dynamic_model
.
writeDynamicFile
(
basename
,
block
,
byte_code
,
use_dll
,
mod_file_struct
.
order_option
);
if
(
!
no_static
)
if
(
!
no_static
)
static_model
.
writeStaticFile
(
basename
,
false
,
false
,
true
);
static_model
.
writeStaticFile
(
basename
,
false
,
false
,
true
,
false
);
// static_model.writeStaticCFile(basename, block, byte_code, use_dll);
// static_model.writeStaticCFile(basename, block, byte_code, use_dll);
...
@@ -959,7 +959,7 @@ ModFile::writeExternalFilesCC(const string &basename, FileOutputType output) con
...
@@ -959,7 +959,7 @@ ModFile::writeExternalFilesCC(const string &basename, FileOutputType output) con
dynamic_model
.
writeDynamicFile
(
basename
,
block
,
byte_code
,
use_dll
,
mod_file_struct
.
order_option
);
dynamic_model
.
writeDynamicFile
(
basename
,
block
,
byte_code
,
use_dll
,
mod_file_struct
.
order_option
);
if
(
!
no_static
)
if
(
!
no_static
)
static_model
.
writeStaticFile
(
basename
,
false
,
false
,
true
);
static_model
.
writeStaticFile
(
basename
,
false
,
false
,
true
,
false
);
// static_model.writeStaticCFile(basename, block, byte_code, use_dll);
// static_model.writeStaticCFile(basename, block, byte_code, use_dll);
// static_model.writeParamsDerivativesFileC(basename, cuda);
// static_model.writeParamsDerivativesFileC(basename, cuda);
...
@@ -1083,6 +1083,7 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
...
@@ -1083,6 +1083,7 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
<<
"##"
<<
endl
<<
"##"
<<
endl
<<
"using DynareModel"
<<
endl
<<
"using DynareModel"
<<
endl
<<
"using Utils"
<<
endl
<<
"using Utils"
<<
endl
<<
"using "
<<
basename
<<
"Static"
<<
endl
<<
"export dynamicmodel!, staticmodel!, steadystate!"
<<
endl
<<
"export dynamicmodel!, staticmodel!, steadystate!"
<<
endl
<<
"export model__"
<<
endl
<<
"export model__"
<<
endl
<<
"model__ = model()"
<<
endl
<<
"model__ = model()"
<<
endl
...
@@ -1115,9 +1116,10 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
...
@@ -1115,9 +1116,10 @@ ModFile::writeExternalFilesJulia(const string &basename, FileOutputType output)
if
(
dynamic_model
.
equation_number
()
>
0
)
if
(
dynamic_model
.
equation_number
()
>
0
)
if
(
!
no_static
)
if
(
!
no_static
)
static_model
.
writeStaticFile
(
basename
,
false
,
false
,
false
,
&
jlOutputFil
e
);
static_model
.
writeStaticFile
(
basename
,
false
,
false
,
false
,
tru
e
);
jlOutputFile
<<
"end"
<<
endl
;
jlOutputFile
<<
"model__.static = "
<<
basename
<<
"Static.getStaticFunction()"
<<
endl
<<
"end"
<<
endl
;
jlOutputFile
.
close
();
jlOutputFile
.
close
();
cout
<<
"done"
<<
endl
;
cout
<<
"done"
<<
endl
;
}
}
StaticModel.cc
View file @
6fc6f2f7
...
@@ -1560,16 +1560,31 @@ StaticModel::writeStaticCFile(const string &func_name) const
...
@@ -1560,16 +1560,31 @@ StaticModel::writeStaticCFile(const string &func_name) const
}
}
void
void
StaticModel
::
writeStaticJuliaFile
(
ofstream
&
jlOutputFil
e
)
const
StaticModel
::
writeStaticJuliaFile
(
const
string
&
basenam
e
)
const
{
{
jlOutputFile
<<
"model__.static = function static(y, x, params)"
<<
endl
;
string
filename
=
basename
+
"Static.jl"
;
writeStaticModel
(
jlOutputFile
,
false
,
true
);
ofstream
output
;
jlOutputFile
<<
"(residual, g1, g2, g3)"
<<
endl
output
.
open
(
filename
.
c_str
(),
ios
::
out
|
ios
::
binary
);
<<
"end"
<<
endl
;
if
(
!
output
.
is_open
())
{
cerr
<<
"ERROR: Can't open file "
<<
filename
<<
" for writing"
<<
endl
;
exit
(
EXIT_FAILURE
);
}
output
<<
"module "
<<
basename
<<
"Static"
<<
endl
<<
endl
<<
"export getStaticFunction"
<<
endl
<<
endl
<<
"function getStaticFunction()"
<<
endl
<<
" static"
<<
endl
<<
"end"
<<
endl
<<
endl
<<
"function static(y, x, params)"
<<
endl
;
writeStaticModel
(
output
,
false
,
true
);
output
<<
"(residual, g1, g2, g3)"
<<
endl
<<
"end"
<<
endl
<<
"end"
<<
endl
;
}
}
void
void
StaticModel
::
writeStaticFile
(
const
string
&
basename
,
bool
block
,
bool
bytecode
,
bool
use_dll
,
ofstream
*
jlOutputFile
)
const
StaticModel
::
writeStaticFile
(
const
string
&
basename
,
bool
block
,
bool
bytecode
,
bool
use_dll
,
bool
julia
)
const
{
{
int
r
;
int
r
;
...
@@ -1598,8 +1613,8 @@ StaticModel::writeStaticFile(const string &basename, bool block, bool bytecode,
...
@@ -1598,8 +1613,8 @@ StaticModel::writeStaticFile(const string &basename, bool block, bool bytecode,
}
}
else
if
(
use_dll
)
else
if
(
use_dll
)
writeStaticCFile
(
basename
);
writeStaticCFile
(
basename
);
else
if
(
j
lOutputFile
!=
NULL
)
else
if
(
j
ulia
)
writeStaticJuliaFile
(
*
jlOutputFil
e
);
writeStaticJuliaFile
(
basenam
e
);
else
else
writeStaticMFile
(
basename
);
writeStaticMFile
(
basename
);
writeAuxVarRecursiveDefinitions
(
basename
);
writeAuxVarRecursiveDefinitions
(
basename
);
...
...
StaticModel.hh
View file @
6fc6f2f7
/*
/*
* Copyright (C) 2003-201
2
Dynare Team
* Copyright (C) 2003-201
5
Dynare Team
*
*
* This file is part of Dynare.
* This file is part of Dynare.
*
*
...
@@ -51,7 +51,7 @@ private:
...
@@ -51,7 +51,7 @@ private:
void
writeStaticCFile
(
const
string
&
func_name
)
const
;
void
writeStaticCFile
(
const
string
&
func_name
)
const
;
//! Writes static model file (Julia version)
//! Writes static model file (Julia version)
void
writeStaticJuliaFile
(
ofstream
&
jlOutputFil
e
)
const
;
void
writeStaticJuliaFile
(
const
string
&
basenam
e
)
const
;
//! Writes the static model equations and its derivatives
//! Writes the static model equations and its derivatives
void
writeStaticModel
(
ostream
&
StaticOutput
,
bool
use_dll
,
bool
julia
)
const
;
void
writeStaticModel
(
ostream
&
StaticOutput
,
bool
use_dll
,
bool
julia
)
const
;
...
@@ -171,7 +171,7 @@ public:
...
@@ -171,7 +171,7 @@ public:
int
&
u_count_int
,
bool
&
file_open
)
const
;
int
&
u_count_int
,
bool
&
file_open
)
const
;
//! Writes static model file
//! Writes static model file
void
writeStaticFile
(
const
string
&
basename
,
bool
block
,
bool
bytecode
,
bool
use_dll
,
ofstream
*
jlOutputFile
=
NULL
)
const
;
void
writeStaticFile
(
const
string
&
basename
,
bool
block
,
bool
bytecode
,
bool
use_dll
,
bool
julia
)
const
;
//! Writes file containing static parameters derivatives
//! Writes file containing static parameters derivatives
void
writeParamsDerivativesFile
(
const
string
&
basename
)
const
;
void
writeParamsDerivativesFile
(
const
string
&
basename
)
const
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment