Skip to main content

Fortran 90 namelist parser

Project description

A Python module for parsing Fortran namelist files


About f90nml

f90nml is a Python module that provides a simple interface for the reading, writing, and the general manipulation of Fortran namelist files.

A namelist file is parsed and converted into an Namelist object, which behaves like a standard Python dict. Values are converted from Fortran data types to equivalent primitive Python types.

Quick usage guide

To read a namelist file sample.nml which contains the following namelists:

   input = ''
   steps = 864
   layout = 8, 16
   visc = 1e-4
   use_biharmonic = .false.

we would use the following script:

import f90nml
nml ='sample.nml')

which would would point nml to the following dict:

nml = {'config_nml':
         {'input': '',
          'steps': 864,
          'layout': [8, 16],
          'visc': 0.0001
          'use_biharmonic': False

To modify one of the values, say steps, and save the output, just manipulate the nml contents and write to disk using the write function:

nml['config_nml']['steps'] = 432

To modify a namelist but preserve its comments and formatting, create a namelist patch and apply it to a target file using the patch function:

patch_nml = {'config_nml': {'visc': 1e-6}}
nml.patch('sample.nml', 'new_sample.nml', patch_nml)


f90nml is available on PyPI and can be installed via pip:

$ pip install f90nml

It is also available on Arch Linux via the AUR:

$ git clone
$ cd python-f90nml
$ makepkg -sri

f90nml is not yet available on other Linux distributions.

The latest version of f90nml can be installed from source:

$ git clone
$ cd f90nml
$ python install

Users without install privileges can append the --user flag to

$ python --user install

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.16.tar.gz (27.9 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