Skip to content

Commit

Permalink
Merge pull request #6 from FluidNumerics/bugfix/fpm_tests
Browse files Browse the repository at this point in the history
Fix fpm tests program and add fpm tests to ci
  • Loading branch information
fluidnumerics-joe authored Nov 27, 2023
2 parents d440161 + ee101f7 commit ffe61bb
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 4 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ jobs:
compiler: gfortran-11
shell: bash
build_type: debug
- os: ubuntu-22.04
os_name: linux
compiler: gfortran-10
shell: bash
build_type: fpm
defaults:
run:
shell: ${{ matrix.shell }}
Expand All @@ -59,12 +64,21 @@ jobs:
run: |
${{ matrix.compiler }} --version
- name: Build
- name: Build with Cmake
if: ${{ matrix.build_type != 'fpm' }}
run: |
cd build
FC=${{ matrix.compiler }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ../
make VERBOSE=1
- name: fpm tests
if: ${{ matrix.build_type == 'fpm' }}
run: |
wget https://github.com/fortran-lang/fpm/releases/download/v0.9.0/fpm-0.9.0-linux-x86_64
chmod +x ./fpm-0.9.0-linux-x86_64 && mv ./fpm-0.9.0-linux-x86_64 fpm
./fpm install
./fpm run --example "*"
- name: Initialize coverage counters
if: ${{ matrix.build_type == 'coverage' }}
run: |
Expand All @@ -74,6 +88,7 @@ jobs:
--zerocounters
- name: Run ctests
if: ${{ matrix.build_type != 'fpm' }}
run: |
cd build/test
ctest || ctest --rerun-failed --output-on-failure
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ fpm build --profile release
fpm test --profile release
```

You can also run the examples included in the `example/` subdirectory :
```
fpm run --example "*"
```

To use `feq-parse` within your fpm project, add the following to your `fpm.toml` file:
```toml
[dependencies]
Expand Down
36 changes: 36 additions & 0 deletions example/array_with_array_eval.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
program array_with_array_eval

use FEQParse

implicit none
integer,parameter :: N = 10000000
type(EquationParser) :: f
character(LEN=1),dimension(1) :: independentVars
character(LEN=30) :: eqChar
real :: x(1:N,1)
real :: feval(1:N)
integer :: i
real :: t1,t2

! Specify the independent variables
independentVars = (/'x'/)

! Specify an equation string that we want to evaluate
eqChar = 'f = \exp( -(x^2) )'

! Create the EquationParser object
f = EquationParser(eqChar,independentVars)

! Evaluate the equation
call cpu_time(t1)
do i = 1,N
x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32)
end do
feval = f % evaluate(x)
call cpu_time(t2)
print *, "runtime :", (t2 - t1)," s"

! Clean up memory
call f % Destruct()

end program array_with_array_eval
36 changes: 36 additions & 0 deletions example/array_with_scalar_eval.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
program array_with_scalar_eval

use FEQParse

implicit none
integer,parameter :: N = 100000
type(EquationParser) :: f
character(LEN=1),dimension(1) :: independentVars
character(LEN=30) :: eqChar
real :: x(1)
real :: feval(1:N)
integer :: i
real :: t1,t2

! Specify the independent variables
independentVars = (/'x'/)

! Specify an equation string that we want to evaluate
eqChar = 'f = \exp( -(x^2) )'

! Create the EquationParser object
f = EquationParser(eqChar,independentVars)

! Evaluate the equation
call cpu_time(t1)
do i = 1,N
x(1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32)
feval(i) = f % evaluate(x)
end do
call cpu_time(t2)
print *, "runtime :", (t2 - t1)," s"

! Clean up memory
call f % Destruct()

end program array_with_scalar_eval
27 changes: 27 additions & 0 deletions example/scalar_with_scalar_eval.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
program scalar_with_scalar_eval

use FEQParse

implicit none
type(EquationParser) :: f
character(LEN=1),dimension(1) :: independentVars
character(LEN=30) :: eqChar
real :: x(1)

! Specify the independent variables
independentVars = (/'x'/)

! Specify an equation string that we want to evaluate
eqChar = 'f = \exp( -(x^2) )'

! Create the EquationParser object
f = EquationParser(eqChar,independentVars)

! Evaluate the equation
x(1) = 0.0
print*, f % evaluate(x)

! Clean up memory
call f % Destruct()

end program scalar_with_scalar_eval
17 changes: 16 additions & 1 deletion fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,19 @@ auto-tests = true
source-dir = "src"

[install]
library = true
library = true

[[example]]
name = "array_with_array_eval"
source-dir = "example"
main = "array_with_array_eval.f90"

[[example]]
name = "array_with_scalar_eval"
source-dir = "example"
main = "array_with_scalar_eval.f90"

[[example]]
name = "scalar_with_scalar_eval"
source-dir = "example"
main = "scalar_with_scalar_eval.f90"
4 changes: 2 additions & 2 deletions test/test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ program test

contains


include "abs_r1fp32.f90"
include "abs_r1fp64.f90"
include "abs_sfp32.f90"
include "abs_sfp64.f90"
Expand Down Expand Up @@ -73,4 +73,4 @@ program test



end program testinclude "abs_r1fp32.f90"
end program test

0 comments on commit ffe61bb

Please sign in to comment.