From 2fdf250c58b367d4914f11b48c4aa9f3a70c061f Mon Sep 17 00:00:00 2001 From: Gareth Aneurin Tribello Date: Wed, 22 May 2024 13:13:40 +0100 Subject: [PATCH] Fixed final problems with building nest inputs and ran astyle --- src/cltools/Driver.cpp | 22 +++++++++++----------- src/core/ActionWithValue.cpp | 1 - src/core/PlumedMain.cpp | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/cltools/Driver.cpp b/src/cltools/Driver.cpp index 95c0b3916a..4a841d9f5f 100644 --- a/src/cltools/Driver.cpp +++ b/src/cltools/Driver.cpp @@ -787,16 +787,16 @@ int Driver::main(FILE* in,FILE*out,Communicator& pc) { } ActionWithValue* av=dynamic_cast(pp.get()); if( av && av->getNumberOfComponents()>0 ) { - Keywords keys; p.getKeywordsForAction( av->getName(), keys ); + Keywords keys; p.getKeywordsForAction( av->getName(), keys ); if( firsta ) { valuefile.printf(" \"%s\" : {\n \"action\" : \"%s\"", av->getLabel().c_str(), keys.getDisplayName().c_str() ); firsta=false; } else valuefile.printf(",\n \"%s\" : {\n \"action\" : \"%s\"", av->getLabel().c_str(), keys.getDisplayName().c_str() ); for(unsigned i=0; igetNumberOfComponents(); ++i) { - Value* myval = av->copyOutput(i); std::string compname = myval->getName(), description; + Value* myval = av->copyOutput(i); std::string compname = myval->getName(), description; if( av->getLabel()==compname ) { - description = keys.getOutputComponentDescription(".#!value"); + description = keys.getOutputComponentDescription(".#!value"); } else { - std::size_t dot=compname.find(av->getLabel() + "."); std::string cname = compname.substr(dot + av->getLabel().length() + 1); - description = av->getOutputComponentDescription( cname, keys ); + std::size_t dot=compname.find(av->getLabel() + "."); std::string cname = compname.substr(dot + av->getLabel().length() + 1); + description = av->getOutputComponentDescription( cname, keys ); } if( description.find("\\")!=std::string::npos ) error("found invalid backslash character in documentation for component " + compname + " in action " + av->getName() + " with label " + av->getLabel() ); valuefile.printf(",\n \"%s\" : { \"type\": \"%s\", \"description\": \"%s\" }", myval->getName().c_str(), myval->getValueType().c_str(), description.c_str() ); @@ -810,7 +810,7 @@ int Driver::main(FILE* in,FILE*out,Communicator& pc) { if( firsta ) { valuefile.printf(" \"shortcut_%s\" : {\n \"action\" : \"%s\"", as->getShortcutLabel().c_str(), as->getName().c_str() ); firsta=false; } else valuefile.printf(",\n \"shortcut_%s\" : {\n \"action\" : \"%s\"", as->getShortcutLabel().c_str(), as->getName().c_str() ); - Keywords keys; p.getKeywordsForAction( as->getName(), keys ); + Keywords keys; p.getKeywordsForAction( as->getName(), keys ); for(unsigned i=0; i( cnames[i] ); if( !av2 ) plumed_merror("could not find value created by shortcut with name " + cnames[i] ); @@ -822,13 +822,13 @@ int Driver::main(FILE* in,FILE*out,Communicator& pc) { valuefile.printf(",\n \"%s\" : { \"type\": \"%s\", \"description\": \"%s\" }", myval->getName().c_str(), myval->getValueType().c_str(), description.c_str() ); } else { for(unsigned j=0; jgetNumberOfComponents(); ++j) { - Value* myval = av2->copyOutput(j); std::string compname = myval->getName(), description; + Value* myval = av2->copyOutput(j); std::string compname = myval->getName(), description; if( av2->getLabel()==compname ) { - plumed_merror("should not be outputting description of value from action when using shortcuts"); + plumed_merror("should not be outputting description of value from action when using shortcuts"); } else { - std::size_t dot=compname.find(av2->getLabel() + "."); std::string cname = compname.substr(dot+av2->getLabel().length() + 1); - description = av2->getOutputComponentDescription( cname, keys ); - } + std::size_t dot=compname.find(av2->getLabel() + "."); std::string cname = compname.substr(dot+av2->getLabel().length() + 1); + description = av2->getOutputComponentDescription( cname, keys ); + } if( description.find("\\")!=std::string::npos ) error("found invalid backslash character in documentation for component " + compname + " in action " + av2->getName() + " with label " + av2->getLabel() ); valuefile.printf(",\n \"%s\" : { \"type\": \"%s\", \"description\": \"%s\" }", myval->getName().c_str(), myval->getValueType().c_str(), description.c_str() ); } diff --git a/src/core/ActionWithValue.cpp b/src/core/ActionWithValue.cpp index 44acb624b3..b708db9c61 100644 --- a/src/core/ActionWithValue.cpp +++ b/src/core/ActionWithValue.cpp @@ -170,7 +170,6 @@ void ActionWithValue::addComponentWithDerivatives( const std::string& name, cons std::string ActionWithValue::getOutputComponentDescription( const std::string& cname, const Keywords& keys ) const { std::size_t und=cname.find_last_of("_"); std::size_t hyph=cname.find_first_of("-"); - if( und!=std::string::npos && hyph!=std::string::npos ) plumed_merror("cannot use underscore and hyphen in name"); if( und!=std::string::npos ) return keys.getOutputComponentDescription(cname.substr(und)) + " This particular component measures this quantity for the input CV named " + cname.substr(0,und); if( hyph!=std::string::npos ) return keys.getOutputComponentDescription(cname.substr(0,hyph)) + " This is the " + cname.substr(hyph+1) + "th of these quantities"; plumed_massert( keys.outputComponentExists(cname), "component " + cname + " does not exist in " + keys.getDisplayName() + " if the component names are customizable then you should override this function" ); diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp index b2efac09cb..cdeba0472f 100644 --- a/src/core/PlumedMain.cpp +++ b/src/core/PlumedMain.cpp @@ -1489,7 +1489,7 @@ bool PlumedMain::parseOnlyMode() const { } void PlumedMain::getKeywordsForAction( const std::string& action, Keywords& keys ) const { - actionRegister().getKeywords( dlloader.getHandles(), action, keys ); + actionRegister().getKeywords( dlloader.getHandles(), action, keys ); } #ifdef __PLUMED_HAS_PYTHON