Skip to content

Commit 619e769

Browse files
Merge pull request #17 from jchristopherson/fpm
Added FPM support
2 parents 9d3170e + c102834 commit 619e769

21 files changed

Lines changed: 425 additions & 10467 deletions

.github/workflows/cmake.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CMake
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
env:
10+
BUILD_TYPE: Release
11+
12+
jobs:
13+
test:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, macos-latest]
19+
toolchain:
20+
- {compiler: gcc, version: 11}
21+
- {compiler: intel-classic, version: '2021.9'}
22+
include:
23+
- os: ubuntu-latest
24+
toolchain: {compiler: intel, version: '2023.2'}
25+
26+
steps:
27+
- uses: awvwgk/setup-fortran@v1
28+
id: setup-fortran
29+
with:
30+
compiler: ${{ matrix.toolchain.compiler }}
31+
version: ${{ matrix.toolchain.version }}
32+
33+
- run: ${{ env.FC }} --version
34+
env:
35+
FC: ${{ steps.setup-fortran.outputs.fc }}
36+
CC: ${{ steps.setup-fortran.outputs.cc }}
37+
38+
- uses: actions/checkout@v3
39+
40+
- name: Configure CMake
41+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_Fortran_COMPILER=${{ env.FC }} -DBUILD_TESTING=TRUE
42+
43+
- name: Build with CMake
44+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
45+
46+
- name: Test with CMake
47+
working-directory: ${{github.workspace}}/build
48+
run: ctest -C ${{env.BUILD_TYPE}}

