Skip to main content

Package for parsing Fortran namelist, modified from OMFT namelist.

Project description


FortranNamelist is a standalone python package/class for parsing Fortran/IDL namelist. It is modified from OMFIT namelist.


  • Support Fortran indexing
  • Support multi-dimensional arrays
  • Retain comments

NOTE: I haven't tested/cleaned all the functions. Please use at your own warranty.


You can install the package using pip.

pip install FortranNamelist

Or from TestPypi using

pip install --index-url FortranNamelist

You can also install it by cloning the source code.

git clone
cd namelist
python install


Here is some simple examples of using the package. There are more functions and you can have a view in the source code.

Parse Fortran namelist

By default, it will use Fortran indexing convention. There is not special meaning for negative index.

import FortranNamelist.namelist as nml
ranged_nl = nml.NamelistFile(input_string='''
                                 entry(-2, -2) = -10
                                 entry(1,1) = 1
                                 entry(2,1:2) = 1, 2
                                 entry(3,1) = 1
                                 entry(3,2) = 2
                                 entry(3,3) = 3
                                 entry(4,1) = 4
                                 entry(5,1:2) = 1, 2
                                 entry(6:7,1) = 6, 7

You can also read namelist from file.

ranged_nl = nml.NamelistFile('path-to-file')

Write namelist to file

You can write the namelist to a file by using # default saved to ranged_nl.filename

or using


Use python indexing

You can also switch to python indexing convention

with nml.python_environment(ranged_nl) :


You can report bugs on GitHub issues and propose improvements using pull request. For more information, please contact Dr. Caoxiang ZHU (caoxiangzhu[at]

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for FortranNamelist, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size FortranNamelist-0.1.0-py3-none-any.whl (29.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size FortranNamelist-0.1.0.tar.gz (26.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page