add checks for global commands, pair and bonded styles

This commit is contained in:
Axel Kohlmeyer
2020-01-11 18:53:09 -05:00
parent 00a31f6637
commit a38cf075db

View File

@ -2,10 +2,39 @@
from __future__ import print_function from __future__ import print_function
from glob import glob from glob import glob
import os, re from argparse import ArgumentParser
import os, re, sys
headers = glob(os.path.join('..', '..', 'src', '*', '*.h')) parser = ArgumentParser(prog='check-styles.py',
headers += glob(os.path.join('..', '..', 'src', '*.h')) description="Check style table completeness")
parser.add_argument("-v", "--verbose",
action='store_const',
const=True, default=False,
help="Enable verbose output")
parser.add_argument("-d", "--doc",
help="Path to LAMMPS documentation sources")
parser.add_argument("-s", "--src",
help="Path to LAMMPS sources")
args = parser.parse_args()
verbose = args.verbose
src = args.src
doc = args.doc
if not args.src or not args.doc:
parser.print_help()
sys.exit(1)
if not os.path.isdir(src):
sys.exit("LAMMPS source path %s does not exist" % src)
if not os.path.isdir(doc):
sys.exit("LAMMPS documentation source path %s does not exist" % doc)
headers = glob(os.path.join(src, '*', '*.h'))
headers += glob(os.path.join(src, '*.h'))
angle = {} angle = {}
atom = {} atom = {}
@ -44,10 +73,28 @@ def register_style(list,style,info):
else: else:
list[style] = info list[style] = info
def add_suffix(list,style):
suffix = ""
if list[style]['gpu']:
suffix += 'g'
if list[style]['intel']:
suffix += 'i'
if list[style]['kokkos']:
suffix += 'k'
if list[style]['omp']:
suffix += 'o'
if list[style]['opt']:
suffix += 't'
if suffix:
return style + ' (' + suffix + ')'
else:
return style
for h in headers: for h in headers:
# print("Checking ", h) if verbose: print("Checking ", h)
fp = open(h) fp = open(h)
text = fp.read() text = fp.read()
fp.close()
matches = re.findall("(.+)Style\((.+),(.+)\)",text,re.MULTILINE) matches = re.findall("(.+)Style\((.+),(.+)\)",text,re.MULTILINE)
for m in matches: for m in matches:
@ -121,5 +168,78 @@ for h in headers:
register_style(region,style,info) register_style(region,style,info)
else: else:
print("Skipping over: ",m) print("Skipping over: ",m)
fp.close()
if verbose:
print("""
Parsed styles from %s:
Angle styles: %3d
Atom styles: %3d
Body styles: %3d
Bond styles: %3d
Command styles: %3d
Compute styles: %3d
Dihedral styles: %3d
Dump styles: %3d
Fix styles: %3d
Improper styles: %3d
Integrate styles: %3d
Kspace styles: %3d
Minimize styles: %3d
Pair styles: %3d
Reader styles: %3d
Region styles: %3d
""" % (src, len(angle), len(atom), len(body), len(bond), \
len(command), len(compute), len(dihedral), len(dump), \
len(fix), len(improper), len(integrate), len(kspace), \
len(minimize), len(pair), len(reader), len(region)))
# check main commands lists
f = os.path.join(doc, 'Commands_all.rst')
fp = open(f)
text = fp.read()
fp.close()
matches = re.findall(":doc:`(.+) <.+>`",text,re.MULTILINE)
for c in command.keys():
if not c in matches:
print("Command %s is missing in Commands_all.rst" % c)
f = os.path.join(doc, 'Commands_pair.rst')
fp = open(f)
text = fp.read()
fp.close()
matches = re.findall(":doc:`(.+) <pair.+>`",text,re.MULTILINE)
for c in pair.keys():
# known undocumented aliases we need to skip
if c in ('meam','lj/sf'): continue
if not add_suffix(pair,c) in matches:
if not pair[c]['removed']:
print("Pair style entry %s is missing or" % c,
"incomplete in Commands_pair.rst")
f = os.path.join(doc, 'Commands_bond.rst')
fp = open(f)
text = fp.read()
fp.close()
matches = re.findall(":doc:`(.+) <bond.+>`",text,re.MULTILINE)
for c in bond.keys():
if not add_suffix(bond,c) in matches:
print("Bond style entry %s is missing or incomplete in Commands_bond.rst" % c)
matches = re.findall(":doc:`(.+) <angle.+>`",text,re.MULTILINE)
for c in angle.keys():
if not add_suffix(angle,c) in matches:
print("Angle style entry %s is missing or incomplete in Commands_bond.rst" % c)
matches = re.findall(":doc:`(.+) <dihedral.+>`",text,re.MULTILINE)
for c in dihedral.keys():
if not add_suffix(dihedral,c) in matches:
print("Dihedral style entry %s is missing or incomplete in Commands_bond.rst" % c)
matches = re.findall(":doc:`(.+) <improper.+>`",text,re.MULTILINE)
for c in improper.keys():
if not add_suffix(improper,c) in matches:
print("Improper style entry %s is missing or incomplete in Commands_bond.rst" % c)