All Projects → marshallward → F90nml

marshallward / F90nml

Licence: apache-2.0
A Python module and command line tool for working with Fortran namelists

Programming Languages

python
139335 projects - #7 most used programming language
fortran
972 projects

Labels

Projects that are alternatives of or similar to F90nml

Anglesharp.js
👼 Extends AngleSharp with a .NET-based JavaScript engine.
Stars: ✭ 68 (-13.92%)
Mutual labels:  parser
Sequential
An environment to visualize JavaScript code execution in a browser
Stars: ✭ 74 (-6.33%)
Mutual labels:  parser
Mimekit
A .NET MIME creation and parser library with support for S/MIME, PGP, DKIM, TNEF and Unix mbox spools.
Stars: ✭ 1,214 (+1436.71%)
Mutual labels:  parser
Ret.js
Tokenizes a string that represents a regular expression.
Stars: ✭ 70 (-11.39%)
Mutual labels:  parser
Method log
Trace the history of an individual method in a git repository (experimental)
Stars: ✭ 73 (-7.59%)
Mutual labels:  parser
Jetpack.js
A ECMAScript bundler and minifier implemented in C++ aimed at excellent performance.
Stars: ✭ 75 (-5.06%)
Mutual labels:  parser
Oga
Read-only mirror of https://gitlab.com/yorickpeterse/oga
Stars: ✭ 1,147 (+1351.9%)
Mutual labels:  parser
Solidity Antlr4
Solidity grammar for ANTLR4
Stars: ✭ 79 (+0%)
Mutual labels:  parser
Parser
Generate a JSON documentation for a SFC Vue component. Contribute: https://gitlab.com/vuedoc/parser#contribute
Stars: ✭ 74 (-6.33%)
Mutual labels:  parser
Lang C
Lightweight C parser for Rust
Stars: ✭ 77 (-2.53%)
Mutual labels:  parser
Parsing With Haskell Parser Combinators
🔍 A step-by-step guide to parsing using Haskell parser combinators.
Stars: ✭ 72 (-8.86%)
Mutual labels:  parser
Xmlparser
A low-level, pull-based, zero-allocation XML 1.0 parser.
Stars: ✭ 73 (-7.59%)
Mutual labels:  parser
Gutenberg Parser Rs
An experimental Rust parser for WordPress Gutenberg post format
Stars: ✭ 76 (-3.8%)
Mutual labels:  parser
To.ml
OCaml library for TOML
Stars: ✭ 68 (-13.92%)
Mutual labels:  parser
Marko
A markdown parser with high extensibility.
Stars: ✭ 77 (-2.53%)
Mutual labels:  parser
Solid
Liquid template engine in Elixir
Stars: ✭ 68 (-13.92%)
Mutual labels:  parser
Any23
Apache Anything To Triples (Any23) is a library, a web service and a command line tool that extracts structured data in RDF format from a variety of Web documents.
Stars: ✭ 74 (-6.33%)
Mutual labels:  parser
Videoparse
这个可能不再维护了,音乐可以参考KMusic
Stars: ✭ 79 (+0%)
Mutual labels:  parser
Spintax
A Python module for parsing spintax, unlike any other module this works with nested spintax and also allows the user to escape the special characters used in its syntax.
Stars: ✭ 78 (-1.27%)
Mutual labels:  parser
Cat
Plain C library for parsing AT commands for use in host devices.
Stars: ✭ 77 (-2.53%)
Mutual labels:  parser

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

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

.. image:: https://travis-ci.org/marshallward/f90nml.svg?branch=master :target: https://travis-ci.org/marshallward/f90nml

.. 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.1112518.svg :target: https://doi.org/10.5281/zenodo.1112518

Documentation

The complete 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 an Namelist object, which behaves like a standard 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, just 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 .

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].