1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-10 06:00:45 +01:00

Hadrons: modules moved in their own directory & utility script to add new modules

This commit is contained in:
Antonin Portelli 2016-05-10 20:12:48 +01:00
parent 29dfe99e7c
commit 84fa2bdce6
24 changed files with 131 additions and 37 deletions

View File

@ -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

View File

@ -0,0 +1,45 @@
#include <Hadrons/Modules/___FILEBASENAME___.hpp>
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<std::string> ___FILEBASENAME___::getInput(void)
{
std::vector<std::string> in;
return in;
}
std::vector<std::string> ___FILEBASENAME___::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
void ___FILEBASENAME___::setup(void)
{
}
// execution ///////////////////////////////////////////////////////////////////
void ___FILEBASENAME___::execute(void)
{
}

View File

@ -0,0 +1,43 @@
#ifndef Hadrons____FILEBASENAME____hpp_
#define Hadrons____FILEBASENAME____hpp_
#include <Hadrons/Global.hpp>
#include <Hadrons/Module.hpp>
#include <Hadrons/ModuleFactory.hpp>
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<std::string> getInput(void);
virtual std::vector<std::string> 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_

15
programs/Hadrons/add_module.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
if (( $# != 1 )); then
echo "usage: `basename $0` <module name>" 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

View File

@ -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

View File

@ -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

View File

@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution
directory.
*******************************************************************************/
#include <Hadrons/AWilson.hpp>
#include <Hadrons/Modules/AWilson.hpp>
using namespace Grid;
using namespace Hadrons;

View File

@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution
directory.
*******************************************************************************/
#include <Hadrons/CMeson.hpp>
#include <Hadrons/Modules/CMeson.hpp>
using namespace Grid;
using namespace QCD;

View File

@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution
directory.
*******************************************************************************/
#include <Hadrons/GLoad.hpp>
#include <Hadrons/Modules/GLoad.hpp>
using namespace Grid;
using namespace Hadrons;

View File

@ -25,13 +25,13 @@ See the full license in the file "LICENSE" in the top level distribution
directory.
*******************************************************************************/
#include <Hadrons/GRandom.hpp>
#include <Hadrons/Modules/GRandom.hpp>
using namespace Grid;
using namespace Hadrons;
/******************************************************************************
* GRandom implementation *
* GRandom implementation *
******************************************************************************/
// constructor /////////////////////////////////////////////////////////////////
GRandom::GRandom(const std::string name)

View File

@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution
directory.
*******************************************************************************/
#include <Hadrons/GUnit.hpp>
#include <Hadrons/Modules/GUnit.hpp>
using namespace Grid;
using namespace Hadrons;

View File

@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution
directory.
*******************************************************************************/
#include <Hadrons/MQuark.hpp>
#include <Hadrons/Modules/MQuark.hpp>
using namespace Grid;
using namespace QCD;

View File

@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution
directory.
*******************************************************************************/
#include <Hadrons/SolRBPrecCG.hpp>
#include <Hadrons/Modules/SolRBPrecCG.hpp>
using namespace Grid;
using namespace QCD;

View File

@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution
directory.
*******************************************************************************/
#include <Hadrons/SrcPoint.hpp>
#include <Hadrons/Modules/SrcPoint.hpp>
using namespace Grid;
using namespace Hadrons;

View File

@ -25,7 +25,7 @@ See the full license in the file "LICENSE" in the top level distribution
directory.
*******************************************************************************/
#include <Hadrons/SrcZ2.hpp>
#include <Hadrons/Modules/SrcZ2.hpp>
using namespace Grid;
using namespace Hadrons;