Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scivision/fortran-namelist
Python and Matlab readers for Fortran namelist => dict / struct
https://github.com/scivision/fortran-namelist
fortran namelist
Last synced: 10 days ago
JSON representation
Python and Matlab readers for Fortran namelist => dict / struct
- Host: GitHub
- URL: https://github.com/scivision/fortran-namelist
- Owner: scivision
- License: mit
- Created: 2019-09-17T15:47:40.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-08T02:47:01.000Z (over 3 years ago)
- Last Synced: 2025-01-20T11:02:00.163Z (13 days ago)
- Topics: fortran, namelist
- Language: MATLAB
- Homepage:
- Size: 22.5 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fortran Namelist Reader
![ci](https://github.com/scivision/fortran-namelist/workflows/ci/badge.svg)
Pure Python and Matlab **readers** for
[Fortran namelist](https://github.com/scivision/fortran2018-examples/tree/master/namelist)
=> dict / structThese are as basic as possible, for putting in your own program directly.
They output dict (Python) or struct (Matlab).Consider
[f90nml](https://github.com/marshallward/f90nml)
for a full-featured read/write Fortran namelist Python package.## Python
```python
from read_namelist import read_namelistprint(read_namelist('example.nml', 'base'))
```## Matlab
```octave
read_namelist('example.nml', 'base')
```## Examples
[read.f90](./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.