From b68eff0e4847c560b1bd9dfa81ffe80831b4e38b Mon Sep 17 00:00:00 2001 From: Gareth Tribello <gareth.tribello@gmail.com> Date: Sun, 28 Jul 2019 10:42:28 +0200 Subject: [PATCH] Functionality for checking plumed include files has been done in a neater way --- developer-doc/usingDoxygen.md | 16 +++++---------- src/generic/Group.cpp | 5 +++-- src/generic/Include.cpp | 25 +++++++++++++--------- user-doc/Doxyfile | 2 -- user-doc/Makefile | 2 +- user-doc/Miscelaneous.md | 5 +++-- user-doc/go-example-check | 33 ++++++++---------------------- user-doc/go-spelling | 4 ++-- user-doc/tutorials/aa-lugano-2.txt | 5 +++-- 9 files changed, 41 insertions(+), 56 deletions(-) diff --git a/developer-doc/usingDoxygen.md b/developer-doc/usingDoxygen.md index 7ef8e8e69..e0dda8b7d 100644 --- a/developer-doc/usingDoxygen.md +++ b/developer-doc/usingDoxygen.md @@ -466,20 +466,14 @@ DISTANCE ATOMS=1,2 LABEL=dist INCLUDE FILE=toBeIncluded.inc \ endplumedfile /*** But with no space between the \ and the endplumedfile -\plumedincludefile -# this is toBeIncluded.inc +\plumedfile +#SETTINGS FILENAME=toBeIncluded.inc RESTRAINT ARG=dist AT=2.0 KAPPA=1.0 -\ endplumedincludefile /*** But with no space between the \ and the endplumedincludefile -\endverbatim - -Please note that it is essential that you write: - -\verbatim -# this is <filename> +\ endplumedfile /*** But with no space between the \ and the endplumedincludefile \endverbatim -on the second line in the plumedincludefile environment as this is where the script that builds the user documentation gets the name of the included file -from. Also notice that if, as in the example above, the included file is not (by itself) a valid plumed input it CANNOT be called *.dat as the script that +By including the FILENAME attribute on the SETTINGS line you can set the name of the plumed input file that is generated when the input is tested. +Also notice that if, as in the example above, the included file is not (by itself) a valid plumed input it CANNOT be called *.dat as the script that checks the input will complain. \subsection molfileeg Using MOLFILE in your example input files diff --git a/src/generic/Group.cpp b/src/generic/Group.cpp index 59b26c780..bdf44b223 100644 --- a/src/generic/Group.cpp +++ b/src/generic/Group.cpp @@ -79,11 +79,12 @@ PRINT ARG=c FILE=colvar Groups can be conveniently stored in a separate file. E.g. one could create a file named `groups.dat` which reads -\plumedincludefile +\plumedfile +#SETTINGS FILENAME=groups.dat # this is groups.dat o: GROUP ATOMS=1,4,7,11,14 h: GROUP ATOMS=2,3,5,6,8,9,12,13 -\endplumedincludefile +\endplumedfile and then include it in the main 'plumed.dat' file \plumedfile INCLUDE FILE=groups.dat diff --git a/src/generic/Include.cpp b/src/generic/Include.cpp index 950d6ef7e..d146678a5 100644 --- a/src/generic/Include.cpp +++ b/src/generic/Include.cpp @@ -54,11 +54,12 @@ d: DISTANCE ATOMS=c1,c2 PRINT ARG=d \endplumedfile where the content of file pippo.dat is -\plumedincludefile +\plumedfile +#SETTINGS FILENAME=pippo.dat # this is pippo.dat c1: COM ATOMS=1-100 c2: COM ATOMS=101-202 -\endplumedincludefile +\endplumedfile The files in this example are rather short, but imagine a case like this one: \plumedfile @@ -67,7 +68,8 @@ c: COORDINATION GROUPA=groupa GROUPB=groupb R_0=0.5 METAD ARG=c HEIGHT=0.2 PACE=100 SIGMA=0.2 BIASFACTOR=5 \endplumedfile Here `groups.dat` could be huge file containing group definitions such as -\plumedincludefile +\plumedfile +#SETTINGS FILENAME=groups.dat # this is groups.dat groupa: GROUP ... ATOMS={ @@ -91,17 +93,18 @@ groupb: GROUP ... 121 } ... -\endplumedincludefile +\endplumedfile So, included files are the best place where one can store long definitions. Another case where INCLUDE is very useful is when running multi-replica simulations. Here different replicas might have different input files, but perhaps a large part of the input is shared. This part can be put in a common included file. For instance you could have `common.dat`: -\plumedincludefile +\plumedfile +#SETTINGS FILENAME=common.dat # this is common.dat t: TORSION ATOMS=1,2,3,4 -\endplumedincludefile +\endplumedfile Then `plumed.0.dat`: \plumedfile # this is plumed.0.dat @@ -128,15 +131,17 @@ t: TORSION ATOMS=1,2,3,4 INCLUDE FILE=other.inc \endplumedfile Then `other.0.inc`: -\plumedincludefile +\plumedfile +#SETTINGS FILENAME=other.0.inc # this is other.0.inc RESTRAINT ARG=t AT=1.0 KAPPA=10 -\endplumedincludefile +\endplumedfile And `other.1.inc`: -\plumedincludefile +\plumedfile +#SETTINGS FILENAME=other.1.inc # this is other.1.inc RESTRAINT ARG=t AT=1.2 KAPPA=10 -\endplumedincludefile +\endplumedfile diff --git a/user-doc/Doxyfile b/user-doc/Doxyfile index 571e3ad3b..26134d62f 100644 --- a/user-doc/Doxyfile +++ b/user-doc/Doxyfile @@ -238,8 +238,6 @@ ALIASES = \ "tarball{1}=\htmlonly<span style=\"background-color:yellow\">\endhtmlonly<a href=\"tutorial-resources/\1.tar.gz\" style=\"font-weight:bold\" style=\"color:green\" download=\"\1.tar.gz\"> TARBALL </a>\htmlonly</span>\endhtmlonly" \ "plumedfile=\verbatim BEGIN_PLUMED_FILE" \ "endplumedfile=\endverbatim" \ - "plumedincludefile=\verbatim BEGIN_PLUMED_FILE" \ - "endplumedincludefile=\endverbatim" \ "auxfile{1}=\verbatim" \ "endauxfile=\endverbatim" \ "plumednotmaintained=\warning This branch is not maintained. Users are invited to upgrade to a newer version" diff --git a/user-doc/Makefile b/user-doc/Makefile index 9e869587a..9e35d3c8e 100644 --- a/user-doc/Makefile +++ b/user-doc/Makefile @@ -17,7 +17,7 @@ else all: ifeq ($(make_doc),yes) make_pdfdoc=$(make_pdfdoc) ./extract - # temporarily removed for travis to build: + # check examples in input file: ./go-example-check make_pdfdoc=$(make_pdfdoc) ./go-doxygen cp *png html/ diff --git a/user-doc/Miscelaneous.md b/user-doc/Miscelaneous.md index a1a452d41..01e9712f2 100644 --- a/user-doc/Miscelaneous.md +++ b/user-doc/Miscelaneous.md @@ -482,10 +482,11 @@ DISTANCE ATOMS=1,2 LABEL=dist INCLUDE FILE=toBeIncluded.inc \endplumedfile plus a "toBeIncluded.inc" file -\plumedincludefile +\plumedfile +#SETTINGS FILENAME=toBeIncluded.inc # this is toBeIncluded.inc RESTRAINT ARG=dist AT=2.0 KAPPA=1.0 -\endplumedincludefile +\endplumedfile However, when you do this it is important to recognize that \ref INCLUDE is a real directive that is only resolved after all the \ref comments have been stripped and the \ref ContinuationLines have been unrolled. This means it diff --git a/user-doc/go-example-check b/user-doc/go-example-check index bd5232592..846bedfdf 100755 --- a/user-doc/go-example-check +++ b/user-doc/go-example-check @@ -5,7 +5,7 @@ mkdir example-check # This generates plumed.dat files for each of the documentation pages in the manual for file in *PP.md automatic/*.txt ../CHANGES/*.md tutorials/*.txt tutorials/*.site tutorials/others/*.txt ; do - # echo Generating examples to check for file $file + #echo Generating examples to check for file $file # Single replica examples splits=`echo $file | sed -e 's/\// /g'` nf=`echo $splits | awk '{print NF}'` @@ -29,31 +29,16 @@ for file in *PP.md automatic/*.txt ../CHANGES/*.md tutorials/*.txt tutorials/*.s wrongc=`grep "this is wrong" example-check/$fname/$i.dat | wc -l | awk '{print $1}'` if [ $wrongc -gt 0 ] ; then rm example-check/$fname/$i.dat + else + # This deals with include files + hasname=`grep "#SETTINGS" example-check/$fname/$i.dat | grep "FILENAME=" | wc -l | awk '{print $1}'` + if [ $hasname -gt 0 ] ; then + filename=`grep "#SETTINGS" example-check/$fname/$i.dat | awk '{for(i=1;i<=NF;++i){if(match($i,"FILENAME=")){print $i}}}' | sed -e 's/FILENAME=//'` + mv example-check/$fname/$i.dat example-check/$fname/$filename + fi fi sline=$eline done - # Check for plumed include files - cat $file | - awk 'BEGIN{inp=0;}{ - if( $1=="\\endplumedincludefile" ){ print ">>END OF EXAMPLE>>"; inp=0; } - else if( $1=="\\plumedincludefile" ){ inp=1; } - else if( inp==1 ){ print $0; } - }' > example-check/$fname.inc - ninc=`grep ">>END OF EXAMPLE>>" example-check/$fname.inc | wc -l | awk '{print $1}'` - # And split the set of include files - sline=0 - for ((i=1;i<=$ninc;++i)) ; do - checks=`grep -A 1 "plumedincludefile" $file | head -n $((($i-1)*6+2)) | tail -n 1 | awk '{match($0,"# this is")}'` - ifname=`grep -A 1 "plumedincludefile" $file | head -n $((($i-1)*6+2)) | tail -n 1 | awk '{if(match($0,"# this is")){ print $4; } else { print "ERROR";}}'` - if [ $ifname == "ERROR" ] ; then - echo ERROR in specification of include file for $file - exit 1 - fi - eline=`grep -n ">>END OF EXAMPLE>>" example-check/$fname.inc | head -n $i | tail -n 1 | awk '{print $1}' | sed -e 's/:>>END//g'` - head -n $(($eline-1)) example-check/$fname.inc | tail -n $(($eline-1-$sline)) > example-check/$fname/$ifname - sline=$eline - done - rm example-check/$fname.inc # Check for auxiliary files cat $file | awk 'BEGIN{inp=0;}{ @@ -145,7 +130,7 @@ for dir in * ; do fi nerr=`grep "PLUMED error" check.log | wc -l | awk '{print $1}'` if [ $nerr -gt 0 ] ; then - echo Found mistakes for examples $file + echo Found mistakes for examples in $dir example $file cat check.log exit 1 fi diff --git a/user-doc/go-spelling b/user-doc/go-spelling index 6b9ced05d..e01ae4b2f 100755 --- a/user-doc/go-spelling +++ b/user-doc/go-spelling @@ -29,8 +29,8 @@ for file in *PP.md automatic/*.txt ../CHANGES/*.md tutorials/*.txt tutorials/*.s # This is some stuff to get rid of stuff that trips up the spell checker: the equations and the plumed examples cat $file | grep -v "\\image" | grep -v "anchor" | sed -e 's/psi-1//' | sed -e 's/-#//' | sed -e 's/@//' | sed -e 's/&//' | sed -e 's/\vdots//' | awk 'BEGIN{inp=0}{ - if($1=="\\endplumedfile" || $1=="\\f]" || $1=="\\f}" || $1=="\\endauxfile" || $1=="\\endplumedincludefile" || $1=="\\endverbatim" || $1=="\\endcode"){inp=0;} - else if($1=="\\plumedfile" || $1=="\\f[" || $1=="\\f{eqnarray*}{" || match($1,"\\auxfile") || $1=="\\plumedincludefile" || $1=="\\verbatim" || index($1,"\\code{")!=0 ){inp=1;} + if($1=="\\endplumedfile" || $1=="\\f]" || $1=="\\f}" || $1=="\\endauxfile" || $1=="\\endverbatim" || $1=="\\endcode"){inp=0;} + else if($1=="\\plumedfile" || $1=="\\f[" || $1=="\\f{eqnarray*}{" || match($1,"\\auxfile") || $1=="\\verbatim" || index($1,"\\code{")!=0 ){inp=1;} else if(inp==0){ skip=0; for(i=1;i<=NF;++i){ diff --git a/user-doc/tutorials/aa-lugano-2.txt b/user-doc/tutorials/aa-lugano-2.txt index 9235e1311..4c92988a1 100644 --- a/user-doc/tutorials/aa-lugano-2.txt +++ b/user-doc/tutorials/aa-lugano-2.txt @@ -390,7 +390,8 @@ is presented in the following but the exercise is possible only if plumed is com Here we use the "replica" syntax of plumed to write a single plumed input file for all the windows: -\plumedincludefile +\plumedfile +#SETTINGS FILENAME=plumed.dat # this is plumed.dat # vim:ft=plumed MOLINFO STRUCTURE=diala.pdb @@ -413,7 +414,7 @@ restraint-phi: RESTRAINT ... } ... # monitor the two variables and the bias potential from the restraint PRINT STRIDE=20 ARG=phi,psi,restraint-phi.bias FILE=COLVAR -\endplumedincludefile +\endplumedfile The \@replicas syntax allow to define different values for a variable for the different replicas. -- GitLab