From 6e4a06e180f7500df13ceea362b71294b8da74ff Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Thu, 20 Oct 2016 15:04:00 +0100 Subject: [PATCH] qed-fvol: initial commit --- Makefile.am | 2 +- configure.ac | 2 ++ programs/Makefile.am | 1 + programs/qed-fvol/Global.cc | 11 +++++++++ programs/qed-fvol/Global.hpp | 42 +++++++++++++++++++++++++++++++++++ programs/qed-fvol/Makefile.am | 9 ++++++++ programs/qed-fvol/qed-fvol.cc | 36 ++++++++++++++++++++++++++++++ 7 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 programs/Makefile.am create mode 100644 programs/qed-fvol/Global.cc create mode 100644 programs/qed-fvol/Global.hpp create mode 100644 programs/qed-fvol/Makefile.am create mode 100644 programs/qed-fvol/qed-fvol.cc diff --git a/Makefile.am b/Makefile.am index 90c5cd71..8cc860a9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # additional include paths necessary to compile the C++ library -SUBDIRS = lib benchmarks tests +SUBDIRS = lib benchmarks tests programs AM_CXXFLAGS += -I$(top_builddir)/include ACLOCAL_AMFLAGS = -I m4 diff --git a/configure.ac b/configure.ac index 7bcdc49f..81ced467 100644 --- a/configure.ac +++ b/configure.ac @@ -326,6 +326,8 @@ AC_CONFIG_FILES(tests/hmc/Makefile) AC_CONFIG_FILES(tests/solver/Makefile) AC_CONFIG_FILES(tests/qdpxx/Makefile) AC_CONFIG_FILES(benchmarks/Makefile) +AC_CONFIG_FILES(programs/Makefile) +AC_CONFIG_FILES(programs/qed-fvol/Makefile) AC_OUTPUT echo " diff --git a/programs/Makefile.am b/programs/Makefile.am new file mode 100644 index 00000000..ff7f6584 --- /dev/null +++ b/programs/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = qed-fvol diff --git a/programs/qed-fvol/Global.cc b/programs/qed-fvol/Global.cc new file mode 100644 index 00000000..57ed97cc --- /dev/null +++ b/programs/qed-fvol/Global.cc @@ -0,0 +1,11 @@ +#include + +using namespace Grid; +using namespace QCD; +using namespace QedFVol; + +QedFVolLogger QedFVol::QedFVolLogError(1,"Error"); +QedFVolLogger QedFVol::QedFVolLogWarning(1,"Warning"); +QedFVolLogger QedFVol::QedFVolLogMessage(1,"Message"); +QedFVolLogger QedFVol::QedFVolLogIterative(1,"Iterative"); +QedFVolLogger QedFVol::QedFVolLogDebug(1,"Debug"); diff --git a/programs/qed-fvol/Global.hpp b/programs/qed-fvol/Global.hpp new file mode 100644 index 00000000..7f07200d --- /dev/null +++ b/programs/qed-fvol/Global.hpp @@ -0,0 +1,42 @@ +#ifndef QedFVol_Global_hpp_ +#define QedFVol_Global_hpp_ + +#include + +#define BEGIN_QEDFVOL_NAMESPACE \ +namespace Grid {\ +using namespace QCD;\ +namespace QedFVol {\ +using Grid::operator<<; +#define END_QEDFVOL_NAMESPACE }} + +/* the 'using Grid::operator<<;' statement prevents a very nasty compilation + * error with GCC (clang compiles fine without it). + */ + +BEGIN_QEDFVOL_NAMESPACE + +class QedFVolLogger: public Logger +{ +public: + QedFVolLogger(int on, std::string nm): Logger("QedFVol", on, nm, + GridLogColours, "BLACK"){}; +}; + +#define LOG(channel) std::cout << QedFVolLog##channel +#define QEDFVOL_ERROR(msg)\ +LOG(Error) << msg << " (" << __FUNCTION__ << " at " << __FILE__ << ":"\ + << __LINE__ << ")" << std::endl;\ +abort(); + +#define DEBUG_VAR(var) LOG(Debug) << #var << "= " << (var) << std::endl; + +extern QedFVolLogger QedFVolLogError; +extern QedFVolLogger QedFVolLogWarning; +extern QedFVolLogger QedFVolLogMessage; +extern QedFVolLogger QedFVolLogIterative; +extern QedFVolLogger QedFVolLogDebug; + +END_QEDFVOL_NAMESPACE + +#endif // QedFVol_Global_hpp_ diff --git a/programs/qed-fvol/Makefile.am b/programs/qed-fvol/Makefile.am new file mode 100644 index 00000000..cd762e94 --- /dev/null +++ b/programs/qed-fvol/Makefile.am @@ -0,0 +1,9 @@ +AM_CXXFLAGS += -I$(top_srcdir)/programs -I../$(top_srcdir)/programs + +bin_PROGRAMS = qed-fvol + +qed_fvol_SOURCES = \ + qed-fvol.cc \ + Global.cc + +qed_fvol_LDADD = -lGrid diff --git a/programs/qed-fvol/qed-fvol.cc b/programs/qed-fvol/qed-fvol.cc new file mode 100644 index 00000000..bb3204c6 --- /dev/null +++ b/programs/qed-fvol/qed-fvol.cc @@ -0,0 +1,36 @@ +#include + +using namespace Grid; +using namespace QCD; +using namespace QedFVol; + +int main(int argc, char *argv[]) +{ + // parse command line + std::string parameterFileName; + + if (argc < 2) + { + std::cerr << "usage: " << argv[0] << " [Grid options]"; + std::cerr << std::endl; + std::exit(EXIT_FAILURE); + } + parameterFileName = argv[1]; + + // initialization + Grid_init(&argc, &argv); + QedFVolLogError.Active(GridLogError.isActive()); + QedFVolLogWarning.Active(GridLogWarning.isActive()); + QedFVolLogMessage.Active(GridLogMessage.isActive()); + QedFVolLogIterative.Active(GridLogIterative.isActive()); + QedFVolLogDebug.Active(GridLogDebug.isActive()); + LOG(Message) << "Grid initialized" << std::endl; + + + + // epilogue + LOG(Message) << "Grid is finalizing now" << std::endl; + Grid_finalize(); + + return EXIT_SUCCESS; +}