diff --git a/interfaces/python/ck2cti.py b/interfaces/python/ck2cti.py index 6fbab29f0..ca1edcff5 100755 --- a/interfaces/python/ck2cti.py +++ b/interfaces/python/ck2cti.py @@ -1385,6 +1385,11 @@ class Parser(object): 'next section on line {0}.'.format(self.line_number)) advance = False tokens.pop() + # Fix the case where there THERMO ALL or REAC UNITS + # ends the species section + if (tokens[-1].upper().startswith('THER') or + tokens[-1].upper().startswith('REAC')): + tokens.pop() break line, comment = readline() diff --git a/test/data/unterminated-sections2.inp b/test/data/unterminated-sections2.inp new file mode 100644 index 000000000..d952e7181 --- /dev/null +++ b/test/data/unterminated-sections2.inp @@ -0,0 +1,31 @@ +Elements +H C + +SPECIES +foo bar baz + + +thermo All + 300.000 1000.000 5000.000 +foo C 1H 4 G 200.000 3500.000 1000.000 1 + 7.48514950E-02 1.33909467E-02-5.73285809E-06 1.22292535E-09-1.01815230E-13 2 +-9.46834459E+03 1.84373180E+01 5.14987613E+00-1.36709788E-02 4.91800599E-05 3 +-4.84743026E-08 1.66693956E-11-1.02466476E+04-4.64130376E+00 4 +bar C 1H 4 G 200.000 3500.000 1000.000 1 + 7.48514950E-02 1.33909467E-02-5.73285809E-06 1.22292535E-09-1.01815230E-13 2 +-9.46834459E+03 1.84373180E+01 5.14987613E+00-1.36709788E-02 4.91800599E-05 3 +-4.84743026E-08 1.66693956E-11-1.02466476E+04-4.64130376E+00 4 +baz C 1H 4 G 200.000 3500.000 1000.000 1 + 7.48514950E-02 1.33909467E-02-5.73285809E-06 1.22292535E-09-1.01815230E-13 2 +-9.46834459E+03 1.84373180E+01 5.14987613E+00-1.36709788E-02 4.91800599E-05 3 +-4.84743026E-08 1.66693956E-11-1.02466476E+04-4.64130376E+00 4 + +reactions cal/mol +foo + bar = 2 baz 1.2345e12 1.0 200.0 +2foo + baz = 3bar 5.4321e10 1.0 500.0 + +transport +foo 2 357.000 5.180 0.000 0.000 1.000 +bar 2 266.800 4.982 0.000 0.000 1.000 +baz 2 266.800 4.982 0.000 0.000 1.000 +! some comment diff --git a/test/python/testConvert.py b/test/python/testConvert.py index 1a3098510..073b76f6f 100644 --- a/test/python/testConvert.py +++ b/test/python/testConvert.py @@ -160,6 +160,20 @@ class chemkinConverterTest(utilities.CanteraTest): self.assertEqual(gas.nSpecies(), 3) self.assertEqual(gas.nReactions(), 2) + def test_unterminatedSections2(self): + self.assertRaises(ck2cti.InputParseError, + lambda: convertMech('../data/unterminated-sections2.inp', + outName='unterminated-sections2.cti', + quiet=True)) + + convertMech('../data/unterminated-sections2.inp', + outName='unterminated-sections2.cti', + quiet=True, permissive=True) + + gas = ct.IdealGasMix('unterminated-sections2.cti') + self.assertEqual(gas.nSpecies(), 3) + self.assertEqual(gas.nReactions(), 2) + def test_nasa9(self): convertMech('../data/nasa9-test.inp', thermoFile='../data/nasa9-test-therm.dat',