Skip to main content

Fortran 90 namelist parser

Project description

A Python module for parsing Fortran namelist files

About f90nml

The f90nml module takes a Fortran 90 namelist file and parses it into a Python dict of namelist groups, each containing a dict of its variables. Fortran data types are converted to equivalent Python types.


To read a Fortran namelist file as a dict, use the read() method:

nml_dict =

To output a Python dict as a Fortran namelist file, use the write() method:

f90nml.write(my_nml, output_filename)

This method will abort if the output file already exists.

Additional Features

Derived types

Additional NmlDicts are created to traverse user-defined types. For example, if you want to access z in the following namelist:

   x%y%z = 1

then z can be accessed in the equivalent namelist nml by typing

z = nml['dtype_nml']['x']['y']['z']

Overwriting an existing file

To overwrite an existing file when using the write method, use the force flag:

f90nml.write(nml, nml_filename, force=True)


The read method produces an NmlDict, which behaves as a dict with case-insensitive keys, due to the case insensitivity of Fortran. This implementation is currently not a true case-insensitive dict, and is only intended to accommodate individual references and assignments.

In a Fortran executable, the data types of values in the namelist files are set by the corresponding variables within the program, and cannot in general be determined from the namelist file alone. Therefore, f90nml only makes an approximate guess about its data type.

The following namelist features are currently not supported:

  • Implicit vector assignment (v(i:j) = c)
  • Multidimensional vector assignment (v(:,:) = 1, 2, 3, 4)
  • Upcast vector elements if components differ (x(i) = 1, x(j) = 2.0)
  • Escape on repeated quotes ('This doesn''t parse correctly')
  • stdin/stdout support (?, ?=)


f90nml is distributed under the Apache 2.0 License.


Marshall Ward <>

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
f90nml-0.6.tar.gz (10.2 kB) Copy SHA256 hash SHA256 Source None

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