Commit b16155f7 authored by Ask Hjorth Larsen's avatar Ask Hjorth Larsen
Browse files

fix array lengths when same thing is parsed multiple times

parent c39af793
...@@ -29,16 +29,20 @@ def siesta_energy(title, meta, **kwargs): ...@@ -29,16 +29,20 @@ def siesta_energy(title, meta, **kwargs):
def ArraySM(header, row, build, **kwargs): def ArraySM(header, row, build, **kwargs):
lines = []
def addrow(parser): class LineBuf:
line = parser.fIn.readline() def __init__(self):
lines.append(line) self.lines = []
def _build_array(parser): def addrow(self, parser):
build(parser.backend.superBackend, lines) line = parser.fIn.readline()
self.lines.append(line)
def _build_array(self, parser):
build(parser.backend.superBackend, self.lines)
self.lines = []
linebuf = LineBuf()
sm = SM(header, sm = SM(header,
name=kwargs.pop('name', 'startarray'), name=kwargs.pop('name', 'startarray'),
required=True, required=True,
...@@ -46,8 +50,8 @@ def ArraySM(header, row, build, **kwargs): ...@@ -46,8 +50,8 @@ def ArraySM(header, row, build, **kwargs):
subMatchers=[ subMatchers=[
SM(row, name='array', repeats=True, SM(row, name='array', repeats=True,
forwardMatch=True, forwardMatch=True,
adHoc=addrow, required=True), adHoc=linebuf.addrow, required=True),
SM(r'', endReStr='', adHoc=_build_array, name='endarray', SM(r'', endReStr='', adHoc=linebuf._build_array, name='endarray',
forwardMatch=True) forwardMatch=True)
], ],
**kwargs) **kwargs)
...@@ -184,6 +188,13 @@ infoFileDescription = SM( ...@@ -184,6 +188,13 @@ infoFileDescription = SM(
r'\s*[0-9]+\s+\S+\s+\S+\s+\S+', r'\s*[0-9]+\s+\S+\s+\S+\s+\S+',
get_forces, name='forces-in-opt-step'), get_forces, name='forces-in-opt-step'),
SM(r'Target enthalpy', name='end-singleconfig'), SM(r'Target enthalpy', name='end-singleconfig'),
# As we get past the last singleconfig, we need to add all the stuff
# that pertains only to the last one, basically eigs and occs.
# Therefore we read a bit past the last config and try to trigger
# this as appropriate.
#SM(r'outcoor: Relaxed atomic coordinates',
# adHoc=read_eigenvalues),
#])
SM(r'', weak=True, name='After singleconfigs', SM(r'', weak=True, name='After singleconfigs',
subFlags=SM.SubFlags.Sequenced, subFlags=SM.SubFlags.Sequenced,
subMatchers=[ subMatchers=[
...@@ -222,7 +233,7 @@ infoFileDescription = SM( ...@@ -222,7 +233,7 @@ infoFileDescription = SM(
# The purpose of the following matcher is to parse all lines # The purpose of the following matcher is to parse all lines
SM(r'x^', name='end') SM(r'x^', name='end')
]) ])
]), ])
]) ])
class SiestaContext(object): class SiestaContext(object):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment