fgen.data_models.fortran_derived_type#
Data model of a Fortran derived type
FortranDerivedType#
- class FortranDerivedType(name, description, attributes, methods)[source]#
Bases:
object
Data model of a Fortran derived type
-
attributes:
dict
[str
,fgen.data_models.value.Value
]# The derived type’s attributes
- property exposed_attributes: dict[str, fgen.data_models.value.Value]#
Get the attributes that are marked to be exposed to python
- Returns:
Collection of exposed attributes
- property fortran_units_holder: Optional[str]#
The attribute on the Fortran derived type which holds the units
This is often, but does not necessarily need to be, an attribute named units.
Fortran doesn’t have an equivalent of
pint
, hence units are just held as plain attributes instead. If a provided derived type has such an attribute, it can be accessed via this property- Returns:
Attribute on the Fortran derived type which holds the units.
If no attribute on the Fortran derived type holds units,
None
is returned.
- property fortran_units_holder_reliant_attributes: tuple[str, ...]#
The attributes whose units are reliant on
self.fortran_units_holder
Fortran doesn’t have an equivalent of
pint
, hence units are just held as plain attributes instead. The units of these attributes is defined by the unit holding attribute.- Returns:
Attributes that rely on the Fortran units holder to define their units.
- get_dynamic_unit_source(value)[source]#
Get the source of the dynamic unit for a given value
- Parameters:
value (
typing.Union
[fgen.data_models.multi_return.MultiReturn
,fgen.data_models.value.Value
]) – Value for which to get the source of the dynamic unit- Returns:
typing.Optional
[str
] – Source of the dynamic unit forvalue
-
methods:
dict
[str
,fgen.data_models.method.Method
]# The derived type’s methods
- property units: dict[str, Union[str, tuple[str, ...]]]#
Get the unit for each declared value in the derived type
The unit for a given named value must be consistent across the derived type and the module which defines it. This includes the unit for
attributes
, and in theparameter
andreturn
values for eachmethod
.- Raises:
ValueError – Inconsistent units were found
- Returns:
Dictionary containing value names’ as keys and the associated units
as values.
- property units_multi_return: dict[str, tuple[str, ...]]#
Get units declared in this object, if the units are tuples
This occurs if the units apply to a return statement that returns multiple values
- Returns:
Dictionary containing value names’ as keys and the associated units
as values (all these values are plain strings).
-
attributes: