Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a simple module map #1063

Merged
merged 4 commits into from May 3, 2024
Merged

Added a simple module map #1063

merged 4 commits into from May 3, 2024

Conversation

Iximiel
Copy link
Member

@Iximiel Iximiel commented Apr 24, 2024

Description

@gtribello, @GiovanniBussi I have set up a simple module map
It can be used as PLMD::getModuleMap().at("actionName")1 to return the name of the module that includes that action (even if the module is not active in the current installation)

for 2.10 it is possible to add also an extra function that returns a std::optional with the module name to not doing the .count("actionname") before calling the at (that may throw), since std::optional is c++17

Since regex are scary I put a link to a site tha visualize the one used in the new maketool script
The new maketool script uses pure bash, I think there should not be problem between bash versions for the regex that I used, and I used pure bash to avoid having the user to install gawk or perl
I do not know if you like the requirements for the .inc file

Target release

I would like my code to appear in release 2.9

Type of contribution
  • changes to code or doc authored by PLUMED developers, or additions of code in the core or within the default modules
  • changes to a module not authored by you
  • new module contribution or edit of a module authored by you
Copyright
  • I agree to transfer the copyright of the code I have written to the PLUMED developers or to the author of the code I am modifying.
  • the module I added or modified contains a COPYRIGHT file with the correct license information. Code should be released under an open source license. I also used the command cd src && ./header.sh mymodulename in order to make sure the headers of the module are correct.
Tests
  • I added a new regtest or modified an existing regtest to validate my changes.
  • I verified that all regtests are passed successfully on GitHub Actions.

Footnotes

  1. operator[] has no const overloads for std::map and std::unordered_map

toPrint=' {"%s", "%s"}'
#regex are scary, here's a link with the flow of the regex
# https://regexper.com/#PLUMED_REGISTER_ACTION%5Cs*%5C%28%5Cs*%5B0-9a-zA-Z_%5D%2B%5Cs*%2C%5Cs*%22%28%5B0-9a-zA-Z_%5D%2B%29%22%5Cs*%5C%29
regex='PLUMED_REGISTER_ACTION\s*\(\s*[0-9a-zA-Z_]+\s*,\s*"([0-9a-zA-Z_]+)"\s*\)'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the mac CI seems to ignore the action regitered like these:

PLUMED_REGISTER_ACTION(Dimer, "DIMER")
PLUMED_REGISTER_ACTION(DynamicReferenceRestraining, "DRR")
PLUMED_REGISTER_ACTION(EDS, "EDS")
PLUMED_REGISTER_ACTION(FuncPathGeneral, "FUNCPATHGENERAL")
PLUMED_REGISTER_ACTION(JCoupling, "JCOUPLING")
PLUMED_REGISTER_ACTION(Loss, "MAZE_LOSS")
PLUMED_REGISTER_ACTION(Memetic, "MAZE_MEMETIC_SAMPLING")
PLUMED_REGISTER_ACTION(OptimizerBias, "MAZE_OPTIMIZER_BIAS")
PLUMED_REGISTER_ACTION(Random_Acceleration_MD, "MAZE_RANDOM_ACCELERATION_MD")
PLUMED_REGISTER_ACTION(Random_Walk, "MAZE_RANDOM_WALK")
PLUMED_REGISTER_ACTION(Simulated_Annealing, "MAZE_SIMULATED_ANNEALING")
PLUMED_REGISTER_ACTION(Steered_MD, "MAZE_STEERED_MD")
PLUMED_REGISTER_ACTION(fusionPoreExpansionP, "FUSIONPOREEXPANSIONP")
PLUMED_REGISTER_ACTION(fusionPoreNucleationP, "FUSIONPORENUCLEATIONP")
PLUMED_REGISTER_ACTION(memFusionP, "MEMFUSIONP")

with only a space after the ","

@GiovanniBussi
Copy link
Member

I guess the script is not portable to different (non gnu) core utils

@Iximiel
Copy link
Member Author

Iximiel commented Apr 29, 2024

I changed the regex to something more restrictive, now accepts only standard whitespaces instead of \s that is "any kind of space" and it works.
I still do not understand why ,\s* does not work but , * yes, since \s do not cause problem in any other place... But I guess that the important things is that it works

@GiovanniBussi GiovanniBussi merged commit 4775bcd into plumed:v2.9 May 3, 2024
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants