Parser for gfortran's Fortran module file format.
Project description
gfModParser
Parser for gfortran's Fortran module file format.
Requires gfortran>=8.0, Works with python >= 3.9
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 involes 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 convienance classes to make life easier:
import gfModParser as gf
mod = gf.Module("fortran.mod")
# Stores all module level varibles
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 fucntions 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 returnd 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gfmodparser-1.0.1.tar.gz.
File metadata
- Download URL: gfmodparser-1.0.1.tar.gz
- Upload date:
- Size: 1.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b444a5d1ff5a3526ed7f1d09b53a00913fca80c543034e822ccd9e4d96d5b83a
|
|
| MD5 |
ac39c8434800f4f45dd821b300b37942
|
|
| BLAKE2b-256 |
44e7b19da02b763e8ba315eafb716e43bc5dd48fbf58a5ab5f65b0ebfeefa719
|
Provenance
The following attestation bundles were made for gfmodparser-1.0.1.tar.gz:
Publisher:
pypi.yml on rjfarmer/gfModParser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gfmodparser-1.0.1.tar.gz -
Subject digest:
b444a5d1ff5a3526ed7f1d09b53a00913fca80c543034e822ccd9e4d96d5b83a - Sigstore transparency entry: 569573110
- Sigstore integration time:
-
Permalink:
rjfarmer/gfModParser@43f71c7a1173a66eb0110fc4f19eacd078f678ee -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/rjfarmer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@43f71c7a1173a66eb0110fc4f19eacd078f678ee -
Trigger Event:
push
-
Statement type:
File details
Details for the file gfmodparser-1.0.1-py3-none-any.whl.
File metadata
- Download URL: gfmodparser-1.0.1-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
300e38969c98ea13cebdc49b8661f6ec68c37e95b8c48e55e7039c7fc93a7285
|
|
| MD5 |
71d696a005189c853384430dfee0590b
|
|
| BLAKE2b-256 |
2e32a60746ce03a6f918fe8296cf203b772cdd1cdd0d69639c95e16052bbad2d
|
Provenance
The following attestation bundles were made for gfmodparser-1.0.1-py3-none-any.whl:
Publisher:
pypi.yml on rjfarmer/gfModParser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gfmodparser-1.0.1-py3-none-any.whl -
Subject digest:
300e38969c98ea13cebdc49b8661f6ec68c37e95b8c48e55e7039c7fc93a7285 - Sigstore transparency entry: 569573142
- Sigstore integration time:
-
Permalink:
rjfarmer/gfModParser@43f71c7a1173a66eb0110fc4f19eacd078f678ee -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/rjfarmer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@43f71c7a1173a66eb0110fc4f19eacd078f678ee -
Trigger Event:
push
-
Statement type: