From 1f7a9acb97a14ee08a837a1b004781f6409895d8 Mon Sep 17 00:00:00 2001
From: Gareth Tribello <gareth.tribello@gmail.com>
Date: Sat, 7 Dec 2013 00:38:43 +0000
Subject: [PATCH] Added info option in patching script

This allows one to create information on the differences in
the various patching procedures by executing:

plumed patch -i

This information is also put into the online manual

(cherry picked from commit a273bb84d5e9e9b953eace77a2d149b0e8a13add)
---
 patches/gromacs-4.5.5.config   | 7 +++++++
 patches/gromacs-4.6.3.config   | 8 ++++++++
 patches/lammps-6Apr13.config   | 6 ++++++
 patches/namd-2.8.config        | 6 ++++++
 patches/patch.sh               | 6 ++++++
 patches/qespresso-5.0.2.config | 6 ++++++
 user-doc/extract               | 8 +++++++-
 7 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/patches/gromacs-4.5.5.config b/patches/gromacs-4.5.5.config
index c4c96cc70..aee30f437 100644
--- a/patches/gromacs-4.5.5.config
+++ b/patches/gromacs-4.5.5.config
@@ -18,3 +18,10 @@ function plumed_after_revert(){
   mv src/kernel/Makefile.plumedbck src/kernel/Makefile
 }
 
+function plumed_patch_info(){
+  echo ""
+  echo "PLUMED can be incorperated into gromacs using a simple patching procedure."
+  echo "Patching must be done after gromacs has been configured."
+  echo 
+  echo "For more information on gromacs you should visit http://www.gromacs.org"
+}
diff --git a/patches/gromacs-4.6.3.config b/patches/gromacs-4.6.3.config
index a5d00fcea..844164555 100644
--- a/patches/gromacs-4.6.3.config
+++ b/patches/gromacs-4.6.3.config
@@ -4,3 +4,11 @@ function plumed_preliminary_test(){
 # check if the README contains the word GROMACS and if gromacs has been already configured
   grep -q GROMACS README 1>/dev/null 2>/dev/null
 }
+
+function plumed_patch_info(){
+  echo ""
+  echo "PLUMED can be incorperated into gromacs using a simple patching procedure."
+  echo "Patching must be done after gromacs has been configured."
+  echo
+  echo "For more information on gromacs you should visit http://www.gromacs.org"
+}
diff --git a/patches/lammps-6Apr13.config b/patches/lammps-6Apr13.config
index 7aa1e453a..d7a729858 100644
--- a/patches/lammps-6Apr13.config
+++ b/patches/lammps-6Apr13.config
@@ -14,3 +14,9 @@ function plumed_after_revert(){
   rm -fr src/USER-PLUMED/
 }
 
+function plumed_patch_info(){
+  echo ""
+  echo "PLUMED can be incorperated into LAMMPS using a simple patching procedure."
+  echo 
+  echo "For more information on LAMMPS you should visit http://lammps.sandia.gov/"
+}
diff --git a/patches/namd-2.8.config b/patches/namd-2.8.config
index 3eff738a2..3bef46c3c 100644
--- a/patches/namd-2.8.config
+++ b/patches/namd-2.8.config
@@ -4,3 +4,9 @@ function plumed_preliminary_test(){
 # check if the README.txt contains the word NAMD
   grep -q NAMD README.txt 1>/dev/null 2>/dev/null && test -f */Make.config
 }
+
+function plumed_patch_info(){
+  echo ""
+  echo ""
+  echo "For more information on NAMD you should visit http://www.ks.uiuc.edu/Research/namd/"
+}
diff --git a/patches/patch.sh b/patches/patch.sh
index 082026b24..60437c10b 100755
--- a/patches/patch.sh
+++ b/patches/patch.sh
@@ -15,6 +15,8 @@ Actions (choose one):
                     save, this needs *.preplumed files (*)
   -n NEWENGINE, --new NEWENGINE
                     create a new patch named NEWENGINE (*)
+  -i, --info
+                    output information on the patching procedure for a particular code                
 Options:
   -e ENGINE, --engine ENGINE
                     set MD engine to ENGINE (default: choose interactively)
@@ -57,6 +59,7 @@ do
     (--save|-s)         test -n "$action" && multiple_actions=yes ; action=save ;;
     (--revert|-R|-r)    test -n "$action" && multiple_actions=yes ; action=revert ;;
     (--list-engines|-l) test -n "$action" && multiple_actions=yes ; action=list ;;
+    (--info|-i)         test -n "$action" && multiple_actions=yes ; action=info ;;
     (--new=*)           test -n "$action" && multiple_actions=yes ; action=new ; newpatch="${prefix_option#--new=}" ;;
     (--description)     echo "patch an MD engine" ; exit ;;
     (--engine=*) engine="${prefix_option#--engine=}" ;;
@@ -226,6 +229,9 @@ case "$action" in
       plumed_after_patch
     fi
   ;;
+  (info)
+    plumed_patch_info 
+  ;;
   (save)
     if [ ! -L Plumed.h -o ! -L Plumed.inc ]
     then
diff --git a/patches/qespresso-5.0.2.config b/patches/qespresso-5.0.2.config
index 84c8e4845..f7c7b6ff5 100644
--- a/patches/qespresso-5.0.2.config
+++ b/patches/qespresso-5.0.2.config
@@ -15,3 +15,9 @@ awk '{if($1=="LIBS" && $2=="="){print $0" $(PLUMED_LOAD) "}else{print }}' make.s
 function plumed_after_revert(){
   mv make.sys.old make.sys
 }
+
+function plumed_patch_info(){
+  echo ""
+  echo "For more information on Quantum Espresso you should visit http://www.quantum-espresso.org"
+}
+
diff --git a/user-doc/extract b/user-doc/extract
index 6443e5d4d..8a795cf34 100755
--- a/user-doc/extract
+++ b/user-doc/extract
@@ -18,7 +18,13 @@ done
 # Create the list of codes that plumed works with from the set of available patches
 for file in ../patches/*.diff
 do
-   echo "- $file" | sed -e 's/.diff//' | sed -e 's/..\/patches\///' >> automatic/codes.list
+   myengine=`echo "$file" | sed -e 's/.diff//' | sed -e 's/..\/patches\///'`
+   mytag=`echo "$myengine" | sed -e 's/\./\_/g'`
+   echo "- \subpage $mytag" >> automatic/codes.list
+   echo "/**" >> automatic/$myengine.txt
+   echo "\page $mytag $myengine" >> automatic/$myengine.txt
+   plumed patch -e $myengine -i | grep -v "PLUMED patching tool" | grep -v "PLUMED location:" | grep -v "extra files located in:" | grep -v "MD engine:" | grep -v "diff file:" | grep -v "sourcing config file:" >> automatic/$myengine.txt
+   echo "*/" >> automatic/$myengine.txt 
 done
 
 ## Check for utilities that register actions with no documentation
-- 
GitLab