Sandbox for playing around with the possibility of using FortWrap with ThermoPack.
The dummy test-case is:
constants.f90
: Module that isuse
'd by all other modules, but is not wrapped.BaseEoS
: Abstract class- Inheriting classes must override
Fres
- Implements
Fideal
, dummy function for ideal gas residual helmholtz energy - Implements
pressure
, which callsFres
andFideal
- Inheriting classes must override
NotIdGas
: Indirecteos.f90
- Concrete class inheriting fromBaseEoS
VariantEoS
: InVariants.f90
- Abstract class inheriting fromBaseEoS
- Inheriting classes must override
internal_comp
- Also contains two parameters not found in
BaseEoS
(param1
andparam2
) - Implements
variant_common_comp
Variant1
: Concrete class inheriting fromVariantEoS
- Implements
internal_comp
- Implements
Fres
, which callsinternal_comp
andvariant_common_comp
- Implements
Variant2
: Concrete class inheriting fromVariantEoS
- Implements
internal_comp
, but differently thanVariant1
- Implements
Fres
, which callsinternal_comp
andvariant_common_comp
- Implements
- Inheriting classes must override
Some changes have been made to FortWrap in order to make the wrapping work, and to automate generation of PyBind11 bindings.
Moving forward:
- Implement internal computations that are not wrapped, to ensure that it is possible to make a minimal wrapper.
- Improve robustness of pybind-bindings generation.
First: Navigate to the top-level directory of the fortwrap
project (where setup.py
is found) and pip install -e .
Then: Navigate to the fortwrap_thermopack_demo
directory (this directory, from now referred to as demo
).
Run the script build.sh
, which does the following:
- Compile the Fortran source
- Build the archive
libdemo_fortran.a
- Move the archive and
.mod
files to thedemo/wrappers
directory - Run
python -m fortwrap -g -i ../FortWrapOptions.txt
from thedemo/src
directory - Compile the resulting
FortranISOWrappers.f90
and add it to thelibdemo_fortran.a
archive - Compile the
.cpp
files in thedemo/wrappers
directory - Compile
demo/main.cpp
To build the python wrappings, you must additionally run cmake .. && make
from the demo/wrappers/build
directory.
The demo/wrappers/CMakeLists.txt
does the following:
- Define the
pybind_module
target - Add the
demo/wrappers/.cpp
files to the target- It is the binding module
pybind11_bindings.cpp
that is used, notbindings.cpp
- It is the binding module
- Link to the archive
libdemo_fortran.a
- Link to
libgfortran.dylib