Skip to content
Snippets Groups Projects
Commit 09e71904 authored by MichelJuillard's avatar MichelJuillard
Browse files

changed line options for extended preprocessor, adding language option

renamed FileOutputType.hh as ExtendedPreprocessorTypes.hh
updated Makefile.am
parent 03833cee
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "macro/MacroDriver.hh" #include "macro/MacroDriver.hh"
#include <unistd.h> #include <unistd.h>
#include "FileOutputType.hh" #include "ExtendedPreprocessorTypes.hh"
/* Prototype for second part of main function /* Prototype for second part of main function
Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
*/ */
void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive, void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive,
bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode, bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test, bool nostrict, FileOutputType output_mode, bool cuda bool parallel_test, bool nostrict, FileOutputType output_mode, LanguageOutputType lang
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc , bool cygwin, bool msvc
#endif #endif
...@@ -48,7 +48,7 @@ usage() ...@@ -48,7 +48,7 @@ usage()
{ {
cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]" cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]"
<< " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] " << " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] "
<< " [-D<variable>[=<value>]] [nostrict] [-double=dynamic|first|second|third] [cuda]" << " [-D<variable>[=<value>]] [nostrict] [output=dynamic|first|second|third] [language=C|C++]"
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
<< " [cygwin] [msvc]" << " [cygwin] [msvc]"
#endif #endif
...@@ -97,7 +97,7 @@ main(int argc, char **argv) ...@@ -97,7 +97,7 @@ main(int argc, char **argv)
bool nostrict = false; bool nostrict = false;
map<string, string> defines; map<string, string> defines;
FileOutputType output_mode = none; FileOutputType output_mode = none;
bool cuda = false; LanguageOutputType language = matlab;
// Parse options // Parse options
for (int arg = 2; arg < argc; arg++) for (int arg = 2; arg < argc; arg++)
...@@ -199,8 +199,6 @@ main(int argc, char **argv) ...@@ -199,8 +199,6 @@ main(int argc, char **argv)
cerr << "Incorrect syntax for ouput option" << endl; cerr << "Incorrect syntax for ouput option" << endl;
usage(); usage();
} }
// we don't want temp terms in CC functions
no_tmp_terms = true;
if (strlen(argv[arg]) == 14 && !strncmp(argv[arg] + 7, "dynamic", 7)) if (strlen(argv[arg]) == 14 && !strncmp(argv[arg] + 7, "dynamic", 7))
output_mode = dynamic; output_mode = dynamic;
else if (strlen(argv[arg]) == 12 && !strncmp(argv[arg] + 7, "first", 5)) else if (strlen(argv[arg]) == 12 && !strncmp(argv[arg] + 7, "first", 5))
...@@ -215,8 +213,31 @@ main(int argc, char **argv) ...@@ -215,8 +213,31 @@ main(int argc, char **argv)
usage(); usage();
} }
} }
else if (!strcmp(argv[arg], "cuda")) else if (strlen(argv[arg]) >= 8 && !strncmp(argv[arg], "language", 8))
cuda = true; {
if (strlen(argv[arg]) <= 9 || argv[arg][6] != '=')
{
cerr << "Incorrect syntax for language option" << endl;
usage();
}
// we don't want temp terms in external functions
no_tmp_terms = true;
if (strlen(argv[arg]) == 10 && !strncmp(argv[arg] + 9, "C", 1))
language = c;
else if (strlen(argv[arg]) == 12 && !strncmp(argv[arg] + 9, "C++", 3))
language = cpp;
else if (strlen(argv[arg]) == 13 && !strncmp(argv[arg] + 9, "cuda", 4))
language = cuda;
else if (strlen(argv[arg]) == 14 && !strncmp(argv[arg] + 9, "julia", 5))
language = julia;
else if (strlen(argv[arg]) == 15 && !strncmp(argv[arg] + 9, "python", 6))
language = python;
else
{
cerr << "Incorrect syntax for ouput option" << endl;
usage();
}
}
else else
{ {
cerr << "Unknown option: " << argv[arg] << endl; cerr << "Unknown option: " << argv[arg] << endl;
...@@ -257,7 +278,7 @@ main(int argc, char **argv) ...@@ -257,7 +278,7 @@ main(int argc, char **argv)
// Do the rest // Do the rest
main2(macro_output, basename, debug, clear_all, no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive, main2(macro_output, basename, debug, clear_all, no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive,
parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test, nostrict, output_mode, cuda parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test, nostrict, output_mode, language
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc , cygwin, msvc
#endif #endif
......
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
#include "ParsingDriver.hh" #include "ParsingDriver.hh"
#include "ModFile.hh" #include "ModFile.hh"
#include "ConfigFile.hh" #include "ConfigFile.hh"
#include "FileOutputType.hh" #include "ExtendedPreprocessorTypes.hh"
void void
main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive, main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive,
bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode, bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test, bool nostrict, FileOutputType output_mode, bool cuda bool parallel_test, bool nostrict, FileOutputType output_mode, LanguageOutputType lang
#if defined(_WIN32) || defined(__CYGWIN32__) #if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc , bool cygwin, bool msvc
#endif #endif
......
...@@ -17,15 +17,25 @@ ...@@ -17,15 +17,25 @@
* along with Dynare. If not, see <http://www.gnu.org/licenses/>. * along with Dynare. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _FILE_OUTPUT_TYPE_HH #ifndef _EXTENDED_PREPROCESSOR_TYPES_HH
#define _FILE_OUTPUT_TYPE_HH #define _EXTENDED_PREPROCESSOR_TYPES_HH
enum FileOutputType enum FileOutputType
{ {
none, // outputs files for Matlab/Octave processing none, // outputs files for Matlab/Octave processing
dynamic, // outputs <fname>_dynamic.cc and related files dynamic, // outputs <fname>_dynamic.* and related files
first, // outputs <fname>_first_derivatives and related files first, // outputs <fname>_first_derivatives.* and related files
second, // outputs <fname>_first_derivatives, <fname>_second_derivatives.cc and related files second, // outputs <fname>_first_derivatives.*, <fname>_second_derivatives.* and related files
third, // outputs <fname>_first_derivatives, <fname>_second_derivatives.cc, <fname>_third_derivatives.cc and related files third, // outputs <fname>_first_derivatives.*, <fname>_second_derivatives.*, <fname>_third_derivatives.* and related files
};
enum LanguageOutputType
{
matlab, // outputs files for Matlab/Octave processing
c, // outputs files for C
cpp, // outputs files for C++
cuda, // outputs files for CUDA (not yet implemented)
julia, // outputs files for Julia (not yet implemented)
python, // outputs files for Python (not yet implemented) (not yet implemented)
}; };
#endif #endif
...@@ -53,7 +53,7 @@ dynare_m_SOURCES = \ ...@@ -53,7 +53,7 @@ dynare_m_SOURCES = \
SteadyStateModel.cc \ SteadyStateModel.cc \
WarningConsolidation.hh \ WarningConsolidation.hh \
WarningConsolidation.cc \ WarningConsolidation.cc \
FileOutputType.hh ExtendedPreprocessorTypes.hh
# The -I. is for <FlexLexer.h> # The -I. is for <FlexLexer.h>
dynare_m_CPPFLAGS = $(BOOST_CPPFLAGS) -I. dynare_m_CPPFLAGS = $(BOOST_CPPFLAGS) -I.
......
...@@ -35,7 +35,7 @@ using namespace std; ...@@ -35,7 +35,7 @@ using namespace std;
#include "ExternalFunctionsTable.hh" #include "ExternalFunctionsTable.hh"
#include "ConfigFile.hh" #include "ConfigFile.hh"
#include "WarningConsolidation.hh" #include "WarningConsolidation.hh"
#include "FileOutputType.hh" #include "ExtendedPreprocessorTypes.hh"
//! The abstract representation of a "mod" file //! The abstract representation of a "mod" file
class ModFile class ModFile
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment