f90nml: Order of repeated blocks not preserved when mixed with other named blocks
File file contains
&block00
i=1
k=2
&end
&block01
m=0
n=1
&end
&block00
j=3
z=4
&end
The statement f90nml.write(f90nml.read(file),outfile) will result in outfile containing
&block00
i=1
k=2
/
&block00
j=3
z=4
/
&block01
m=0
n=1
/
where order of namelist blocks has not been preserved.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 24 (14 by maintainers)
I have pushed a fix for this issue. I believe it to be working so I will close this issue, but please re-open if any problems are detected.
Also probably setitem?
I would guess that the order does not need to be explicitly tracked. This is already being implicitly tracked in the
OrderedDict. (Namelistis a subclass ofOrderedDict). Groups are stored in the order which they are added. When groups are not repeated, we are already preserving the order.I think all we need to do in this case is just provide a different internal name. After that,
__getitem__can be modified to return a list of all groups if multiple groups share the same (public) name.