Skip to content

Commit

Permalink
Set Fortran standards and add tests (#145)
Browse files Browse the repository at this point in the history
* Add tests for different Fortran standards

* Set Fortran 2008 to default standard

* Update README with Fortran standard

* Add dependencies to documentation

---------

Co-authored-by: ElliottKasoar <[email protected]>
  • Loading branch information
2 people authored and dorchard committed Nov 15, 2024
1 parent 92c50a9 commit 5c2bb6e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
test-suite:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
std: ["f2008", "f2018"]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -45,7 +49,7 @@ jobs:
export BUILD_DIR=$(pwd)/src/build
mkdir ${BUILD_DIR}
cd ${BUILD_DIR}
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${BUILD_DIR} -DCMAKE_BUILD_TESTS=TRUE
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${BUILD_DIR} -DCMAKE_BUILD_TESTS=TRUE -DCMAKE_Fortran_FLAGS="-std=${{ matrix.std }}"
cmake --build .
cmake --install .
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**_A library for coupling (Py)Torch machine learning models to Fortran_**

![GitHub](https://img.shields.io/github/license/Cambridge-ICCS/FTorch)
![Fortran](https://img.shields.io/badge/Fortran-2008-purple)

This repository contains code, utilities, and examples for directly calling PyTorch ML
models from Fortran.
Expand Down Expand Up @@ -83,7 +84,7 @@ To install the library requires the following to be installed on the system:

* CMake >= 3.1
* [libtorch](https://pytorch.org/cppdocs/installing.html)<sup>*</sup> or [PyTorch](https://pytorch.org/)
* Fortran, C++ (must fully support C++17), and C compilers
* Fortran (2008 standard compliant), C++ (must fully support C++17), and C compilers

<sup>*</sup> _The minimal example provided downloads the CPU-only Linux Nightly binary. [Alternative versions](https://pytorch.org/get-started/locally/) may be required._

Expand Down
9 changes: 9 additions & 0 deletions pages/cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ Installation of FTorch is done by CMake.

This is controlled by the `CMakeLists.txt` file in `src/`.

## Dependencies

To install the library requires the following to be installed on the system:

- CMake >= 3.1
- libtorch or PyTorch
- Fortran (2008 standard compliant), C++ (must fully support C++17), and C compilers


## Basic instructions

To build the library, first clone it from GitHub to your local machine and then run:
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if(NOT CMAKE_Fortran_FLAGS)
set(CMAKE_Fortran_FLAGS "-std=f2008")
endif()

include(CheckLanguage)
if(ENABLE_CUDA)
check_language(CUDA)
Expand Down

0 comments on commit 5c2bb6e

Please sign in to comment.