Commit fdf9a8a4 authored by Houtan Bastani's avatar Houtan Bastani

move preprocessor to submodule

parent 04ce0891
......@@ -30,3 +30,6 @@
[submodule "contrib/jsonlab"]
path = contrib/jsonlab
url = https://github.com/fangq/jsonlab.git
[submodule "preprocessor"]
path = preprocessor
url = https://github.com/DynareTeam/dynare-preprocessor.git
......@@ -35,6 +35,17 @@ EXTRA_DIST = \
scripts \
.dir-locals.el
all-local: preprocessor/src/dynare_m
{ \
if [ -z "`file preprocessor/src/dynare_m | grep x86.64`" ]; then \
ARCH="32"; \
else \
ARCH="64"; \
fi; \
mkdir -p $(abs_srcdir)/matlab/preprocessor$$ARCH; \
cp preprocessor/src/dynare_m $(abs_srcdir)/matlab/preprocessor$$ARCH; \
}
dist-hook:
rm -rf `find $(distdir)/matlab $(distdir)/examples -name *~`
rm -rf $(distdir)/matlab/preprocessor* $(distdir)/matlab/dynare_version.m
......@@ -51,13 +62,13 @@ install-exec-local:
find $(DESTDIR)$(pkglibdir) -name LICENSE.md -delete
rm -rf $(DESTDIR)$(pkglibdir)/matlab/preprocessor*
{ \
if [ -z "`file preprocessor/dynare_m | grep x86.64`" ]; then \
if [ -z "`file preprocessor/src/dynare_m | grep x86.64`" ]; then \
ARCH="32"; \
else \
ARCH="64"; \
fi; \
mkdir -p $(DESTDIR)$(pkglibdir)/matlab/preprocessor$$ARCH; \
cp preprocessor/dynare_m $(DESTDIR)$(pkglibdir)/matlab/preprocessor$$ARCH; \
cp preprocessor/src/dynare_m $(DESTDIR)$(pkglibdir)/matlab/preprocessor$$ARCH; \
}
uninstall-local:
......
dnl Process this file with autoconf to produce a configure script.
dnl Copyright (C) 2009-2017 Dynare Team
dnl Copyright (C) 2009-2018 Dynare Team
dnl
dnl This file is part of Dynare.
dnl
......@@ -19,9 +19,11 @@ dnl along with Dynare. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ([2.62])
AC_INIT([dynare], [4.6-unstable])
AC_CONFIG_SRCDIR([preprocessor/DynareMain.cc])
AC_CONFIG_SRCDIR([preprocessor/src/DynareMain.cc])
AM_INIT_AUTOMAKE([1.11 -Wall -Wno-portability foreign no-dist-gzip dist-xz tar-pax])
AC_CONFIG_SUBDIRS([preprocessor])
AC_PROG_CC
AC_PROG_CXX
......@@ -61,17 +63,6 @@ AX_PROG_LN_S
AC_PROG_MKDIR_P
AM_PROG_LEX
# Hack to get lex include dir, ticket #575
AC_PATH_PROG([LEXPATH], [$LEX])
AC_SUBST([LEXINC], [`eval "echo $LEXPATH | sed 's|\(.*\)$LEX$|\1../include|'"`])
AC_CHECK_PROG([YACC], [bison], [bison])
if test "x$YACC" = "x"; then
unset YACC # AM_MISSING_PROG needs an unset variable: an empty variable won't do
AM_MISSING_PROG([YACC], [bison])
fi
# We need 1.36 because of unordered_{set,hash} used by Dynare++
AX_BOOST_BASE([1.36], [], [AC_MSG_ERROR([Can't find Boost >= 1.36])])
......@@ -121,9 +112,6 @@ if test "x$PDFLATEX" != "x" -a "x$BIBTEX" != "x"; then
fi
AM_CONDITIONAL([HAVE_BEAMER], [test "x$ax_latex_have_beamer" = "xyes"])
AC_CHECK_PROG([DOXYGEN], [doxygen], [doxygen])
AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$DOXYGEN" != "x"])
AC_CHECK_PROG([CTANGLE], [ctangle], [ctangle])
AM_CONDITIONAL([HAVE_CTANGLE], [test "x$CTANGLE" != "x"])
if test "x$CTANGLE" = "x"; then
......@@ -166,8 +154,6 @@ AX_PTHREAD
AC_CONFIG_FILES([Makefile
VERSION
preprocessor/macro/Makefile
preprocessor/Makefile
doc/Makefile
doc/preprocessor/Makefile
doc/macroprocessor/Makefile
......@@ -220,8 +206,6 @@ AM_CONDITIONAL([ENABLE_ORG_EXPORT], [test "x$enable_org_export" != "x"])
# Construct final output message
BUILD_PREPROCESSOR="yes"
if test "x$ax_blas_ok" = "xyes" -a "x$ax_lapack_ok" = "xyes" -a "x$has_matio" = "xyes"; then
if test x"$ax_pthread_ok" = "xyes"; then
BUILD_DYNAREPLUSPLUS="yes"
......@@ -250,12 +234,6 @@ else
BUILD_OTHER_PDF_DOC="no (missing pdflatex)"
fi
if test "x$DOXYGEN" != "x"; then
BUILD_DYNARE_PREPROC_DOC="yes"
else
BUILD_DYNARE_PREPROC_DOC="no (missing doxygen)"
fi
if test "x$enable_org_export" != "x"; then
BUILD_DYNARE_INTERNAL_DOC="yes"
else
......@@ -293,7 +271,6 @@ AC_MSG_NOTICE([
Dynare is now configured for building the following components...
Binaries (with "make"):
Dynare preprocessor: $BUILD_PREPROCESSOR
Dynare++: $BUILD_DYNAREPLUSPLUS
PDF documentation (with "make pdf"):
......@@ -304,7 +281,6 @@ PDF documentation (with "make pdf"):
HTML documentation (with "make html"):
Dynare reference manual: $BUILD_DYNARE_HTML_MANUAL
Dynare preprocessor developer doc: $BUILD_DYNARE_PREPROC_DOC
Dynare internal doc: $BUILD_DYNARE_INTERNAL_DOC
Info documentation (with "make info"): $BUILD_DYNARE_INFO
......
mex_PROGRAMS = bytecode
bytecode_CPPFLAGS = -Wno-maybe-uninitialized $(AM_CPPFLAGS) -I$(top_srcdir)/../../sources -I$(top_srcdir)/../../sources/bytecode -I$(top_srcdir)/../../../preprocessor
bytecode_CPPFLAGS = -Wno-maybe-uninitialized $(AM_CPPFLAGS) -I$(top_srcdir)/../../sources -I$(top_srcdir)/../../sources/bytecode -I$(top_srcdir)/../../../preprocessor/src
TOPDIR = $(top_srcdir)/../../sources/bytecode
......
Subproject commit 662d3f71cecf0d8a32e94564071bf9cfc27eae4d
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2010-2017 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CONFIG_FILE_HH
#define _CONFIG_FILE_HH
#include <map>
#include <vector>
#include "WarningConsolidation.hh"
using namespace std;
typedef map<string, double> member_nodes_t;
class Hook
{
public:
Hook(string &global_init_file_arg);
~Hook();
private:
map<string, string> hooks;
public:
inline map<string, string>
get_hooks()
{
return hooks;
};
};
class Path
{
public:
Path(vector<string> &includepath_arg);
~Path();
private:
map<string, vector<string> > paths;
public:
inline map<string, vector<string> >
get_paths()
{
return paths;
};
};
class SlaveNode
{
friend class ConfigFile;
public:
SlaveNode(string &computerName_arg, string port_arg, int minCpuNbr_arg, int maxCpuNbr_arg, string &userName_arg,
string &password_arg, string &remoteDrive_arg, string &remoteDirectory_arg,
string &dynarePath_arg, string &matlabOctavePath_arg, bool singleCompThread_arg, int numberOfThreadsPerJob_arg,
string &operatingSystem_arg);
~SlaveNode();
protected:
const string computerName;
const string port;
int minCpuNbr;
int maxCpuNbr;
const string userName;
const string password;
const string remoteDrive;
const string remoteDirectory;
const string dynarePath;
const string matlabOctavePath;
const bool singleCompThread;
const int numberOfThreadsPerJob;
const string operatingSystem;
};
class Cluster
{
friend class ConfigFile;
public:
Cluster(member_nodes_t member_nodes_arg);
~Cluster();
protected:
member_nodes_t member_nodes;
};
//! The abstract representation of a "config" file
class ConfigFile
{
public:
ConfigFile(bool parallel_arg, bool parallel_test_arg, bool parallel_slave_open_mode_arg, const string &cluster_name);
~ConfigFile();
private:
const bool parallel;
const bool parallel_test;
const bool parallel_slave_open_mode;
const string cluster_name;
string firstClusterName;
//! Hooks
vector<Hook *> hooks;
//! Paths
vector<Path *> paths;
//! Cluster Table
map<string, Cluster *> clusters;
//! Node Map
map<string, SlaveNode *> slave_nodes;
//! Add Hooks
void addHooksConfFileElement(string &global_init_file);
//! Add Paths
void addPathsConfFileElement(vector<string> &includepath);
//! Add a SlaveNode or a Cluster object
void addParallelConfFileElement(bool inNode, bool inCluster, member_nodes_t member_nodes, string &name,
string &computerName, string port, int minCpuNbr, int maxCpuNbr, string &userName,
string &password, string &remoteDrive, string &remoteDirectory,
string &dynarePath, string &matlabOctavePath, bool singleCompThread, int numberOfThreadsPerJob,
string &operatingSystem);
public:
//! Parse config file
void getConfigFileInfo(const string &parallel_config_file);
//! Check Pass
void checkPass(WarningConsolidation &warnings) const;
//! Check Pass
void transformPass();
//! Get Path Info
vector<string> getIncludePaths() const;
//! Write any hooks
void writeHooks(ostream &output) const;
//! Create options_.parallel structure, write options
void writeCluster(ostream &output) const;
//! Close slave nodes if needed
void writeEndParallel(ostream &output) const;
};
#endif // ! CONFIG_FILE_HH
/*
* Copyright (C) 2003-2016 Dynare Team
*
* This file is part of Dynare.
*
* Dynare is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Dynare is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdlib>
#include <cassert>
#include <iostream>
#include "DataTree.hh"
DataTree::DataTree(SymbolTable &symbol_table_arg,
NumericalConstants &num_constants_arg,
ExternalFunctionsTable &external_functions_table_arg) :
symbol_table(symbol_table_arg),
num_constants(num_constants_arg),
external_functions_table(external_functions_table_arg),
node_counter(0)
{
Zero = AddNonNegativeConstant("0");
One = AddNonNegativeConstant("1");
Two = AddNonNegativeConstant("2");
MinusOne = AddUMinus(One);
NaN = AddNonNegativeConstant("NaN");
Infinity = AddNonNegativeConstant("Inf");
MinusInfinity = AddUMinus(Infinity);
Pi = AddNonNegativeConstant("3.141592653589793");
}
DataTree::~DataTree()
{
for (node_list_t::iterator it = node_list.begin(); it != node_list.end(); it++)
delete *it;
}
expr_t
DataTree::AddNonNegativeConstant(const string &value)
{
int id = num_constants.AddNonNegativeConstant(value);
num_const_node_map_t::iterator it = num_const_node_map.find(id);
if (it != num_const_node_map.end())
return it->second;
else
return new NumConstNode(*this, id);
}
VariableNode *
DataTree::AddVariableInternal(int symb_id, int lag)
{
variable_node_map_t::iterator it = variable_node_map.find(make_pair(symb_id, lag));
if (it != variable_node_map.end())
return it->second;
else
return new VariableNode(*this, symb_id, lag);
}
bool
DataTree::ParamUsedWithLeadLagInternal() const
{
for (variable_node_map_t::const_iterator it = variable_node_map.begin();
it != variable_node_map.end(); it++)
if (symbol_table.getType(it->first.first) == eParameter && it->first.second != 0)
return true;
return false;
}
VariableNode *
DataTree::AddVariable(int symb_id, int lag)
{
assert(lag == 0);
return AddVariableInternal(symb_id, lag);
}
expr_t
DataTree::AddPlus(expr_t iArg1, expr_t iArg2)
{
if (iArg1 != Zero && iArg2 != Zero)
{
// Simplify x+(-y) in x-y
UnaryOpNode *uarg2 = dynamic_cast<UnaryOpNode *>(iArg2);
if (uarg2 != NULL && uarg2->get_op_code() == oUminus)
return AddMinus(iArg1, uarg2->get_arg());
// To treat commutativity of "+"
// Nodes iArg1 and iArg2 are sorted by index
if (iArg1->idx > iArg2->idx)
{
expr_t tmp = iArg1;
iArg1 = iArg2;
iArg2 = tmp;
}
return AddBinaryOp(iArg1, oPlus, iArg2);
}
else if (iArg1 != Zero)
return iArg1;
else if (iArg2 != Zero)
return iArg2;
else
return Zero;
}
expr_t
DataTree::AddMinus(expr_t iArg1, expr_t iArg2)
{
if (iArg2 == Zero)
return iArg1;
if (iArg1 == Zero)
return AddUMinus(iArg2);
if (iArg1 == iArg2)
return Zero;
return AddBinaryOp(iArg1, oMinus, iArg2);
}
expr_t
DataTree::AddUMinus(expr_t iArg1)
{
if (iArg1 != Zero)
{
// Simplify -(-x) in x
UnaryOpNode *uarg = dynamic_cast<UnaryOpNode *>(iArg1);
if (uarg != NULL && uarg->get_op_code() == oUminus)
return uarg->get_arg();
return AddUnaryOp(oUminus, iArg1);
}
else
return Zero;
}
expr_t
DataTree::AddTimes(expr_t iArg1, expr_t iArg2)
{
if (iArg1 == MinusOne)
return AddUMinus(iArg2);
else if (iArg2 == MinusOne)
return AddUMinus(iArg1);
else if (iArg1 != Zero && iArg1 != One && iArg2 != Zero && iArg2 != One)
{
// To treat commutativity of "*"
// Nodes iArg1 and iArg2 are sorted by index
if (iArg1->idx > iArg2->idx)
{
expr_t tmp = iArg1;
iArg1 = iArg2;
iArg2 = tmp;
}
return AddBinaryOp(iArg1, oTimes, iArg2);
}
else if (iArg1 != Zero && iArg1 != One && iArg2 == One)
return iArg1;
else if (iArg2 != Zero && iArg2 != One && iArg1 == One)
return iArg2;
else if (iArg2 == One && iArg1 == One)
return One;
else
return Zero;
}
expr_t
DataTree::AddDivide(expr_t iArg1, expr_t iArg2) throw (DivisionByZeroException)
{
if (iArg2 == One)
return iArg1;
// This test should be before the next two, otherwise 0/0 won't be rejected
if (iArg2 == Zero)
{
cerr << "ERROR: Division by zero!" << endl;
throw DivisionByZeroException();
}
if (iArg1 == Zero)
return Zero;
if (iArg1 == iArg2)
return One;
return AddBinaryOp(iArg1, oDivide, iArg2);
}
expr_t
DataTree::AddLess(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oLess, iArg2);
}
expr_t
DataTree::AddGreater(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oGreater, iArg2);
}
expr_t
DataTree::AddLessEqual(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oLessEqual, iArg2);
}
expr_t
DataTree::AddGreaterEqual(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oGreaterEqual, iArg2);
}
expr_t
DataTree::AddEqualEqual(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oEqualEqual, iArg2);
}
expr_t
DataTree::AddDifferent(expr_t iArg1, expr_t iArg2)
{
return AddBinaryOp(iArg1, oDifferent, iArg2);
}
expr_t
DataTree::AddPower(expr_t iArg1, expr_t iArg2)
{
if (iArg1 != Zero && iArg2 != Zero && iArg1 != One && iArg2 != One)
return AddBinaryOp(iArg1, oPower, iArg2);
else if (iArg1 == One)
return One;
else if (iArg2 == One)
return iArg1;
else if (iArg2 == Zero)
return One;
else
return Zero;
}
expr_t
DataTree::AddPowerDeriv(expr_t iArg1, expr_t iArg2, int powerDerivOrder)
{
assert(powerDerivOrder > 0);
return AddBinaryOp(iArg1, oPowerDeriv, iArg2, powerDerivOrder);
}
expr_t
DataTree::AddExp(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oExp, iArg1);
else
return One;
}
expr_t
DataTree::AddLog(expr_t iArg1)
{
if (iArg1 != Zero && iArg1 != One)
return AddUnaryOp(oLog, iArg1);
else if (iArg1 == One)
return Zero;
else
{
cerr << "ERROR: log(0) not defined!" << endl;
exit(EXIT_FAILURE);
}
}
expr_t
DataTree::AddLog10(expr_t iArg1)
{
if (iArg1 != Zero && iArg1 != One)
return AddUnaryOp(oLog10, iArg1);
else if (iArg1 == One)
return Zero;
else
{
cerr << "ERROR: log10(0) not defined!" << endl;
exit(EXIT_FAILURE);
}
}
expr_t
DataTree::AddCos(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oCos, iArg1);
else
return One;
}
expr_t
DataTree::AddSin(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oSin, iArg1);
else
return Zero;
}
expr_t
DataTree::AddTan(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oTan, iArg1);
else
return Zero;
}
expr_t
DataTree::AddAcos(expr_t iArg1)
{
if (iArg1 != One)
return AddUnaryOp(oAcos, iArg1);
else
return Zero;
}
expr_t
DataTree::AddAsin(expr_t iArg1)
{
if (iArg1 != Zero)
return AddUnaryOp(oAsin, iArg1);
else