This package contains a toy application which demonstrates how to use DL_PY2F for the interoperability in both Python-to-Fortran and Fortran-to-Python ways. The package is also a test bench for validating DL_PY2F.
DL_PY2F example is open source and released under GNU Lesser General Public License v3.0. It is available for download from the repository.
Applications using DL_PY2F should cite:
You Lu and Thomas W. Keal, Journal of Open Source Software, in preparation
The Python-to-Fortran interoperability demonstrated in DL_PY2F example has been comprehensively tested using both GNU and Intel compilers.
DL_PY2F example is still undergoing testing and validation, and is currently limited to use with the GNU compiler gfortran, as the proprietary .mod file format used by the Intel compiler is not yet supported.
| Tools & Libraries | Min. version | Note |
|---|---|---|
| gcc/gfortran | 7.3 | |
| OR icc/ifort | 17 | |
| cmake | 3.16 | |
| python3-dev | 3.8 | |
| python3-numpy | 1.21.5 |
💡 The above package names are based on Ubuntu Linux. They may vary on other operating systems.
For compiling and running this example application with the source code of DL_PY2F, please follow the steps (bash environment assumed here)
- Cloning the example package to, e.g.,
my_copy(you probably have done this already):
$ git clone https://github.com/stfc/dl_py2f-example.git my_copy
- Navigating to the example package's source package (which contains this README.md file):
$ cd my_copy
- There is a subdirectory for an example application project:
$ cd example
- Cloning
DL_PY2Ffrom the repository:
$ git clone https://github.com/stfc/dl_py2f.git dl_py2f
- Making a directory for building
$ mkdir build
$ cd build
- Configuring and compiling using cmake
$ cmake -DFROM_SOURCE:BOOL=TRUE ..; make
Please see the bash script compile_from_source.sh provided by the example package for this method.
DL_PY2F has been published and deployed on launchpad.net and is thus available for installing using apt for Debian-type systems (e.g., Ubuntu):
$ sudo add-apt-repository ppa:dl-py2f/ppa
$ sudo apt update
$ sudo apt install dl-py2f
_, the package name published on launchpad.net is dl-py2f but not dl_py2f.
💡 sudo access is required for installing system-wide packages using apt.
Compiling the example package is similar to the steps of the above method, just without cloning DL_PY2F or telling cmake to use its source code:
$ git clone https://github.com/stfc/dl_py2f-example.git my_copy
$ cd my_copy
$ cd example
$ mkdir build
$ cd build
$ cmake ..; make
Please see the bash script install_with_apt.sh provided by the example package for this method.
There is an exemplar user input script for launching the example project. To run it, please
- Navigating to the example package's source package (which contains the current README.md file):
$ cd my_copy
- Define the environment variable
PYTHONPATHfor the example application project:
$ export PYTHONPATH=my_copy
- Run as a user of your example application:
$ python3 user_script.py
💡 For using DL_PY2F in your own real project, there are more ways to organise the source package's structure.
$ cd example/build
$ make clean
💡 There is also a bash script compile.sh containing all the above steps which is ready for executing.
Please raise an Issue on the project's page if you have a question about the code.
Contributions are welcome in the form of Issue/PR on github.com.
The DL_PY2F library was created during the redevelopment of ChemShell as a Python-based package, which was funded by EPSRC under the grant EP/K038419/1. Ongoing support for the development of DL_PY2F as part of ChemShell is provided under EPSRC grants EP/R001847/1 and EP/W014378/1, and the Computational Science Centre for Research Communities (CoSeC), via the support provided to the Materials Chemistry Consortium. We acknowledge helpful discussions and suggestions for improvement from Paul Sherwood, Joseph Thacker, and Thomas Durrant.