.github/workflows/fpm.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: fpm
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
gcc-build:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os: [ubuntu-latest, macos-11]
12+
gcc_v: [10] # Version of GFortran we want to use.
13+
include:
14+
- os: ubuntu-latest
15+
os-arch: linux-x86_64
16+
17+
- os: macos-11
18+
os-arch: macos-x86_64
19+
20+
env:
21+
FC: gfortran
22+
GCC_V: ${{ matrix.gcc_v }}
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v1
27+
28+
- name: Install GFortran macOS
29+
if: contains(matrix.os, 'macos')
30+
run: |
31+
ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
32+
which gfortran-${GCC_V}
33+
which gfortran
34+
35+
- name: Install GFortran Linux
36+
if: contains(matrix.os, 'ubuntu')
37+
run: |
38+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
39+
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
40+
--slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V}
41+
42+
- name: Install fpm
43+
uses: fortran-lang/setup-fpm@v3
44+
with:
45+
fpm-version: 'v0.8.2'
46+
47+
- name: Build FERROR
48+
run: |
49+
gfortran --version
50+
fpm build
51+
52+
- name: Run tests
53+
run: |
54+
gfortran --version
55+
fpm test
56+
57+
msys2-build:
58+
runs-on: windows-latest
59+
defaults:
60+
run:
61+
shell: msys2 {0}
62+
63+
steps:
64+
- uses: actions/checkout@v2
65+
- uses: msys2/setup-msys2@v2
66+
with:
67+
msystem: MINGW64
68+
update: true
69+
path-type: inherit
70+
install: |
71+
mingw-w64-x86_64-gcc-fortran
72+
mingw-w64-x86_64-fpm
73+
74+
- name: fpm build
75+
run: |
76+
gfortran --version
77+
fpm --version
78+
fpm build
79+
80+
- name: fpm test
81+
run: |
82+
fpm test
83+
84+
intel-build:
85+
runs-on: ubuntu-latest
86+
strategy:
87+
fail-fast: false
88+
89+
env:
90+
FPM_FC: ifort
91+
FC: ifort
92+
93+
steps:
94+
- name: Checkout code
95+
uses: actions/checkout@v3
96+
97+
- name: Add Intel repository (Linux)
98+
run: |
99+
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
100+
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
101+
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
102+
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
103+
sudo apt-get update
104+
105+
- name: Install Intel oneAPI compiler (Linux)
106+
run: |
107+
sudo apt-get install intel-oneapi-compiler-fortran
108+
109+
- name: Setup Intel oneAPI environment
110+
run: |
111+
source /opt/intel/oneapi/setvars.sh
112+
printenv >> $GITHUB_ENV
113+
114+
- name: Install fpm
115+
uses: fortran-lang/setup-fpm@v3
116+
with:
117+
fpm-version: 'v0.8.2'
118+
119+
- name: fpm build
120+
run: |
121+
ifort --version
122+
fpm --version
123+
fpm build --profile debug --flag "-warn nointerfaces"
124+
125+
- name: fpm test
126+
run: |
127+
fpm test --profile debug --flag "-warn nointerfaces"

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ add_fortran_library(
2828
link_library(${PROJECT_NAME} ${ferror_LIBRARY} ${ferror_INCLUDE_DIR})
2929
link_library(${PROJECT_NAME} ${iso_varying_string_LIBRARY} ${iso_varying_string_INCLUDE_DIR})
3030
link_library(${PROJECT_NAME} ${collections_LIBRARY} ${collections_INCLUDE_DIR})
31+
link_library(${PROJECT_NAME} ${geompack_LIBRARY} ${geompack_INCLUDE_DIR})
3132

3233
# Installation
3334
# add_subdirectory(install)
@@ -43,3 +44,14 @@ if (BUILD_FPLOT_EXAMPLES)
4344
# Build the examples
4445
add_subdirectory(examples)
4546
endif()
47+
48+
# ------------------------------------------------------------------------------
49+
# TESTING
50+
# ------------------------------------------------------------------------------
51+
option(BUILD_TESTING "Build tests")
52+
include(CTest)
53+
message(STATUS "Build tests: ${BUILD_TESTING}")
54+
if (BUILD_TESTING)
55+
enable_testing()
56+
add_subdirectory(test)
57+
endif()

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# fplot
22
A Fortran library providing a convenient interface for plotting with Gnuplot.
33

4+
5+
## Status
6+
![Build Status](https://github.com/jchristopherson/fplot/actions/workflows/cmake.yml/badge.svg)
7+
[![Actions Status](https://github.com/jchristopherson/fplot/workflows/fpm/badge.svg)](https://github.com/jchristopherson/fplot/actions)
8+
49
## Gnuplot
510
This library is tailored to write script files for Gnuplot. As such, Gnuplot is required to make use of the output of this library. Gnuplot can be found [here](http://www.gnuplot.info/).
611

@@ -336,10 +341,20 @@ This is the plot resulting from the above program.
336341
![](images/polar_example_1.png?raw=true)
337342

338343
## Building FPLOT
339-
This library can be built using CMake. For instructions see [Running CMake](https://cmake.org/runningcmake/).
344+
[CMake](https://cmake.org/)This library can be built using CMake. For instructions see [Running CMake](https://cmake.org/runningcmake/).
345+
346+
[FPM](https://github.com/fortran-lang/fpm) can also be used to build this library using the provided fpm.toml.
347+
```txt
348+
fpm build
349+
```
350+
The FPLOT library can be used within your FPM project by adding the following to your fpm.toml file.
351+
```
352+
[dependencies]
353+
fplot = { git = "https://github.com/jchristopherson/fplot" }
340354
341355
## External Libraries
342356
The FPLOT library depends upon the following libraries.
343357
- [FERROR](https://github.com/jchristopherson/ferror)
344358
- [COLLECTIONS](https://github.com/jchristopherson/collections)
345359
- [ISO_VARYING_STRING](https://gitlab.com/everythingfunctional/iso_varying_string)
360+
- [GEOMPACK](https://github.com/jchristopherson/geompack)

dependencies/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@ set(iso_varying_string_INCLUDE_DIR ${iso_varying_string_INCLUDE_DIR} PARENT_SCOP
1515
# Get COLLECTIONS
1616
add_subdirectory(collections)
1717
set(collections_LIBRARY ${collections_LIBRARY} PARENT_SCOPE)
18-
set(collections_INCLUDE_DIR ${collections_INCLUDE_DIR} PARENT_SCOPE)
18+
set(collections_INCLUDE_DIR ${collections_INCLUDE_DIR} PARENT_SCOPE)
19+
20+
# Get GEOMPACK
21+
add_subdirectory(geompack)
22+
set(geompack_LIBRARY ${geompack_LIBRARY} PARENT_SCOPE)
23+
set(geompack_INCLUDE_DIR ${geompack_INCLUDE_DIR} PARENT_SCOPE)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Get the macros and functions we'll need
2+
include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake")
3+
include(FetchContent)
4+
5+
# Fetch the proper content
6+
FetchContent_Declare(
7+
geompack
8+
GIT_REPOSITORY "https://github.com/jchristopherson/geompack"
9+
GIT_TAG main
10+
)
11+
12+
FetchContent_MakeAvailable(geompack)
13+
14+
if (WIN32)
15+
if (BUILD_SHARED_LIBS)
16+
add_custom_command(
17+
TARGET ${PROJECT_NAME} POST_BUILD
18+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
19+
$<TARGET_FILE:geompack>
20+
$<TARGET_FILE_DIR:${PROJECT_NAME}>
21+
)
22+
endif()
23+
endif()
24+
25+
set(geompack_INCLUDE_DIR ${geompack_BINARY_DIR}/include)
26+
set(geompack_INCLUDE_DIR ${geompack_INCLUDE_DIR} PARENT_SCOPE)
27+
28+
# Make a parent-scope variable for the library
29+
set(geompack_LIBRARY geompack)
30+
set(geompack_LIBRARY ${geompack_LIBRARY} PARENT_SCOPE)

fpm.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name = "fplot"
2+
version = "1.6.2"
3+
license = "GPL-3.0"
4+
author = "Jason Christopherson"
5+
maintainer = "Jason Christopherson"
6+
copyright = "Copyright 2017-2023, Jason Christopherson"
7+
description = "A Fortran library providing a convenient interface for plotting with Gnuplot."
8+
homepage = "https://github.com/jchristopherson/fplot"
9+
10+
[library]
11+
source-dir = "src"
12+
13+
[dependencies]
14+
ferror = { git = "https://github.com/jchristopherson/ferror" }
15+
collections = { git = "https://github.com/jchristopherson/collections" }
16+
iso_varying_string = { git = "https://gitlab.com/everythingfunctional/iso_varying_string" }
17+
geompack = { git = "https://github.com/jchristopherson/geompack" }
18+
19+
[install]
20+
library = true
21+
22+
[build]
23+
auto-executables = false
24+
auto-examples = false
25+
auto-tests = false
26+
27+
[[test]]
28+
name = "fplot_test"
29+
source-dir = "test"
30+
main = "fplot_test.f90"

src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ set(FPLOT_SOURCES
3939
${dir}/fplot_vector_field_plot_data.f90
4040
${dir}/fplot_plot_polar.f90
4141
${dir}/fplot_filled_plot_data.f90
42-
${dir}/geompack.f
43-
${dir}/tripack.f
4442
${dir}/fplot_string_builder.f90
4543
${dir}/fplot_string_builder_implementation.f90
4644
${dir}/fplot_triangulations_delaunay_2d.f90

0 commit comments

Comments
 (0)