"wrappers/python/vscode:/vscode.git/clone" did not exist on "b37e25713096e29a753d3072ed76991084e94f13"
Unverified Commit 78a31f3b authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Improve accuracy of constants in Fortran interface (#3264)

* Improve accuracy of constants in Fortran interface

* Use different suffix for Fortran constants
parent c456dd54
......@@ -902,6 +902,7 @@ class FortranHeaderGenerator(WrapperGenerator):
def writeGlobalConstants(self):
self.out.write(" ! Global Constants\n\n")
self.out.write(" integer, parameter :: dp = kind(1.d0)\n")
node = next((x for x in findNodes(self.doc.getroot(), "compounddef", kind="namespace") if x.findtext("compoundname") == "OpenMM"))
for section in findNodes(node, "sectiondef", kind="var"):
for memberNode in findNodes(section, "memberdef", kind="variable", mutable="no", prot="public", static="yes"):
......@@ -909,6 +910,9 @@ class FortranHeaderGenerator(WrapperGenerator):
iDef = getText("initializer", memberNode)
if iDef.startswith("="):
iDef = iDef[1:]
# Append _dp to constants so they will be interpreted as double precision. Some constants
# are defined as ratios, so we need to append it to both numerator and denominator.
iDef = '/'.join(f'{x}_dp' for x in iDef.split('/'))
self.out.write(" real*8, parameter :: OpenMM_%s = %s\n" % (vDef, iDef))
def writeTypeDeclarations(self):
......
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