f90nml - A Python module for Fortran namelists

f90nml - A Python module for Fortran namelists - Published in JOSS (2019)

https://github.com/marshallward/f90nml

Science Score: 95.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    7 of 26 committers (26.9%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

fortran namelist parser python
Last synced: 4 months ago · JSON representation

Repository

A Python module and command line tool for working with Fortran namelists

Basic Info
  • Host: GitHub
  • Owner: marshallward
  • License: apache-2.0
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 786 KB
Statistics
  • Stars: 143
  • Watchers: 10
  • Forks: 54
  • Open Issues: 27
  • Releases: 9
Topics
fortran namelist parser python
Created almost 12 years ago · Last pushed 5 months ago
Metadata Files
Readme Changelog License Authors

README.rst

=========================================================
f90nml - A Fortran namelist parser, generator, and editor
=========================================================

A Python module and command line tool for parsing Fortran namelist files

.. image:: https://ci.appveyor.com/api/projects/status/bcugyoqxiyyvemy8?svg=true
   :target: https://ci.appveyor.com/project/marshallward/f90nml

.. image:: https://coveralls.io/repos/marshallward/f90nml/badge.svg?branch=master
   :target: https://coveralls.io/r/marshallward/f90nml?branch=master

.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3245482.svg
   :target: https://doi.org/10.5281/zenodo.3245482


Documentation
=============

The documentation for ``f90nml`` is available from Read The Docs.

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


About f90nml
============

``f90nml`` is a Python module and command line tool that provides a simple
interface for the reading, writing, and modifying Fortran namelist files.

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

The command line tool ``f90nml`` can be used to modify individual values inside
of a shell environment.  It can also be used to convert the data between
namelists and other configuration formats.  JSON and YAML formats are currently
supported.


Quick usage guide
=================

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

.. code-block:: fortran

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

we would use the following script:

.. code:: python

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

which would would point ``nml`` to the following ``dict``:

.. code:: python

   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:

.. code:: python

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

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

.. code:: python

   nml['config_nml']['steps'] = 432
   nml.write('new_sample.nml')

Namelists can also be saved to file objects:

.. code:: python

   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:

.. code:: python

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


Command line interface
----------------------

A command line tool is provided to manipulate namelist files within the shell:

.. code:: sh

   $ f90nml config.nml -g config_nml -v steps=432

.. code-block:: fortran

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

See the documentation for details.


Installation
============

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

   $ pip install f90nml

The latest version of ``f90nml`` can be installed from source::

   $ git clone https://github.com/marshallward/f90nml.git
   $ cd f90nml
   $ pip install .

conda
-----

There is a conda-forge feedstock (not maintained by the author)::

    $ conda install -c conda-forge f90nml

Information on supported versions and platforms, and detailed installation
instructions using ``conda`` and ``conda-forge`` is available here:

   https://github.com/conda-forge/f90nml-feedstock


Package distribution
--------------------

``f90nml`` is not distributed through any official packaging tools, but it is
available on Arch Linux via the AUR::

   $ git clone https://aur.archlinux.org/python-f90nml.git
   $ cd python-f90nml
   $ makepkg -sri

Volunteers are welcome to submit and maintain ``f90nml`` on other
distributions.


Local install
-------------

Users without install privileges can append the ``--user`` flag to ``pip`` from
the top ``f90nml`` directory::

   $ pip install --user .

If pip is not available, then ``setup.py`` can still be used::

   $ python setup.py install --user

When using ``setup.py`` locally, some users have reported that ``--prefix=``
may need to be appended to the command::

   $ python setup.py install --user --prefix=


YAML support
------------

The command line tool offers support for conversion between namelists and YAML
formatted output.  If PyYAML is already installed, then no other steps are
required.  To require YAML support, install the ``yaml`` extras package::

   $ pip install f90nml[yaml]

To install as a user::

   $ pip install --user .[yaml]


Contributing to ``f90nml``
==========================

Users are welcome to submit bug reports, feature requests, and code
contributions to this project through GitHub.  More information is available in
the `Contributing`_ guidelines.

.. _Contributing: http://f90nml.readthedocs.org/en/latest/contributing.html

Owner

  • Name: Marshall Ward
  • Login: marshallward
  • Kind: user
  • Location: Princeton, NJ, USA
  • Company: @noaa-gfdl

Still pretending to be an oceanographer.

JOSS Publication

f90nml - A Python module for Fortran namelists
Published
June 14, 2019
Volume 4, Issue 38, Page 1474
Authors
Marshall L. Ward ORCID
NOAA Geophysical Fluid Dynamics Laboratory, Princeton, NJ, USA, Australian National University, Canberra, Australia
Editor
Daniel S. Katz ORCID
Tags
fortran namelist python

GitHub Events

Total
  • Issues event: 8
  • Watch event: 7
  • Delete event: 8
  • Issue comment event: 20
  • Push event: 37
  • Pull request event: 7
  • Fork event: 4
  • Create event: 4
Last Year
  • Issues event: 8
  • Watch event: 7
  • Delete event: 8
  • Issue comment event: 20
  • Push event: 37
  • Pull request event: 7
  • Fork event: 4
  • Create event: 4

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 767
  • Total Committers: 26
  • Avg Commits per committer: 29.5
  • Development Distribution Score (DDS): 0.203
Past Year
  • Commits: 13
  • Committers: 2
  • Avg Commits per committer: 6.5
  • Development Distribution Score (DDS): 0.077
Top Committers
Name Email Commits
Marshall Ward m****d@g****m 611
Marshall Ward g****t@m****g 103
Holger Wolff h****f@m****u 11
Qi q****0@c****u 5
James Penn j****s@j****k 5
Daniel S. Katz d****z@i****g 4
Jens Svensmark j****s@u****p 3
Aidan Heerdegen a****n@g****m 2
Huziy Oleksandr g****a@g****m 2
MartinDix m****x@c****u 2
Robert Gieseke r****e@p****e 2
dwwork d****k@g****m 2
naught101 n****1@g****m 2
Andrew Kiss 3****s 1
Balthasar Reuter b****r@e****t 1
Holger Wolff h****t@w****e 1
Kai Li k****x@g****m 1
LiamPattinson L****n 1
Maik Riechert m****t@a****e 1
Michael Lamparski d****e@g****m 1
Philip Cross p****c@g****m 1
Jens Svensmark j****s@m****m 1
Greg Bullock g****g@n****m 1
Pascal Hebbeker p****r@n****z 1
Warrick Ball w****l@b****k 1
malmans2 m****i@j****u 1

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 97
  • Total pull requests: 26
  • Average time to close issues: 6 months
  • Average time to close pull requests: 23 days
  • Total issue authors: 57
  • Total pull request authors: 17
  • Average comments per issue: 5.98
  • Average comments per pull request: 4.19
  • Merged pull requests: 18
  • Bot issues: 0
  • Bot pull requests: 2
Past Year
  • Issues: 9
  • Pull requests: 4
  • Average time to close issues: about 5 hours
  • Average time to close pull requests: about 7 hours
  • Issue authors: 6
  • Pull request authors: 2
  • Average comments per issue: 0.33
  • Average comments per pull request: 1.25
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • marshallward (15)
  • gitporst (4)
  • jacobwilliams (4)
  • letmaik (3)
  • rhfogh (3)
  • zbeekman (3)
  • kripnerl (2)
  • greyltc (2)
  • amorison (2)
  • dpanici (2)
  • Cory-Kramer (2)
  • mandresm (2)
  • aekiss (2)
  • warrickball (2)
  • coreur (2)
Pull Request Authors
  • marshallward (5)
  • aidanheerdegen (2)
  • reuterbal (2)
  • scivision (2)
  • dependabot[bot] (2)
  • jenssss (2)
  • aekiss (1)
  • LiamPattinson (1)
  • danielskatz (1)
  • letmaik (1)
  • warrickball (1)
  • margomw (1)
  • thepith (1)
  • amicitas (1)
  • singularitti (1)
Top Labels
Issue Labels
bug (5) enhancement (3) sdds (2) duplicate (1) performance (1)
Pull Request Labels
dependencies (2)

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 93,652 last-month
  • Total docker downloads: 545
  • Total dependent packages: 42
    (may contain duplicates)
  • Total dependent repositories: 153
    (may contain duplicates)
  • Total versions: 57
  • Total maintainers: 2
pypi.org: f90nml

Fortran 90 namelist parser

  • Versions: 45
  • Dependent Packages: 35
  • Dependent Repositories: 118
  • Downloads: 93,652 Last month
  • Docker Downloads: 545
Rankings
Dependent packages count: 0.4%
Dependent repos count: 1.4%
Docker downloads count: 2.2%
Downloads: 2.2%
Average: 3.1%
Forks count: 5.9%
Stargazers count: 6.5%
Maintainers (1)
Last synced: 4 months ago
conda-forge.org: f90nml
  • Versions: 9
  • Dependent Packages: 7
  • Dependent Repositories: 35
Rankings
Dependent repos count: 6.2%
Dependent packages count: 8.0%
Average: 18.1%
Forks count: 25.8%
Stargazers count: 32.2%
Last synced: 4 months ago
spack.io: py-f90nml

Fortran 90 namelist parser.

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Forks count: 16.3%
Stargazers count: 17.9%
Average: 22.9%
Dependent packages count: 57.3%
Maintainers (1)
Last synced: 4 months ago

Dependencies

.github/workflows/testing.yaml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
tests/requirements_test.txt pypi
  • coverage ==3.7.1 test
  • coverage * test
  • coveralls * test
  • idna ==2.7 test
  • pycparser ==2.18 test
  • pyyaml * test
setup.py pypi