Skip to content

Commit

Permalink
Merge pull request #23 from davidpfister/master
Browse files Browse the repository at this point in the history
Speedup, variables length > 1, addition of functions, removal of Destruct...
  • Loading branch information
fluidnumerics-joe authored Feb 2, 2024
2 parents 7922196 + 60511a0 commit d6f9934
Show file tree
Hide file tree
Showing 185 changed files with 2,667 additions and 3,261 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@ jobs:
if: ${{ matrix.memcheck }}
run: |
sudo apt-get install -y valgrind
valgrind --undef-value-erros=no --error-exitcode=1 -s ./build/test/testsuite -A
valgrind --undef-value-errors=no --error-exitcode=1 -s ./build/test/testsuite -A
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.mod
build/
.DS_Store
*.i90
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ Intel oneAPI classic (`ifort`) | 2021.1 | Ubuntu 22.04.2 LTS | `fpm`, `cmake` |

## Usage

> [!NOTE]
> All functions in the equation string must start with a `\`
### Run examples with fpm
> [!NOTE]
> Examples are now included in the `example/` subdirectory
Expand Down Expand Up @@ -153,7 +150,7 @@ IMPLICIT NONE
independentVars = (/ 'x', 'y', 'z' /)
! Specify an equation string that we want to evaluate
eqChar = 'f = \exp( -(x^2 + y^2 + z^2) )'
eqChar = 'f = exp( -(x^2 + y^2 + z^2) )'
! Create the EquationParser object
f = EquationParser(eqChar, independentVars)
Expand Down
9 changes: 3 additions & 6 deletions example/array_with_array_eval.f90
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
program array_with_array_eval

use iso_fortran_env
use FEQParse

implicit none
integer,parameter :: N = 10000000
integer,parameter :: N = 10000
type(EquationParser) :: f
character(LEN=1),dimension(1) :: independentVars
character(LEN=30) :: eqChar
Expand All @@ -16,7 +16,7 @@ program array_with_array_eval
independentVars = (/'x'/)

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

! Create the EquationParser object
f = EquationParser(eqChar,independentVars)
Expand All @@ -30,7 +30,4 @@ program array_with_array_eval
call cpu_time(t2)
print *, "runtime :", (t2 - t1)," s"

! Clean up memory
call f % Destruct()

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

use iso_fortran_env
use FEQParse

implicit none
integer,parameter :: N = 100000
integer,parameter :: N = 100
type(EquationParser) :: f
character(LEN=1),dimension(1) :: independentVars
character(LEN=30) :: eqChar
Expand All @@ -16,7 +16,7 @@ program array_with_scalar_eval
independentVars = (/'x'/)

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

! Create the EquationParser object
f = EquationParser(eqChar,independentVars)
Expand All @@ -30,7 +30,4 @@ program array_with_scalar_eval
call cpu_time(t2)
print *, "runtime :", (t2 - t1)," s"

! Clean up memory
call f % Destruct()

end program array_with_scalar_eval
21 changes: 9 additions & 12 deletions example/gaussian_scalar_multivar.f90
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
program gaussian_scalar_multivar

use iso_fortran_env
use FEQParse

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

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

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

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

! Evaluate the equation
x(1) = 1.0
x(2) = 1.0
print*, f % evaluate(x)
print*, exp(-1.0) -1.0

! Clean up memory
call f % Destruct()


end program gaussian_scalar_multivar
7 changes: 2 additions & 5 deletions example/scalar_function_product.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program scalar_function_product

use iso_fortran_env
use FEQParse

implicit none
Expand All @@ -13,7 +13,7 @@ program scalar_function_product
independentVars = (/'x', 'y'/)

! Specify an equation string that we want to evaluate
eqChar = 'f = \cos( 2.0*pi*x )*\cos( 2.0*pi*y )'
eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )'

! Create the EquationParser object
f = EquationParser(eqChar,independentVars)
Expand All @@ -23,7 +23,4 @@ program scalar_function_product
feval = f % evaluate(x)
print*, feval

! Clean up memory
call f % Destruct()

end program scalar_function_product
7 changes: 2 additions & 5 deletions example/scalar_with_scalar_eval.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program scalar_with_scalar_eval

use iso_fortran_env
use FEQParse

implicit none
Expand All @@ -12,7 +12,7 @@ program scalar_with_scalar_eval
independentVars = (/'x'/)

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

! Create the EquationParser object
f = EquationParser(eqChar,independentVars)
Expand All @@ -21,7 +21,4 @@ program scalar_with_scalar_eval
x(1) = 0.0
print*, f % evaluate(x)

! Clean up memory
call f % Destruct()

end program scalar_with_scalar_eval
46 changes: 46 additions & 0 deletions feq.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"files.exclude": {
"**/.gitignore": true,
"**/site/": true,
"**/.vscode": true,
"**/.vs": true,
"**/*.code-workspace": true,
"**/build": true,
"**/*.i90": true,
"**/*.ud2": true,
"**/*.mod": true,
"**/bin/": true,
"**/obj/": true,
},
"code-runner.defaultLanguage": "fortran",
"cSpell.words": [],
"terminal.integrated.profiles.windows": {
"MYSYS": {
"path": "C:\\msys64\\usr\\bin\\bash.exe",
"args": [
"--login",
"-i"
]
}
},
"terminal.integrated.env.windows": {
"CHERE_INVOKING": "1",
"MSYSTEM": "MINGW64",
"PATH": "${env:PATH}"
},
"fortran.linter.compilerPath": "C:/Program Files (x86)/Intel/oneAPI/compiler/2022.0.3/windows/bin/intel64/ifort.exe",
"fortran.linter.compiler": "ifort",
"fortran.linter.extraArgs": [
"-warn all,noexternal",
"-warn truncated_source"
],
"fortran.formatting.formatter": "fprettify",
"fortran.preferredCase": "uppercase"
}
}
48 changes: 24 additions & 24 deletions fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ name = "unit-tests"
source-dir = "test/fpm"
main = "test.f90"

[[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"

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

[[example]]
name = "gaussian_scalar_multivar"
source-dir = "example"
main = "gaussian_scalar_multivar.f90"
# [[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"

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

# [[example]]
# name = "gaussian_scalar_multivar"
# source-dir = "example"
# main = "gaussian_scalar_multivar.f90"
Loading

0 comments on commit d6f9934

Please sign in to comment.