gfModParser
Parser for gfortran's Fortran module file format.
Requires gfortran>=8.0, Works with python >= 3.10
GFortran module source code https://github.com/gcc-mirror/gcc/blob/master/gcc/fortran/module.cc
Build
Installing locally:
python -m pip install .
or install via PyPi
python -m pip install --upgrade --user gfModParser
Development
python -m pip install .[dev] # Development tools
python -m pip install .[test] # Tools needs for running pytest
black is used to lint the Python code, so before starting development install the pre-commit hook:
pre-commit install
This will then run black for the Python and zizmor for the workflows yml files.
python -m pytest --cov gfModParser --cov-report html # Generate coverage report
Usage
Basic usage involves loading a module then exploring what it offers:
import gfModParser as gf
mod = gf.Module("fortran.mod")
# Get list of all available things in the module
mod.keys()
# Extract a single variable named 'a_variable'
mod['a_variable']
The Module class provides all the information known about a thing, but can be complicated to use. So there exists some convenience classes to make life easier:
import gfModParser as gf
mod = gf.Module("fortran.mod")
# Stores all module level variables
variables = gf.Variables(mod)
# Stores all module level parameters
parameters = gf.Parameters(mod)
# Stores all module level procedures
procedures = gf.Procedures(mod)
# Stores all module level derived types
dt = gf.DerivedTypes(mod)
Each acts like a dict, with a keys() function to list available members and __contains__ for lookup. Each class is accessed like a dict so variables['a_variable'] is the same as mod['a_variable']
Variables
The Variables class also contains functions for quick reference to the type and kind of a variable
variables.type('a_variable')
variables.kind('a_variable')
and array provides information on its array status:
variables.array('a_variable').is_array
variables.array('a_variable').shape # etc
Parameter
Has the same functions as Variables but also a method for returning the value of the parameter:
parameters.value('a_parameter')
Procedures
The return value of a Fortran function (None if a subroutine) can be accessed via:
result = procedures.result('a_function')
# This can be fed back into Variables
variables.type(result)
Arguments to the procedure can be accessed via, and returned as a dict:
args = procedures.arguments('a_function')
# This can be fed back into Variables class
variables.type(result['a_argument'])
Derived types
The components of a derived type can be found with (returned as a dict):
components = dt.components('A_dt')
Note the use of a captial first letter, this is required to find the definition. Also a derived type component is not like a function argument and can not be fed back into the Variables class (they are not stored in the same way as procedure arguments).
License
gfModParser is distributed under the GPLv2 or later.
Metadata
Release files for gfModParser 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gfmodparser-1.2.1.tar.gz | 1.9 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gfmodparser-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.9 MB
Release files / gfmodparser-1.2.1.tar.gz
| Download URL | gfmodparser-1.2.1.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93893534d9a536cae78b213f719524aaf8be43ff3d9053be64637d699aa1bdaf
|
|
BLAKE2b-256 checksum How to use checksums |
e933ec92c1ee0cac65edac468fead6439c9d8e7d59cab6a5bd2737f66e6af5a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 30, 2026.
Transparency logRelease files / gfmodparser-1.2.1-py3-none-any.whl
| Download URL | gfmodparser-1.2.1-py3-none-any.whl |
|---|---|
| Size | 26.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d47c7fad1c86b69ccbdd20239f0011b5142c1669732a4680ab92de344e0faae
|
|
BLAKE2b-256 checksum How to use checksums |
44f873df5c78f1b09f28d39674ce9258e1bec3515f7f8bdf8a03e45573b9b129
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 30, 2026.
Transparency log