Skip to content

Parsing error using array assignment in namelist #127

Description

@Cory-Kramer

One of the namelists I am trying to parse using f90nml contains an array assignment of the following syntax

&example
  arr(1:2)%foo =   1.0,   2.0
  arr(1:2)%bar =   3.0,   4.0
/

If I try to read/parse this namelist

import f90nml
f90nml.reads('''
&example
  arr(1:2)%foo =   1.0,   2.0
  arr(1:2)%bar =   3.0,   4.0
/
''')

I will get the following error

Traceback (most recent call last):
  File "<pyshell#1>", line 5, in <module>
    ''')
  File "C:\Python\Python37-64\lib\site-packages\f90nml\__init__.py", line 47, in reads
    return parser.reads(nml_string)
  File "C:\Python\Python37-64\lib\site-packages\f90nml\parser.py", line 280, in reads
    return self._readstream(iter(nml_string.splitlines()))
  File "C:\Python\Python37-64\lib\site-packages\f90nml\parser.py", line 359, in _readstream
    patch_nml=grp_patch
  File "C:\Python\Python37-64\lib\site-packages\f90nml\parser.py", line 459, in _parse_variable
    assert v_idx_bounds[0][1] - v_idx_bounds[0][0] == 1
AssertionError

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions