From 84fa2bdce6a8d4b27bb02371eebd51be759dc363 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 10 May 2016 20:12:48 +0100 Subject: [PATCH] Hadrons: modules moved in their own directory & utility script to add new modules --- programs/Hadrons/Makefile.am | 31 ++----------- programs/Hadrons/Module.cc.template | 45 +++++++++++++++++++ programs/Hadrons/Module.hpp.template | 43 ++++++++++++++++++ programs/Hadrons/add_module.sh | 15 +++++++ programs/Hadrons/make_module_list.sh | 4 ++ programs/Hadrons/modules.inc | 10 +++++ programs/Hadrons/{ => modules}/AWilson.cc | 2 +- programs/Hadrons/{ => modules}/AWilson.hpp | 0 programs/Hadrons/{ => modules}/CMeson.cc | 2 +- programs/Hadrons/{ => modules}/CMeson.hpp | 0 programs/Hadrons/{ => modules}/GLoad.cc | 2 +- programs/Hadrons/{ => modules}/GLoad.hpp | 0 programs/Hadrons/{ => modules}/GRandom.cc | 4 +- programs/Hadrons/{ => modules}/GRandom.hpp | 0 programs/Hadrons/{ => modules}/GUnit.cc | 2 +- programs/Hadrons/{ => modules}/GUnit.hpp | 0 programs/Hadrons/{ => modules}/MQuark.cc | 2 +- programs/Hadrons/{ => modules}/MQuark.hpp | 0 programs/Hadrons/{ => modules}/SolRBPrecCG.cc | 2 +- .../Hadrons/{ => modules}/SolRBPrecCG.hpp | 0 programs/Hadrons/{ => modules}/SrcPoint.cc | 2 +- programs/Hadrons/{ => modules}/SrcPoint.hpp | 0 programs/Hadrons/{ => modules}/SrcZ2.cc | 2 +- programs/Hadrons/{ => modules}/SrcZ2.hpp | 0 24 files changed, 131 insertions(+), 37 deletions(-) create mode 100644 programs/Hadrons/Module.cc.template create mode 100644 programs/Hadrons/Module.hpp.template create mode 100755 programs/Hadrons/add_module.sh create mode 100755 programs/Hadrons/make_module_list.sh create mode 100644 programs/Hadrons/modules.inc rename programs/Hadrons/{ => modules}/AWilson.cc (98%) rename programs/Hadrons/{ => modules}/AWilson.hpp (100%) rename programs/Hadrons/{ => modules}/CMeson.cc (98%) rename programs/Hadrons/{ => modules}/CMeson.hpp (100%) rename programs/Hadrons/{ => modules}/GLoad.cc (98%) rename programs/Hadrons/{ => modules}/GLoad.hpp (100%) rename programs/Hadrons/{ => modules}/GRandom.cc (94%) rename programs/Hadrons/{ => modules}/GRandom.hpp (100%) rename programs/Hadrons/{ => modules}/GUnit.cc (98%) rename programs/Hadrons/{ => modules}/GUnit.hpp (100%) rename programs/Hadrons/{ => modules}/MQuark.cc (99%) rename programs/Hadrons/{ => modules}/MQuark.hpp (100%) rename programs/Hadrons/{ => modules}/SolRBPrecCG.cc (98%) rename programs/Hadrons/{ => modules}/SolRBPrecCG.hpp (100%) rename programs/Hadrons/{ => modules}/SrcPoint.cc (98%) rename programs/Hadrons/{ => modules}/SrcPoint.hpp (100%) rename programs/Hadrons/{ => modules}/SrcZ2.cc (98%) rename programs/Hadrons/{ => modules}/SrcZ2.hpp (100%) diff --git a/programs/Hadrons/Makefile.am b/programs/Hadrons/Makefile.am index 2d1b5980..19bc9515 100644 --- a/programs/Hadrons/Makefile.am +++ b/programs/Hadrons/Makefile.am @@ -1,4 +1,4 @@ -AM_CXXFLAGS = -I$(top_srcdir)/programs -I$(top_srcdir)/lib +AM_CXXFLAGS = -I$(top_srcdir)/programs -I../$(top_srcdir)/programs -I$(top_srcdir)/lib AM_LDFLAGS = -L$(top_builddir)/lib bin_PROGRAMS = Hadrons @@ -11,31 +11,8 @@ Hadrons_SOURCES = \ Hadrons.cc \ Module.cc -# general modules -Hadrons_SOURCES += \ - MQuark.cc - -# fermion actions -Hadrons_SOURCES += \ - AWilson.cc - -# contraction modules -Hadrons_SOURCES += \ - CMeson.cc - -# gauge modules -Hadrons_SOURCES += \ - GLoad.cc \ - GRandom.cc \ - GUnit.cc - -# solver modules -Hadrons_SOURCES += \ - SolRBPrecCG.cc - -# source modules -Hadrons_SOURCES += \ - SrcPoint.cc \ - SrcZ2.cc +# modules +include modules.inc +Hadrons_SOURCES += $(modules) Hadrons_LDADD = -lGrid diff --git a/programs/Hadrons/Module.cc.template b/programs/Hadrons/Module.cc.template new file mode 100644 index 00000000..f2533d80 --- /dev/null +++ b/programs/Hadrons/Module.cc.template @@ -0,0 +1,45 @@ +#include + +using namespace Grid; +using namespace Hadrons; + +/****************************************************************************** +* ___FILEBASENAME___ implementation * +******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +___FILEBASENAME___::___FILEBASENAME___(const std::string name) +: Module(name) +{} + +// parse parameters //////////////////////////////////////////////////////////// +void ___FILEBASENAME___::parseParameters(XmlReader &reader, const std::string name) +{ + read(reader, name, par_); +} + +// dependencies/products /////////////////////////////////////////////////////// +std::vector ___FILEBASENAME___::getInput(void) +{ + std::vector in; + + return in; +} + +std::vector ___FILEBASENAME___::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +void ___FILEBASENAME___::setup(void) +{ + +} + +// execution /////////////////////////////////////////////////////////////////// +void ___FILEBASENAME___::execute(void) +{ + +} diff --git a/programs/Hadrons/Module.hpp.template b/programs/Hadrons/Module.hpp.template new file mode 100644 index 00000000..002d93b9 --- /dev/null +++ b/programs/Hadrons/Module.hpp.template @@ -0,0 +1,43 @@ +#ifndef Hadrons____FILEBASENAME____hpp_ +#define Hadrons____FILEBASENAME____hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * ___FILEBASENAME___ * + ******************************************************************************/ +class ___FILEBASENAME___: public Module +{ +public: + class Par: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(Par, unsigned int, i); + }; +public: + // constructor + ___FILEBASENAME___(const std::string name); + // destructor + virtual ~___FILEBASENAME___(void) = default; + // parse parameters + virtual void parseParameters(XmlReader &reader, const std::string name); + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +private: + Par par_; +}; + +MODULE_REGISTER(___FILEBASENAME___); + +END_HADRONS_NAMESPACE + +#endif // Hadrons____FILEBASENAME____hpp_ diff --git a/programs/Hadrons/add_module.sh b/programs/Hadrons/add_module.sh new file mode 100755 index 00000000..e412e0e7 --- /dev/null +++ b/programs/Hadrons/add_module.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +if (( $# != 1 )); then + echo "usage: `basename $0` " 1>&2 + exit 1 +fi +NAME=$1 + +if [ -e "Modules/${NAME}.cc" ] || [ -e "Modules/${NAME}.hpp" ]; then + echo "error: files Modules/${NAME}.* already exists" 1>&2 + exit 1 +fi +sed "s/___FILEBASENAME___/${NAME}/g" Module.cc.template > Modules/${NAME}.cc +sed "s/___FILEBASENAME___/${NAME}/g" Module.hpp.template > Modules/${NAME}.hpp +./make_module_list.sh diff --git a/programs/Hadrons/make_module_list.sh b/programs/Hadrons/make_module_list.sh new file mode 100755 index 00000000..78ed8040 --- /dev/null +++ b/programs/Hadrons/make_module_list.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +echo 'modules =\' > modules.inc +find Modules -name '*.cc' -type f -print | sed 's/^/ /;$q;s/$/ \\/' >> modules.inc \ No newline at end of file diff --git a/programs/Hadrons/modules.inc b/programs/Hadrons/modules.inc new file mode 100644 index 00000000..c0da727a --- /dev/null +++ b/programs/Hadrons/modules.inc @@ -0,0 +1,10 @@ +modules =\ + Modules/AWilson.cc \ + Modules/CMeson.cc \ + Modules/GLoad.cc \ + Modules/GRandom.cc \ + Modules/GUnit.cc \ + Modules/MQuark.cc \ + Modules/SolRBPrecCG.cc \ + Modules/SrcPoint.cc \ + Modules/SrcZ2.cc diff --git a/programs/Hadrons/AWilson.cc b/programs/Hadrons/modules/AWilson.cc similarity index 98% rename from programs/Hadrons/AWilson.cc rename to programs/Hadrons/modules/AWilson.cc index 5a75a257..77f9cc25 100644 --- a/programs/Hadrons/AWilson.cc +++ b/programs/Hadrons/modules/AWilson.cc @@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; diff --git a/programs/Hadrons/AWilson.hpp b/programs/Hadrons/modules/AWilson.hpp similarity index 100% rename from programs/Hadrons/AWilson.hpp rename to programs/Hadrons/modules/AWilson.hpp diff --git a/programs/Hadrons/CMeson.cc b/programs/Hadrons/modules/CMeson.cc similarity index 98% rename from programs/Hadrons/CMeson.cc rename to programs/Hadrons/modules/CMeson.cc index 6cd627bd..28b2dd81 100644 --- a/programs/Hadrons/CMeson.cc +++ b/programs/Hadrons/modules/CMeson.cc @@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace QCD; diff --git a/programs/Hadrons/CMeson.hpp b/programs/Hadrons/modules/CMeson.hpp similarity index 100% rename from programs/Hadrons/CMeson.hpp rename to programs/Hadrons/modules/CMeson.hpp diff --git a/programs/Hadrons/GLoad.cc b/programs/Hadrons/modules/GLoad.cc similarity index 98% rename from programs/Hadrons/GLoad.cc rename to programs/Hadrons/modules/GLoad.cc index cff9f3ed..8f1b4d95 100644 --- a/programs/Hadrons/GLoad.cc +++ b/programs/Hadrons/modules/GLoad.cc @@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; diff --git a/programs/Hadrons/GLoad.hpp b/programs/Hadrons/modules/GLoad.hpp similarity index 100% rename from programs/Hadrons/GLoad.hpp rename to programs/Hadrons/modules/GLoad.hpp diff --git a/programs/Hadrons/GRandom.cc b/programs/Hadrons/modules/GRandom.cc similarity index 94% rename from programs/Hadrons/GRandom.cc rename to programs/Hadrons/modules/GRandom.cc index 7f81624c..34b1d57e 100644 --- a/programs/Hadrons/GRandom.cc +++ b/programs/Hadrons/modules/GRandom.cc @@ -25,13 +25,13 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; /****************************************************************************** -* GRandom implementation * +* GRandom implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// GRandom::GRandom(const std::string name) diff --git a/programs/Hadrons/GRandom.hpp b/programs/Hadrons/modules/GRandom.hpp similarity index 100% rename from programs/Hadrons/GRandom.hpp rename to programs/Hadrons/modules/GRandom.hpp diff --git a/programs/Hadrons/GUnit.cc b/programs/Hadrons/modules/GUnit.cc similarity index 98% rename from programs/Hadrons/GUnit.cc rename to programs/Hadrons/modules/GUnit.cc index 75bdc597..d61f5551 100644 --- a/programs/Hadrons/GUnit.cc +++ b/programs/Hadrons/modules/GUnit.cc @@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; diff --git a/programs/Hadrons/GUnit.hpp b/programs/Hadrons/modules/GUnit.hpp similarity index 100% rename from programs/Hadrons/GUnit.hpp rename to programs/Hadrons/modules/GUnit.hpp diff --git a/programs/Hadrons/MQuark.cc b/programs/Hadrons/modules/MQuark.cc similarity index 99% rename from programs/Hadrons/MQuark.cc rename to programs/Hadrons/modules/MQuark.cc index c6af53f4..ffb91791 100644 --- a/programs/Hadrons/MQuark.cc +++ b/programs/Hadrons/modules/MQuark.cc @@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace QCD; diff --git a/programs/Hadrons/MQuark.hpp b/programs/Hadrons/modules/MQuark.hpp similarity index 100% rename from programs/Hadrons/MQuark.hpp rename to programs/Hadrons/modules/MQuark.hpp diff --git a/programs/Hadrons/SolRBPrecCG.cc b/programs/Hadrons/modules/SolRBPrecCG.cc similarity index 98% rename from programs/Hadrons/SolRBPrecCG.cc rename to programs/Hadrons/modules/SolRBPrecCG.cc index fc1d00aa..3db4a4d1 100644 --- a/programs/Hadrons/SolRBPrecCG.cc +++ b/programs/Hadrons/modules/SolRBPrecCG.cc @@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace QCD; diff --git a/programs/Hadrons/SolRBPrecCG.hpp b/programs/Hadrons/modules/SolRBPrecCG.hpp similarity index 100% rename from programs/Hadrons/SolRBPrecCG.hpp rename to programs/Hadrons/modules/SolRBPrecCG.hpp diff --git a/programs/Hadrons/SrcPoint.cc b/programs/Hadrons/modules/SrcPoint.cc similarity index 98% rename from programs/Hadrons/SrcPoint.cc rename to programs/Hadrons/modules/SrcPoint.cc index 559e56d3..b668f7bb 100644 --- a/programs/Hadrons/SrcPoint.cc +++ b/programs/Hadrons/modules/SrcPoint.cc @@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; diff --git a/programs/Hadrons/SrcPoint.hpp b/programs/Hadrons/modules/SrcPoint.hpp similarity index 100% rename from programs/Hadrons/SrcPoint.hpp rename to programs/Hadrons/modules/SrcPoint.hpp diff --git a/programs/Hadrons/SrcZ2.cc b/programs/Hadrons/modules/SrcZ2.cc similarity index 98% rename from programs/Hadrons/SrcZ2.cc rename to programs/Hadrons/modules/SrcZ2.cc index 0ed6227d..2c9bb403 100644 --- a/programs/Hadrons/SrcZ2.cc +++ b/programs/Hadrons/modules/SrcZ2.cc @@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; diff --git a/programs/Hadrons/SrcZ2.hpp b/programs/Hadrons/modules/SrcZ2.hpp similarity index 100% rename from programs/Hadrons/SrcZ2.hpp rename to programs/Hadrons/modules/SrcZ2.hpp