Skip to content

Commit

Permalink
Merge pull request #65 from jacobwilliams/develop
Browse files Browse the repository at this point in the history
clean up build system and ci
  • Loading branch information
jacobwilliams authored Feb 27, 2022
2 parents 5c0f836 + d336b67 commit 39db432
Show file tree
Hide file tree
Showing 25 changed files with 117 additions and 378 deletions.
70 changes: 30 additions & 40 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
gcc_v: [9] # Version of GFortran we want to use.
python-version: [3.7]
gcc_v: [10] # Version of GFortran we want to use.
python-version: [3.9]
env:
FC: gfortran-${{ matrix.gcc_v }}
GCC_V: ${{ matrix.gcc_v }}
Expand All @@ -28,56 +28,46 @@ jobs:
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1

- name: Setup Fortran Package Manager
uses: fortran-lang/setup-fpm@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Python dependencies
if: contains( matrix.os, 'ubuntu')
run: |
python -m pip install --upgrade pip
pip install ford FoBiS.py numpy matplotlib
pip install ford numpy matplotlib
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install GFortran Linux
if: contains( matrix.os, 'ubuntu')
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y gcc-${GCC_V} gfortran-${GCC_V}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
--slave /usr/bingcov gcov /usr/bin/gcov-${GCC_V}
- name: Compile
run: |
FoBiS.py build -f bspline-fortran.fobis -mode tests-gnu
- name: bspline_test
run: ./bin/bspline_test

- name: bspline_test_2
run: ./bin/bspline_test_2

- name: bspline_extrap_test
run: ./bin/bspline_extrap_test
sudo apt-get install lcov
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.gcc_v }} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ matrix.gcc_v }} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ matrix.gcc_v }}
- name: test_regrid
run: ./bin/test_regrid
# - name: Compile
# run: fpm build --profile release

- name: knot_tests
run: ./bin/knot_tests
- name: Run tests
run: fpm test --profile debug --flag -coverage

- name: speed_test_oo
run: ./bin/speed_test_oo

- name: speed_test
run: ./bin/speed_test

- name: test_integrate
run: ./bin/test_integrate

- name: test_oo
run: ./bin/test_oo

- name: dbint4_test
run: ./bin/dbint4_test
- name: Create coverage report
run: |
mkdir -p ${{ env.COV_DIR }}
lcov --capture --initial --base-directory . --directory build/gfortran_*/ --output-file ${{ env.COV_DIR }}/coverage.base
lcov --capture --base-directory . --directory build/gfortran_*/ --output-file ${{ env.COV_DIR }}/coverage.capture
lcov --add-tracefile ${{ env.COV_DIR }}/coverage.base --add-tracefile ${{ env.COV_DIR }}/coverage.capture --output-file ${{ env.COV_DIR }}/coverage.info
env:
COV_DIR: build/coverage

- name: Upload coverage report
uses: codecov/codecov-action@v2
with:
files: build/coverage/coverage.info

- name: Build documentation
run: ford ./bspline-fortran.md
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

53 changes: 1 addition & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
cmake_minimum_required(VERSION 3.11)

set( CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/install"
CACHE STRING "Select where to install the library and test programs." )
CACHE STRING "Select where to install the library." )

project(bspline-fortran NONE)

Expand Down Expand Up @@ -50,20 +50,6 @@ set( SOURCES
src/bspline_oo_module.f90
src/bspline_sub_module.f90 )

set( PYPLOT_SOURCES
src/tests/pyplot-fortran/src/pyplot_module.f90 )

set( TEST_SOURCES src/tests/bspline_extrap_test.f90
src/tests/bspline_test.f90
src/tests/bspline_test_2.f90
src/tests/dbint4_test.f90
src/tests/knot_tests.f90
src/tests/speed_test.f90
src/tests/speed_test_oo.f90
src/tests/test_integrate.f90
src/tests/test_oo.f90
src/tests/test_regrid.f90 )

set(INSTALL_MOD_DIR "lib")
set(INSTALL_LIB_DIR "${INSTALL_MOD_DIR}")
set(ABS_LIB_INSTALL_DIR "\${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}")
Expand Down Expand Up @@ -103,43 +89,6 @@ set_target_properties(${LIB_NAME}
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR})

set( BSPLINE_TESTS TRUE CACHE BOOL "Enable the unit tests." )

if( BSPLINE_TESTS )

# we also need to build the pyplot-fortran library,
# since that is needed by some of the tests:
set( PYPLOT_LIB_NAME "pyplot-fortran" )
add_library( ${PYPLOT_LIB_NAME} STATIC ${PYPLOT_SOURCES} )
set_target_properties(${PYPLOT_LIB_NAME}
PROPERTIES
OUTPUT_NAME ${PYPLOT_LIB_NAME}
if(NOT MSVC_IDE)
PREFIX lib
endif()
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
Fortran_MODULE_DIRECTORY ${MODULE_DIR})

# build each test program:
foreach( UNIT_TEST ${TEST_SOURCES} )
get_filename_component( TEST ${UNIT_TEST} NAME_WE )
if(MSVC_IDE)
link_directories(${CMAKE_BINARY_DIR}/lib)
endif()
add_executable( ${TEST} ${UNIT_TEST} )
target_link_libraries( ${TEST} ${LIB_NAME}-static ${PYPLOT_LIB_NAME} )
set_target_properties(${TEST}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
Fortran_MODULE_DIRECTORY ${MODULE_DIR})
install(TARGETS ${TEST} ${TEST}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endforeach()

endif()

# install library:
install( TARGETS ${LIB_NAME} ${LIB_NAME}-static
LIBRARY DESTINATION "${INSTALL_LIB_DIR}"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSPLINE-FORTRAN: Multidimensional B-Spline Interpolation of Data on a Regular Grid

Copyright (c) 2015-2021, Jacob Williams
Copyright (c) 2015-2022, Jacob Williams
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
81 changes: 59 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
![bspline-fortran](/media/bspline-fortran.png)
============

bspline-fortran [![GitHub release](https://img.shields.io/github/release/jacobwilliams/bspline-fortran.svg?style=plastic)](https://github.com/jacobwilliams/bspline-fortran/releases/latest) [![DOI](https://zenodo.org/badge/31299552.svg)](https://zenodo.org/badge/latestdoi/31299552)
============

Multidimensional B-Spline Interpolation of Data on a Regular Grid

# Status
## Status

[![GitHub release](https://img.shields.io/github/release/jacobwilliams/bspline-fortran.svg?style=plastic)](https://github.com/jacobwilliams/bspline-fortran/releases/latest)
![Build Status](https://github.com/jacobwilliams/bspline-fortran/actions/workflows/CI.yml/badge.svg)
[![codecov](https://codecov.io/gh/jacobwilliams/bspline-fortran/branch/master/graph/badge.svg?token=umusIZ8Ir8)](https://codecov.io/gh/jacobwilliams/bspline-fortran)
[![DOI](https://zenodo.org/badge/31299552.svg)](https://zenodo.org/badge/latestdoi/31299552)

# Brief description
## Brief description

The library provides subroutines for 1D-6D interpolation and extrapolation using B-splines. The code is written in modern Fortran (i.e., Fortran 2003+). There are two ways to use the module, via a basic subroutine interface and an object-oriented interface. Both are thread safe.

Expand Down Expand Up @@ -83,14 +83,62 @@ The library also contains routines for computing definite integrals of bsplines.

Note that extrapolation is not currently supported for these.

# Examples
## Examples

See the [examples](https://github.com/jacobwilliams/bspline-fortran/tree/master/src/tests) for more details. Note that, to compile and run some of the test programs, the [pyplot_module.f90](https://github.com/jacobwilliams/pyplot-fortran) file (which is used to generate plots) must be copied into the `src/tests` directory.

# Compiling
## Compiling

The library can be compiled with recent versions the Intel Fortran Compiler and GFortran (and presumably any other Fortran compiler that supports modern standards).

### FPM

A `fmp.toml` file is provided for compiling bspline-fortran with the [Fortran Package Manager](https://github.com/fortran-lang/fpm). For example, to build:

```
fpm build --profile release
```

By default, the library is built with double precision (`real64`) real values and single precision (`int32`) integer values. Explicitly specifying the real or integer kinds can be done using the following processor flags:

Preprocessor flag | Kind | Number of bytes
----------------- | ----- | ---------------
`REAL32` | `real(kind=real32)` | 4
`REAL64` | `real(kind=real64)` | 8
`REAL128` | `real(kind=real128)` | 16

Preprocessor flag | Kind | Number of bytes
----------------- | ----- | ---------------
`INT8` | `integer(kind=int8)` | 1
`INT16` | `integer(kind=int16)` | 2
`INT32` | `integer(kind=int32)` | 4
`INT64` | `integer(kind=int64)` | 8

For example, to build a single precision version of the library, use:

```
fpm build --profile release --flag "-DREAL32"
```

A simple bash script ```build.sh``` is provided for building bspline-fortran with gfortran using [FoBiS](https://github.com/szaghi/FoBiS). It also builds the API documentation using [FORD](https://github.com/Fortran-FOSS-Programmers/ford). The library can also be compiled with the Intel Fortran Compiler (and presumably any other Fortran compiler that supports modern standards).
To run the unit tests:

```
fpm test --profile release
```

To use `bspline-fortran` within your fpm project, add the following to your `fpm.toml` file:
```toml
[dependencies]
bspline-fortran = { git="https://github.com/jacobwilliams/bspline-fortran.git" }
```

or, to use a specific version:
```toml
[dependencies]
bspline-fortran = { git="https://github.com/jacobwilliams/bspline-fortran.git", tag = "6.1.0" }
```

### CMake
A basic CMake configuration file is also included. For example, to build a static library:

```bash
Expand All @@ -111,21 +159,10 @@ For a debug build:
cmake -DCMAKE_BUILD_TYPE=DEBUG ..
```

A [FoBiS](https://github.com/szaghi/FoBiS) configuration file (`bspline-fortran.fobis`) is also provided that can also build the library and examples. Use the `mode` flag to indicate what to build. For example:

* To build all the examples using gfortran: `FoBiS.py build -f bspline-fortran.fobis -mode tests-gnu`
* To build all the examples using ifort: `FoBiS.py build -f bspline-fortran.fobis -mode tests-intel`
* To build a static library using gfortran: `FoBiS.py build -f bspline-fortran.fobis -mode static-gnu`
* To build a static library using ifort: `FoBiS.py build -f bspline-fortran.fobis -mode static-intel`

The full set of modes are: `static-gnu`, `static-gnu-debug`, `static-intel`, `static-intel-debug`, `shared-gnu`, `shared-gnu-debug`, `shared-intel`, `shared-intel-debug`, `tests-gnu`, `tests-gnu-debug`, `tests-intel`, `tests-intel-debug`

To generate the documentation using [ford](https://github.com/Fortran-FOSS-Programmers/ford), run: ```FoBis.py rule --execute makedoc -f bspline-fortran.fobis```

# Documentation
## Documentation

The latest API documentation can be found [here](http://jacobwilliams.github.io/bspline-fortran/). This was generated from the source code using [FORD](https://github.com/Fortran-FOSS-Programmers/ford) (note that the build script will also generate these files).
The latest API documentation can be found [here](https://jacobwilliams.github.io/bspline-fortran/). This was generated from the source code using [FORD](https://github.com/Fortran-FOSS-Programmers/ford) (i.e. by running `ford bspline-fortran.md`).

# License
## License

The bspline-fortran source code and related files and documentation are distributed under a permissive free software [license](https://github.com/jacobwilliams/bspline-fortran/blob/master/LICENSE) (BSD-style).
Loading

0 comments on commit 39db432

Please sign in to comment.