jkitchin / vasp

New ASE compliant Python interface to VASP
122 stars 58 forks source link

Issue with get_elapsed_time in getters.py #44

Closed MAHines closed 2 years ago

MAHines commented 7 years ago

I am working on a computer that has some sort of profiling turned on for VASP. As a result, the OUTCAR always has a few hundred lines of extra timing information at the end. When Vasp goes to parse the OUTCAR, it looks for a certain regex 8 line for the end and does not find it (which is fine). The issue is that the regex search returns None, not the expected output from a successful search, which causes the next line to fail.

The key bit of code in get_elapsed_time in getters.py currently reads:

# fragile but fast.
m = re.search(regexp, lines[-8]) 

time = m.groupdict().get('time', None)   # this line causes crash for non-standard OUTCAR

I suggest this be changed to read:

# fragile but fast.
m = re.search(regexp, lines[-8])

if m is not None:
    time = m.groupdict().get('time', None)
    if time is not None:
        return float(time)
    else:
        return None
else:
    return None
jkitchin commented 7 years ago

Thanks for reporting this. What do you think of something like this instead? Could you try it?

m = re.search(regexp, lines[-8])
time = float(m.groupdict().get('time', -1)) if m is not None else -1.0
return time
MAHines commented 7 years ago

This works! Thanks.