This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Fortran 90 namelist parser

Project Description

A Python module for parsing Fortran namelist files

Documentation: http://f90nml.readthedocs.org/en/latest/

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:

&config_nml
   input = 'wind.nc'
   steps = 864
   layout = 8, 16
   visc = 1e-4
   use_biharmonic = .false.
/

we would use the following script:

import f90nml
nml = f90nml.read('sample.nml')

which would would point nml to the following dict:

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

File objects can also be used as inputs:

with open('sample.nml') as nml_file:
    nml = f90nml.read(nml_file)

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
nml.write('new_sample.nml')

Namelists can also be saved to file objects:

with open('target.nml') as nml_file:
   nml.write(nml_file)

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}}
f90nml.patch('sample.nml', patch_nml, 'new_sample.nml')

Installation

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 https://aur.archlinux.org/python-f90nml.git
$ 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 https://github.com/marshallward/f90nml.git
$ cd f90nml
$ python setup.py install

Users without install privileges can append the --user flag to setup.py:

$ python setup.py --user install
Release History

Release History

This version
History Node

0.21

History Node

0.20

History Node

0.19

History Node

0.18

History Node

0.17

History Node

0.16

History Node

0.15

History Node

0.14

History Node

0.13.post1

History Node

0.13

History Node

0.12

History Node

0.11

History Node

0.10.2

History Node

0.10.1

History Node

0.10

History Node

0.9.1

History Node

0.9

History Node

0.8

History Node

0.7

History Node

0.6.2

History Node

0.6.1

History Node

0.6

History Node

0.5

History Node

0.4

History Node

0.3

History Node

0.2.1

History Node

0.2

History Node

0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
f90nml-0.21.tar.gz (33.3 kB) Copy SHA256 Checksum SHA256 Source Feb 3, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting