From 73ab8441e61a7c4a964f738871c51a66e57e2b4a Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 11 Feb 2024 10:32:20 -0500 Subject: [PATCH 01/10] Add linting workflow to execute before other workflows --- .github/workflows/fprettify-lint.yml | 41 ++++++++++++++++++++++++++++ .github/workflows/linux-cmake.yml | 17 +++--------- .github/workflows/linux-fpm.yml | 18 ++++-------- .github/workflows/windows-cmake.yml | 17 +++--------- .github/workflows/windows-fpm.yml | 17 +++--------- fprettify.config | 24 ++++++++++++++++ 6 files changed, 82 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/fprettify-lint.yml create mode 100644 fprettify.config diff --git a/.github/workflows/fprettify-lint.yml b/.github/workflows/fprettify-lint.yml new file mode 100644 index 0000000..37fe4c3 --- /dev/null +++ b/.github/workflows/fprettify-lint.yml @@ -0,0 +1,41 @@ +name: fprettify-lint + +on: + push: + branches: + - master + - main + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + pull_request: + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + +jobs: + fprettify: + name: fprettify-check + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + defaults: + run: + shell: bash + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + + - name: Check for formatting differences + run: | + pip3 install fprettify + if [[ $(fprettify './src/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1) ]]; then + fprettify './src/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1 + exit 1 + else + echo "linting passed!" + fi + \ No newline at end of file diff --git a/.github/workflows/linux-cmake.yml b/.github/workflows/linux-cmake.yml index 3d8bf81..ef3e1eb 100644 --- a/.github/workflows/linux-cmake.yml +++ b/.github/workflows/linux-cmake.yml @@ -1,19 +1,10 @@ name: linux-cmake on: - push: - branches: - - master - - main - paths-ignore: - - 'AUTHORS.md' - - 'LICENSE.md' - - 'README.md' - pull_request: - paths-ignore: - - 'AUTHORS.md' - - 'LICENSE.md' - - 'README.md' + workflow_run: + workflows: [fprettify-lint] + types: + - completed env: # Modify this variable to change the ifort compiler version - do NOT hardcode the version # anywhere else! diff --git a/.github/workflows/linux-fpm.yml b/.github/workflows/linux-fpm.yml index e42e7fb..ccb124e 100644 --- a/.github/workflows/linux-fpm.yml +++ b/.github/workflows/linux-fpm.yml @@ -1,19 +1,11 @@ name: linux-fpm on: - push: - branches: - - master - - main - paths-ignore: - - 'AUTHORS.md' - - 'LICENSE.md' - - 'README.md' - pull_request: - paths-ignore: - - 'AUTHORS.md' - - 'LICENSE.md' - - 'README.md' + workflow_run: + workflows: [fprettify-lint] + types: + - completed + env: # Modify this variable to change the ifort compiler version - do NOT hardcode the version # anywhere else! diff --git a/.github/workflows/windows-cmake.yml b/.github/workflows/windows-cmake.yml index fa123a4..1432d22 100644 --- a/.github/workflows/windows-cmake.yml +++ b/.github/workflows/windows-cmake.yml @@ -1,19 +1,10 @@ name: windows-cmake on: - push: - branches: - - master - - main - paths-ignore: - - 'AUTHORS.md' - - 'LICENSE.md' - - 'README.md' - pull_request: - paths-ignore: - - 'AUTHORS.md' - - 'LICENSE.md' - - 'README.md' + workflow_run: + workflows: [fprettify-lint] + types: + - completed env: # Modify this variable to change the ifort compiler version - do NOT hardcode the version # anywhere else! diff --git a/.github/workflows/windows-fpm.yml b/.github/workflows/windows-fpm.yml index 4213aef..623af52 100644 --- a/.github/workflows/windows-fpm.yml +++ b/.github/workflows/windows-fpm.yml @@ -1,19 +1,10 @@ name: windows-fpm on: - push: - branches: - - master - - main - paths-ignore: - - 'AUTHORS.md' - - 'LICENSE.md' - - 'README.md' - pull_request: - paths-ignore: - - 'AUTHORS.md' - - 'LICENSE.md' - - 'README.md' + workflow_run: + workflows: [fprettify-lint] + types: + - completed env: # Modify this variable to change the ifort compiler version - do NOT hardcode the version # anywhere else! diff --git a/fprettify.config b/fprettify.config new file mode 100644 index 0000000..82b61fc --- /dev/null +++ b/fprettify.config @@ -0,0 +1,24 @@ +disable-indent-mod=False +enable-replacements=False +c-relations=False + +# White space settings +indent=4 +line-length=256 +strict-indent=True +strip-comments=True +whitespace-relational=True +whitespace-logical=True +whitespace-plusminus=True +whitespace-multdiv=True +whitespace-comma=True +whitespace-intrinsics=True +whitespace-print=False +whitespace-type=False + +# Control whitespace around '::' declarations +whitespace-decl=None +enable-decl=False + +# Don't indent pre-processor statements +disable-fypp=True From 23cbf13d223c109a21757e16bbaaef6bef9267e7 Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 11 Feb 2024 10:34:57 -0500 Subject: [PATCH 02/10] Fix formatting --- example/array_with_array_eval.f90 | 50 +++++------ example/array_with_scalar_eval.f90 | 50 +++++------ example/gaussian_scalar_multivar.f90 | 42 ++++----- example/scalar_function_product.f90 | 36 ++++---- example/scalar_with_scalar_eval.f90 | 32 +++---- src/FEQParse.F90 | 16 ++-- src/FEQParse_Functions.F90 | 129 +++++++++++++-------------- test/abs_r1fp32.f90 | 84 ++++++++--------- test/abs_r1fp64.f90 | 84 ++++++++--------- test/abs_r2fp32.f90 | 103 +++++++++++---------- test/abs_r2fp64.f90 | 102 ++++++++++----------- test/abs_r3fp32.f90 | 106 +++++++++++----------- test/abs_r3fp64.f90 | 102 ++++++++++----------- test/abs_r4fp32.f90 | 116 ++++++++++++------------ test/abs_r4fp64.f90 | 112 +++++++++++------------ test/abs_sfp32.f90 | 78 ++++++++-------- test/abs_sfp64.f90 | 78 ++++++++-------- test/acos_r1fp32.f90 | 84 ++++++++--------- test/acos_r1fp64.f90 | 84 ++++++++--------- test/acos_r2fp32.f90 | 102 ++++++++++----------- test/acos_r2fp64.f90 | 102 ++++++++++----------- test/acos_r3fp32.f90 | 106 +++++++++++----------- test/acos_r3fp64.f90 | 104 ++++++++++----------- test/acos_r4fp32.f90 | 118 ++++++++++++------------ test/acos_r4fp64.f90 | 116 ++++++++++++------------ test/acos_sfp32.f90 | 78 ++++++++-------- test/acos_sfp64.f90 | 80 ++++++++--------- test/asin_r1fp32.f90 | 84 ++++++++--------- test/asin_r1fp64.f90 | 84 ++++++++--------- test/asin_r2fp32.f90 | 102 ++++++++++----------- test/asin_r2fp64.f90 | 102 ++++++++++----------- test/asin_r3fp32.f90 | 104 ++++++++++----------- test/asin_r3fp64.f90 | 104 ++++++++++----------- test/asin_r4fp32.f90 | 118 ++++++++++++------------ test/asin_r4fp64.f90 | 116 ++++++++++++------------ test/asin_sfp32.f90 | 78 ++++++++-------- test/asin_sfp64.f90 | 78 ++++++++-------- test/atan_r1fp32.f90 | 84 ++++++++--------- test/atan_r1fp64.f90 | 84 ++++++++--------- test/atan_r2fp32.f90 | 102 ++++++++++----------- test/atan_r2fp64.f90 | 102 ++++++++++----------- test/atan_r3fp32.f90 | 104 ++++++++++----------- test/atan_r3fp64.f90 | 104 ++++++++++----------- test/atan_r4fp32.f90 | 114 +++++++++++------------ test/atan_r4fp64.f90 | 114 +++++++++++------------ test/atan_sfp32.f90 | 78 ++++++++-------- test/atan_sfp64.f90 | 78 ++++++++-------- test/cos_r1fp32.f90 | 86 +++++++++--------- test/cos_r1fp64.f90 | 86 +++++++++--------- test/cos_r2fp32.f90 | 104 ++++++++++----------- test/cos_r2fp64.f90 | 104 ++++++++++----------- test/cos_r3fp32.f90 | 106 +++++++++++----------- test/cos_r3fp64.f90 | 106 +++++++++++----------- test/cos_r4fp32.f90 | 116 ++++++++++++------------ test/cos_r4fp64.f90 | 116 ++++++++++++------------ test/cos_sfp32.f90 | 80 ++++++++--------- test/cos_sfp64.f90 | 80 ++++++++--------- test/custom_r1fp64.f90 | 18 ++-- test/division_r1fp32.f90 | 84 ++++++++--------- test/division_r1fp64.f90 | 84 ++++++++--------- test/division_r2fp32.f90 | 106 +++++++++++----------- test/division_r2fp64.f90 | 102 ++++++++++----------- test/division_r3fp32.f90 | 108 +++++++++++----------- test/division_r3fp64.f90 | 108 +++++++++++----------- test/division_r4fp32.f90 | 118 ++++++++++++------------ test/division_r4fp64.f90 | 118 ++++++++++++------------ test/division_sfp32.f90 | 78 ++++++++-------- test/division_sfp64.f90 | 78 ++++++++-------- test/gaussian3d_r1fp32.f90 | 88 +++++++++--------- test/gaussian3d_r1fp64.f90 | 88 +++++++++--------- test/gaussian3d_r2fp32.f90 | 102 ++++++++++----------- test/gaussian3d_r2fp64.f90 | 102 ++++++++++----------- test/gaussian3d_r3fp32.f90 | 104 ++++++++++----------- test/gaussian3d_r3fp64.f90 | 104 ++++++++++----------- test/gaussian3d_r4fp32.f90 | 114 +++++++++++------------ test/gaussian3d_r4fp64.f90 | 114 +++++++++++------------ test/gaussian3d_sfp32.f90 | 54 +++++------ test/gaussian3d_sfp64.f90 | 54 +++++------ test/linear_r1fp32.f90 | 84 ++++++++--------- test/linear_r1fp64.f90 | 84 ++++++++--------- test/linear_r2fp32.f90 | 106 +++++++++++----------- test/linear_r2fp64.f90 | 102 ++++++++++----------- test/linear_r3fp32.f90 | 108 +++++++++++----------- test/linear_r3fp64.f90 | 108 +++++++++++----------- test/linear_r4fp32.f90 | 118 ++++++++++++------------ test/linear_r4fp64.f90 | 118 ++++++++++++------------ test/log10_r1fp32.f90 | 84 ++++++++--------- test/log10_r1fp64.f90 | 84 ++++++++--------- test/log10_r2fp32.f90 | 102 ++++++++++----------- test/log10_r2fp64.f90 | 102 ++++++++++----------- test/log10_r3fp32.f90 | 104 ++++++++++----------- test/log10_r3fp64.f90 | 104 ++++++++++----------- test/log10_r4fp32.f90 | 114 +++++++++++------------ test/log10_r4fp64.f90 | 114 +++++++++++------------ test/log10_sfp32.f90 | 78 ++++++++-------- test/log10_sfp64.f90 | 78 ++++++++-------- test/log_r1fp32.f90 | 84 ++++++++--------- test/log_r1fp64.f90 | 84 ++++++++--------- test/log_r2fp32.f90 | 102 ++++++++++----------- test/log_r2fp64.f90 | 102 ++++++++++----------- test/log_r3fp32.f90 | 104 ++++++++++----------- test/log_r3fp64.f90 | 104 ++++++++++----------- test/log_r4fp32.f90 | 114 +++++++++++------------ test/log_r4fp64.f90 | 114 +++++++++++------------ test/log_sfp32.f90 | 78 ++++++++-------- test/log_sfp64.f90 | 78 ++++++++-------- test/monadic_r1fp32.f90 | 84 ++++++++--------- test/monadic_r1fp64.f90 | 84 ++++++++--------- test/monadic_r2fp32.f90 | 106 +++++++++++----------- test/monadic_r2fp64.f90 | 102 ++++++++++----------- test/monadic_r3fp32.f90 | 108 +++++++++++----------- test/monadic_r3fp64.f90 | 108 +++++++++++----------- test/monadic_r4fp32.f90 | 118 ++++++++++++------------ test/monadic_r4fp64.f90 | 118 ++++++++++++------------ test/monadic_sfp32.f90 | 78 ++++++++-------- test/monadic_sfp64.f90 | 78 ++++++++-------- test/parsing_difficult_r1fp64.f90 | 78 ++++++++-------- test/print_tokens.f90 | 46 +++++----- test/random_r1fp32.f90 | 80 ++++++++--------- test/random_r1fp64.f90 | 80 ++++++++--------- test/random_r2fp32.f90 | 96 ++++++++++---------- test/random_r2fp64.f90 | 96 ++++++++++---------- test/random_r3fp32.f90 | 106 +++++++++++----------- test/random_r3fp64.f90 | 106 +++++++++++----------- test/random_r4fp32.f90 | 112 +++++++++++------------ test/random_r4fp64.f90 | 112 +++++++++++------------ test/random_sfp32.f90 | 74 +++++++-------- test/random_sfp64.f90 | 74 +++++++-------- test/sech_r1fp32.f90 | 84 ++++++++--------- test/sech_r1fp64.f90 | 84 ++++++++--------- test/sech_r2fp32.f90 | 104 ++++++++++----------- test/sech_r2fp64.f90 | 104 ++++++++++----------- test/sech_r3fp32.f90 | 108 +++++++++++----------- test/sech_r3fp64.f90 | 108 +++++++++++----------- test/sech_r4fp32.f90 | 118 ++++++++++++------------ test/sech_r4fp64.f90 | 118 ++++++++++++------------ test/sech_sfp32.f90 | 78 ++++++++-------- test/sech_sfp64.f90 | 78 ++++++++-------- test/sin_r1fp32.f90 | 86 +++++++++--------- test/sin_r1fp64.f90 | 86 +++++++++--------- test/sin_r2fp32.f90 | 104 ++++++++++----------- test/sin_r2fp64.f90 | 104 ++++++++++----------- test/sin_r3fp32.f90 | 106 +++++++++++----------- test/sin_r3fp64.f90 | 106 +++++++++++----------- test/sin_r4fp32.f90 | 116 ++++++++++++------------ test/sin_r4fp64.f90 | 116 ++++++++++++------------ test/sin_sfp32.f90 | 80 ++++++++--------- test/sin_sfp64.f90 | 80 ++++++++--------- test/sqrt_r1fp32.f90 | 84 ++++++++--------- test/sqrt_r1fp64.f90 | 84 ++++++++--------- test/sqrt_r2fp32.f90 | 102 ++++++++++----------- test/sqrt_r2fp64.f90 | 102 ++++++++++----------- test/sqrt_r3fp32.f90 | 104 ++++++++++----------- test/sqrt_r3fp64.f90 | 104 ++++++++++----------- test/sqrt_r4fp32.f90 | 114 +++++++++++------------ test/sqrt_r4fp64.f90 | 114 +++++++++++------------ test/sqrt_sfp32.f90 | 78 ++++++++-------- test/sqrt_sfp64.f90 | 78 ++++++++-------- test/tan_r1fp32.f90 | 86 +++++++++--------- test/tan_r1fp64.f90 | 86 +++++++++--------- test/tan_r2fp32.f90 | 104 ++++++++++----------- test/tan_r2fp64.f90 | 104 ++++++++++----------- test/tan_r3fp32.f90 | 106 +++++++++++----------- test/tan_r3fp64.f90 | 106 +++++++++++----------- test/tan_r4fp32.f90 | 116 ++++++++++++------------ test/tan_r4fp64.f90 | 116 ++++++++++++------------ test/tan_sfp32.f90 | 80 ++++++++--------- test/tan_sfp64.f90 | 80 ++++++++--------- test/tanh_r1fp32.f90 | 84 ++++++++--------- test/tanh_r1fp64.f90 | 84 ++++++++--------- test/tanh_r2fp32.f90 | 102 ++++++++++----------- test/tanh_r2fp64.f90 | 102 ++++++++++----------- test/tanh_r3fp32.f90 | 104 ++++++++++----------- test/tanh_r3fp64.f90 | 104 ++++++++++----------- test/tanh_r4fp32.f90 | 114 +++++++++++------------ test/tanh_r4fp64.f90 | 114 +++++++++++------------ test/tanh_sfp32.f90 | 78 ++++++++-------- test/tanh_sfp64.f90 | 78 ++++++++-------- 178 files changed, 8408 insertions(+), 8410 deletions(-) diff --git a/example/array_with_array_eval.f90 b/example/array_with_array_eval.f90 index e981eb4..a6fa50f 100644 --- a/example/array_with_array_eval.f90 +++ b/example/array_with_array_eval.f90 @@ -1,33 +1,33 @@ program array_with_array_eval - use iso_fortran_env - use FEQParse + use iso_fortran_env + use FEQParse - implicit none - integer,parameter :: N = 10000 - 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 + implicit none + integer, parameter :: N = 10000 + 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 the independent variables + independentVars = (/'x'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! 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" + ! 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" end program array_with_array_eval diff --git a/example/array_with_scalar_eval.f90 b/example/array_with_scalar_eval.f90 index ab8b4fa..42e28f9 100644 --- a/example/array_with_scalar_eval.f90 +++ b/example/array_with_scalar_eval.f90 @@ -1,33 +1,33 @@ program array_with_scalar_eval - use iso_fortran_env - use FEQParse + use iso_fortran_env + use FEQParse - implicit none - integer,parameter :: N = 100 - 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 + implicit none + integer, parameter :: N = 100 + 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 the independent variables + independentVars = (/'x'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! 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" + ! 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" end program array_with_scalar_eval diff --git a/example/gaussian_scalar_multivar.f90 b/example/gaussian_scalar_multivar.f90 index d1c0b27..797cc92 100644 --- a/example/gaussian_scalar_multivar.f90 +++ b/example/gaussian_scalar_multivar.f90 @@ -1,28 +1,28 @@ program gaussian_scalar_multivar - use iso_fortran_env - use FEQParse + use iso_fortran_env + use FEQParse - implicit none - type(EquationParser) :: f - character(LEN=1),dimension(2) :: independentVars - character(LEN=30) :: eqChar - real :: x(2) + 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 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 = (x - a)^2 )' + ! Specify an equation string that we want to evaluate + 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) + ! 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 + ! Evaluate the equation + x(1) = 1.0 + x(2) = 1.0 + print*,f%evaluate(x) + print*,exp(-1.0) - 1.0 - end program gaussian_scalar_multivar \ No newline at end of file +end program gaussian_scalar_multivar diff --git a/example/scalar_function_product.f90 b/example/scalar_function_product.f90 index fb2360c..2fd6afe 100644 --- a/example/scalar_function_product.f90 +++ b/example/scalar_function_product.f90 @@ -1,26 +1,26 @@ program scalar_function_product - use iso_fortran_env - use FEQParse + use iso_fortran_env + use FEQParse - implicit none - type(EquationParser) :: f - character(LEN=1),dimension(2) :: independentVars - character(LEN=2048) :: eqChar - real :: x(2) - real :: feval + implicit none + type(EquationParser) :: f + character(LEN=1), dimension(2) :: independentVars + character(LEN=2048) :: eqChar + real :: x(2) + real :: feval - ! Specify the independent variables - independentVars = (/'x', 'y'/) + ! Specify the independent variables + independentVars = (/'x', 'y'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - ! Evaluate the equation - x = 0.5 - feval = f % evaluate(x) - print*, feval + ! Evaluate the equation + x = 0.5 + feval = f%evaluate(x) + print*,feval end program scalar_function_product diff --git a/example/scalar_with_scalar_eval.f90 b/example/scalar_with_scalar_eval.f90 index 85cd43f..2a0db2d 100644 --- a/example/scalar_with_scalar_eval.f90 +++ b/example/scalar_with_scalar_eval.f90 @@ -1,24 +1,24 @@ program scalar_with_scalar_eval - use iso_fortran_env - use FEQParse + use iso_fortran_env + use FEQParse - implicit none - type(EquationParser) :: f - character(LEN=1),dimension(1) :: independentVars - character(LEN=30) :: eqChar - real :: x(1) + 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 the independent variables + independentVars = (/'x'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - ! Evaluate the equation - x(1) = 0.0 - print*, f % evaluate(x) + ! Evaluate the equation + x(1) = 0.0 + print*,f%evaluate(x) end program scalar_with_scalar_eval diff --git a/src/FEQParse.F90 b/src/FEQParse.F90 index 5816165..71b9074 100644 --- a/src/FEQParse.F90 +++ b/src/FEQParse.F90 @@ -19,7 +19,7 @@ module FEQParse use FEQParse_FloatStacks implicit none - + public :: FEQParse_Function, & AddFunction @@ -39,7 +39,7 @@ module FEQParse enumerator :: ClosingParentheses_Token = 6 enumerator :: Monadic_Token = 7 end enum - + integer, parameter, private :: nSeparators = 7 character(1), private :: separators(7) = ['+', '-', '*', '/', "(", ")", '^'] @@ -63,10 +63,10 @@ module FEQParse procedure :: ConvertToPostfix generic :: Evaluate => Evaluate_sfp32, Evaluate_sfp64, & - Evaluate_r1fp32, Evaluate_r1fp64, & - Evaluate_r2fp32, Evaluate_r2fp64, & - Evaluate_r3fp32, Evaluate_r3fp64, & - Evaluate_r4fp32, Evaluate_r4fp64 + Evaluate_r1fp32, Evaluate_r1fp64, & + Evaluate_r2fp32, Evaluate_r2fp64, & + Evaluate_r3fp32, Evaluate_r3fp64, & + Evaluate_r4fp32, Evaluate_r4fp64 procedure, private :: Evaluate_sfp32, Evaluate_sfp64 procedure, private :: Evaluate_r1fp32, Evaluate_r1fp64 procedure, private :: Evaluate_r2fp32, Evaluate_r2fp64 @@ -121,7 +121,7 @@ function Construct_EquationParser(equation, indepVars) result(parser) if (tokenized) then call parser%ConvertToPostFix() else - if (allocated(errorMsg)) print*, trim(errorMsg) + if (allocated(errorMsg)) print*,trim(errorMsg) success = .false. end if end if @@ -345,7 +345,7 @@ subroutine ConvertToPostFix(parser) if (.not. operator_stack%IsEmpty()) then tok = operator_stack%TopToken() - + do while (trim(tok%tokenString) /= '(' .and. & parser%Priority(tok) > & parser%Priority(parser%inFix%tokens(i))) diff --git a/src/FEQParse_Functions.F90 b/src/FEQParse_Functions.F90 index 60517c9..d196c35 100644 --- a/src/FEQParse_Functions.F90 +++ b/src/FEQParse_Functions.F90 @@ -18,7 +18,7 @@ module FEQParse_Functions integer, public :: nFunctions = 17 integer, protected, public :: maxFunctionLength = 0 - + enum, bind(c) enumerator :: cos_function = 1 enumerator :: cosh_function = 2 @@ -40,24 +40,24 @@ module FEQParse_Functions end enum private - + public :: InitializeFunctions, & AddFunction - + interface pure real(real32) function f32(x) import real(real32), intent(in) :: x end function end interface - + interface pure real(real64) function f64(x) import real(real64), intent(in) :: x end function end interface - + type Tuple character(:), allocatable :: item1 character(:), allocatable :: item2 @@ -104,22 +104,21 @@ pure real(real64) function randomize_r64() module procedure :: AddFunction64 module procedure :: AddFunction32And64 end interface - + interface Tuple module procedure Tuple_new end interface - contains - +contains + type(Tuple) function Tuple_new(item1, item2) result(t) character(*), intent(in) :: item1 character(*), intent(in) :: item2 - + t%item1 = item1 t%item2 = item2 end function - - + subroutine character_array_assign_function(lhs, rhs) class(FEQParse_Function), intent(inout) :: lhs !! Left hand side. class(Tuple), intent(in) :: rhs !! Right hand side. @@ -177,75 +176,75 @@ elemental function character_neq_function(lhs, rhs) result(ok) ok = lhs /= rhs%str .or. lhs /= rhs%caps end function - + subroutine InitializeFunctions() if (allocated(Functions)) return - + allocate (Functions(1:nFunctions)) Functions(cos_function) = Tuple("cos", "COS") Functions(cos_function)%ptr32 => cos32 Functions(cos_function)%ptr64 => cos64 - + Functions(cosh_function) = Tuple("cosh", "COSH") Functions(cosh_function)%ptr32 => cosh32 Functions(cosh_function)%ptr64 => cosh64 - + Functions(sin_function) = Tuple("sin", "SIN") Functions(sin_function)%ptr32 => sin32 Functions(sin_function)%ptr64 => sin64 - + Functions(sinh_function) = Tuple("sinh", "SINH") Functions(sinh_function)%ptr32 => sinh32 Functions(sinh_function)%ptr64 => sinh64 - + Functions(tan_function) = Tuple("tan", "TAN") Functions(tan_function)%ptr32 => tan32 Functions(tan_function)%ptr64 => tan64 - + Functions(tanh_function) = Tuple("tanh", "TANH") Functions(tanh_function)%ptr32 => tanh32 Functions(tanh_function)%ptr64 => tanh64 - + Functions(sqrt_function) = Tuple("sqrt", "SQRT") Functions(sqrt_function)%ptr32 => sqrt32 Functions(sqrt_function)%ptr64 => sqrt64 - + Functions(abs_function) = Tuple("abs", "ABS") Functions(abs_function)%ptr32 => abs32 Functions(abs_function)%ptr64 => abs64 - + Functions(exp_function) = Tuple("exp", "EXP") Functions(exp_function)%ptr32 => exp32 Functions(exp_function)%ptr64 => exp64 - + Functions(ln_function) = Tuple("ln", "LN") Functions(ln_function)%ptr32 => log32 Functions(ln_function)%ptr64 => log64 - + Functions(log_function) = Tuple("log", "LOG") Functions(log_function)%ptr32 => log32 Functions(log_function)%ptr64 => log64 - + Functions(log10_function) = Tuple("log10", "LOG10") Functions(log10_function)%ptr32 => log1032 Functions(log10_function)%ptr64 => log1064 - + Functions(acos_function) = Tuple("acos", "ACOS") Functions(acos_function)%ptr32 => acos32 Functions(acos_function)%ptr64 => acos64 - + Functions(asin_function) = Tuple("asin", "ASIN") Functions(asin_function)%ptr32 => asin32 Functions(asin_function)%ptr64 => asin64 - + Functions(atan_function) = Tuple("atan", "ATAN") Functions(atan_function)%ptr32 => atan32 Functions(atan_function)%ptr64 => atan64 - + Functions(sech_function) = Tuple("sech", "SECH") Functions(sech_function)%ptr32 => sech32 Functions(sech_function)%ptr64 => sech64 - + Functions(rand_function) = Tuple("rand", "RAND") Functions(rand_function)%ptr32 => rand32 Functions(rand_function)%ptr64 => rand64 @@ -254,7 +253,7 @@ end subroutine InitializeFunctions subroutine AddFunction32(name, f_32) character(*), intent(in) :: name procedure(f32) :: f_32 - !private + !private type(FEQParse_Function) :: func call InitializeFunctions() @@ -268,7 +267,7 @@ subroutine AddFunction32(name, f_32) subroutine AddFunction64(name, f_64) character(*), intent(in) :: name procedure(f64) :: f_64 - !private + !private type(FEQParse_Function) :: func call InitializeFunctions() @@ -283,7 +282,7 @@ subroutine AddFunction32And64(name, f_32, f_64) character(*), intent(in) :: name procedure(f32) :: f_32 procedure(f64) :: f_64 - !private + !private type(FEQParse_Function) :: func call InitializeFunctions() @@ -299,163 +298,163 @@ elemental real(real32) function invoke32(this, x) result(fx) real(real32), intent(in) :: x fx = this%ptr32(x) end function - + elemental real(real64) function invoke64(this, x) result(fx) class(FEQParse_Function), intent(in) :: this real(real64), intent(in) :: x fx = this%ptr64(x) end function - + pure real(real32) function cos32(x) result(fx) real(real32), intent(in) :: x fx = cos(x) end function - + pure real(real64) function cos64(x) result(fx) real(real64), intent(in) :: x fx = cos(x) end function - + pure real(real32) function cosh32(x) result(fx) real(real32), intent(in) :: x fx = cosh(x) end function - + pure real(real64) function cosh64(x) result(fx) real(real64), intent(in) :: x fx = cosh(x) end function - + pure real(real32) function sin32(x) result(fx) real(real32), intent(in) :: x fx = sin(x) end function - + pure real(real64) function sin64(x) result(fx) real(real64), intent(in) :: x fx = sin(x) end function - + pure real(real32) function sinh32(x) result(fx) real(real32), intent(in) :: x fx = sinh(x) end function - + pure real(real64) function sinh64(x) result(fx) real(real64), intent(in) :: x fx = sinh(x) end function - + pure real(real32) function tan32(x) result(fx) real(real32), intent(in) :: x fx = tan(x) end function - + pure real(real64) function tan64(x) result(fx) real(real64), intent(in) :: x fx = tan(x) end function - + pure real(real32) function tanh32(x) result(fx) real(real32), intent(in) :: x fx = tanh(x) end function - + pure real(real64) function tanh64(x) result(fx) real(real64), intent(in) :: x fx = tanh(x) end function - + pure real(real32) function sqrt32(x) result(fx) real(real32), intent(in) :: x fx = sqrt(x) end function - + pure real(real64) function sqrt64(x) result(fx) real(real64), intent(in) :: x fx = sqrt(x) end function - + pure real(real32) function abs32(x) result(fx) real(real32), intent(in) :: x fx = abs(x) end function - + pure real(real64) function abs64(x) result(fx) real(real64), intent(in) :: x fx = abs(x) end function - + pure real(real32) function exp32(x) result(fx) real(real32), intent(in) :: x fx = exp(x) end function - + pure real(real64) function exp64(x) result(fx) real(real64), intent(in) :: x fx = exp(x) end function - + pure real(real32) function log32(x) result(fx) real(real32), intent(in) :: x fx = log(x) end function - + pure real(real64) function log64(x) result(fx) real(real64), intent(in) :: x fx = log(x) end function - + pure real(real32) function log1032(x) result(fx) real(real32), intent(in) :: x fx = log10(x) end function - + pure real(real64) function log1064(x) result(fx) real(real64), intent(in) :: x fx = log10(x) end function - + pure real(real32) function acos32(x) result(fx) real(real32), intent(in) :: x fx = acos(x) end function - + pure real(real64) function acos64(x) result(fx) real(real64), intent(in) :: x fx = acos(x) end function - + pure real(real32) function asin32(x) result(fx) real(real32), intent(in) :: x fx = asin(x) end function - + pure real(real64) function asin64(x) result(fx) real(real64), intent(in) :: x fx = asin(x) end function - + pure real(real32) function atan32(x) result(fx) real(real32), intent(in) :: x fx = atan(x) end function - + pure real(real64) function atan64(x) result(fx) real(real64), intent(in) :: x fx = atan(x) end function - + pure real(real32) function sech32(x) result(fx) real(real32), intent(in) :: x fx = 2.0_real32 / (exp(x) + exp(-x)) end function - + pure real(real64) function sech64(x) result(fx) real(real64), intent(in) :: x fx = 2.0_real64 / (exp(x) + exp(-x)) end function - + pure real(real32) function rand32(x) result(fx) real(real32), intent(in) :: x !private @@ -464,7 +463,7 @@ pure real(real32) function rand32(x) result(fx) fx = r * x end associate end function - + pure real(real64) function rand64(x) result(fx) real(real64), intent(in) :: x !private diff --git a/test/abs_r1fp32.f90 b/test/abs_r1fp32.f90 index 59e17c7..7d12f71 100644 --- a/test/abs_r1fp32.f90 +++ b/test/abs_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = abs_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = abs_r1fp32() + stop exit_code contains -integer function abs_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = abs(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function abs_r1fp32 + integer function abs_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = abs(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function abs_r1fp32 end program test diff --git a/test/abs_r1fp64.f90 b/test/abs_r1fp64.f90 index 1f9c003..145eb4e 100644 --- a/test/abs_r1fp64.f90 +++ b/test/abs_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = abs_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = abs_r1fp64() + stop exit_code contains -integer function abs_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = abs(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function abs_r1fp64 + integer function abs_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = abs(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function abs_r1fp64 end program test diff --git a/test/abs_r2fp32.f90 b/test/abs_r2fp32.f90 index faf4b8c..99a8c82 100644 --- a/test/abs_r2fp32.f90 +++ b/test/abs_r2fp32.f90 @@ -1,58 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = abs_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = abs_r2fp32() + stop exit_code contains -integer function abs_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = abs(x(i,j,1) + x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - - -end function abs_r2fp32 + integer function abs_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = abs(x(i, j, 1) + x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function abs_r2fp32 end program test diff --git a/test/abs_r2fp64.f90 b/test/abs_r2fp64.f90 index ec5842a..a54d8c9 100644 --- a/test/abs_r2fp64.f90 +++ b/test/abs_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = abs_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = abs_r2fp64() + stop exit_code contains -integer function abs_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = abs(x(i,j,1) + x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function abs_r2fp64 + integer function abs_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = abs(x(i, j, 1) + x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function abs_r2fp64 end program test diff --git a/test/abs_r3fp32.f90 b/test/abs_r3fp32.f90 index 053629a..cc46baa 100644 --- a/test/abs_r3fp32.f90 +++ b/test/abs_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = abs_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = abs_r3fp32() + stop exit_code contains -integer function abs_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function abs_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k + + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y + z )' - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y + z )' + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = abs(x(i, j, k, 1) + x(i, j, k, 2) + x(i, j, k, 3)) + end do + end do + end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = abs(x(i,j,k,1) + x(i,j,k,2) + x(i,j,k,3)) - end do - end do - end do + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= 10.0_real32 * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real32*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function abs_r3fp32 + end function abs_r3fp32 end program test diff --git a/test/abs_r3fp64.f90 b/test/abs_r3fp64.f90 index 9a78c53..ca2f5aa 100644 --- a/test/abs_r3fp64.f90 +++ b/test/abs_r3fp64.f90 @@ -1,65 +1,65 @@ program test - implicit none - integer :: exit_code - - exit_code = abs_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = abs_r3fp64() + stop exit_code contains -integer function abs_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function abs_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y + z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y + z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = abs(x(i,j,k,1) + x(i,j,k,2) + x(i,j,k,3)) - end do - end do - end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = abs(x(i, j, k, 1) + x(i, j, k, 2) + x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real64*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= 10.0_real64 * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if -end function abs_r3fp64 + end function abs_r3fp64 end program test diff --git a/test/abs_r4fp32.f90 b/test/abs_r4fp32.f90 index 402587c..b31f1b0 100644 --- a/test/abs_r4fp32.f90 +++ b/test/abs_r4fp32.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code - - exit_code = abs_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = abs_r4fp32() + stop exit_code contains -integer function abs_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function abs_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y + z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y + z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = abs(x(i,j,k,l,1) + x(i,j,k,l,2) + x(i,j,k,l,3)) - end do - end do - end do - end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = abs(x(i, j, k, l, 1) + x(i, j, k, l, 2) + x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - print*,maxval(abs(feval - fexact)) - r = 1 - end if - deallocate (x,feval,fexact) + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + print*,maxval(abs(feval - fexact)) + r = 1 + end if + deallocate (x, feval, fexact) -end function abs_r4fp32 + end function abs_r4fp32 end program test diff --git a/test/abs_r4fp64.f90 b/test/abs_r4fp64.f90 index 16942c8..31441da 100644 --- a/test/abs_r4fp64.f90 +++ b/test/abs_r4fp64.f90 @@ -1,70 +1,70 @@ program test - implicit none - integer :: exit_code - - exit_code = abs_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = abs_r4fp64() + stop exit_code contains -integer function abs_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function abs_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y + z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y + z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = abs(x(i,j,k,l,1) + x(i,j,k,l,2) + x(i,j,k,l,3)) - end do - end do - end do - end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = abs(x(i, j, k, l, 1) + x(i, j, k, l, 2) + x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if -end function abs_r4fp64 + end function abs_r4fp64 end program test diff --git a/test/abs_sfp32.f90 b/test/abs_sfp32.f90 index 8c57f60..87af357 100644 --- a/test/abs_sfp32.f90 +++ b/test/abs_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = abs_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = abs_sfp32() + stop exit_code contains -integer function abs_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = abs(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function abs_sfp32 + integer function abs_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = abs(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function abs_sfp32 end program test diff --git a/test/abs_sfp64.f90 b/test/abs_sfp64.f90 index 3f7f1a1..f7fc63d 100644 --- a/test/abs_sfp64.f90 +++ b/test/abs_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = abs_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = abs_sfp64() + stop exit_code contains -integer function abs_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = abs(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function abs_sfp64 + integer function abs_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = abs(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function abs_sfp64 end program test diff --git a/test/acos_r1fp32.f90 b/test/acos_r1fp32.f90 index 62ba366..5dfca59 100644 --- a/test/acos_r1fp32.f90 +++ b/test/acos_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = acos_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = acos_r1fp32() + stop exit_code contains -integer function acos_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = acos(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function acos_r1fp32 + integer function acos_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = acos(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function acos_r1fp32 end program test diff --git a/test/acos_r1fp64.f90 b/test/acos_r1fp64.f90 index 38c2e2e..a61633b 100644 --- a/test/acos_r1fp64.f90 +++ b/test/acos_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = acos_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = acos_r1fp64() + stop exit_code contains -integer function acos_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = acos(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function acos_r1fp64 + integer function acos_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = acos(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function acos_r1fp64 end program test diff --git a/test/acos_r2fp32.f90 b/test/acos_r2fp32.f90 index 3555512..97c8f21 100644 --- a/test/acos_r2fp32.f90 +++ b/test/acos_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = acos_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = acos_r2fp32() + stop exit_code contains -integer function acos_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = acos(x(i,j,1))*acos(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function acos_r2fp32 + integer function acos_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = acos(x(i, j, 1)) * acos(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function acos_r2fp32 end program test diff --git a/test/acos_r2fp64.f90 b/test/acos_r2fp64.f90 index 5c738ff..5f427cc 100644 --- a/test/acos_r2fp64.f90 +++ b/test/acos_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = acos_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = acos_r2fp64() + stop exit_code contains -integer function acos_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = acos(x(i,j,1))*acos(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function acos_r2fp64 + integer function acos_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = acos(x(i, j, 1)) * acos(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function acos_r2fp64 end program test diff --git a/test/acos_r3fp32.f90 b/test/acos_r3fp32.f90 index 0ef12cf..fd57702 100644 --- a/test/acos_r3fp32.f90 +++ b/test/acos_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = acos_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = acos_r3fp32() + stop exit_code contains -integer function acos_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function acos_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k + + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )*acos( z )' - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )*acos( z )' + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = acos(x(i, j, k, 1)) * acos(x(i, j, k, 2)) * acos(x(i, j, k, 3)) + end do + end do + end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = acos(x(i,j,k,1))*acos(x(i,j,k,2))*acos(x(i,j,k,3)) - end do - end do - end do + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function acos_r3fp32 + end function acos_r3fp32 end program test diff --git a/test/acos_r3fp64.f90 b/test/acos_r3fp64.f90 index 2c8bba6..2c13700 100644 --- a/test/acos_r3fp64.f90 +++ b/test/acos_r3fp64.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = acos_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = acos_r3fp64() + stop exit_code contains -integer function acos_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function acos_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )*acos( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )*acos( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = acos(x(i,j,k,1))*acos(x(i,j,k,2))*acos(x(i,j,k,3)) - end do - end do - end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = acos(x(i, j, k, 1)) * acos(x(i, j, k, 2)) * acos(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function acos_r3fp64 + end function acos_r3fp64 end program test diff --git a/test/acos_r4fp32.f90 b/test/acos_r4fp32.f90 index 460efc4..1dfc66c 100644 --- a/test/acos_r4fp32.f90 +++ b/test/acos_r4fp32.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code - - exit_code = acos_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = acos_r4fp32() + stop exit_code contains -integer function acos_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:4) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function acos_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:4) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:4), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:4), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z', 't'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z', 't'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )*acos( z )*acos( t )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )*acos( z )*acos( t )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - x(i,j,k,l,4) = -1.0_real32 + (2.0_real32)/real(M,real32)*real(l - 1,real32) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + x(i, j, k, l, 4) = -1.0_real32 + (2.0_real32) / real(M, real32) * real(l - 1, real32) + end do + end do + end do + end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = acos(x(i,j,k,l,1))*acos(x(i,j,k,l,2))*acos(x(i,j,k,l,3))*acos(x(i,j,k,l,4)) - end do - end do - end do - end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = acos(x(i, j, k, l, 1)) * acos(x(i, j, k, l, 2)) * acos(x(i, j, k, l, 3)) * acos(x(i, j, k, l, 4)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - print*, maxval(abs(feval - fexact)),maxval(abs(fexact))*epsilon(1.0_real32) - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + print*,maxval(abs(feval - fexact)), maxval(abs(fexact)) * epsilon(1.0_real32) + r = 1 + end if - deallocate (x,feval,fexact) -end function acos_r4fp32 + deallocate (x, feval, fexact) + end function acos_r4fp32 end program test diff --git a/test/acos_r4fp64.f90 b/test/acos_r4fp64.f90 index c982ffd..4b28994 100644 --- a/test/acos_r4fp64.f90 +++ b/test/acos_r4fp64.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code - - exit_code = acos_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = acos_r4fp64() + stop exit_code contains -integer function acos_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:4) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function acos_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:4) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:4), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:4), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z','t'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z', 't'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )*acos( z )*acos( t )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )*acos( z )*acos( t )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - x(i,j,k,l,4) = -1.0_real64 + (2.0_real64)/real(M,real64)*real(l - 1,real64) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + x(i, j, k, l, 4) = -1.0_real64 + (2.0_real64) / real(M, real64) * real(l - 1, real64) + end do + end do + end do + end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = acos(x(i,j,k,l,1))*acos(x(i,j,k,l,2))*acos(x(i,j,k,l,3))*acos(x(i,j,k,l,4)) - end do - end do - end do - end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = acos(x(i, j, k, l, 1)) * acos(x(i, j, k, l, 2)) * acos(x(i, j, k, l, 3)) * acos(x(i, j, k, l, 4)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) -end function acos_r4fp64 + deallocate (x, feval, fexact) + end function acos_r4fp64 end program test diff --git a/test/acos_sfp32.f90 b/test/acos_sfp32.f90 index 5023101..80d81d2 100644 --- a/test/acos_sfp32.f90 +++ b/test/acos_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = acos_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = acos_sfp32() + stop exit_code contains -integer function acos_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = acos(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function acos_sfp32 + integer function acos_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = acos(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function acos_sfp32 end program test diff --git a/test/acos_sfp64.f90 b/test/acos_sfp64.f90 index b93ae57..e2344cd 100644 --- a/test/acos_sfp64.f90 +++ b/test/acos_sfp64.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code - - exit_code = acos_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = acos_sfp64() + stop exit_code contains -integer function acos_sfp64() result(r) - ! WARNING - acos(x) accurate only to single precision with gfortran 11.4.0 - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = acos(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function acos_sfp64 + integer function acos_sfp64() result(r) + ! WARNING - acos(x) accurate only to single precision with gfortran 11.4.0 + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = acos(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function acos_sfp64 end program test diff --git a/test/asin_r1fp32.f90 b/test/asin_r1fp32.f90 index 2fb569c..000ee22 100644 --- a/test/asin_r1fp32.f90 +++ b/test/asin_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = asin_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = asin_r1fp32() + stop exit_code contains -integer function asin_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = asin(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function asin_r1fp32 + integer function asin_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = asin(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function asin_r1fp32 end program test diff --git a/test/asin_r1fp64.f90 b/test/asin_r1fp64.f90 index 0797e32..a4edda5 100644 --- a/test/asin_r1fp64.f90 +++ b/test/asin_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = asin_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = asin_r1fp64() + stop exit_code contains -integer function asin_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = asin(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function asin_r1fp64 + integer function asin_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = asin(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function asin_r1fp64 end program test diff --git a/test/asin_r2fp32.f90 b/test/asin_r2fp32.f90 index 7cb400c..6b54d3f 100644 --- a/test/asin_r2fp32.f90 +++ b/test/asin_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = asin_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = asin_r2fp32() + stop exit_code contains -integer function asin_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = asin(x(i,j,1))*asin(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function asin_r2fp32 + integer function asin_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = asin(x(i, j, 1)) * asin(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function asin_r2fp32 end program test diff --git a/test/asin_r2fp64.f90 b/test/asin_r2fp64.f90 index e4d264d..885e48f 100644 --- a/test/asin_r2fp64.f90 +++ b/test/asin_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = asin_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = asin_r2fp64() + stop exit_code contains -integer function asin_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = asin(x(i,j,1))*asin(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function asin_r2fp64 + integer function asin_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = asin(x(i, j, 1)) * asin(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function asin_r2fp64 end program test diff --git a/test/asin_r3fp32.f90 b/test/asin_r3fp32.f90 index 277055f..74a746e 100644 --- a/test/asin_r3fp32.f90 +++ b/test/asin_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = asin_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = asin_r3fp32() + stop exit_code contains -integer function asin_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function asin_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )*asin( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )*asin( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = asin(x(i,j,k,1))*asin(x(i,j,k,2))*asin(x(i,j,k,3)) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = asin(x(i, j, k, 1)) * asin(x(i, j, k, 2)) * asin(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function asin_r3fp32 + end function asin_r3fp32 end program test diff --git a/test/asin_r3fp64.f90 b/test/asin_r3fp64.f90 index 56d744c..7093030 100644 --- a/test/asin_r3fp64.f90 +++ b/test/asin_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = asin_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = asin_r3fp64() + stop exit_code contains -integer function asin_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function asin_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )*asin( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )*asin( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = asin(x(i,j,k,1))*asin(x(i,j,k,2))*asin(x(i,j,k,3)) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = asin(x(i, j, k, 1)) * asin(x(i, j, k, 2)) * asin(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function asin_r3fp64 + end function asin_r3fp64 end program test diff --git a/test/asin_r4fp32.f90 b/test/asin_r4fp32.f90 index 0b9181d..624be4c 100644 --- a/test/asin_r4fp32.f90 +++ b/test/asin_r4fp32.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code - - exit_code = asin_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = asin_r4fp32() + stop exit_code contains -integer function asin_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:4) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function asin_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:4) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:4), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:4), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z','t'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z', 't'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )*asin( z )*asin( t )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )*asin( z )*asin( t )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - x(i,j,k,l,4) = -1.0_real32 + (2.0_real32)/real(M,real32)*real(l - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = asin(x(i,j,k,l,1))*asin(x(i,j,k,l,2))*asin(x(i,j,k,l,3))*asin(x(i,j,k,l,4)) - end do - end do - end do - end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - print*, maxval(abs(feval - fexact)),maxval(abs(fexact))*epsilon(1.0_real32) - r = 1 - end if + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + x(i, j, k, l, 4) = -1.0_real32 + (2.0_real32) / real(M, real32) * real(l - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = asin(x(i, j, k, l, 1)) * asin(x(i, j, k, l, 2)) * asin(x(i, j, k, l, 3)) * asin(x(i, j, k, l, 4)) + end do + end do + end do + end do + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + print*,maxval(abs(feval - fexact)), maxval(abs(fexact)) * epsilon(1.0_real32) + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function asin_r4fp32 + end function asin_r4fp32 end program test diff --git a/test/asin_r4fp64.f90 b/test/asin_r4fp64.f90 index 81e56b9..f46ad52 100644 --- a/test/asin_r4fp64.f90 +++ b/test/asin_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = asin_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = asin_r4fp64() + stop exit_code contains -integer function asin_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:4) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function asin_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:4) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:4), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:4), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z','t'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z', 't'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )*asin( z )*asin( t )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )*asin( z )*asin( t )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - x(i,j,k,l,4) = -1.0_real64 + (2.0_real64)/real(M,real64)*real(l - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = asin(x(i,j,k,l,1))*asin(x(i,j,k,l,2))*asin(x(i,j,k,l,3))*asin(x(i,j,k,l,4)) - end do - end do - end do - end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + x(i, j, k, l, 4) = -1.0_real64 + (2.0_real64) / real(M, real64) * real(l - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = asin(x(i, j, k, l, 1)) * asin(x(i, j, k, l, 2)) * asin(x(i, j, k, l, 3)) * asin(x(i, j, k, l, 4)) + end do + end do + end do + end do + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function asin_r4fp64 + end function asin_r4fp64 end program test diff --git a/test/asin_sfp32.f90 b/test/asin_sfp32.f90 index 4bd0410..4d30f3a 100644 --- a/test/asin_sfp32.f90 +++ b/test/asin_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = asin_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = asin_sfp32() + stop exit_code contains -integer function asin_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = asin(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function asin_sfp32 + integer function asin_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = asin(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function asin_sfp32 end program test diff --git a/test/asin_sfp64.f90 b/test/asin_sfp64.f90 index 5dc4210..bceecd4 100644 --- a/test/asin_sfp64.f90 +++ b/test/asin_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = asin_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = asin_sfp64() + stop exit_code contains -integer function asin_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = asin(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function asin_sfp64 + integer function asin_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = asin(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function asin_sfp64 end program test diff --git a/test/atan_r1fp32.f90 b/test/atan_r1fp32.f90 index 8295441..ea5df77 100644 --- a/test/atan_r1fp32.f90 +++ b/test/atan_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = atan_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = atan_r1fp32() + stop exit_code contains -integer function atan_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = atan(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function atan_r1fp32 + integer function atan_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = atan(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function atan_r1fp32 end program test diff --git a/test/atan_r1fp64.f90 b/test/atan_r1fp64.f90 index 9ba3f2f..faf4c42 100644 --- a/test/atan_r1fp64.f90 +++ b/test/atan_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = atan_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = atan_r1fp64() + stop exit_code contains -integer function atan_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = atan(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function atan_r1fp64 + integer function atan_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = atan(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function atan_r1fp64 end program test diff --git a/test/atan_r2fp32.f90 b/test/atan_r2fp32.f90 index 47709ce..b20042e 100644 --- a/test/atan_r2fp32.f90 +++ b/test/atan_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = atan_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = atan_r2fp32() + stop exit_code contains -integer function atan_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = atan(x(i,j,1))*atan(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function atan_r2fp32 + integer function atan_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = atan(x(i, j, 1)) * atan(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function atan_r2fp32 end program test diff --git a/test/atan_r2fp64.f90 b/test/atan_r2fp64.f90 index 2478a19..01a90f8 100644 --- a/test/atan_r2fp64.f90 +++ b/test/atan_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = atan_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = atan_r2fp64() + stop exit_code contains -integer function atan_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = atan(x(i,j,1))*atan(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function atan_r2fp64 + integer function atan_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = atan(x(i, j, 1)) * atan(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function atan_r2fp64 end program test diff --git a/test/atan_r3fp32.f90 b/test/atan_r3fp32.f90 index 3f19fc2..8ed679f 100644 --- a/test/atan_r3fp32.f90 +++ b/test/atan_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = atan_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = atan_r3fp32() + stop exit_code contains -integer function atan_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function atan_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )*atan( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )*atan( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = atan(x(i,j,k,1))*atan(x(i,j,k,2))*atan(x(i,j,k,3)) - end do - end do - end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = atan(x(i, j, k, 1)) * atan(x(i, j, k, 2)) * atan(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function atan_r3fp32 + end function atan_r3fp32 end program test diff --git a/test/atan_r3fp64.f90 b/test/atan_r3fp64.f90 index 55840e8..0ed42c9 100644 --- a/test/atan_r3fp64.f90 +++ b/test/atan_r3fp64.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = atan_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = atan_r3fp64() + stop exit_code contains -integer function atan_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function atan_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )*atan( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )*atan( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = atan(x(i,j,k,1))*atan(x(i,j,k,2))*atan(x(i,j,k,3)) - end do - end do - end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = atan(x(i, j, k, 1)) * atan(x(i, j, k, 2)) * atan(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real32) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function atan_r3fp64 + end function atan_r3fp64 end program test diff --git a/test/atan_r4fp32.f90 b/test/atan_r4fp32.f90 index 55ea9f2..25672b9 100644 --- a/test/atan_r4fp32.f90 +++ b/test/atan_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = atan_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = atan_r4fp32() + stop exit_code contains -integer function atan_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function atan_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )*atan( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )*atan( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = atan(x(i,j,k,l,1))*atan(x(i,j,k,l,2))*atan(x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = atan(x(i, j, k, l, 1)) * atan(x(i, j, k, l, 2)) * atan(x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function atan_r4fp32 + end function atan_r4fp32 end program test diff --git a/test/atan_r4fp64.f90 b/test/atan_r4fp64.f90 index 31a6951..a908604 100644 --- a/test/atan_r4fp64.f90 +++ b/test/atan_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = atan_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = atan_r4fp64() + stop exit_code contains -integer function atan_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function atan_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )*atan( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )*atan( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = atan(x(i,j,k,l,1))*atan(x(i,j,k,l,2))*atan(x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = atan(x(i, j, k, l, 1)) * atan(x(i, j, k, l, 2)) * atan(x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function atan_r4fp64 + end function atan_r4fp64 end program test diff --git a/test/atan_sfp32.f90 b/test/atan_sfp32.f90 index e19a20b..77e54c6 100644 --- a/test/atan_sfp32.f90 +++ b/test/atan_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = atan_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = atan_sfp32() + stop exit_code contains -integer function atan_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = atan(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function atan_sfp32 + integer function atan_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = atan(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function atan_sfp32 end program test diff --git a/test/atan_sfp64.f90 b/test/atan_sfp64.f90 index d27a54f..0d43baa 100644 --- a/test/atan_sfp64.f90 +++ b/test/atan_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = atan_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = atan_sfp64() + stop exit_code contains -integer function atan_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = atan(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function atan_sfp64 + integer function atan_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = atan(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function atan_sfp64 end program test diff --git a/test/cos_r1fp32.f90 b/test/cos_r1fp32.f90 index 333e82b..b25e186 100644 --- a/test/cos_r1fp32.f90 +++ b/test/cos_r1fp32.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code - - exit_code = cos_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = cos_r1fp32() + stop exit_code contains -integer function cos_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = cos(2.0_real32*pi*x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function cos_r1fp32 + integer function cos_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = cos(2.0_real32 * pi * x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function cos_r1fp32 end program test diff --git a/test/cos_r1fp64.f90 b/test/cos_r1fp64.f90 index db1c14c..da766e0 100644 --- a/test/cos_r1fp64.f90 +++ b/test/cos_r1fp64.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code - - exit_code = cos_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = cos_r1fp64() + stop exit_code contains -integer function cos_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = cos(2.0_real64*pi*x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function cos_r1fp64 + integer function cos_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = cos(2.0_real64 * pi * x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function cos_r1fp64 end program test diff --git a/test/cos_r2fp32.f90 b/test/cos_r2fp32.f90 index 2d17ee7..ee2d4f2 100644 --- a/test/cos_r2fp32.f90 +++ b/test/cos_r2fp32.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code - - exit_code = cos_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = cos_r2fp32() + stop exit_code contains -integer function cos_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = cos(2.0_real32*pi*x(i,j,1))*cos(2.0_real32*pi*x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function cos_r2fp32 + integer function cos_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = cos(2.0_real32 * pi * x(i, j, 1)) * cos(2.0_real32 * pi * x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function cos_r2fp32 end program test diff --git a/test/cos_r2fp64.f90 b/test/cos_r2fp64.f90 index cdccb2d..0f308fc 100644 --- a/test/cos_r2fp64.f90 +++ b/test/cos_r2fp64.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code - - exit_code = cos_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = cos_r2fp64() + stop exit_code contains -integer function cos_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = cos(2.0_real32*pi*x(i,j,1))*cos(2.0_real32*pi*x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function cos_r2fp64 + integer function cos_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = cos(2.0_real32 * pi * x(i, j, 1)) * cos(2.0_real32 * pi * x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function cos_r2fp64 end program test diff --git a/test/cos_r3fp32.f90 b/test/cos_r3fp32.f90 index 5b18053..22f9343 100644 --- a/test/cos_r3fp32.f90 +++ b/test/cos_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = cos_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = cos_r3fp32() + stop exit_code contains -integer function cos_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function cos_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = cos(2.0_real32*pi*x(i,j,k,1))*cos(2.0_real32*pi*x(i,j,k,2))*cos(2.0_real32*pi*x(i,j,k,3)) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = cos(2.0_real32 * pi * x(i, j, k, 1)) * cos(2.0_real32 * pi * x(i, j, k, 2)) * cos(2.0_real32 * pi * x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function cos_r3fp32 + end function cos_r3fp32 end program test diff --git a/test/cos_r3fp64.f90 b/test/cos_r3fp64.f90 index b9fd4df..2a20f37 100644 --- a/test/cos_r3fp64.f90 +++ b/test/cos_r3fp64.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = cos_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = cos_r3fp64() + stop exit_code contains -integer function cos_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function cos_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = cos(2.0_real64*pi*x(i,j,k,1))*cos(2.0_real64*pi*x(i,j,k,2))*cos(2.0_real64*pi*x(i,j,k,3)) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = cos(2.0_real64 * pi * x(i, j, k, 1)) * cos(2.0_real64 * pi * x(i, j, k, 2)) * cos(2.0_real64 * pi * x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function cos_r3fp64 + end function cos_r3fp64 end program test diff --git a/test/cos_r4fp32.f90 b/test/cos_r4fp32.f90 index df084a7..0ff1484 100644 --- a/test/cos_r4fp32.f90 +++ b/test/cos_r4fp32.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code - - exit_code = cos_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = cos_r4fp32() + stop exit_code contains -integer function cos_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function cos_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = cos(2.0_real32*pi*x(i,j,k,l,1))*cos(2.0_real32*pi*x(i,j,k,l,2))*cos(2.0_real32*pi*x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = cos(2.0_real32 * pi * x(i, j, k, l, 1)) * cos(2.0_real32 * pi * x(i, j, k, l, 2)) * cos(2.0_real32 * pi * x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function cos_r4fp32 + end function cos_r4fp32 end program test diff --git a/test/cos_r4fp64.f90 b/test/cos_r4fp64.f90 index d9af947..3bf5e15 100644 --- a/test/cos_r4fp64.f90 +++ b/test/cos_r4fp64.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code - - exit_code = cos_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = cos_r4fp64() + stop exit_code contains -integer function cos_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function cos_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = cos(2.0_real64*pi*x(i,j,k,l,1))*cos(2.0_real64*pi*x(i,j,k,l,2))*cos(2.0_real64*pi*x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = cos(2.0_real64 * pi * x(i, j, k, l, 1)) * cos(2.0_real64 * pi * x(i, j, k, l, 2)) * cos(2.0_real64 * pi * x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function cos_r4fp64 + end function cos_r4fp64 end program test diff --git a/test/cos_sfp32.f90 b/test/cos_sfp32.f90 index 93755b2..9987845 100644 --- a/test/cos_sfp32.f90 +++ b/test/cos_sfp32.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code - - exit_code = cos_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = cos_sfp32() + stop exit_code contains -integer function cos_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = cos(2.0_real32*pi*x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function cos_sfp32 + integer function cos_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = cos(2.0_real32 * pi * x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function cos_sfp32 end program test diff --git a/test/cos_sfp64.f90 b/test/cos_sfp64.f90 index f4c7220..e4bad1c 100644 --- a/test/cos_sfp64.f90 +++ b/test/cos_sfp64.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code - - exit_code = cos_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = cos_sfp64() + stop exit_code contains -integer function cos_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = cos(2.0_real64*pi*x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function cos_sfp64 + integer function cos_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = cos(2.0_real64 * pi * x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function cos_sfp64 end program test diff --git a/test/custom_r1fp64.f90 b/test/custom_r1fp64.f90 index 3d428f8..a1d1122 100644 --- a/test/custom_r1fp64.f90 +++ b/test/custom_r1fp64.f90 @@ -2,23 +2,23 @@ program test use iso_fortran_env, only: i1 => int8, i2 => int16, i4 => int32, i8 => int64, & r4 => real32, r8 => real64, r16 => real128 use FEQParse - + implicit none - - write(*,'(A,I20)') "test ", testing() - - contains - + + write (*, '(A,I20)') "test ", testing() + +contains + integer function testing() result(r) !private type(EquationParser) :: f real(r8) :: feval type(FEQParse_Function) :: func - + call AddFunction("myfunc", myfunc64) f = EquationParser("MYFUNC(x)", ["x"]) - + feval = f%evaluate([1.0_r8]) if ((abs(feval - 0.5_r8)) <= epsilon(1.0_r8)) then r = 0 @@ -26,7 +26,7 @@ integer function testing() result(r) r = 1 end if end function - + pure real(r8) function myfunc64(x) real(r8), intent(in) :: x myfunc64 = x / 2.0_r8 diff --git a/test/division_r1fp32.f90 b/test/division_r1fp32.f90 index 27d785a..0249530 100644 --- a/test/division_r1fp32.f90 +++ b/test/division_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = division_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = division_r1fp32() + stop exit_code contains -integer function division_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -x/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = -x(i,1)/10.0_real32 - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function division_r1fp32 + integer function division_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -x/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = -x(i, 1) / 10.0_real32 + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function division_r1fp32 end program test diff --git a/test/division_r1fp64.f90 b/test/division_r1fp64.f90 index dca3ec1..3389d0f 100644 --- a/test/division_r1fp64.f90 +++ b/test/division_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = division_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = division_r1fp64() + stop exit_code contains -integer function division_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -x/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = -x(i,1)/10.0_real64 - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function division_r1fp64 + integer function division_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -x/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = -x(i, 1) / 10.0_real64 + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function division_r1fp64 end program test diff --git a/test/division_r2fp32.f90 b/test/division_r2fp32.f90 index 7a765c6..a633065 100644 --- a/test/division_r2fp32.f90 +++ b/test/division_r2fp32.f90 @@ -1,59 +1,59 @@ program test - implicit none - integer :: exit_code - - exit_code = division_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = division_r2fp32() + stop exit_code contains -integer function division_r2fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = -(x(i,j,1) + 1.0_real32)*(x(i,j,2) + 1.0_real32)/10.0_real32 - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real32*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function division_r2fp32 + integer function division_r2fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = -(x(i, j, 1) + 1.0_real32) * (x(i, j, 2) + 1.0_real32) / 10.0_real32 + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= 10.0_real32 * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function division_r2fp32 end program test diff --git a/test/division_r2fp64.f90 b/test/division_r2fp64.f90 index a2be1772..e595c6e 100644 --- a/test/division_r2fp64.f90 +++ b/test/division_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = division_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = division_r2fp64() + stop exit_code contains -integer function division_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = -(x(i,j,1) + 1.0_real64)*(x(i,j,2) + 1.0_real64)/10.0_real64 - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function division_r2fp64 + integer function division_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = -(x(i, j, 1) + 1.0_real64) * (x(i, j, 2) + 1.0_real64) / 10.0_real64 + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function division_r2fp64 end program test diff --git a/test/division_r3fp32.f90 b/test/division_r3fp32.f90 index e808967..1baaa11 100644 --- a/test/division_r3fp32.f90 +++ b/test/division_r3fp32.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code - - exit_code = division_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = division_r3fp32() + stop exit_code contains -integer function division_r3fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function division_r3fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = -(x(i,j,k,1) + 1.0_real32)*(x(i,j,k,2) + 1.0_real32)*(x(i,j,k,3) + 1.0_real32)/10.0_real32 - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = -(x(i, j, k, 1) + 1.0_real32) * (x(i, j, k, 2) + 1.0_real32) * (x(i, j, k, 3) + 1.0_real32) / 10.0_real32 + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function division_r3fp32 + end function division_r3fp32 end program test diff --git a/test/division_r3fp64.f90 b/test/division_r3fp64.f90 index 40afd00..2d3d70b 100644 --- a/test/division_r3fp64.f90 +++ b/test/division_r3fp64.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code - - exit_code = division_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = division_r3fp64() + stop exit_code contains -integer function division_r3fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function division_r3fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = -(x(i,j,k,1) + 1.0_real64)*(x(i,j,k,2) + 1.0_real64)*(x(i,j,k,3) + 1.0_real64)/10.0_real64 - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = -(x(i, j, k, 1) + 1.0_real64) * (x(i, j, k, 2) + 1.0_real64) * (x(i, j, k, 3) + 1.0_real64) / 10.0_real64 + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function division_r3fp64 + end function division_r3fp64 end program test diff --git a/test/division_r4fp32.f90 b/test/division_r4fp32.f90 index ebeb285..22a48c8 100644 --- a/test/division_r4fp32.f90 +++ b/test/division_r4fp32.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code - - exit_code = division_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = division_r4fp32() + stop exit_code contains -integer function division_r4fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function division_r4fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = -(x(i,j,k,l,1) + 1.0_real32)*(x(i,j,k,l,2) + 1.0_real32)*(x(i,j,k,l,3) + 1.0_real32)/10.0_real32 - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = -(x(i, j, k, l, 1) + 1.0_real32) * (x(i, j, k, l, 2) + 1.0_real32) * (x(i, j, k, l, 3) + 1.0_real32) / 10.0_real32 + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function division_r4fp32 + end function division_r4fp32 end program test diff --git a/test/division_r4fp64.f90 b/test/division_r4fp64.f90 index bc137b5..b94ae27 100644 --- a/test/division_r4fp64.f90 +++ b/test/division_r4fp64.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code - - exit_code = division_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = division_r4fp64() + stop exit_code contains -integer function division_r4fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function division_r4fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = -(x(i,j,k,l,1) + 1.0_real64)*(x(i,j,k,l,2) + 1.0_real64)*(x(i,j,k,l,3) + 1.0_real64)/10.0_real64 - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = -(x(i, j, k, l, 1) + 1.0_real64) * (x(i, j, k, l, 2) + 1.0_real64) * (x(i, j, k, l, 3) + 1.0_real64) / 10.0_real64 + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function division_r4fp64 + end function division_r4fp64 end program test diff --git a/test/division_sfp32.f90 b/test/division_sfp32.f90 index f7d2465..86db1ff 100644 --- a/test/division_sfp32.f90 +++ b/test/division_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = division_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = division_sfp32() + stop exit_code contains -integer function division_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -x/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = -x(1)/10.0_real32 - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function division_sfp32 + integer function division_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -x/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = -x(1) / 10.0_real32 + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function division_sfp32 end program test diff --git a/test/division_sfp64.f90 b/test/division_sfp64.f90 index ecfb390..506d669 100644 --- a/test/division_sfp64.f90 +++ b/test/division_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = division_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = division_sfp64() + stop exit_code contains -integer function division_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -x/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = -x(1)/10.0_real64 - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function division_sfp64 + integer function division_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -x/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = -x(1) / 10.0_real64 + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function division_sfp64 end program test diff --git a/test/gaussian3d_r1fp32.f90 b/test/gaussian3d_r1fp32.f90 index e5d9098..c1c93be 100644 --- a/test/gaussian3d_r1fp32.f90 +++ b/test/gaussian3d_r1fp32.f90 @@ -1,50 +1,50 @@ program test - implicit none - integer :: exit_code - - exit_code = gaussian3d_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = gaussian3d_r1fp32() + stop exit_code contains -integer function gaussian3d_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = exp(-(x(i,1)**2 + x(i,2)**2 + x(i,3)**2)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function gaussian3d_r1fp32 + integer function gaussian3d_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = exp(-(x(i, 1)**2 + x(i, 2)**2 + x(i, 3)**2)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function gaussian3d_r1fp32 end program test diff --git a/test/gaussian3d_r1fp64.f90 b/test/gaussian3d_r1fp64.f90 index 16e6852..a48c90c 100644 --- a/test/gaussian3d_r1fp64.f90 +++ b/test/gaussian3d_r1fp64.f90 @@ -1,50 +1,50 @@ program test - implicit none - integer :: exit_code - - exit_code = gaussian3d_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = gaussian3d_r1fp64() + stop exit_code contains -integer function gaussian3d_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = exp(-(x(i,1)**2 + x(i,2)**2 + x(i,3)**2)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function gaussian3d_r1fp64 + integer function gaussian3d_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = exp(-(x(i, 1)**2 + x(i, 2)**2 + x(i, 3)**2)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function gaussian3d_r1fp64 end program test diff --git a/test/gaussian3d_r2fp32.f90 b/test/gaussian3d_r2fp32.f90 index 5b16b47..86d2a7a 100644 --- a/test/gaussian3d_r2fp32.f90 +++ b/test/gaussian3d_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = gaussian3d_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = gaussian3d_r2fp32() + stop exit_code contains -integer function gaussian3d_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2) )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = exp(-(x(i,j,1)**2 + x(i,j,2)**2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function gaussian3d_r2fp32 + integer function gaussian3d_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2) )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = exp(-(x(i, j, 1)**2 + x(i, j, 2)**2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function gaussian3d_r2fp32 end program test diff --git a/test/gaussian3d_r2fp64.f90 b/test/gaussian3d_r2fp64.f90 index ba4d006..a61f787 100644 --- a/test/gaussian3d_r2fp64.f90 +++ b/test/gaussian3d_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = gaussian3d_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = gaussian3d_r2fp64() + stop exit_code contains -integer function gaussian3d_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2) )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = exp(-(x(i,j,1)**2 + x(i,j,2)**2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function gaussian3d_r2fp64 + integer function gaussian3d_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2) )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = exp(-(x(i, j, 1)**2 + x(i, j, 2)**2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function gaussian3d_r2fp64 end program test diff --git a/test/gaussian3d_r3fp32.f90 b/test/gaussian3d_r3fp32.f90 index 638b472..7d008e4 100644 --- a/test/gaussian3d_r3fp32.f90 +++ b/test/gaussian3d_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = gaussian3d_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = gaussian3d_r3fp32() + stop exit_code contains -integer function gaussian3d_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function gaussian3d_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = exp(-(x(i,j,k,1)**2 + x(i,j,k,2)**2 + x(i,j,k,3)**2)) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = exp(-(x(i, j, k, 1)**2 + x(i, j, k, 2)**2 + x(i, j, k, 3)**2)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function gaussian3d_r3fp32 + end function gaussian3d_r3fp32 end program test diff --git a/test/gaussian3d_r3fp64.f90 b/test/gaussian3d_r3fp64.f90 index 27e79f7..5446f8c 100644 --- a/test/gaussian3d_r3fp64.f90 +++ b/test/gaussian3d_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = gaussian3d_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = gaussian3d_r3fp64() + stop exit_code contains -integer function gaussian3d_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function gaussian3d_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = exp(-(x(i,j,k,1)**2 + x(i,j,k,2)**2 + x(i,j,k,3)**2)) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = exp(-(x(i, j, k, 1)**2 + x(i, j, k, 2)**2 + x(i, j, k, 3)**2)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function gaussian3d_r3fp64 + end function gaussian3d_r3fp64 end program test diff --git a/test/gaussian3d_r4fp32.f90 b/test/gaussian3d_r4fp32.f90 index c4e1a5b..c5d5e49 100644 --- a/test/gaussian3d_r4fp32.f90 +++ b/test/gaussian3d_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = gaussian3d_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = gaussian3d_r4fp32() + stop exit_code contains -integer function gaussian3d_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function gaussian3d_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = exp(-(x(i,j,k,l,1)**2 + x(i,j,k,l,2)**2 + x(i,j,k,l,3)**2)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = exp(-(x(i, j, k, l, 1)**2 + x(i, j, k, l, 2)**2 + x(i, j, k, l, 3)**2)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function gaussian3d_r4fp32 + end function gaussian3d_r4fp32 end program test diff --git a/test/gaussian3d_r4fp64.f90 b/test/gaussian3d_r4fp64.f90 index 774c36c..440083f 100644 --- a/test/gaussian3d_r4fp64.f90 +++ b/test/gaussian3d_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = gaussian3d_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = gaussian3d_r4fp64() + stop exit_code contains -integer function gaussian3d_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function gaussian3d_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = exp(-(x(i,j,k,l,1)**2 + x(i,j,k,l,2)**2 + x(i,j,k,l,3)**2)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = exp(-(x(i, j, k, l, 1)**2 + x(i, j, k, l, 2)**2 + x(i, j, k, l, 3)**2)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function gaussian3d_r4fp64 + end function gaussian3d_r4fp64 end program test diff --git a/test/gaussian3d_sfp32.f90 b/test/gaussian3d_sfp32.f90 index 9bed757..c04a0e3 100644 --- a/test/gaussian3d_sfp32.f90 +++ b/test/gaussian3d_sfp32.f90 @@ -1,39 +1,39 @@ program test - implicit none - integer :: exit_code - - exit_code = gaussian3d_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = gaussian3d_sfp32() + stop exit_code contains -integer function gaussian3d_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none + integer function gaussian3d_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - ! Evaluate the equation - x = (/0.0,0.0,0.0/) - if (abs(f % evaluate(x) - 1.0) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + x = (/0.0, 0.0, 0.0/) + if (abs(f%evaluate(x) - 1.0) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if -end function gaussian3d_sfp32 + end function gaussian3d_sfp32 end program test diff --git a/test/gaussian3d_sfp64.f90 b/test/gaussian3d_sfp64.f90 index 8c38e82..a80eacf 100644 --- a/test/gaussian3d_sfp64.f90 +++ b/test/gaussian3d_sfp64.f90 @@ -1,39 +1,39 @@ program test - implicit none - integer :: exit_code - - exit_code = gaussian3d_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = gaussian3d_sfp64() + stop exit_code contains -integer function gaussian3d_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none + integer function gaussian3d_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - ! Evaluate the equation - x = (/0.0,0.0,0.0/) - if (abs(f % evaluate(x) - 1.0) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + x = (/0.0, 0.0, 0.0/) + if (abs(f%evaluate(x) - 1.0) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if -end function gaussian3d_sfp64 + end function gaussian3d_sfp64 end program test diff --git a/test/linear_r1fp32.f90 b/test/linear_r1fp32.f90 index a8ac37c..437aa37 100644 --- a/test/linear_r1fp32.f90 +++ b/test/linear_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = linear_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = linear_r1fp32() + stop exit_code contains -integer function linear_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = x^3-1' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = x(i,1)**3 - 1.0_real32 - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function linear_r1fp32 + integer function linear_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = x^3-1' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = x(i, 1)**3 - 1.0_real32 + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function linear_r1fp32 end program test diff --git a/test/linear_r1fp64.f90 b/test/linear_r1fp64.f90 index 2275165..c2a5eba 100644 --- a/test/linear_r1fp64.f90 +++ b/test/linear_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = linear_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = linear_r1fp64() + stop exit_code contains -integer function linear_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = x^3-1' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = x(i,1)**3 - 1.0_real64 - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function linear_r1fp64 + integer function linear_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = x^3-1' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = x(i, 1)**3 - 1.0_real64 + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function linear_r1fp64 end program test diff --git a/test/linear_r2fp32.f90 b/test/linear_r2fp32.f90 index bcf49b6..507d5f6 100644 --- a/test/linear_r2fp32.f90 +++ b/test/linear_r2fp32.f90 @@ -1,59 +1,59 @@ program test - implicit none - integer :: exit_code - - exit_code = linear_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = linear_r2fp32() + stop exit_code contains -integer function linear_r2fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = (x(i,j,1)**3 - 1.0_real32)*(x(i,j,2)**3 - 1.0_real32) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real32*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function linear_r2fp32 + integer function linear_r2fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = (x(i, j, 1)**3 - 1.0_real32) * (x(i, j, 2)**3 - 1.0_real32) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= 10.0_real32 * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function linear_r2fp32 end program test diff --git a/test/linear_r2fp64.f90 b/test/linear_r2fp64.f90 index 4bc50d1..1609b80 100644 --- a/test/linear_r2fp64.f90 +++ b/test/linear_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = linear_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = linear_r2fp64() + stop exit_code contains -integer function linear_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = (x(i,j,1)**3 - 1.0_real64)*(x(i,j,2)**3 - 1.0_real64) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function linear_r2fp64 + integer function linear_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = (x(i, j, 1)**3 - 1.0_real64) * (x(i, j, 2)**3 - 1.0_real64) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function linear_r2fp64 end program test diff --git a/test/linear_r3fp32.f90 b/test/linear_r3fp32.f90 index 0e42f7b..49e710b 100644 --- a/test/linear_r3fp32.f90 +++ b/test/linear_r3fp32.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code - - exit_code = linear_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = linear_r3fp32() + stop exit_code contains -integer function linear_r3fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function linear_r3fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = (x(i,j,k,1)**3 - 1.0_real32)*(x(i,j,k,2)**3 - 1.0_real32)*(x(i,j,k,3)**3 - 1.0_real32) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = (x(i, j, k, 1)**3 - 1.0_real32) * (x(i, j, k, 2)**3 - 1.0_real32) * (x(i, j, k, 3)**3 - 1.0_real32) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function linear_r3fp32 + end function linear_r3fp32 end program test diff --git a/test/linear_r3fp64.f90 b/test/linear_r3fp64.f90 index 2d8ad58..c6d16e9 100644 --- a/test/linear_r3fp64.f90 +++ b/test/linear_r3fp64.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code - - exit_code = linear_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = linear_r3fp64() + stop exit_code contains -integer function linear_r3fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function linear_r3fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = (x(i,j,k,1)**3 - 1.0_real64)*(x(i,j,k,2)**3 - 1.0_real64)*(x(i,j,k,3)**3 - 1.0_real64) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = (x(i, j, k, 1)**3 - 1.0_real64) * (x(i, j, k, 2)**3 - 1.0_real64) * (x(i, j, k, 3)**3 - 1.0_real64) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function linear_r3fp64 + end function linear_r3fp64 end program test diff --git a/test/linear_r4fp32.f90 b/test/linear_r4fp32.f90 index ad23d62..f431e69 100644 --- a/test/linear_r4fp32.f90 +++ b/test/linear_r4fp32.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code - - exit_code = linear_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = linear_r4fp32() + stop exit_code contains -integer function linear_r4fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function linear_r4fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = (x(i,j,k,l,1)**3 - 1.0_real32)*(x(i,j,k,l,2)**3 - 1.0_real32)*(x(i,j,k,l,3)**3 - 1.0_real32) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = (x(i, j, k, l, 1)**3 - 1.0_real32) * (x(i, j, k, l, 2)**3 - 1.0_real32) * (x(i, j, k, l, 3)**3 - 1.0_real32) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function linear_r4fp32 + end function linear_r4fp32 end program test diff --git a/test/linear_r4fp64.f90 b/test/linear_r4fp64.f90 index ce75402..e41799d 100644 --- a/test/linear_r4fp64.f90 +++ b/test/linear_r4fp64.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code - - exit_code = linear_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = linear_r4fp64() + stop exit_code contains -integer function linear_r4fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function linear_r4fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = (x(i,j,k,l,1)**3 - 1.0_real64)*(x(i,j,k,l,2)**3 - 1.0_real64)*(x(i,j,k,l,3)**3 - 1.0_real64) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = (x(i, j, k, l, 1)**3 - 1.0_real64) * (x(i, j, k, l, 2)**3 - 1.0_real64) * (x(i, j, k, l, 3)**3 - 1.0_real64) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function linear_r4fp64 + end function linear_r4fp64 end program test diff --git a/test/log10_r1fp32.f90 b/test/log10_r1fp32.f90 index 8f25b84..4ce7551 100644 --- a/test/log10_r1fp32.f90 +++ b/test/log10_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = log10_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log10_r1fp32() + stop exit_code contains -integer function log10_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = log10(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function log10_r1fp32 + integer function log10_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = log10(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function log10_r1fp32 end program test diff --git a/test/log10_r1fp64.f90 b/test/log10_r1fp64.f90 index 5f36acc..cd3df6e 100644 --- a/test/log10_r1fp64.f90 +++ b/test/log10_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = log10_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log10_r1fp64() + stop exit_code contains -integer function log10_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = log10(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function log10_r1fp64 + integer function log10_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = log10(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function log10_r1fp64 end program test diff --git a/test/log10_r2fp32.f90 b/test/log10_r2fp32.f90 index b52fefc..82dd22a 100644 --- a/test/log10_r2fp32.f90 +++ b/test/log10_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = log10_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log10_r2fp32() + stop exit_code contains -integer function log10_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10(y)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = log10(x(i,j,1))*log10(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function log10_r2fp32 + integer function log10_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10(y)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = log10(x(i, j, 1)) * log10(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function log10_r2fp32 end program test diff --git a/test/log10_r2fp64.f90 b/test/log10_r2fp64.f90 index 985f2bd..aea55f2 100644 --- a/test/log10_r2fp64.f90 +++ b/test/log10_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = log10_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log10_r2fp64() + stop exit_code contains -integer function log10_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = log10(x(i,j,1))*log10(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function log10_r2fp64 + integer function log10_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = log10(x(i, j, 1)) * log10(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function log10_r2fp64 end program test diff --git a/test/log10_r3fp32.f90 b/test/log10_r3fp32.f90 index f3e7280..8c7de7b 100644 --- a/test/log10_r3fp32.f90 +++ b/test/log10_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = log10_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log10_r3fp32() + stop exit_code contains -integer function log10_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function log10_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10(y)*log10(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10(y)*log10(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = log10(x(i,j,k,1))*log10(x(i,j,k,2))*log10(x(i,j,k,3)) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = log10(x(i, j, k, 1)) * log10(x(i, j, k, 2)) * log10(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function log10_r3fp32 + end function log10_r3fp32 end program test diff --git a/test/log10_r3fp64.f90 b/test/log10_r3fp64.f90 index 1360f47..19476a6 100644 --- a/test/log10_r3fp64.f90 +++ b/test/log10_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = log10_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log10_r3fp64() + stop exit_code contains -integer function log10_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function log10_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10(y)*log10(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10(y)*log10(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = log10(x(i,j,k,1))*log10(x(i,j,k,2))*log10(x(i,j,k,3)) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = log10(x(i, j, k, 1)) * log10(x(i, j, k, 2)) * log10(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function log10_r3fp64 + end function log10_r3fp64 end program test diff --git a/test/log10_r4fp32.f90 b/test/log10_r4fp32.f90 index 1846703..b73e44a 100644 --- a/test/log10_r4fp32.f90 +++ b/test/log10_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = log10_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log10_r4fp32() + stop exit_code contains -integer function log10_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function log10_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10(y)*log10(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10(y)*log10(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = log10(x(i,j,k,l,1))*log10(x(i,j,k,l,2))*log10(x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = log10(x(i, j, k, l, 1)) * log10(x(i, j, k, l, 2)) * log10(x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function log10_r4fp32 + end function log10_r4fp32 end program test diff --git a/test/log10_r4fp64.f90 b/test/log10_r4fp64.f90 index 34a92be..bbd698e 100644 --- a/test/log10_r4fp64.f90 +++ b/test/log10_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = log10_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log10_r4fp64() + stop exit_code contains -integer function log10_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function log10_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10(y)*log10(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10(y)*log10(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = log10(x(i,j,k,l,1))*log10(x(i,j,k,l,2))*log10(x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = log10(x(i, j, k, l, 1)) * log10(x(i, j, k, l, 2)) * log10(x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function log10_r4fp64 + end function log10_r4fp64 end program test diff --git a/test/log10_sfp32.f90 b/test/log10_sfp32.f90 index c0172e8..49c852f 100644 --- a/test/log10_sfp32.f90 +++ b/test/log10_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = log10_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log10_sfp32() + stop exit_code contains -integer function log10_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 10.0_real32 - fexact = log10(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function log10_sfp32 + integer function log10_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 10.0_real32 + fexact = log10(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function log10_sfp32 end program test diff --git a/test/log10_sfp64.f90 b/test/log10_sfp64.f90 index 1174e8a..305d712 100644 --- a/test/log10_sfp64.f90 +++ b/test/log10_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = log10_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log10_sfp64() + stop exit_code contains -integer function log10_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 10.0_real64 - fexact = log10(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function log10_sfp64 + integer function log10_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 10.0_real64 + fexact = log10(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function log10_sfp64 end program test diff --git a/test/log_r1fp32.f90 b/test/log_r1fp32.f90 index 8bfd0a9..e8a24da 100644 --- a/test/log_r1fp32.f90 +++ b/test/log_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = log_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log_r1fp32() + stop exit_code contains -integer function log_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = log(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function log_r1fp32 + integer function log_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = log(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function log_r1fp32 end program test diff --git a/test/log_r1fp64.f90 b/test/log_r1fp64.f90 index 50db889..003a069 100644 --- a/test/log_r1fp64.f90 +++ b/test/log_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = log_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log_r1fp64() + stop exit_code contains -integer function log_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = log(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function log_r1fp64 + integer function log_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = log(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function log_r1fp64 end program test diff --git a/test/log_r2fp32.f90 b/test/log_r2fp32.f90 index 5fa351c..e307c39 100644 --- a/test/log_r2fp32.f90 +++ b/test/log_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = log_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log_r2fp32() + stop exit_code contains -integer function log_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = log(x(i,j,1))*log(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function log_r2fp32 + integer function log_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = log(x(i, j, 1)) * log(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function log_r2fp32 end program test diff --git a/test/log_r2fp64.f90 b/test/log_r2fp64.f90 index 2f72769..b8650db 100644 --- a/test/log_r2fp64.f90 +++ b/test/log_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = log_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log_r2fp64() + stop exit_code contains -integer function log_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = log(x(i,j,1))*log(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function log_r2fp64 + integer function log_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = log(x(i, j, 1)) * log(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function log_r2fp64 end program test diff --git a/test/log_r3fp32.f90 b/test/log_r3fp32.f90 index efaf06e..6ab8828 100644 --- a/test/log_r3fp32.f90 +++ b/test/log_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = log_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log_r3fp32() + stop exit_code contains -integer function log_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function log_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)*ln(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)*ln(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = log(x(i,j,k,1))*log(x(i,j,k,2))*log(x(i,j,k,3)) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = log(x(i, j, k, 1)) * log(x(i, j, k, 2)) * log(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function log_r3fp32 + end function log_r3fp32 end program test diff --git a/test/log_r3fp64.f90 b/test/log_r3fp64.f90 index d499f73..99bdd8e 100644 --- a/test/log_r3fp64.f90 +++ b/test/log_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = log_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log_r3fp64() + stop exit_code contains -integer function log_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function log_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)*ln(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)*ln(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = log(x(i,j,k,1))*log(x(i,j,k,2))*log(x(i,j,k,3)) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = log(x(i, j, k, 1)) * log(x(i, j, k, 2)) * log(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function log_r3fp64 + end function log_r3fp64 end program test diff --git a/test/log_r4fp32.f90 b/test/log_r4fp32.f90 index b015dd6..e47b632 100644 --- a/test/log_r4fp32.f90 +++ b/test/log_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = log_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log_r4fp32() + stop exit_code contains -integer function log_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function log_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)*ln(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)*ln(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = 1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = log(x(i,j,k,l,1))*log(x(i,j,k,l,2))*log(x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = log(x(i, j, k, l, 1)) * log(x(i, j, k, l, 2)) * log(x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function log_r4fp32 + end function log_r4fp32 end program test diff --git a/test/log_r4fp64.f90 b/test/log_r4fp64.f90 index 3c42a71..a055ffa 100644 --- a/test/log_r4fp64.f90 +++ b/test/log_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = log_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log_r4fp64() + stop exit_code contains -integer function log_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function log_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)*ln(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)*ln(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = 1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = log(x(i,j,k,l,1))*log(x(i,j,k,l,2))*log(x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = log(x(i, j, k, l, 1)) * log(x(i, j, k, l, 2)) * log(x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function log_r4fp64 + end function log_r4fp64 end program test diff --git a/test/log_sfp32.f90 b/test/log_sfp32.f90 index 8691c2d..903e21d 100644 --- a/test/log_sfp32.f90 +++ b/test/log_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = log_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log_sfp32() + stop exit_code contains -integer function log_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 1.0_real32 - fexact = log(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function log_sfp32 + integer function log_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 1.0_real32 + fexact = log(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function log_sfp32 end program test diff --git a/test/log_sfp64.f90 b/test/log_sfp64.f90 index 2e59394..865c36a 100644 --- a/test/log_sfp64.f90 +++ b/test/log_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = log_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = log_sfp64() + stop exit_code contains -integer function log_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 1.0_real64 - fexact = log(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function log_sfp64 + integer function log_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 1.0_real64 + fexact = log(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function log_sfp64 end program test diff --git a/test/monadic_r1fp32.f90 b/test/monadic_r1fp32.f90 index c7a18d7..ca06d37 100644 --- a/test/monadic_r1fp32.f90 +++ b/test/monadic_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = monadic_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = monadic_r1fp32() + stop exit_code contains -integer function monadic_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x + 1)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = -x(i,1)-1.0_real32 - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function monadic_r1fp32 + integer function monadic_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x + 1)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = -x(i, 1) - 1.0_real32 + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function monadic_r1fp32 end program test diff --git a/test/monadic_r1fp64.f90 b/test/monadic_r1fp64.f90 index 2f90859..5091c83 100644 --- a/test/monadic_r1fp64.f90 +++ b/test/monadic_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = monadic_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = monadic_r1fp64() + stop exit_code contains -integer function monadic_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x + 1)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = -x(i,1)-1.0_real64 - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function monadic_r1fp64 + integer function monadic_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x + 1)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = -x(i, 1) - 1.0_real64 + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function monadic_r1fp64 end program test diff --git a/test/monadic_r2fp32.f90 b/test/monadic_r2fp32.f90 index 5d6100c..0f10378 100644 --- a/test/monadic_r2fp32.f90 +++ b/test/monadic_r2fp32.f90 @@ -1,59 +1,59 @@ program test - implicit none - integer :: exit_code - - exit_code = monadic_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = monadic_r2fp32() + stop exit_code contains -integer function monadic_r2fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = -(x(i,j,1) + 1.0_real32)*(x(i,j,2) + 1.0_real32) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real32*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function monadic_r2fp32 + integer function monadic_r2fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = -(x(i, j, 1) + 1.0_real32) * (x(i, j, 2) + 1.0_real32) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= 10.0_real32 * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function monadic_r2fp32 end program test diff --git a/test/monadic_r2fp64.f90 b/test/monadic_r2fp64.f90 index cfab9aa..134d861 100644 --- a/test/monadic_r2fp64.f90 +++ b/test/monadic_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = monadic_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = monadic_r2fp64() + stop exit_code contains -integer function monadic_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = -(x(i,j,1) + 1.0_real64)*(x(i,j,2) + 1.0_real64) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function monadic_r2fp64 + integer function monadic_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = -(x(i, j, 1) + 1.0_real64) * (x(i, j, 2) + 1.0_real64) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function monadic_r2fp64 end program test diff --git a/test/monadic_r3fp32.f90 b/test/monadic_r3fp32.f90 index 1a7fe09..3e38a7c 100644 --- a/test/monadic_r3fp32.f90 +++ b/test/monadic_r3fp32.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code - - exit_code = monadic_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = monadic_r3fp32() + stop exit_code contains -integer function monadic_r3fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function monadic_r3fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = -(x(i,j,k,1) + 1.0_real32)*(x(i,j,k,2) + 1.0_real32)*(x(i,j,k,3) + 1.0_real32) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = -(x(i, j, k, 1) + 1.0_real32) * (x(i, j, k, 2) + 1.0_real32) * (x(i, j, k, 3) + 1.0_real32) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function monadic_r3fp32 + end function monadic_r3fp32 end program test diff --git a/test/monadic_r3fp64.f90 b/test/monadic_r3fp64.f90 index 611dc03..47dac43 100644 --- a/test/monadic_r3fp64.f90 +++ b/test/monadic_r3fp64.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code - - exit_code = monadic_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = monadic_r3fp64() + stop exit_code contains -integer function monadic_r3fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function monadic_r3fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = -(x(i,j,k,1) + 1.0_real64)*(x(i,j,k,2) + 1.0_real64)*(x(i,j,k,3) + 1.0_real64) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = -(x(i, j, k, 1) + 1.0_real64) * (x(i, j, k, 2) + 1.0_real64) * (x(i, j, k, 3) + 1.0_real64) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function monadic_r3fp64 + end function monadic_r3fp64 end program test diff --git a/test/monadic_r4fp32.f90 b/test/monadic_r4fp32.f90 index b2aa4a8..2d42c15 100644 --- a/test/monadic_r4fp32.f90 +++ b/test/monadic_r4fp32.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code - - exit_code = monadic_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = monadic_r4fp32() + stop exit_code contains -integer function monadic_r4fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function monadic_r4fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = -(x(i,j,k,l,1) + 1.0_real32)*(x(i,j,k,l,2) + 1.0_real32)*(x(i,j,k,l,3) + 1.0_real32) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = -(x(i, j, k, l, 1) + 1.0_real32) * (x(i, j, k, l, 2) + 1.0_real32) * (x(i, j, k, l, 3) + 1.0_real32) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function monadic_r4fp32 + end function monadic_r4fp32 end program test diff --git a/test/monadic_r4fp64.f90 b/test/monadic_r4fp64.f90 index da7e553..6c4de74 100644 --- a/test/monadic_r4fp64.f90 +++ b/test/monadic_r4fp64.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code - - exit_code = monadic_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = monadic_r4fp64() + stop exit_code contains -integer function monadic_r4fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function monadic_r4fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = -(x(i,j,k,l,1) + 1.0_real64)*(x(i,j,k,l,2) + 1.0_real64)*(x(i,j,k,l,3) + 1.0_real64) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = -(x(i, j, k, l, 1) + 1.0_real64) * (x(i, j, k, l, 2) + 1.0_real64) * (x(i, j, k, l, 3) + 1.0_real64) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function monadic_r4fp64 + end function monadic_r4fp64 end program test diff --git a/test/monadic_sfp32.f90 b/test/monadic_sfp32.f90 index 1ee2366..837268a 100644 --- a/test/monadic_sfp32.f90 +++ b/test/monadic_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = monadic_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = monadic_sfp32() + stop exit_code contains -integer function monadic_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x + 1)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = -(x(1)+1.0_real32) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function monadic_sfp32 + integer function monadic_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x + 1)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = -(x(1) + 1.0_real32) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function monadic_sfp32 end program test diff --git a/test/monadic_sfp64.f90 b/test/monadic_sfp64.f90 index f1aafd3..9dd0d40 100644 --- a/test/monadic_sfp64.f90 +++ b/test/monadic_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = monadic_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = monadic_sfp64() + stop exit_code contains -integer function monadic_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x + 1)' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = -(x(1)+1.0_real64) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function monadic_sfp64 + integer function monadic_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x + 1)' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = -(x(1) + 1.0_real64) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function monadic_sfp64 end program test diff --git a/test/parsing_difficult_r1fp64.f90 b/test/parsing_difficult_r1fp64.f90 index 08570f9..159c4c9 100644 --- a/test/parsing_difficult_r1fp64.f90 +++ b/test/parsing_difficult_r1fp64.f90 @@ -2,39 +2,39 @@ program test use iso_fortran_env, only: i1 => int8, i2 => int16, i4 => int32, i8 => int64, & r4 => real32, r8 => real64, r16 => real128 use FEQParse - + implicit none - + real(r8) :: results(24) integer j data(results(j), j=1, 24) / 0.9508_r8, & - 0.7958_r8, & - 0.2846_r8, & - 1.1247_r8, & - 0.9177_r8, & - 1.0599_r8, & - 0.8064_r8, & - 3.2193_r8, & - 0.9981_r8, & - 0.8366_r8, & - 0.9441_r8, & - 0.1457_r8, & - 4.2508_r8, & - 1.2064_r8, & - 1.2227_r8, & - 20.6962_r8, & - 112.1323_r8, & - 1.5597_r8, & - 7.5806_r8, & - 1.5574_r8, & - 0.8869_r8, & - 3.0118_r8, & - 5.4819_r8, & - 1.5311_r8 / - + 0.7958_r8, & + 0.2846_r8, & + 1.1247_r8, & + 0.9177_r8, & + 1.0599_r8, & + 0.8064_r8, & + 3.2193_r8, & + 0.9981_r8, & + 0.8366_r8, & + 0.9441_r8, & + 0.1457_r8, & + 4.2508_r8, & + 1.2064_r8, & + 1.2227_r8, & + 20.6962_r8, & + 112.1323_r8, & + 1.5597_r8, & + 7.5806_r8, & + 1.5574_r8, & + 0.8869_r8, & + 3.0118_r8, & + 5.4819_r8, & + 1.5311_r8 / + character(200) :: test_data(1:24) data(test_data(j), j=1, 24)/ & - 'a+b*x1', & + 'a+b*x1', & '(a*x**b)/(c+x**b)', & '(a*x)/(b+(x*(1+x/c)))', & 'a+b*exp(c*x)+d*exp(e*x)', & @@ -58,22 +58,22 @@ program test '(x+a)/(b+c*(x+a)+d*(x+a)**2)', & '(x+y+z+x*y+x*z+y*z+x/y+x/z+y/z+x*cos(x)+y*sin(y)+z*tan(z)*2/(x+y+z+x*y+x*z+y*z+x/y+ & & x/z+y/z+x*cos(x)+y*sin(y)+z*tan(z))*3+sqrt(x*y*z+x+y+z)*log10(sqrt(x*2+y*2+z*2)+x+y+z))', & - 'a+b*log(x1)+c*log(x1)**2+d*log(x1)**3+e/x'/ - - character(len=10),dimension(1:11) :: independentvars + 'a+b*log(x1)+c*log(x1)**2+d*log(x1)**3+e/x'/ + + character(len=10), dimension(1:11) :: independentvars real(r8) :: x(1:11) - + call initialize() - + do j = 1, 24 - write(*,'(A,A,I20)') "parsing ", test_data(j), parsing(j) + write (*, '(A,A,I20)') "parsing ", test_data(j), parsing(j) end do - + contains - + subroutine initialize() independentvars = ['x ', 'y ', 'z ', 'x1', 'x2', & - 'a ', 'b ', 'c ', 'd ', 'e ', 'f '] + 'a ', 'b ', 'c ', 'd ', 'e ', 'f '] x(1) = 0.175_r8 x(2) = 0.110_r8 x(3) = 0.900_r8 @@ -86,7 +86,7 @@ subroutine initialize() x(10) = 0.120_r8 x(11) = 0.140_r8 end subroutine - + integer function parsing(i) result(r) integer, intent(in) :: i !private @@ -100,5 +100,5 @@ integer function parsing(i) result(r) r = 1 end if end function - -end program \ No newline at end of file + +end program diff --git a/test/print_tokens.f90 b/test/print_tokens.f90 index d74f75d..8e05d6d 100644 --- a/test/print_tokens.f90 +++ b/test/print_tokens.f90 @@ -1,35 +1,35 @@ program test - implicit none - integer :: exit_code - - exit_code = print_tokens() - stop exit_code + implicit none + integer :: exit_code + + exit_code = print_tokens() + stop exit_code contains -integer function print_tokens() result(r) - use FEQParse - use iso_fortran_env - implicit none - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar + integer function print_tokens() result(r) + use FEQParse + use iso_fortran_env + implicit none + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(cos( 2.0*pi*x ) + 5.0)/(sin(2.0*pi*y) + 10.0)*tanh(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(cos( 2.0*pi*x ) + 5.0)/(sin(2.0*pi*y) + 10.0)*tanh(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - call f % Print_InfixTokens() - call f % Print_PostfixTokens() + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + call f%Print_InfixTokens() + call f%Print_PostfixTokens() - ! Clean up memory + ! Clean up memory - r=0 + r = 0 -end function print_tokens + end function print_tokens end program test diff --git a/test/random_r1fp32.f90 b/test/random_r1fp32.f90 index 1f2b7a9..a29c89d 100644 --- a/test/random_r1fp32.f90 +++ b/test/random_r1fp32.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code - - exit_code = random_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = random_r1fp32() + stop exit_code contains -integer function random_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - end if - -end function random_r1fp32 + integer function random_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval)) <= 1.0_real32) then + r = 0 + else + r = 1 + end if + + end function random_r1fp32 end program test diff --git a/test/random_r1fp64.f90 b/test/random_r1fp64.f90 index 2a85906..e479cf0 100644 --- a/test/random_r1fp64.f90 +++ b/test/random_r1fp64.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code - - exit_code = random_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = random_r1fp64() + stop exit_code contains -integer function random_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - end if - -end function random_r1fp64 + integer function random_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval)) <= 1.0_real64) then + r = 0 + else + r = 1 + end if + + end function random_r1fp64 end program test diff --git a/test/random_r2fp32.f90 b/test/random_r2fp32.f90 index 98aa14b..540e5e6 100644 --- a/test/random_r2fp32.f90 +++ b/test/random_r2fp32.f90 @@ -1,54 +1,54 @@ program test - implicit none - integer :: exit_code - - exit_code = random_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = random_r2fp32() + stop exit_code contains -integer function random_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval) - -end function random_r2fp32 + integer function random_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval)) <= 1.0_real32) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval) + + end function random_r2fp32 end program test diff --git a/test/random_r2fp64.f90 b/test/random_r2fp64.f90 index 317c726..82480aa 100644 --- a/test/random_r2fp64.f90 +++ b/test/random_r2fp64.f90 @@ -1,54 +1,54 @@ program test - implicit none - integer :: exit_code - - exit_code = random_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = random_r2fp64() + stop exit_code contains -integer function random_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval) - -end function random_r2fp64 + integer function random_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval)) <= 1.0_real64) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval) + + end function random_r2fp64 end program test diff --git a/test/random_r3fp32.f90 b/test/random_r3fp32.f90 index f5c3dc5..bdbef65 100644 --- a/test/random_r3fp32.f90 +++ b/test/random_r3fp32.f90 @@ -1,59 +1,59 @@ program test - implicit none - integer :: exit_code - - exit_code = random_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = random_r3fp32() + stop exit_code contains -integer function random_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k - - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function random_r3fp32 + integer function random_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k + + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )*rand( z )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval)) <= 1.0_real32) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function random_r3fp32 end program test diff --git a/test/random_r3fp64.f90 b/test/random_r3fp64.f90 index 682f59c..af620cc 100644 --- a/test/random_r3fp64.f90 +++ b/test/random_r3fp64.f90 @@ -1,59 +1,59 @@ program test - implicit none - integer :: exit_code - - exit_code = random_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = random_r3fp64() + stop exit_code contains -integer function random_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k - - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function random_r3fp64 + integer function random_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k + + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )*rand( z )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval)) <= 1.0_real64) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function random_r3fp64 end program test diff --git a/test/random_r4fp32.f90 b/test/random_r4fp32.f90 index 1c1a07c..5daca22 100644 --- a/test/random_r4fp32.f90 +++ b/test/random_r4fp32.f90 @@ -1,62 +1,62 @@ program test - implicit none - integer :: exit_code - - exit_code = random_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = random_r4fp32() + stop exit_code contains -integer function random_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l - - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (0.1_real32)/real(N,real32)*real(i - 1,real32) + 0.1_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (0.1_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (0.1_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function random_r4fp32 + integer function random_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l + + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )*rand( z )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (0.1_real32) / real(N, real32) * real(i - 1, real32) + 0.1_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (0.1_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (0.1_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval)) <= 1.0_real32) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function random_r4fp32 end program test diff --git a/test/random_r4fp64.f90 b/test/random_r4fp64.f90 index 2f09f39..213262d 100644 --- a/test/random_r4fp64.f90 +++ b/test/random_r4fp64.f90 @@ -1,62 +1,62 @@ program test - implicit none - integer :: exit_code - - exit_code = random_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = random_r4fp64() + stop exit_code contains -integer function random_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l - - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (0.1_real64)/real(N,real64)*real(i - 1,real64) + 0.1_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (0.1_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (0.1_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function random_r4fp64 + integer function random_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l + + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )*rand( z )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (0.1_real64) / real(N, real64) * real(i - 1, real64) + 0.1_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (0.1_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (0.1_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval)) <= 1.0_real64) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function random_r4fp64 end program test diff --git a/test/random_sfp32.f90 b/test/random_sfp32.f90 index 8a72d25..09be090 100644 --- a/test/random_sfp32.f90 +++ b/test/random_sfp32.f90 @@ -1,43 +1,43 @@ program test - implicit none - integer :: exit_code - - exit_code = random_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = random_sfp32() + stop exit_code contains -integer function random_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - end if - -end function random_sfp32 + integer function random_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval)) <= 1.0_real32) then + r = 0 + else + r = 1 + end if + + end function random_sfp32 end program test diff --git a/test/random_sfp64.f90 b/test/random_sfp64.f90 index b1fe8c8..8468471 100644 --- a/test/random_sfp64.f90 +++ b/test/random_sfp64.f90 @@ -1,43 +1,43 @@ program test - implicit none - integer :: exit_code - - exit_code = random_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = random_sfp64() + stop exit_code contains -integer function random_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - end if - -end function random_sfp64 + integer function random_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval)) <= 1.0_real64) then + r = 0 + else + r = 1 + end if + + end function random_sfp64 end program test diff --git a/test/sech_r1fp32.f90 b/test/sech_r1fp32.f90 index 048f35f..695057d 100644 --- a/test/sech_r1fp32.f90 +++ b/test/sech_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = sech_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sech_r1fp32() + stop exit_code contains -integer function sech_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = 2.0_real32/(exp(x(i,1)) + exp(-x(i,1))) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function sech_r1fp32 + integer function sech_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = 2.0_real32 / (exp(x(i, 1)) + exp(-x(i, 1))) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function sech_r1fp32 end program test diff --git a/test/sech_r1fp64.f90 b/test/sech_r1fp64.f90 index 6ef37a0..a229071 100644 --- a/test/sech_r1fp64.f90 +++ b/test/sech_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = sech_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sech_r1fp64() + stop exit_code contains -integer function sech_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = 2.0_real64/(exp(x(i,1)) + exp(-x(i,1))) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function sech_r1fp64 + integer function sech_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = 2.0_real64 / (exp(x(i, 1)) + exp(-x(i, 1))) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function sech_r1fp64 end program test diff --git a/test/sech_r2fp32.f90 b/test/sech_r2fp32.f90 index 60deb60..82ce994 100644 --- a/test/sech_r2fp32.f90 +++ b/test/sech_r2fp32.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code - - exit_code = sech_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sech_r2fp32() + stop exit_code contains -integer function sech_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = 2.0_real32/(exp(x(i,j,1)) + exp(-x(i,j,1)))* & - 2.0_real32/(exp(x(i,j,2)) + exp(-x(i,j,2))) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function sech_r2fp32 + integer function sech_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = 2.0_real32 / (exp(x(i, j, 1)) + exp(-x(i, j, 1))) * & + 2.0_real32 / (exp(x(i, j, 2)) + exp(-x(i, j, 2))) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function sech_r2fp32 end program test diff --git a/test/sech_r2fp64.f90 b/test/sech_r2fp64.f90 index d70193b..6b62bd3 100644 --- a/test/sech_r2fp64.f90 +++ b/test/sech_r2fp64.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code - - exit_code = sech_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sech_r2fp64() + stop exit_code contains -integer function sech_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = 2.0_real64/(exp(x(i,j,1)) + exp(-x(i,j,1)))* & - 2.0_real64/(exp(x(i,j,2)) + exp(-x(i,j,2))) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function sech_r2fp64 + integer function sech_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = 2.0_real64 / (exp(x(i, j, 1)) + exp(-x(i, j, 1))) * & + 2.0_real64 / (exp(x(i, j, 2)) + exp(-x(i, j, 2))) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function sech_r2fp64 end program test diff --git a/test/sech_r3fp32.f90 b/test/sech_r3fp32.f90 index 9a623e0..82bac74 100644 --- a/test/sech_r3fp32.f90 +++ b/test/sech_r3fp32.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code - - exit_code = sech_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sech_r3fp32() + stop exit_code contains -integer function sech_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function sech_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )*sech(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )*sech(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = 2.0_real32/(exp(x(i,j,k,1)) + exp(-x(i,j,k,1)))* & - 2.0_real32/(exp(x(i,j,k,2)) + exp(-x(i,j,k,2)))* & - 2.0_real32/(exp(x(i,j,k,3)) + exp(-x(i,j,k,3))) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = 2.0_real32 / (exp(x(i, j, k, 1)) + exp(-x(i, j, k, 1))) * & + 2.0_real32 / (exp(x(i, j, k, 2)) + exp(-x(i, j, k, 2))) * & + 2.0_real32 / (exp(x(i, j, k, 3)) + exp(-x(i, j, k, 3))) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function sech_r3fp32 + end function sech_r3fp32 end program test diff --git a/test/sech_r3fp64.f90 b/test/sech_r3fp64.f90 index af399af..3ef5561 100644 --- a/test/sech_r3fp64.f90 +++ b/test/sech_r3fp64.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code - - exit_code = sech_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sech_r3fp64() + stop exit_code contains -integer function sech_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function sech_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )*sech(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )*sech(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = 2.0_real64/(exp(x(i,j,k,1)) + exp(-x(i,j,k,1)))* & - 2.0_real64/(exp(x(i,j,k,2)) + exp(-x(i,j,k,2)))* & - 2.0_real64/(exp(x(i,j,k,3)) + exp(-x(i,j,k,3))) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = 2.0_real64 / (exp(x(i, j, k, 1)) + exp(-x(i, j, k, 1))) * & + 2.0_real64 / (exp(x(i, j, k, 2)) + exp(-x(i, j, k, 2))) * & + 2.0_real64 / (exp(x(i, j, k, 3)) + exp(-x(i, j, k, 3))) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function sech_r3fp64 + end function sech_r3fp64 end program test diff --git a/test/sech_r4fp32.f90 b/test/sech_r4fp32.f90 index 1f2b90f..2e9f66e 100644 --- a/test/sech_r4fp32.f90 +++ b/test/sech_r4fp32.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code - - exit_code = sech_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sech_r4fp32() + stop exit_code contains -integer function sech_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function sech_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )*sech(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )*sech(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = 2.0_real32/(exp(x(i,j,k,l,1)) + exp(-x(i,j,k,l,1)))* & - 2.0_real32/(exp(x(i,j,k,l,2)) + exp(-x(i,j,k,l,2)))* & - 2.0_real32/(exp(x(i,j,k,l,3)) + exp(-x(i,j,k,l,3))) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = 2.0_real32 / (exp(x(i, j, k, l, 1)) + exp(-x(i, j, k, l, 1))) * & + 2.0_real32 / (exp(x(i, j, k, l, 2)) + exp(-x(i, j, k, l, 2))) * & + 2.0_real32 / (exp(x(i, j, k, l, 3)) + exp(-x(i, j, k, l, 3))) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function sech_r4fp32 + end function sech_r4fp32 end program test diff --git a/test/sech_r4fp64.f90 b/test/sech_r4fp64.f90 index 7bf071f..9f3c2ce 100644 --- a/test/sech_r4fp64.f90 +++ b/test/sech_r4fp64.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code - - exit_code = sech_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sech_r4fp64() + stop exit_code contains -integer function sech_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function sech_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )*sech(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )*sech(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = 2.0_real64/(exp(x(i,j,k,l,1)) + exp(-x(i,j,k,l,1)))* & - 2.0_real64/(exp(x(i,j,k,l,2)) + exp(-x(i,j,k,l,2)))* & - 2.0_real64/(exp(x(i,j,k,l,3)) + exp(-x(i,j,k,l,3))) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = 2.0_real64 / (exp(x(i, j, k, l, 1)) + exp(-x(i, j, k, l, 1))) * & + 2.0_real64 / (exp(x(i, j, k, l, 2)) + exp(-x(i, j, k, l, 2))) * & + 2.0_real64 / (exp(x(i, j, k, l, 3)) + exp(-x(i, j, k, l, 3))) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function sech_r4fp64 + end function sech_r4fp64 end program test diff --git a/test/sech_sfp32.f90 b/test/sech_sfp32.f90 index 4dcae5e..ff462b8 100644 --- a/test/sech_sfp32.f90 +++ b/test/sech_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = sech_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sech_sfp32() + stop exit_code contains -integer function sech_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = 2.0_real32/(exp(x(1)) + exp(-x(1))) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function sech_sfp32 + integer function sech_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = 2.0_real32 / (exp(x(1)) + exp(-x(1))) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function sech_sfp32 end program test diff --git a/test/sech_sfp64.f90 b/test/sech_sfp64.f90 index e1efcb5..9967bad 100644 --- a/test/sech_sfp64.f90 +++ b/test/sech_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = sech_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sech_sfp64() + stop exit_code contains -integer function sech_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = 2.0_real64/(exp(x(1)) + exp(-x(1))) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function sech_sfp64 + integer function sech_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = 2.0_real64 / (exp(x(1)) + exp(-x(1))) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function sech_sfp64 end program test diff --git a/test/sin_r1fp32.f90 b/test/sin_r1fp32.f90 index 414342d..c0bad94 100644 --- a/test/sin_r1fp32.f90 +++ b/test/sin_r1fp32.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code - - exit_code = sin_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sin_r1fp32() + stop exit_code contains -integer function sin_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = sin(2.0_real32*pi*x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function sin_r1fp32 + integer function sin_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = sin(2.0_real32 * pi * x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function sin_r1fp32 end program test diff --git a/test/sin_r1fp64.f90 b/test/sin_r1fp64.f90 index 65ec71d..22c96fb 100644 --- a/test/sin_r1fp64.f90 +++ b/test/sin_r1fp64.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code - - exit_code = sin_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sin_r1fp64() + stop exit_code contains -integer function sin_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = sin(2.0_real64*pi*x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function sin_r1fp64 + integer function sin_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = sin(2.0_real64 * pi * x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function sin_r1fp64 end program test diff --git a/test/sin_r2fp32.f90 b/test/sin_r2fp32.f90 index aec9e07..9285a68 100644 --- a/test/sin_r2fp32.f90 +++ b/test/sin_r2fp32.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code - - exit_code = sin_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sin_r2fp32() + stop exit_code contains -integer function sin_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = sin(2.0_real32*pi*x(i,j,1))*sin(2.0_real32*pi*x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function sin_r2fp32 + integer function sin_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = sin(2.0_real32 * pi * x(i, j, 1)) * sin(2.0_real32 * pi * x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function sin_r2fp32 end program test diff --git a/test/sin_r2fp64.f90 b/test/sin_r2fp64.f90 index e355d76..15b91ed 100644 --- a/test/sin_r2fp64.f90 +++ b/test/sin_r2fp64.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code - - exit_code = sin_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sin_r2fp64() + stop exit_code contains -integer function sin_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = sin(2.0_real64*pi*x(i,j,1))*sin(2.0_real32*pi*x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function sin_r2fp64 + integer function sin_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = sin(2.0_real64 * pi * x(i, j, 1)) * sin(2.0_real32 * pi * x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function sin_r2fp64 end program test diff --git a/test/sin_r3fp32.f90 b/test/sin_r3fp32.f90 index 4c3719c..86267d0 100644 --- a/test/sin_r3fp32.f90 +++ b/test/sin_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = sin_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sin_r3fp32() + stop exit_code contains -integer function sin_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function sin_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = sin(2.0_real32*pi*x(i,j,k,1))*sin(2.0_real32*pi*x(i,j,k,2))*sin(2.0_real32*pi*x(i,j,k,3)) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = sin(2.0_real32 * pi * x(i, j, k, 1)) * sin(2.0_real32 * pi * x(i, j, k, 2)) * sin(2.0_real32 * pi * x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function sin_r3fp32 + end function sin_r3fp32 end program test diff --git a/test/sin_r3fp64.f90 b/test/sin_r3fp64.f90 index 53b7c31..1dddeb8 100644 --- a/test/sin_r3fp64.f90 +++ b/test/sin_r3fp64.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = sin_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sin_r3fp64() + stop exit_code contains -integer function sin_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function sin_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = sin(2.0_real64*pi*x(i,j,k,1))*sin(2.0_real64*pi*x(i,j,k,2))*sin(2.0_real64*pi*x(i,j,k,3)) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = sin(2.0_real64 * pi * x(i, j, k, 1)) * sin(2.0_real64 * pi * x(i, j, k, 2)) * sin(2.0_real64 * pi * x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function sin_r3fp64 + end function sin_r3fp64 end program test diff --git a/test/sin_r4fp32.f90 b/test/sin_r4fp32.f90 index 633835b..2844712 100644 --- a/test/sin_r4fp32.f90 +++ b/test/sin_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = sin_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sin_r4fp32() + stop exit_code contains -integer function sin_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function sin_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = sin(2.0_real32*pi*x(i,j,k,l,1))*sin(2.0_real32*pi*x(i,j,k,l,2))*sin(2.0_real32*pi*x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = sin(2.0_real32 * pi * x(i, j, k, l, 1)) * sin(2.0_real32 * pi * x(i, j, k, l, 2)) * sin(2.0_real32 * pi * x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) -end function sin_r4fp32 + deallocate (x, feval, fexact) + end function sin_r4fp32 end program test diff --git a/test/sin_r4fp64.f90 b/test/sin_r4fp64.f90 index a3ce313..3129f01 100644 --- a/test/sin_r4fp64.f90 +++ b/test/sin_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = sin_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sin_r4fp64() + stop exit_code contains -integer function sin_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function sin_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = sin(2.0_real64*pi*x(i,j,k,l,1))*sin(2.0_real64*pi*x(i,j,k,l,2))*sin(2.0_real64*pi*x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = sin(2.0_real64 * pi * x(i, j, k, l, 1)) * sin(2.0_real64 * pi * x(i, j, k, l, 2)) * sin(2.0_real64 * pi * x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) -end function sin_r4fp64 + deallocate (x, feval, fexact) + end function sin_r4fp64 end program test diff --git a/test/sin_sfp32.f90 b/test/sin_sfp32.f90 index f53281c..940b1c5 100644 --- a/test/sin_sfp32.f90 +++ b/test/sin_sfp32.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code - - exit_code = sin_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sin_sfp32() + stop exit_code contains -integer function sin_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = sin(2.0_real32*pi*x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function sin_sfp32 + integer function sin_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = sin(2.0_real32 * pi * x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function sin_sfp32 end program test diff --git a/test/sin_sfp64.f90 b/test/sin_sfp64.f90 index 93eba92..aed87cb 100644 --- a/test/sin_sfp64.f90 +++ b/test/sin_sfp64.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code - - exit_code = sin_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sin_sfp64() + stop exit_code contains -integer function sin_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = sin(2.0_real64*pi*x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function sin_sfp64 + integer function sin_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = sin(2.0_real64 * pi * x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function sin_sfp64 end program test diff --git a/test/sqrt_r1fp32.f90 b/test/sqrt_r1fp32.f90 index 7d00fe2..92ae531 100644 --- a/test/sqrt_r1fp32.f90 +++ b/test/sqrt_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = sqrt_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sqrt_r1fp32() + stop exit_code contains -integer function sqrt_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = sqrt(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function sqrt_r1fp32 + integer function sqrt_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = sqrt(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function sqrt_r1fp32 end program test diff --git a/test/sqrt_r1fp64.f90 b/test/sqrt_r1fp64.f90 index 4bf8788..b7a3424 100644 --- a/test/sqrt_r1fp64.f90 +++ b/test/sqrt_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = sqrt_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sqrt_r1fp64() + stop exit_code contains -integer function sqrt_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = sqrt(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function sqrt_r1fp64 + integer function sqrt_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = sqrt(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function sqrt_r1fp64 end program test diff --git a/test/sqrt_r2fp32.f90 b/test/sqrt_r2fp32.f90 index cee678b..b7f3c87 100644 --- a/test/sqrt_r2fp32.f90 +++ b/test/sqrt_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = sqrt_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sqrt_r2fp32() + stop exit_code contains -integer function sqrt_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = sqrt(x(i,j,1))*sqrt(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function sqrt_r2fp32 + integer function sqrt_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = sqrt(x(i, j, 1)) * sqrt(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function sqrt_r2fp32 end program test diff --git a/test/sqrt_r2fp64.f90 b/test/sqrt_r2fp64.f90 index 2f5aa9f..18d2e48 100644 --- a/test/sqrt_r2fp64.f90 +++ b/test/sqrt_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = sqrt_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sqrt_r2fp64() + stop exit_code contains -integer function sqrt_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = sqrt(x(i,j,1))*sqrt(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function sqrt_r2fp64 + integer function sqrt_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = sqrt(x(i, j, 1)) * sqrt(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function sqrt_r2fp64 end program test diff --git a/test/sqrt_r3fp32.f90 b/test/sqrt_r3fp32.f90 index c50d945..f672736 100644 --- a/test/sqrt_r3fp32.f90 +++ b/test/sqrt_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = sqrt_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sqrt_r3fp32() + stop exit_code contains -integer function sqrt_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function sqrt_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = sqrt(x(i,j,k,1))*sqrt(x(i,j,k,2))*sqrt(x(i,j,k,3)) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = sqrt(x(i, j, k, 1)) * sqrt(x(i, j, k, 2)) * sqrt(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function sqrt_r3fp32 + end function sqrt_r3fp32 end program test diff --git a/test/sqrt_r3fp64.f90 b/test/sqrt_r3fp64.f90 index d53e618..795ec5f 100644 --- a/test/sqrt_r3fp64.f90 +++ b/test/sqrt_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = sqrt_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sqrt_r3fp64() + stop exit_code contains -integer function sqrt_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function sqrt_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = sqrt(x(i,j,k,1))*sqrt(x(i,j,k,2))*sqrt(x(i,j,k,3)) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = sqrt(x(i, j, k, 1)) * sqrt(x(i, j, k, 2)) * sqrt(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real64*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= 10.0_real64 * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function sqrt_r3fp64 + end function sqrt_r3fp64 end program test diff --git a/test/sqrt_r4fp32.f90 b/test/sqrt_r4fp32.f90 index 3eb40f6..a01ee3d 100644 --- a/test/sqrt_r4fp32.f90 +++ b/test/sqrt_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = sqrt_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sqrt_r4fp32() + stop exit_code contains -integer function sqrt_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function sqrt_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = sqrt(x(i,j,k,l,1))*sqrt(x(i,j,k,l,2))*sqrt(x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = sqrt(x(i, j, k, l, 1)) * sqrt(x(i, j, k, l, 2)) * sqrt(x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function sqrt_r4fp32 + end function sqrt_r4fp32 end program test diff --git a/test/sqrt_r4fp64.f90 b/test/sqrt_r4fp64.f90 index 0cbaa16..b9bf17b 100644 --- a/test/sqrt_r4fp64.f90 +++ b/test/sqrt_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code - - exit_code = sqrt_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sqrt_r4fp64() + stop exit_code contains -integer function sqrt_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function sqrt_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = sqrt(x(i,j,k,l,1))*sqrt(x(i,j,k,l,2))*sqrt(x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = sqrt(x(i, j, k, l, 1)) * sqrt(x(i, j, k, l, 2)) * sqrt(x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function sqrt_r4fp64 + end function sqrt_r4fp64 end program test diff --git a/test/sqrt_sfp32.f90 b/test/sqrt_sfp32.f90 index dac4953..e53321f 100644 --- a/test/sqrt_sfp32.f90 +++ b/test/sqrt_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = sqrt_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sqrt_sfp32() + stop exit_code contains -integer function sqrt_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 100.0_real32 - fexact = sqrt(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function sqrt_sfp32 + integer function sqrt_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 100.0_real32 + fexact = sqrt(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function sqrt_sfp32 end program test diff --git a/test/sqrt_sfp64.f90 b/test/sqrt_sfp64.f90 index 1e59f33..34f9583 100644 --- a/test/sqrt_sfp64.f90 +++ b/test/sqrt_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = sqrt_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = sqrt_sfp64() + stop exit_code contains -integer function sqrt_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 100.0_real64 - fexact = sqrt(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function sqrt_sfp64 + integer function sqrt_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 100.0_real64 + fexact = sqrt(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function sqrt_sfp64 end program test diff --git a/test/tan_r1fp32.f90 b/test/tan_r1fp32.f90 index fcc37bc..4a9d91d 100644 --- a/test/tan_r1fp32.f90 +++ b/test/tan_r1fp32.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code - - exit_code = tan_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tan_r1fp32() + stop exit_code contains -integer function tan_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = tan(0.5_real32*pi*x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function tan_r1fp32 + integer function tan_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = tan(0.5_real32 * pi * x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function tan_r1fp32 end program test diff --git a/test/tan_r1fp64.f90 b/test/tan_r1fp64.f90 index 51d9333..ebb42dc 100644 --- a/test/tan_r1fp64.f90 +++ b/test/tan_r1fp64.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code - - exit_code = tan_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tan_r1fp64() + stop exit_code contains -integer function tan_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = tan(0.5_real64*pi*x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function tan_r1fp64 + integer function tan_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = tan(0.5_real64 * pi * x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function tan_r1fp64 end program test diff --git a/test/tan_r2fp32.f90 b/test/tan_r2fp32.f90 index d197df4..7eea704 100644 --- a/test/tan_r2fp32.f90 +++ b/test/tan_r2fp32.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code - - exit_code = tan_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tan_r2fp32() + stop exit_code contains -integer function tan_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=60) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = tan(0.5_real32*pi*x(i,j,1))*tan(0.5_real32*pi*x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function tan_r2fp32 + integer function tan_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=60) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = tan(0.5_real32 * pi * x(i, j, 1)) * tan(0.5_real32 * pi * x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function tan_r2fp32 end program test diff --git a/test/tan_r2fp64.f90 b/test/tan_r2fp64.f90 index d3a08d0..5cc3017 100644 --- a/test/tan_r2fp64.f90 +++ b/test/tan_r2fp64.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code - - exit_code = tan_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tan_r2fp64() + stop exit_code contains -integer function tan_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=60) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = tan(0.5_real64*pi*x(i,j,1))*tan(0.5_real64*pi*x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function tan_r2fp64 + integer function tan_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=60) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = tan(0.5_real64 * pi * x(i, j, 1)) * tan(0.5_real64 * pi * x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function tan_r2fp64 end program test diff --git a/test/tan_r3fp32.f90 b/test/tan_r3fp32.f90 index 0fceac4..f4d7738 100644 --- a/test/tan_r3fp32.f90 +++ b/test/tan_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = tan_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tan_r3fp32() + stop exit_code contains -integer function tan_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=60) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function tan_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=60) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = tan(0.5_real32*pi*x(i,j,k,1))*tan(0.5_real32*pi*x(i,j,k,2))*tan(0.5_real32*pi*x(i,j,k,3)) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = tan(0.5_real32 * pi * x(i, j, k, 1)) * tan(0.5_real32 * pi * x(i, j, k, 2)) * tan(0.5_real32 * pi * x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function tan_r3fp32 + end function tan_r3fp32 end program test diff --git a/test/tan_r3fp64.f90 b/test/tan_r3fp64.f90 index 889fa48..0157a13 100644 --- a/test/tan_r3fp64.f90 +++ b/test/tan_r3fp64.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code - - exit_code = tan_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tan_r3fp64() + stop exit_code contains -integer function tan_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=60) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function tan_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=60) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = tan(0.5_real64*pi*x(i,j,k,1))*tan(0.5_real64*pi*x(i,j,k,2))*tan(0.5_real64*pi*x(i,j,k,3)) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = tan(0.5_real64 * pi * x(i, j, k, 1)) * tan(0.5_real64 * pi * x(i, j, k, 2)) * tan(0.5_real64 * pi * x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function tan_r3fp64 + end function tan_r3fp64 end program test diff --git a/test/tan_r4fp32.f90 b/test/tan_r4fp32.f90 index f993482..c290acc 100644 --- a/test/tan_r4fp32.f90 +++ b/test/tan_r4fp32.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code - - exit_code = tan_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tan_r4fp32() + stop exit_code contains -integer function tan_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function tan_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = tan(0.5_real32*pi*x(i,j,k,l,1))*tan(0.5_real32*pi*x(i,j,k,l,2))*tan(0.5_real32*pi*x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = tan(0.5_real32 * pi * x(i, j, k, l, 1)) * tan(0.5_real32 * pi * x(i, j, k, l, 2)) * tan(0.5_real32 * pi * x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function tan_r4fp32 + end function tan_r4fp32 end program test diff --git a/test/tan_r4fp64.f90 b/test/tan_r4fp64.f90 index 3b60b67..bb05548 100644 --- a/test/tan_r4fp64.f90 +++ b/test/tan_r4fp64.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code - - exit_code = tan_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tan_r4fp64() + stop exit_code contains -integer function tan_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function tan_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = tan(0.5_real64*pi*x(i,j,k,l,1))*tan(0.5_real64*pi*x(i,j,k,l,2))*tan(0.5_real64*pi*x(i,j,k,l,3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = tan(0.5_real64 * pi * x(i, j, k, l, 1)) * tan(0.5_real64 * pi * x(i, j, k, l, 2)) * tan(0.5_real64 * pi * x(i, j, k, l, 3)) + end do + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function tan_r4fp64 + end function tan_r4fp64 end program test diff --git a/test/tan_sfp32.f90 b/test/tan_sfp32.f90 index 235d586..56c2015 100644 --- a/test/tan_sfp32.f90 +++ b/test/tan_sfp32.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code - - exit_code = tan_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tan_sfp32() + stop exit_code contains -integer function tan_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = tan(0.5_real32*pi*x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function tan_sfp32 + integer function tan_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = tan(0.5_real32 * pi * x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function tan_sfp32 end program test diff --git a/test/tan_sfp64.f90 b/test/tan_sfp64.f90 index 756c3d5..0835dbe 100644 --- a/test/tan_sfp64.f90 +++ b/test/tan_sfp64.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code - - exit_code = tan_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tan_sfp64() + stop exit_code contains -integer function tan_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = tan(0.5_real64*pi*x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function tan_sfp64 + integer function tan_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = tan(0.5_real64 * pi * x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function tan_sfp64 end program test diff --git a/test/tanh_r1fp32.f90 b/test/tanh_r1fp32.f90 index 2ed8944..a8f0ff1 100644 --- a/test/tanh_r1fp32.f90 +++ b/test/tanh_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = tanh_r1fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tanh_r1fp32() + stop exit_code contains -integer function tanh_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - fexact(i) = tanh(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function tanh_r1fp32 + integer function tanh_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N, 1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do i = 1, N + x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + fexact(i) = tanh(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function tanh_r1fp32 end program test diff --git a/test/tanh_r1fp64.f90 b/test/tanh_r1fp64.f90 index 6883ee3..4bbda3c 100644 --- a/test/tanh_r1fp64.f90 +++ b/test/tanh_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code - - exit_code = tanh_r1fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tanh_r1fp64() + stop exit_code contains -integer function tanh_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - fexact(i) = tanh(x(i,1)) - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - -end function tanh_r1fp64 + integer function tanh_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N, 1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do i = 1, N + x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + fexact(i) = tanh(x(i, 1)) + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + end function tanh_r1fp64 end program test diff --git a/test/tanh_r2fp32.f90 b/test/tanh_r2fp32.f90 index 4798d29..ca9198d 100644 --- a/test/tanh_r2fp32.f90 +++ b/test/tanh_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = tanh_r2fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tanh_r2fp32() + stop exit_code contains -integer function tanh_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - real(real32),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - fexact(i,j) = tanh(x(i,j,1))*tanh(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function tanh_r2fp32 + integer function tanh_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :) + real(real32), allocatable :: feval(:, :) + real(real32), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + fexact(i, j) = tanh(x(i, j, 1)) * tanh(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function tanh_r2fp32 end program test diff --git a/test/tanh_r2fp64.f90 b/test/tanh_r2fp64.f90 index 56d139c..7d92387 100644 --- a/test/tanh_r2fp64.f90 +++ b/test/tanh_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code - - exit_code = tanh_r2fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tanh_r2fp64() + stop exit_code contains -integer function tanh_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - real(real64),allocatable :: fexact(:,:) - integer :: i,j - - allocate (x(1:N,1:N,1:3), & - feval(1:N,1:N), & - fexact(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - fexact(i,j) = tanh(x(i,j,1))*tanh(x(i,j,2)) - end do - end do - - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x,feval,fexact) - -end function tanh_r2fp64 + integer function tanh_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :) + real(real64), allocatable :: feval(:, :) + real(real64), allocatable :: fexact(:, :) + integer :: i, j + + allocate (x(1:N, 1:N, 1:3), & + feval(1:N, 1:N), & + fexact(1:N, 1:N)) + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + do j = 1, N + do i = 1, N + x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + fexact(i, j) = tanh(x(i, j, 1)) * tanh(x(i, j, 2)) + end do + end do + + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + end if + + deallocate (x, feval, fexact) + + end function tanh_r2fp64 end program test diff --git a/test/tanh_r3fp32.f90 b/test/tanh_r3fp32.f90 index 63636b5..d0f3d97 100644 --- a/test/tanh_r3fp32.f90 +++ b/test/tanh_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = tanh_r3fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tanh_r3fp32() + stop exit_code contains -integer function tanh_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function tanh_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :) + real(real32), allocatable :: feval(:, :, :) + real(real32), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) - x(i,j,k,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = tanh(x(i,j,k,1))*tanh(x(i,j,k,2))*tanh(x(i,j,k,3)) - end do - end do - end do + x = 0.0_real32 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = tanh(x(i, j, k, 1)) * tanh(x(i, j, k, 2)) * tanh(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function tanh_r3fp32 + end function tanh_r3fp32 end program test diff --git a/test/tanh_r3fp64.f90 b/test/tanh_r3fp64.f90 index 7f93b5d..dc6795a 100644 --- a/test/tanh_r3fp64.f90 +++ b/test/tanh_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code - - exit_code = tanh_r3fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tanh_r3fp64() + stop exit_code contains -integer function tanh_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k + integer function tanh_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :) + real(real64), allocatable :: feval(:, :, :) + real(real64), allocatable :: fexact(:, :, :) + integer :: i, j, k - allocate (x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) + allocate (x(1:N, 1:N, 1:N, 1:3), & + feval(1:N, 1:N, 1:N), & + fexact(1:N, 1:N, 1:N)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) - x(i,j,k,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k) = tanh(x(i,j,k,1))*tanh(x(i,j,k,2))*tanh(x(i,j,k,3)) - end do - end do - end do + x = 0.0_real64 + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k) = tanh(x(i, j, k, 1)) * tanh(x(i, j, k, 2)) * tanh(x(i, j, k, 3)) + end do + end do + end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function tanh_r3fp64 + end function tanh_r3fp64 end program test diff --git a/test/tanh_r4fp32.f90 b/test/tanh_r4fp32.f90 index 29e6558..29099aa 100644 --- a/test/tanh_r4fp32.f90 +++ b/test/tanh_r4fp32.f90 @@ -1,69 +1,69 @@ program test - implicit none - integer :: exit_code - - exit_code = tanh_r4fp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tanh_r4fp32() + stop exit_code contains -integer function tanh_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function tanh_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32), allocatable :: x(:, :, :, :, :) + real(real32), allocatable :: feval(:, :, :, :) + real(real32), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(i - 1,real32) + 2.0_real32*real(l - 1,real32) - x(i,j,k,l,2) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(j - 1,real32) - x(i,j,k,l,3) = -1.0_real32 + (2.0_real32)/real(N,real32)*real(k - 1,real32) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = tanh(x(i,j,k,l,1))*tanh(x(i,j,k,l,2))*tanh(x(i,j,k,l,3)) - end do - end do - end do - end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + x = 0.0_real32 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) + x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) + x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = tanh(x(i, j, k, l, 1)) * tanh(x(i, j, k, l, 2)) * tanh(x(i, j, k, l, 3)) + end do + end do + end do + end do + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function tanh_r4fp32 + end function tanh_r4fp32 end program test diff --git a/test/tanh_r4fp64.f90 b/test/tanh_r4fp64.f90 index 276b790..49b029a 100644 --- a/test/tanh_r4fp64.f90 +++ b/test/tanh_r4fp64.f90 @@ -1,69 +1,69 @@ program test - implicit none - integer :: exit_code - - exit_code = tanh_r4fp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tanh_r4fp64() + stop exit_code contains -integer function tanh_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l + integer function tanh_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 2 + integer, parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64), allocatable :: x(:, :, :, :, :) + real(real64), allocatable :: feval(:, :, :, :) + real(real64), allocatable :: fexact(:, :, :, :) + integer :: i, j, k, l - allocate (x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x','y','z'/) + allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & + feval(1:N, 1:N, 1:N, 1:M), & + fexact(1:N, 1:N, 1:N, 1:M)) + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(i - 1,real64) + 2.0_real64*real(l - 1,real64) - x(i,j,k,l,2) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(j - 1,real64) - x(i,j,k,l,3) = -1.0_real64 + (2.0_real64)/real(N,real64)*real(k - 1,real64) - end do - end do - end do - end do - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - fexact(i,j,k,l) = tanh(x(i,j,k,l,1))*tanh(x(i,j,k,l,2))*tanh(x(i,j,k,l,3)) - end do - end do - end do - end do - ! Evaluate the equation - feval = f % evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + x = 0.0_real64 + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) + x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) + x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) + end do + end do + end do + end do + do l = 1, M + do k = 1, N + do j = 1, N + do i = 1, N + fexact(i, j, k, l) = tanh(x(i, j, k, l, 1)) * tanh(x(i, j, k, l, 2)) * tanh(x(i, j, k, l, 3)) + end do + end do + end do + end do + ! Evaluate the equation + feval = f%evaluate(x) + if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if - deallocate (x,feval,fexact) + deallocate (x, feval, fexact) -end function tanh_r4fp64 + end function tanh_r4fp64 end program test diff --git a/test/tanh_sfp32.f90 b/test/tanh_sfp32.f90 index f641dfb..043c43b 100644 --- a/test/tanh_sfp32.f90 +++ b/test/tanh_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = tanh_sfp32() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tanh_sfp32() + stop exit_code contains -integer function tanh_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - fexact = tanh(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - -end function tanh_sfp32 + integer function tanh_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real32 + fexact = tanh(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + end if + + end function tanh_sfp32 end program test diff --git a/test/tanh_sfp64.f90 b/test/tanh_sfp64.f90 index 0900fbb..ef754d6 100644 --- a/test/tanh_sfp64.f90 +++ b/test/tanh_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code - - exit_code = tanh_sfp64() - stop exit_code + implicit none + integer :: exit_code + + exit_code = tanh_sfp64() + stop exit_code contains -integer function tanh_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - fexact = tanh(x(1)) - - ! Evaluate the equation - feval = f % evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - -end function tanh_sfp64 + integer function tanh_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer, parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1), dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x', 'y', 'z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar, independentVars) + + x = 0.0_real64 + fexact = tanh(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + end if + + end function tanh_sfp64 end program test From 2ecbe378e2815fa3fb8f643f849d3e86d1617617 Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 11 Feb 2024 10:37:27 -0500 Subject: [PATCH 03/10] Add linting check for test/ and example/ --- .github/workflows/fprettify-lint.yml | 32 ++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/fprettify-lint.yml b/.github/workflows/fprettify-lint.yml index 37fe4c3..aff52a0 100644 --- a/.github/workflows/fprettify-lint.yml +++ b/.github/workflows/fprettify-lint.yml @@ -27,15 +27,35 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - - - - name: Check for formatting differences + + - name: Install fprettify run: | pip3 install fprettify + + - name: Check for formatting differences (src/) + run: | if [[ $(fprettify './src/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1) ]]; then fprettify './src/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1 exit 1 else - echo "linting passed!" - fi - \ No newline at end of file + echo "src/ linting passed!" + fi + + - name: Check for formatting differences (test/) + run: | + if [[ $(fprettify './test/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1) ]]; then + fprettify './test/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1 + exit 1 + else + echo "test/ linting passed!" + fi + + - name: Check for formatting differences (example/) + run: | + if [[ $(fprettify './example/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1) ]]; then + fprettify './example/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1 + exit 1 + else + echo "example/ linting passed!" + fi + From c5b48eeac4d153a9fe7f16b49c5e1017196ff5de Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 11 Feb 2024 10:40:56 -0500 Subject: [PATCH 04/10] Add statement on code formatting --- CONTRIBUTING.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 27d51df..7125cf6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,3 +12,13 @@ If you want to help resolve [any open issues](https://github.com/FluidNumerics/f 4. Work with the upstream reviewer to merge your changes into feq-parse. When you contribute code, feel add your name to the Contributors section of the README.md + +### Code formatting +Each pull request is checked for formatting before running other tests. The `feq-parse` project uses [`fprettify`](https://pypi.org/project/fprettify/) for formatting fortran source code. We have included a configuration file in the `feq-parse` repository (`fprettify.config`) that can be used for ensuring formatting correctness. + +You can run the following to format code to conform to the expected format for `feq-parse`. +``` +fprettify './src/' --config-file ./fprettify.config --recursive --case 1 1 1 1 +fprettify './test/' --config-file ./fprettify.config --recursive --case 1 1 1 1 +fprettify './example/' --config-file ./fprettify.config --recursive --case 1 1 1 1 +``` From ada1d77168d0b9cabef625e1df4a77ab3c937d8b Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 11 Feb 2024 10:43:09 -0500 Subject: [PATCH 05/10] Run all workflows on push/pr --- .github/workflows/linux-cmake.yml | 18 ++++++++++++++---- .github/workflows/linux-fpm.yml | 19 ++++++++++++++----- .github/workflows/windows-cmake.yml | 18 ++++++++++++++---- .github/workflows/windows-fpm.yml | 18 ++++++++++++++---- 4 files changed, 56 insertions(+), 17 deletions(-) diff --git a/.github/workflows/linux-cmake.yml b/.github/workflows/linux-cmake.yml index ef3e1eb..d46b7c1 100644 --- a/.github/workflows/linux-cmake.yml +++ b/.github/workflows/linux-cmake.yml @@ -1,10 +1,20 @@ name: linux-cmake on: - workflow_run: - workflows: [fprettify-lint] - types: - - completed + push: + branches: + - master + - main + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + pull_request: + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + env: # Modify this variable to change the ifort compiler version - do NOT hardcode the version # anywhere else! diff --git a/.github/workflows/linux-fpm.yml b/.github/workflows/linux-fpm.yml index ccb124e..8201154 100644 --- a/.github/workflows/linux-fpm.yml +++ b/.github/workflows/linux-fpm.yml @@ -1,11 +1,20 @@ name: linux-fpm on: - workflow_run: - workflows: [fprettify-lint] - types: - - completed - + push: + branches: + - master + - main + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + pull_request: + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + env: # Modify this variable to change the ifort compiler version - do NOT hardcode the version # anywhere else! diff --git a/.github/workflows/windows-cmake.yml b/.github/workflows/windows-cmake.yml index 1432d22..fee3595 100644 --- a/.github/workflows/windows-cmake.yml +++ b/.github/workflows/windows-cmake.yml @@ -1,10 +1,20 @@ name: windows-cmake on: - workflow_run: - workflows: [fprettify-lint] - types: - - completed + push: + branches: + - master + - main + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + pull_request: + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + env: # Modify this variable to change the ifort compiler version - do NOT hardcode the version # anywhere else! diff --git a/.github/workflows/windows-fpm.yml b/.github/workflows/windows-fpm.yml index 623af52..1387107 100644 --- a/.github/workflows/windows-fpm.yml +++ b/.github/workflows/windows-fpm.yml @@ -1,10 +1,20 @@ name: windows-fpm on: - workflow_run: - workflows: [fprettify-lint] - types: - - completed + push: + branches: + - master + - main + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + pull_request: + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + env: # Modify this variable to change the ifort compiler version - do NOT hardcode the version # anywhere else! From 951261296ef916f7698a3faa7d5e9a1c3a78a95b Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 11 Feb 2024 13:17:28 -0500 Subject: [PATCH 06/10] Split workflows based on compiler --- .github/workflows/linux-gnu-cmake.yml | 132 ++++++++++++++++++ .github/workflows/linux-gnu-fpm.yml | 76 ++++++++++ ...{linux-cmake.yml => linux-intel-cmake.yml} | 40 +----- .../{linux-fpm.yml => linux-intel-fpm.yml} | 29 +--- ...indows-cmake.yml => windows-gnu-cmake.yml} | 2 +- .../{windows-fpm.yml => windows-gnu-fpm.yml} | 1 - README.md | 10 +- 7 files changed, 219 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/linux-gnu-cmake.yml create mode 100644 .github/workflows/linux-gnu-fpm.yml rename .github/workflows/{linux-cmake.yml => linux-intel-cmake.yml} (79%) rename .github/workflows/{linux-fpm.yml => linux-intel-fpm.yml} (81%) rename .github/workflows/{windows-cmake.yml => windows-gnu-cmake.yml} (98%) rename .github/workflows/{windows-fpm.yml => windows-gnu-fpm.yml} (96%) diff --git a/.github/workflows/linux-gnu-cmake.yml b/.github/workflows/linux-gnu-cmake.yml new file mode 100644 index 0000000..017f15d --- /dev/null +++ b/.github/workflows/linux-gnu-cmake.yml @@ -0,0 +1,132 @@ +name: linux-cmake + +on: + push: + branches: + - master + - main + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + pull_request: + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + +env: + # Modify this variable to change the ifort compiler version - do NOT hardcode the version + # anywhere else! + INTEL_ONEAPI_VERSION: 2023.2.1 + +jobs: + linux-tests: + timeout-minutes: 8 + if: "!contains(github.event.head_commit.message, 'skip ci')" + name: ${{ matrix.os }} - ${{ matrix.fcompiler }} - ${{ matrix.build_type }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + # Linux + - os: ubuntu-22.04 + fcompiler: gfortran-9 + ccompiler: gcc-9 + shell: bash + build_type: coverage + memcheck: true + + - os: ubuntu-22.04 + fcompiler: gfortran-9 + ccompiler: gcc-9 + shell: bash + build_type: debug + memcheck: false + + - os: ubuntu-22.04 + fcompiler: gfortran-10 + ccompiler: gcc-10 + shell: bash + build_type: debug + memcheck: false + + - os: ubuntu-22.04 + fcompiler: gfortran-11 + ccompiler: gcc-11 + shell: bash + build_type: debug + memcheck: false + + - os: ubuntu-22.04 + fcompiler: gfortran-12 + ccompiler: gcc-12 + shell: bash + build_type: debug + memcheck: false + + + defaults: + run: + shell: ${{ matrix.shell }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + + - name: Show version information + run: | + ${{ matrix.fcompiler }} --version + ${{ matrix.ccompiler }} --version + + - name: Build with Cmake + run: | + mkdir build + cd build + FC=${{ matrix.fcompiler }} CC=${{ matrix.ccompiler }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ../ + make VERBOSE=1 + + - name: Initialize coverage counters + if: ${{ matrix.build_type == 'coverage' }} + run: | + sudo apt-get update -y && sudo apt-get install lcov + lcov --no-external \ + --directory /home/runner/work/feq-parse \ + --zerocounters + + - name: Run ctests + run: | + cd build/test + ctest || ctest --rerun-failed --output-on-failure + + - name: Create coverage report + if: ${{ matrix.build_type == 'coverage' }} + run: | + + lcov --no-external \ + --capture \ + --directory /home/runner/work/feq-parse \ + --exclude '*/test/*' \ + --output-file /home/runner/work/lcov.info + + - name: codecov + if: ${{ matrix.build_type == 'coverage' }} + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + files: /home/runner/work/lcov.info + flags: ctests + + - name: Run memory checks with Valgrind (only Linux and GNU compilers) + if: ${{ matrix.memcheck }} + run: | + sudo apt-get install -y valgrind + for f in $(find ./build/test/ -executable -type f) + do + echo $f + valgrind --undef-value-errors=no --error-exitcode=1 -s $f -A + done + + diff --git a/.github/workflows/linux-gnu-fpm.yml b/.github/workflows/linux-gnu-fpm.yml new file mode 100644 index 0000000..fda2624 --- /dev/null +++ b/.github/workflows/linux-gnu-fpm.yml @@ -0,0 +1,76 @@ +name: linux-fpm + +on: + push: + branches: + - master + - main + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + pull_request: + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + +env: + # Modify this variable to change the ifort compiler version - do NOT hardcode the version + # anywhere else! + INTEL_ONEAPI_VERSION: 2023.2.1 + +jobs: + linux-tests: + timeout-minutes: 8 + if: "!contains(github.event.head_commit.message, 'skip ci')" + name: ${{ matrix.os }} - ${{ matrix.fcompiler }} - ${{ matrix.build_type }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + # Linux + - os: ubuntu-22.04 + fcompiler: gfortran-9 + ccompiler: gcc-9 + shell: bash + + - os: ubuntu-22.04 + fcompiler: gfortran-10 + ccompiler: gcc-10 + shell: bash + + - os: ubuntu-22.04 + fcompiler: gfortran-11 + ccompiler: gcc-11 + shell: bash + + - os: ubuntu-22.04 + fcompiler: gfortran-12 + ccompiler: gcc-12 + shell: bash + + + defaults: + run: + shell: ${{ matrix.shell }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + + - name: Show version information + run: | + ${{ matrix.fcompiler }} --version + ${{ matrix.ccompiler }} --version + + + - name: fpm tests + 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 --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} + ./fpm test --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} + ./fpm run --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} --example "*" + diff --git a/.github/workflows/linux-cmake.yml b/.github/workflows/linux-intel-cmake.yml similarity index 79% rename from .github/workflows/linux-cmake.yml rename to .github/workflows/linux-intel-cmake.yml index d46b7c1..7951a83 100644 --- a/.github/workflows/linux-cmake.yml +++ b/.github/workflows/linux-intel-cmake.yml @@ -1,4 +1,4 @@ -name: linux-cmake +name: linux-intel-cmake on: push: @@ -30,42 +30,6 @@ jobs: fail-fast: false matrix: include: - # Linux - - os: ubuntu-22.04 - fcompiler: gfortran-9 - ccompiler: gcc-9 - shell: bash - build_type: coverage - memcheck: true - - - os: ubuntu-22.04 - fcompiler: gfortran-9 - ccompiler: gcc-9 - shell: bash - build_type: debug - memcheck: false - - - os: ubuntu-22.04 - fcompiler: gfortran-10 - ccompiler: gcc-10 - shell: bash - build_type: debug - memcheck: false - - - os: ubuntu-22.04 - fcompiler: gfortran-11 - ccompiler: gcc-11 - shell: bash - build_type: debug - memcheck: false - - - os: ubuntu-22.04 - fcompiler: gfortran-12 - ccompiler: gcc-12 - shell: bash - build_type: debug - memcheck: false - - os: ubuntu-22.04 fcompiler: ifx ccompiler: icx-cc @@ -89,7 +53,6 @@ jobs: uses: actions/checkout@v3 - name: Install Intel oneAPI Fortran compiler - if: ${{ startsWith(matrix.fcompiler,'if') }} run: | # download the key to system keyring wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ @@ -107,7 +70,6 @@ jobs: env | grep oneapi >> $GITHUB_ENV - name: Use existing Intel oneAPI Fortran compiler - if: ${{ startsWith(matrix.fcompiler,'if') }} run: | # set environment variables and make them persistent across steps . /opt/intel/oneapi/setvars.sh diff --git a/.github/workflows/linux-fpm.yml b/.github/workflows/linux-intel-fpm.yml similarity index 81% rename from .github/workflows/linux-fpm.yml rename to .github/workflows/linux-intel-fpm.yml index 8201154..7a1b6c9 100644 --- a/.github/workflows/linux-fpm.yml +++ b/.github/workflows/linux-intel-fpm.yml @@ -30,27 +30,6 @@ jobs: fail-fast: false matrix: include: - # Linux - - os: ubuntu-22.04 - fcompiler: gfortran-9 - ccompiler: gcc-9 - shell: bash - - - os: ubuntu-22.04 - fcompiler: gfortran-10 - ccompiler: gcc-10 - shell: bash - - - os: ubuntu-22.04 - fcompiler: gfortran-11 - ccompiler: gcc-11 - shell: bash - - - os: ubuntu-22.04 - fcompiler: gfortran-12 - ccompiler: gcc-12 - shell: bash - - os: ubuntu-22.04 fcompiler: ifx ccompiler: icx-cc @@ -70,7 +49,6 @@ jobs: uses: actions/checkout@v3 - name: Install Intel oneAPI Fortran compiler - if: ${{ startsWith(matrix.fcompiler,'if') }} run: | # download the key to system keyring wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ @@ -88,7 +66,6 @@ jobs: env | grep oneapi >> $GITHUB_ENV - name: Use existing Intel oneAPI Fortran compiler - if: ${{ startsWith(matrix.fcompiler,'if') }} run: | # set environment variables and make them persistent across steps . /opt/intel/oneapi/setvars.sh @@ -101,7 +78,7 @@ jobs: - name: fpm tests (ifx) - if: ${{ (matrix.build_type == 'fpm') && (matrix.fcompiler == 'ifx') }} + if: ${{ (matrix.fcompiler == 'ifx') }} 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 @@ -109,8 +86,8 @@ jobs: ./fpm test --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} --flag "-debug all -check all,nouninit -traceback" ./fpm run --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} --flag "-debug all -check all,nouninit -traceback" --example "*" - - name: fpm tests - if: ${{ (matrix.build_type == 'fpm') && (matrix.fcompiler != 'ifx') }} + - name: fpm tests (ifort) + if: ${{ (matrix.fcompiler == 'ifort') }} 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 diff --git a/.github/workflows/windows-cmake.yml b/.github/workflows/windows-gnu-cmake.yml similarity index 98% rename from .github/workflows/windows-cmake.yml rename to .github/workflows/windows-gnu-cmake.yml index fee3595..72f8b38 100644 --- a/.github/workflows/windows-cmake.yml +++ b/.github/workflows/windows-gnu-cmake.yml @@ -1,4 +1,4 @@ -name: windows-cmake +name: windows-gnu-cmake on: push: diff --git a/.github/workflows/windows-fpm.yml b/.github/workflows/windows-gnu-fpm.yml similarity index 96% rename from .github/workflows/windows-fpm.yml rename to .github/workflows/windows-gnu-fpm.yml index 1387107..8063a50 100644 --- a/.github/workflows/windows-fpm.yml +++ b/.github/workflows/windows-gnu-fpm.yml @@ -64,7 +64,6 @@ jobs: ${{ matrix.ccompiler }} --version - name: fpm tests - if: ${{ (matrix.build_type == 'fpm') && (matrix.fcompiler != 'ifx') }} run: | fpm install --verbose --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} fpm test --verbose --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} diff --git a/README.md b/README.md index c0a3421..6413e99 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # Fortran Equation Parser Copyright 2020 Fluid Numerics LLC -[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-cmake.yml) -[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-fpm.yml) +[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-gnu-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-gnu-cmake.yml) +[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-gnu-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-gnu-fpm.yml) +[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-intel-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-intel-cmake.yml) +[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-intel-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-intel-fpm.yml) -[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/windows-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/windows-cmake.yml) -[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/windows-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/windows-fpm.yml) +[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/windows-gnu-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/windows-gnu-cmake.yml) +[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/windows-gnu-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/windows-gnu-fpm.yml) [![codecov](https://codecov.io/gh/FluidNumerics/feq-parse/graph/badge.svg?token=IBNDDI4MHB)](https://codecov.io/gh/FluidNumerics/feq-parse) From fb0c3c9d07dffa64869a49bc4a72ae729c6fa052 Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 11 Feb 2024 13:18:44 -0500 Subject: [PATCH 07/10] Fix workflow names --- .github/workflows/linux-gnu-cmake.yml | 2 +- .github/workflows/linux-gnu-fpm.yml | 2 +- .github/workflows/linux-intel-fpm.yml | 2 +- .github/workflows/windows-gnu-fpm.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux-gnu-cmake.yml b/.github/workflows/linux-gnu-cmake.yml index 017f15d..16b8452 100644 --- a/.github/workflows/linux-gnu-cmake.yml +++ b/.github/workflows/linux-gnu-cmake.yml @@ -1,4 +1,4 @@ -name: linux-cmake +name: linux-gnu-cmake on: push: diff --git a/.github/workflows/linux-gnu-fpm.yml b/.github/workflows/linux-gnu-fpm.yml index fda2624..95a2b85 100644 --- a/.github/workflows/linux-gnu-fpm.yml +++ b/.github/workflows/linux-gnu-fpm.yml @@ -1,4 +1,4 @@ -name: linux-fpm +name: linux-gnu-fpm on: push: diff --git a/.github/workflows/linux-intel-fpm.yml b/.github/workflows/linux-intel-fpm.yml index 7a1b6c9..77e626b 100644 --- a/.github/workflows/linux-intel-fpm.yml +++ b/.github/workflows/linux-intel-fpm.yml @@ -1,4 +1,4 @@ -name: linux-fpm +name: linux-intel-fpm on: push: diff --git a/.github/workflows/windows-gnu-fpm.yml b/.github/workflows/windows-gnu-fpm.yml index 8063a50..1924ac0 100644 --- a/.github/workflows/windows-gnu-fpm.yml +++ b/.github/workflows/windows-gnu-fpm.yml @@ -1,4 +1,4 @@ -name: windows-fpm +name: windows-gnu-fpm on: push: From 87377a7219fe4ab93418ac43544e4c51407f65d3 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 12 Feb 2024 08:14:15 -0500 Subject: [PATCH 08/10] Change formatting to allow compilation with default gcc line length --- example/array_with_array_eval.f90 | 52 +- example/array_with_scalar_eval.f90 | 52 +- example/gaussian_scalar_multivar.f90 | 42 +- example/scalar_function_product.f90 | 38 +- example/scalar_with_scalar_eval.f90 | 34 +- fprettify.config | 12 +- src/FEQParse.F90 | 2381 +++++++++++++------------- src/FEQParse_FloatStacks.F90 | 718 ++++---- src/FEQParse_Functions.F90 | 993 +++++------ src/FEQParse_TokenStack.F90 | 146 +- test/abs_r1fp32.f90 | 84 +- test/abs_r1fp64.f90 | 84 +- test/abs_r2fp32.f90 | 102 +- test/abs_r2fp64.f90 | 102 +- test/abs_r3fp32.f90 | 104 +- test/abs_r3fp64.f90 | 102 +- test/abs_r4fp32.f90 | 116 +- test/abs_r4fp64.f90 | 112 +- test/abs_sfp32.f90 | 78 +- test/abs_sfp64.f90 | 78 +- test/acos_r1fp32.f90 | 84 +- test/acos_r1fp64.f90 | 84 +- test/acos_r2fp32.f90 | 102 +- test/acos_r2fp64.f90 | 102 +- test/acos_r3fp32.f90 | 104 +- test/acos_r3fp64.f90 | 104 +- test/acos_r4fp32.f90 | 118 +- test/acos_r4fp64.f90 | 116 +- test/acos_sfp32.f90 | 78 +- test/acos_sfp64.f90 | 80 +- test/asin_r1fp32.f90 | 84 +- test/asin_r1fp64.f90 | 84 +- test/asin_r2fp32.f90 | 102 +- test/asin_r2fp64.f90 | 102 +- test/asin_r3fp32.f90 | 104 +- test/asin_r3fp64.f90 | 104 +- test/asin_r4fp32.f90 | 118 +- test/asin_r4fp64.f90 | 116 +- test/asin_sfp32.f90 | 78 +- test/asin_sfp64.f90 | 78 +- test/atan_r1fp32.f90 | 84 +- test/atan_r1fp64.f90 | 84 +- test/atan_r2fp32.f90 | 102 +- test/atan_r2fp64.f90 | 102 +- test/atan_r3fp32.f90 | 104 +- test/atan_r3fp64.f90 | 104 +- test/atan_r4fp32.f90 | 114 +- test/atan_r4fp64.f90 | 114 +- test/atan_sfp32.f90 | 78 +- test/atan_sfp64.f90 | 78 +- test/cos_r1fp32.f90 | 86 +- test/cos_r1fp64.f90 | 86 +- test/cos_r2fp32.f90 | 104 +- test/cos_r2fp64.f90 | 104 +- test/cos_r3fp32.f90 | 106 +- test/cos_r3fp64.f90 | 106 +- test/cos_r4fp32.f90 | 116 +- test/cos_r4fp64.f90 | 116 +- test/cos_sfp32.f90 | 80 +- test/cos_sfp64.f90 | 80 +- test/custom_r1fp64.f90 | 55 +- test/division_r1fp32.f90 | 84 +- test/division_r1fp64.f90 | 84 +- test/division_r2fp32.f90 | 106 +- test/division_r2fp64.f90 | 102 +- test/division_r3fp32.f90 | 108 +- test/division_r3fp64.f90 | 108 +- test/division_r4fp32.f90 | 118 +- test/division_r4fp64.f90 | 118 +- test/division_sfp32.f90 | 78 +- test/division_sfp64.f90 | 78 +- test/gaussian3d_r1fp32.f90 | 88 +- test/gaussian3d_r1fp64.f90 | 88 +- test/gaussian3d_r2fp32.f90 | 102 +- test/gaussian3d_r2fp64.f90 | 102 +- test/gaussian3d_r3fp32.f90 | 104 +- test/gaussian3d_r3fp64.f90 | 104 +- test/gaussian3d_r4fp32.f90 | 114 +- test/gaussian3d_r4fp64.f90 | 114 +- test/gaussian3d_sfp32.f90 | 54 +- test/gaussian3d_sfp64.f90 | 54 +- test/linear_r1fp32.f90 | 84 +- test/linear_r1fp64.f90 | 84 +- test/linear_r2fp32.f90 | 106 +- test/linear_r2fp64.f90 | 102 +- test/linear_r3fp32.f90 | 108 +- test/linear_r3fp64.f90 | 108 +- test/linear_r4fp32.f90 | 118 +- test/linear_r4fp64.f90 | 118 +- test/log10_r1fp32.f90 | 84 +- test/log10_r1fp64.f90 | 84 +- test/log10_r2fp32.f90 | 102 +- test/log10_r2fp64.f90 | 102 +- test/log10_r3fp32.f90 | 104 +- test/log10_r3fp64.f90 | 104 +- test/log10_r4fp32.f90 | 114 +- test/log10_r4fp64.f90 | 114 +- test/log10_sfp32.f90 | 78 +- test/log10_sfp64.f90 | 78 +- test/log_r1fp32.f90 | 84 +- test/log_r1fp64.f90 | 84 +- test/log_r2fp32.f90 | 102 +- test/log_r2fp64.f90 | 102 +- test/log_r3fp32.f90 | 104 +- test/log_r3fp64.f90 | 104 +- test/log_r4fp32.f90 | 114 +- test/log_r4fp64.f90 | 114 +- test/log_sfp32.f90 | 78 +- test/log_sfp64.f90 | 78 +- test/monadic_r1fp32.f90 | 84 +- test/monadic_r1fp64.f90 | 84 +- test/monadic_r2fp32.f90 | 106 +- test/monadic_r2fp64.f90 | 102 +- test/monadic_r3fp32.f90 | 108 +- test/monadic_r3fp64.f90 | 108 +- test/monadic_r4fp32.f90 | 118 +- test/monadic_r4fp64.f90 | 118 +- test/monadic_sfp32.f90 | 78 +- test/monadic_sfp64.f90 | 78 +- test/parsing_difficult_r1fp64.f90 | 184 +- test/print_tokens.f90 | 46 +- test/random_r1fp32.f90 | 80 +- test/random_r1fp64.f90 | 80 +- test/random_r2fp32.f90 | 96 +- test/random_r2fp64.f90 | 96 +- test/random_r3fp32.f90 | 106 +- test/random_r3fp64.f90 | 106 +- test/random_r4fp32.f90 | 112 +- test/random_r4fp64.f90 | 112 +- test/random_sfp32.f90 | 74 +- test/random_sfp64.f90 | 74 +- test/sech_r1fp32.f90 | 84 +- test/sech_r1fp64.f90 | 84 +- test/sech_r2fp32.f90 | 104 +- test/sech_r2fp64.f90 | 104 +- test/sech_r3fp32.f90 | 108 +- test/sech_r3fp64.f90 | 108 +- test/sech_r4fp32.f90 | 118 +- test/sech_r4fp64.f90 | 118 +- test/sech_sfp32.f90 | 78 +- test/sech_sfp64.f90 | 78 +- test/sin_r1fp32.f90 | 86 +- test/sin_r1fp64.f90 | 86 +- test/sin_r2fp32.f90 | 104 +- test/sin_r2fp64.f90 | 104 +- test/sin_r3fp32.f90 | 106 +- test/sin_r3fp64.f90 | 106 +- test/sin_r4fp32.f90 | 116 +- test/sin_r4fp64.f90 | 116 +- test/sin_sfp32.f90 | 80 +- test/sin_sfp64.f90 | 80 +- test/sqrt_r1fp32.f90 | 84 +- test/sqrt_r1fp64.f90 | 84 +- test/sqrt_r2fp32.f90 | 102 +- test/sqrt_r2fp64.f90 | 102 +- test/sqrt_r3fp32.f90 | 104 +- test/sqrt_r3fp64.f90 | 104 +- test/sqrt_r4fp32.f90 | 114 +- test/sqrt_r4fp64.f90 | 114 +- test/sqrt_sfp32.f90 | 78 +- test/sqrt_sfp64.f90 | 78 +- test/tan_r1fp32.f90 | 86 +- test/tan_r1fp64.f90 | 86 +- test/tan_r2fp32.f90 | 104 +- test/tan_r2fp64.f90 | 104 +- test/tan_r3fp32.f90 | 106 +- test/tan_r3fp64.f90 | 106 +- test/tan_r4fp32.f90 | 116 +- test/tan_r4fp64.f90 | 116 +- test/tan_sfp32.f90 | 80 +- test/tan_sfp64.f90 | 80 +- test/tanh_r1fp32.f90 | 84 +- test/tanh_r1fp64.f90 | 84 +- test/tanh_r2fp32.f90 | 102 +- test/tanh_r2fp64.f90 | 102 +- test/tanh_r3fp32.f90 | 104 +- test/tanh_r3fp64.f90 | 104 +- test/tanh_r4fp32.f90 | 114 +- test/tanh_r4fp64.f90 | 114 +- test/tanh_sfp32.f90 | 78 +- test/tanh_sfp64.f90 | 78 +- 181 files changed, 10535 insertions(+), 10534 deletions(-) diff --git a/example/array_with_array_eval.f90 b/example/array_with_array_eval.f90 index a6fa50f..3e174b3 100644 --- a/example/array_with_array_eval.f90 +++ b/example/array_with_array_eval.f90 @@ -1,33 +1,33 @@ program array_with_array_eval - use iso_fortran_env - use FEQParse + use iso_fortran_env + use FEQParse - implicit none - integer, parameter :: N = 10000 - 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 + implicit none + integer,parameter :: N = 10000 + 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 the independent variables + independentVars = (/'x'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! 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" + ! 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) + enddo + feval = f%evaluate(x) + call cpu_time(t2) + print*,"runtime :",(t2-t1)," s" -end program array_with_array_eval +endprogram array_with_array_eval diff --git a/example/array_with_scalar_eval.f90 b/example/array_with_scalar_eval.f90 index 42e28f9..25b0bee 100644 --- a/example/array_with_scalar_eval.f90 +++ b/example/array_with_scalar_eval.f90 @@ -1,33 +1,33 @@ program array_with_scalar_eval - use iso_fortran_env - use FEQParse + use iso_fortran_env + use FEQParse - implicit none - integer, parameter :: N = 100 - 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 + implicit none + integer,parameter :: N = 100 + 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 the independent variables + independentVars = (/'x'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! 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" + ! 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) + enddo + call cpu_time(t2) + print*,"runtime :",(t2-t1)," s" -end program array_with_scalar_eval +endprogram array_with_scalar_eval diff --git a/example/gaussian_scalar_multivar.f90 b/example/gaussian_scalar_multivar.f90 index 797cc92..29f53cc 100644 --- a/example/gaussian_scalar_multivar.f90 +++ b/example/gaussian_scalar_multivar.f90 @@ -1,28 +1,28 @@ program gaussian_scalar_multivar - use iso_fortran_env - use FEQParse + use iso_fortran_env + use FEQParse - implicit none - type(EquationParser) :: f - character(LEN=1), dimension(2) :: independentVars - character(LEN=30) :: eqChar - real :: x(2) + 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 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 = (x - a)^2 )' + ! Specify an equation string that we want to evaluate + 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) + ! 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 + ! Evaluate the equation + x(1) = 1.0 + x(2) = 1.0 + print*,f%evaluate(x) + print*,exp(-1.0)-1.0 -end program gaussian_scalar_multivar +endprogram gaussian_scalar_multivar diff --git a/example/scalar_function_product.f90 b/example/scalar_function_product.f90 index 2fd6afe..245344e 100644 --- a/example/scalar_function_product.f90 +++ b/example/scalar_function_product.f90 @@ -1,26 +1,26 @@ program scalar_function_product - use iso_fortran_env - use FEQParse + use iso_fortran_env + use FEQParse - implicit none - type(EquationParser) :: f - character(LEN=1), dimension(2) :: independentVars - character(LEN=2048) :: eqChar - real :: x(2) - real :: feval + implicit none + type(EquationParser) :: f + character(LEN=1),dimension(2) :: independentVars + character(LEN=2048) :: eqChar + real :: x(2) + real :: feval - ! Specify the independent variables - independentVars = (/'x', 'y'/) + ! Specify the independent variables + independentVars = (/'x','y'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - ! Evaluate the equation - x = 0.5 - feval = f%evaluate(x) - print*,feval + ! Evaluate the equation + x = 0.5 + feval = f%evaluate(x) + print*,feval -end program scalar_function_product +endprogram scalar_function_product diff --git a/example/scalar_with_scalar_eval.f90 b/example/scalar_with_scalar_eval.f90 index 2a0db2d..339fc0b 100644 --- a/example/scalar_with_scalar_eval.f90 +++ b/example/scalar_with_scalar_eval.f90 @@ -1,24 +1,24 @@ program scalar_with_scalar_eval - use iso_fortran_env - use FEQParse + use iso_fortran_env + use FEQParse - implicit none - type(EquationParser) :: f - character(LEN=1), dimension(1) :: independentVars - character(LEN=30) :: eqChar - real :: x(1) + 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 the independent variables + independentVars = (/'x'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - ! Evaluate the equation - x(1) = 0.0 - print*,f%evaluate(x) + ! Evaluate the equation + x(1) = 0.0 + print*,f%evaluate(x) -end program scalar_with_scalar_eval +endprogram scalar_with_scalar_eval diff --git a/fprettify.config b/fprettify.config index 82b61fc..60bf5f2 100644 --- a/fprettify.config +++ b/fprettify.config @@ -3,16 +3,16 @@ enable-replacements=False c-relations=False # White space settings -indent=4 -line-length=256 +indent=2 +line-length=132 strict-indent=True strip-comments=True whitespace-relational=True whitespace-logical=True -whitespace-plusminus=True -whitespace-multdiv=True -whitespace-comma=True -whitespace-intrinsics=True +whitespace-plusminus=False +whitespace-multdiv=False +whitespace-comma=False +whitespace-intrinsics=False whitespace-print=False whitespace-type=False diff --git a/src/FEQParse.F90 b/src/FEQParse.F90 index 71b9074..377bc9b 100644 --- a/src/FEQParse.F90 +++ b/src/FEQParse.F90 @@ -13,1683 +13,1684 @@ module FEQParse - use iso_fortran_env - use FEQParse_Functions - use FEQParse_TokenStack - use FEQParse_FloatStacks - - implicit none - - public :: FEQParse_Function, & - AddFunction - - real(real64), parameter :: pi_real64 = 4.0_real64 * atan(1.0_real64) - real(real32), parameter :: pi_real32 = 4.0_real32 * atan(1.0_real32) - - integer, parameter, private :: Stack_Length = 256 - - ! Token types - enum, bind(c) - enumerator :: None_Token = 0 - enumerator :: Number_Token = 1 - enumerator :: Variable_Token = 2 - enumerator :: Operator_Token = 3 - enumerator :: Function_Token = 4 - enumerator :: OpeningParentheses_Token = 5 - enumerator :: ClosingParentheses_Token = 6 - enumerator :: Monadic_Token = 7 - end enum - - integer, parameter, private :: nSeparators = 7 - - character(1), private :: separators(7) = ['+', '-', '*', '/', "(", ")", '^'] - character(1), private :: operators(5) = ['+', '-', '*', '/', '^'] - character(1), private :: numbers(10) = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] - ! Private Types ! - - private - - type, public :: EquationParser - character(:), allocatable :: equation - character(:), allocatable :: variableName - character(:), allocatable :: inFixFormula - integer :: nIndepVars - type(IndepVar), dimension(:), allocatable :: indepVars - type(TokenStack) :: inFix - type(TokenStack) :: postFix - contains - procedure :: CleanEquation - procedure :: Tokenize - procedure :: ConvertToPostfix - - generic :: Evaluate => Evaluate_sfp32, Evaluate_sfp64, & - Evaluate_r1fp32, Evaluate_r1fp64, & - Evaluate_r2fp32, Evaluate_r2fp64, & - Evaluate_r3fp32, Evaluate_r3fp64, & - Evaluate_r4fp32, Evaluate_r4fp64 - procedure, private :: Evaluate_sfp32, Evaluate_sfp64 - procedure, private :: Evaluate_r1fp32, Evaluate_r1fp64 - procedure, private :: Evaluate_r2fp32, Evaluate_r2fp64 - procedure, private :: Evaluate_r3fp32, Evaluate_r3fp64 - procedure, private :: Evaluate_r4fp32, Evaluate_r4fp64 - - procedure :: Print_InFixTokens - procedure :: Print_PostFixTokens - - procedure, private :: Priority - - end type EquationParser - - type IndepVar - character(:), allocatable :: value - end type - - interface EquationParser - procedure Construct_EquationParser - end interface EquationParser + use iso_fortran_env + use FEQParse_Functions + use FEQParse_TokenStack + use FEQParse_FloatStacks + + implicit none + + public :: FEQParse_Function, & + AddFunction + + real(real64),parameter :: pi_real64 = 4.0_real64*atan(1.0_real64) + real(real32),parameter :: pi_real32 = 4.0_real32*atan(1.0_real32) + + integer,parameter,private :: Stack_Length = 256 + + ! Token types + enum,bind(c) + enumerator :: None_Token = 0 + enumerator :: Number_Token = 1 + enumerator :: Variable_Token = 2 + enumerator :: Operator_Token = 3 + enumerator :: Function_Token = 4 + enumerator :: OpeningParentheses_Token = 5 + enumerator :: ClosingParentheses_Token = 6 + enumerator :: Monadic_Token = 7 + endenum + + integer,parameter,private :: nSeparators = 7 + + character(1),private :: separators(7) = ['+','-','*','/',"(",")",'^'] + character(1),private :: operators(5) = ['+','-','*','/','^'] + character(1),private :: numbers(10) = ['0','1','2','3','4','5','6','7','8','9'] + ! Private Types ! + + private + + type,public :: EquationParser + character(:),allocatable :: equation + character(:),allocatable :: variableName + character(:),allocatable :: inFixFormula + integer :: nIndepVars + type(IndepVar),dimension(:),allocatable :: indepVars + type(TokenStack) :: inFix + type(TokenStack) :: postFix + type(FEQParse_Function),dimension(:),allocatable :: functions + contains + procedure :: CleanEquation + procedure :: Tokenize + procedure :: ConvertToPostfix + + generic :: Evaluate => Evaluate_sfp32,Evaluate_sfp64, & + Evaluate_r1fp32,Evaluate_r1fp64, & + Evaluate_r2fp32,Evaluate_r2fp64, & + Evaluate_r3fp32,Evaluate_r3fp64, & + Evaluate_r4fp32,Evaluate_r4fp64 + procedure,private :: Evaluate_sfp32,Evaluate_sfp64 + procedure,private :: Evaluate_r1fp32,Evaluate_r1fp64 + procedure,private :: Evaluate_r2fp32,Evaluate_r2fp64 + procedure,private :: Evaluate_r3fp32,Evaluate_r3fp64 + procedure,private :: Evaluate_r4fp32,Evaluate_r4fp64 + + procedure :: Print_InFixTokens + procedure :: Print_PostFixTokens + + procedure,private :: Priority + + endtype EquationParser + + type IndepVar + character(:),allocatable :: value + endtype + + interface EquationParser + procedure Construct_EquationParser + endinterface EquationParser contains - function Construct_EquationParser(equation, indepVars) result(parser) - type(EquationParser) :: parser - character(*) :: equation - character(*) :: indepVars(:) - ! Local - integer :: i - character(:), allocatable :: errorMsg - logical :: equationIsClean, tokenized, success - integer :: nIndepVars - - call InitializeFunctions() - - nIndepVars = size(indepVars) - allocate (parser%indepVars(1:nIndepVars)) - parser%nIndepVars = nIndepVars - do i = 1, nIndepVars - parser%indepVars(i)%value = trim(indepVars(i)) - end do - - parser%equation = trim(equation) - if (allocated(parser%inFixFormula)) deallocate (parser%inFixFormula) - allocate (character(len(parser%equation) + maxFunctionLength + 1) :: parser%inFixFormula) - parser%variableName = '#noname' - - call parser%CleanEquation(equationIsClean) - - if (equationIsClean) then - call parser%Tokenize(tokenized, errorMsg) - if (tokenized) then - call parser%ConvertToPostFix() - else - if (allocated(errorMsg)) print*,trim(errorMsg) - success = .false. - end if - end if - - end function Construct_EquationParser - - subroutine CleanEquation(parser, equationCleaned) - class(EquationParser), intent(inout) :: parser - logical, intent(out) :: equationCleaned - ! Local - integer :: nChar, equalSignLoc, j, i, n - character(:), allocatable :: infixformula - - equationCleaned = .false. - - equalSignLoc = index(parser%equation, '=') - if (equalSignLoc /= 0) then - parser%variableName = parser%equation(1:equalSignLoc - 1) - end if - - !Replace ** for ^ - parser%equation = ReplaceStr(parser%equation, '**', '^') - nChar = len_trim(parser%equation) - - ! Grab the formula to the right of the equal sign and left adjust the formula - inFixFormula = parser%equation(equalSignLoc + 1:) - ! Remove any spaces - j = 1 - n = len(inFixFormula) - do i = 1, n - if (inFixFormula(i:i) /= ' ') then - parser%inFixFormula(j:j) = inFixFormula(i:i) - j = j + 1 - end if - end do - - parser%inFixFormula(j:) = ' ' - equationCleaned = .true. - - end subroutine CleanEquation - - pure recursive function ReplaceStr(string, search, substitute) result(modifiedString) - implicit none - character(*), intent(in) :: string, search, substitute - character(:), allocatable :: modifiedString - integer :: i, stringLen, searchLen - stringLen = len(string) - searchLen = len(search) - if (stringLen == 0 .or. searchLen == 0) then - modifiedString = '' - return - elseif (stringLen < searchLen) then - modifiedString = string - return - end if - i = 1 - do - if (string(i:i + searchLen - 1) == search) then - modifiedString = string(1:i - 1)//substitute//replaceStr(string(i + searchLen:stringLen), search, substitute) - exit - end if - if (i + searchLen > stringLen) then - modifiedString = string - exit - end if - i = i + 1 - cycle - end do - end function ReplaceStr - - subroutine Tokenize(parser, tokenized, errorMsg) - class(EquationParser), intent(inout) :: parser - logical, intent(out) :: tokenized - character(:), allocatable, intent(out) :: errorMsg - ! Local - integer :: i, j, k, id - integer, allocatable :: maxVarLen, varLen - - tokenized = .false. - - call parser%infix%Construct(Stack_Length) - - maxVarLen = 0 - do k = 1, parser%nIndepVars - maxVarLen = max(maxVarLen, len(parser%indepVars(k)%value)) - end do - - i = 1 - do while (parser%inFixFormula(i:i) /= ' ') - varLen = maxVarLen - if (IsFunction(j, parser%infixFormula(i:i + maxFunctionLength), id)) then - - parser%inFix%top_index = parser%inFix%top_index + 1 - parser%inFix%tokens(parser%inFix%top_index)%tokenString = parser%inFixFormula(i:i + j - 1) - parser%inFix%tokens(parser%inFix%top_index)%tokenType = Function_Token - parser%inFix%tokens(parser%inFix%top_index)%tokenIndex = id - i = i + j - - elseif (IsVariable(varLen, parser%inFixFormula(i:i + varLen - 1), parser%indepVars, parser%nIndepVars)) then - parser%inFix%top_index = parser%inFix%top_index + 1 - parser%inFix%tokens(parser%inFix%top_index)%tokenString = parser%inFixFormula(i:i + varLen - 1) - parser%inFix%tokens(parser%inFix%top_index)%tokenType = Variable_Token - i = i + varLen - - ! Next item must be an operator, closing parentheses, or end of equation - - if (.not. IsOperator(parser%infixFormula(i:i)) .and. & - parser%inFixFormula(i:i) /= ')' .and. parser%inFixFormula(i:i) /= ' ') then - - errorMsg = 'Missing operator or closing parentheses after token : '// & - trim(parser%inFix%tokens(parser%inFix%top_index)%tokenString) - return - - end if - - elseif (IsNumber(parser%inFixFormula(i:i))) then - - parser%inFix%top_index = parser%inFix%top_index + 1 - parser%inFix%tokens(parser%inFix%top_index)%tokenString = '' - - if (parser%inFixFormula(i:i) == 'p' .or. parser%inFixFormula(i:i) == 'P') then + function Construct_EquationParser(equation,indepVars) result(parser) + type(EquationParser) :: parser + character(*) :: equation + character(*) :: indepVars(:) + ! Local + integer :: i + character(:),allocatable :: errorMsg + logical :: equationIsClean,tokenized,success + integer :: nIndepVars + + call InitializeFunctions() + + nIndepVars = size(indepVars) + allocate(parser%indepVars(1:nIndepVars)) + parser%nIndepVars = nIndepVars + do i = 1,nIndepVars + parser%indepVars(i)%value = trim(indepVars(i)) + enddo + + parser%equation = trim(equation) + if(allocated(parser%inFixFormula)) deallocate(parser%inFixFormula) + allocate(character(len(parser%equation)+maxFunctionLength+1) :: parser%inFixFormula) + parser%variableName = '#noname' + + call parser%CleanEquation(equationIsClean) + + if(equationIsClean) then + call parser%Tokenize(tokenized,errorMsg) + if(tokenized) then + call parser%ConvertToPostFix() + else + if(allocated(errorMsg)) print*,trim(errorMsg) + success = .false. + endif + endif + + endfunction Construct_EquationParser + + subroutine CleanEquation(parser,equationCleaned) + class(EquationParser),intent(inout) :: parser + logical,intent(out) :: equationCleaned + ! Local + integer :: nChar,equalSignLoc,j,i,n + character(:),allocatable :: infixformula + + equationCleaned = .false. + + equalSignLoc = index(parser%equation,'=') + if(equalSignLoc /= 0) then + parser%variableName = parser%equation(1:equalSignLoc-1) + endif + + !Replace ** for ^ + parser%equation = ReplaceStr(parser%equation,'**','^') + nChar = len_trim(parser%equation) + + ! Grab the formula to the right of the equal sign and left adjust the formula + inFixFormula = parser%equation(equalSignLoc+1:) + ! Remove any spaces + j = 1 + n = len(inFixFormula) + do i = 1,n + if(inFixFormula(i:i) /= ' ') then + parser%inFixFormula(j:j) = inFixFormula(i:i) + j = j+1 + endif + enddo + + parser%inFixFormula(j:) = ' ' + equationCleaned = .true. + + endsubroutine CleanEquation + + pure recursive function ReplaceStr(string,search,substitute) result(modifiedString) + implicit none + character(*),intent(in) :: string,search,substitute + character(:),allocatable :: modifiedString + integer :: i,stringLen,searchLen + stringLen = len(string) + searchLen = len(search) + if(stringLen == 0 .or. searchLen == 0) then + modifiedString = '' + return + elseif(stringLen < searchLen) then + modifiedString = string + return + endif + i = 1 + do + if(string(i:i+searchLen-1) == search) then + modifiedString = string(1:i-1)//substitute//replaceStr(string(i+searchLen:stringLen),search,substitute) + exit + endif + if(i+searchLen > stringLen) then + modifiedString = string + exit + endif + i = i+1 + cycle + enddo + endfunction ReplaceStr + + subroutine Tokenize(parser,tokenized,errorMsg) + class(EquationParser),intent(inout) :: parser + logical,intent(out) :: tokenized + character(:),allocatable,intent(out) :: errorMsg + ! Local + integer :: i,j,k,id + integer,allocatable :: maxVarLen,varLen + + tokenized = .false. + + call parser%infix%Construct(Stack_Length) + + maxVarLen = 0 + do k = 1,parser%nIndepVars + maxVarLen = max(maxVarLen,len(parser%indepVars(k)%value)) + enddo + + i = 1 + do while(parser%inFixFormula(i:i) /= ' ') + varLen = maxVarLen + if(IsFunction(j,parser%infixFormula(i:i+maxFunctionLength),id)) then + + parser%inFix%top_index = parser%inFix%top_index+1 + parser%inFix%tokens(parser%inFix%top_index)%tokenString = parser%inFixFormula(i:i+j-1) + parser%inFix%tokens(parser%inFix%top_index)%tokenType = Function_Token + parser%inFix%tokens(parser%inFix%top_index)%tokenIndex = id + i = i+j + + elseif(IsVariable(varLen,parser%inFixFormula(i:i+varLen-1),parser%indepVars,parser%nIndepVars)) then + parser%inFix%top_index = parser%inFix%top_index+1 + parser%inFix%tokens(parser%inFix%top_index)%tokenString = parser%inFixFormula(i:i+varLen-1) + parser%inFix%tokens(parser%inFix%top_index)%tokenType = Variable_Token + i = i+varLen + + ! Next item must be an operator, closing parentheses, or end of equation + + if(.not. IsOperator(parser%infixFormula(i:i)) .and. & + parser%inFixFormula(i:i) /= ')' .and. parser%inFixFormula(i:i) /= ' ') then + + errorMsg = 'Missing operator or closing parentheses after token : '// & + trim(parser%inFix%tokens(parser%inFix%top_index)%tokenString) + return + + endif + + elseif(IsNumber(parser%inFixFormula(i:i))) then + + parser%inFix%top_index = parser%inFix%top_index+1 + parser%inFix%tokens(parser%inFix%top_index)%tokenString = '' + + if(parser%inFixFormula(i:i) == 'p' .or. parser%inFixFormula(i:i) == 'P') then + + ! Conditional for using built in 'pi' definition + parser%inFix%tokens(parser%inFix%top_index)%tokenString(1:2) = parser%inFixFormula(i:i+1) + j = 2 - ! Conditional for using built in 'pi' definition - parser%inFix%tokens(parser%inFix%top_index)%tokenString(1:2) = parser%inFixFormula(i:i + 1) - j = 2 + else - else + j = 0 + do while(IsNumber(parser%inFixFormula(i+j:i+j))) - j = 0 - do while (IsNumber(parser%inFixFormula(i + j:i + j))) + parser%inFix%tokens(parser%inFix%top_index)%tokenString(j+1:j+1) = parser%inFixFormula(i+j:i+j) + j = j+1 - parser%inFix%tokens(parser%inFix%top_index)%tokenString(j + 1:j + 1) = parser%inFixFormula(i + j:i + j) - j = j + 1 + enddo - end do + endif - end if + parser%inFix%tokens(parser%inFix%top_index)%tokenType = Number_Token - parser%inFix%tokens(parser%inFix%top_index)%tokenType = Number_Token + i = i+j - i = i + j + ! Next item must be an operator or a closing parentheses + if(.not. IsOperator(parser%infixFormula(i:i)) .and. & + parser%inFixFormula(i:i) /= ')' .and. parser%inFixFormula(i:i) /= ' ') then - ! Next item must be an operator or a closing parentheses - if (.not. IsOperator(parser%infixFormula(i:i)) .and. & - parser%inFixFormula(i:i) /= ')' .and. parser%inFixFormula(i:i) /= ' ') then + errorMsg = 'Missing operator or closing parentheses after token : '// & + trim(parser%inFix%tokens(parser%inFix%top_index)%tokenString) + return - errorMsg = 'Missing operator or closing parentheses after token : '// & - trim(parser%inFix%tokens(parser%inFix%top_index)%tokenString) - return + endif - end if + elseif(IsSeparator(parser%inFixFormula(i:i))) then - elseif (IsSeparator(parser%inFixFormula(i:i))) then + parser%inFix%top_index = parser%inFix%top_index+1 + parser%inFix%tokens(parser%inFix%top_index)%tokenString = parser%inFixFormula(i:i) - parser%inFix%top_index = parser%inFix%top_index + 1 - parser%inFix%tokens(parser%inFix%top_index)%tokenString = parser%inFixFormula(i:i) + if(parser%inFixFormula(i:i) == '(') then + parser%inFix%tokens(parser%inFix%top_index)%tokenType = OpeningParentheses_Token + elseif(parser%inFixFormula(i:i) == ')') then + parser%inFix%tokens(parser%inFix%top_index)%tokenType = ClosingParentheses_Token + else + parser%inFix%tokens(parser%inFix%top_index)%tokenType = Operator_Token + endif - if (parser%inFixFormula(i:i) == '(') then - parser%inFix%tokens(parser%inFix%top_index)%tokenType = OpeningParentheses_Token - elseif (parser%inFixFormula(i:i) == ')') then - parser%inFix%tokens(parser%inFix%top_index)%tokenType = ClosingParentheses_Token - else - parser%inFix%tokens(parser%inFix%top_index)%tokenType = Operator_Token - end if + i = i+1 + else - i = i + 1 - else + errorMsg = 'Invalid Token : '// & + trim(parser%inFixFormula(i:i)) - errorMsg = 'Invalid Token : '// & - trim(parser%inFixFormula(i:i)) + return - return + endif + enddo - end if - end do + if(parser%inFix%tokens(1)%tokenType == Operator_Token) then + if(trim(parser%inFix%tokens(1)%tokenString) == '+' .or. & + trim(parser%inFix%tokens(1)%tokenString) == '-') then + parser%inFix%tokens(1)%tokenType = Monadic_Token + endif + endif - if (parser%inFix%tokens(1)%tokenType == Operator_Token) then - if (trim(parser%inFix%tokens(1)%tokenString) == '+' .or. & - trim(parser%inFix%tokens(1)%tokenString) == '-') then - parser%inFix%tokens(1)%tokenType = Monadic_Token - end if - end if + do i = 2,parser%inFix%top_index + if(parser%inFix%tokens(i)%tokenType == Operator_Token .and. & + parser%inFix%tokens(i-1)%tokenType == OpeningParentheses_Token) then + parser%inFix%tokens(i)%tokenType = Monadic_Token + endif + enddo - do i = 2, parser%inFix%top_index - if (parser%inFix%tokens(i)%tokenType == Operator_Token .and. & - parser%inFix%tokens(i - 1)%tokenType == OpeningParentheses_Token) then - parser%inFix%tokens(i)%tokenType = Monadic_Token - end if - end do + tokenized = .true. - tokenized = .true. + endsubroutine Tokenize - end subroutine Tokenize + subroutine ConvertToPostFix(parser) + class(EquationParser),intent(inout) :: parser + ! Local + type(TokenStack) :: operator_stack + type(Token) :: tok + integer :: i - subroutine ConvertToPostFix(parser) - class(EquationParser), intent(inout) :: parser - ! Local - type(TokenStack) :: operator_stack - type(Token) :: tok - integer :: i + !success = .FALSE. - !success = .FALSE. + call parser%postfix%Construct(Stack_Length) + call operator_stack%Construct(Stack_Length) - call parser%postfix%Construct(Stack_Length) - call operator_stack%Construct(Stack_Length) + do i = 1,parser%infix%top_index + !print*, parser % inFix % tokens(i) % tokenString + if(parser%inFix%tokens(i)%tokenType == Variable_Token .or. & + parser%inFix%tokens(i)%tokenType == Number_Token) then - do i = 1, parser%infix%top_index - !print*, parser % inFix % tokens(i) % tokenString - if (parser%inFix%tokens(i)%tokenType == Variable_Token .or. & - parser%inFix%tokens(i)%tokenType == Number_Token) then + call parser%postFix%push(parser%inFix%tokens(i)) - call parser%postFix%push(parser%inFix%tokens(i)) + elseif(parser%inFix%tokens(i)%tokenType == Function_Token) then - elseif (parser%inFix%tokens(i)%tokenType == Function_Token) then + call operator_stack%push(parser%inFix%tokens(i)) - call operator_stack%push(parser%inFix%tokens(i)) + elseif(parser%inFix%tokens(i)%tokenType == Operator_Token & + .or. parser%inFix%tokens(i)%tokenType == Monadic_Token) then - elseif (parser%inFix%tokens(i)%tokenType == Operator_Token & - .or. parser%inFix%tokens(i)%tokenType == Monadic_Token) then + if(.not. operator_stack%IsEmpty()) then - if (.not. operator_stack%IsEmpty()) then + tok = operator_stack%TopToken() - tok = operator_stack%TopToken() + do while(trim(tok%tokenString) /= '(' .and. & + parser%Priority(tok) > & + parser%Priority(parser%inFix%tokens(i))) - do while (trim(tok%tokenString) /= '(' .and. & - parser%Priority(tok) > & - parser%Priority(parser%inFix%tokens(i))) + call parser%postFix%push(tok) + call operator_stack%pop(tok) + tok = operator_stack%TopToken() - call parser%postFix%push(tok) - call operator_stack%pop(tok) - tok = operator_stack%TopToken() + enddo - end do + endif - end if + call operator_stack%push(parser%inFix%tokens(i)) - call operator_stack%push(parser%inFix%tokens(i)) + elseif(parser%inFix%tokens(i)%tokenType == OpeningParentheses_Token) then - elseif (parser%inFix%tokens(i)%tokenType == OpeningParentheses_Token) then + call operator_stack%push(parser%inFix%tokens(i)) - call operator_stack%push(parser%inFix%tokens(i)) + elseif(parser%inFix%tokens(i)%tokenType == ClosingParentheses_Token) then - elseif (parser%inFix%tokens(i)%tokenType == ClosingParentheses_Token) then + tok = operator_stack%TopToken() - tok = operator_stack%TopToken() + do while(.not.(operator_stack%IsEmpty()) .and. tok%tokenString(1:1) /= '(') - do while (.not. (operator_stack%IsEmpty()) .and. tok%tokenString(1:1) /= '(') + call parser%postFix%push(tok) + call operator_stack%pop(tok) + tok = operator_stack%TopToken() - call parser%postFix%push(tok) - call operator_stack%pop(tok) - tok = operator_stack%TopToken() + enddo - end do + ! Pop the opening parenthesis + call operator_stack%pop(tok) - ! Pop the opening parenthesis - call operator_stack%pop(tok) + endif - end if + enddo - end do + ! Pop the remaining operators + do while(.not.(operator_stack%IsEmpty())) - ! Pop the remaining operators - do while (.not. (operator_stack%IsEmpty())) + tok = operator_stack%TopToken() + call parser%postFix%push(tok) + call operator_stack%pop(tok) - tok = operator_stack%TopToken() - call parser%postFix%push(tok) - call operator_stack%pop(tok) + enddo - end do + endsubroutine ConvertToPostFix - end subroutine ConvertToPostFix + function Evaluate_sfp32(parser,x) result(f) + class(EquationParser) :: parser + real(real32) :: x(1:parser%nIndepVars) + real(real32) :: f + ! Local + integer :: i,k + type(Token) :: t + type(sfp32Stack) :: stack + real(real32) :: v,a,b,c - function Evaluate_sfp32(parser, x) result(f) - class(EquationParser) :: parser - real(real32) :: x(1:parser%nIndepVars) - real(real32) :: f - ! Local - integer :: i, k - type(Token) :: t - type(sfp32Stack) :: stack - real(real32) :: v, a, b, c + call stack%Construct(Stack_Length) - call stack%Construct(Stack_Length) + do k = 1,parser%postfix%top_index - do k = 1, parser%postfix%top_index + t = parser%postfix%tokens(k)%Copy() - t = parser%postfix%tokens(k)%Copy() + select case(t%tokenType) - select case (t%tokenType) + case(Number_Token) - case (Number_Token) + if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then + v = pi_real32 + else + read(t%tokenString,*) v + endif - if (t%tokenString == 'pi' .or. t%tokenString == 'PI') then - v = pi_real32 - else - read (t%tokenString, *) v - end if + call stack%Push(v) - call stack%Push(v) + case(Variable_Token) - case (Variable_Token) + do i = 1,parser%nIndepVars + if(trim(t%tokenString) == parser%indepVars(i)%value) then + call stack%Push(x(i)) + exit + endif + enddo - do i = 1, parser%nIndepVars - if (trim(t%tokenString) == parser%indepVars(i)%value) then - call stack%Push(x(i)) - exit - end if - end do + case(Operator_Token) - case (Operator_Token) + call stack%Pop(a) + call stack%Pop(b) - call stack%Pop(a) - call stack%Pop(b) + select case(trim(t%tokenString)) - select case (trim(t%tokenString)) + case('+') - case ('+') + c = a+b - c = a + b + case('-') - case ('-') + c = b-a - c = b - a + case('*') - case ('*') + c = a*b - c = a * b + case('/') - case ('/') + c = b/a - c = b / a + case('^') - case ('^') + c = b**a + case default - c = b**a - case default + endselect - end select + call stack%Push(c) - call stack%Push(c) + case(Function_Token) - case (Function_Token) + call stack%Pop(a) - call stack%Pop(a) + b = Functions(t%tokenIndex)%invoke(a) - b = Functions(t%tokenIndex)%invoke(a) + call stack%Push(b) - call stack%Push(b) + case(Monadic_Token) - case (Monadic_Token) + if(trim(t%tokenString) == '-') then - if (trim(t%tokenString) == '-') then + call stack%Pop(a) + a = -a + call stack%Push(a) - call stack%Pop(a) - a = -a - call stack%Push(a) + endif - end if + case default - case default + endselect - end select + enddo - end do + call stack%Pop(a) + f = a + endfunction Evaluate_sfp32 - call stack%Pop(a) - f = a - end function Evaluate_sfp32 + function Evaluate_sfp64(parser,x) result(f) + class(EquationParser) :: parser + real(real64) :: x(1:parser%nIndepVars) + real(real64) :: f + ! Local + integer :: i,k + type(Token) :: t + type(sfp64Stack) :: stack + real(real64) :: v,a,b,c - function Evaluate_sfp64(parser, x) result(f) - class(EquationParser) :: parser - real(real64) :: x(1:parser%nIndepVars) - real(real64) :: f - ! Local - integer :: i, k - type(Token) :: t - type(sfp64Stack) :: stack - real(real64) :: v, a, b, c + call stack%Construct(Stack_Length) - call stack%Construct(Stack_Length) + do k = 1,parser%postfix%top_index - do k = 1, parser%postfix%top_index + t = parser%postfix%tokens(k)%Copy() - t = parser%postfix%tokens(k)%Copy() + select case(t%tokenType) - select case (t%tokenType) + case(Number_Token) - case (Number_Token) + if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then + v = pi_real64 + else + read(t%tokenString,*) v + endif - if (t%tokenString == 'pi' .or. t%tokenString == 'PI') then - v = pi_real64 - else - read (t%tokenString, *) v - end if + call stack%Push(v) - call stack%Push(v) + case(Variable_Token) - case (Variable_Token) + do i = 1,parser%nIndepVars + if(trim(t%tokenString) == parser%indepVars(i)%value) then + call stack%Push(x(i)) + exit + endif + enddo - do i = 1, parser%nIndepVars - if (trim(t%tokenString) == parser%indepVars(i)%value) then - call stack%Push(x(i)) - exit - end if - end do + case(Operator_Token) - case (Operator_Token) + call stack%Pop(a) + call stack%Pop(b) - call stack%Pop(a) - call stack%Pop(b) + select case(trim(t%tokenString)) - select case (trim(t%tokenString)) + case('+') - case ('+') + c = a+b - c = a + b + case('-') - case ('-') + c = b-a - c = b - a + case('*') - case ('*') + c = a*b - c = a * b + case('/') - case ('/') + c = b/a - c = b / a + case('^') - case ('^') + c = b**a + case default - c = b**a - case default + endselect - end select + call stack%Push(c) - call stack%Push(c) + case(Function_Token) - case (Function_Token) + call stack%Pop(a) - call stack%Pop(a) + b = Functions(t%tokenIndex)%invoke(a) - b = Functions(t%tokenIndex)%invoke(a) + call stack%Push(b) - call stack%Push(b) + case(Monadic_Token) - case (Monadic_Token) + if(trim(t%tokenString) == '-') then - if (trim(t%tokenString) == '-') then + call stack%Pop(a) + a = -a + call stack%Push(a) - call stack%Pop(a) - a = -a - call stack%Push(a) + endif - end if + case default - case default + endselect - end select + enddo - end do + call stack%Pop(a) + f = a + endfunction Evaluate_sfp64 - call stack%Pop(a) - f = a - end function Evaluate_sfp64 + function Evaluate_r1fp32(parser,x) result(f) + class(EquationParser) :: parser + real(real32) :: x(:,:) + real(real32) :: f(lbound(x,1):ubound(x,1)) + ! Local + integer :: i,k + type(Token) :: t + type(r1fp32Stack) :: stack + real(real32) :: vnumber + real(real32),allocatable :: v(:) + real(real32),allocatable :: a(:) + real(real32),allocatable :: b(:) + real(real32),allocatable :: c(:) - function Evaluate_r1fp32(parser, x) result(f) - class(EquationParser) :: parser - real(real32) :: x(:, :) - real(real32) :: f(lbound(x, 1):ubound(x, 1)) - ! Local - integer :: i, k - type(Token) :: t - type(r1fp32Stack) :: stack - real(real32) :: vnumber - real(real32), allocatable :: v(:) - real(real32), allocatable :: a(:) - real(real32), allocatable :: b(:) - real(real32), allocatable :: c(:) + allocate(v(lbound(x,1):ubound(x,1)), & + a(lbound(x,1):ubound(x,1)), & + b(lbound(x,1):ubound(x,1)), & + c(lbound(x,1):ubound(x,1))) - allocate (v(lbound(x, 1):ubound(x, 1)), & - a(lbound(x, 1):ubound(x, 1)), & - b(lbound(x, 1):ubound(x, 1)), & - c(lbound(x, 1):ubound(x, 1))) + call stack%Construct(Stack_Length,v) - call stack%Construct(Stack_Length, v) + do k = 1,parser%postfix%top_index - do k = 1, parser%postfix%top_index + t = parser%postfix%tokens(k)%Copy() - t = parser%postfix%tokens(k)%Copy() + select case(t%tokenType) - select case (t%tokenType) + case(Number_Token) + if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then + v = pi_real32 + else + read(t%tokenString,*) vnumber + v = vnumber + endif - case (Number_Token) - if (t%tokenString == 'pi' .or. t%tokenString == 'PI') then - v = pi_real32 - else - read (t%tokenString, *) vnumber - v = vnumber - end if + call stack%Push(v) - call stack%Push(v) + case(Variable_Token) - case (Variable_Token) + do i = 1,parser%nIndepVars + if(trim(t%tokenString) == parser%indepVars(i)%value) then + call stack%Push(x(:,i)) + exit + endif + enddo - do i = 1, parser%nIndepVars - if (trim(t%tokenString) == parser%indepVars(i)%value) then - call stack%Push(x(:, i)) - exit - end if - end do + case(Operator_Token) - case (Operator_Token) + call stack%Pop(a) + call stack%Pop(b) - call stack%Pop(a) - call stack%Pop(b) + select case(trim(t%tokenString)) - select case (trim(t%tokenString)) + case('+') - case ('+') + c = a+b - c = a + b + case('-') - case ('-') + c = b-a - c = b - a + case('*') - case ('*') + c = a*b - c = a * b + case('/') - case ('/') + c = b/a - c = b / a + case('^') - case ('^') + c = b**a + case default - c = b**a - case default + endselect - end select + call stack%Push(c) - call stack%Push(c) + case(Function_Token) - case (Function_Token) + call stack%Pop(a) - call stack%Pop(a) + b = Functions(t%tokenIndex)%invoke(a) - b = Functions(t%tokenIndex)%invoke(a) + call stack%Push(b) - call stack%Push(b) + case(Monadic_Token) - case (Monadic_Token) + if(trim(t%tokenString) == '-') then - if (trim(t%tokenString) == '-') then + call stack%Pop(a) + a = -a + call stack%Push(a) - call stack%Pop(a) - a = -a - call stack%Push(a) + endif - end if + case default - case default + endselect - end select + enddo - end do + call stack%Pop(a) + f = a + deallocate(v,a,b,c) - call stack%Pop(a) - f = a - deallocate (v, a, b, c) + endfunction Evaluate_r1fp32 - end function Evaluate_r1fp32 + function Evaluate_r1fp64(parser,x) result(f) + class(EquationParser) :: parser + real(real64) :: x(:,:) + real(real64) :: f(lbound(x,1):ubound(x,1)) + ! Local + integer :: i,k + type(Token) :: t + type(r1fp64Stack) :: stack + real(real64) :: vnumber + real(real64),allocatable :: v(:) + real(real64),allocatable :: a(:) + real(real64),allocatable :: b(:) + real(real64),allocatable :: c(:) - function Evaluate_r1fp64(parser, x) result(f) - class(EquationParser) :: parser - real(real64) :: x(:, :) - real(real64) :: f(lbound(x, 1):ubound(x, 1)) - ! Local - integer :: i, k - type(Token) :: t - type(r1fp64Stack) :: stack - real(real64) :: vnumber - real(real64), allocatable :: v(:) - real(real64), allocatable :: a(:) - real(real64), allocatable :: b(:) - real(real64), allocatable :: c(:) + allocate(v(lbound(x,1):ubound(x,1)), & + a(lbound(x,1):ubound(x,1)), & + b(lbound(x,1):ubound(x,1)), & + c(lbound(x,1):ubound(x,1))) - allocate (v(lbound(x, 1):ubound(x, 1)), & - a(lbound(x, 1):ubound(x, 1)), & - b(lbound(x, 1):ubound(x, 1)), & - c(lbound(x, 1):ubound(x, 1))) + call stack%Construct(Stack_Length,v) - call stack%Construct(Stack_Length, v) + do k = 1,parser%postfix%top_index - do k = 1, parser%postfix%top_index + t = parser%postfix%tokens(k)%Copy() - t = parser%postfix%tokens(k)%Copy() + select case(t%tokenType) - select case (t%tokenType) + case(Number_Token) - case (Number_Token) + if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then + v = pi_real64 + else + read(t%tokenString,*) vnumber + v = vnumber + endif - if (t%tokenString == 'pi' .or. t%tokenString == 'PI') then - v = pi_real64 - else - read (t%tokenString, *) vnumber - v = vnumber - end if + call stack%Push(v) - call stack%Push(v) + case(Variable_Token) - case (Variable_Token) + do i = 1,parser%nIndepVars + if(trim(t%tokenString) == parser%indepVars(i)%value) then + call stack%Push(x(:,i)) + exit + endif + enddo - do i = 1, parser%nIndepVars - if (trim(t%tokenString) == parser%indepVars(i)%value) then - call stack%Push(x(:, i)) - exit - end if - end do + case(Operator_Token) - case (Operator_Token) + call stack%Pop(a) + call stack%Pop(b) - call stack%Pop(a) - call stack%Pop(b) + select case(trim(t%tokenString)) - select case (trim(t%tokenString)) + case('+') - case ('+') + c = a+b - c = a + b + case('-') - case ('-') + c = b-a - c = b - a + case('*') - case ('*') + c = a*b - c = a * b + case('/') - case ('/') + c = b/a - c = b / a + case('^') - case ('^') + c = b**a + case default - c = b**a - case default + endselect - end select + call stack%Push(c) - call stack%Push(c) + case(Function_Token) - case (Function_Token) + call stack%Pop(a) - call stack%Pop(a) + b = Functions(t%tokenIndex)%invoke(a) - b = Functions(t%tokenIndex)%invoke(a) + call stack%Push(b) - call stack%Push(b) + case(Monadic_Token) - case (Monadic_Token) + if(trim(t%tokenString) == '-') then - if (trim(t%tokenString) == '-') then + call stack%Pop(a) + a = -a + call stack%Push(a) - call stack%Pop(a) - a = -a - call stack%Push(a) + endif - end if + case default - case default + endselect - end select + enddo - end do + call stack%Pop(a) + f = a + deallocate(v,a,b,c) - call stack%Pop(a) - f = a - deallocate (v, a, b, c) + endfunction Evaluate_r1fp64 - end function Evaluate_r1fp64 + function Evaluate_r2fp32(parser,x) result(f) + class(EquationParser) :: parser + real(real32) :: x(:,:,:) + real(real32) :: f(lbound(x,1):ubound(x,1), & + lbound(x,2):ubound(x,2)) + ! Local + integer :: i,k + type(Token) :: t + type(r2fp32Stack) :: stack + real(real32) :: vnumber + real(real32),allocatable :: v(:,:) + real(real32),allocatable :: a(:,:) + real(real32),allocatable :: b(:,:) + real(real32),allocatable :: c(:,:) + integer :: l1,l2,u1,u2 - function Evaluate_r2fp32(parser, x) result(f) - class(EquationParser) :: parser - real(real32) :: x(:, :, :) - real(real32) :: f(lbound(x, 1):ubound(x, 1), & - lbound(x, 2):ubound(x, 2)) - ! Local - integer :: i, k - type(Token) :: t - type(r2fp32Stack) :: stack - real(real32) :: vnumber - real(real32), allocatable :: v(:, :) - real(real32), allocatable :: a(:, :) - real(real32), allocatable :: b(:, :) - real(real32), allocatable :: c(:, :) - integer :: l1, l2, u1, u2 + l1 = lbound(x,1) + l2 = lbound(x,2) + u1 = ubound(x,1) + u2 = ubound(x,2) + allocate(v(l1:u1,l2:u2), & + a(l1:u1,l2:u2), & + b(l1:u1,l2:u2), & + c(l1:u1,l2:u2)) - l1 = lbound(x, 1) - l2 = lbound(x, 2) - u1 = ubound(x, 1) - u2 = ubound(x, 2) - allocate (v(l1:u1, l2:u2), & - a(l1:u1, l2:u2), & - b(l1:u1, l2:u2), & - c(l1:u1, l2:u2)) + call stack%Construct(Stack_Length,v) - call stack%Construct(Stack_Length, v) + do k = 1,parser%postfix%top_index - do k = 1, parser%postfix%top_index + t = parser%postfix%tokens(k)%Copy() - t = parser%postfix%tokens(k)%Copy() + select case(t%tokenType) - select case (t%tokenType) + case(Number_Token) + if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then + v = pi_real32 + else + read(t%tokenString,*) vnumber + v = vnumber + endif - case (Number_Token) - if (t%tokenString == 'pi' .or. t%tokenString == 'PI') then - v = pi_real32 - else - read (t%tokenString, *) vnumber - v = vnumber - end if + call stack%Push(v) - call stack%Push(v) + case(Variable_Token) - case (Variable_Token) + do i = 1,parser%nIndepVars + if(trim(t%tokenString) == parser%indepVars(i)%value) then + call stack%Push(x(:,:,i)) + exit + endif + enddo - do i = 1, parser%nIndepVars - if (trim(t%tokenString) == parser%indepVars(i)%value) then - call stack%Push(x(:, :, i)) - exit - end if - end do + case(Operator_Token) - case (Operator_Token) + call stack%Pop(a) + call stack%Pop(b) - call stack%Pop(a) - call stack%Pop(b) + select case(trim(t%tokenString)) - select case (trim(t%tokenString)) + case('+') - case ('+') + c = a+b - c = a + b + case('-') - case ('-') + c = b-a - c = b - a + case('*') - case ('*') + c = a*b - c = a * b + case('/') - case ('/') + c = b/a - c = b / a + case('^') - case ('^') + c = b**a + case default - c = b**a - case default + endselect - end select + call stack%Push(c) - call stack%Push(c) + case(Function_Token) - case (Function_Token) + call stack%Pop(a) - call stack%Pop(a) + b = Functions(t%tokenIndex)%invoke(a) - b = Functions(t%tokenIndex)%invoke(a) + call stack%Push(b) - call stack%Push(b) + case(Monadic_Token) - case (Monadic_Token) + if(trim(t%tokenString) == '-') then - if (trim(t%tokenString) == '-') then + call stack%Pop(a) + a = -a + call stack%Push(a) - call stack%Pop(a) - a = -a - call stack%Push(a) + endif - end if + case default - case default + endselect - end select + enddo - end do + call stack%Pop(a) + f = a - call stack%Pop(a) - f = a + deallocate(v,a,b,c) - deallocate (v, a, b, c) + endfunction Evaluate_r2fp32 - end function Evaluate_r2fp32 + function Evaluate_r2fp64(parser,x) result(f) + class(EquationParser) :: parser + real(real64) :: x(:,:,:) + real(real64) :: f(lbound(x,1):ubound(x,1), & + lbound(x,2):ubound(x,2)) + ! Local + integer :: i,k + type(Token) :: t + type(r2fp64Stack) :: stack + real(real64) :: vnumber + real(real64),allocatable :: v(:,:) + real(real64),allocatable :: a(:,:) + real(real64),allocatable :: b(:,:) + real(real64),allocatable :: c(:,:) + integer :: l1,l2,u1,u2 - function Evaluate_r2fp64(parser, x) result(f) - class(EquationParser) :: parser - real(real64) :: x(:, :, :) - real(real64) :: f(lbound(x, 1):ubound(x, 1), & - lbound(x, 2):ubound(x, 2)) - ! Local - integer :: i, k - type(Token) :: t - type(r2fp64Stack) :: stack - real(real64) :: vnumber - real(real64), allocatable :: v(:, :) - real(real64), allocatable :: a(:, :) - real(real64), allocatable :: b(:, :) - real(real64), allocatable :: c(:, :) - integer :: l1, l2, u1, u2 + l1 = lbound(x,1) + l2 = lbound(x,2) + u1 = ubound(x,1) + u2 = ubound(x,2) + allocate(v(l1:u1,l2:u2), & + a(l1:u1,l2:u2), & + b(l1:u1,l2:u2), & + c(l1:u1,l2:u2)) - l1 = lbound(x, 1) - l2 = lbound(x, 2) - u1 = ubound(x, 1) - u2 = ubound(x, 2) - allocate (v(l1:u1, l2:u2), & - a(l1:u1, l2:u2), & - b(l1:u1, l2:u2), & - c(l1:u1, l2:u2)) + call stack%Construct(Stack_Length,v) - call stack%Construct(Stack_Length, v) + do k = 1,parser%postfix%top_index - do k = 1, parser%postfix%top_index + t = parser%postfix%tokens(k)%Copy() - t = parser%postfix%tokens(k)%Copy() + select case(t%tokenType) - select case (t%tokenType) + case(Number_Token) - case (Number_Token) + if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then + v = pi_real64 + else + read(t%tokenString,*) vnumber + v = vnumber + endif - if (t%tokenString == 'pi' .or. t%tokenString == 'PI') then - v = pi_real64 - else - read (t%tokenString, *) vnumber - v = vnumber - end if + call stack%Push(v) - call stack%Push(v) + case(Variable_Token) - case (Variable_Token) + do i = 1,parser%nIndepVars + if(trim(t%tokenString) == parser%indepVars(i)%value) then + call stack%Push(x(:,:,i)) + exit + endif + enddo - do i = 1, parser%nIndepVars - if (trim(t%tokenString) == parser%indepVars(i)%value) then - call stack%Push(x(:, :, i)) - exit - end if - end do + case(Operator_Token) - case (Operator_Token) + call stack%Pop(a) + call stack%Pop(b) - call stack%Pop(a) - call stack%Pop(b) + select case(trim(t%tokenString)) - select case (trim(t%tokenString)) + case('+') - case ('+') + c = a+b - c = a + b + case('-') - case ('-') + c = b-a - c = b - a + case('*') - case ('*') + c = a*b - c = a * b + case('/') - case ('/') + c = b/a - c = b / a + case('^') - case ('^') + c = b**a + case default - c = b**a - case default + endselect - end select + call stack%Push(c) - call stack%Push(c) + case(Function_Token) - case (Function_Token) + call stack%Pop(a) - call stack%Pop(a) + b = Functions(t%tokenIndex)%invoke(a) - b = Functions(t%tokenIndex)%invoke(a) + call stack%Push(b) - call stack%Push(b) + case(Monadic_Token) - case (Monadic_Token) + if(trim(t%tokenString) == '-') then - if (trim(t%tokenString) == '-') then + call stack%Pop(a) + a = -a + call stack%Push(a) - call stack%Pop(a) - a = -a - call stack%Push(a) + endif - end if + case default - case default + endselect - end select + enddo - end do + call stack%Pop(a) + f = a - call stack%Pop(a) - f = a + deallocate(v,a,b,c) - deallocate (v, a, b, c) + endfunction Evaluate_r2fp64 - end function Evaluate_r2fp64 + function Evaluate_r3fp32(parser,x) result(f) + class(EquationParser) :: parser + real(real32) :: x(:,:,:,:) + real(real32) :: f(lbound(x,1):ubound(x,1), & + lbound(x,2):ubound(x,2), & + lbound(x,3):ubound(x,3)) + ! Local + integer :: i,k + type(Token) :: t + type(r3fp32Stack) :: stack + real(real32) :: vnumber + real(real32),allocatable :: v(:,:,:) + real(real32),allocatable :: a(:,:,:) + real(real32),allocatable :: b(:,:,:) + real(real32),allocatable :: c(:,:,:) + integer :: l1,l2,l3,u1,u2,u3 - function Evaluate_r3fp32(parser, x) result(f) - class(EquationParser) :: parser - real(real32) :: x(:, :, :, :) - real(real32) :: f(lbound(x, 1):ubound(x, 1), & - lbound(x, 2):ubound(x, 2), & - lbound(x, 3):ubound(x, 3)) - ! Local - integer :: i, k - type(Token) :: t - type(r3fp32Stack) :: stack - real(real32) :: vnumber - real(real32), allocatable :: v(:, :, :) - real(real32), allocatable :: a(:, :, :) - real(real32), allocatable :: b(:, :, :) - real(real32), allocatable :: c(:, :, :) - integer :: l1, l2, l3, u1, u2, u3 + l1 = lbound(x,1) + l2 = lbound(x,2) + l3 = lbound(x,3) + u1 = ubound(x,1) + u2 = ubound(x,2) + u3 = ubound(x,3) + allocate(v(l1:u1,l2:u2,l3:u3), & + a(l1:u1,l2:u2,l3:u3), & + b(l1:u1,l2:u2,l3:u3), & + c(l1:u1,l2:u2,l3:u3)) - l1 = lbound(x, 1) - l2 = lbound(x, 2) - l3 = lbound(x, 3) - u1 = ubound(x, 1) - u2 = ubound(x, 2) - u3 = ubound(x, 3) - allocate (v(l1:u1, l2:u2, l3:u3), & - a(l1:u1, l2:u2, l3:u3), & - b(l1:u1, l2:u2, l3:u3), & - c(l1:u1, l2:u2, l3:u3)) + call stack%Construct(Stack_Length,v) - call stack%Construct(Stack_Length, v) + do k = 1,parser%postfix%top_index - do k = 1, parser%postfix%top_index + t = parser%postfix%tokens(k)%Copy() - t = parser%postfix%tokens(k)%Copy() + select case(t%tokenType) - select case (t%tokenType) + case(Number_Token) + if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then + v = pi_real32 + else + read(t%tokenString,*) vnumber + v = vnumber + endif - case (Number_Token) - if (t%tokenString == 'pi' .or. t%tokenString == 'PI') then - v = pi_real32 - else - read (t%tokenString, *) vnumber - v = vnumber - end if + call stack%Push(v) - call stack%Push(v) + case(Variable_Token) - case (Variable_Token) + do i = 1,parser%nIndepVars + if(trim(t%tokenString) == parser%indepVars(i)%value) then + call stack%Push(x(:,:,:,i)) + exit + endif + enddo - do i = 1, parser%nIndepVars - if (trim(t%tokenString) == parser%indepVars(i)%value) then - call stack%Push(x(:, :, :, i)) - exit - end if - end do + case(Operator_Token) - case (Operator_Token) + call stack%Pop(a) + call stack%Pop(b) - call stack%Pop(a) - call stack%Pop(b) + select case(trim(t%tokenString)) - select case (trim(t%tokenString)) + case('+') - case ('+') + c = a+b - c = a + b + case('-') - case ('-') + c = b-a - c = b - a + case('*') - case ('*') + c = a*b - c = a * b + case('/') - case ('/') + c = b/a - c = b / a + case('^') - case ('^') + c = b**a + case default - c = b**a - case default + endselect - end select + call stack%Push(c) - call stack%Push(c) + case(Function_Token) - case (Function_Token) + call stack%Pop(a) - call stack%Pop(a) + b = Functions(t%tokenIndex)%invoke(a) - b = Functions(t%tokenIndex)%invoke(a) + call stack%Push(b) - call stack%Push(b) + case(Monadic_Token) - case (Monadic_Token) + if(trim(t%tokenString) == '-') then - if (trim(t%tokenString) == '-') then + call stack%Pop(a) + a = -a + call stack%Push(a) - call stack%Pop(a) - a = -a - call stack%Push(a) + endif - end if + case default - case default + endselect - end select + enddo - end do + call stack%Pop(a) + f = a - call stack%Pop(a) - f = a + deallocate(v,a,b,c) - deallocate (v, a, b, c) + endfunction Evaluate_r3fp32 - end function Evaluate_r3fp32 + function Evaluate_r3fp64(parser,x) result(f) + class(EquationParser) :: parser + real(real64) :: x(:,:,:,:) + real(real64) :: f(lbound(x,1):ubound(x,1), & + lbound(x,2):ubound(x,2), & + lbound(x,3):ubound(x,3)) + ! Local + integer :: i,k + type(Token) :: t + type(r3fp64Stack) :: stack + real(real64) :: vnumber + real(real64),allocatable :: v(:,:,:) + real(real64),allocatable :: a(:,:,:) + real(real64),allocatable :: b(:,:,:) + real(real64),allocatable :: c(:,:,:) + integer :: l1,l2,l3,u1,u2,u3 - function Evaluate_r3fp64(parser, x) result(f) - class(EquationParser) :: parser - real(real64) :: x(:, :, :, :) - real(real64) :: f(lbound(x, 1):ubound(x, 1), & - lbound(x, 2):ubound(x, 2), & - lbound(x, 3):ubound(x, 3)) - ! Local - integer :: i, k - type(Token) :: t - type(r3fp64Stack) :: stack - real(real64) :: vnumber - real(real64), allocatable :: v(:, :, :) - real(real64), allocatable :: a(:, :, :) - real(real64), allocatable :: b(:, :, :) - real(real64), allocatable :: c(:, :, :) - integer :: l1, l2, l3, u1, u2, u3 + l1 = lbound(x,1) + l2 = lbound(x,2) + l3 = lbound(x,3) + u1 = ubound(x,1) + u2 = ubound(x,2) + u3 = ubound(x,3) + allocate(v(l1:u1,l2:u2,l3:u3), & + a(l1:u1,l2:u2,l3:u3), & + b(l1:u1,l2:u2,l3:u3), & + c(l1:u1,l2:u2,l3:u3)) - l1 = lbound(x, 1) - l2 = lbound(x, 2) - l3 = lbound(x, 3) - u1 = ubound(x, 1) - u2 = ubound(x, 2) - u3 = ubound(x, 3) - allocate (v(l1:u1, l2:u2, l3:u3), & - a(l1:u1, l2:u2, l3:u3), & - b(l1:u1, l2:u2, l3:u3), & - c(l1:u1, l2:u2, l3:u3)) + call stack%Construct(Stack_Length,v) - call stack%Construct(Stack_Length, v) + do k = 1,parser%postfix%top_index - do k = 1, parser%postfix%top_index + t = parser%postfix%tokens(k)%Copy() - t = parser%postfix%tokens(k)%Copy() + select case(t%tokenType) - select case (t%tokenType) + case(Number_Token) - case (Number_Token) + if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then + v = pi_real64 + else + read(t%tokenString,*) vnumber + v = vnumber + endif - if (t%tokenString == 'pi' .or. t%tokenString == 'PI') then - v = pi_real64 - else - read (t%tokenString, *) vnumber - v = vnumber - end if + call stack%Push(v) - call stack%Push(v) + case(Variable_Token) - case (Variable_Token) + do i = 1,parser%nIndepVars + if(trim(t%tokenString) == parser%indepVars(i)%value) then + call stack%Push(x(:,:,:,i)) + exit + endif + enddo - do i = 1, parser%nIndepVars - if (trim(t%tokenString) == parser%indepVars(i)%value) then - call stack%Push(x(:, :, :, i)) - exit - end if - end do + case(Operator_Token) - case (Operator_Token) + call stack%Pop(a) + call stack%Pop(b) - call stack%Pop(a) - call stack%Pop(b) + select case(trim(t%tokenString)) - select case (trim(t%tokenString)) + case('+') - case ('+') + c = a+b - c = a + b + case('-') - case ('-') + c = b-a - c = b - a + case('*') - case ('*') + c = a*b - c = a * b + case('/') - case ('/') + c = b/a - c = b / a + case('^') - case ('^') + c = b**a + case default - c = b**a - case default + endselect - end select + call stack%Push(c) - call stack%Push(c) + case(Function_Token) - case (Function_Token) + call stack%Pop(a) - call stack%Pop(a) + b = Functions(t%tokenIndex)%invoke(a) - b = Functions(t%tokenIndex)%invoke(a) + call stack%Push(b) - call stack%Push(b) + case(Monadic_Token) - case (Monadic_Token) + if(trim(t%tokenString) == '-') then - if (trim(t%tokenString) == '-') then + call stack%Pop(a) + a = -a + call stack%Push(a) - call stack%Pop(a) - a = -a - call stack%Push(a) + endif - end if + case default - case default + endselect - end select + enddo - end do + call stack%Pop(a) + f = a + deallocate(v,a,b,c) - call stack%Pop(a) - f = a - deallocate (v, a, b, c) + endfunction Evaluate_r3fp64 - end function Evaluate_r3fp64 + function Evaluate_r4fp32(parser,x) result(f) + class(EquationParser) :: parser + real(real32) :: x(:,:,:,:,:) + real(real32) :: f(lbound(x,1):ubound(x,1), & + lbound(x,2):ubound(x,2), & + lbound(x,3):ubound(x,3), & + lbound(x,4):ubound(x,4)) + ! Local + integer :: i,k + type(Token) :: t + type(r4fp32Stack) :: stack + real(real32) :: vnumber + real(real32),allocatable :: v(:,:,:,:) + real(real32),allocatable :: a(:,:,:,:) + real(real32),allocatable :: b(:,:,:,:) + real(real32),allocatable :: c(:,:,:,:) + integer :: l1,l2,l3,l4,u1,u2,u3,u4 - function Evaluate_r4fp32(parser, x) result(f) - class(EquationParser) :: parser - real(real32) :: x(:, :, :, :, :) - real(real32) :: f(lbound(x, 1):ubound(x, 1), & - lbound(x, 2):ubound(x, 2), & - lbound(x, 3):ubound(x, 3), & - lbound(x, 4):ubound(x, 4)) - ! Local - integer :: i, k - type(Token) :: t - type(r4fp32Stack) :: stack - real(real32) :: vnumber - real(real32), allocatable :: v(:, :, :, :) - real(real32), allocatable :: a(:, :, :, :) - real(real32), allocatable :: b(:, :, :, :) - real(real32), allocatable :: c(:, :, :, :) - integer :: l1, l2, l3, l4, u1, u2, u3, u4 + l1 = lbound(x,1) + l2 = lbound(x,2) + l3 = lbound(x,3) + l4 = lbound(x,3) + u1 = ubound(x,1) + u2 = ubound(x,2) + u3 = ubound(x,3) + u4 = ubound(x,4) + allocate(v(l1:u1,l2:u2,l3:u3,l4:u4), & + a(l1:u1,l2:u2,l3:u3,l4:u4), & + b(l1:u1,l2:u2,l3:u3,l4:u4), & + c(l1:u1,l2:u2,l3:u3,l4:u4)) - l1 = lbound(x, 1) - l2 = lbound(x, 2) - l3 = lbound(x, 3) - l4 = lbound(x, 3) - u1 = ubound(x, 1) - u2 = ubound(x, 2) - u3 = ubound(x, 3) - u4 = ubound(x, 4) - allocate (v(l1:u1, l2:u2, l3:u3, l4:u4), & - a(l1:u1, l2:u2, l3:u3, l4:u4), & - b(l1:u1, l2:u2, l3:u3, l4:u4), & - c(l1:u1, l2:u2, l3:u3, l4:u4)) + call stack%Construct(Stack_Length,v) - call stack%Construct(Stack_Length, v) + do k = 1,parser%postfix%top_index - do k = 1, parser%postfix%top_index + t = parser%postfix%tokens(k)%Copy() - t = parser%postfix%tokens(k)%Copy() + select case(t%tokenType) - select case (t%tokenType) + case(Number_Token) + if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then + v = pi_real32 + else + read(t%tokenString,*) vnumber + v = vnumber + endif - case (Number_Token) - if (t%tokenString == 'pi' .or. t%tokenString == 'PI') then - v = pi_real32 - else - read (t%tokenString, *) vnumber - v = vnumber - end if + call stack%Push(v) - call stack%Push(v) + case(Variable_Token) - case (Variable_Token) + do i = 1,parser%nIndepVars + if(trim(t%tokenString) == parser%indepVars(i)%value) then + call stack%Push(x(:,:,:,:,i)) + exit + endif + enddo - do i = 1, parser%nIndepVars - if (trim(t%tokenString) == parser%indepVars(i)%value) then - call stack%Push(x(:, :, :, :, i)) - exit - end if - end do + case(Operator_Token) - case (Operator_Token) + call stack%Pop(a) + call stack%Pop(b) - call stack%Pop(a) - call stack%Pop(b) + select case(trim(t%tokenString)) - select case (trim(t%tokenString)) + case('+') - case ('+') + c = a+b - c = a + b + case('-') - case ('-') + c = b-a - c = b - a + case('*') - case ('*') + c = a*b - c = a * b + case('/') - case ('/') + c = b/a - c = b / a + case('^') - case ('^') + c = b**a + case default - c = b**a - case default + endselect - end select + call stack%Push(c) - call stack%Push(c) + case(Function_Token) - case (Function_Token) + call stack%Pop(a) - call stack%Pop(a) + b = Functions(t%tokenIndex)%invoke(a) - b = Functions(t%tokenIndex)%invoke(a) + call stack%Push(b) - call stack%Push(b) + case(Monadic_Token) - case (Monadic_Token) + if(trim(t%tokenString) == '-') then - if (trim(t%tokenString) == '-') then + call stack%Pop(a) + a = -a + call stack%Push(a) - call stack%Pop(a) - a = -a - call stack%Push(a) + endif - end if + case default - case default + endselect - end select + enddo - end do + call stack%Pop(a) + f = a - call stack%Pop(a) - f = a + deallocate(v,a,b,c) - deallocate (v, a, b, c) + endfunction Evaluate_r4fp32 - end function Evaluate_r4fp32 + function Evaluate_r4fp64(parser,x) result(f) + class(EquationParser) :: parser + real(real64) :: x(:,:,:,:,:) + real(real64) :: f(lbound(x,1):ubound(x,1), & + lbound(x,2):ubound(x,2), & + lbound(x,3):ubound(x,3), & + lbound(x,4):ubound(x,4)) + ! Local + integer :: i,k + type(Token) :: t + type(r4fp64Stack) :: stack + real(real64) :: vnumber + real(real64),allocatable :: v(:,:,:,:) + real(real64),allocatable :: a(:,:,:,:) + real(real64),allocatable :: b(:,:,:,:) + real(real64),allocatable :: c(:,:,:,:) + integer :: l1,l2,l3,l4,u1,u2,u3,u4 - function Evaluate_r4fp64(parser, x) result(f) - class(EquationParser) :: parser - real(real64) :: x(:, :, :, :, :) - real(real64) :: f(lbound(x, 1):ubound(x, 1), & - lbound(x, 2):ubound(x, 2), & - lbound(x, 3):ubound(x, 3), & - lbound(x, 4):ubound(x, 4)) - ! Local - integer :: i, k - type(Token) :: t - type(r4fp64Stack) :: stack - real(real64) :: vnumber - real(real64), allocatable :: v(:, :, :, :) - real(real64), allocatable :: a(:, :, :, :) - real(real64), allocatable :: b(:, :, :, :) - real(real64), allocatable :: c(:, :, :, :) - integer :: l1, l2, l3, l4, u1, u2, u3, u4 + l1 = lbound(x,1) + l2 = lbound(x,2) + l3 = lbound(x,3) + l4 = lbound(x,3) + u1 = ubound(x,1) + u2 = ubound(x,2) + u3 = ubound(x,3) + u4 = ubound(x,4) + allocate(v(l1:u1,l2:u2,l3:u3,l4:u4), & + a(l1:u1,l2:u2,l3:u3,l4:u4), & + b(l1:u1,l2:u2,l3:u3,l4:u4), & + c(l1:u1,l2:u2,l3:u3,l4:u4)) - l1 = lbound(x, 1) - l2 = lbound(x, 2) - l3 = lbound(x, 3) - l4 = lbound(x, 3) - u1 = ubound(x, 1) - u2 = ubound(x, 2) - u3 = ubound(x, 3) - u4 = ubound(x, 4) - allocate (v(l1:u1, l2:u2, l3:u3, l4:u4), & - a(l1:u1, l2:u2, l3:u3, l4:u4), & - b(l1:u1, l2:u2, l3:u3, l4:u4), & - c(l1:u1, l2:u2, l3:u3, l4:u4)) + call stack%Construct(Stack_Length,v) - call stack%Construct(Stack_Length, v) + do k = 1,parser%postfix%top_index - do k = 1, parser%postfix%top_index + t = parser%postfix%tokens(k)%Copy() - t = parser%postfix%tokens(k)%Copy() + select case(t%tokenType) - select case (t%tokenType) + case(Number_Token) - case (Number_Token) + if(t%tokenString == 'pi' .or. t%tokenString == 'PI') then + v = pi_real64 + else + read(t%tokenString,*) vnumber + v = vnumber + endif - if (t%tokenString == 'pi' .or. t%tokenString == 'PI') then - v = pi_real64 - else - read (t%tokenString, *) vnumber - v = vnumber - end if + call stack%Push(v) - call stack%Push(v) + case(Variable_Token) - case (Variable_Token) + do i = 1,parser%nIndepVars + if(trim(t%tokenString) == parser%indepVars(i)%value) then + call stack%Push(x(:,:,:,:,i)) + exit + endif + enddo - do i = 1, parser%nIndepVars - if (trim(t%tokenString) == parser%indepVars(i)%value) then - call stack%Push(x(:, :, :, :, i)) - exit - end if - end do + case(Operator_Token) - case (Operator_Token) + call stack%Pop(a) + call stack%Pop(b) - call stack%Pop(a) - call stack%Pop(b) + select case(trim(t%tokenString)) - select case (trim(t%tokenString)) + case('+') - case ('+') + c = a+b - c = a + b + case('-') - case ('-') + c = b-a - c = b - a + case('*') - case ('*') + c = a*b - c = a * b + case('/') - case ('/') + c = b/a - c = b / a + case('^') - case ('^') + c = b**a + case default - c = b**a - case default + endselect - end select + call stack%Push(c) - call stack%Push(c) + case(Function_Token) - case (Function_Token) + call stack%Pop(a) - call stack%Pop(a) + b = Functions(t%tokenIndex)%invoke(a) - b = Functions(t%tokenIndex)%invoke(a) + call stack%Push(b) - call stack%Push(b) + case(Monadic_Token) - case (Monadic_Token) + if(trim(t%tokenString) == '-') then - if (trim(t%tokenString) == '-') then + call stack%Pop(a) + a = -a + call stack%Push(a) - call stack%Pop(a) - a = -a - call stack%Push(a) + endif - end if + case default - case default + endselect - end select + enddo - end do + call stack%Pop(a) + f = a - call stack%Pop(a) - f = a + deallocate(v,a,b,c) - deallocate (v, a, b, c) + endfunction Evaluate_r4fp64 - end function Evaluate_r4fp64 + subroutine Print_InfixTokens(parser) + class(EquationParser),intent(in) :: parser + ! Local + integer :: i - subroutine Print_InfixTokens(parser) - class(EquationParser), intent(in) :: parser - ! Local - integer :: i + do i = 1,parser%inFix%top_index + print*,trim(parser%inFix%tokens(i)%tokenString) + enddo - do i = 1, parser%inFix%top_index - print*,trim(parser%inFix%tokens(i)%tokenString) - end do + endsubroutine Print_InfixTokens - end subroutine Print_InfixTokens + subroutine Print_PostfixTokens(parser) + class(EquationParser),intent(in) :: parser + ! Local + integer :: i - subroutine Print_PostfixTokens(parser) - class(EquationParser), intent(in) :: parser - ! Local - integer :: i + do i = 1,parser%postFix%top_index + print*,trim(parser%postFix%tokens(i)%tokenString),parser%postFix%tokens(i)%tokenType + enddo - do i = 1, parser%postFix%top_index - print*,trim(parser%postFix%tokens(i)%tokenString), parser%postFix%tokens(i)%tokenType - end do + endsubroutine Print_PostfixTokens - end subroutine Print_PostfixTokens + ! Support Functions ! - ! Support Functions ! + logical function IsSeparator(eqChar) + character(1) :: eqChar + ! Local + integer :: i - logical function IsSeparator(eqChar) - character(1) :: eqChar - ! Local - integer :: i + IsSeparator = .false. + do i = 1,nSeparators - IsSeparator = .false. - do i = 1, nSeparators + if(eqChar == separators(i)) then + IsSeparator = .true. + endif - if (eqChar == separators(i)) then - IsSeparator = .true. - end if + enddo - end do + endfunction IsSeparator - end function IsSeparator + logical function IsNumber(eqChar) + character(1) :: eqChar + ! Local + integer :: i - logical function IsNumber(eqChar) - character(1) :: eqChar - ! Local - integer :: i + IsNumber = .false. - IsNumber = .false. - - if (eqChar == '.' .or. eqChar == 'p' .or. eqChar == 'P') then - IsNumber = .true. - return - end if + if(eqChar == '.' .or. eqChar == 'p' .or. eqChar == 'P') then + IsNumber = .true. + return + endif - do i = 1, 10 + do i = 1,10 - if (eqChar == numbers(i)) then - IsNumber = .true. - return - end if + if(eqChar == numbers(i)) then + IsNumber = .true. + return + endif - end do + enddo - end function IsNumber + endfunction IsNumber - logical function IsVariable(varlen, eqChar, variables, nvariables) - integer, intent(inout) :: varlen - character(*), intent(in) :: eqChar - integer :: nvariables - type(IndepVar) :: variables(1:nvariables) - ! Local - integer :: i + logical function IsVariable(varlen,eqChar,variables,nvariables) + integer,intent(inout) :: varlen + character(*),intent(in) :: eqChar + integer :: nvariables + type(IndepVar) :: variables(1:nvariables) + ! Local + integer :: i - IsVariable = .false. - varlen = 0 - if (any(separators(:) == eqChar(1:1))) return - if (verify(eqChar(1:1), '0123456789') == 0) return + IsVariable = .false. + varlen = 0 + if(any(separators(:) == eqChar(1:1))) return + if(verify(eqChar(1:1),'0123456789') == 0) return - do i = 1, nvariables + do i = 1,nvariables - if (index(eqChar, variables(i)%value) == 1) then - IsVariable = .true. + if(index(eqChar,variables(i)%value) == 1) then + IsVariable = .true. - if (len(variables(i)%value) > varlen) then - varlen = len(variables(i)%value) - end if - end if - end do - end function IsVariable + if(len(variables(i)%value) > varlen) then + varlen = len(variables(i)%value) + endif + endif + enddo + endfunction IsVariable - logical function IsOperator(eqChar) - character(1) :: eqChar - ! Local - integer :: i + logical function IsOperator(eqChar) + character(1) :: eqChar + ! Local + integer :: i - IsOperator = .false. - do i = 1, 5 + IsOperator = .false. + do i = 1,5 - if (eqChar == operators(i)) then - IsOperator = .true. - return - end if - end do + if(eqChar == operators(i)) then + IsOperator = .true. + return + endif + enddo - end function IsOperator + endfunction IsOperator - logical function IsFunction(varlen, eqChar, idx) - integer, intent(inout) :: varlen - character(*), intent(in) :: eqChar - integer, intent(out) :: idx - ! Local - integer :: i + logical function IsFunction(varlen,eqChar,idx) + integer,intent(inout) :: varlen + character(*),intent(in) :: eqChar + integer,intent(out) :: idx + ! Local + integer :: i - IsFunction = .false. - varlen = 0 + IsFunction = .false. + varlen = 0 - if (any(separators(:) == eqChar(1:1))) return - if (verify(eqChar(1:1), '0123456789') == 0) return + if(any(separators(:) == eqChar(1:1))) return + if(verify(eqChar(1:1),'0123456789') == 0) return - do i = 1, nFunctions - if (Functions(i)%len <= len(eqChar)) then - if (Functions(i) == eqChar(:Functions(i)%len)) then - if (eqChar(Functions(i)%len + 1:Functions(i)%len + 1) == '(') then - IsFunction = .true. - varlen = max(Functions(i)%len, varlen) - idx = i - end if - end if - end if - end do - end function + do i = 1,nFunctions + if(Functions(i)%len <= len(eqChar)) then + if(Functions(i) == eqChar(:Functions(i)%len)) then + if(eqChar(Functions(i)%len+1:Functions(i)%len+1) == '(') then + IsFunction = .true. + varlen = max(Functions(i)%len,varlen) + idx = i + endif + endif + endif + enddo + endfunction - function ToLowerCase(str) result(res) - character(*), intent(in) :: str - character(len(str)), allocatable :: res - integer :: i + function ToLowerCase(str) result(res) + character(*),intent(in) :: str + character(len(str)),allocatable :: res + integer :: i - do i = 1, len(str) - select case (str(i:i)) - case ('A':'Z') - res(i:i) = achar(iachar(str(i:i)) + 32) - case default - res(i:i) = str(i:i) - end select - end do - end function ToLowerCase + do i = 1,len(str) + select case(str(i:i)) + case('A':'Z') + res(i:i) = achar(iachar(str(i:i))+32) + case default + res(i:i) = str(i:i) + endselect + enddo + endfunction ToLowerCase - integer function Priority(parser, toke) - class(EquationParser) :: parser - type(Token) :: toke + integer function Priority(parser,toke) + class(EquationParser) :: parser + type(Token) :: toke - if (toke%tokenType == Function_Token) then + if(toke%tokenType == Function_Token) then - Priority = 5 + Priority = 5 - elseif (toke%tokenString(1:1) == '^') then + elseif(toke%tokenString(1:1) == '^') then - Priority = 4 + Priority = 4 - elseif (toke%tokenString(1:1) == '/') then + elseif(toke%tokenString(1:1) == '/') then - Priority = 3 + Priority = 3 - elseif (toke%tokenString(1:1) == '*') then + elseif(toke%tokenString(1:1) == '*') then - Priority = 2 + Priority = 2 - elseif (toke%tokenString(1:1) == '+' .or. toke%tokenString(1:1) == '-') then + elseif(toke%tokenString(1:1) == '+' .or. toke%tokenString(1:1) == '-') then - Priority = 1 + Priority = 1 - else + else - Priority = 0 + Priority = 0 - end if + endif - end function Priority + endfunction Priority -end module FEQParse +endmodule FEQParse diff --git a/src/FEQParse_FloatStacks.F90 b/src/FEQParse_FloatStacks.F90 index 6837613..e01dd3f 100644 --- a/src/FEQParse_FloatStacks.F90 +++ b/src/FEQParse_FloatStacks.F90 @@ -13,505 +13,505 @@ module FEQParse_FloatStacks - use iso_fortran_env + use iso_fortran_env - implicit none + implicit none - type feqparse_floatstack - integer :: top_index - end type feqparse_floatstack + type feqparse_floatstack + integer :: top_index + endtype feqparse_floatstack - type, extends(feqparse_floatstack) :: sfp32Stack - real(real32), allocatable :: tokens(:) + type,extends(feqparse_floatstack) :: sfp32Stack + real(real32),allocatable :: tokens(:) - contains + contains - procedure :: Construct => Construct_sfp32Stack - procedure :: Push => Push_sfp32Stack - procedure :: Pop => Pop_sfp32Stack + procedure :: Construct => Construct_sfp32Stack + procedure :: Push => Push_sfp32Stack + procedure :: Pop => Pop_sfp32Stack - end type sfp32Stack + endtype sfp32Stack - type, extends(feqparse_floatstack) :: sfp64Stack - real(real64), allocatable :: tokens(:) + type,extends(feqparse_floatstack) :: sfp64Stack + real(real64),allocatable :: tokens(:) - contains + contains - procedure :: Construct => Construct_sfp64Stack - procedure :: Push => Push_sfp64Stack - procedure :: Pop => Pop_sfp64Stack + procedure :: Construct => Construct_sfp64Stack + procedure :: Push => Push_sfp64Stack + procedure :: Pop => Pop_sfp64Stack - end type sfp64Stack + endtype sfp64Stack - type, extends(feqparse_floatstack) :: r1fp32Stack - real(real32), allocatable :: tokens(:, :) + type,extends(feqparse_floatstack) :: r1fp32Stack + real(real32),allocatable :: tokens(:,:) - contains + contains - procedure :: Construct => Construct_r1fp32Stack - procedure :: Push => Push_r1fp32Stack - procedure :: Pop => Pop_r1fp32Stack + procedure :: Construct => Construct_r1fp32Stack + procedure :: Push => Push_r1fp32Stack + procedure :: Pop => Pop_r1fp32Stack - end type r1fp32Stack + endtype r1fp32Stack - type, extends(feqparse_floatstack) :: r1fp64Stack - real(real64), allocatable :: tokens(:, :) + type,extends(feqparse_floatstack) :: r1fp64Stack + real(real64),allocatable :: tokens(:,:) - contains + contains - procedure :: Construct => Construct_r1fp64Stack - procedure :: Push => Push_r1fp64Stack - procedure :: Pop => Pop_r1fp64Stack + procedure :: Construct => Construct_r1fp64Stack + procedure :: Push => Push_r1fp64Stack + procedure :: Pop => Pop_r1fp64Stack - end type r1fp64Stack + endtype r1fp64Stack - type, extends(feqparse_floatstack) :: r2fp32Stack - real(real32), allocatable :: tokens(:, :, :) + type,extends(feqparse_floatstack) :: r2fp32Stack + real(real32),allocatable :: tokens(:,:,:) - contains + contains - procedure :: Construct => Construct_r2fp32Stack - procedure :: Push => Push_r2fp32Stack - procedure :: Pop => Pop_r2fp32Stack + procedure :: Construct => Construct_r2fp32Stack + procedure :: Push => Push_r2fp32Stack + procedure :: Pop => Pop_r2fp32Stack - end type r2fp32Stack + endtype r2fp32Stack - type, extends(feqparse_floatstack) :: r2fp64Stack - real(real64), allocatable :: tokens(:, :, :) + type,extends(feqparse_floatstack) :: r2fp64Stack + real(real64),allocatable :: tokens(:,:,:) - contains + contains - procedure :: Construct => Construct_r2fp64Stack - procedure :: Push => Push_r2fp64Stack - procedure :: Pop => Pop_r2fp64Stack + procedure :: Construct => Construct_r2fp64Stack + procedure :: Push => Push_r2fp64Stack + procedure :: Pop => Pop_r2fp64Stack - end type r2fp64Stack + endtype r2fp64Stack - type, extends(feqparse_floatstack) :: r3fp32Stack - real(real32), allocatable :: tokens(:, :, :, :) + type,extends(feqparse_floatstack) :: r3fp32Stack + real(real32),allocatable :: tokens(:,:,:,:) - contains + contains - procedure :: Construct => Construct_r3fp32Stack - procedure :: Push => Push_r3fp32Stack - procedure :: Pop => Pop_r3fp32Stack + procedure :: Construct => Construct_r3fp32Stack + procedure :: Push => Push_r3fp32Stack + procedure :: Pop => Pop_r3fp32Stack - end type r3fp32Stack + endtype r3fp32Stack - type, extends(feqparse_floatstack) :: r3fp64Stack - real(real64), allocatable :: tokens(:, :, :, :) + type,extends(feqparse_floatstack) :: r3fp64Stack + real(real64),allocatable :: tokens(:,:,:,:) - contains + contains - procedure :: Construct => Construct_r3fp64Stack - procedure :: Push => Push_r3fp64Stack - procedure :: Pop => Pop_r3fp64Stack + procedure :: Construct => Construct_r3fp64Stack + procedure :: Push => Push_r3fp64Stack + procedure :: Pop => Pop_r3fp64Stack - end type r3fp64Stack + endtype r3fp64Stack - type, extends(feqparse_floatstack) :: r4fp32Stack - real(real32), allocatable :: tokens(:, :, :, :, :) + type,extends(feqparse_floatstack) :: r4fp32Stack + real(real32),allocatable :: tokens(:,:,:,:,:) - contains + contains - procedure :: Construct => Construct_r4fp32Stack - procedure :: Push => Push_r4fp32Stack - procedure :: Pop => Pop_r4fp32Stack + procedure :: Construct => Construct_r4fp32Stack + procedure :: Push => Push_r4fp32Stack + procedure :: Pop => Pop_r4fp32Stack - end type r4fp32Stack + endtype r4fp32Stack - type, extends(feqparse_floatstack) :: r4fp64Stack - real(real64), allocatable :: tokens(:, :, :, :, :) + type,extends(feqparse_floatstack) :: r4fp64Stack + real(real64),allocatable :: tokens(:,:,:,:,:) - contains + contains - procedure :: Construct => Construct_r4fp64Stack - procedure :: Push => Push_r4fp64Stack - procedure :: Pop => Pop_r4fp64Stack + procedure :: Construct => Construct_r4fp64Stack + procedure :: Push => Push_r4fp64Stack + procedure :: Pop => Pop_r4fp64Stack - end type r4fp64Stack + endtype r4fp64Stack contains - subroutine Construct_sfp32Stack(stack, N) - class(sfp32Stack), intent(out) :: stack - integer, intent(in) :: N + subroutine Construct_sfp32Stack(stack,N) + class(sfp32Stack),intent(out) :: stack + integer,intent(in) :: N - allocate (stack%tokens(1:N)) - stack%top_index = 0 + allocate(stack%tokens(1:N)) + stack%top_index = 0 - end subroutine Construct_sfp32Stack + endsubroutine Construct_sfp32Stack - subroutine Push_sfp32Stack(stack, tok) - class(sfp32Stack), intent(inout) :: stack - real(real32), intent(in) :: tok + subroutine Push_sfp32Stack(stack,tok) + class(sfp32Stack),intent(inout) :: stack + real(real32),intent(in) :: tok - stack%top_index = stack%top_index + 1 - stack%tokens(stack%top_index) = tok + stack%top_index = stack%top_index+1 + stack%tokens(stack%top_index) = tok - end subroutine Push_sfp32Stack + endsubroutine Push_sfp32Stack - subroutine Pop_sfp32Stack(stack, tok) - class(sfp32Stack), intent(inout) :: stack - real(real32), intent(out) :: tok + subroutine Pop_sfp32Stack(stack,tok) + class(sfp32Stack),intent(inout) :: stack + real(real32),intent(out) :: tok - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok = stack%tokens(stack%top_index) - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok = stack%tokens(stack%top_index) + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_sfp32Stack + endsubroutine Pop_sfp32Stack - subroutine Construct_sfp64Stack(stack, N) - class(sfp64Stack), intent(out) :: stack - integer, intent(in) :: N + subroutine Construct_sfp64Stack(stack,N) + class(sfp64Stack),intent(out) :: stack + integer,intent(in) :: N - allocate (stack%tokens(1:N)) - stack%top_index = 0 + allocate(stack%tokens(1:N)) + stack%top_index = 0 - end subroutine Construct_sfp64Stack + endsubroutine Construct_sfp64Stack - subroutine Push_sfp64Stack(stack, tok) - class(sfp64Stack), intent(inout) :: stack - real(real64), intent(in) :: tok + subroutine Push_sfp64Stack(stack,tok) + class(sfp64Stack),intent(inout) :: stack + real(real64),intent(in) :: tok - stack%top_index = stack%top_index + 1 - stack%tokens(stack%top_index) = tok + stack%top_index = stack%top_index+1 + stack%tokens(stack%top_index) = tok - end subroutine Push_sfp64Stack + endsubroutine Push_sfp64Stack - subroutine Pop_sfp64Stack(stack, tok) - class(sfp64Stack), intent(inout) :: stack - real(real64), intent(out) :: tok + subroutine Pop_sfp64Stack(stack,tok) + class(sfp64Stack),intent(inout) :: stack + real(real64),intent(out) :: tok - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok = stack%tokens(stack%top_index) - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok = stack%tokens(stack%top_index) + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_sfp64Stack + endsubroutine Pop_sfp64Stack - ! >> Rank 1 fp32, fp64 << ! + ! >> Rank 1 fp32, fp64 << ! - subroutine Construct_r1fp32Stack(stack, N, mold) - implicit none - class(r1fp32Stack), intent(out) :: stack - integer, intent(in) :: N - real(real32), intent(in) :: mold(:) - ! local - integer :: l(1) - integer :: u(1) + subroutine Construct_r1fp32Stack(stack,N,mold) + implicit none + class(r1fp32Stack),intent(out) :: stack + integer,intent(in) :: N + real(real32),intent(in) :: mold(:) + ! local + integer :: l(1) + integer :: u(1) - l = lbound(mold) - u = ubound(mold) + l = lbound(mold) + u = ubound(mold) - allocate (stack%tokens(l(1):u(1), 1:N)) - stack%top_index = 0 + allocate(stack%tokens(l(1):u(1),1:N)) + stack%top_index = 0 - end subroutine Construct_r1fp32Stack + endsubroutine Construct_r1fp32Stack - subroutine Push_r1fp32Stack(stack, tok) - class(r1fp32Stack), intent(inout) :: stack - real(real32), intent(in) :: tok(:) + subroutine Push_r1fp32Stack(stack,tok) + class(r1fp32Stack),intent(inout) :: stack + real(real32),intent(in) :: tok(:) - stack%top_index = stack%top_index + 1 - stack%tokens(:, stack%top_index) = tok(:) + stack%top_index = stack%top_index+1 + stack%tokens(:,stack%top_index) = tok(:) - end subroutine Push_r1fp32Stack + endsubroutine Push_r1fp32Stack - subroutine Pop_r1fp32Stack(stack, tok) - class(r1fp32Stack), intent(inout) :: stack - real(real32), intent(out) :: tok(:) + subroutine Pop_r1fp32Stack(stack,tok) + class(r1fp32Stack),intent(inout) :: stack + real(real32),intent(out) :: tok(:) - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok(:) = stack%tokens(:, stack%top_index) - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok(:) = stack%tokens(:,stack%top_index) + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_r1fp32Stack + endsubroutine Pop_r1fp32Stack - subroutine Construct_r1fp64Stack(stack, N, mold) - class(r1fp64Stack), intent(out) :: stack - integer, intent(in) :: N - real(real64), intent(in) :: mold(:) - ! local - integer :: l(1) - integer :: u(1) + subroutine Construct_r1fp64Stack(stack,N,mold) + class(r1fp64Stack),intent(out) :: stack + integer,intent(in) :: N + real(real64),intent(in) :: mold(:) + ! local + integer :: l(1) + integer :: u(1) - l = lbound(mold) - u = ubound(mold) + l = lbound(mold) + u = ubound(mold) - allocate (stack%tokens(l(1):u(1), 1:N)) - stack%top_index = 0 + allocate(stack%tokens(l(1):u(1),1:N)) + stack%top_index = 0 - end subroutine Construct_r1fp64Stack + endsubroutine Construct_r1fp64Stack - subroutine Push_r1fp64Stack(stack, tok) - class(r1fp64Stack), intent(inout) :: stack - real(real64), intent(in) :: tok(:) + subroutine Push_r1fp64Stack(stack,tok) + class(r1fp64Stack),intent(inout) :: stack + real(real64),intent(in) :: tok(:) - stack%top_index = stack%top_index + 1 - stack%tokens(:, stack%top_index) = tok(:) + stack%top_index = stack%top_index+1 + stack%tokens(:,stack%top_index) = tok(:) - end subroutine Push_r1fp64Stack + endsubroutine Push_r1fp64Stack - subroutine Pop_r1fp64Stack(stack, tok) - class(r1fp64Stack), intent(inout) :: stack - real(real64), intent(out) :: tok(:) + subroutine Pop_r1fp64Stack(stack,tok) + class(r1fp64Stack),intent(inout) :: stack + real(real64),intent(out) :: tok(:) - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok(:) = stack%tokens(:, stack%top_index) - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok(:) = stack%tokens(:,stack%top_index) + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_r1fp64Stack + endsubroutine Pop_r1fp64Stack - subroutine Construct_r2fp32Stack(stack, N, mold) - class(r2fp32Stack), intent(out) :: stack - integer, intent(in) :: N - real(real32), intent(in) :: mold(:, :) - ! local - integer :: l(1:2), u(1:2) + subroutine Construct_r2fp32Stack(stack,N,mold) + class(r2fp32Stack),intent(out) :: stack + integer,intent(in) :: N + real(real32),intent(in) :: mold(:,:) + ! local + integer :: l(1:2),u(1:2) - l = lbound(mold) - u = ubound(mold) + l = lbound(mold) + u = ubound(mold) - allocate (stack%tokens(l(1):u(1), & - l(2):u(2), & - 1:N)) - stack%top_index = 0 + allocate(stack%tokens(l(1):u(1), & + l(2):u(2), & + 1:N)) + stack%top_index = 0 - end subroutine Construct_r2fp32Stack + endsubroutine Construct_r2fp32Stack - subroutine Push_r2fp32Stack(stack, tok) - class(r2fp32Stack), intent(inout) :: stack - real(real32), intent(in) :: tok(:, :) + subroutine Push_r2fp32Stack(stack,tok) + class(r2fp32Stack),intent(inout) :: stack + real(real32),intent(in) :: tok(:,:) - stack%top_index = stack%top_index + 1 - stack%tokens(:, :, stack%top_index) = tok(:, :) + stack%top_index = stack%top_index+1 + stack%tokens(:,:,stack%top_index) = tok(:,:) - end subroutine Push_r2fp32Stack + endsubroutine Push_r2fp32Stack - subroutine Pop_r2fp32Stack(stack, tok) - class(r2fp32Stack), intent(inout) :: stack - real(real32), intent(out) :: tok(:, :) + subroutine Pop_r2fp32Stack(stack,tok) + class(r2fp32Stack),intent(inout) :: stack + real(real32),intent(out) :: tok(:,:) - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok(:, :) = stack%tokens(:, :, stack%top_index) - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok(:,:) = stack%tokens(:,:,stack%top_index) + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_r2fp32Stack + endsubroutine Pop_r2fp32Stack - subroutine Construct_r2fp64Stack(stack, N, mold) - class(r2fp64Stack), intent(out) :: stack - integer, intent(in) :: N - real(real64), intent(in) :: mold(:, :) - ! local - integer :: l(1:2), u(1:2) + subroutine Construct_r2fp64Stack(stack,N,mold) + class(r2fp64Stack),intent(out) :: stack + integer,intent(in) :: N + real(real64),intent(in) :: mold(:,:) + ! local + integer :: l(1:2),u(1:2) - l = lbound(mold) - u = ubound(mold) + l = lbound(mold) + u = ubound(mold) - allocate (stack%tokens(l(1):u(1), & - l(2):u(2), & - 1:N)) - stack%top_index = 0 + allocate(stack%tokens(l(1):u(1), & + l(2):u(2), & + 1:N)) + stack%top_index = 0 - end subroutine Construct_r2fp64Stack + endsubroutine Construct_r2fp64Stack - subroutine Push_r2fp64Stack(stack, tok) - class(r2fp64Stack), intent(inout) :: stack - real(real64), intent(in) :: tok(:, :) + subroutine Push_r2fp64Stack(stack,tok) + class(r2fp64Stack),intent(inout) :: stack + real(real64),intent(in) :: tok(:,:) - stack%top_index = stack%top_index + 1 - stack%tokens(:, :, stack%top_index) = tok(:, :) + stack%top_index = stack%top_index+1 + stack%tokens(:,:,stack%top_index) = tok(:,:) - end subroutine Push_r2fp64Stack + endsubroutine Push_r2fp64Stack - subroutine Pop_r2fp64Stack(stack, tok) - class(r2fp64Stack), intent(inout) :: stack - real(real64), intent(out) :: tok(:, :) + subroutine Pop_r2fp64Stack(stack,tok) + class(r2fp64Stack),intent(inout) :: stack + real(real64),intent(out) :: tok(:,:) - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok(:, :) = stack%tokens(:, :, stack%top_index) - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok(:,:) = stack%tokens(:,:,stack%top_index) + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_r2fp64Stack + endsubroutine Pop_r2fp64Stack - subroutine Construct_r3fp32Stack(stack, N, mold) - class(r3fp32Stack), intent(out) :: stack - integer, intent(in) :: N - real(real32), intent(in) :: mold(:, :, :) - ! local - integer :: l(1:3), u(1:3) + subroutine Construct_r3fp32Stack(stack,N,mold) + class(r3fp32Stack),intent(out) :: stack + integer,intent(in) :: N + real(real32),intent(in) :: mold(:,:,:) + ! local + integer :: l(1:3),u(1:3) - l = lbound(mold) - u = ubound(mold) + l = lbound(mold) + u = ubound(mold) - allocate (stack%tokens(l(1):u(1), & - l(2):u(2), & - l(3):u(3), & - 1:N)) - stack%top_index = 0 + allocate(stack%tokens(l(1):u(1), & + l(2):u(2), & + l(3):u(3), & + 1:N)) + stack%top_index = 0 - end subroutine Construct_r3fp32Stack + endsubroutine Construct_r3fp32Stack - subroutine Push_r3fp32Stack(stack, tok) - class(r3fp32Stack), intent(inout) :: stack - real(real32), intent(in) :: tok(:, :, :) + subroutine Push_r3fp32Stack(stack,tok) + class(r3fp32Stack),intent(inout) :: stack + real(real32),intent(in) :: tok(:,:,:) - stack%top_index = stack%top_index + 1 - stack%tokens(:, :, :, stack%top_index) = tok(:, :, :) + stack%top_index = stack%top_index+1 + stack%tokens(:,:,:,stack%top_index) = tok(:,:,:) - end subroutine Push_r3fp32Stack + endsubroutine Push_r3fp32Stack - subroutine Pop_r3fp32Stack(stack, tok) - class(r3fp32Stack), intent(inout) :: stack - real(real32), intent(out) :: tok(:, :, :) + subroutine Pop_r3fp32Stack(stack,tok) + class(r3fp32Stack),intent(inout) :: stack + real(real32),intent(out) :: tok(:,:,:) - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok(:, :, :) = stack%tokens(:, :, :, stack%top_index) - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok(:,:,:) = stack%tokens(:,:,:,stack%top_index) + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_r3fp32Stack + endsubroutine Pop_r3fp32Stack - subroutine Construct_r3fp64Stack(stack, N, mold) - class(r3fp64Stack), intent(out) :: stack - integer, intent(in) :: N - real(real64), intent(in) :: mold(:, :, :) - ! local - integer :: l(1:3), u(1:3) + subroutine Construct_r3fp64Stack(stack,N,mold) + class(r3fp64Stack),intent(out) :: stack + integer,intent(in) :: N + real(real64),intent(in) :: mold(:,:,:) + ! local + integer :: l(1:3),u(1:3) - l = lbound(mold) - u = ubound(mold) + l = lbound(mold) + u = ubound(mold) - allocate (stack%tokens(l(1):u(1), & - l(2):u(2), & - l(3):u(3), & - 1:N)) - stack%top_index = 0 + allocate(stack%tokens(l(1):u(1), & + l(2):u(2), & + l(3):u(3), & + 1:N)) + stack%top_index = 0 - end subroutine Construct_r3fp64Stack + endsubroutine Construct_r3fp64Stack - subroutine Push_r3fp64Stack(stack, tok) - class(r3fp64Stack), intent(inout) :: stack - real(real64), intent(in) :: tok(:, :, :) + subroutine Push_r3fp64Stack(stack,tok) + class(r3fp64Stack),intent(inout) :: stack + real(real64),intent(in) :: tok(:,:,:) - stack%top_index = stack%top_index + 1 - stack%tokens(:, :, :, stack%top_index) = tok(:, :, :) + stack%top_index = stack%top_index+1 + stack%tokens(:,:,:,stack%top_index) = tok(:,:,:) - end subroutine Push_r3fp64Stack + endsubroutine Push_r3fp64Stack - subroutine Pop_r3fp64Stack(stack, tok) - class(r3fp64Stack), intent(inout) :: stack - real(real64), intent(out) :: tok(:, :, :) + subroutine Pop_r3fp64Stack(stack,tok) + class(r3fp64Stack),intent(inout) :: stack + real(real64),intent(out) :: tok(:,:,:) - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok(:, :, :) = stack%tokens(:, :, :, stack%top_index) - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok(:,:,:) = stack%tokens(:,:,:,stack%top_index) + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_r3fp64Stack + endsubroutine Pop_r3fp64Stack - subroutine Construct_r4fp32Stack(stack, N, mold) - class(r4fp32Stack), intent(out) :: stack - integer, intent(in) :: N - real(real32), intent(in) :: mold(:, :, :, :) - ! local - integer :: l(1:4), u(1:4) + subroutine Construct_r4fp32Stack(stack,N,mold) + class(r4fp32Stack),intent(out) :: stack + integer,intent(in) :: N + real(real32),intent(in) :: mold(:,:,:,:) + ! local + integer :: l(1:4),u(1:4) - l = lbound(mold) - u = ubound(mold) + l = lbound(mold) + u = ubound(mold) - allocate (stack%tokens(l(1):u(1), & - l(2):u(2), & - l(3):u(3), & - l(4):u(4), & - 1:N)) - stack%top_index = 0 + allocate(stack%tokens(l(1):u(1), & + l(2):u(2), & + l(3):u(3), & + l(4):u(4), & + 1:N)) + stack%top_index = 0 - end subroutine Construct_r4fp32Stack + endsubroutine Construct_r4fp32Stack - subroutine Push_r4fp32Stack(stack, tok) - class(r4fp32Stack), intent(inout) :: stack - real(real32), intent(in) :: tok(:, :, :, :) + subroutine Push_r4fp32Stack(stack,tok) + class(r4fp32Stack),intent(inout) :: stack + real(real32),intent(in) :: tok(:,:,:,:) - stack%top_index = stack%top_index + 1 - stack%tokens(:, :, :, :, stack%top_index) = tok(:, :, :, :) + stack%top_index = stack%top_index+1 + stack%tokens(:,:,:,:,stack%top_index) = tok(:,:,:,:) - end subroutine Push_r4fp32Stack + endsubroutine Push_r4fp32Stack - subroutine Pop_r4fp32Stack(stack, tok) - class(r4fp32Stack), intent(inout) :: stack - real(real32), intent(out) :: tok(:, :, :, :) + subroutine Pop_r4fp32Stack(stack,tok) + class(r4fp32Stack),intent(inout) :: stack + real(real32),intent(out) :: tok(:,:,:,:) - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok(:, :, :, :) = stack%tokens(:, :, :, :, stack%top_index) - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok(:,:,:,:) = stack%tokens(:,:,:,:,stack%top_index) + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_r4fp32Stack + endsubroutine Pop_r4fp32Stack - subroutine Construct_r4fp64Stack(stack, N, mold) - class(r4fp64Stack), intent(out) :: stack - integer, intent(in) :: N - real(real64), intent(in) :: mold(:, :, :, :) - ! local - integer :: l(1:4), u(1:4) - - l = lbound(mold) - u = ubound(mold) + subroutine Construct_r4fp64Stack(stack,N,mold) + class(r4fp64Stack),intent(out) :: stack + integer,intent(in) :: N + real(real64),intent(in) :: mold(:,:,:,:) + ! local + integer :: l(1:4),u(1:4) + + l = lbound(mold) + u = ubound(mold) - allocate (stack%tokens(l(1):u(1), & - l(2):u(2), & - l(3):u(3), & - l(4):u(4), & - 1:N)) - stack%top_index = 0 + allocate(stack%tokens(l(1):u(1), & + l(2):u(2), & + l(3):u(3), & + l(4):u(4), & + 1:N)) + stack%top_index = 0 - end subroutine Construct_r4fp64Stack + endsubroutine Construct_r4fp64Stack - subroutine Push_r4fp64Stack(stack, tok) - class(r4fp64Stack), intent(inout) :: stack - real(real64), intent(in) :: tok(:, :, :, :) + subroutine Push_r4fp64Stack(stack,tok) + class(r4fp64Stack),intent(inout) :: stack + real(real64),intent(in) :: tok(:,:,:,:) - stack%top_index = stack%top_index + 1 - stack%tokens(:, :, :, :, stack%top_index) = tok(:, :, :, :) + stack%top_index = stack%top_index+1 + stack%tokens(:,:,:,:,stack%top_index) = tok(:,:,:,:) - end subroutine Push_r4fp64Stack + endsubroutine Push_r4fp64Stack - subroutine Pop_r4fp64Stack(stack, tok) - class(r4fp64Stack), intent(inout) :: stack - real(real64), intent(out) :: tok(:, :, :, :) + subroutine Pop_r4fp64Stack(stack,tok) + class(r4fp64Stack),intent(inout) :: stack + real(real64),intent(out) :: tok(:,:,:,:) - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok(:, :, :, :) = stack%tokens(:, :, :, :, stack%top_index) - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok(:,:,:,:) = stack%tokens(:,:,:,:,stack%top_index) + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_r4fp64Stack + endsubroutine Pop_r4fp64Stack -end module FEQParse_FloatStacks +endmodule FEQParse_FloatStacks diff --git a/src/FEQParse_Functions.F90 b/src/FEQParse_Functions.F90 index d196c35..f8b2e6f 100644 --- a/src/FEQParse_Functions.F90 +++ b/src/FEQParse_Functions.F90 @@ -12,511 +12,512 @@ ! //////////////////////////////////////////////////////////////////////////////////////////////// ! module FEQParse_Functions - use iso_fortran_env - - implicit none - - integer, public :: nFunctions = 17 - integer, protected, public :: maxFunctionLength = 0 - - enum, bind(c) - enumerator :: cos_function = 1 - enumerator :: cosh_function = 2 - enumerator :: sin_function = 3 - enumerator :: sinh_function = 4 - enumerator :: tan_function = 5 - enumerator :: tanh_function = 6 - enumerator :: sqrt_function = 7 - enumerator :: abs_function = 8 - enumerator :: exp_function = 9 - enumerator :: ln_function = 10 - enumerator :: log_function = 11 - enumerator :: log10_function = 12 - enumerator :: acos_function = 13 - enumerator :: asin_function = 14 - enumerator :: atan_function = 15 - enumerator :: sech_function = 16 - enumerator :: rand_function = 17 - end enum - - private - - public :: InitializeFunctions, & - AddFunction - - interface - pure real(real32) function f32(x) - import - real(real32), intent(in) :: x - end function - end interface - - interface - pure real(real64) function f64(x) - import - real(real64), intent(in) :: x - end function - end interface - - type Tuple - character(:), allocatable :: item1 - character(:), allocatable :: item2 - end type - - type, public :: FEQParse_Function - integer :: len - character(:), allocatable :: str - character(:), allocatable :: caps - procedure(f32), public, nopass, pointer :: ptr32 => null() - procedure(f64), public, nopass, pointer :: ptr64 => null() - contains - procedure, private, pass(lhs) :: character_array_assign_function - procedure, private, pass(lhs) :: character_assign_function - procedure, private, pass(rhs) :: function_assign_character - generic :: assignment(=) => character_assign_function, character_array_assign_function - procedure, private, pass(lhs) :: function_eq_character - procedure, private, pass(rhs) :: character_eq_function - generic :: operator(==) => function_eq_character, character_eq_function - procedure, private, pass(lhs) :: function_neq_character - procedure, private, pass(rhs) :: character_neq_function - generic :: operator(/=) => function_neq_character, character_neq_function - procedure, private, pass(this) :: invoke32 - procedure, private, pass(this) :: invoke64 - generic :: invoke => invoke32, invoke64 - end type FEQParse_Function - - type(FEQParse_Function), dimension(:), allocatable, public :: Functions - - interface - pure real(real32) function randomize_r32() - import - end function - end interface - - interface - pure real(real64) function randomize_r64() - import - end function - end interface - - interface AddFunction - module procedure :: AddFunction32 - module procedure :: AddFunction64 - module procedure :: AddFunction32And64 - end interface - - interface Tuple - module procedure Tuple_new - end interface + use iso_fortran_env + + implicit none + + integer,public :: nFunctions = 17 + integer,protected,public :: maxFunctionLength = 0 + + enum,bind(c) + enumerator :: cos_function = 1 + enumerator :: cosh_function = 2 + enumerator :: sin_function = 3 + enumerator :: sinh_function = 4 + enumerator :: tan_function = 5 + enumerator :: tanh_function = 6 + enumerator :: sqrt_function = 7 + enumerator :: abs_function = 8 + enumerator :: exp_function = 9 + enumerator :: ln_function = 10 + enumerator :: log_function = 11 + enumerator :: log10_function = 12 + enumerator :: acos_function = 13 + enumerator :: asin_function = 14 + enumerator :: atan_function = 15 + enumerator :: sech_function = 16 + enumerator :: rand_function = 17 + endenum + + private + + public :: InitializeFunctions, & + AddFunction + + interface + pure real(real32) function f32(x) + import + real(real32),intent(in) :: x + endfunction + endinterface + + interface + pure real(real64) function f64(x) + import + real(real64),intent(in) :: x + endfunction + endinterface + + type Tuple + character(:),allocatable :: item1 + character(:),allocatable :: item2 + endtype + + type,public :: FEQParse_Function + integer :: len + character(:),allocatable :: str + character(:),allocatable :: caps + procedure(f32),public,nopass,pointer :: ptr32 => null() + procedure(f64),public,nopass,pointer :: ptr64 => null() + contains + procedure,private,pass(lhs) :: character_array_assign_function + procedure,private,pass(lhs) :: character_assign_function + procedure,private,pass(rhs) :: function_assign_character + generic :: assignment(=) => character_assign_function,character_array_assign_function + procedure,private,pass(lhs) :: function_eq_character + procedure,private,pass(rhs) :: character_eq_function + generic :: operator(==) => function_eq_character,character_eq_function + procedure,private,pass(lhs) :: function_neq_character + procedure,private,pass(rhs) :: character_neq_function + generic :: operator(/=) => function_neq_character,character_neq_function + procedure,private,pass(this) :: invoke32 + procedure,private,pass(this) :: invoke64 + generic :: invoke => invoke32,invoke64 + endtype FEQParse_Function + + type(FEQParse_Function),dimension(:),allocatable,public :: Functions + + interface + pure real(real32) function randomize_r32() + import + endfunction + endinterface + + interface + pure real(real64) function randomize_r64() + import + endfunction + endinterface + + interface AddFunction + module procedure :: AddFunction32 + module procedure :: AddFunction64 + module procedure :: AddFunction32And64 + endinterface + + interface Tuple + module procedure Tuple_new + endinterface contains - type(Tuple) function Tuple_new(item1, item2) result(t) - character(*), intent(in) :: item1 - character(*), intent(in) :: item2 - - t%item1 = item1 - t%item2 = item2 - end function - - subroutine character_array_assign_function(lhs, rhs) - class(FEQParse_Function), intent(inout) :: lhs !! Left hand side. - class(Tuple), intent(in) :: rhs !! Right hand side. - - lhs%str = rhs%item1 - lhs%len = len(rhs%item1) - lhs%caps = rhs%item2 - maxFunctionLength = max(maxFunctionLength, lhs%len) - end subroutine + type(Tuple) function Tuple_new(item1,item2) result(t) + character(*),intent(in) :: item1 + character(*),intent(in) :: item2 + + t%item1 = item1 + t%item2 = item2 + endfunction + + subroutine character_array_assign_function(lhs,rhs) + class(FEQParse_Function),intent(inout) :: lhs !! Left hand side. + class(Tuple),intent(in) :: rhs !! Right hand side. + + lhs%str = rhs%item1 + lhs%len = len(rhs%item1) + lhs%caps = rhs%item2 + maxFunctionLength = max(maxFunctionLength,lhs%len) + endsubroutine - subroutine character_assign_function(lhs, rhs) - class(FEQParse_Function), intent(inout) :: lhs !! Left hand side. - character(len=*), intent(in) :: rhs !! Right hand side. + subroutine character_assign_function(lhs,rhs) + class(FEQParse_Function),intent(inout) :: lhs !! Left hand side. + character(len=*),intent(in) :: rhs !! Right hand side. - lhs%str = rhs - lhs%len = len(rhs) - lhs%caps = ToUpperCase(rhs) - maxFunctionLength = max(maxFunctionLength, lhs%len) - end subroutine - - pure subroutine function_assign_character(lhs, rhs) - character(len=*), allocatable, intent(inout) :: lhs - class(FEQParse_Function), intent(in) :: rhs - lhs = rhs%str - end subroutine + lhs%str = rhs + lhs%len = len(rhs) + lhs%caps = ToUpperCase(rhs) + maxFunctionLength = max(maxFunctionLength,lhs%len) + endsubroutine + + pure subroutine function_assign_character(lhs,rhs) + character(len=*),allocatable,intent(inout) :: lhs + class(FEQParse_Function),intent(in) :: rhs + lhs = rhs%str + endsubroutine - elemental function function_eq_character(lhs, rhs) result(ok) - class(FEQParse_Function), intent(in) :: lhs !! Left hand side. - character(len=*), intent(in) :: rhs !! Right hand side. - logical :: ok - - ok = lhs%str == rhs .or. lhs%caps == rhs - end function - - elemental function character_eq_function(lhs, rhs) result(ok) - character(len=*), intent(in) :: lhs - class(FEQParse_Function), intent(in) :: rhs - logical :: ok - - ok = lhs == rhs%str .or. lhs == rhs%caps - end function - - elemental function function_neq_character(lhs, rhs) result(ok) - class(FEQParse_Function), intent(in) :: lhs !! Left hand side. - character(len=*), intent(in) :: rhs !! Right hand side. - logical :: ok - - ok = lhs%str /= rhs .or. lhs%caps /= rhs - end function - - elemental function character_neq_function(lhs, rhs) result(ok) - character(len=*), intent(in) :: lhs - class(FEQParse_Function), intent(in) :: rhs - logical :: ok - - ok = lhs /= rhs%str .or. lhs /= rhs%caps - end function - - subroutine InitializeFunctions() - if (allocated(Functions)) return - - allocate (Functions(1:nFunctions)) - Functions(cos_function) = Tuple("cos", "COS") - Functions(cos_function)%ptr32 => cos32 - Functions(cos_function)%ptr64 => cos64 - - Functions(cosh_function) = Tuple("cosh", "COSH") - Functions(cosh_function)%ptr32 => cosh32 - Functions(cosh_function)%ptr64 => cosh64 - - Functions(sin_function) = Tuple("sin", "SIN") - Functions(sin_function)%ptr32 => sin32 - Functions(sin_function)%ptr64 => sin64 - - Functions(sinh_function) = Tuple("sinh", "SINH") - Functions(sinh_function)%ptr32 => sinh32 - Functions(sinh_function)%ptr64 => sinh64 - - Functions(tan_function) = Tuple("tan", "TAN") - Functions(tan_function)%ptr32 => tan32 - Functions(tan_function)%ptr64 => tan64 - - Functions(tanh_function) = Tuple("tanh", "TANH") - Functions(tanh_function)%ptr32 => tanh32 - Functions(tanh_function)%ptr64 => tanh64 - - Functions(sqrt_function) = Tuple("sqrt", "SQRT") - Functions(sqrt_function)%ptr32 => sqrt32 - Functions(sqrt_function)%ptr64 => sqrt64 - - Functions(abs_function) = Tuple("abs", "ABS") - Functions(abs_function)%ptr32 => abs32 - Functions(abs_function)%ptr64 => abs64 - - Functions(exp_function) = Tuple("exp", "EXP") - Functions(exp_function)%ptr32 => exp32 - Functions(exp_function)%ptr64 => exp64 - - Functions(ln_function) = Tuple("ln", "LN") - Functions(ln_function)%ptr32 => log32 - Functions(ln_function)%ptr64 => log64 - - Functions(log_function) = Tuple("log", "LOG") - Functions(log_function)%ptr32 => log32 - Functions(log_function)%ptr64 => log64 - - Functions(log10_function) = Tuple("log10", "LOG10") - Functions(log10_function)%ptr32 => log1032 - Functions(log10_function)%ptr64 => log1064 - - Functions(acos_function) = Tuple("acos", "ACOS") - Functions(acos_function)%ptr32 => acos32 - Functions(acos_function)%ptr64 => acos64 - - Functions(asin_function) = Tuple("asin", "ASIN") - Functions(asin_function)%ptr32 => asin32 - Functions(asin_function)%ptr64 => asin64 - - Functions(atan_function) = Tuple("atan", "ATAN") - Functions(atan_function)%ptr32 => atan32 - Functions(atan_function)%ptr64 => atan64 - - Functions(sech_function) = Tuple("sech", "SECH") - Functions(sech_function)%ptr32 => sech32 - Functions(sech_function)%ptr64 => sech64 - - Functions(rand_function) = Tuple("rand", "RAND") - Functions(rand_function)%ptr32 => rand32 - Functions(rand_function)%ptr64 => rand64 - end subroutine InitializeFunctions - - subroutine AddFunction32(name, f_32) - character(*), intent(in) :: name - procedure(f32) :: f_32 - !private - type(FEQParse_Function) :: func - - call InitializeFunctions() - func = name - func%ptr32 => f_32 - func%ptr64 => null() - Functions = [Functions, func] - nFunctions = nFunctions + 1 - end subroutine - - subroutine AddFunction64(name, f_64) - character(*), intent(in) :: name - procedure(f64) :: f_64 - !private - type(FEQParse_Function) :: func - - call InitializeFunctions() - func = name - func%ptr32 => null() - func%ptr64 => f_64 - Functions = [Functions, func] - nFunctions = nFunctions + 1 - end subroutine - - subroutine AddFunction32And64(name, f_32, f_64) - character(*), intent(in) :: name - procedure(f32) :: f_32 - procedure(f64) :: f_64 - !private - type(FEQParse_Function) :: func - - call InitializeFunctions() - func = name - func%ptr32 => f_32 - func%ptr64 => f_64 - Functions = [Functions, func] - nFunctions = nFunctions + 1 - end subroutine - - elemental real(real32) function invoke32(this, x) result(fx) - class(FEQParse_Function), intent(in) :: this - real(real32), intent(in) :: x - fx = this%ptr32(x) - end function - - elemental real(real64) function invoke64(this, x) result(fx) - class(FEQParse_Function), intent(in) :: this - real(real64), intent(in) :: x - fx = this%ptr64(x) - end function - - pure real(real32) function cos32(x) result(fx) - real(real32), intent(in) :: x - fx = cos(x) - end function - - pure real(real64) function cos64(x) result(fx) - real(real64), intent(in) :: x - fx = cos(x) - end function - - pure real(real32) function cosh32(x) result(fx) - real(real32), intent(in) :: x - fx = cosh(x) - end function - - pure real(real64) function cosh64(x) result(fx) - real(real64), intent(in) :: x - fx = cosh(x) - end function - - pure real(real32) function sin32(x) result(fx) - real(real32), intent(in) :: x - fx = sin(x) - end function - - pure real(real64) function sin64(x) result(fx) - real(real64), intent(in) :: x - fx = sin(x) - end function - - pure real(real32) function sinh32(x) result(fx) - real(real32), intent(in) :: x - fx = sinh(x) - end function - - pure real(real64) function sinh64(x) result(fx) - real(real64), intent(in) :: x - fx = sinh(x) - end function - - pure real(real32) function tan32(x) result(fx) - real(real32), intent(in) :: x - fx = tan(x) - end function - - pure real(real64) function tan64(x) result(fx) - real(real64), intent(in) :: x - fx = tan(x) - end function - - pure real(real32) function tanh32(x) result(fx) - real(real32), intent(in) :: x - fx = tanh(x) - end function - - pure real(real64) function tanh64(x) result(fx) - real(real64), intent(in) :: x - fx = tanh(x) - end function - - pure real(real32) function sqrt32(x) result(fx) - real(real32), intent(in) :: x - fx = sqrt(x) - end function - - pure real(real64) function sqrt64(x) result(fx) - real(real64), intent(in) :: x - fx = sqrt(x) - end function - - pure real(real32) function abs32(x) result(fx) - real(real32), intent(in) :: x - fx = abs(x) - end function - - pure real(real64) function abs64(x) result(fx) - real(real64), intent(in) :: x - fx = abs(x) - end function - - pure real(real32) function exp32(x) result(fx) - real(real32), intent(in) :: x - fx = exp(x) - end function - - pure real(real64) function exp64(x) result(fx) - real(real64), intent(in) :: x - fx = exp(x) - end function - - pure real(real32) function log32(x) result(fx) - real(real32), intent(in) :: x - fx = log(x) - end function - - pure real(real64) function log64(x) result(fx) - real(real64), intent(in) :: x - fx = log(x) - end function - - pure real(real32) function log1032(x) result(fx) - real(real32), intent(in) :: x - fx = log10(x) - end function - - pure real(real64) function log1064(x) result(fx) - real(real64), intent(in) :: x - fx = log10(x) - end function - - pure real(real32) function acos32(x) result(fx) - real(real32), intent(in) :: x - fx = acos(x) - end function - - pure real(real64) function acos64(x) result(fx) - real(real64), intent(in) :: x - fx = acos(x) - end function - - pure real(real32) function asin32(x) result(fx) - real(real32), intent(in) :: x - fx = asin(x) - end function - - pure real(real64) function asin64(x) result(fx) - real(real64), intent(in) :: x - fx = asin(x) - end function - - pure real(real32) function atan32(x) result(fx) - real(real32), intent(in) :: x - fx = atan(x) - end function - - pure real(real64) function atan64(x) result(fx) - real(real64), intent(in) :: x - fx = atan(x) - end function - - pure real(real32) function sech32(x) result(fx) - real(real32), intent(in) :: x - fx = 2.0_real32 / (exp(x) + exp(-x)) - end function - - pure real(real64) function sech64(x) result(fx) - real(real64), intent(in) :: x - fx = 2.0_real64 / (exp(x) + exp(-x)) - end function - - pure real(real32) function rand32(x) result(fx) - real(real32), intent(in) :: x - !private - real(real32) :: r - associate (r => randomize_r32()) - fx = r * x - end associate - end function - - pure real(real64) function rand64(x) result(fx) - real(real64), intent(in) :: x - !private - real(real64) :: r - associate (r => randomize_r64()) - fx = r * x - end associate - end function - - pure function ToUpperCase(str) result(res) - character(*), intent(in) :: str - character(len(str)) :: res - integer :: i, j - - do i = 1, len(str) - select case (str(i:i)) - case ('a':'z') - res(i:i) = achar(iachar(str(i:i)) - 32) - case default - res(i:i) = str(i:i) - end select - end do - end function ToUpperCase - - pure function ToLowerCase(str) result(res) - character(*), intent(in) :: str - character(len(str)), allocatable :: res - integer :: i - - do i = 1, len(str) - select case (str(i:i)) - case ('A':'Z') - res(i:i) = achar(iachar(str(i:i)) + 32) - case default - res(i:i) = str(i:i) - end select - end do - end function ToLowerCase - -end module FEQParse_Functions + elemental function function_eq_character(lhs,rhs) result(ok) + class(FEQParse_Function),intent(in) :: lhs !! Left hand side. + character(len=*),intent(in) :: rhs !! Right hand side. + logical :: ok + + ok = lhs%str == rhs .or. lhs%caps == rhs + endfunction + + elemental function character_eq_function(lhs,rhs) result(ok) + character(len=*),intent(in) :: lhs + class(FEQParse_Function),intent(in) :: rhs + logical :: ok + + ok = lhs == rhs%str .or. lhs == rhs%caps + endfunction + + elemental function function_neq_character(lhs,rhs) result(ok) + class(FEQParse_Function),intent(in) :: lhs !! Left hand side. + character(len=*),intent(in) :: rhs !! Right hand side. + logical :: ok + + ok = lhs%str /= rhs .or. lhs%caps /= rhs + endfunction + + elemental function character_neq_function(lhs,rhs) result(ok) + character(len=*),intent(in) :: lhs + class(FEQParse_Function),intent(in) :: rhs + logical :: ok + + ok = lhs /= rhs%str .or. lhs /= rhs%caps + endfunction + + subroutine InitializeFunctions() + if(allocated(Functions)) return + + allocate(Functions(1:nFunctions)) + Functions(cos_function) = Tuple("cos","COS") + Functions(cos_function)%ptr32 => cos32 + Functions(cos_function)%ptr64 => cos64 + + Functions(cosh_function) = Tuple("cosh","COSH") + Functions(cosh_function)%ptr32 => cosh32 + Functions(cosh_function)%ptr64 => cosh64 + + Functions(sin_function) = Tuple("sin","SIN") + Functions(sin_function)%ptr32 => sin32 + Functions(sin_function)%ptr64 => sin64 + + Functions(sinh_function) = Tuple("sinh","SINH") + Functions(sinh_function)%ptr32 => sinh32 + Functions(sinh_function)%ptr64 => sinh64 + + Functions(tan_function) = Tuple("tan","TAN") + Functions(tan_function)%ptr32 => tan32 + Functions(tan_function)%ptr64 => tan64 + + Functions(tanh_function) = Tuple("tanh","TANH") + Functions(tanh_function)%ptr32 => tanh32 + Functions(tanh_function)%ptr64 => tanh64 + + Functions(sqrt_function) = Tuple("sqrt","SQRT") + Functions(sqrt_function)%ptr32 => sqrt32 + Functions(sqrt_function)%ptr64 => sqrt64 + + Functions(abs_function) = Tuple("abs","ABS") + Functions(abs_function)%ptr32 => abs32 + Functions(abs_function)%ptr64 => abs64 + + Functions(exp_function) = Tuple("exp","EXP") + Functions(exp_function)%ptr32 => exp32 + Functions(exp_function)%ptr64 => exp64 + + Functions(ln_function) = Tuple("ln","LN") + Functions(ln_function)%ptr32 => log32 + Functions(ln_function)%ptr64 => log64 + + Functions(log_function) = Tuple("log","LOG") + Functions(log_function)%ptr32 => log32 + Functions(log_function)%ptr64 => log64 + + Functions(log10_function) = Tuple("log10","LOG10") + Functions(log10_function)%ptr32 => log1032 + Functions(log10_function)%ptr64 => log1064 + + Functions(acos_function) = Tuple("acos","ACOS") + Functions(acos_function)%ptr32 => acos32 + Functions(acos_function)%ptr64 => acos64 + + Functions(asin_function) = Tuple("asin","ASIN") + Functions(asin_function)%ptr32 => asin32 + Functions(asin_function)%ptr64 => asin64 + + Functions(atan_function) = Tuple("atan","ATAN") + Functions(atan_function)%ptr32 => atan32 + Functions(atan_function)%ptr64 => atan64 + + Functions(sech_function) = Tuple("sech","SECH") + Functions(sech_function)%ptr32 => sech32 + Functions(sech_function)%ptr64 => sech64 + + Functions(rand_function) = Tuple("rand","RAND") + Functions(rand_function)%ptr32 => rand32 + Functions(rand_function)%ptr64 => rand64 + endsubroutine InitializeFunctions + + subroutine AddFunction32(name,f_32) + character(*),intent(in) :: name + procedure(f32) :: f_32 + !private + type(FEQParse_Function) :: func + + call InitializeFunctions() + func = name + func%ptr32 => f_32 + func%ptr64 => null() + Functions = [Functions,func] + nFunctions = nFunctions+1 + endsubroutine + + subroutine AddFunction64(name,f_64) + character(*),intent(in) :: name + procedure(f64) :: f_64 + !private + type(FEQParse_Function) :: func + + call InitializeFunctions() + func = name + func%ptr32 => null() + func%ptr64 => f_64 + print*,size(Functions) + Functions = [Functions,func] + nFunctions = nFunctions+1 + endsubroutine + + subroutine AddFunction32And64(name,f_32,f_64) + character(*),intent(in) :: name + procedure(f32) :: f_32 + procedure(f64) :: f_64 + !private + type(FEQParse_Function) :: func + + call InitializeFunctions() + func = name + func%ptr32 => f_32 + func%ptr64 => f_64 + Functions = [Functions,func] + nFunctions = nFunctions+1 + endsubroutine + + elemental real(real32) function invoke32(this,x) result(fx) + class(FEQParse_Function),intent(in) :: this + real(real32),intent(in) :: x + fx = this%ptr32(x) + endfunction + + elemental real(real64) function invoke64(this,x) result(fx) + class(FEQParse_Function),intent(in) :: this + real(real64),intent(in) :: x + fx = this%ptr64(x) + endfunction + + pure real(real32) function cos32(x) result(fx) + real(real32),intent(in) :: x + fx = cos(x) + endfunction + + pure real(real64) function cos64(x) result(fx) + real(real64),intent(in) :: x + fx = cos(x) + endfunction + + pure real(real32) function cosh32(x) result(fx) + real(real32),intent(in) :: x + fx = cosh(x) + endfunction + + pure real(real64) function cosh64(x) result(fx) + real(real64),intent(in) :: x + fx = cosh(x) + endfunction + + pure real(real32) function sin32(x) result(fx) + real(real32),intent(in) :: x + fx = sin(x) + endfunction + + pure real(real64) function sin64(x) result(fx) + real(real64),intent(in) :: x + fx = sin(x) + endfunction + + pure real(real32) function sinh32(x) result(fx) + real(real32),intent(in) :: x + fx = sinh(x) + endfunction + + pure real(real64) function sinh64(x) result(fx) + real(real64),intent(in) :: x + fx = sinh(x) + endfunction + + pure real(real32) function tan32(x) result(fx) + real(real32),intent(in) :: x + fx = tan(x) + endfunction + + pure real(real64) function tan64(x) result(fx) + real(real64),intent(in) :: x + fx = tan(x) + endfunction + + pure real(real32) function tanh32(x) result(fx) + real(real32),intent(in) :: x + fx = tanh(x) + endfunction + + pure real(real64) function tanh64(x) result(fx) + real(real64),intent(in) :: x + fx = tanh(x) + endfunction + + pure real(real32) function sqrt32(x) result(fx) + real(real32),intent(in) :: x + fx = sqrt(x) + endfunction + + pure real(real64) function sqrt64(x) result(fx) + real(real64),intent(in) :: x + fx = sqrt(x) + endfunction + + pure real(real32) function abs32(x) result(fx) + real(real32),intent(in) :: x + fx = abs(x) + endfunction + + pure real(real64) function abs64(x) result(fx) + real(real64),intent(in) :: x + fx = abs(x) + endfunction + + pure real(real32) function exp32(x) result(fx) + real(real32),intent(in) :: x + fx = exp(x) + endfunction + + pure real(real64) function exp64(x) result(fx) + real(real64),intent(in) :: x + fx = exp(x) + endfunction + + pure real(real32) function log32(x) result(fx) + real(real32),intent(in) :: x + fx = log(x) + endfunction + + pure real(real64) function log64(x) result(fx) + real(real64),intent(in) :: x + fx = log(x) + endfunction + + pure real(real32) function log1032(x) result(fx) + real(real32),intent(in) :: x + fx = log10(x) + endfunction + + pure real(real64) function log1064(x) result(fx) + real(real64),intent(in) :: x + fx = log10(x) + endfunction + + pure real(real32) function acos32(x) result(fx) + real(real32),intent(in) :: x + fx = acos(x) + endfunction + + pure real(real64) function acos64(x) result(fx) + real(real64),intent(in) :: x + fx = acos(x) + endfunction + + pure real(real32) function asin32(x) result(fx) + real(real32),intent(in) :: x + fx = asin(x) + endfunction + + pure real(real64) function asin64(x) result(fx) + real(real64),intent(in) :: x + fx = asin(x) + endfunction + + pure real(real32) function atan32(x) result(fx) + real(real32),intent(in) :: x + fx = atan(x) + endfunction + + pure real(real64) function atan64(x) result(fx) + real(real64),intent(in) :: x + fx = atan(x) + endfunction + + pure real(real32) function sech32(x) result(fx) + real(real32),intent(in) :: x + fx = 2.0_real32/(exp(x)+exp(-x)) + endfunction + + pure real(real64) function sech64(x) result(fx) + real(real64),intent(in) :: x + fx = 2.0_real64/(exp(x)+exp(-x)) + endfunction + + pure real(real32) function rand32(x) result(fx) + real(real32),intent(in) :: x + !private + real(real32) :: r + associate(r => randomize_r32()) + fx = r*x + endassociate + endfunction + + pure real(real64) function rand64(x) result(fx) + real(real64),intent(in) :: x + !private + real(real64) :: r + associate(r => randomize_r64()) + fx = r*x + endassociate + endfunction + + pure function ToUpperCase(str) result(res) + character(*),intent(in) :: str + character(len(str)) :: res + integer :: i,j + + do i = 1,len(str) + select case(str(i:i)) + case('a':'z') + res(i:i) = achar(iachar(str(i:i))-32) + case default + res(i:i) = str(i:i) + endselect + enddo + endfunction ToUpperCase + + pure function ToLowerCase(str) result(res) + character(*),intent(in) :: str + character(len(str)),allocatable :: res + integer :: i + + do i = 1,len(str) + select case(str(i:i)) + case('A':'Z') + res(i:i) = achar(iachar(str(i:i))+32) + case default + res(i:i) = str(i:i) + endselect + enddo + endfunction ToLowerCase + +endmodule FEQParse_Functions real(real32) function randomize_r32() - use, intrinsic :: iso_fortran_env, only: real32 - real(real32) :: r + use,intrinsic :: iso_fortran_env,only:real32 + real(real32) :: r - call random_number(r) - randomize_r32 = r -end function + call random_number(r) + randomize_r32 = r +endfunction real(real64) function randomize_r64() - use, intrinsic :: iso_fortran_env, only: real64 - real(real64) :: r + use,intrinsic :: iso_fortran_env,only:real64 + real(real64) :: r - call random_number(r) - randomize_r64 = r -end function + call random_number(r) + randomize_r64 = r +endfunction diff --git a/src/FEQParse_TokenStack.F90 b/src/FEQParse_TokenStack.F90 index 6b23315..eb2ba6c 100644 --- a/src/FEQParse_TokenStack.F90 +++ b/src/FEQParse_TokenStack.F90 @@ -12,96 +12,96 @@ ! //////////////////////////////////////////////////////////////////////////////////////////////// ! module FEQParse_TokenStack - use iso_fortran_env - - implicit none - - type Token - character(48) :: tokenString - integer :: tokenType - integer :: tokenIndex - contains - procedure :: Copy - end type - - type TokenStack - type(Token), allocatable :: tokens(:) - integer :: top_index = 0 - contains - procedure :: Construct => Construct_TokenStack - procedure :: Push => Push_TokenStack - procedure :: Pop => Pop_TokenStack - procedure :: IsEmpty => IsEmpty_TokenStack - procedure :: TopToken - end type + use iso_fortran_env + + implicit none + + type Token + character(48) :: tokenString + integer :: tokenType + integer :: tokenIndex + contains + procedure :: Copy + endtype + + type TokenStack + type(Token),allocatable :: tokens(:) + integer :: top_index = 0 + contains + procedure :: Construct => Construct_TokenStack + procedure :: Push => Push_TokenStack + procedure :: Pop => Pop_TokenStack + procedure :: IsEmpty => IsEmpty_TokenStack + procedure :: TopToken + endtype contains - subroutine Construct_TokenStack(stack, N) - class(TokenStack), intent(out) :: stack - integer, intent(in) :: N + subroutine Construct_TokenStack(stack,N) + class(TokenStack),intent(out) :: stack + integer,intent(in) :: N - allocate (stack%tokens(1:N)) - stack%top_index = 0 + allocate(stack%tokens(1:N)) + stack%top_index = 0 - end subroutine Construct_TokenStack + endsubroutine Construct_TokenStack - subroutine Push_TokenStack(stack, tok) - class(TokenStack), intent(inout) :: stack - type(Token), intent(in) :: tok + subroutine Push_TokenStack(stack,tok) + class(TokenStack),intent(inout) :: stack + type(Token),intent(in) :: tok - stack%top_index = stack%top_index + 1 - stack%tokens(stack%top_index)%tokenString = tok%tokenString - stack%tokens(stack%top_index)%tokenType = tok%tokenType - stack%tokens(stack%top_index)%tokenIndex = tok%tokenIndex - end subroutine Push_TokenStack + stack%top_index = stack%top_index+1 + stack%tokens(stack%top_index)%tokenString = tok%tokenString + stack%tokens(stack%top_index)%tokenType = tok%tokenType + stack%tokens(stack%top_index)%tokenIndex = tok%tokenIndex + endsubroutine Push_TokenStack - subroutine Pop_TokenStack(stack, tok) - class(TokenStack), intent(inout) :: stack - type(Token), intent(out) :: tok + subroutine Pop_TokenStack(stack,tok) + class(TokenStack),intent(inout) :: stack + type(Token),intent(out) :: tok - if (stack%top_index <= 0) then - print*,"Attempt to pop from empty token stack" - else - tok%tokenString = stack%tokens(stack%top_index)%tokenString - tok%tokenType = stack%tokens(stack%top_index)%tokenType - tok%tokenIndex = stack%tokens(stack%top_index)%tokenIndex - stack%top_index = stack%top_index - 1 - end if + if(stack%top_index <= 0) then + print*,"Attempt to pop from empty token stack" + else + tok%tokenString = stack%tokens(stack%top_index)%tokenString + tok%tokenType = stack%tokens(stack%top_index)%tokenType + tok%tokenIndex = stack%tokens(stack%top_index)%tokenIndex + stack%top_index = stack%top_index-1 + endif - end subroutine Pop_TokenStack + endsubroutine Pop_TokenStack - logical function IsEmpty_TokenStack(stack) - class(TokenStack) :: stack + logical function IsEmpty_TokenStack(stack) + class(TokenStack) :: stack - IsEmpty_TokenStack = .false. + IsEmpty_TokenStack = .false. - if (stack%top_index <= 0) then - IsEmpty_TokenStack = .true. - end if + if(stack%top_index <= 0) then + IsEmpty_TokenStack = .true. + endif - end function IsEmpty_TokenStack + endfunction IsEmpty_TokenStack - type(Token) function TopToken(stack) - class(TokenStack) :: stack + type(Token) function TopToken(stack) + class(TokenStack) :: stack - if (stack%top_index > 0) then - TopToken%tokenString = stack%tokens(stack%top_index)%tokenString - TopToken%tokenType = stack%tokens(stack%top_index)%tokenType - TopToken%tokenIndex = stack%tokens(stack%top_index)%tokenIndex - else - TopToken%tokenString = '' - end if + if(stack%top_index > 0) then + TopToken%tokenString = stack%tokens(stack%top_index)%tokenString + TopToken%tokenType = stack%tokens(stack%top_index)%tokenType + TopToken%tokenIndex = stack%tokens(stack%top_index)%tokenIndex + else + TopToken%tokenString = '' + endif - end function TopToken + endfunction TopToken - function Copy(this) result(that) - class(Token) :: this - type(Token) :: that + function Copy(this) result(that) + class(Token) :: this + type(Token) :: that - that%tokenString = this%tokenString - that%tokenType = this%tokenType - that%tokenIndex = this%tokenIndex - end function Copy + that%tokenString = this%tokenString + that%tokenType = this%tokenType + that%tokenIndex = this%tokenIndex + endfunction Copy -end module FEQParse_TokenStack +endmodule FEQParse_TokenStack diff --git a/test/abs_r1fp32.f90 b/test/abs_r1fp32.f90 index 7d12f71..6c197e5 100644 --- a/test/abs_r1fp32.f90 +++ b/test/abs_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = abs_r1fp32() - stop exit_code + exit_code = abs_r1fp32() + stop exit_code contains - integer function abs_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = abs(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function abs_r1fp32 -end program test + integer function abs_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = abs(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction abs_r1fp32 +endprogram test diff --git a/test/abs_r1fp64.f90 b/test/abs_r1fp64.f90 index 145eb4e..b1d36c0 100644 --- a/test/abs_r1fp64.f90 +++ b/test/abs_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = abs_r1fp64() - stop exit_code + exit_code = abs_r1fp64() + stop exit_code contains - integer function abs_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = abs(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function abs_r1fp64 -end program test + integer function abs_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = abs(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction abs_r1fp64 +endprogram test diff --git a/test/abs_r2fp32.f90 b/test/abs_r2fp32.f90 index 99a8c82..53d31bb 100644 --- a/test/abs_r2fp32.f90 +++ b/test/abs_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = abs_r2fp32() - stop exit_code + exit_code = abs_r2fp32() + stop exit_code contains - integer function abs_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = abs(x(i, j, 1) + x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function abs_r2fp32 -end program test + integer function abs_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = abs(x(i,j,1)+x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction abs_r2fp32 +endprogram test diff --git a/test/abs_r2fp64.f90 b/test/abs_r2fp64.f90 index a54d8c9..ac0ee52 100644 --- a/test/abs_r2fp64.f90 +++ b/test/abs_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = abs_r2fp64() - stop exit_code + exit_code = abs_r2fp64() + stop exit_code contains - integer function abs_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = abs(x(i, j, 1) + x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function abs_r2fp64 -end program test + integer function abs_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = abs(x(i,j,1)+x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction abs_r2fp64 +endprogram test diff --git a/test/abs_r3fp32.f90 b/test/abs_r3fp32.f90 index cc46baa..4210d33 100644 --- a/test/abs_r3fp32.f90 +++ b/test/abs_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = abs_r3fp32() - stop exit_code + exit_code = abs_r3fp32() + stop exit_code contains - integer function abs_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function abs_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y + z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y + z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = abs(x(i, j, k, 1) + x(i, j, k, 2) + x(i, j, k, 3)) - end do - end do - end do + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = abs(x(i,j,k,1)+x(i,j,k,2)+x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real32 * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= 10.0_real32*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function abs_r3fp32 -end program test + endfunction abs_r3fp32 +endprogram test diff --git a/test/abs_r3fp64.f90 b/test/abs_r3fp64.f90 index ca2f5aa..9e8de53 100644 --- a/test/abs_r3fp64.f90 +++ b/test/abs_r3fp64.f90 @@ -1,65 +1,65 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = abs_r3fp64() - stop exit_code + exit_code = abs_r3fp64() + stop exit_code contains - integer function abs_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function abs_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y + z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y + z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = abs(x(i, j, k, 1) + x(i, j, k, 2) + x(i, j, k, 3)) - end do - end do - end do + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = abs(x(i,j,k,1)+x(i,j,k,2)+x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real64 * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= 10.0_real64*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - end function abs_r3fp64 -end program test + endfunction abs_r3fp64 +endprogram test diff --git a/test/abs_r4fp32.f90 b/test/abs_r4fp32.f90 index b31f1b0..186adc6 100644 --- a/test/abs_r4fp32.f90 +++ b/test/abs_r4fp32.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = abs_r4fp32() - stop exit_code + exit_code = abs_r4fp32() + stop exit_code contains - integer function abs_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function abs_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y + z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y + z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = abs(x(i, j, k, l, 1) + x(i, j, k, l, 2) + x(i, j, k, l, 3)) - end do - end do - end do - end do + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = abs(x(i,j,k,l,1)+x(i,j,k,l,2)+x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - print*,maxval(abs(feval - fexact)) - r = 1 - end if - deallocate (x, feval, fexact) + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + print*,maxval(abs(feval-fexact)) + r = 1 + endif + deallocate(x,feval,fexact) - end function abs_r4fp32 -end program test + endfunction abs_r4fp32 +endprogram test diff --git a/test/abs_r4fp64.f90 b/test/abs_r4fp64.f90 index 31441da..094e957 100644 --- a/test/abs_r4fp64.f90 +++ b/test/abs_r4fp64.f90 @@ -1,70 +1,70 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = abs_r4fp64() - stop exit_code + exit_code = abs_r4fp64() + stop exit_code contains - integer function abs_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function abs_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x + y + z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x + y + z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = abs(x(i, j, k, l, 1) + x(i, j, k, l, 2) + x(i, j, k, l, 3)) - end do - end do - end do - end do + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = abs(x(i,j,k,l,1)+x(i,j,k,l,2)+x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - end function abs_r4fp64 -end program test + endfunction abs_r4fp64 +endprogram test diff --git a/test/abs_sfp32.f90 b/test/abs_sfp32.f90 index 87af357..92550f7 100644 --- a/test/abs_sfp32.f90 +++ b/test/abs_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = abs_sfp32() - stop exit_code + exit_code = abs_sfp32() + stop exit_code contains - integer function abs_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = abs(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function abs_sfp32 -end program test + integer function abs_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = abs(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction abs_sfp32 +endprogram test diff --git a/test/abs_sfp64.f90 b/test/abs_sfp64.f90 index f7fc63d..4b32e7a 100644 --- a/test/abs_sfp64.f90 +++ b/test/abs_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = abs_sfp64() - stop exit_code + exit_code = abs_sfp64() + stop exit_code contains - integer function abs_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = abs( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = abs(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function abs_sfp64 -end program test + integer function abs_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = abs( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = abs(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction abs_sfp64 +endprogram test diff --git a/test/acos_r1fp32.f90 b/test/acos_r1fp32.f90 index 5dfca59..31a2453 100644 --- a/test/acos_r1fp32.f90 +++ b/test/acos_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = acos_r1fp32() - stop exit_code + exit_code = acos_r1fp32() + stop exit_code contains - integer function acos_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = acos(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function acos_r1fp32 -end program test + integer function acos_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = acos(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction acos_r1fp32 +endprogram test diff --git a/test/acos_r1fp64.f90 b/test/acos_r1fp64.f90 index a61633b..47479a9 100644 --- a/test/acos_r1fp64.f90 +++ b/test/acos_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = acos_r1fp64() - stop exit_code + exit_code = acos_r1fp64() + stop exit_code contains - integer function acos_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = acos(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function acos_r1fp64 -end program test + integer function acos_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = acos(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction acos_r1fp64 +endprogram test diff --git a/test/acos_r2fp32.f90 b/test/acos_r2fp32.f90 index 97c8f21..dfa2eac 100644 --- a/test/acos_r2fp32.f90 +++ b/test/acos_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = acos_r2fp32() - stop exit_code + exit_code = acos_r2fp32() + stop exit_code contains - integer function acos_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = acos(x(i, j, 1)) * acos(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function acos_r2fp32 -end program test + integer function acos_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = acos(x(i,j,1))*acos(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction acos_r2fp32 +endprogram test diff --git a/test/acos_r2fp64.f90 b/test/acos_r2fp64.f90 index 5f427cc..effa481 100644 --- a/test/acos_r2fp64.f90 +++ b/test/acos_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = acos_r2fp64() - stop exit_code + exit_code = acos_r2fp64() + stop exit_code contains - integer function acos_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = acos(x(i, j, 1)) * acos(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function acos_r2fp64 -end program test + integer function acos_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = acos(x(i,j,1))*acos(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction acos_r2fp64 +endprogram test diff --git a/test/acos_r3fp32.f90 b/test/acos_r3fp32.f90 index fd57702..31ff441 100644 --- a/test/acos_r3fp32.f90 +++ b/test/acos_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = acos_r3fp32() - stop exit_code + exit_code = acos_r3fp32() + stop exit_code contains - integer function acos_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function acos_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )*acos( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )*acos( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = acos(x(i, j, k, 1)) * acos(x(i, j, k, 2)) * acos(x(i, j, k, 3)) - end do - end do - end do + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = acos(x(i,j,k,1))*acos(x(i,j,k,2))*acos(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function acos_r3fp32 -end program test + endfunction acos_r3fp32 +endprogram test diff --git a/test/acos_r3fp64.f90 b/test/acos_r3fp64.f90 index 2c13700..ea6c9dd 100644 --- a/test/acos_r3fp64.f90 +++ b/test/acos_r3fp64.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = acos_r3fp64() - stop exit_code + exit_code = acos_r3fp64() + stop exit_code contains - integer function acos_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function acos_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )*acos( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )*acos( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = acos(x(i, j, k, 1)) * acos(x(i, j, k, 2)) * acos(x(i, j, k, 3)) - end do - end do - end do + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = acos(x(i,j,k,1))*acos(x(i,j,k,2))*acos(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function acos_r3fp64 -end program test + endfunction acos_r3fp64 +endprogram test diff --git a/test/acos_r4fp32.f90 b/test/acos_r4fp32.f90 index 1dfc66c..e1723c6 100644 --- a/test/acos_r4fp32.f90 +++ b/test/acos_r4fp32.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = acos_r4fp32() - stop exit_code + exit_code = acos_r4fp32() + stop exit_code contains - integer function acos_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:4) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function acos_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:4) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:4), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:4), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z', 't'/) + ! Specify the independent variables + independentVars = (/'x','y','z','t'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )*acos( z )*acos( t )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )*acos( z )*acos( t )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - x(i, j, k, l, 4) = -1.0_real32 + (2.0_real32) / real(M, real32) * real(l - 1, real32) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + x(i,j,k,l,4) = -1.0_real32+(2.0_real32)/real(M,real32)*real(l-1,real32) + enddo + enddo + enddo + enddo - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = acos(x(i, j, k, l, 1)) * acos(x(i, j, k, l, 2)) * acos(x(i, j, k, l, 3)) * acos(x(i, j, k, l, 4)) - end do - end do - end do - end do + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = acos(x(i,j,k,l,1))*acos(x(i,j,k,l,2))*acos(x(i,j,k,l,3))*acos(x(i,j,k,l,4)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - print*,maxval(abs(feval - fexact)), maxval(abs(fexact)) * epsilon(1.0_real32) - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + print*,maxval(abs(feval-fexact)),maxval(abs(fexact))*epsilon(1.0_real32) + r = 1 + endif - deallocate (x, feval, fexact) - end function acos_r4fp32 -end program test + deallocate(x,feval,fexact) + endfunction acos_r4fp32 +endprogram test diff --git a/test/acos_r4fp64.f90 b/test/acos_r4fp64.f90 index 4b28994..c4d00dc 100644 --- a/test/acos_r4fp64.f90 +++ b/test/acos_r4fp64.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = acos_r4fp64() - stop exit_code + exit_code = acos_r4fp64() + stop exit_code contains - integer function acos_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:4) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function acos_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:4) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:4), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:4), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z', 't'/) + ! Specify the independent variables + independentVars = (/'x','y','z','t'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )*acos( y )*acos( z )*acos( t )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )*acos( y )*acos( z )*acos( t )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - x(i, j, k, l, 4) = -1.0_real64 + (2.0_real64) / real(M, real64) * real(l - 1, real64) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + x(i,j,k,l,4) = -1.0_real64+(2.0_real64)/real(M,real64)*real(l-1,real64) + enddo + enddo + enddo + enddo - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = acos(x(i, j, k, l, 1)) * acos(x(i, j, k, l, 2)) * acos(x(i, j, k, l, 3)) * acos(x(i, j, k, l, 4)) - end do - end do - end do - end do + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = acos(x(i,j,k,l,1))*acos(x(i,j,k,l,2))*acos(x(i,j,k,l,3))*acos(x(i,j,k,l,4)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) - end function acos_r4fp64 -end program test + deallocate(x,feval,fexact) + endfunction acos_r4fp64 +endprogram test diff --git a/test/acos_sfp32.f90 b/test/acos_sfp32.f90 index 80d81d2..31a1376 100644 --- a/test/acos_sfp32.f90 +++ b/test/acos_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = acos_sfp32() - stop exit_code + exit_code = acos_sfp32() + stop exit_code contains - integer function acos_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = acos(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function acos_sfp32 -end program test + integer function acos_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = acos(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction acos_sfp32 +endprogram test diff --git a/test/acos_sfp64.f90 b/test/acos_sfp64.f90 index e2344cd..4dd2d12 100644 --- a/test/acos_sfp64.f90 +++ b/test/acos_sfp64.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = acos_sfp64() - stop exit_code + exit_code = acos_sfp64() + stop exit_code contains - integer function acos_sfp64() result(r) - ! WARNING - acos(x) accurate only to single precision with gfortran 11.4.0 - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = acos( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = acos(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function acos_sfp64 -end program test + integer function acos_sfp64() result(r) + ! WARNING - acos(x) accurate only to single precision with gfortran 11.4.0 + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = acos( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = acos(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction acos_sfp64 +endprogram test diff --git a/test/asin_r1fp32.f90 b/test/asin_r1fp32.f90 index 000ee22..fb48fd8 100644 --- a/test/asin_r1fp32.f90 +++ b/test/asin_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = asin_r1fp32() - stop exit_code + exit_code = asin_r1fp32() + stop exit_code contains - integer function asin_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = asin(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function asin_r1fp32 -end program test + integer function asin_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = asin(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction asin_r1fp32 +endprogram test diff --git a/test/asin_r1fp64.f90 b/test/asin_r1fp64.f90 index a4edda5..401c9bc 100644 --- a/test/asin_r1fp64.f90 +++ b/test/asin_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = asin_r1fp64() - stop exit_code + exit_code = asin_r1fp64() + stop exit_code contains - integer function asin_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = asin(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function asin_r1fp64 -end program test + integer function asin_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = asin(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction asin_r1fp64 +endprogram test diff --git a/test/asin_r2fp32.f90 b/test/asin_r2fp32.f90 index 6b54d3f..3050a55 100644 --- a/test/asin_r2fp32.f90 +++ b/test/asin_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = asin_r2fp32() - stop exit_code + exit_code = asin_r2fp32() + stop exit_code contains - integer function asin_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = asin(x(i, j, 1)) * asin(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function asin_r2fp32 -end program test + integer function asin_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = asin(x(i,j,1))*asin(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction asin_r2fp32 +endprogram test diff --git a/test/asin_r2fp64.f90 b/test/asin_r2fp64.f90 index 885e48f..5528b07 100644 --- a/test/asin_r2fp64.f90 +++ b/test/asin_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = asin_r2fp64() - stop exit_code + exit_code = asin_r2fp64() + stop exit_code contains - integer function asin_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = asin(x(i, j, 1)) * asin(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function asin_r2fp64 -end program test + integer function asin_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = asin(x(i,j,1))*asin(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction asin_r2fp64 +endprogram test diff --git a/test/asin_r3fp32.f90 b/test/asin_r3fp32.f90 index 74a746e..ad8a36e 100644 --- a/test/asin_r3fp32.f90 +++ b/test/asin_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = asin_r3fp32() - stop exit_code + exit_code = asin_r3fp32() + stop exit_code contains - integer function asin_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function asin_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )*asin( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )*asin( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = asin(x(i, j, k, 1)) * asin(x(i, j, k, 2)) * asin(x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = asin(x(i,j,k,1))*asin(x(i,j,k,2))*asin(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function asin_r3fp32 -end program test + endfunction asin_r3fp32 +endprogram test diff --git a/test/asin_r3fp64.f90 b/test/asin_r3fp64.f90 index 7093030..24f03f8 100644 --- a/test/asin_r3fp64.f90 +++ b/test/asin_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = asin_r3fp64() - stop exit_code + exit_code = asin_r3fp64() + stop exit_code contains - integer function asin_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function asin_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )*asin( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )*asin( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = asin(x(i, j, k, 1)) * asin(x(i, j, k, 2)) * asin(x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = asin(x(i,j,k,1))*asin(x(i,j,k,2))*asin(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function asin_r3fp64 -end program test + endfunction asin_r3fp64 +endprogram test diff --git a/test/asin_r4fp32.f90 b/test/asin_r4fp32.f90 index 624be4c..a384421 100644 --- a/test/asin_r4fp32.f90 +++ b/test/asin_r4fp32.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = asin_r4fp32() - stop exit_code + exit_code = asin_r4fp32() + stop exit_code contains - integer function asin_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:4) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function asin_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:4) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:4), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:4), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z', 't'/) + ! Specify the independent variables + independentVars = (/'x','y','z','t'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )*asin( z )*asin( t )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )*asin( z )*asin( t )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - x(i, j, k, l, 4) = -1.0_real32 + (2.0_real32) / real(M, real32) * real(l - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = asin(x(i, j, k, l, 1)) * asin(x(i, j, k, l, 2)) * asin(x(i, j, k, l, 3)) * asin(x(i, j, k, l, 4)) - end do - end do - end do - end do - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - print*,maxval(abs(feval - fexact)), maxval(abs(fexact)) * epsilon(1.0_real32) - r = 1 - end if + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + x(i,j,k,l,4) = -1.0_real32+(2.0_real32)/real(M,real32)*real(l-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = asin(x(i,j,k,l,1))*asin(x(i,j,k,l,2))*asin(x(i,j,k,l,3))*asin(x(i,j,k,l,4)) + enddo + enddo + enddo + enddo + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + print*,maxval(abs(feval-fexact)),maxval(abs(fexact))*epsilon(1.0_real32) + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function asin_r4fp32 -end program test + endfunction asin_r4fp32 +endprogram test diff --git a/test/asin_r4fp64.f90 b/test/asin_r4fp64.f90 index f46ad52..bd3141c 100644 --- a/test/asin_r4fp64.f90 +++ b/test/asin_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = asin_r4fp64() - stop exit_code + exit_code = asin_r4fp64() + stop exit_code contains - integer function asin_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:4) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function asin_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:4) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:4), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:4), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z', 't'/) + ! Specify the independent variables + independentVars = (/'x','y','z','t'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )*asin( y )*asin( z )*asin( t )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )*asin( y )*asin( z )*asin( t )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - x(i, j, k, l, 4) = -1.0_real64 + (2.0_real64) / real(M, real64) * real(l - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = asin(x(i, j, k, l, 1)) * asin(x(i, j, k, l, 2)) * asin(x(i, j, k, l, 3)) * asin(x(i, j, k, l, 4)) - end do - end do - end do - end do - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + x(i,j,k,l,4) = -1.0_real64+(2.0_real64)/real(M,real64)*real(l-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = asin(x(i,j,k,l,1))*asin(x(i,j,k,l,2))*asin(x(i,j,k,l,3))*asin(x(i,j,k,l,4)) + enddo + enddo + enddo + enddo + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function asin_r4fp64 -end program test + endfunction asin_r4fp64 +endprogram test diff --git a/test/asin_sfp32.f90 b/test/asin_sfp32.f90 index 4d30f3a..8dffcc1 100644 --- a/test/asin_sfp32.f90 +++ b/test/asin_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = asin_sfp32() - stop exit_code + exit_code = asin_sfp32() + stop exit_code contains - integer function asin_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = asin(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function asin_sfp32 -end program test + integer function asin_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = asin(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction asin_sfp32 +endprogram test diff --git a/test/asin_sfp64.f90 b/test/asin_sfp64.f90 index bceecd4..905aefe 100644 --- a/test/asin_sfp64.f90 +++ b/test/asin_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = asin_sfp64() - stop exit_code + exit_code = asin_sfp64() + stop exit_code contains - integer function asin_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = asin( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = asin(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function asin_sfp64 -end program test + integer function asin_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = asin( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = asin(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction asin_sfp64 +endprogram test diff --git a/test/atan_r1fp32.f90 b/test/atan_r1fp32.f90 index ea5df77..2229f54 100644 --- a/test/atan_r1fp32.f90 +++ b/test/atan_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = atan_r1fp32() - stop exit_code + exit_code = atan_r1fp32() + stop exit_code contains - integer function atan_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = atan(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function atan_r1fp32 -end program test + integer function atan_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = atan(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction atan_r1fp32 +endprogram test diff --git a/test/atan_r1fp64.f90 b/test/atan_r1fp64.f90 index faf4c42..a4f9588 100644 --- a/test/atan_r1fp64.f90 +++ b/test/atan_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = atan_r1fp64() - stop exit_code + exit_code = atan_r1fp64() + stop exit_code contains - integer function atan_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = atan(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function atan_r1fp64 -end program test + integer function atan_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = atan(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction atan_r1fp64 +endprogram test diff --git a/test/atan_r2fp32.f90 b/test/atan_r2fp32.f90 index b20042e..4520eff 100644 --- a/test/atan_r2fp32.f90 +++ b/test/atan_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = atan_r2fp32() - stop exit_code + exit_code = atan_r2fp32() + stop exit_code contains - integer function atan_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = atan(x(i, j, 1)) * atan(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function atan_r2fp32 -end program test + integer function atan_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = atan(x(i,j,1))*atan(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction atan_r2fp32 +endprogram test diff --git a/test/atan_r2fp64.f90 b/test/atan_r2fp64.f90 index 01a90f8..fd217ab 100644 --- a/test/atan_r2fp64.f90 +++ b/test/atan_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = atan_r2fp64() - stop exit_code + exit_code = atan_r2fp64() + stop exit_code contains - integer function atan_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = atan(x(i, j, 1)) * atan(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function atan_r2fp64 -end program test + integer function atan_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = atan(x(i,j,1))*atan(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction atan_r2fp64 +endprogram test diff --git a/test/atan_r3fp32.f90 b/test/atan_r3fp32.f90 index 8ed679f..8dad2be 100644 --- a/test/atan_r3fp32.f90 +++ b/test/atan_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = atan_r3fp32() - stop exit_code + exit_code = atan_r3fp32() + stop exit_code contains - integer function atan_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function atan_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )*atan( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )*atan( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = atan(x(i, j, k, 1)) * atan(x(i, j, k, 2)) * atan(x(i, j, k, 3)) - end do - end do - end do + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = atan(x(i,j,k,1))*atan(x(i,j,k,2))*atan(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function atan_r3fp32 -end program test + endfunction atan_r3fp32 +endprogram test diff --git a/test/atan_r3fp64.f90 b/test/atan_r3fp64.f90 index 0ed42c9..6c29bf4 100644 --- a/test/atan_r3fp64.f90 +++ b/test/atan_r3fp64.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = atan_r3fp64() - stop exit_code + exit_code = atan_r3fp64() + stop exit_code contains - integer function atan_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function atan_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )*atan( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )*atan( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = atan(x(i, j, k, 1)) * atan(x(i, j, k, 2)) * atan(x(i, j, k, 3)) - end do - end do - end do + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = atan(x(i,j,k,1))*atan(x(i,j,k,2))*atan(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real32) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function atan_r3fp64 -end program test + endfunction atan_r3fp64 +endprogram test diff --git a/test/atan_r4fp32.f90 b/test/atan_r4fp32.f90 index 25672b9..8054de4 100644 --- a/test/atan_r4fp32.f90 +++ b/test/atan_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = atan_r4fp32() - stop exit_code + exit_code = atan_r4fp32() + stop exit_code contains - integer function atan_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function atan_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )*atan( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )*atan( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = atan(x(i, j, k, l, 1)) * atan(x(i, j, k, l, 2)) * atan(x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = atan(x(i,j,k,l,1))*atan(x(i,j,k,l,2))*atan(x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function atan_r4fp32 -end program test + endfunction atan_r4fp32 +endprogram test diff --git a/test/atan_r4fp64.f90 b/test/atan_r4fp64.f90 index a908604..872780e 100644 --- a/test/atan_r4fp64.f90 +++ b/test/atan_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = atan_r4fp64() - stop exit_code + exit_code = atan_r4fp64() + stop exit_code contains - integer function atan_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function atan_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )*atan( y )*atan( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )*atan( y )*atan( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = atan(x(i, j, k, l, 1)) * atan(x(i, j, k, l, 2)) * atan(x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = atan(x(i,j,k,l,1))*atan(x(i,j,k,l,2))*atan(x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function atan_r4fp64 -end program test + endfunction atan_r4fp64 +endprogram test diff --git a/test/atan_sfp32.f90 b/test/atan_sfp32.f90 index 77e54c6..f845dde 100644 --- a/test/atan_sfp32.f90 +++ b/test/atan_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = atan_sfp32() - stop exit_code + exit_code = atan_sfp32() + stop exit_code contains - integer function atan_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = atan(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function atan_sfp32 -end program test + integer function atan_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = atan(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction atan_sfp32 +endprogram test diff --git a/test/atan_sfp64.f90 b/test/atan_sfp64.f90 index 0d43baa..04fc3ac 100644 --- a/test/atan_sfp64.f90 +++ b/test/atan_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = atan_sfp64() - stop exit_code + exit_code = atan_sfp64() + stop exit_code contains - integer function atan_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = atan( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = atan(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function atan_sfp64 -end program test + integer function atan_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = atan( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = atan(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction atan_sfp64 +endprogram test diff --git a/test/cos_r1fp32.f90 b/test/cos_r1fp32.f90 index b25e186..4fe1d59 100644 --- a/test/cos_r1fp32.f90 +++ b/test/cos_r1fp32.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = cos_r1fp32() - stop exit_code + exit_code = cos_r1fp32() + stop exit_code contains - integer function cos_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = cos(2.0_real32 * pi * x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function cos_r1fp32 -end program test + integer function cos_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = cos(2.0_real32*pi*x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction cos_r1fp32 +endprogram test diff --git a/test/cos_r1fp64.f90 b/test/cos_r1fp64.f90 index da766e0..1a11224 100644 --- a/test/cos_r1fp64.f90 +++ b/test/cos_r1fp64.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = cos_r1fp64() - stop exit_code + exit_code = cos_r1fp64() + stop exit_code contains - integer function cos_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = cos(2.0_real64 * pi * x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function cos_r1fp64 -end program test + integer function cos_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = cos(2.0_real64*pi*x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction cos_r1fp64 +endprogram test diff --git a/test/cos_r2fp32.f90 b/test/cos_r2fp32.f90 index ee2d4f2..19d4da2 100644 --- a/test/cos_r2fp32.f90 +++ b/test/cos_r2fp32.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = cos_r2fp32() - stop exit_code + exit_code = cos_r2fp32() + stop exit_code contains - integer function cos_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = cos(2.0_real32 * pi * x(i, j, 1)) * cos(2.0_real32 * pi * x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function cos_r2fp32 -end program test + integer function cos_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = cos(2.0_real32*pi*x(i,j,1))*cos(2.0_real32*pi*x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction cos_r2fp32 +endprogram test diff --git a/test/cos_r2fp64.f90 b/test/cos_r2fp64.f90 index 0f308fc..84ff2fd 100644 --- a/test/cos_r2fp64.f90 +++ b/test/cos_r2fp64.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = cos_r2fp64() - stop exit_code + exit_code = cos_r2fp64() + stop exit_code contains - integer function cos_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = cos(2.0_real32 * pi * x(i, j, 1)) * cos(2.0_real32 * pi * x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function cos_r2fp64 -end program test + integer function cos_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = cos(2.0_real32*pi*x(i,j,1))*cos(2.0_real32*pi*x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction cos_r2fp64 +endprogram test diff --git a/test/cos_r3fp32.f90 b/test/cos_r3fp32.f90 index 22f9343..6fb3139 100644 --- a/test/cos_r3fp32.f90 +++ b/test/cos_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = cos_r3fp32() - stop exit_code + exit_code = cos_r3fp32() + stop exit_code contains - integer function cos_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function cos_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = cos(2.0_real32 * pi * x(i, j, k, 1)) * cos(2.0_real32 * pi * x(i, j, k, 2)) * cos(2.0_real32 * pi * x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = cos(2.0_real32*pi*x(i,j,k,1))*cos(2.0_real32*pi*x(i,j,k,2))*cos(2.0_real32*pi*x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function cos_r3fp32 -end program test + endfunction cos_r3fp32 +endprogram test diff --git a/test/cos_r3fp64.f90 b/test/cos_r3fp64.f90 index 2a20f37..dd1c14c 100644 --- a/test/cos_r3fp64.f90 +++ b/test/cos_r3fp64.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = cos_r3fp64() - stop exit_code + exit_code = cos_r3fp64() + stop exit_code contains - integer function cos_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function cos_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = cos(2.0_real64 * pi * x(i, j, k, 1)) * cos(2.0_real64 * pi * x(i, j, k, 2)) * cos(2.0_real64 * pi * x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = cos(2.0_real64*pi*x(i,j,k,1))*cos(2.0_real64*pi*x(i,j,k,2))*cos(2.0_real64*pi*x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function cos_r3fp64 -end program test + endfunction cos_r3fp64 +endprogram test diff --git a/test/cos_r4fp32.f90 b/test/cos_r4fp32.f90 index 0ff1484..da73390 100644 --- a/test/cos_r4fp32.f90 +++ b/test/cos_r4fp32.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = cos_r4fp32() - stop exit_code + exit_code = cos_r4fp32() + stop exit_code contains - integer function cos_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function cos_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = cos(2.0_real32 * pi * x(i, j, k, l, 1)) * cos(2.0_real32 * pi * x(i, j, k, l, 2)) * cos(2.0_real32 * pi * x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = cos(2.0_real32*pi*x(i,j,k,l,1))*cos(2.0_real32*pi*x(i,j,k,l,2))*cos(2.0_real32*pi*x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function cos_r4fp32 -end program test + endfunction cos_r4fp32 +endprogram test diff --git a/test/cos_r4fp64.f90 b/test/cos_r4fp64.f90 index 3bf5e15..8ab6fb2 100644 --- a/test/cos_r4fp64.f90 +++ b/test/cos_r4fp64.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = cos_r4fp64() - stop exit_code + exit_code = cos_r4fp64() + stop exit_code contains - integer function cos_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function cos_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )*cos( 2.0*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = cos(2.0_real64 * pi * x(i, j, k, l, 1)) * cos(2.0_real64 * pi * x(i, j, k, l, 2)) * cos(2.0_real64 * pi * x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = cos(2.0_real64*pi*x(i,j,k,l,1))*cos(2.0_real64*pi*x(i,j,k,l,2))*cos(2.0_real64*pi*x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function cos_r4fp64 -end program test + endfunction cos_r4fp64 +endprogram test diff --git a/test/cos_sfp32.f90 b/test/cos_sfp32.f90 index 9987845..7d0e561 100644 --- a/test/cos_sfp32.f90 +++ b/test/cos_sfp32.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = cos_sfp32() - stop exit_code + exit_code = cos_sfp32() + stop exit_code contains - integer function cos_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = cos(2.0_real32 * pi * x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function cos_sfp32 -end program test + integer function cos_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = cos(2.0_real32*pi*x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction cos_sfp32 +endprogram test diff --git a/test/cos_sfp64.f90 b/test/cos_sfp64.f90 index e4bad1c..6a459d1 100644 --- a/test/cos_sfp64.f90 +++ b/test/cos_sfp64.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = cos_sfp64() - stop exit_code + exit_code = cos_sfp64() + stop exit_code contains - integer function cos_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = cos( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = cos(2.0_real64 * pi * x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function cos_sfp64 -end program test + integer function cos_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = cos( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = cos(2.0_real64*pi*x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction cos_sfp64 +endprogram test diff --git a/test/custom_r1fp64.f90 b/test/custom_r1fp64.f90 index a1d1122..3a2a350 100644 --- a/test/custom_r1fp64.f90 +++ b/test/custom_r1fp64.f90 @@ -1,34 +1,33 @@ program test - use iso_fortran_env, only: i1 => int8, i2 => int16, i4 => int32, i8 => int64, & - r4 => real32, r8 => real64, r16 => real128 - use FEQParse + use iso_fortran_env,only:i1 => int8,i2 => int16,i4 => int32,i8 => int64, & + r4 => real32,r8 => real64,r16 => real128 + use FEQParse - implicit none + implicit none - write (*, '(A,I20)') "test ", testing() + write(*,'(A,I20)') "test ",testing() contains - integer function testing() result(r) - !private - type(EquationParser) :: f - real(r8) :: feval - type(FEQParse_Function) :: func - - call AddFunction("myfunc", myfunc64) - - f = EquationParser("MYFUNC(x)", ["x"]) - - feval = f%evaluate([1.0_r8]) - if ((abs(feval - 0.5_r8)) <= epsilon(1.0_r8)) then - r = 0 - else - r = 1 - end if - end function - - pure real(r8) function myfunc64(x) - real(r8), intent(in) :: x - myfunc64 = x / 2.0_r8 - end function -end program + integer function testing() result(r) + !private + type(EquationParser) :: f + real(r8) :: feval + + call AddFunction("myfunc",myfunc64) + + f = EquationParser("MYFUNC(x)",["x"]) + + feval = f%evaluate([1.0_r8]) + if((abs(feval-0.5_r8)) <= epsilon(1.0_r8)) then + r = 0 + else + r = 1 + endif + endfunction + + pure real(r8) function myfunc64(x) + real(r8),intent(in) :: x + myfunc64 = x/2.0_r8 + endfunction +endprogram diff --git a/test/division_r1fp32.f90 b/test/division_r1fp32.f90 index 0249530..18a1fd1 100644 --- a/test/division_r1fp32.f90 +++ b/test/division_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = division_r1fp32() - stop exit_code + exit_code = division_r1fp32() + stop exit_code contains - integer function division_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -x/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = -x(i, 1) / 10.0_real32 - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function division_r1fp32 -end program test + integer function division_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -x/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = -x(i,1)/10.0_real32 + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction division_r1fp32 +endprogram test diff --git a/test/division_r1fp64.f90 b/test/division_r1fp64.f90 index 3389d0f..d8ffe22 100644 --- a/test/division_r1fp64.f90 +++ b/test/division_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = division_r1fp64() - stop exit_code + exit_code = division_r1fp64() + stop exit_code contains - integer function division_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -x/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = -x(i, 1) / 10.0_real64 - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function division_r1fp64 -end program test + integer function division_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -x/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = -x(i,1)/10.0_real64 + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction division_r1fp64 +endprogram test diff --git a/test/division_r2fp32.f90 b/test/division_r2fp32.f90 index a633065..fc90dbf 100644 --- a/test/division_r2fp32.f90 +++ b/test/division_r2fp32.f90 @@ -1,59 +1,59 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = division_r2fp32() - stop exit_code + exit_code = division_r2fp32() + stop exit_code contains - integer function division_r2fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = -(x(i, j, 1) + 1.0_real32) * (x(i, j, 2) + 1.0_real32) / 10.0_real32 - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real32 * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function division_r2fp32 -end program test + integer function division_r2fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = -(x(i,j,1)+1.0_real32)*(x(i,j,2)+1.0_real32)/10.0_real32 + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= 10.0_real32*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction division_r2fp32 +endprogram test diff --git a/test/division_r2fp64.f90 b/test/division_r2fp64.f90 index e595c6e..7a3b441 100644 --- a/test/division_r2fp64.f90 +++ b/test/division_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = division_r2fp64() - stop exit_code + exit_code = division_r2fp64() + stop exit_code contains - integer function division_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = -(x(i, j, 1) + 1.0_real64) * (x(i, j, 2) + 1.0_real64) / 10.0_real64 - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function division_r2fp64 -end program test + integer function division_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = -(x(i,j,1)+1.0_real64)*(x(i,j,2)+1.0_real64)/10.0_real64 + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction division_r2fp64 +endprogram test diff --git a/test/division_r3fp32.f90 b/test/division_r3fp32.f90 index 1baaa11..96d4a79 100644 --- a/test/division_r3fp32.f90 +++ b/test/division_r3fp32.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = division_r3fp32() - stop exit_code + exit_code = division_r3fp32() + stop exit_code contains - integer function division_r3fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function division_r3fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = -(x(i, j, k, 1) + 1.0_real32) * (x(i, j, k, 2) + 1.0_real32) * (x(i, j, k, 3) + 1.0_real32) / 10.0_real32 - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = -(x(i,j,k,1)+1.0_real32)*(x(i,j,k,2)+1.0_real32)*(x(i,j,k,3)+1.0_real32)/10.0_real32 + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function division_r3fp32 -end program test + endfunction division_r3fp32 +endprogram test diff --git a/test/division_r3fp64.f90 b/test/division_r3fp64.f90 index 2d3d70b..1eefb47 100644 --- a/test/division_r3fp64.f90 +++ b/test/division_r3fp64.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = division_r3fp64() - stop exit_code + exit_code = division_r3fp64() + stop exit_code contains - integer function division_r3fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function division_r3fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = -(x(i, j, k, 1) + 1.0_real64) * (x(i, j, k, 2) + 1.0_real64) * (x(i, j, k, 3) + 1.0_real64) / 10.0_real64 - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = -(x(i,j,k,1)+1.0_real64)*(x(i,j,k,2)+1.0_real64)*(x(i,j,k,3)+1.0_real64)/10.0_real64 + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function division_r3fp64 -end program test + endfunction division_r3fp64 +endprogram test diff --git a/test/division_r4fp32.f90 b/test/division_r4fp32.f90 index 22a48c8..8927a4f 100644 --- a/test/division_r4fp32.f90 +++ b/test/division_r4fp32.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = division_r4fp32() - stop exit_code + exit_code = division_r4fp32() + stop exit_code contains - integer function division_r4fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function division_r4fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = -(x(i, j, k, l, 1) + 1.0_real32) * (x(i, j, k, l, 2) + 1.0_real32) * (x(i, j, k, l, 3) + 1.0_real32) / 10.0_real32 - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = -(x(i,j,k,l,1)+1.0_real32)*(x(i,j,k,l,2)+1.0_real32)*(x(i,j,k,l,3)+1.0_real32)/10.0_real32 + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function division_r4fp32 -end program test + endfunction division_r4fp32 +endprogram test diff --git a/test/division_r4fp64.f90 b/test/division_r4fp64.f90 index b94ae27..1b1a535 100644 --- a/test/division_r4fp64.f90 +++ b/test/division_r4fp64.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = division_r4fp64() - stop exit_code + exit_code = division_r4fp64() + stop exit_code contains - integer function division_r4fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function division_r4fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)/10.0' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = -(x(i, j, k, l, 1) + 1.0_real64) * (x(i, j, k, l, 2) + 1.0_real64) * (x(i, j, k, l, 3) + 1.0_real64) / 10.0_real64 - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = -(x(i,j,k,l,1)+1.0_real64)*(x(i,j,k,l,2)+1.0_real64)*(x(i,j,k,l,3)+1.0_real64)/10.0_real64 + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function division_r4fp64 -end program test + endfunction division_r4fp64 +endprogram test diff --git a/test/division_sfp32.f90 b/test/division_sfp32.f90 index 86db1ff..cc93daa 100644 --- a/test/division_sfp32.f90 +++ b/test/division_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = division_sfp32() - stop exit_code + exit_code = division_sfp32() + stop exit_code contains - integer function division_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -x/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = -x(1) / 10.0_real32 - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function division_sfp32 -end program test + integer function division_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -x/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = -x(1)/10.0_real32 + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction division_sfp32 +endprogram test diff --git a/test/division_sfp64.f90 b/test/division_sfp64.f90 index 506d669..e486a68 100644 --- a/test/division_sfp64.f90 +++ b/test/division_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = division_sfp64() - stop exit_code + exit_code = division_sfp64() + stop exit_code contains - integer function division_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -x/10.0' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = -x(1) / 10.0_real64 - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function division_sfp64 -end program test + integer function division_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -x/10.0' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = -x(1)/10.0_real64 + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction division_sfp64 +endprogram test diff --git a/test/gaussian3d_r1fp32.f90 b/test/gaussian3d_r1fp32.f90 index c1c93be..a718015 100644 --- a/test/gaussian3d_r1fp32.f90 +++ b/test/gaussian3d_r1fp32.f90 @@ -1,50 +1,50 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = gaussian3d_r1fp32() - stop exit_code + exit_code = gaussian3d_r1fp32() + stop exit_code contains - integer function gaussian3d_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = exp(-(x(i, 1)**2 + x(i, 2)**2 + x(i, 3)**2)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function gaussian3d_r1fp32 -end program test + integer function gaussian3d_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = exp(-(x(i,1)**2+x(i,2)**2+x(i,3)**2)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction gaussian3d_r1fp32 +endprogram test diff --git a/test/gaussian3d_r1fp64.f90 b/test/gaussian3d_r1fp64.f90 index a48c90c..fdc0fce 100644 --- a/test/gaussian3d_r1fp64.f90 +++ b/test/gaussian3d_r1fp64.f90 @@ -1,50 +1,50 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = gaussian3d_r1fp64() - stop exit_code + exit_code = gaussian3d_r1fp64() + stop exit_code contains - integer function gaussian3d_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = exp(-(x(i, 1)**2 + x(i, 2)**2 + x(i, 3)**2)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function gaussian3d_r1fp64 -end program test + integer function gaussian3d_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = exp(-(x(i,1)**2+x(i,2)**2+x(i,3)**2)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction gaussian3d_r1fp64 +endprogram test diff --git a/test/gaussian3d_r2fp32.f90 b/test/gaussian3d_r2fp32.f90 index 86d2a7a..a1473dd 100644 --- a/test/gaussian3d_r2fp32.f90 +++ b/test/gaussian3d_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = gaussian3d_r2fp32() - stop exit_code + exit_code = gaussian3d_r2fp32() + stop exit_code contains - integer function gaussian3d_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2) )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = exp(-(x(i, j, 1)**2 + x(i, j, 2)**2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function gaussian3d_r2fp32 -end program test + integer function gaussian3d_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2) )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = exp(-(x(i,j,1)**2+x(i,j,2)**2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction gaussian3d_r2fp32 +endprogram test diff --git a/test/gaussian3d_r2fp64.f90 b/test/gaussian3d_r2fp64.f90 index a61f787..23668e7 100644 --- a/test/gaussian3d_r2fp64.f90 +++ b/test/gaussian3d_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = gaussian3d_r2fp64() - stop exit_code + exit_code = gaussian3d_r2fp64() + stop exit_code contains - integer function gaussian3d_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2) )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = exp(-(x(i, j, 1)**2 + x(i, j, 2)**2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function gaussian3d_r2fp64 -end program test + integer function gaussian3d_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2) )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = exp(-(x(i,j,1)**2+x(i,j,2)**2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction gaussian3d_r2fp64 +endprogram test diff --git a/test/gaussian3d_r3fp32.f90 b/test/gaussian3d_r3fp32.f90 index 7d008e4..84d7321 100644 --- a/test/gaussian3d_r3fp32.f90 +++ b/test/gaussian3d_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = gaussian3d_r3fp32() - stop exit_code + exit_code = gaussian3d_r3fp32() + stop exit_code contains - integer function gaussian3d_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function gaussian3d_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = exp(-(x(i, j, k, 1)**2 + x(i, j, k, 2)**2 + x(i, j, k, 3)**2)) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = exp(-(x(i,j,k,1)**2+x(i,j,k,2)**2+x(i,j,k,3)**2)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function gaussian3d_r3fp32 -end program test + endfunction gaussian3d_r3fp32 +endprogram test diff --git a/test/gaussian3d_r3fp64.f90 b/test/gaussian3d_r3fp64.f90 index 5446f8c..e077724 100644 --- a/test/gaussian3d_r3fp64.f90 +++ b/test/gaussian3d_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = gaussian3d_r3fp64() - stop exit_code + exit_code = gaussian3d_r3fp64() + stop exit_code contains - integer function gaussian3d_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function gaussian3d_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = exp(-(x(i, j, k, 1)**2 + x(i, j, k, 2)**2 + x(i, j, k, 3)**2)) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = exp(-(x(i,j,k,1)**2+x(i,j,k,2)**2+x(i,j,k,3)**2)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function gaussian3d_r3fp64 -end program test + endfunction gaussian3d_r3fp64 +endprogram test diff --git a/test/gaussian3d_r4fp32.f90 b/test/gaussian3d_r4fp32.f90 index c5d5e49..ed57721 100644 --- a/test/gaussian3d_r4fp32.f90 +++ b/test/gaussian3d_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = gaussian3d_r4fp32() - stop exit_code + exit_code = gaussian3d_r4fp32() + stop exit_code contains - integer function gaussian3d_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function gaussian3d_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = exp(-(x(i, j, k, l, 1)**2 + x(i, j, k, l, 2)**2 + x(i, j, k, l, 3)**2)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = exp(-(x(i,j,k,l,1)**2+x(i,j,k,l,2)**2+x(i,j,k,l,3)**2)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function gaussian3d_r4fp32 -end program test + endfunction gaussian3d_r4fp32 +endprogram test diff --git a/test/gaussian3d_r4fp64.f90 b/test/gaussian3d_r4fp64.f90 index 440083f..b39649d 100644 --- a/test/gaussian3d_r4fp64.f90 +++ b/test/gaussian3d_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = gaussian3d_r4fp64() - stop exit_code + exit_code = gaussian3d_r4fp64() + stop exit_code contains - integer function gaussian3d_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function gaussian3d_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = exp(-(x(i, j, k, l, 1)**2 + x(i, j, k, l, 2)**2 + x(i, j, k, l, 3)**2)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = exp(-(x(i,j,k,l,1)**2+x(i,j,k,l,2)**2+x(i,j,k,l,3)**2)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function gaussian3d_r4fp64 -end program test + endfunction gaussian3d_r4fp64 +endprogram test diff --git a/test/gaussian3d_sfp32.f90 b/test/gaussian3d_sfp32.f90 index c04a0e3..6bb8b78 100644 --- a/test/gaussian3d_sfp32.f90 +++ b/test/gaussian3d_sfp32.f90 @@ -1,39 +1,39 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = gaussian3d_sfp32() - stop exit_code + exit_code = gaussian3d_sfp32() + stop exit_code contains - integer function gaussian3d_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none + integer function gaussian3d_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - ! Evaluate the equation - x = (/0.0, 0.0, 0.0/) - if (abs(f%evaluate(x) - 1.0) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + x = (/0.0,0.0,0.0/) + if(abs(f%evaluate(x)-1.0) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif - end function gaussian3d_sfp32 -end program test + endfunction gaussian3d_sfp32 +endprogram test diff --git a/test/gaussian3d_sfp64.f90 b/test/gaussian3d_sfp64.f90 index a80eacf..4399ad0 100644 --- a/test/gaussian3d_sfp64.f90 +++ b/test/gaussian3d_sfp64.f90 @@ -1,39 +1,39 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = gaussian3d_sfp64() - stop exit_code + exit_code = gaussian3d_sfp64() + stop exit_code contains - integer function gaussian3d_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none + integer function gaussian3d_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - ! Evaluate the equation - x = (/0.0, 0.0, 0.0/) - if (abs(f%evaluate(x) - 1.0) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + x = (/0.0,0.0,0.0/) + if(abs(f%evaluate(x)-1.0) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif - end function gaussian3d_sfp64 -end program test + endfunction gaussian3d_sfp64 +endprogram test diff --git a/test/linear_r1fp32.f90 b/test/linear_r1fp32.f90 index 437aa37..7fe8d65 100644 --- a/test/linear_r1fp32.f90 +++ b/test/linear_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = linear_r1fp32() - stop exit_code + exit_code = linear_r1fp32() + stop exit_code contains - integer function linear_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = x^3-1' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = x(i, 1)**3 - 1.0_real32 - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function linear_r1fp32 -end program test + integer function linear_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = x^3-1' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = x(i,1)**3-1.0_real32 + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction linear_r1fp32 +endprogram test diff --git a/test/linear_r1fp64.f90 b/test/linear_r1fp64.f90 index c2a5eba..21c532e 100644 --- a/test/linear_r1fp64.f90 +++ b/test/linear_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = linear_r1fp64() - stop exit_code + exit_code = linear_r1fp64() + stop exit_code contains - integer function linear_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = x^3-1' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = x(i, 1)**3 - 1.0_real64 - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function linear_r1fp64 -end program test + integer function linear_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = x^3-1' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = x(i,1)**3-1.0_real64 + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction linear_r1fp64 +endprogram test diff --git a/test/linear_r2fp32.f90 b/test/linear_r2fp32.f90 index 507d5f6..ca683e2 100644 --- a/test/linear_r2fp32.f90 +++ b/test/linear_r2fp32.f90 @@ -1,59 +1,59 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = linear_r2fp32() - stop exit_code + exit_code = linear_r2fp32() + stop exit_code contains - integer function linear_r2fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = (x(i, j, 1)**3 - 1.0_real32) * (x(i, j, 2)**3 - 1.0_real32) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real32 * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function linear_r2fp32 -end program test + integer function linear_r2fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = (x(i,j,1)**3-1.0_real32)*(x(i,j,2)**3-1.0_real32) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= 10.0_real32*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction linear_r2fp32 +endprogram test diff --git a/test/linear_r2fp64.f90 b/test/linear_r2fp64.f90 index 1609b80..5277e8d 100644 --- a/test/linear_r2fp64.f90 +++ b/test/linear_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = linear_r2fp64() - stop exit_code + exit_code = linear_r2fp64() + stop exit_code contains - integer function linear_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = (x(i, j, 1)**3 - 1.0_real64) * (x(i, j, 2)**3 - 1.0_real64) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function linear_r2fp64 -end program test + integer function linear_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = (x(i,j,1)**3-1.0_real64)*(x(i,j,2)**3-1.0_real64) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction linear_r2fp64 +endprogram test diff --git a/test/linear_r3fp32.f90 b/test/linear_r3fp32.f90 index 49e710b..1aaf6d0 100644 --- a/test/linear_r3fp32.f90 +++ b/test/linear_r3fp32.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = linear_r3fp32() - stop exit_code + exit_code = linear_r3fp32() + stop exit_code contains - integer function linear_r3fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function linear_r3fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = (x(i, j, k, 1)**3 - 1.0_real32) * (x(i, j, k, 2)**3 - 1.0_real32) * (x(i, j, k, 3)**3 - 1.0_real32) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = (x(i,j,k,1)**3-1.0_real32)*(x(i,j,k,2)**3-1.0_real32)*(x(i,j,k,3)**3-1.0_real32) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function linear_r3fp32 -end program test + endfunction linear_r3fp32 +endprogram test diff --git a/test/linear_r3fp64.f90 b/test/linear_r3fp64.f90 index c6d16e9..d1c5a4d 100644 --- a/test/linear_r3fp64.f90 +++ b/test/linear_r3fp64.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = linear_r3fp64() - stop exit_code + exit_code = linear_r3fp64() + stop exit_code contains - integer function linear_r3fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function linear_r3fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = (x(i, j, k, 1)**3 - 1.0_real64) * (x(i, j, k, 2)**3 - 1.0_real64) * (x(i, j, k, 3)**3 - 1.0_real64) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = (x(i,j,k,1)**3-1.0_real64)*(x(i,j,k,2)**3-1.0_real64)*(x(i,j,k,3)**3-1.0_real64) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function linear_r3fp64 -end program test + endfunction linear_r3fp64 +endprogram test diff --git a/test/linear_r4fp32.f90 b/test/linear_r4fp32.f90 index f431e69..f034295 100644 --- a/test/linear_r4fp32.f90 +++ b/test/linear_r4fp32.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = linear_r4fp32() - stop exit_code + exit_code = linear_r4fp32() + stop exit_code contains - integer function linear_r4fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function linear_r4fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = (x(i, j, k, l, 1)**3 - 1.0_real32) * (x(i, j, k, l, 2)**3 - 1.0_real32) * (x(i, j, k, l, 3)**3 - 1.0_real32) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = (x(i,j,k,l,1)**3-1.0_real32)*(x(i,j,k,l,2)**3-1.0_real32)*(x(i,j,k,l,3)**3-1.0_real32) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function linear_r4fp32 -end program test + endfunction linear_r4fp32 +endprogram test diff --git a/test/linear_r4fp64.f90 b/test/linear_r4fp64.f90 index e41799d..f72a196 100644 --- a/test/linear_r4fp64.f90 +++ b/test/linear_r4fp64.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = linear_r4fp64() - stop exit_code + exit_code = linear_r4fp64() + stop exit_code contains - integer function linear_r4fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function linear_r4fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = (x^3-1)*(y^3-1)*(z^3-1)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = (x(i, j, k, l, 1)**3 - 1.0_real64) * (x(i, j, k, l, 2)**3 - 1.0_real64) * (x(i, j, k, l, 3)**3 - 1.0_real64) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = (x(i,j,k,l,1)**3-1.0_real64)*(x(i,j,k,l,2)**3-1.0_real64)*(x(i,j,k,l,3)**3-1.0_real64) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function linear_r4fp64 -end program test + endfunction linear_r4fp64 +endprogram test diff --git a/test/log10_r1fp32.f90 b/test/log10_r1fp32.f90 index 4ce7551..57c63dc 100644 --- a/test/log10_r1fp32.f90 +++ b/test/log10_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log10_r1fp32() - stop exit_code + exit_code = log10_r1fp32() + stop exit_code contains - integer function log10_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = log10(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function log10_r1fp32 -end program test + integer function log10_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = 1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = log10(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction log10_r1fp32 +endprogram test diff --git a/test/log10_r1fp64.f90 b/test/log10_r1fp64.f90 index cd3df6e..38e49e4 100644 --- a/test/log10_r1fp64.f90 +++ b/test/log10_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log10_r1fp64() - stop exit_code + exit_code = log10_r1fp64() + stop exit_code contains - integer function log10_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = log10(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function log10_r1fp64 -end program test + integer function log10_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = log10(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction log10_r1fp64 +endprogram test diff --git a/test/log10_r2fp32.f90 b/test/log10_r2fp32.f90 index 82dd22a..5d4a4b0 100644 --- a/test/log10_r2fp32.f90 +++ b/test/log10_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log10_r2fp32() - stop exit_code + exit_code = log10_r2fp32() + stop exit_code contains - integer function log10_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10(y)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = log10(x(i, j, 1)) * log10(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function log10_r2fp32 -end program test + integer function log10_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10(y)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = 1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = log10(x(i,j,1))*log10(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction log10_r2fp32 +endprogram test diff --git a/test/log10_r2fp64.f90 b/test/log10_r2fp64.f90 index aea55f2..a81f7cd 100644 --- a/test/log10_r2fp64.f90 +++ b/test/log10_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log10_r2fp64() - stop exit_code + exit_code = log10_r2fp64() + stop exit_code contains - integer function log10_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = log10(x(i, j, 1)) * log10(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function log10_r2fp64 -end program test + integer function log10_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = 1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = log10(x(i,j,1))*log10(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction log10_r2fp64 +endprogram test diff --git a/test/log10_r3fp32.f90 b/test/log10_r3fp32.f90 index 8c7de7b..c76bcb0 100644 --- a/test/log10_r3fp32.f90 +++ b/test/log10_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log10_r3fp32() - stop exit_code + exit_code = log10_r3fp32() + stop exit_code contains - integer function log10_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function log10_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10(y)*log10(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10(y)*log10(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = log10(x(i, j, k, 1)) * log10(x(i, j, k, 2)) * log10(x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = 1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = 1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = 1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = log10(x(i,j,k,1))*log10(x(i,j,k,2))*log10(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function log10_r3fp32 -end program test + endfunction log10_r3fp32 +endprogram test diff --git a/test/log10_r3fp64.f90 b/test/log10_r3fp64.f90 index 19476a6..aaa1594 100644 --- a/test/log10_r3fp64.f90 +++ b/test/log10_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log10_r3fp64() - stop exit_code + exit_code = log10_r3fp64() + stop exit_code contains - integer function log10_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function log10_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10(y)*log10(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10(y)*log10(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = log10(x(i, j, k, 1)) * log10(x(i, j, k, 2)) * log10(x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = 1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = 1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = log10(x(i,j,k,1))*log10(x(i,j,k,2))*log10(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function log10_r3fp64 -end program test + endfunction log10_r3fp64 +endprogram test diff --git a/test/log10_r4fp32.f90 b/test/log10_r4fp32.f90 index b73e44a..2fec4db 100644 --- a/test/log10_r4fp32.f90 +++ b/test/log10_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log10_r4fp32() - stop exit_code + exit_code = log10_r4fp32() + stop exit_code contains - integer function log10_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function log10_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10(y)*log10(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10(y)*log10(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = log10(x(i, j, k, l, 1)) * log10(x(i, j, k, l, 2)) * log10(x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = 1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = 1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = 1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = log10(x(i,j,k,l,1))*log10(x(i,j,k,l,2))*log10(x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function log10_r4fp32 -end program test + endfunction log10_r4fp32 +endprogram test diff --git a/test/log10_r4fp64.f90 b/test/log10_r4fp64.f90 index bbd698e..4a513a8 100644 --- a/test/log10_r4fp64.f90 +++ b/test/log10_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log10_r4fp64() - stop exit_code + exit_code = log10_r4fp64() + stop exit_code contains - integer function log10_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function log10_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )*log10(y)*log10(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )*log10(y)*log10(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = log10(x(i, j, k, l, 1)) * log10(x(i, j, k, l, 2)) * log10(x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = 1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = 1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = log10(x(i,j,k,l,1))*log10(x(i,j,k,l,2))*log10(x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function log10_r4fp64 -end program test + endfunction log10_r4fp64 +endprogram test diff --git a/test/log10_sfp32.f90 b/test/log10_sfp32.f90 index 49c852f..8edf482 100644 --- a/test/log10_sfp32.f90 +++ b/test/log10_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log10_sfp32() - stop exit_code + exit_code = log10_sfp32() + stop exit_code contains - integer function log10_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 10.0_real32 - fexact = log10(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function log10_sfp32 -end program test + integer function log10_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 10.0_real32 + fexact = log10(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction log10_sfp32 +endprogram test diff --git a/test/log10_sfp64.f90 b/test/log10_sfp64.f90 index 305d712..1821615 100644 --- a/test/log10_sfp64.f90 +++ b/test/log10_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log10_sfp64() - stop exit_code + exit_code = log10_sfp64() + stop exit_code contains - integer function log10_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = log10( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 10.0_real64 - fexact = log10(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function log10_sfp64 -end program test + integer function log10_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = log10( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 10.0_real64 + fexact = log10(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction log10_sfp64 +endprogram test diff --git a/test/log_r1fp32.f90 b/test/log_r1fp32.f90 index e8a24da..3d06487 100644 --- a/test/log_r1fp32.f90 +++ b/test/log_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log_r1fp32() - stop exit_code + exit_code = log_r1fp32() + stop exit_code contains - integer function log_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = log(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function log_r1fp32 -end program test + integer function log_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = 1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = log(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction log_r1fp32 +endprogram test diff --git a/test/log_r1fp64.f90 b/test/log_r1fp64.f90 index 003a069..2bd7a14 100644 --- a/test/log_r1fp64.f90 +++ b/test/log_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log_r1fp64() - stop exit_code + exit_code = log_r1fp64() + stop exit_code contains - integer function log_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = log(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function log_r1fp64 -end program test + integer function log_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = log(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction log_r1fp64 +endprogram test diff --git a/test/log_r2fp32.f90 b/test/log_r2fp32.f90 index e307c39..040412f 100644 --- a/test/log_r2fp32.f90 +++ b/test/log_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log_r2fp32() - stop exit_code + exit_code = log_r2fp32() + stop exit_code contains - integer function log_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = log(x(i, j, 1)) * log(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function log_r2fp32 -end program test + integer function log_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = 1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = log(x(i,j,1))*log(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction log_r2fp32 +endprogram test diff --git a/test/log_r2fp64.f90 b/test/log_r2fp64.f90 index b8650db..9406879 100644 --- a/test/log_r2fp64.f90 +++ b/test/log_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log_r2fp64() - stop exit_code + exit_code = log_r2fp64() + stop exit_code contains - integer function log_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = log(x(i, j, 1)) * log(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function log_r2fp64 -end program test + integer function log_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = 1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = log(x(i,j,1))*log(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction log_r2fp64 +endprogram test diff --git a/test/log_r3fp32.f90 b/test/log_r3fp32.f90 index 6ab8828..991bb62 100644 --- a/test/log_r3fp32.f90 +++ b/test/log_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log_r3fp32() - stop exit_code + exit_code = log_r3fp32() + stop exit_code contains - integer function log_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function log_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)*ln(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)*ln(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = log(x(i, j, k, 1)) * log(x(i, j, k, 2)) * log(x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = 1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = 1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = 1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = log(x(i,j,k,1))*log(x(i,j,k,2))*log(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function log_r3fp32 -end program test + endfunction log_r3fp32 +endprogram test diff --git a/test/log_r3fp64.f90 b/test/log_r3fp64.f90 index 99bdd8e..30c49a1 100644 --- a/test/log_r3fp64.f90 +++ b/test/log_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log_r3fp64() - stop exit_code + exit_code = log_r3fp64() + stop exit_code contains - integer function log_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function log_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)*ln(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)*ln(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = log(x(i, j, k, 1)) * log(x(i, j, k, 2)) * log(x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = 1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = 1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = log(x(i,j,k,1))*log(x(i,j,k,2))*log(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function log_r3fp64 -end program test + endfunction log_r3fp64 +endprogram test diff --git a/test/log_r4fp32.f90 b/test/log_r4fp32.f90 index e47b632..ec485b2 100644 --- a/test/log_r4fp32.f90 +++ b/test/log_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log_r4fp32() - stop exit_code + exit_code = log_r4fp32() + stop exit_code contains - integer function log_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function log_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)*ln(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)*ln(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = 1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = log(x(i, j, k, l, 1)) * log(x(i, j, k, l, 2)) * log(x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = 1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = 1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = 1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = log(x(i,j,k,l,1))*log(x(i,j,k,l,2))*log(x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function log_r4fp32 -end program test + endfunction log_r4fp32 +endprogram test diff --git a/test/log_r4fp64.f90 b/test/log_r4fp64.f90 index a055ffa..aa4a373 100644 --- a/test/log_r4fp64.f90 +++ b/test/log_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log_r4fp64() - stop exit_code + exit_code = log_r4fp64() + stop exit_code contains - integer function log_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function log_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )*ln(y)*ln(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )*ln(y)*ln(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = 1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = log(x(i, j, k, l, 1)) * log(x(i, j, k, l, 2)) * log(x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = 1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = 1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = log(x(i,j,k,l,1))*log(x(i,j,k,l,2))*log(x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function log_r4fp64 -end program test + endfunction log_r4fp64 +endprogram test diff --git a/test/log_sfp32.f90 b/test/log_sfp32.f90 index 903e21d..de1fbfe 100644 --- a/test/log_sfp32.f90 +++ b/test/log_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log_sfp32() - stop exit_code + exit_code = log_sfp32() + stop exit_code contains - integer function log_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 1.0_real32 - fexact = log(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function log_sfp32 -end program test + integer function log_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 1.0_real32 + fexact = log(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction log_sfp32 +endprogram test diff --git a/test/log_sfp64.f90 b/test/log_sfp64.f90 index 865c36a..a75d3c2 100644 --- a/test/log_sfp64.f90 +++ b/test/log_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = log_sfp64() - stop exit_code + exit_code = log_sfp64() + stop exit_code contains - integer function log_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = ln( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 1.0_real64 - fexact = log(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function log_sfp64 -end program test + integer function log_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = ln( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 1.0_real64 + fexact = log(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction log_sfp64 +endprogram test diff --git a/test/monadic_r1fp32.f90 b/test/monadic_r1fp32.f90 index ca06d37..e1ef4c0 100644 --- a/test/monadic_r1fp32.f90 +++ b/test/monadic_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = monadic_r1fp32() - stop exit_code + exit_code = monadic_r1fp32() + stop exit_code contains - integer function monadic_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x + 1)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = -x(i, 1) - 1.0_real32 - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function monadic_r1fp32 -end program test + integer function monadic_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x + 1)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = -x(i,1)-1.0_real32 + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction monadic_r1fp32 +endprogram test diff --git a/test/monadic_r1fp64.f90 b/test/monadic_r1fp64.f90 index 5091c83..159f559 100644 --- a/test/monadic_r1fp64.f90 +++ b/test/monadic_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = monadic_r1fp64() - stop exit_code + exit_code = monadic_r1fp64() + stop exit_code contains - integer function monadic_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x + 1)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = -x(i, 1) - 1.0_real64 - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function monadic_r1fp64 -end program test + integer function monadic_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x + 1)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = -x(i,1)-1.0_real64 + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction monadic_r1fp64 +endprogram test diff --git a/test/monadic_r2fp32.f90 b/test/monadic_r2fp32.f90 index 0f10378..de3a2ae 100644 --- a/test/monadic_r2fp32.f90 +++ b/test/monadic_r2fp32.f90 @@ -1,59 +1,59 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = monadic_r2fp32() - stop exit_code + exit_code = monadic_r2fp32() + stop exit_code contains - integer function monadic_r2fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = -(x(i, j, 1) + 1.0_real32) * (x(i, j, 2) + 1.0_real32) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real32 * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function monadic_r2fp32 -end program test + integer function monadic_r2fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = -(x(i,j,1)+1.0_real32)*(x(i,j,2)+1.0_real32) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= 10.0_real32*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction monadic_r2fp32 +endprogram test diff --git a/test/monadic_r2fp64.f90 b/test/monadic_r2fp64.f90 index 134d861..123e415 100644 --- a/test/monadic_r2fp64.f90 +++ b/test/monadic_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = monadic_r2fp64() - stop exit_code + exit_code = monadic_r2fp64() + stop exit_code contains - integer function monadic_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = -(x(i, j, 1) + 1.0_real64) * (x(i, j, 2) + 1.0_real64) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function monadic_r2fp64 -end program test + integer function monadic_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = -(x(i,j,1)+1.0_real64)*(x(i,j,2)+1.0_real64) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction monadic_r2fp64 +endprogram test diff --git a/test/monadic_r3fp32.f90 b/test/monadic_r3fp32.f90 index 3e38a7c..b1fe509 100644 --- a/test/monadic_r3fp32.f90 +++ b/test/monadic_r3fp32.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = monadic_r3fp32() - stop exit_code + exit_code = monadic_r3fp32() + stop exit_code contains - integer function monadic_r3fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function monadic_r3fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = -(x(i, j, k, 1) + 1.0_real32) * (x(i, j, k, 2) + 1.0_real32) * (x(i, j, k, 3) + 1.0_real32) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = -(x(i,j,k,1)+1.0_real32)*(x(i,j,k,2)+1.0_real32)*(x(i,j,k,3)+1.0_real32) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function monadic_r3fp32 -end program test + endfunction monadic_r3fp32 +endprogram test diff --git a/test/monadic_r3fp64.f90 b/test/monadic_r3fp64.f90 index 47dac43..06ebc10 100644 --- a/test/monadic_r3fp64.f90 +++ b/test/monadic_r3fp64.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = monadic_r3fp64() - stop exit_code + exit_code = monadic_r3fp64() + stop exit_code contains - integer function monadic_r3fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function monadic_r3fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = -(x(i, j, k, 1) + 1.0_real64) * (x(i, j, k, 2) + 1.0_real64) * (x(i, j, k, 3) + 1.0_real64) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = -(x(i,j,k,1)+1.0_real64)*(x(i,j,k,2)+1.0_real64)*(x(i,j,k,3)+1.0_real64) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function monadic_r3fp64 -end program test + endfunction monadic_r3fp64 +endprogram test diff --git a/test/monadic_r4fp32.f90 b/test/monadic_r4fp32.f90 index 2d42c15..5c08fcc 100644 --- a/test/monadic_r4fp32.f90 +++ b/test/monadic_r4fp32.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = monadic_r4fp32() - stop exit_code + exit_code = monadic_r4fp32() + stop exit_code contains - integer function monadic_r4fp32() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function monadic_r4fp32() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = -(x(i, j, k, l, 1) + 1.0_real32) * (x(i, j, k, l, 2) + 1.0_real32) * (x(i, j, k, l, 3) + 1.0_real32) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = -(x(i,j,k,l,1)+1.0_real32)*(x(i,j,k,l,2)+1.0_real32)*(x(i,j,k,l,3)+1.0_real32) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32) * 10.0_real32) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)*10.0_real32) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function monadic_r4fp32 -end program test + endfunction monadic_r4fp32 +endprogram test diff --git a/test/monadic_r4fp64.f90 b/test/monadic_r4fp64.f90 index 6c4de74..41f3c76 100644 --- a/test/monadic_r4fp64.f90 +++ b/test/monadic_r4fp64.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = monadic_r4fp64() - stop exit_code + exit_code = monadic_r4fp64() + stop exit_code contains - integer function monadic_r4fp64() result(r) - ! WARNING : the change in order of operations with feq-parse compared to the compilers - ! implementation for "fexact" leads to differences that are larger than machine epsilon. - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function monadic_r4fp64() result(r) + ! WARNING : the change in order of operations with feq-parse compared to the compilers + ! implementation for "fexact" leads to differences that are larger than machine epsilon. + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x+1)*(y+1)*(z+1)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x+1)*(y+1)*(z+1)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = -(x(i, j, k, l, 1) + 1.0_real64) * (x(i, j, k, l, 2) + 1.0_real64) * (x(i, j, k, l, 3) + 1.0_real64) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = -(x(i,j,k,l,1)+1.0_real64)*(x(i,j,k,l,2)+1.0_real64)*(x(i,j,k,l,3)+1.0_real64) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function monadic_r4fp64 -end program test + endfunction monadic_r4fp64 +endprogram test diff --git a/test/monadic_sfp32.f90 b/test/monadic_sfp32.f90 index 837268a..2c5d774 100644 --- a/test/monadic_sfp32.f90 +++ b/test/monadic_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = monadic_sfp32() - stop exit_code + exit_code = monadic_sfp32() + stop exit_code contains - integer function monadic_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x + 1)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = -(x(1) + 1.0_real32) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function monadic_sfp32 -end program test + integer function monadic_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x + 1)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = -(x(1)+1.0_real32) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction monadic_sfp32 +endprogram test diff --git a/test/monadic_sfp64.f90 b/test/monadic_sfp64.f90 index 9dd0d40..27ae264 100644 --- a/test/monadic_sfp64.f90 +++ b/test/monadic_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = monadic_sfp64() - stop exit_code + exit_code = monadic_sfp64() + stop exit_code contains - integer function monadic_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(x + 1)' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = -(x(1) + 1.0_real64) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function monadic_sfp64 -end program test + integer function monadic_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(x + 1)' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = -(x(1)+1.0_real64) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction monadic_sfp64 +endprogram test diff --git a/test/parsing_difficult_r1fp64.f90 b/test/parsing_difficult_r1fp64.f90 index 159c4c9..4917b77 100644 --- a/test/parsing_difficult_r1fp64.f90 +++ b/test/parsing_difficult_r1fp64.f90 @@ -1,104 +1,104 @@ program test - use iso_fortran_env, only: i1 => int8, i2 => int16, i4 => int32, i8 => int64, & - r4 => real32, r8 => real64, r16 => real128 - use FEQParse + use iso_fortran_env,only:i1 => int8,i2 => int16,i4 => int32,i8 => int64, & + r4 => real32,r8 => real64,r16 => real128 + use FEQParse - implicit none + implicit none - real(r8) :: results(24) - integer j - data(results(j), j=1, 24) / 0.9508_r8, & - 0.7958_r8, & - 0.2846_r8, & - 1.1247_r8, & - 0.9177_r8, & - 1.0599_r8, & - 0.8064_r8, & - 3.2193_r8, & - 0.9981_r8, & - 0.8366_r8, & - 0.9441_r8, & - 0.1457_r8, & - 4.2508_r8, & - 1.2064_r8, & - 1.2227_r8, & - 20.6962_r8, & - 112.1323_r8, & - 1.5597_r8, & - 7.5806_r8, & - 1.5574_r8, & - 0.8869_r8, & - 3.0118_r8, & - 5.4819_r8, & - 1.5311_r8 / + real(r8) :: results(24) + integer j + data(results(j),j=1,24)/0.9508_r8, & + 0.7958_r8, & + 0.2846_r8, & + 1.1247_r8, & + 0.9177_r8, & + 1.0599_r8, & + 0.8064_r8, & + 3.2193_r8, & + 0.9981_r8, & + 0.8366_r8, & + 0.9441_r8, & + 0.1457_r8, & + 4.2508_r8, & + 1.2064_r8, & + 1.2227_r8, & + 20.6962_r8, & + 112.1323_r8, & + 1.5597_r8, & + 7.5806_r8, & + 1.5574_r8, & + 0.8869_r8, & + 3.0118_r8, & + 5.4819_r8, & + 1.5311_r8/ - character(200) :: test_data(1:24) - data(test_data(j), j=1, 24)/ & - 'a+b*x1', & - '(a*x**b)/(c+x**b)', & - '(a*x)/(b+(x*(1+x/c)))', & - 'a+b*exp(c*x)+d*exp(e*x)', & - 'a+b*(exp(c*x) - 1)/c', & - 'a+b*log(x)+c*log(x)**2', & - 'a-log(1+b*exp(-c*x))', & - '(a+b*x)/(c+x)', & - 'a+b*exp(-(c*x))', & - 'a+b*sin(2*3.14*x/c+d)', & - 'a+b*sin(2*4.14*x/c+d)**2', & - '1-exp(-a*x)', & - 'a+b*x1+c*x2', & - 'a+b*log(x1)+c*log(x2)', & - 'a*x1**b*x2**c', & - 'cosh(log(abs(y*z+x**2+x1**x2)))+a*d*(exp(c*f)+154.3)', & - 'a+b*log(x1)+c*x2+d*x2**2', & - 'atan(sinh(log(abs(exp(z/x)*sqrt(y+a**c+f*e)))))', & - 'a+b/x1+c*log(x2)+d*log(x2)**2+e*log(x2)**3', & - 'atan(sinh(log(abs(exp(z/x)*sqrt(y+a**c+f*e)))))*cos(log(abs(sqrt(y+a**c+f*e))))', & - 'a+b*log(x1)+c*log(x1)**2+d/x2+e/x2**2', & - '(x+a)/(b+c*(x+a)+d*(x+a)**2)', & - '(x+y+z+x*y+x*z+y*z+x/y+x/z+y/z+x*cos(x)+y*sin(y)+z*tan(z)*2/(x+y+z+x*y+x*z+y*z+x/y+ & - & x/z+y/z+x*cos(x)+y*sin(y)+z*tan(z))*3+sqrt(x*y*z+x+y+z)*log10(sqrt(x*2+y*2+z*2)+x+y+z))', & - 'a+b*log(x1)+c*log(x1)**2+d*log(x1)**3+e/x'/ + character(200) :: test_data(1:24) + data(test_data(j),j=1,24)/ & + 'a+b*x1', & + '(a*x**b)/(c+x**b)', & + '(a*x)/(b+(x*(1+x/c)))', & + 'a+b*exp(c*x)+d*exp(e*x)', & + 'a+b*(exp(c*x) - 1)/c', & + 'a+b*log(x)+c*log(x)**2', & + 'a-log(1+b*exp(-c*x))', & + '(a+b*x)/(c+x)', & + 'a+b*exp(-(c*x))', & + 'a+b*sin(2*3.14*x/c+d)', & + 'a+b*sin(2*4.14*x/c+d)**2', & + '1-exp(-a*x)', & + 'a+b*x1+c*x2', & + 'a+b*log(x1)+c*log(x2)', & + 'a*x1**b*x2**c', & + 'cosh(log(abs(y*z+x**2+x1**x2)))+a*d*(exp(c*f)+154.3)', & + 'a+b*log(x1)+c*x2+d*x2**2', & + 'atan(sinh(log(abs(exp(z/x)*sqrt(y+a**c+f*e)))))', & + 'a+b/x1+c*log(x2)+d*log(x2)**2+e*log(x2)**3', & + 'atan(sinh(log(abs(exp(z/x)*sqrt(y+a**c+f*e)))))*cos(log(abs(sqrt(y+a**c+f*e))))', & + 'a+b*log(x1)+c*log(x1)**2+d/x2+e/x2**2', & + '(x+a)/(b+c*(x+a)+d*(x+a)**2)', & + '(x+y+z+x*y+x*z+y*z+x/y+x/z+y/z+x*cos(x)+y*sin(y)+z*tan(z)*2/(x+y+z+x*y+x*z+y*z+x/y+ & + & x/z+y/z+x*cos(x)+y*sin(y)+z*tan(z))*3+sqrt(x*y*z+x+y+z)*log10(sqrt(x*2+y*2+z*2)+x+y+z))', & + 'a+b*log(x1)+c*log(x1)**2+d*log(x1)**3+e/x'/ - character(len=10), dimension(1:11) :: independentvars - real(r8) :: x(1:11) + character(len=10),dimension(1:11) :: independentvars + real(r8) :: x(1:11) - call initialize() + call initialize() - do j = 1, 24 - write (*, '(A,A,I20)') "parsing ", test_data(j), parsing(j) - end do + do j = 1,24 + write(*,'(A,A,I20)') "parsing ",test_data(j),parsing(j) + enddo contains - subroutine initialize() - independentvars = ['x ', 'y ', 'z ', 'x1', 'x2', & - 'a ', 'b ', 'c ', 'd ', 'e ', 'f '] - x(1) = 0.175_r8 - x(2) = 0.110_r8 - x(3) = 0.900_r8 - x(4) = 0.508_r8 - x(5) = 30.000_r8 - x(6) = 0.900_r8 - x(7) = 0.100_r8 - x(8) = 0.110_r8 - x(9) = 0.120_r8 - x(10) = 0.120_r8 - x(11) = 0.140_r8 - end subroutine + subroutine initialize() + independentvars = ['x ','y ','z ','x1','x2', & + 'a ','b ','c ','d ','e ','f '] + x(1) = 0.175_r8 + x(2) = 0.110_r8 + x(3) = 0.900_r8 + x(4) = 0.508_r8 + x(5) = 30.000_r8 + x(6) = 0.900_r8 + x(7) = 0.100_r8 + x(8) = 0.110_r8 + x(9) = 0.120_r8 + x(10) = 0.120_r8 + x(11) = 0.140_r8 + endsubroutine - integer function parsing(i) result(r) - integer, intent(in) :: i - !private - type(EquationParser) :: f - real(r8) :: feval - f = EquationParser(test_data(i), independentvars) - feval = f%evaluate(x) - if ((abs(feval - results(i))) <= 0.001_r8) then - r = 0 - else - r = 1 - end if - end function + integer function parsing(i) result(r) + integer,intent(in) :: i + !private + type(EquationParser) :: f + real(r8) :: feval + f = EquationParser(test_data(i),independentvars) + feval = f%evaluate(x) + if((abs(feval-results(i))) <= 0.001_r8) then + r = 0 + else + r = 1 + endif + endfunction -end program +endprogram diff --git a/test/print_tokens.f90 b/test/print_tokens.f90 index 8e05d6d..a417365 100644 --- a/test/print_tokens.f90 +++ b/test/print_tokens.f90 @@ -1,35 +1,35 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = print_tokens() - stop exit_code + exit_code = print_tokens() + stop exit_code contains - integer function print_tokens() result(r) - use FEQParse - use iso_fortran_env - implicit none - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar + integer function print_tokens() result(r) + use FEQParse + use iso_fortran_env + implicit none + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = -(cos( 2.0*pi*x ) + 5.0)/(sin(2.0*pi*y) + 10.0)*tanh(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = -(cos( 2.0*pi*x ) + 5.0)/(sin(2.0*pi*y) + 10.0)*tanh(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - call f%Print_InfixTokens() - call f%Print_PostfixTokens() + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + call f%Print_InfixTokens() + call f%Print_PostfixTokens() - ! Clean up memory + ! Clean up memory - r = 0 + r = 0 - end function print_tokens -end program test + endfunction print_tokens +endprogram test diff --git a/test/random_r1fp32.f90 b/test/random_r1fp32.f90 index a29c89d..2d703b4 100644 --- a/test/random_r1fp32.f90 +++ b/test/random_r1fp32.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = random_r1fp32() - stop exit_code + exit_code = random_r1fp32() + stop exit_code contains - integer function random_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - end if - - end function random_r1fp32 -end program test + integer function random_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval)) <= 1.0_real32) then + r = 0 + else + r = 1 + endif + + endfunction random_r1fp32 +endprogram test diff --git a/test/random_r1fp64.f90 b/test/random_r1fp64.f90 index e479cf0..e9a425b 100644 --- a/test/random_r1fp64.f90 +++ b/test/random_r1fp64.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = random_r1fp64() - stop exit_code + exit_code = random_r1fp64() + stop exit_code contains - integer function random_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - end if - - end function random_r1fp64 -end program test + integer function random_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval)) <= 1.0_real64) then + r = 0 + else + r = 1 + endif + + endfunction random_r1fp64 +endprogram test diff --git a/test/random_r2fp32.f90 b/test/random_r2fp32.f90 index 540e5e6..8c6d03e 100644 --- a/test/random_r2fp32.f90 +++ b/test/random_r2fp32.f90 @@ -1,54 +1,54 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = random_r2fp32() - stop exit_code + exit_code = random_r2fp32() + stop exit_code contains - integer function random_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval) - - end function random_r2fp32 -end program test + integer function random_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval)) <= 1.0_real32) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval) + + endfunction random_r2fp32 +endprogram test diff --git a/test/random_r2fp64.f90 b/test/random_r2fp64.f90 index 82480aa..0e70cc1 100644 --- a/test/random_r2fp64.f90 +++ b/test/random_r2fp64.f90 @@ -1,54 +1,54 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = random_r2fp64() - stop exit_code + exit_code = random_r2fp64() + stop exit_code contains - integer function random_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval) - - end function random_r2fp64 -end program test + integer function random_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval)) <= 1.0_real64) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval) + + endfunction random_r2fp64 +endprogram test diff --git a/test/random_r3fp32.f90 b/test/random_r3fp32.f90 index bdbef65..6692cd1 100644 --- a/test/random_r3fp32.f90 +++ b/test/random_r3fp32.f90 @@ -1,59 +1,59 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = random_r3fp32() - stop exit_code + exit_code = random_r3fp32() + stop exit_code contains - integer function random_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k - - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function random_r3fp32 -end program test + integer function random_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k + + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )*rand( z )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval)) <= 1.0_real32) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction random_r3fp32 +endprogram test diff --git a/test/random_r3fp64.f90 b/test/random_r3fp64.f90 index af620cc..067dd11 100644 --- a/test/random_r3fp64.f90 +++ b/test/random_r3fp64.f90 @@ -1,59 +1,59 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = random_r3fp64() - stop exit_code + exit_code = random_r3fp64() + stop exit_code contains - integer function random_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k - - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function random_r3fp64 -end program test + integer function random_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k + + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )*rand( z )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval)) <= 1.0_real64) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction random_r3fp64 +endprogram test diff --git a/test/random_r4fp32.f90 b/test/random_r4fp32.f90 index 5daca22..55da1d9 100644 --- a/test/random_r4fp32.f90 +++ b/test/random_r4fp32.f90 @@ -1,62 +1,62 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = random_r4fp32() - stop exit_code + exit_code = random_r4fp32() + stop exit_code contains - integer function random_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l - - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (0.1_real32) / real(N, real32) * real(i - 1, real32) + 0.1_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (0.1_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (0.1_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function random_r4fp32 -end program test + integer function random_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l + + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )*rand( z )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(0.1_real32)/real(N,real32)*real(i-1,real32)+0.1_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(0.1_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(0.1_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval)) <= 1.0_real32) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction random_r4fp32 +endprogram test diff --git a/test/random_r4fp64.f90 b/test/random_r4fp64.f90 index 213262d..eba6795 100644 --- a/test/random_r4fp64.f90 +++ b/test/random_r4fp64.f90 @@ -1,62 +1,62 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = random_r4fp64() - stop exit_code + exit_code = random_r4fp64() + stop exit_code contains - integer function random_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l - - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (0.1_real64) / real(N, real64) * real(i - 1, real64) + 0.1_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (0.1_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (0.1_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function random_r4fp64 -end program test + integer function random_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l + + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )*rand( y )*rand( z )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(0.1_real64)/real(N,real64)*real(i-1,real64)+0.1_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(0.1_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(0.1_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval)) <= 1.0_real64) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction random_r4fp64 +endprogram test diff --git a/test/random_sfp32.f90 b/test/random_sfp32.f90 index 09be090..bda6d99 100644 --- a/test/random_sfp32.f90 +++ b/test/random_sfp32.f90 @@ -1,43 +1,43 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = random_sfp32() - stop exit_code + exit_code = random_sfp32() + stop exit_code contains - integer function random_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - end if - - end function random_sfp32 -end program test + integer function random_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval)) <= 1.0_real32) then + r = 0 + else + r = 1 + endif + + endfunction random_sfp32 +endprogram test diff --git a/test/random_sfp64.f90 b/test/random_sfp64.f90 index 8468471..8df995f 100644 --- a/test/random_sfp64.f90 +++ b/test/random_sfp64.f90 @@ -1,43 +1,43 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = random_sfp64() - stop exit_code + exit_code = random_sfp64() + stop exit_code contains - integer function random_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - end if - - end function random_sfp64 -end program test + integer function random_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = rand( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval)) <= 1.0_real64) then + r = 0 + else + r = 1 + endif + + endfunction random_sfp64 +endprogram test diff --git a/test/sech_r1fp32.f90 b/test/sech_r1fp32.f90 index 695057d..d32be21 100644 --- a/test/sech_r1fp32.f90 +++ b/test/sech_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sech_r1fp32() - stop exit_code + exit_code = sech_r1fp32() + stop exit_code contains - integer function sech_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = 2.0_real32 / (exp(x(i, 1)) + exp(-x(i, 1))) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function sech_r1fp32 -end program test + integer function sech_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = 2.0_real32/(exp(x(i,1))+exp(-x(i,1))) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction sech_r1fp32 +endprogram test diff --git a/test/sech_r1fp64.f90 b/test/sech_r1fp64.f90 index a229071..118e513 100644 --- a/test/sech_r1fp64.f90 +++ b/test/sech_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sech_r1fp64() - stop exit_code + exit_code = sech_r1fp64() + stop exit_code contains - integer function sech_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = 2.0_real64 / (exp(x(i, 1)) + exp(-x(i, 1))) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function sech_r1fp64 -end program test + integer function sech_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = 2.0_real64/(exp(x(i,1))+exp(-x(i,1))) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction sech_r1fp64 +endprogram test diff --git a/test/sech_r2fp32.f90 b/test/sech_r2fp32.f90 index 82ce994..5f87dc3 100644 --- a/test/sech_r2fp32.f90 +++ b/test/sech_r2fp32.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sech_r2fp32() - stop exit_code + exit_code = sech_r2fp32() + stop exit_code contains - integer function sech_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = 2.0_real32 / (exp(x(i, j, 1)) + exp(-x(i, j, 1))) * & - 2.0_real32 / (exp(x(i, j, 2)) + exp(-x(i, j, 2))) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function sech_r2fp32 -end program test + integer function sech_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = 2.0_real32/(exp(x(i,j,1))+exp(-x(i,j,1)))* & + 2.0_real32/(exp(x(i,j,2))+exp(-x(i,j,2))) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction sech_r2fp32 +endprogram test diff --git a/test/sech_r2fp64.f90 b/test/sech_r2fp64.f90 index 6b62bd3..cb57ec1 100644 --- a/test/sech_r2fp64.f90 +++ b/test/sech_r2fp64.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sech_r2fp64() - stop exit_code + exit_code = sech_r2fp64() + stop exit_code contains - integer function sech_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = 2.0_real64 / (exp(x(i, j, 1)) + exp(-x(i, j, 1))) * & - 2.0_real64 / (exp(x(i, j, 2)) + exp(-x(i, j, 2))) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function sech_r2fp64 -end program test + integer function sech_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = 2.0_real64/(exp(x(i,j,1))+exp(-x(i,j,1)))* & + 2.0_real64/(exp(x(i,j,2))+exp(-x(i,j,2))) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction sech_r2fp64 +endprogram test diff --git a/test/sech_r3fp32.f90 b/test/sech_r3fp32.f90 index 82bac74..24425e2 100644 --- a/test/sech_r3fp32.f90 +++ b/test/sech_r3fp32.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sech_r3fp32() - stop exit_code + exit_code = sech_r3fp32() + stop exit_code contains - integer function sech_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function sech_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )*sech(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )*sech(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = 2.0_real32 / (exp(x(i, j, k, 1)) + exp(-x(i, j, k, 1))) * & - 2.0_real32 / (exp(x(i, j, k, 2)) + exp(-x(i, j, k, 2))) * & - 2.0_real32 / (exp(x(i, j, k, 3)) + exp(-x(i, j, k, 3))) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = 2.0_real32/(exp(x(i,j,k,1))+exp(-x(i,j,k,1)))* & + 2.0_real32/(exp(x(i,j,k,2))+exp(-x(i,j,k,2)))* & + 2.0_real32/(exp(x(i,j,k,3))+exp(-x(i,j,k,3))) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function sech_r3fp32 -end program test + endfunction sech_r3fp32 +endprogram test diff --git a/test/sech_r3fp64.f90 b/test/sech_r3fp64.f90 index 3ef5561..99b434a 100644 --- a/test/sech_r3fp64.f90 +++ b/test/sech_r3fp64.f90 @@ -1,68 +1,68 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sech_r3fp64() - stop exit_code + exit_code = sech_r3fp64() + stop exit_code contains - integer function sech_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function sech_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )*sech(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )*sech(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = 2.0_real64 / (exp(x(i, j, k, 1)) + exp(-x(i, j, k, 1))) * & - 2.0_real64 / (exp(x(i, j, k, 2)) + exp(-x(i, j, k, 2))) * & - 2.0_real64 / (exp(x(i, j, k, 3)) + exp(-x(i, j, k, 3))) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = 2.0_real64/(exp(x(i,j,k,1))+exp(-x(i,j,k,1)))* & + 2.0_real64/(exp(x(i,j,k,2))+exp(-x(i,j,k,2)))* & + 2.0_real64/(exp(x(i,j,k,3))+exp(-x(i,j,k,3))) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function sech_r3fp64 -end program test + endfunction sech_r3fp64 +endprogram test diff --git a/test/sech_r4fp32.f90 b/test/sech_r4fp32.f90 index 2e9f66e..71ec33d 100644 --- a/test/sech_r4fp32.f90 +++ b/test/sech_r4fp32.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sech_r4fp32() - stop exit_code + exit_code = sech_r4fp32() + stop exit_code contains - integer function sech_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function sech_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )*sech(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )*sech(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = 2.0_real32 / (exp(x(i, j, k, l, 1)) + exp(-x(i, j, k, l, 1))) * & - 2.0_real32 / (exp(x(i, j, k, l, 2)) + exp(-x(i, j, k, l, 2))) * & - 2.0_real32 / (exp(x(i, j, k, l, 3)) + exp(-x(i, j, k, l, 3))) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = 2.0_real32/(exp(x(i,j,k,l,1))+exp(-x(i,j,k,l,1)))* & + 2.0_real32/(exp(x(i,j,k,l,2))+exp(-x(i,j,k,l,2)))* & + 2.0_real32/(exp(x(i,j,k,l,3))+exp(-x(i,j,k,l,3))) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function sech_r4fp32 -end program test + endfunction sech_r4fp32 +endprogram test diff --git a/test/sech_r4fp64.f90 b/test/sech_r4fp64.f90 index 9f3c2ce..a9a23cf 100644 --- a/test/sech_r4fp64.f90 +++ b/test/sech_r4fp64.f90 @@ -1,73 +1,73 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sech_r4fp64() - stop exit_code + exit_code = sech_r4fp64() + stop exit_code contains - integer function sech_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function sech_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )*sech( y )*sech(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )*sech( y )*sech(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = 2.0_real64 / (exp(x(i, j, k, l, 1)) + exp(-x(i, j, k, l, 1))) * & - 2.0_real64 / (exp(x(i, j, k, l, 2)) + exp(-x(i, j, k, l, 2))) * & - 2.0_real64 / (exp(x(i, j, k, l, 3)) + exp(-x(i, j, k, l, 3))) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = 2.0_real64/(exp(x(i,j,k,l,1))+exp(-x(i,j,k,l,1)))* & + 2.0_real64/(exp(x(i,j,k,l,2))+exp(-x(i,j,k,l,2)))* & + 2.0_real64/(exp(x(i,j,k,l,3))+exp(-x(i,j,k,l,3))) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function sech_r4fp64 -end program test + endfunction sech_r4fp64 +endprogram test diff --git a/test/sech_sfp32.f90 b/test/sech_sfp32.f90 index ff462b8..aec1c7b 100644 --- a/test/sech_sfp32.f90 +++ b/test/sech_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sech_sfp32() - stop exit_code + exit_code = sech_sfp32() + stop exit_code contains - integer function sech_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = 2.0_real32 / (exp(x(1)) + exp(-x(1))) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function sech_sfp32 -end program test + integer function sech_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = 2.0_real32/(exp(x(1))+exp(-x(1))) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction sech_sfp32 +endprogram test diff --git a/test/sech_sfp64.f90 b/test/sech_sfp64.f90 index 9967bad..642c3da 100644 --- a/test/sech_sfp64.f90 +++ b/test/sech_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sech_sfp64() - stop exit_code + exit_code = sech_sfp64() + stop exit_code contains - integer function sech_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sech( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = 2.0_real64 / (exp(x(1)) + exp(-x(1))) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function sech_sfp64 -end program test + integer function sech_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sech( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = 2.0_real64/(exp(x(1))+exp(-x(1))) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction sech_sfp64 +endprogram test diff --git a/test/sin_r1fp32.f90 b/test/sin_r1fp32.f90 index c0bad94..8c37201 100644 --- a/test/sin_r1fp32.f90 +++ b/test/sin_r1fp32.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sin_r1fp32() - stop exit_code + exit_code = sin_r1fp32() + stop exit_code contains - integer function sin_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = sin(2.0_real32 * pi * x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function sin_r1fp32 -end program test + integer function sin_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = sin(2.0_real32*pi*x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction sin_r1fp32 +endprogram test diff --git a/test/sin_r1fp64.f90 b/test/sin_r1fp64.f90 index 22c96fb..91f9783 100644 --- a/test/sin_r1fp64.f90 +++ b/test/sin_r1fp64.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sin_r1fp64() - stop exit_code + exit_code = sin_r1fp64() + stop exit_code contains - integer function sin_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = sin(2.0_real64 * pi * x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function sin_r1fp64 -end program test + integer function sin_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = sin(2.0_real64*pi*x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction sin_r1fp64 +endprogram test diff --git a/test/sin_r2fp32.f90 b/test/sin_r2fp32.f90 index 9285a68..0a57b29 100644 --- a/test/sin_r2fp32.f90 +++ b/test/sin_r2fp32.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sin_r2fp32() - stop exit_code + exit_code = sin_r2fp32() + stop exit_code contains - integer function sin_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = sin(2.0_real32 * pi * x(i, j, 1)) * sin(2.0_real32 * pi * x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function sin_r2fp32 -end program test + integer function sin_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = sin(2.0_real32*pi*x(i,j,1))*sin(2.0_real32*pi*x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction sin_r2fp32 +endprogram test diff --git a/test/sin_r2fp64.f90 b/test/sin_r2fp64.f90 index 15b91ed..db205d3 100644 --- a/test/sin_r2fp64.f90 +++ b/test/sin_r2fp64.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sin_r2fp64() - stop exit_code + exit_code = sin_r2fp64() + stop exit_code contains - integer function sin_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = sin(2.0_real64 * pi * x(i, j, 1)) * sin(2.0_real32 * pi * x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function sin_r2fp64 -end program test + integer function sin_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = sin(2.0_real64*pi*x(i,j,1))*sin(2.0_real32*pi*x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction sin_r2fp64 +endprogram test diff --git a/test/sin_r3fp32.f90 b/test/sin_r3fp32.f90 index 86267d0..1b9f68e 100644 --- a/test/sin_r3fp32.f90 +++ b/test/sin_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sin_r3fp32() - stop exit_code + exit_code = sin_r3fp32() + stop exit_code contains - integer function sin_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function sin_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = sin(2.0_real32 * pi * x(i, j, k, 1)) * sin(2.0_real32 * pi * x(i, j, k, 2)) * sin(2.0_real32 * pi * x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = sin(2.0_real32*pi*x(i,j,k,1))*sin(2.0_real32*pi*x(i,j,k,2))*sin(2.0_real32*pi*x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function sin_r3fp32 -end program test + endfunction sin_r3fp32 +endprogram test diff --git a/test/sin_r3fp64.f90 b/test/sin_r3fp64.f90 index 1dddeb8..8fe0907 100644 --- a/test/sin_r3fp64.f90 +++ b/test/sin_r3fp64.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sin_r3fp64() - stop exit_code + exit_code = sin_r3fp64() + stop exit_code contains - integer function sin_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function sin_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = sin(2.0_real64 * pi * x(i, j, k, 1)) * sin(2.0_real64 * pi * x(i, j, k, 2)) * sin(2.0_real64 * pi * x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = sin(2.0_real64*pi*x(i,j,k,1))*sin(2.0_real64*pi*x(i,j,k,2))*sin(2.0_real64*pi*x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function sin_r3fp64 -end program test + endfunction sin_r3fp64 +endprogram test diff --git a/test/sin_r4fp32.f90 b/test/sin_r4fp32.f90 index 2844712..d9754c4 100644 --- a/test/sin_r4fp32.f90 +++ b/test/sin_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sin_r4fp32() - stop exit_code + exit_code = sin_r4fp32() + stop exit_code contains - integer function sin_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function sin_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = sin(2.0_real32 * pi * x(i, j, k, l, 1)) * sin(2.0_real32 * pi * x(i, j, k, l, 2)) * sin(2.0_real32 * pi * x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = sin(2.0_real32*pi*x(i,j,k,l,1))*sin(2.0_real32*pi*x(i,j,k,l,2))*sin(2.0_real32*pi*x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) - end function sin_r4fp32 -end program test + deallocate(x,feval,fexact) + endfunction sin_r4fp32 +endprogram test diff --git a/test/sin_r4fp64.f90 b/test/sin_r4fp64.f90 index 3129f01..7ba410c 100644 --- a/test/sin_r4fp64.f90 +++ b/test/sin_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sin_r4fp64() - stop exit_code + exit_code = sin_r4fp64() + stop exit_code contains - integer function sin_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function sin_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )*sin( 2.0*pi*y )*sin(2.0*pi*z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = sin(2.0_real64 * pi * x(i, j, k, l, 1)) * sin(2.0_real64 * pi * x(i, j, k, l, 2)) * sin(2.0_real64 * pi * x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = sin(2.0_real64*pi*x(i,j,k,l,1))*sin(2.0_real64*pi*x(i,j,k,l,2))*sin(2.0_real64*pi*x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) - end function sin_r4fp64 -end program test + deallocate(x,feval,fexact) + endfunction sin_r4fp64 +endprogram test diff --git a/test/sin_sfp32.f90 b/test/sin_sfp32.f90 index 940b1c5..21e344f 100644 --- a/test/sin_sfp32.f90 +++ b/test/sin_sfp32.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sin_sfp32() - stop exit_code + exit_code = sin_sfp32() + stop exit_code contains - integer function sin_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = sin(2.0_real32 * pi * x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function sin_sfp32 -end program test + integer function sin_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = sin(2.0_real32*pi*x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction sin_sfp32 +endprogram test diff --git a/test/sin_sfp64.f90 b/test/sin_sfp64.f90 index aed87cb..66eac48 100644 --- a/test/sin_sfp64.f90 +++ b/test/sin_sfp64.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sin_sfp64() - stop exit_code + exit_code = sin_sfp64() + stop exit_code contains - integer function sin_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sin( 2.0*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = sin(2.0_real64 * pi * x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function sin_sfp64 -end program test + integer function sin_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sin( 2.0*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = sin(2.0_real64*pi*x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction sin_sfp64 +endprogram test diff --git a/test/sqrt_r1fp32.f90 b/test/sqrt_r1fp32.f90 index 92ae531..1d25c64 100644 --- a/test/sqrt_r1fp32.f90 +++ b/test/sqrt_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sqrt_r1fp32() - stop exit_code + exit_code = sqrt_r1fp32() + stop exit_code contains - integer function sqrt_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = sqrt(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function sqrt_r1fp32 -end program test + integer function sqrt_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = (2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = sqrt(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction sqrt_r1fp32 +endprogram test diff --git a/test/sqrt_r1fp64.f90 b/test/sqrt_r1fp64.f90 index b7a3424..4c87d01 100644 --- a/test/sqrt_r1fp64.f90 +++ b/test/sqrt_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sqrt_r1fp64() - stop exit_code + exit_code = sqrt_r1fp64() + stop exit_code contains - integer function sqrt_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = sqrt(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function sqrt_r1fp64 -end program test + integer function sqrt_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = (2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = sqrt(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction sqrt_r1fp64 +endprogram test diff --git a/test/sqrt_r2fp32.f90 b/test/sqrt_r2fp32.f90 index b7f3c87..2344c9c 100644 --- a/test/sqrt_r2fp32.f90 +++ b/test/sqrt_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sqrt_r2fp32() - stop exit_code + exit_code = sqrt_r2fp32() + stop exit_code contains - integer function sqrt_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = sqrt(x(i, j, 1)) * sqrt(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function sqrt_r2fp32 -end program test + integer function sqrt_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = (2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = (2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = sqrt(x(i,j,1))*sqrt(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction sqrt_r2fp32 +endprogram test diff --git a/test/sqrt_r2fp64.f90 b/test/sqrt_r2fp64.f90 index 18d2e48..0574da9 100644 --- a/test/sqrt_r2fp64.f90 +++ b/test/sqrt_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sqrt_r2fp64() - stop exit_code + exit_code = sqrt_r2fp64() + stop exit_code contains - integer function sqrt_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = sqrt(x(i, j, 1)) * sqrt(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function sqrt_r2fp64 -end program test + integer function sqrt_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = (2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = (2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = sqrt(x(i,j,1))*sqrt(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction sqrt_r2fp64 +endprogram test diff --git a/test/sqrt_r3fp32.f90 b/test/sqrt_r3fp32.f90 index f672736..b0b6c6e 100644 --- a/test/sqrt_r3fp32.f90 +++ b/test/sqrt_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sqrt_r3fp32() - stop exit_code + exit_code = sqrt_r3fp32() + stop exit_code contains - integer function sqrt_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function sqrt_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = sqrt(x(i, j, k, 1)) * sqrt(x(i, j, k, 2)) * sqrt(x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = (2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = (2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = (2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = sqrt(x(i,j,k,1))*sqrt(x(i,j,k,2))*sqrt(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function sqrt_r3fp32 -end program test + endfunction sqrt_r3fp32 +endprogram test diff --git a/test/sqrt_r3fp64.f90 b/test/sqrt_r3fp64.f90 index 795ec5f..617cce1 100644 --- a/test/sqrt_r3fp64.f90 +++ b/test/sqrt_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sqrt_r3fp64() - stop exit_code + exit_code = sqrt_r3fp64() + stop exit_code contains - integer function sqrt_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function sqrt_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = sqrt(x(i, j, k, 1)) * sqrt(x(i, j, k, 2)) * sqrt(x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = (2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = (2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = (2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = sqrt(x(i,j,k,1))*sqrt(x(i,j,k,2))*sqrt(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= 10.0_real64 * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= 10.0_real64*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function sqrt_r3fp64 -end program test + endfunction sqrt_r3fp64 +endprogram test diff --git a/test/sqrt_r4fp32.f90 b/test/sqrt_r4fp32.f90 index a01ee3d..cd5e782 100644 --- a/test/sqrt_r4fp32.f90 +++ b/test/sqrt_r4fp32.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sqrt_r4fp32() - stop exit_code + exit_code = sqrt_r4fp32() + stop exit_code contains - integer function sqrt_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function sqrt_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = sqrt(x(i, j, k, l, 1)) * sqrt(x(i, j, k, l, 2)) * sqrt(x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = (2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = (2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = (2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = sqrt(x(i,j,k,l,1))*sqrt(x(i,j,k,l,2))*sqrt(x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function sqrt_r4fp32 -end program test + endfunction sqrt_r4fp32 +endprogram test diff --git a/test/sqrt_r4fp64.f90 b/test/sqrt_r4fp64.f90 index b9bf17b..feb3ab1 100644 --- a/test/sqrt_r4fp64.f90 +++ b/test/sqrt_r4fp64.f90 @@ -1,71 +1,71 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sqrt_r4fp64() - stop exit_code + exit_code = sqrt_r4fp64() + stop exit_code contains - integer function sqrt_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function sqrt_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )*sqrt( y )*sqrt(z)' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = sqrt(x(i, j, k, l, 1)) * sqrt(x(i, j, k, l, 2)) * sqrt(x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = (2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = (2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = (2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = sqrt(x(i,j,k,l,1))*sqrt(x(i,j,k,l,2))*sqrt(x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64) * 10.0_real64) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)*10.0_real64) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function sqrt_r4fp64 -end program test + endfunction sqrt_r4fp64 +endprogram test diff --git a/test/sqrt_sfp32.f90 b/test/sqrt_sfp32.f90 index e53321f..730587a 100644 --- a/test/sqrt_sfp32.f90 +++ b/test/sqrt_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sqrt_sfp32() - stop exit_code + exit_code = sqrt_sfp32() + stop exit_code contains - integer function sqrt_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 100.0_real32 - fexact = sqrt(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function sqrt_sfp32 -end program test + integer function sqrt_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 100.0_real32 + fexact = sqrt(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction sqrt_sfp32 +endprogram test diff --git a/test/sqrt_sfp64.f90 b/test/sqrt_sfp64.f90 index 34f9583..e289661 100644 --- a/test/sqrt_sfp64.f90 +++ b/test/sqrt_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = sqrt_sfp64() - stop exit_code + exit_code = sqrt_sfp64() + stop exit_code contains - integer function sqrt_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = sqrt( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 100.0_real64 - fexact = sqrt(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function sqrt_sfp64 -end program test + integer function sqrt_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = sqrt( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 100.0_real64 + fexact = sqrt(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction sqrt_sfp64 +endprogram test diff --git a/test/tan_r1fp32.f90 b/test/tan_r1fp32.f90 index 4a9d91d..22b7615 100644 --- a/test/tan_r1fp32.f90 +++ b/test/tan_r1fp32.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tan_r1fp32() - stop exit_code + exit_code = tan_r1fp32() + stop exit_code contains - integer function tan_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = tan(0.5_real32 * pi * x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function tan_r1fp32 -end program test + integer function tan_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = tan(0.5_real32*pi*x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction tan_r1fp32 +endprogram test diff --git a/test/tan_r1fp64.f90 b/test/tan_r1fp64.f90 index ebb42dc..3964a85 100644 --- a/test/tan_r1fp64.f90 +++ b/test/tan_r1fp64.f90 @@ -1,49 +1,49 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tan_r1fp64() - stop exit_code + exit_code = tan_r1fp64() + stop exit_code contains - integer function tan_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = tan(0.5_real64 * pi * x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function tan_r1fp64 -end program test + integer function tan_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = tan(0.5_real64*pi*x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction tan_r1fp64 +endprogram test diff --git a/test/tan_r2fp32.f90 b/test/tan_r2fp32.f90 index 7eea704..82f948b 100644 --- a/test/tan_r2fp32.f90 +++ b/test/tan_r2fp32.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tan_r2fp32() - stop exit_code + exit_code = tan_r2fp32() + stop exit_code contains - integer function tan_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=60) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = tan(0.5_real32 * pi * x(i, j, 1)) * tan(0.5_real32 * pi * x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function tan_r2fp32 -end program test + integer function tan_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=60) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = tan(0.5_real32*pi*x(i,j,1))*tan(0.5_real32*pi*x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction tan_r2fp32 +endprogram test diff --git a/test/tan_r2fp64.f90 b/test/tan_r2fp64.f90 index 5cc3017..c70b733 100644 --- a/test/tan_r2fp64.f90 +++ b/test/tan_r2fp64.f90 @@ -1,58 +1,58 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tan_r2fp64() - stop exit_code + exit_code = tan_r2fp64() + stop exit_code contains - integer function tan_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=60) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = tan(0.5_real64 * pi * x(i, j, 1)) * tan(0.5_real64 * pi * x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function tan_r2fp64 -end program test + integer function tan_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=60) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = tan(0.5_real64*pi*x(i,j,1))*tan(0.5_real64*pi*x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction tan_r2fp64 +endprogram test diff --git a/test/tan_r3fp32.f90 b/test/tan_r3fp32.f90 index f4d7738..d02d266 100644 --- a/test/tan_r3fp32.f90 +++ b/test/tan_r3fp32.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tan_r3fp32() - stop exit_code + exit_code = tan_r3fp32() + stop exit_code contains - integer function tan_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=60) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function tan_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=60) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = tan(0.5_real32 * pi * x(i, j, k, 1)) * tan(0.5_real32 * pi * x(i, j, k, 2)) * tan(0.5_real32 * pi * x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = tan(0.5_real32*pi*x(i,j,k,1))*tan(0.5_real32*pi*x(i,j,k,2))*tan(0.5_real32*pi*x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function tan_r3fp32 -end program test + endfunction tan_r3fp32 +endprogram test diff --git a/test/tan_r3fp64.f90 b/test/tan_r3fp64.f90 index 0157a13..e26ff91 100644 --- a/test/tan_r3fp64.f90 +++ b/test/tan_r3fp64.f90 @@ -1,67 +1,67 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tan_r3fp64() - stop exit_code + exit_code = tan_r3fp64() + stop exit_code contains - integer function tan_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=60) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function tan_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=60) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = tan(0.5_real64 * pi * x(i, j, k, 1)) * tan(0.5_real64 * pi * x(i, j, k, 2)) * tan(0.5_real64 * pi * x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = tan(0.5_real64*pi*x(i,j,k,1))*tan(0.5_real64*pi*x(i,j,k,2))*tan(0.5_real64*pi*x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function tan_r3fp64 -end program test + endfunction tan_r3fp64 +endprogram test diff --git a/test/tan_r4fp32.f90 b/test/tan_r4fp32.f90 index c290acc..f20d1d2 100644 --- a/test/tan_r4fp32.f90 +++ b/test/tan_r4fp32.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tan_r4fp32() - stop exit_code + exit_code = tan_r4fp32() + stop exit_code contains - integer function tan_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function tan_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = tan(0.5_real32 * pi * x(i, j, k, l, 1)) * tan(0.5_real32 * pi * x(i, j, k, l, 2)) * tan(0.5_real32 * pi * x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = tan(0.5_real32*pi*x(i,j,k,l,1))*tan(0.5_real32*pi*x(i,j,k,l,2))*tan(0.5_real32*pi*x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function tan_r4fp32 -end program test + endfunction tan_r4fp32 +endprogram test diff --git a/test/tan_r4fp64.f90 b/test/tan_r4fp64.f90 index bb05548..f8be483 100644 --- a/test/tan_r4fp64.f90 +++ b/test/tan_r4fp64.f90 @@ -1,72 +1,72 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tan_r4fp64() - stop exit_code + exit_code = tan_r4fp64() + stop exit_code contains - integer function tan_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function tan_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )*tan( 0.5*pi*y )*tan( 0.5*pi*z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = tan(0.5_real64 * pi * x(i, j, k, l, 1)) * tan(0.5_real64 * pi * x(i, j, k, l, 2)) * tan(0.5_real64 * pi * x(i, j, k, l, 3)) - end do - end do - end do - end do + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = tan(0.5_real64*pi*x(i,j,k,l,1))*tan(0.5_real64*pi*x(i,j,k,l,2))*tan(0.5_real64*pi*x(i,j,k,l,3)) + enddo + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= maxval(abs(fexact)) * epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= maxval(abs(fexact))*epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function tan_r4fp64 -end program test + endfunction tan_r4fp64 +endprogram test diff --git a/test/tan_sfp32.f90 b/test/tan_sfp32.f90 index 56c2015..41a3293 100644 --- a/test/tan_sfp32.f90 +++ b/test/tan_sfp32.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tan_sfp32() - stop exit_code + exit_code = tan_sfp32() + stop exit_code contains - integer function tan_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real32), parameter :: pi = 4.0_real32 * atan(1.0_real32) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = tan(0.5_real32 * pi * x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function tan_sfp32 -end program test + integer function tan_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = tan(0.5_real32*pi*x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction tan_sfp32 +endprogram test diff --git a/test/tan_sfp64.f90 b/test/tan_sfp64.f90 index 0835dbe..734aeb9 100644 --- a/test/tan_sfp64.f90 +++ b/test/tan_sfp64.f90 @@ -1,46 +1,46 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tan_sfp64() - stop exit_code + exit_code = tan_sfp64() + stop exit_code contains - integer function tan_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - real(real64), parameter :: pi = 4.0_real64 * atan(1.0_real64) - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tan( 0.5*pi*x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = tan(0.5_real64 * pi * x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function tan_sfp64 -end program test + integer function tan_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tan( 0.5*pi*x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = tan(0.5_real64*pi*x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction tan_sfp64 +endprogram test diff --git a/test/tanh_r1fp32.f90 b/test/tanh_r1fp32.f90 index a8f0ff1..8fbcc7f 100644 --- a/test/tanh_r1fp32.f90 +++ b/test/tanh_r1fp32.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tanh_r1fp32() - stop exit_code + exit_code = tanh_r1fp32() + stop exit_code contains - integer function tanh_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N, 1:3) - real(real32) :: feval(1:N) - real(real32) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do i = 1, N - x(i, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - fexact(i) = tanh(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function tanh_r1fp32 -end program test + integer function tanh_r1fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:N,1:3) + real(real32) :: feval(1:N) + real(real32) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do i = 1,N + x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + fexact(i) = tanh(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction tanh_r1fp32 +endprogram test diff --git a/test/tanh_r1fp64.f90 b/test/tanh_r1fp64.f90 index 4bbda3c..4ba38e5 100644 --- a/test/tanh_r1fp64.f90 +++ b/test/tanh_r1fp64.f90 @@ -1,48 +1,48 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tanh_r1fp64() - stop exit_code + exit_code = tanh_r1fp64() + stop exit_code contains - integer function tanh_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N, 1:3) - real(real64) :: feval(1:N) - real(real64) :: fexact(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do i = 1, N - x(i, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - fexact(i) = tanh(x(i, 1)) - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - end function tanh_r1fp64 -end program test + integer function tanh_r1fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:N,1:3) + real(real64) :: feval(1:N) + real(real64) :: fexact(1:N) + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do i = 1,N + x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + fexact(i) = tanh(x(i,1)) + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + endfunction tanh_r1fp64 +endprogram test diff --git a/test/tanh_r2fp32.f90 b/test/tanh_r2fp32.f90 index ca9198d..b82b795 100644 --- a/test/tanh_r2fp32.f90 +++ b/test/tanh_r2fp32.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tanh_r2fp32() - stop exit_code + exit_code = tanh_r2fp32() + stop exit_code contains - integer function tanh_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :) - real(real32), allocatable :: feval(:, :) - real(real32), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - fexact(i, j) = tanh(x(i, j, 1)) * tanh(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function tanh_r2fp32 -end program test + integer function tanh_r2fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:) + real(real32),allocatable :: feval(:,:) + real(real32),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + fexact(i,j) = tanh(x(i,j,1))*tanh(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction tanh_r2fp32 +endprogram test diff --git a/test/tanh_r2fp64.f90 b/test/tanh_r2fp64.f90 index 7d92387..a06299e 100644 --- a/test/tanh_r2fp64.f90 +++ b/test/tanh_r2fp64.f90 @@ -1,57 +1,57 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tanh_r2fp64() - stop exit_code + exit_code = tanh_r2fp64() + stop exit_code contains - integer function tanh_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :) - real(real64), allocatable :: feval(:, :) - real(real64), allocatable :: fexact(:, :) - integer :: i, j - - allocate (x(1:N, 1:N, 1:3), & - feval(1:N, 1:N), & - fexact(1:N, 1:N)) - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - do j = 1, N - do i = 1, N - x(i, j, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - fexact(i, j) = tanh(x(i, j, 1)) * tanh(x(i, j, 2)) - end do - end do - - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0)) then - r = 0 - else - r = 1 - end if - - deallocate (x, feval, fexact) - - end function tanh_r2fp64 -end program test + integer function tanh_r2fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:) + real(real64),allocatable :: feval(:,:) + real(real64),allocatable :: fexact(:,:) + integer :: i,j + + allocate(x(1:N,1:N,1:3), & + feval(1:N,1:N), & + fexact(1:N,1:N)) + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + do j = 1,N + do i = 1,N + x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + fexact(i,j) = tanh(x(i,j,1))*tanh(x(i,j,2)) + enddo + enddo + + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then + r = 0 + else + r = 1 + endif + + deallocate(x,feval,fexact) + + endfunction tanh_r2fp64 +endprogram test diff --git a/test/tanh_r3fp32.f90 b/test/tanh_r3fp32.f90 index d0f3d97..035ec11 100644 --- a/test/tanh_r3fp32.f90 +++ b/test/tanh_r3fp32.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tanh_r3fp32() - stop exit_code + exit_code = tanh_r3fp32() + stop exit_code contains - integer function tanh_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :) - real(real32), allocatable :: feval(:, :, :) - real(real32), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function tanh_r3fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:) + real(real32),allocatable :: feval(:,:,:) + real(real32),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) - x(i, j, k, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = tanh(x(i, j, k, 1)) * tanh(x(i, j, k, 2)) * tanh(x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real32 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) + x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = tanh(x(i,j,k,1))*tanh(x(i,j,k,2))*tanh(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function tanh_r3fp32 -end program test + endfunction tanh_r3fp32 +endprogram test diff --git a/test/tanh_r3fp64.f90 b/test/tanh_r3fp64.f90 index dc6795a..f4238e9 100644 --- a/test/tanh_r3fp64.f90 +++ b/test/tanh_r3fp64.f90 @@ -1,66 +1,66 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tanh_r3fp64() - stop exit_code + exit_code = tanh_r3fp64() + stop exit_code contains - integer function tanh_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :) - real(real64), allocatable :: feval(:, :, :) - real(real64), allocatable :: fexact(:, :, :) - integer :: i, j, k + integer function tanh_r3fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:) + real(real64),allocatable :: feval(:,:,:) + real(real64),allocatable :: fexact(:,:,:) + integer :: i,j,k - allocate (x(1:N, 1:N, 1:N, 1:3), & - feval(1:N, 1:N, 1:N), & - fexact(1:N, 1:N, 1:N)) + allocate(x(1:N,1:N,1:N,1:3), & + feval(1:N,1:N,1:N), & + fexact(1:N,1:N,1:N)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) - x(i, j, k, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k) = tanh(x(i, j, k, 1)) * tanh(x(i, j, k, 2)) * tanh(x(i, j, k, 3)) - end do - end do - end do + x = 0.0_real64 + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) + x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k) = tanh(x(i,j,k,1))*tanh(x(i,j,k,2))*tanh(x(i,j,k,3)) + enddo + enddo + enddo - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function tanh_r3fp64 -end program test + endfunction tanh_r3fp64 +endprogram test diff --git a/test/tanh_r4fp32.f90 b/test/tanh_r4fp32.f90 index 29099aa..a44e9e1 100644 --- a/test/tanh_r4fp32.f90 +++ b/test/tanh_r4fp32.f90 @@ -1,69 +1,69 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tanh_r4fp32() - stop exit_code + exit_code = tanh_r4fp32() + stop exit_code contains - integer function tanh_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32), allocatable :: x(:, :, :, :, :) - real(real32), allocatable :: feval(:, :, :, :) - real(real32), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function tanh_r4fp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real32),allocatable :: x(:,:,:,:,:) + real(real32),allocatable :: feval(:,:,:,:) + real(real32),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real32 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(i - 1, real32) + 2.0_real32 * real(l - 1, real32) - x(i, j, k, l, 2) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(j - 1, real32) - x(i, j, k, l, 3) = -1.0_real32 + (2.0_real32) / real(N, real32) * real(k - 1, real32) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = tanh(x(i, j, k, l, 1)) * tanh(x(i, j, k, l, 2)) * tanh(x(i, j, k, l, 3)) - end do - end do - end do - end do - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if + x = 0.0_real32 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32)+2.0_real32*real(l-1,real32) + x(i,j,k,l,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) + x(i,j,k,l,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = tanh(x(i,j,k,l,1))*tanh(x(i,j,k,l,2))*tanh(x(i,j,k,l,3)) + enddo + enddo + enddo + enddo + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function tanh_r4fp32 -end program test + endfunction tanh_r4fp32 +endprogram test diff --git a/test/tanh_r4fp64.f90 b/test/tanh_r4fp64.f90 index 49b029a..f05fcd9 100644 --- a/test/tanh_r4fp64.f90 +++ b/test/tanh_r4fp64.f90 @@ -1,69 +1,69 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tanh_r4fp64() - stop exit_code + exit_code = tanh_r4fp64() + stop exit_code contains - integer function tanh_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 2 - integer, parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64), allocatable :: x(:, :, :, :, :) - real(real64), allocatable :: feval(:, :, :, :) - real(real64), allocatable :: fexact(:, :, :, :) - integer :: i, j, k, l + integer function tanh_r4fp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 2 + integer,parameter :: M = 5 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=1024) :: eqChar + real(real64),allocatable :: x(:,:,:,:,:) + real(real64),allocatable :: feval(:,:,:,:) + real(real64),allocatable :: fexact(:,:,:,:) + integer :: i,j,k,l - allocate (x(1:N, 1:N, 1:N, 1:M, 1:3), & - feval(1:N, 1:N, 1:N, 1:M), & - fexact(1:N, 1:N, 1:N, 1:M)) - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) + allocate(x(1:N,1:N,1:N,1:M,1:3), & + feval(1:N,1:N,1:N,1:M), & + fexact(1:N,1:N,1:N,1:M)) + ! Specify the independent variables + independentVars = (/'x','y','z'/) - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )*tanh( y )*tanh( z )' - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) - x = 0.0_real64 - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - x(i, j, k, l, 1) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(i - 1, real64) + 2.0_real64 * real(l - 1, real64) - x(i, j, k, l, 2) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(j - 1, real64) - x(i, j, k, l, 3) = -1.0_real64 + (2.0_real64) / real(N, real64) * real(k - 1, real64) - end do - end do - end do - end do - do l = 1, M - do k = 1, N - do j = 1, N - do i = 1, N - fexact(i, j, k, l) = tanh(x(i, j, k, l, 1)) * tanh(x(i, j, k, l, 2)) * tanh(x(i, j, k, l, 3)) - end do - end do - end do - end do - ! Evaluate the equation - feval = f%evaluate(x) - if (maxval(abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if + x = 0.0_real64 + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + x(i,j,k,l,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64)+2.0_real64*real(l-1,real64) + x(i,j,k,l,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) + x(i,j,k,l,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) + enddo + enddo + enddo + enddo + do l = 1,M + do k = 1,N + do j = 1,N + do i = 1,N + fexact(i,j,k,l) = tanh(x(i,j,k,l,1))*tanh(x(i,j,k,l,2))*tanh(x(i,j,k,l,3)) + enddo + enddo + enddo + enddo + ! Evaluate the equation + feval = f%evaluate(x) + if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif - deallocate (x, feval, fexact) + deallocate(x,feval,fexact) - end function tanh_r4fp64 -end program test + endfunction tanh_r4fp64 +endprogram test diff --git a/test/tanh_sfp32.f90 b/test/tanh_sfp32.f90 index 043c43b..3bd8012 100644 --- a/test/tanh_sfp32.f90 +++ b/test/tanh_sfp32.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tanh_sfp32() - stop exit_code + exit_code = tanh_sfp32() + stop exit_code contains - integer function tanh_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - real(real32) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real32 - fexact = tanh(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real32)) then - r = 0 - else - r = 1 - end if - - end function tanh_sfp32 -end program test + integer function tanh_sfp32() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real32) :: x(1:3) + real(real32) :: feval + real(real32) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real32 + fexact = tanh(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real32)) then + r = 0 + else + r = 1 + endif + + endfunction tanh_sfp32 +endprogram test diff --git a/test/tanh_sfp64.f90 b/test/tanh_sfp64.f90 index ef754d6..0ea7883 100644 --- a/test/tanh_sfp64.f90 +++ b/test/tanh_sfp64.f90 @@ -1,45 +1,45 @@ program test - implicit none - integer :: exit_code + implicit none + integer :: exit_code - exit_code = tanh_sfp64() - stop exit_code + exit_code = tanh_sfp64() + stop exit_code contains - integer function tanh_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer, parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1), dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - real(real64) :: fexact - integer :: i - - ! Specify the independent variables - independentVars = (/'x', 'y', 'z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = tanh( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar, independentVars) - - x = 0.0_real64 - fexact = tanh(x(1)) - - ! Evaluate the equation - feval = f%evaluate(x) - if ((abs(feval - fexact)) <= epsilon(1.0_real64)) then - r = 0 - else - r = 1 - end if - - end function tanh_sfp64 -end program test + integer function tanh_sfp64() result(r) + use FEQParse + use iso_fortran_env + implicit none + integer,parameter :: N = 10 + type(EquationParser) :: f + character(LEN=1),dimension(1:3) :: independentVars + character(LEN=2048) :: eqChar + real(real64) :: x(1:3) + real(real64) :: feval + real(real64) :: fexact + integer :: i + + ! Specify the independent variables + independentVars = (/'x','y','z'/) + + ! Specify an equation string that we want to evaluate + eqChar = 'f = tanh( x )' + + ! Create the EquationParser object + f = EquationParser(eqChar,independentVars) + + x = 0.0_real64 + fexact = tanh(x(1)) + + ! Evaluate the equation + feval = f%evaluate(x) + if((abs(feval-fexact)) <= epsilon(1.0_real64)) then + r = 0 + else + r = 1 + endif + + endfunction tanh_sfp64 +endprogram test From 7c45d0fab422d246a7a412044022516405f54e35 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 12 Feb 2024 08:17:49 -0500 Subject: [PATCH 09/10] Clean up formatting on custom functions work --- src/FEQParse_Functions.F90 | 1068 ++++++++++++++++++------------------ 1 file changed, 534 insertions(+), 534 deletions(-) diff --git a/src/FEQParse_Functions.F90 b/src/FEQParse_Functions.F90 index 4e1bdf0..868ddd4 100644 --- a/src/FEQParse_Functions.F90 +++ b/src/FEQParse_Functions.F90 @@ -12,543 +12,543 @@ ! //////////////////////////////////////////////////////////////////////////////////////////////// ! module FEQParse_Functions - use iso_fortran_env - - implicit none - - integer, public :: nFunctions = 17 - integer, protected, public :: maxFunctionLength = 0 - integer, parameter :: maxFunctions = 100 - logical :: isInitialized = .false. - - enum, bind(c) - enumerator :: cos_function = 1 - enumerator :: cosh_function = 2 - enumerator :: sin_function = 3 - enumerator :: sinh_function = 4 - enumerator :: tan_function = 5 - enumerator :: tanh_function = 6 - enumerator :: sqrt_function = 7 - enumerator :: abs_function = 8 - enumerator :: exp_function = 9 - enumerator :: ln_function = 10 - enumerator :: log_function = 11 - enumerator :: log10_function = 12 - enumerator :: acos_function = 13 - enumerator :: asin_function = 14 - enumerator :: atan_function = 15 - enumerator :: sech_function = 16 - enumerator :: rand_function = 17 - end enum - - private - - public :: InitializeFunctions, & - AddFunction - - interface - pure real(real32) function f32(x) - import - real(real32), intent(in) :: x - end function - end interface - - interface - pure real(real64) function f64(x) - import - real(real64), intent(in) :: x - end function - end interface - - type Tuple - character(:), allocatable :: item1 - character(:), allocatable :: item2 - contains - final :: Tuple_Finalize - end type - - type, public :: FEQParse_Function - integer :: len - character(:), allocatable :: str - character(:), allocatable :: caps - procedure(f32), public, nopass, pointer :: ptr32 => null() - procedure(f64), public, nopass, pointer :: ptr64 => null() - contains - procedure, private, pass(lhs) :: character_array_assign_function - procedure, private, pass(lhs) :: character_assign_function - procedure, private, pass(rhs) :: function_assign_character - generic :: assignment(=) => character_assign_function, character_array_assign_function - procedure, private, pass(lhs) :: function_eq_character - procedure, private, pass(rhs) :: character_eq_function - generic :: operator(==) => function_eq_character, character_eq_function - procedure, private, pass(lhs) :: function_neq_character - procedure, private, pass(rhs) :: character_neq_function - generic :: operator(/=) => function_neq_character, character_neq_function - procedure, private, pass(this) :: invoke32 - procedure, private, pass(this) :: invoke64 - generic :: invoke => invoke32, invoke64 - final :: Function_Finalize - end type FEQParse_Function - - type(FEQParse_Function), public :: Functions(maxFunctions) - - interface - pure real(real32) function randomize_r32() - import - end function - end interface - - interface - pure real(real64) function randomize_r64() - import - end function - end interface - - interface AddFunction - module procedure :: AddFunction32 - module procedure :: AddFunction64 - module procedure :: AddFunction32And64 - end interface - - interface Tuple - module procedure Tuple_new - end interface - - contains - - type(Tuple) function Tuple_new(item1, item2) result(t) - character(*), intent(in) :: item1 - character(*), intent(in) :: item2 - - t%item1 = item1 - t%item2 = item2 - end function - - subroutine Tuple_Finalize(this) - type(Tuple), intent(inout) :: this - if (allocated(this%item1)) deallocate(this%item1) - if (allocated(this%item2)) deallocate(this%item2) - end subroutine - - subroutine Function_Finalize(this) - type(FEQParse_Function), intent(inout) :: this - if (allocated(this%str)) deallocate(this%str) - if (allocated(this%caps)) deallocate(this%caps) - if (associated(this%ptr32)) nullify(this%ptr32) - if (associated(this%ptr64)) nullify(this%ptr64) - end subroutine - - subroutine character_array_assign_function(lhs, rhs) - class(FEQParse_Function), intent(inout) :: lhs !! Left hand side. - class(Tuple), intent(in) :: rhs !! Right hand side. - - lhs%str = rhs%item1 - lhs%len = len(rhs%item1) - lhs%caps = rhs%item2 - maxFunctionLength = max(maxFunctionLength, lhs%len) - end subroutine - - subroutine character_assign_function(lhs, rhs) - class(FEQParse_Function), intent(inout) :: lhs !! Left hand side. - character(len=*), intent(in) :: rhs !! Right hand side. - - lhs%str = rhs - lhs%len = len(rhs) - lhs%caps = ToUpperCase(rhs) - maxFunctionLength = max(maxFunctionLength, lhs%len) - end subroutine - - pure subroutine function_assign_character(lhs, rhs) - character(len=*), allocatable, intent(inout) :: lhs - class(FEQParse_Function), intent(in) :: rhs - lhs = rhs%str - end subroutine - - elemental function function_eq_character(lhs, rhs) result(ok) - class(FEQParse_Function), intent(in) :: lhs !! Left hand side. - character(len=*), intent(in) :: rhs !! Right hand side. - logical :: ok - - ok = lhs%str == rhs .or. lhs%caps == rhs - end function - - elemental function character_eq_function(lhs, rhs) result(ok) - character(len=*), intent(in) :: lhs - class(FEQParse_Function), intent(in) :: rhs - logical :: ok - - ok = lhs == rhs%str .or. lhs == rhs%caps - end function - - elemental function function_neq_character(lhs, rhs) result(ok) - class(FEQParse_Function), intent(in) :: lhs !! Left hand side. - character(len=*), intent(in) :: rhs !! Right hand side. - logical :: ok - - ok = lhs%str /= rhs .or. lhs%caps /= rhs - end function - - elemental function character_neq_function(lhs, rhs) result(ok) - character(len=*), intent(in) :: lhs - class(FEQParse_Function), intent(in) :: rhs - logical :: ok - - ok = lhs /= rhs%str .or. lhs /= rhs%caps - end function - - subroutine InitializeFunctions() - if (isInitialized .eqv. .true.) return - - Functions(cos_function) = Tuple("cos", "COS") - Functions(cos_function)%ptr32 => cos32 - Functions(cos_function)%ptr64 => cos64 - - Functions(cosh_function) = Tuple("cosh", "COSH") - Functions(cosh_function)%ptr32 => cosh32 - Functions(cosh_function)%ptr64 => cosh64 - - Functions(sin_function) = Tuple("sin", "SIN") - Functions(sin_function)%ptr32 => sin32 - Functions(sin_function)%ptr64 => sin64 - - Functions(sinh_function) = Tuple("sinh", "SINH") - Functions(sinh_function)%ptr32 => sinh32 - Functions(sinh_function)%ptr64 => sinh64 - - Functions(tan_function) = Tuple("tan", "TAN") - Functions(tan_function)%ptr32 => tan32 - Functions(tan_function)%ptr64 => tan64 - - Functions(tanh_function) = Tuple("tanh", "TANH") - Functions(tanh_function)%ptr32 => tanh32 - Functions(tanh_function)%ptr64 => tanh64 - - Functions(sqrt_function) = Tuple("sqrt", "SQRT") - Functions(sqrt_function)%ptr32 => sqrt32 - Functions(sqrt_function)%ptr64 => sqrt64 - - Functions(abs_function) = Tuple("abs", "ABS") - Functions(abs_function)%ptr32 => abs32 - Functions(abs_function)%ptr64 => abs64 - - Functions(exp_function) = Tuple("exp", "EXP") - Functions(exp_function)%ptr32 => exp32 - Functions(exp_function)%ptr64 => exp64 - - Functions(ln_function) = Tuple("ln", "LN") - Functions(ln_function)%ptr32 => log32 - Functions(ln_function)%ptr64 => log64 - - Functions(log_function) = Tuple("log", "LOG") - Functions(log_function)%ptr32 => log32 - Functions(log_function)%ptr64 => log64 - - Functions(log10_function) = Tuple("log10", "LOG10") - Functions(log10_function)%ptr32 => log1032 - Functions(log10_function)%ptr64 => log1064 - - Functions(acos_function) = Tuple("acos", "ACOS") - Functions(acos_function)%ptr32 => acos32 - Functions(acos_function)%ptr64 => acos64 - - Functions(asin_function) = Tuple("asin", "ASIN") - Functions(asin_function)%ptr32 => asin32 - Functions(asin_function)%ptr64 => asin64 - - Functions(atan_function) = Tuple("atan", "ATAN") - Functions(atan_function)%ptr32 => atan32 - Functions(atan_function)%ptr64 => atan64 - - Functions(sech_function) = Tuple("sech", "SECH") - Functions(sech_function)%ptr32 => sech32 - Functions(sech_function)%ptr64 => sech64 - - Functions(rand_function) = Tuple("rand", "RAND") - Functions(rand_function)%ptr32 => rand32 - Functions(rand_function)%ptr64 => rand64 - - isInitialized = .true. - end subroutine InitializeFunctions - - subroutine AddFunction32(name, f_32) - character(*), intent(in) :: name - procedure(f32) :: f_32 - !private - type(FEQParse_Function) :: func - - call InitializeFunctions() - func = name - func%ptr32 => f_32 - func%ptr64 => null() - if (nFunctions < maxFunctions) then - Functions(nFunctions + 1) = func - nFunctions = nFunctions + 1 - else - stop 'Argument out of range' - end if - end subroutine - - subroutine AddFunction64(name, f_64) - character(*), intent(in) :: name - procedure(f64) :: f_64 - !private - type(FEQParse_Function) :: func - - call InitializeFunctions() - func = name - func%ptr32 => null() - func%ptr64 => f_64 - if (nFunctions < maxFunctions) then - Functions(nFunctions + 1) = func - nFunctions = nFunctions + 1 - else - stop 'Argument out of range' - end if - end subroutine - - subroutine AddFunction32And64(name, f_32, f_64) - character(*), intent(in) :: name - procedure(f32) :: f_32 - procedure(f64) :: f_64 - !private - type(FEQParse_Function) :: func - - call InitializeFunctions() - func = name - func%ptr32 => f_32 - func%ptr64 => f_64 - if (nFunctions < maxFunctions) then - Functions(nFunctions + 1) = func - nFunctions = nFunctions + 1 - else - stop 'Argument out of range' - end if - end subroutine - - elemental real(real32) function invoke32(this, x) result(fx) - class(FEQParse_Function), intent(in) :: this - real(real32), intent(in) :: x - fx = this%ptr32(x) - end function - - elemental real(real64) function invoke64(this, x) result(fx) - class(FEQParse_Function), intent(in) :: this - real(real64), intent(in) :: x - fx = this%ptr64(x) - end function - - pure real(real32) function cos32(x) result(fx) - real(real32), intent(in) :: x - fx = cos(x) - end function - - pure real(real64) function cos64(x) result(fx) - real(real64), intent(in) :: x - fx = cos(x) - end function - - pure real(real32) function cosh32(x) result(fx) - real(real32), intent(in) :: x - fx = cosh(x) - end function - - pure real(real64) function cosh64(x) result(fx) - real(real64), intent(in) :: x - fx = cosh(x) - end function - - pure real(real32) function sin32(x) result(fx) - real(real32), intent(in) :: x - fx = sin(x) - end function - - pure real(real64) function sin64(x) result(fx) - real(real64), intent(in) :: x - fx = sin(x) - end function - - pure real(real32) function sinh32(x) result(fx) - real(real32), intent(in) :: x - fx = sinh(x) - end function - - pure real(real64) function sinh64(x) result(fx) - real(real64), intent(in) :: x - fx = sinh(x) - end function - - pure real(real32) function tan32(x) result(fx) - real(real32), intent(in) :: x - fx = tan(x) - end function - - pure real(real64) function tan64(x) result(fx) - real(real64), intent(in) :: x - fx = tan(x) - end function - - pure real(real32) function tanh32(x) result(fx) - real(real32), intent(in) :: x - fx = tanh(x) - end function - - pure real(real64) function tanh64(x) result(fx) - real(real64), intent(in) :: x - fx = tanh(x) - end function - - pure real(real32) function sqrt32(x) result(fx) - real(real32), intent(in) :: x - fx = sqrt(x) - end function - - pure real(real64) function sqrt64(x) result(fx) - real(real64), intent(in) :: x - fx = sqrt(x) - end function - - pure real(real32) function abs32(x) result(fx) - real(real32), intent(in) :: x - fx = abs(x) - end function - - pure real(real64) function abs64(x) result(fx) - real(real64), intent(in) :: x - fx = abs(x) - end function - - pure real(real32) function exp32(x) result(fx) - real(real32), intent(in) :: x - fx = exp(x) - end function - - pure real(real64) function exp64(x) result(fx) - real(real64), intent(in) :: x - fx = exp(x) - end function - - pure real(real32) function log32(x) result(fx) - real(real32), intent(in) :: x - fx = log(x) - end function - - pure real(real64) function log64(x) result(fx) - real(real64), intent(in) :: x - fx = log(x) - end function - - pure real(real32) function log1032(x) result(fx) - real(real32), intent(in) :: x - fx = log10(x) - end function - - pure real(real64) function log1064(x) result(fx) - real(real64), intent(in) :: x - fx = log10(x) - end function - - pure real(real32) function acos32(x) result(fx) - real(real32), intent(in) :: x - fx = acos(x) - end function - - pure real(real64) function acos64(x) result(fx) - real(real64), intent(in) :: x - fx = acos(x) - end function - - pure real(real32) function asin32(x) result(fx) - real(real32), intent(in) :: x - fx = asin(x) - end function - - pure real(real64) function asin64(x) result(fx) - real(real64), intent(in) :: x - fx = asin(x) - end function - - pure real(real32) function atan32(x) result(fx) - real(real32), intent(in) :: x - fx = atan(x) - end function - - pure real(real64) function atan64(x) result(fx) - real(real64), intent(in) :: x - fx = atan(x) - end function - - pure real(real32) function sech32(x) result(fx) - real(real32), intent(in) :: x - fx = 2.0_real32 / (exp(x) + exp(-x)) - end function - - pure real(real64) function sech64(x) result(fx) - real(real64), intent(in) :: x - fx = 2.0_real64 / (exp(x) + exp(-x)) - end function - - pure real(real32) function rand32(x) result(fx) - real(real32), intent(in) :: x - !private - real(real32) :: r - associate (r => randomize_r32()) - fx = r * x - end associate - end function - - pure real(real64) function rand64(x) result(fx) - real(real64), intent(in) :: x - !private - real(real64) :: r - associate (r => randomize_r64()) - fx = r * x - end associate - end function - - pure function ToUpperCase(str) result(res) - character(*), intent(in) :: str - character(len(str)) :: res - integer :: i, j - - do i = 1, len(str) - select case (str(i:i)) - case ('a':'z') - res(i:i) = achar(iachar(str(i:i)) - 32) - case default - res(i:i) = str(i:i) - end select - end do - end function ToUpperCase - - pure function ToLowerCase(str) result(res) - character(*), intent(in) :: str - character(len(str)), allocatable :: res - integer :: i - - do i = 1, len(str) - select case (str(i:i)) - case ('A':'Z') - res(i:i) = achar(iachar(str(i:i)) + 32) - case default - res(i:i) = str(i:i) - end select - end do - end function ToLowerCase - -end module FEQParse_Functions + use iso_fortran_env + + implicit none + + integer,public :: nFunctions = 17 + integer,protected,public :: maxFunctionLength = 0 + integer,parameter :: maxFunctions = 100 + logical :: isInitialized = .false. + + enum,bind(c) + enumerator :: cos_function = 1 + enumerator :: cosh_function = 2 + enumerator :: sin_function = 3 + enumerator :: sinh_function = 4 + enumerator :: tan_function = 5 + enumerator :: tanh_function = 6 + enumerator :: sqrt_function = 7 + enumerator :: abs_function = 8 + enumerator :: exp_function = 9 + enumerator :: ln_function = 10 + enumerator :: log_function = 11 + enumerator :: log10_function = 12 + enumerator :: acos_function = 13 + enumerator :: asin_function = 14 + enumerator :: atan_function = 15 + enumerator :: sech_function = 16 + enumerator :: rand_function = 17 + endenum + + private + + public :: InitializeFunctions, & + AddFunction + + interface + pure real(real32) function f32(x) + import + real(real32),intent(in) :: x + endfunction + endinterface + + interface + pure real(real64) function f64(x) + import + real(real64),intent(in) :: x + endfunction + endinterface + + type Tuple + character(:),allocatable :: item1 + character(:),allocatable :: item2 + contains + final :: Tuple_Finalize + endtype + + type,public :: FEQParse_Function + integer :: len + character(:),allocatable :: str + character(:),allocatable :: caps + procedure(f32),public,nopass,pointer :: ptr32 => null() + procedure(f64),public,nopass,pointer :: ptr64 => null() + contains + procedure,private,pass(lhs) :: character_array_assign_function + procedure,private,pass(lhs) :: character_assign_function + procedure,private,pass(rhs) :: function_assign_character + generic :: assignment(=) => character_assign_function,character_array_assign_function + procedure,private,pass(lhs) :: function_eq_character + procedure,private,pass(rhs) :: character_eq_function + generic :: operator(==) => function_eq_character,character_eq_function + procedure,private,pass(lhs) :: function_neq_character + procedure,private,pass(rhs) :: character_neq_function + generic :: operator(/=) => function_neq_character,character_neq_function + procedure,private,pass(this) :: invoke32 + procedure,private,pass(this) :: invoke64 + generic :: invoke => invoke32,invoke64 + final :: Function_Finalize + endtype FEQParse_Function + + type(FEQParse_Function),public :: Functions(maxFunctions) + + interface + pure real(real32) function randomize_r32() + import + endfunction + endinterface + + interface + pure real(real64) function randomize_r64() + import + endfunction + endinterface + + interface AddFunction + module procedure :: AddFunction32 + module procedure :: AddFunction64 + module procedure :: AddFunction32And64 + endinterface + + interface Tuple + module procedure Tuple_new + endinterface + +contains + + type(Tuple) function Tuple_new(item1,item2) result(t) + character(*),intent(in) :: item1 + character(*),intent(in) :: item2 + + t%item1 = item1 + t%item2 = item2 + endfunction + + subroutine Tuple_Finalize(this) + type(Tuple),intent(inout) :: this + if(allocated(this%item1)) deallocate(this%item1) + if(allocated(this%item2)) deallocate(this%item2) + endsubroutine + + subroutine Function_Finalize(this) + type(FEQParse_Function),intent(inout) :: this + if(allocated(this%str)) deallocate(this%str) + if(allocated(this%caps)) deallocate(this%caps) + if(associated(this%ptr32)) nullify(this%ptr32) + if(associated(this%ptr64)) nullify(this%ptr64) + endsubroutine + + subroutine character_array_assign_function(lhs,rhs) + class(FEQParse_Function),intent(inout) :: lhs !! Left hand side. + class(Tuple),intent(in) :: rhs !! Right hand side. + + lhs%str = rhs%item1 + lhs%len = len(rhs%item1) + lhs%caps = rhs%item2 + maxFunctionLength = max(maxFunctionLength,lhs%len) + endsubroutine + + subroutine character_assign_function(lhs,rhs) + class(FEQParse_Function),intent(inout) :: lhs !! Left hand side. + character(len=*),intent(in) :: rhs !! Right hand side. + + lhs%str = rhs + lhs%len = len(rhs) + lhs%caps = ToUpperCase(rhs) + maxFunctionLength = max(maxFunctionLength,lhs%len) + endsubroutine + + pure subroutine function_assign_character(lhs,rhs) + character(len=*),allocatable,intent(inout) :: lhs + class(FEQParse_Function),intent(in) :: rhs + lhs = rhs%str + endsubroutine + + elemental function function_eq_character(lhs,rhs) result(ok) + class(FEQParse_Function),intent(in) :: lhs !! Left hand side. + character(len=*),intent(in) :: rhs !! Right hand side. + logical :: ok + + ok = lhs%str == rhs .or. lhs%caps == rhs + endfunction + + elemental function character_eq_function(lhs,rhs) result(ok) + character(len=*),intent(in) :: lhs + class(FEQParse_Function),intent(in) :: rhs + logical :: ok + + ok = lhs == rhs%str .or. lhs == rhs%caps + endfunction + + elemental function function_neq_character(lhs,rhs) result(ok) + class(FEQParse_Function),intent(in) :: lhs !! Left hand side. + character(len=*),intent(in) :: rhs !! Right hand side. + logical :: ok + + ok = lhs%str /= rhs .or. lhs%caps /= rhs + endfunction + + elemental function character_neq_function(lhs,rhs) result(ok) + character(len=*),intent(in) :: lhs + class(FEQParse_Function),intent(in) :: rhs + logical :: ok + + ok = lhs /= rhs%str .or. lhs /= rhs%caps + endfunction + + subroutine InitializeFunctions() + if(isInitialized .eqv. .true.) return + + Functions(cos_function) = Tuple("cos","COS") + Functions(cos_function)%ptr32 => cos32 + Functions(cos_function)%ptr64 => cos64 + + Functions(cosh_function) = Tuple("cosh","COSH") + Functions(cosh_function)%ptr32 => cosh32 + Functions(cosh_function)%ptr64 => cosh64 + + Functions(sin_function) = Tuple("sin","SIN") + Functions(sin_function)%ptr32 => sin32 + Functions(sin_function)%ptr64 => sin64 + + Functions(sinh_function) = Tuple("sinh","SINH") + Functions(sinh_function)%ptr32 => sinh32 + Functions(sinh_function)%ptr64 => sinh64 + + Functions(tan_function) = Tuple("tan","TAN") + Functions(tan_function)%ptr32 => tan32 + Functions(tan_function)%ptr64 => tan64 + + Functions(tanh_function) = Tuple("tanh","TANH") + Functions(tanh_function)%ptr32 => tanh32 + Functions(tanh_function)%ptr64 => tanh64 + + Functions(sqrt_function) = Tuple("sqrt","SQRT") + Functions(sqrt_function)%ptr32 => sqrt32 + Functions(sqrt_function)%ptr64 => sqrt64 + + Functions(abs_function) = Tuple("abs","ABS") + Functions(abs_function)%ptr32 => abs32 + Functions(abs_function)%ptr64 => abs64 + + Functions(exp_function) = Tuple("exp","EXP") + Functions(exp_function)%ptr32 => exp32 + Functions(exp_function)%ptr64 => exp64 + + Functions(ln_function) = Tuple("ln","LN") + Functions(ln_function)%ptr32 => log32 + Functions(ln_function)%ptr64 => log64 + + Functions(log_function) = Tuple("log","LOG") + Functions(log_function)%ptr32 => log32 + Functions(log_function)%ptr64 => log64 + + Functions(log10_function) = Tuple("log10","LOG10") + Functions(log10_function)%ptr32 => log1032 + Functions(log10_function)%ptr64 => log1064 + + Functions(acos_function) = Tuple("acos","ACOS") + Functions(acos_function)%ptr32 => acos32 + Functions(acos_function)%ptr64 => acos64 + + Functions(asin_function) = Tuple("asin","ASIN") + Functions(asin_function)%ptr32 => asin32 + Functions(asin_function)%ptr64 => asin64 + + Functions(atan_function) = Tuple("atan","ATAN") + Functions(atan_function)%ptr32 => atan32 + Functions(atan_function)%ptr64 => atan64 + + Functions(sech_function) = Tuple("sech","SECH") + Functions(sech_function)%ptr32 => sech32 + Functions(sech_function)%ptr64 => sech64 + + Functions(rand_function) = Tuple("rand","RAND") + Functions(rand_function)%ptr32 => rand32 + Functions(rand_function)%ptr64 => rand64 + + isInitialized = .true. + endsubroutine InitializeFunctions + + subroutine AddFunction32(name,f_32) + character(*),intent(in) :: name + procedure(f32) :: f_32 + !private + type(FEQParse_Function) :: func + + call InitializeFunctions() + func = name + func%ptr32 => f_32 + func%ptr64 => null() + if(nFunctions < maxFunctions) then + Functions(nFunctions+1) = func + nFunctions = nFunctions+1 + else + stop 'Argument out of range' + endif + endsubroutine + + subroutine AddFunction64(name,f_64) + character(*),intent(in) :: name + procedure(f64) :: f_64 + !private + type(FEQParse_Function) :: func + + call InitializeFunctions() + func = name + func%ptr32 => null() + func%ptr64 => f_64 + if(nFunctions < maxFunctions) then + Functions(nFunctions+1) = func + nFunctions = nFunctions+1 + else + stop 'Argument out of range' + endif + endsubroutine + + subroutine AddFunction32And64(name,f_32,f_64) + character(*),intent(in) :: name + procedure(f32) :: f_32 + procedure(f64) :: f_64 + !private + type(FEQParse_Function) :: func + + call InitializeFunctions() + func = name + func%ptr32 => f_32 + func%ptr64 => f_64 + if(nFunctions < maxFunctions) then + Functions(nFunctions+1) = func + nFunctions = nFunctions+1 + else + stop 'Argument out of range' + endif + endsubroutine + + elemental real(real32) function invoke32(this,x) result(fx) + class(FEQParse_Function),intent(in) :: this + real(real32),intent(in) :: x + fx = this%ptr32(x) + endfunction + + elemental real(real64) function invoke64(this,x) result(fx) + class(FEQParse_Function),intent(in) :: this + real(real64),intent(in) :: x + fx = this%ptr64(x) + endfunction + + pure real(real32) function cos32(x) result(fx) + real(real32),intent(in) :: x + fx = cos(x) + endfunction + + pure real(real64) function cos64(x) result(fx) + real(real64),intent(in) :: x + fx = cos(x) + endfunction + + pure real(real32) function cosh32(x) result(fx) + real(real32),intent(in) :: x + fx = cosh(x) + endfunction + + pure real(real64) function cosh64(x) result(fx) + real(real64),intent(in) :: x + fx = cosh(x) + endfunction + + pure real(real32) function sin32(x) result(fx) + real(real32),intent(in) :: x + fx = sin(x) + endfunction + + pure real(real64) function sin64(x) result(fx) + real(real64),intent(in) :: x + fx = sin(x) + endfunction + + pure real(real32) function sinh32(x) result(fx) + real(real32),intent(in) :: x + fx = sinh(x) + endfunction + + pure real(real64) function sinh64(x) result(fx) + real(real64),intent(in) :: x + fx = sinh(x) + endfunction + + pure real(real32) function tan32(x) result(fx) + real(real32),intent(in) :: x + fx = tan(x) + endfunction + + pure real(real64) function tan64(x) result(fx) + real(real64),intent(in) :: x + fx = tan(x) + endfunction + + pure real(real32) function tanh32(x) result(fx) + real(real32),intent(in) :: x + fx = tanh(x) + endfunction + + pure real(real64) function tanh64(x) result(fx) + real(real64),intent(in) :: x + fx = tanh(x) + endfunction + + pure real(real32) function sqrt32(x) result(fx) + real(real32),intent(in) :: x + fx = sqrt(x) + endfunction + + pure real(real64) function sqrt64(x) result(fx) + real(real64),intent(in) :: x + fx = sqrt(x) + endfunction + + pure real(real32) function abs32(x) result(fx) + real(real32),intent(in) :: x + fx = abs(x) + endfunction + + pure real(real64) function abs64(x) result(fx) + real(real64),intent(in) :: x + fx = abs(x) + endfunction + + pure real(real32) function exp32(x) result(fx) + real(real32),intent(in) :: x + fx = exp(x) + endfunction + + pure real(real64) function exp64(x) result(fx) + real(real64),intent(in) :: x + fx = exp(x) + endfunction + + pure real(real32) function log32(x) result(fx) + real(real32),intent(in) :: x + fx = log(x) + endfunction + + pure real(real64) function log64(x) result(fx) + real(real64),intent(in) :: x + fx = log(x) + endfunction + + pure real(real32) function log1032(x) result(fx) + real(real32),intent(in) :: x + fx = log10(x) + endfunction + + pure real(real64) function log1064(x) result(fx) + real(real64),intent(in) :: x + fx = log10(x) + endfunction + + pure real(real32) function acos32(x) result(fx) + real(real32),intent(in) :: x + fx = acos(x) + endfunction + + pure real(real64) function acos64(x) result(fx) + real(real64),intent(in) :: x + fx = acos(x) + endfunction + + pure real(real32) function asin32(x) result(fx) + real(real32),intent(in) :: x + fx = asin(x) + endfunction + + pure real(real64) function asin64(x) result(fx) + real(real64),intent(in) :: x + fx = asin(x) + endfunction + + pure real(real32) function atan32(x) result(fx) + real(real32),intent(in) :: x + fx = atan(x) + endfunction + + pure real(real64) function atan64(x) result(fx) + real(real64),intent(in) :: x + fx = atan(x) + endfunction + + pure real(real32) function sech32(x) result(fx) + real(real32),intent(in) :: x + fx = 2.0_real32/(exp(x)+exp(-x)) + endfunction + + pure real(real64) function sech64(x) result(fx) + real(real64),intent(in) :: x + fx = 2.0_real64/(exp(x)+exp(-x)) + endfunction + + pure real(real32) function rand32(x) result(fx) + real(real32),intent(in) :: x + !private + real(real32) :: r + associate(r => randomize_r32()) + fx = r*x + endassociate + endfunction + + pure real(real64) function rand64(x) result(fx) + real(real64),intent(in) :: x + !private + real(real64) :: r + associate(r => randomize_r64()) + fx = r*x + endassociate + endfunction + + pure function ToUpperCase(str) result(res) + character(*),intent(in) :: str + character(len(str)) :: res + integer :: i,j + + do i = 1,len(str) + select case(str(i:i)) + case('a':'z') + res(i:i) = achar(iachar(str(i:i))-32) + case default + res(i:i) = str(i:i) + endselect + enddo + endfunction ToUpperCase + + pure function ToLowerCase(str) result(res) + character(*),intent(in) :: str + character(len(str)),allocatable :: res + integer :: i + + do i = 1,len(str) + select case(str(i:i)) + case('A':'Z') + res(i:i) = achar(iachar(str(i:i))+32) + case default + res(i:i) = str(i:i) + endselect + enddo + endfunction ToLowerCase + +endmodule FEQParse_Functions real(real32) function randomize_r32() - use, intrinsic :: iso_fortran_env, only: real32 - real(real32) :: r + use,intrinsic :: iso_fortran_env,only:real32 + real(real32) :: r - call random_number(r) - randomize_r32 = r -end function + call random_number(r) + randomize_r32 = r +endfunction real(real64) function randomize_r64() - use, intrinsic :: iso_fortran_env, only: real64 - real(real64) :: r + use,intrinsic :: iso_fortran_env,only:real64 + real(real64) :: r - call random_number(r) - randomize_r64 = r -end function + call random_number(r) + randomize_r64 = r +endfunction From 233a7e5317526aec0acefbf7f144c481758dde81 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 12 Feb 2024 08:21:16 -0500 Subject: [PATCH 10/10] Clean up workflow names --- .github/workflows/linux-gnu-fpm.yml | 2 +- .github/workflows/linux-intel-fpm.yml | 2 +- .github/workflows/windows-gnu-fpm.yml | 8 +------- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/linux-gnu-fpm.yml b/.github/workflows/linux-gnu-fpm.yml index 95a2b85..cb1255f 100644 --- a/.github/workflows/linux-gnu-fpm.yml +++ b/.github/workflows/linux-gnu-fpm.yml @@ -24,7 +24,7 @@ jobs: linux-tests: timeout-minutes: 8 if: "!contains(github.event.head_commit.message, 'skip ci')" - name: ${{ matrix.os }} - ${{ matrix.fcompiler }} - ${{ matrix.build_type }} + name: ${{ matrix.os }} - ${{ matrix.fcompiler }} runs-on: ${{ matrix.os }} strategy: fail-fast: false diff --git a/.github/workflows/linux-intel-fpm.yml b/.github/workflows/linux-intel-fpm.yml index 77e626b..027d9a5 100644 --- a/.github/workflows/linux-intel-fpm.yml +++ b/.github/workflows/linux-intel-fpm.yml @@ -24,7 +24,7 @@ jobs: linux-tests: timeout-minutes: 8 if: "!contains(github.event.head_commit.message, 'skip ci')" - name: ${{ matrix.os }} - ${{ matrix.fcompiler }} - ${{ matrix.build_type }} + name: ${{ matrix.os }} - ${{ matrix.fcompiler }} runs-on: ${{ matrix.os }} strategy: fail-fast: false diff --git a/.github/workflows/windows-gnu-fpm.yml b/.github/workflows/windows-gnu-fpm.yml index 1924ac0..475908e 100644 --- a/.github/workflows/windows-gnu-fpm.yml +++ b/.github/workflows/windows-gnu-fpm.yml @@ -24,7 +24,7 @@ jobs: windows-tests: timeout-minutes: 8 if: "!contains(github.event.head_commit.message, 'skip ci')" - name: ${{ matrix.os }} - ${{ matrix.fcompiler }} - ${{ matrix.build_type }} + name: ${{ matrix.os }} - ${{ matrix.fcompiler }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -32,12 +32,6 @@ jobs: include: # Windows - - os: windows-latest - fcompiler: gfortran - ccompiler: gcc - shell: 'msys2 {0}' - build_type: debug - - os: windows-latest fcompiler: gfortran ccompiler: gcc