mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Added the ability to write a version of the validated XML file excluding any of the module IDs supplied in a separate exclude file
This commit is contained in:
parent
e7050a7aed
commit
f5ad4f3de8
@ -180,7 +180,7 @@ void Application::parseParameterFile(const std::string parameterFileName)
|
|||||||
pop(reader);
|
pop(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::saveParameterFile(const std::string parameterFileName, unsigned int prec)
|
void Application::saveParameterFile(const std::string ¶meterFileName, const std::vector<std::string> &Except, unsigned int prec)
|
||||||
{
|
{
|
||||||
LOG(Message) << "Saving application to '" << parameterFileName << "'..." << std::endl;
|
LOG(Message) << "Saving application to '" << parameterFileName << "'..." << std::endl;
|
||||||
if (env().getGrid()->IsBoss())
|
if (env().getGrid()->IsBoss())
|
||||||
@ -194,18 +194,27 @@ void Application::saveParameterFile(const std::string parameterFileName, unsigne
|
|||||||
push(writer, "modules");
|
push(writer, "modules");
|
||||||
for (unsigned int i = 0; i < nMod; ++i)
|
for (unsigned int i = 0; i < nMod; ++i)
|
||||||
{
|
{
|
||||||
push(writer, "module");
|
|
||||||
id.name = vm().getModuleName(i);
|
id.name = vm().getModuleName(i);
|
||||||
|
if( std::find( Except.begin(), Except.end(), id.name ) == Except.end() )
|
||||||
|
{
|
||||||
|
push(writer, "module");
|
||||||
id.type = vm().getModule(i)->getRegisteredName();
|
id.type = vm().getModule(i)->getRegisteredName();
|
||||||
write(writer, "id", id);
|
write(writer, "id", id);
|
||||||
vm().getModule(i)->saveParameters(writer, "options");
|
vm().getModule(i)->saveParameters(writer, "options");
|
||||||
pop(writer);
|
pop(writer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pop(writer);
|
pop(writer);
|
||||||
pop(writer);
|
pop(writer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::saveParameterFile(const std::string ¶meterFileName, unsigned int prec)
|
||||||
|
{
|
||||||
|
const std::vector<std::string> Except;
|
||||||
|
saveParameterFile(parameterFileName, Except, prec);
|
||||||
|
}
|
||||||
|
|
||||||
// schedule computation ////////////////////////////////////////////////////////
|
// schedule computation ////////////////////////////////////////////////////////
|
||||||
void Application::schedule(void)
|
void Application::schedule(void)
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,8 @@ public:
|
|||||||
void run(void);
|
void run(void);
|
||||||
// XML parameter file I/O
|
// XML parameter file I/O
|
||||||
void parseParameterFile(const std::string parameterFileName);
|
void parseParameterFile(const std::string parameterFileName);
|
||||||
void saveParameterFile(const std::string parameterFileName, unsigned int prec=15);
|
void saveParameterFile(const std::string ¶meterFileName, unsigned int prec=15);
|
||||||
|
void saveParameterFile(const std::string ¶meterFileName, const std::vector<std::string> &Except, unsigned int prec=15);
|
||||||
// schedule computation
|
// schedule computation
|
||||||
void schedule(void);
|
void schedule(void);
|
||||||
void saveSchedule(const std::string filename);
|
void saveSchedule(const std::string filename);
|
||||||
|
@ -27,24 +27,52 @@ See the full license in the file "LICENSE" in the top level distribution directo
|
|||||||
/* END LEGAL */
|
/* END LEGAL */
|
||||||
|
|
||||||
#include <Hadrons/Application.hpp>
|
#include <Hadrons/Application.hpp>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
using namespace QCD;
|
using namespace QCD;
|
||||||
using namespace Hadrons;
|
using namespace Hadrons;
|
||||||
|
|
||||||
|
// Does the specified file exist?
|
||||||
|
bool FileExists(const std::string& Filename)
|
||||||
|
{
|
||||||
|
struct stat buf;
|
||||||
|
return stat(Filename.c_str(), &buf) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Shorten( Application &app, const std::string &FileList, const std::string OutFileName )
|
||||||
|
{
|
||||||
|
std::vector<std::string> Except;
|
||||||
|
std::ifstream list{ FileList };
|
||||||
|
for( std::string s; std::getline(list, s); ) {
|
||||||
|
//const std::string::size_type l{ s.find_first_of( '.' ) };
|
||||||
|
//if( l != std::string::npos )
|
||||||
|
//s.resize( l );
|
||||||
|
if( s.length() )
|
||||||
|
Except.push_back( s );
|
||||||
|
}
|
||||||
|
std::sort( Except.begin(), Except.end() );
|
||||||
|
for( const std::string &s : Except )
|
||||||
|
std::cout << s << std::endl;
|
||||||
|
app.saveParameterFile( OutFileName, Except );
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// parse command line
|
// parse command line
|
||||||
std::string parameterFileName;
|
std::string parameterFileName;
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2 && argc != 4)
|
||||||
{
|
{
|
||||||
std::cerr << "usage: " << argv[0] << " <parameter file>";
|
std::cerr << "usage: " << argv[0] << " <parameter file> [filelist.txt output.xml]";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::exit(EXIT_FAILURE);
|
std::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
parameterFileName = argv[1];
|
parameterFileName = argv[1];
|
||||||
|
if( argc == 4 )
|
||||||
|
Grid_init(&argc, &argv);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Application application(parameterFileName);
|
Application application(parameterFileName);
|
||||||
@ -54,11 +82,22 @@ int main(int argc, char *argv[])
|
|||||||
vm.getModuleGraph();
|
vm.getModuleGraph();
|
||||||
LOG(Message) << "Application valid (check XML warnings though)"
|
LOG(Message) << "Application valid (check XML warnings though)"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
if( argc == 4 ) {
|
||||||
|
const std::string FileList{ argv[3] };
|
||||||
|
const std::string OutFileName{ argv[2] };
|
||||||
|
if( !FileExists( FileList ) )
|
||||||
|
std::cout << "File list \"" << FileList << "\" does not exist" << std::endl;
|
||||||
|
else {
|
||||||
|
Shorten( application, FileList, OutFileName );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
Exceptions::abort(e);
|
Exceptions::abort(e);
|
||||||
}
|
}
|
||||||
|
if( argc == 4 )
|
||||||
|
Grid_finalize();
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user