Skip to content
Fortran namelist parser in Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Fortran namelist files in Python

Build Status

Install with pip

pip install namelist_python

Read in a namelist file:

from namelist_python import read_namelist_file
namelist = read_namelist_file('')

namelist is an instance of namelist_python.Namelist and all groups are stored in the attribute groups with each variable in a nested dictionary structure (using OrderedDict so that the order will be remembered).

Write a Namelist object back to a file:

with open('', 'w') as f:

dump takes an optional argument array_inline a boolean which sets whether arrays should be inline or given in index notation.

If you use ipython there is usefull attribute called data which allows you to do tab completion on the group and variable names, and do assignment:

In [7]:
In [7]:
Out[7]: 3.0

In [8]: = 4.0

In [9]:
Out[9]: 4.0


  • Parses ints, floats, booleans, escaped strings and complex numbers.
  • Parses arrays in index notation and inlined.
  • Can output in namelist format.
  • Tab-completion and variable assignment in interactive console

Missing features

  • Currently can't handle complex variable definitions across multiple lines
  • Comments are not kept, and so won't exist in output.


Please send any namelist files that don't parse correctly or fix the code yourself and send me a pull request :)

Thanks, Leif

You can’t perform that action at this time.