Skip to content

Python and Matlab readers for Fortran namelist => dict / struct

License

Notifications You must be signed in to change notification settings

scivision/fortran-namelist

Repository files navigation

Fortran Namelist Reader

ci

Pure Python and Matlab readers for Fortran namelist => dict / struct

These are as basic as possible, for putting in your own program directly. They output dict (Python) or struct (Matlab).

Consider f90nml for a full-featured read/write Fortran namelist Python package.

Python

from read_namelist import read_namelist

print(read_namelist('example.nml', 'base'))

Matlab

read_namelist('example.nml', 'base')

Examples

read.f90 example shows that one must allocate arrays before reading a namelist array variable. Character can be read with a variable (much) longer than known needed, then trim() to another allocatable character variable. Despite what some forums say, reading namelist directly into allocatable just segfaults with Intel or GCC compilers.