Package: f90nml
A Python module and command line tool for parsing Fortran namelist filesDocumentationThe complete documentation forf90nmlis available from Read The Docs.http://f90nml.readthedocs.org/en/latest/About f90nmlf90nmlis 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 anNamelistobject, which
behaves like a standard Pythondict.  Values are converted from Fortran
data types to equivalent primitive Python types.The command line toolf90nmlcan 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 guideTo read a namelist filesample.nmlwhich contains the following namelists:&config_nmlinput='wind.nc'steps=864layout=8,16visc=1.0e-4use_biharmonic=.false./we would use the following script:importf90nmlnml=f90nml.read('sample.nml')which would would pointnmlto the followingdict: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:withopen('sample.nml')asnml_file:nml=f90nml.read(nml_file)To modify one of the values, saysteps, and save the output, just
manipulate thenmlcontents and write to disk using thewritefunction:nml['config_nml']['steps']=432nml.write('new_sample.nml')Namelists can also be saved to file objects:withopen('target.nml')asnml_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 thepatchfunction:patch_nml={'config_nml':{'visc':1e-6}}f90nml.patch('sample.nml',patch_nml,'new_sample.nml')Command line interfaceA command line tool is provided to manipulate namelist files within the shell:$f90nmlconfig.nml-gconfig_nml-vsteps=432&config_nmlinput='wind.nc'steps=432layout=8,16visc=1.0e-4use_biharmonic=.false./See the documentation for details.Installationf90nmlis available on PyPI and can be installed via pip:$ pip install f90nmlThe latest version off90nmlcan be installed from source:$ git clone https://github.com/marshallward/f90nml.git
$ cd f90nml
$ pip install .Package distributionf90nmlis 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 -sriVolunteers are welcome to submit and maintainf90nmlon other
distributions.Local installUsers without install privileges can append the--userflag topipfrom
the topf90nmldirectory:$ pip install --user .If pip is not available, thensetup.pycan still be used:$ python setup.py install --userWhen usingsetup.pylocally, some users have reported that--prefix=may need to be appended to the command:$ python setup.py install --user --prefix=YAML supportThe 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 theyamlextras package:$ pip install f90nml[yaml]To install as a user:$ pip install --user .[yaml]Contributing tof90nmlUsers are welcome to submit bug reports, feature requests, and code
contributions to this project through GitHub.  More information is available in
theContributingguidelines.