Registry / serialization / f90nml

f90nml

JSON →
library1.5pypypi✓ verified 85d ago

A Python module for reading and writing Fortran 90 namelist files. Current version is 1.5 with irregular release cadence. Supports parsing, modifying, and writing namelist files, preserving structure and comments.

pip install f90nml
INSTALL
IMPORT
SIG · F90NML
F
f90nml
serializationpythonv1.5
Install
1.5s avg
Import
19ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.020s · 18.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.018s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

f90nml
import f90nml
from f90nml import parse
Wrong because f90nml uses a module-level API; direct import of parse may be unconventional.

Basic usage: read, modify, write namelist files.

import f90nml import os # Read a namelist file nml = f90nml.read('path/to/namelist') # Access a variable print(nml['namelist_name']['variable_name']) # Write back nml.write('output.nml') # Create from dict data = {'namelist': {'var1': 1.0, 'var2': 2}} nml = f90nml.Namelist(data) nml.write('new.nml')
Debug
Known issues
deprecatedThe write() method with a file path is deprecated in favor of using open() and write() with a file object.
fix
Use: with open('file.nml', 'w') as f: nml.write(f)
affects: >=1.4
breakingDuplicate keys behavior changed: in version 1.4, duplicate keys are now stored as Cogroup objects, not lists. Code expecting plain lists will break.
fix
Handle duplicate keys via f90nml.Cogroup or use nml.todict() with dups=True to get list representation.
affects: >=1.4
gotchaEmpty lists in namelist are formatted as comma-delimited blanks (e.g., ',,') instead of an empty line. This can cause confusion when re-parsing.
fix
Use custom formatting or work with string representation if needed.
affects: >=1.4.1
gotchaThe parser treats unquoted strings case-sensitively. Fortran normally treats them case-insensitively, leading to unexpected mismatches.
fix
Manually convert string values to lowercase/uppercase as needed.
affects: all
Errors
Common errors & fixes
AttributeError: module 'f90nml' has no attribute 'Namelist'
Typo in class name: correct is 'Namelist' with capital 'N'.
fix
Use: from f90nml import Namelist or f90nml.Namelist
TypeError: write() argument must be str, not _io.TextIOWrapper
Passing a file object to write() without specifiying mode 'w' or using deprecated string path.
fix
Use: with open('file.nml', 'w') as f: nml.write(f)
ValueError: Invalid key: 'mykey' - key must be a string
Keys passed to Namelist constructor or assignments must be strings.
fix
Ensure all namelist group and variable names are strings.
AttributeError: 'Cogroup' object has no attribute 'append'
Cogroup does not support append; use list-like indexing or extend.
fix
Use: nml['group']['key'].extend([value]) or nml['group']['key'] = f90nml.Cogroup([value1, value2])
Upgrade
Version history
1.5latest on PyPI · released Oct 7, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
18
Resources
f90nml — pip install f90nml · libregistry