mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 14:04:32 +00:00 
			
		
		
		
	Hadrons: contractor token @traj@ for trajectory number in input file
This commit is contained in:
		@@ -249,6 +249,20 @@ void        makeFileDir(const std::string filename, GridBase *g = nullptr);
 | 
				
			|||||||
// pretty print time profile
 | 
					// pretty print time profile
 | 
				
			||||||
void printTimeProfile(const std::map<std::string, GridTime> &timing, GridTime total);
 | 
					void printTimeProfile(const std::map<std::string, GridTime> &timing, GridTime total);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// token replacement utility
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					void tokenReplace(std::string &str, const std::string token,
 | 
				
			||||||
 | 
					                  const T &x, const std::string mark = "@")
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    std::string fullToken = mark + token + mark;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    auto pos = str.find(fullToken);
 | 
				
			||||||
 | 
					    if (pos != std::string::npos)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        str.replace(pos, fullToken.size(), std::to_string(x));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
END_HADRONS_NAMESPACE
 | 
					END_HADRONS_NAMESPACE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <Hadrons/Exceptions.hpp>
 | 
					#include <Hadrons/Exceptions.hpp>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,7 +60,7 @@ namespace Contractor
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        GRID_SERIALIZABLE_CLASS_MEMBERS(A2AMatrixPar,
 | 
					        GRID_SERIALIZABLE_CLASS_MEMBERS(A2AMatrixPar,
 | 
				
			||||||
                                        std::string, fileStem,
 | 
					                                        std::string, file,
 | 
				
			||||||
                                        std::string, dataset,
 | 
					                                        std::string, dataset,
 | 
				
			||||||
                                        unsigned int, cacheSize,
 | 
					                                        unsigned int, cacheSize,
 | 
				
			||||||
                                        std::string, name);
 | 
					                                        std::string, name);
 | 
				
			||||||
@@ -279,9 +279,10 @@ int main(int argc, char* argv[])
 | 
				
			|||||||
        // load data
 | 
					        // load data
 | 
				
			||||||
        for (auto &p: par.a2aMatrix)
 | 
					        for (auto &p: par.a2aMatrix)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            std::string filename = RESULT_FILE_NAME(p.fileStem, traj);
 | 
					            std::string filename = p.file;
 | 
				
			||||||
            double      t, size;
 | 
					            double      t, size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            tokenReplace(filename, "traj", traj);
 | 
				
			||||||
            std::cout << "======== Loading '" << filename << "'" << std::endl;
 | 
					            std::cout << "======== Loading '" << filename << "'" << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            A2AMatrixIo<HADRONS_A2AM_IO_TYPE> a2aIo(filename, p.dataset, par.global.nt);
 | 
					            A2AMatrixIo<HADRONS_A2AM_IO_TYPE> a2aIo(filename, p.dataset, par.global.nt);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user