Skip to content

stfc/dl_py2f-example

Repository files navigation

DL_PY2F Example

GNU

About

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.

License

DL_PY2F example is open source and released under GNU Lesser General Public License v3.0. It is available for download from the repository.

Citing DL_PY2F

Applications using DL_PY2F should cite:

You Lu and Thomas W. Keal, Journal of Open Source Software, in preparation

Project status

The Python-to-Fortran interoperability demonstrated in DL_PY2F example has been comprehensively tested using both GNU and Intel compilers.

⚠️ Warning: However, the method for Fortran-to-Python interoperability demonstrated in 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.

Getting started

Required libraries and tools

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.

⚠️ The Fortran-to-Python method does NOT yet work with the Intel compilers as Intel's proprietary .mod file format is unpublished and unsupported.

Compiling

Using DL_PY2F source code

For compiling and running this example application with the source code of DL_PY2F, please follow the steps (bash environment assumed here)

  1. 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

  1. Navigating to the example package's source package (which contains this README.md file):

$ cd my_copy

  1. There is a subdirectory for an example application project:

$ cd example

  1. Cloning DL_PY2F from the repository:

$ git clone https://github.com/stfc/dl_py2f.git dl_py2f

  1. Making a directory for building

$ mkdir build

$ cd build

  1. 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.

Using system installed DL_PY2F (Debian only)

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

⚠️ Since Debian PPA does not allow underscore _, 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.

Running

There is an exemplar user input script for launching the example project. To run it, please

  1. Navigating to the example package's source package (which contains the current README.md file):

$ cd my_copy

  1. Define the environment variable PYTHONPATH for the example application project:

$ export PYTHONPATH=my_copy

  1. 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.

Cleaning

$ cd example/build

$ make clean

💡 There is also a bash script compile.sh containing all the above steps which is ready for executing.

Miscellaneous

Support

Please raise an Issue on the project's page if you have a question about the code.

Contributing

Contributions are welcome in the form of Issue/PR on github.com.

Acknowledgements

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •