├── .github ├── FUNDING.yml └── workflows │ ├── fprettify-lint.yml │ ├── linux-amdflang-cmake.yaml │ ├── linux-gnu-cmake.yml │ ├── linux-gnu-fpm.yml │ ├── linux-intel-cmake.yml │ ├── linux-intel-fpm.yml │ ├── linux-nvfortran-cmake.yaml │ ├── release-deb.yml │ ├── windows-gnu-cmake.yml │ └── windows-gnu-fpm.yml ├── .gitignore ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── docs ├── assets │ └── images │ │ ├── favicon.png │ │ ├── logo-fluid-numerics.png │ │ └── tutorials │ │ └── traveling-shock │ │ └── initial-condition.png ├── build-with-feqparse.md ├── ford │ ├── css │ │ ├── bootstrap.css │ │ ├── bootstrap.min.css │ │ ├── font-awesome.css │ │ ├── font-awesome.min.css │ │ ├── local.css │ │ └── pygments.css │ ├── favicon.png │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ ├── index.html │ ├── interface │ │ ├── addfunction.html │ │ ├── equationparser.html │ │ ├── f32.html │ │ ├── f64.html │ │ ├── randomize_r32.html │ │ ├── randomize_r64.html │ │ └── tuple.html │ ├── js │ │ ├── MathJax-config │ │ │ └── .gitignore │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── ie10-viewport-bug-workaround.js │ │ ├── jquery-2.1.3.min.js │ │ └── svg-pan-zoom.min.js │ ├── lists │ │ ├── files.html │ │ ├── modules.html │ │ ├── procedures.html │ │ └── types.html │ ├── module │ │ ├── feqparse.html │ │ ├── feqparse_floatstacks.html │ │ ├── feqparse_functions.html │ │ └── feqparse_tokenstack.html │ ├── proc │ │ ├── abs32.html │ │ ├── abs64.html │ │ ├── acos32.html │ │ ├── acos64.html │ │ ├── addfunction32.html │ │ ├── addfunction64.html │ │ ├── asin32.html │ │ ├── asin64.html │ │ ├── atan32.html │ │ ├── atan64.html │ │ ├── character_array_assign_function.html │ │ ├── character_assign_function.html │ │ ├── character_eq_function.html │ │ ├── character_neq_function.html │ │ ├── cleanequation.html │ │ ├── construct_equationparser.html │ │ ├── construct_r1fp32stack.html │ │ ├── construct_r1fp64stack.html │ │ ├── construct_r2fp32stack.html │ │ ├── construct_r2fp64stack.html │ │ ├── construct_r3fp32stack.html │ │ ├── construct_r3fp64stack.html │ │ ├── construct_r4fp32stack.html │ │ ├── construct_r4fp64stack.html │ │ ├── construct_sfp32stack.html │ │ ├── construct_sfp64stack.html │ │ ├── construct_tokenstack.html │ │ ├── converttopostfix.html │ │ ├── copy.html │ │ ├── cos32.html │ │ ├── cos64.html │ │ ├── cosh32.html │ │ ├── cosh64.html │ │ ├── evaluate_r1fp32.html │ │ ├── evaluate_r1fp64.html │ │ ├── evaluate_r2fp32.html │ │ ├── evaluate_r2fp64.html │ │ ├── evaluate_r3fp32.html │ │ ├── evaluate_r3fp64.html │ │ ├── evaluate_r4fp32.html │ │ ├── evaluate_r4fp64.html │ │ ├── evaluate_sfp32.html │ │ ├── evaluate_sfp64.html │ │ ├── exp32.html │ │ ├── exp64.html │ │ ├── finalize_equationparser.html │ │ ├── finalize_r1fp32stack.html │ │ ├── finalize_r1fp64stack.html │ │ ├── finalize_r2fp32stack.html │ │ ├── finalize_r2fp64stack.html │ │ ├── finalize_r3fp32stack.html │ │ ├── finalize_r3fp64stack.html │ │ ├── finalize_r4fp32stack.html │ │ ├── finalize_r4fp64stack.html │ │ ├── finalize_sfp32stack.html │ │ ├── finalize_sfp64stack.html │ │ ├── finalize_tokenstack.html │ │ ├── function_eq_character.html │ │ ├── function_finalize.html │ │ ├── function_neq_character.html │ │ ├── initializefunctions.html │ │ ├── invoke32.html │ │ ├── invoke64.html │ │ ├── isempty_tokenstack.html │ │ ├── isfunction.html │ │ ├── isnumber.html │ │ ├── isoperator.html │ │ ├── isseparator.html │ │ ├── isvariable.html │ │ ├── log1032.html │ │ ├── log1064.html │ │ ├── log32.html │ │ ├── log64.html │ │ ├── pop_r1fp32stack.html │ │ ├── pop_r1fp64stack.html │ │ ├── pop_r2fp32stack.html │ │ ├── pop_r2fp64stack.html │ │ ├── pop_r3fp32stack.html │ │ ├── pop_r3fp64stack.html │ │ ├── pop_r4fp32stack.html │ │ ├── pop_r4fp64stack.html │ │ ├── pop_sfp32stack.html │ │ ├── pop_sfp64stack.html │ │ ├── pop_tokenstack.html │ │ ├── print_infixtokens.html │ │ ├── print_postfixtokens.html │ │ ├── priority.html │ │ ├── push_r1fp32stack.html │ │ ├── push_r1fp64stack.html │ │ ├── push_r2fp32stack.html │ │ ├── push_r2fp64stack.html │ │ ├── push_r3fp32stack.html │ │ ├── push_r3fp64stack.html │ │ ├── push_r4fp32stack.html │ │ ├── push_r4fp64stack.html │ │ ├── push_sfp32stack.html │ │ ├── push_sfp64stack.html │ │ ├── push_tokenstack.html │ │ ├── rand32.html │ │ ├── rand64.html │ │ ├── randomize_r32.html │ │ ├── randomize_r64.html │ │ ├── replacestr.html │ │ ├── sech32.html │ │ ├── sech64.html │ │ ├── sin32.html │ │ ├── sin64.html │ │ ├── sinh32.html │ │ ├── sinh64.html │ │ ├── sqrt32.html │ │ ├── sqrt64.html │ │ ├── tan32.html │ │ ├── tan64.html │ │ ├── tanh32.html │ │ ├── tanh64.html │ │ ├── tokenize.html │ │ ├── toptoken.html │ │ ├── touppercase.html │ │ ├── tuple_finalize.html │ │ └── tuple_new.html │ ├── search.html │ ├── sourcefile │ │ ├── feqparse.f90.html │ │ ├── feqparse_floatstacks.f90.html │ │ ├── feqparse_functions.f90.html │ │ └── feqparse_tokenstack.f90.html │ ├── src │ │ ├── FEQParse.f90 │ │ ├── FEQParse_FloatStacks.f90 │ │ ├── FEQParse_Functions.f90 │ │ └── FEQParse_TokenStack.f90 │ ├── tipuesearch │ │ ├── img │ │ │ ├── loader.gif │ │ │ └── search.png │ │ ├── tipuesearch.css │ │ ├── tipuesearch.js │ │ ├── tipuesearch.min.js │ │ ├── tipuesearch_content.js │ │ └── tipuesearch_set.js │ └── type │ │ ├── equationparser.html │ │ ├── feqparse_floatstack.html │ │ ├── feqparse_function.html │ │ ├── indepvar.html │ │ ├── r1fp32stack.html │ │ ├── r1fp64stack.html │ │ ├── r2fp32stack.html │ │ ├── r2fp64stack.html │ │ ├── r3fp32stack.html │ │ ├── r3fp64stack.html │ │ ├── r4fp32stack.html │ │ ├── r4fp64stack.html │ │ ├── sfp32stack.html │ │ ├── sfp64stack.html │ │ ├── token.html │ │ ├── tokenstack.html │ │ └── tuple.html ├── index.md └── parsing-equations.md ├── example ├── array_with_array_eval.f90 ├── array_with_scalar_eval.f90 ├── gaussian_scalar_multivar.f90 ├── scalar_function_product.f90 └── scalar_with_scalar_eval.f90 ├── feq-parse.md ├── fpm.toml ├── fprettify.config ├── mkdocs.yml ├── src ├── CMakeLists.txt ├── FEQParse.f90 ├── FEQParse_FloatStacks.f90 ├── FEQParse_Functions.f90 └── FEQParse_TokenStack.f90 └── test ├── CMakeLists.txt ├── abs_r1fp32.f90 ├── abs_r1fp64.f90 ├── abs_r2fp32.f90 ├── abs_r2fp64.f90 ├── abs_r3fp32.f90 ├── abs_r3fp64.f90 ├── abs_r4fp32.f90 ├── abs_r4fp64.f90 ├── abs_sfp32.f90 ├── abs_sfp64.f90 ├── acos_r1fp32.f90 ├── acos_r1fp64.f90 ├── acos_r2fp32.f90 ├── acos_r2fp64.f90 ├── acos_r3fp32.f90 ├── acos_r3fp64.f90 ├── acos_r4fp32.f90 ├── acos_r4fp64.f90 ├── acos_sfp32.f90 ├── acos_sfp64.f90 ├── asin_r1fp32.f90 ├── asin_r1fp64.f90 ├── asin_r2fp32.f90 ├── asin_r2fp64.f90 ├── asin_r3fp32.f90 ├── asin_r3fp64.f90 ├── asin_r4fp32.f90 ├── asin_r4fp64.f90 ├── asin_sfp32.f90 ├── asin_sfp64.f90 ├── atan_r1fp32.f90 ├── atan_r1fp64.f90 ├── atan_r2fp32.f90 ├── atan_r2fp64.f90 ├── atan_r3fp32.f90 ├── atan_r3fp64.f90 ├── atan_r4fp32.f90 ├── atan_r4fp64.f90 ├── atan_sfp32.f90 ├── atan_sfp64.f90 ├── cos_r1fp32.f90 ├── cos_r1fp64.f90 ├── cos_r2fp32.f90 ├── cos_r2fp64.f90 ├── cos_r3fp32.f90 ├── cos_r3fp64.f90 ├── cos_r4fp32.f90 ├── cos_r4fp64.f90 ├── cos_sfp32.f90 ├── cos_sfp64.f90 ├── cosh_r1fp32.f90 ├── cosh_r1fp64.f90 ├── custom_r1fp64.f90 ├── division_r1fp32.f90 ├── division_r1fp64.f90 ├── division_r2fp32.f90 ├── division_r2fp64.f90 ├── division_r3fp32.f90 ├── division_r3fp64.f90 ├── division_r4fp32.f90 ├── division_r4fp64.f90 ├── division_sfp32.f90 ├── division_sfp64.f90 ├── gaussian3d_r1fp32.f90 ├── gaussian3d_r1fp64.f90 ├── gaussian3d_r2fp32.f90 ├── gaussian3d_r2fp64.f90 ├── gaussian3d_r3fp32.f90 ├── gaussian3d_r3fp64.f90 ├── gaussian3d_r4fp32.f90 ├── gaussian3d_r4fp64.f90 ├── gaussian3d_sfp32.f90 ├── gaussian3d_sfp64.f90 ├── linear_r1fp32.f90 ├── linear_r1fp64.f90 ├── linear_r2fp32.f90 ├── linear_r2fp64.f90 ├── linear_r3fp32.f90 ├── linear_r3fp64.f90 ├── linear_r4fp32.f90 ├── linear_r4fp64.f90 ├── log10_r1fp32.f90 ├── log10_r1fp64.f90 ├── log10_r2fp32.f90 ├── log10_r2fp64.f90 ├── log10_r3fp32.f90 ├── log10_r3fp64.f90 ├── log10_r4fp32.f90 ├── log10_r4fp64.f90 ├── log10_sfp32.f90 ├── log10_sfp64.f90 ├── log_r1fp32.f90 ├── log_r1fp64.f90 ├── log_r2fp32.f90 ├── log_r2fp64.f90 ├── log_r3fp32.f90 ├── log_r3fp64.f90 ├── log_r4fp32.f90 ├── log_r4fp64.f90 ├── log_sfp32.f90 ├── log_sfp64.f90 ├── monadic_r1fp32.f90 ├── monadic_r1fp64.f90 ├── monadic_r2fp32.f90 ├── monadic_r2fp64.f90 ├── monadic_r3fp32.f90 ├── monadic_r3fp64.f90 ├── monadic_r4fp32.f90 ├── monadic_r4fp64.f90 ├── monadic_sfp32.f90 ├── monadic_sfp64.f90 ├── parsing_difficult_r1fp64.f90 ├── parsing_vanderpol_sfp64.f90 ├── print_tokens.f90 ├── random_r1fp32.f90 ├── random_r1fp64.f90 ├── random_r2fp32.f90 ├── random_r2fp64.f90 ├── random_r3fp32.f90 ├── random_r3fp64.f90 ├── random_r4fp32.f90 ├── random_r4fp64.f90 ├── random_sfp32.f90 ├── random_sfp64.f90 ├── sech_r1fp32.f90 ├── sech_r1fp64.f90 ├── sech_r2fp32.f90 ├── sech_r2fp64.f90 ├── sech_r3fp32.f90 ├── sech_r3fp64.f90 ├── sech_r4fp32.f90 ├── sech_r4fp64.f90 ├── sech_sfp32.f90 ├── sech_sfp64.f90 ├── sin_r1fp32.f90 ├── sin_r1fp64.f90 ├── sin_r2fp32.f90 ├── sin_r2fp64.f90 ├── sin_r3fp32.f90 ├── sin_r3fp64.f90 ├── sin_r4fp32.f90 ├── sin_r4fp64.f90 ├── sin_sfp32.f90 ├── sin_sfp64.f90 ├── sinh_r1fp32.f90 ├── sinh_r1fp64.f90 ├── sqrt_r1fp32.f90 ├── sqrt_r1fp64.f90 ├── sqrt_r2fp32.f90 ├── sqrt_r2fp64.f90 ├── sqrt_r3fp32.f90 ├── sqrt_r3fp64.f90 ├── sqrt_r4fp32.f90 ├── sqrt_r4fp64.f90 ├── sqrt_sfp32.f90 ├── sqrt_sfp64.f90 ├── tan_r1fp32.f90 ├── tan_r1fp64.f90 ├── tan_r2fp32.f90 ├── tan_r2fp64.f90 ├── tan_r3fp32.f90 ├── tan_r3fp64.f90 ├── tan_r4fp32.f90 ├── tan_r4fp64.f90 ├── tan_sfp32.f90 ├── tan_sfp64.f90 ├── tanh_r1fp32.f90 ├── tanh_r1fp64.f90 ├── tanh_r2fp32.f90 ├── tanh_r2fp64.f90 ├── tanh_r3fp32.f90 ├── tanh_r3fp64.f90 ├── tanh_r4fp32.f90 ├── tanh_r4fp64.f90 ├── tanh_sfp32.f90 └── tanh_sfp64.f90 /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | # github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | # patreon: # Replace with a single Patreon username 5 | open_collective: opensource-fluidnumerics 6 | # ko_fi: # Replace with a single Ko-fi username 7 | # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | # liberapay: # Replace with a single Liberapay username 10 | # issuehunt: # Replace with a single IssueHunt username 11 | # otechie: # Replace with a single Otechie username 12 | # lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | # custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/workflows/fprettify-lint.yml: -------------------------------------------------------------------------------- 1 | name: fprettify-lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | paths-ignore: 9 | - 'AUTHORS.md' 10 | - 'LICENSE.md' 11 | - 'README.md' 12 | pull_request: 13 | paths-ignore: 14 | - 'AUTHORS.md' 15 | - 'LICENSE.md' 16 | - 'README.md' 17 | 18 | jobs: 19 | fprettify: 20 | name: fprettify-check 21 | runs-on: ubuntu-22.04 22 | strategy: 23 | fail-fast: false 24 | defaults: 25 | run: 26 | shell: bash 27 | steps: 28 | - name: Checkout repository 29 | uses: actions/checkout@v3 30 | 31 | - name: Install fprettify 32 | run: | 33 | pip3 install fprettify 34 | 35 | - name: Check for formatting differences (src/) 36 | run: | 37 | if [[ $(fprettify './src/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1) ]]; then 38 | fprettify './src/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1 39 | exit 1 40 | else 41 | echo "src/ linting passed!" 42 | fi 43 | 44 | - name: Check for formatting differences (test/) 45 | run: | 46 | if [[ $(fprettify './test/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1) ]]; then 47 | fprettify './test/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1 48 | exit 1 49 | else 50 | echo "test/ linting passed!" 51 | fi 52 | 53 | - name: Check for formatting differences (example/) 54 | run: | 55 | if [[ $(fprettify './example/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1) ]]; then 56 | fprettify './example/' --config-file ./fprettify.config -d --recursive --case 1 1 1 1 57 | exit 1 58 | else 59 | echo "example/ linting passed!" 60 | fi 61 | 62 | -------------------------------------------------------------------------------- /.github/workflows/linux-amdflang-cmake.yaml: -------------------------------------------------------------------------------- 1 | name: linux-amdflang-cmake 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | paths-ignore: 9 | - 'AUTHORS.md' 10 | - 'LICENSE.md' 11 | - 'README.md' 12 | pull_request: 13 | paths-ignore: 14 | - 'AUTHORS.md' 15 | - 'LICENSE.md' 16 | - 'README.md' 17 | 18 | jobs: 19 | linux-tests: 20 | timeout-minutes: 20 21 | if: "!contains(github.event.head_commit.message, 'skip ci')" 22 | name: ${{ matrix.os }} - ${{ matrix.fcompiler }} - ${{ matrix.build_type }} 23 | runs-on: ${{ matrix.os }} 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | include: 28 | - os: ubuntu-22.04 29 | fcompiler: amdflang 30 | ccompiler: amdclang 31 | shell: bash 32 | build_type: debug 33 | memcheck: false 34 | 35 | defaults: 36 | run: 37 | shell: ${{ matrix.shell }} 38 | steps: 39 | - name: Checkout repository 40 | uses: actions/checkout@v3 41 | 42 | 43 | - name: rocm-setup 44 | run: | 45 | sudo apt update -y 46 | wget https://repo.radeon.com/amdgpu-install/6.1.1/ubuntu/jammy/amdgpu-install_6.1.60101-1_all.deb 47 | sudo apt install -y ./amdgpu-install_6.1.60101-1_all.deb 48 | sudo amdgpu-install --accept-eula -y --usecase=openmpsdk --no-dkms 49 | 50 | - name: Show version information 51 | run: | 52 | export PATH=${PATH}:/opt/rocm/bin 53 | ${{ matrix.fcompiler }} --version 54 | ${{ matrix.ccompiler }} --version 55 | 56 | - name: Build with Cmake 57 | run: | 58 | export PATH=${PATH}:/opt/rocm/bin 59 | mkdir build 60 | cd build 61 | FC=${{ matrix.fcompiler }} CC=${{ matrix.ccompiler }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ../ 62 | make VERBOSE=1 63 | 64 | - name: Run ctests 65 | run: | 66 | cd build/test 67 | ctest || ctest --rerun-failed --output-on-failure 68 | 69 | -------------------------------------------------------------------------------- /.github/workflows/linux-gnu-fpm.yml: -------------------------------------------------------------------------------- 1 | name: linux-gnu-fpm 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | paths-ignore: 9 | - 'AUTHORS.md' 10 | - 'LICENSE.md' 11 | - 'README.md' 12 | pull_request: 13 | paths-ignore: 14 | - 'AUTHORS.md' 15 | - 'LICENSE.md' 16 | - 'README.md' 17 | 18 | env: 19 | # Modify this variable to change the ifort compiler version - do NOT hardcode the version 20 | # anywhere else! 21 | INTEL_ONEAPI_VERSION: 2023.2.1 22 | 23 | jobs: 24 | linux-tests: 25 | timeout-minutes: 8 26 | if: "!contains(github.event.head_commit.message, 'skip ci')" 27 | name: ${{ matrix.os }} - ${{ matrix.fcompiler }} 28 | runs-on: ${{ matrix.os }} 29 | strategy: 30 | fail-fast: false 31 | matrix: 32 | include: 33 | # Linux 34 | - os: ubuntu-22.04 35 | fcompiler: gfortran-9 36 | ccompiler: gcc-9 37 | shell: bash 38 | 39 | - os: ubuntu-22.04 40 | fcompiler: gfortran-10 41 | ccompiler: gcc-10 42 | shell: bash 43 | 44 | - os: ubuntu-22.04 45 | fcompiler: gfortran-11 46 | ccompiler: gcc-11 47 | shell: bash 48 | 49 | - os: ubuntu-22.04 50 | fcompiler: gfortran-12 51 | ccompiler: gcc-12 52 | shell: bash 53 | 54 | 55 | defaults: 56 | run: 57 | shell: ${{ matrix.shell }} 58 | steps: 59 | - name: Checkout repository 60 | uses: actions/checkout@v3 61 | 62 | 63 | - name: Show version information 64 | run: | 65 | ${{ matrix.fcompiler }} --version 66 | ${{ matrix.ccompiler }} --version 67 | 68 | 69 | - name: fpm tests 70 | run: | 71 | wget https://github.com/fortran-lang/fpm/releases/download/v0.9.0/fpm-0.9.0-linux-x86_64 72 | chmod +x ./fpm-0.9.0-linux-x86_64 && mv ./fpm-0.9.0-linux-x86_64 fpm 73 | ./fpm install --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} 74 | ./fpm test --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} 75 | ./fpm run --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} --example "*" 76 | 77 | -------------------------------------------------------------------------------- /.github/workflows/linux-nvfortran-cmake.yaml: -------------------------------------------------------------------------------- 1 | name: linux-nvidia-hpc-cmake 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | paths-ignore: 9 | - 'AUTHORS.md' 10 | - 'LICENSE.md' 11 | - 'README.md' 12 | pull_request: 13 | paths-ignore: 14 | - 'AUTHORS.md' 15 | - 'LICENSE.md' 16 | - 'README.md' 17 | 18 | jobs: 19 | linux-tests: 20 | timeout-minutes: 20 21 | if: "!contains(github.event.head_commit.message, 'skip ci')" 22 | name: ${{ matrix.os }} - ${{ matrix.toolchain.compiler }} - ${{ matrix.build_type }} 23 | runs-on: ${{ matrix.os }} 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | toolchain: 28 | - {compiler: nvidia-hpc, version: '23.11'} 29 | include: 30 | - os: ubuntu-22.04 31 | shell: bash 32 | build_type: debug 33 | toolchain: {compiler: nvidia-hpc, version: '23.11'} 34 | 35 | defaults: 36 | run: 37 | shell: ${{ matrix.shell }} 38 | steps: 39 | - name: Checkout repository 40 | uses: actions/checkout@v3 41 | 42 | - uses: fortran-lang/setup-fortran@v1 43 | id: setup-fortran 44 | with: 45 | compiler: ${{ matrix.toolchain.compiler }} 46 | version: ${{ matrix.toolchain.version }} 47 | 48 | - name: Show version information 49 | run: | 50 | ${{ env.FC }} --version 51 | ${{ env.CC }} --version 52 | 53 | - name: Build with Cmake 54 | run: | 55 | export PATH=${PATH}:/opt/rocm/bin 56 | mkdir build 57 | cd build 58 | FC=${{ env.FC }} CC=${{ env.CC }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ../ 59 | make VERBOSE=1 60 | 61 | - name: Run ctests 62 | run: | 63 | cd build/test 64 | ctest || ctest --rerun-failed --output-on-failure 65 | 66 | -------------------------------------------------------------------------------- /.github/workflows/windows-gnu-cmake.yml: -------------------------------------------------------------------------------- 1 | name: windows-gnu-cmake 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | paths-ignore: 9 | - 'AUTHORS.md' 10 | - 'LICENSE.md' 11 | - 'README.md' 12 | pull_request: 13 | paths-ignore: 14 | - 'AUTHORS.md' 15 | - 'LICENSE.md' 16 | - 'README.md' 17 | 18 | env: 19 | # Modify this variable to change the ifort compiler version - do NOT hardcode the version 20 | # anywhere else! 21 | INTEL_ONEAPI_VERSION: 2023.2.1 22 | 23 | jobs: 24 | windows-tests: 25 | timeout-minutes: 8 26 | if: "!contains(github.event.head_commit.message, 'skip ci')" 27 | name: ${{ matrix.os }} - ${{ matrix.fcompiler }} - ${{ matrix.build_type }} 28 | runs-on: ${{ matrix.os }} 29 | strategy: 30 | fail-fast: false 31 | matrix: 32 | include: 33 | 34 | # Windows 35 | - os: windows-latest 36 | fcompiler: gfortran 37 | ccompiler: gcc 38 | shell: 'msys2 {0}' 39 | build_type: debug 40 | 41 | 42 | defaults: 43 | run: 44 | shell: ${{ matrix.shell }} 45 | steps: 46 | - name: Checkout repository 47 | uses: actions/checkout@v3 48 | 49 | - name: Install packages 50 | uses: msys2/setup-msys2@v2 51 | if: ${{ matrix.os == 'windows-latest' }} 52 | with: 53 | update: true 54 | install: git base-devel mingw-w64-x86_64-toolchain cmake mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-fpm 55 | 56 | - name: Show version information 57 | run: | 58 | ${{ matrix.fcompiler }} --version 59 | ${{ matrix.ccompiler }} --version 60 | 61 | - name: Build with Cmake 62 | run: | 63 | mkdir build 64 | cd build 65 | FC=${{ matrix.fcompiler }} CC=${{ matrix.ccompiler }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ../ 66 | make VERBOSE=1 67 | 68 | - name: Run ctests 69 | run: | 70 | cd build/test 71 | ctest || ctest --rerun-failed --output-on-failure 72 | 73 | -------------------------------------------------------------------------------- /.github/workflows/windows-gnu-fpm.yml: -------------------------------------------------------------------------------- 1 | name: windows-gnu-fpm 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | paths-ignore: 9 | - 'AUTHORS.md' 10 | - 'LICENSE.md' 11 | - 'README.md' 12 | pull_request: 13 | paths-ignore: 14 | - 'AUTHORS.md' 15 | - 'LICENSE.md' 16 | - 'README.md' 17 | 18 | env: 19 | # Modify this variable to change the ifort compiler version - do NOT hardcode the version 20 | # anywhere else! 21 | INTEL_ONEAPI_VERSION: 2023.2.1 22 | 23 | jobs: 24 | windows-tests: 25 | timeout-minutes: 8 26 | if: "!contains(github.event.head_commit.message, 'skip ci')" 27 | name: ${{ matrix.os }} - ${{ matrix.fcompiler }} 28 | runs-on: ${{ matrix.os }} 29 | strategy: 30 | fail-fast: false 31 | matrix: 32 | include: 33 | 34 | # Windows 35 | - os: windows-latest 36 | fcompiler: gfortran 37 | ccompiler: gcc 38 | shell: 'msys2 {0}' 39 | build_type: fpm 40 | 41 | defaults: 42 | run: 43 | shell: ${{ matrix.shell }} 44 | steps: 45 | - name: Checkout repository 46 | uses: actions/checkout@v3 47 | 48 | - name: Install packages 49 | uses: msys2/setup-msys2@v2 50 | if: ${{ matrix.os == 'windows-latest' }} 51 | with: 52 | update: true 53 | install: git base-devel mingw-w64-x86_64-toolchain cmake mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-fpm 54 | 55 | - name: Show version information 56 | run: | 57 | ${{ matrix.fcompiler }} --version 58 | ${{ matrix.ccompiler }} --version 59 | 60 | - name: fpm tests 61 | run: | 62 | fpm install --verbose --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} 63 | fpm test --verbose --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} 64 | fpm run --verbose --compiler ${{ matrix.fcompiler }} --c-compiler ${{ matrix.ccompiler }} --example="*" 65 | 66 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.mod 3 | build/ 4 | .DS_Store 5 | *.i90 6 | *.code-workspace 7 | .vscode 8 | fpm 9 | check 10 | test.sh 11 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to feqparse 2 | 3 | ## Reporting Issues 4 | Issues, including bugs and feature requests, can be reported at https://github.com/FluidNumerics/feq-parse/issues 5 | 6 | ## Contributing 7 | If you want to help resolve [any open issues](https://github.com/FluidNumerics/feq-parse/issues), you can do the following : 8 | 9 | 1. Fork this repository 10 | 2. Insert your fixes and commit your changes to your fork. Be sure to include any new additional tests to demonstrate the new feature or bug fix. 11 | 3. Open a pull request from your fork to this upstream repository. 12 | 4. Work with the upstream reviewer to merge your changes into feq-parse. 13 | 14 | When you contribute code, feel add your name to the Contributors section of the README.md 15 | 16 | ### Code formatting 17 | 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. 18 | 19 | You can run the following to format code to conform to the expected format for `feq-parse`. 20 | ``` 21 | fprettify './src/' --config-file ./fprettify.config --recursive --case 1 1 1 1 22 | fprettify './test/' --config-file ./fprettify.config --recursive --case 1 1 1 1 23 | fprettify './example/' --config-file ./fprettify.config --recursive --case 1 1 1 1 24 | ``` 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2024 Fluid Numerics LLC 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /docs/assets/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/assets/images/favicon.png -------------------------------------------------------------------------------- /docs/assets/images/logo-fluid-numerics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/assets/images/logo-fluid-numerics.png -------------------------------------------------------------------------------- /docs/assets/images/tutorials/traveling-shock/initial-condition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/assets/images/tutorials/traveling-shock/initial-condition.png -------------------------------------------------------------------------------- /docs/build-with-feqparse.md: -------------------------------------------------------------------------------- 1 | # Build your application with feq-parse 2 | 3 | Once feq-parse is installed, you can use the library to start creating your own Fortran applications with dynamic equation support! Below, we provide example Makefiles and CMakeLists.txt to get your started. You can peruse the [feq-parse/example](https://github.com/FluidNumerics/feq-parse/tree/master/example) for demonstrations of how you can use `feq-parse` in your project. 4 | 5 | 6 | ## Build 7 | 8 | When building an application with feqparse, you need to specify linker and includes flags to your Fortran compiler so that it can find the feqparse library and Fortran `.mod` files. Below are examples for doing this with a Makefile and with a CMake build system. 9 | 10 | ### Makefile 11 | ``` 12 | FC?=gfortran # This needs to be the same Fortran compiler that was used to build feq-parse 13 | FEQPARSE_ROOT?=/usr # Modify this line or set FEQPARSE_ROOT environment variable to the root installation path for feq-parse 14 | 15 | FEQPARSE_LIB=-L${FEQPARSE_ROOT}/lib/ -lfeqparse 16 | FEQPARSE_INCLUDE=-I${FEQPARSE_ROOT}/include 17 | 18 | app: app.o 19 | ${FC} ${FEQPARSE_LIB} ${FEQPARSE_INCLUDE} app.o -o $@ 20 | 21 | app.o: 22 | ${FC} -c ${FEQPARSE_LIB} ${FEQPARSE_INCLUDE} app.f90 -o $@ 23 | ``` 24 | 25 | ### CMakeLists.txt 26 | 27 | ``` 28 | cmake_minimum_required(VERSION 3.21) 29 | cmake_policy(VERSION 3.21...3.27) 30 | 31 | project(myproject VERSION 1.0.0 32 | DESCRIPTION "A totally useful application" 33 | LANGUAGES Fortran) 34 | 35 | 36 | # FEQ-Parse 37 | find_library(FEQPARSE_LIBRARIES NAMES feqparse REQUIRED) 38 | find_path(FEQPARSE_INCLUDE_DIRS feqparse.mod) 39 | 40 | # After you declare your build targets, you can use: 41 | # 42 | # target_link_libraries(target-name PRIVATE ${FEQPARSE_LIBRARIES}) 43 | # 44 | # to link your target to the feq-parse library, and you can use : 45 | # 46 | # target_include_directories(target-name PRIVATE ${FEQPARSE_INCLUDE_DIRS}) 47 | # 48 | # to add the necessary includes flags to the feq-parse `.mod` files. 49 | # 50 | ``` 51 | 52 | -------------------------------------------------------------------------------- /docs/ford/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/favicon.png -------------------------------------------------------------------------------- /docs/ford/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /docs/ford/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs/ford/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/ford/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/ford/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /docs/ford/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /docs/ford/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /docs/ford/js/MathJax-config/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/js/MathJax-config/.gitignore -------------------------------------------------------------------------------- /docs/ford/js/ie10-viewport-bug-workaround.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * IE10 viewport hack for Surface/desktop Windows 8 bug 3 | * Copyright 2014 Twitter, Inc. 4 | * Licensed under the Creative Commons Attribution 3.0 Unported License. For 5 | * details, see http://creativecommons.org/licenses/by/3.0/. 6 | */ 7 | 8 | // See the Getting Started docs for more information: 9 | // http://getbootstrap.com/getting-started/#support-ie10-width 10 | 11 | (function () { 12 | 'use strict'; 13 | if (navigator.userAgent.match(/IEMobile\/10\.0/)) { 14 | var msViewportStyle = document.createElement('style') 15 | msViewportStyle.appendChild( 16 | document.createTextNode( 17 | '@-ms-viewport{width:auto!important}' 18 | ) 19 | ) 20 | document.querySelector('head').appendChild(msViewportStyle) 21 | } 22 | })(); 23 | -------------------------------------------------------------------------------- /docs/ford/tipuesearch/img/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/tipuesearch/img/loader.gif -------------------------------------------------------------------------------- /docs/ford/tipuesearch/img/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FluidNumerics/feq-parse/d196662c9e8d9d7d99a9be27fe3d04bba483d479/docs/ford/tipuesearch/img/search.png -------------------------------------------------------------------------------- /docs/ford/tipuesearch/tipuesearch_set.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Tipue Search 4.0 4 | Copyright (c) 2014 Tipue 5 | Tipue Search is released under the MIT License 6 | http://www.tipue.com/search 7 | */ 8 | 9 | 10 | var tipuesearch_stop_words = ["and", "be", "by", "do", "for", "he", "how", "if", "is", "it", "my", "not", "of", "or", "the", "to", "up", "what", "when", "use", "who", "she", "my", "his", "her"]; 11 | 12 | var tipuesearch_replace = {"words": [ 13 | {"word": "tipua", "replace_with": "tipue"}, 14 | {"word": "javscript", "replace_with": "javascript"} 15 | ]}; 16 | 17 | var tipuesearch_stem = {"words": [ 18 | {"word": "e-mail", "stem": "email"}, 19 | {"word": "javascript", "stem": "script"}, 20 | {"word": "procedure", "stem": "subroutine"}, 21 | {"word": "procedure", "stem": "function"} 22 | ]}; 23 | 24 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # FEQParse 2 | 3 | 4 | ## Quickstart 5 | 6 |
Install with Fortran Package Manager (fpm) 7 | 8 | * [Download and install Fortran Package Manager (fpm)](https://fpm.fortran-lang.org/install/index.html) 9 | 10 | * Clone `feq-parse` 11 | ``` 12 | git clone https://github.com/fluidnumerics/feq-parse ~/feq-parse 13 | ``` 14 | 15 | * Install 16 | ``` 17 | cd ~/feq-parse 18 | fpm build --profile release 19 | fpm test --profile release 20 | ``` 21 |
22 | 23 |
Install with Spack 24 | 25 | * Download and set up the [Spack package manager](https://spack.io) 26 | ``` 27 | git clone https://github.com/spack/spack ~/spack 28 | source ~/spack/share/spack/setup-env.sh 29 | spack compiler find 30 | ``` 31 | 32 | * Install `feq-parse` 33 | ``` 34 | spack install feq-parse 35 | ``` 36 |
37 | 38 |
Install with CMake 39 | 40 | * Clone `feq-parse` 41 | ``` 42 | git clone https://github.com/fluidnumerics/feq-parse ~/feq-parse 43 | ``` 44 | 45 | * Install 46 | ``` 47 | mkdir ~/feq-parse/build 48 | cd ~/feq-parse/build 49 | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${HOME}/apps/feq-parse ../ 50 | make 51 | make install 52 | ``` 53 |
54 | ## Learn more 55 | 56 | * [Building your applications with feq-parse](./build-with-feqparse.md) 57 | * [Learn more about the feq-parse algorithms](./parsing-equations.md) 58 | -------------------------------------------------------------------------------- /example/array_with_array_eval.f90: -------------------------------------------------------------------------------- 1 | program array_with_array_eval 2 | use iso_fortran_env 3 | use FEQParse 4 | 5 | implicit none 6 | integer,parameter :: N = 10000 7 | type(EquationParser) :: f 8 | character(LEN=1),dimension(1) :: independentVars 9 | character(LEN=30) :: eqChar 10 | real :: x(1:N,1) 11 | real :: feval(1:N) 12 | integer :: i 13 | real :: t1,t2 14 | 15 | ! Specify the independent variables 16 | independentVars = (/'x'/) 17 | 18 | ! Specify an equation string that we want to evaluate 19 | eqChar = 'f = exp( -(x^2) )' 20 | 21 | ! Create the EquationParser object 22 | f = EquationParser(eqChar,independentVars) 23 | 24 | ! Evaluate the equation 25 | call cpu_time(t1) 26 | do i = 1,N 27 | x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 28 | enddo 29 | feval = f%evaluate(x) 30 | call cpu_time(t2) 31 | print*,"runtime :",(t2-t1)," s" 32 | 33 | endprogram array_with_array_eval 34 | -------------------------------------------------------------------------------- /example/array_with_scalar_eval.f90: -------------------------------------------------------------------------------- 1 | program array_with_scalar_eval 2 | use iso_fortran_env 3 | use FEQParse 4 | 5 | implicit none 6 | integer,parameter :: N = 100 7 | type(EquationParser) :: f 8 | character(LEN=1),dimension(1) :: independentVars 9 | character(LEN=30) :: eqChar 10 | real :: x(1) 11 | real :: feval(1:N) 12 | integer :: i 13 | real :: t1,t2 14 | 15 | ! Specify the independent variables 16 | independentVars = (/'x'/) 17 | 18 | ! Specify an equation string that we want to evaluate 19 | eqChar = 'f = exp( -(x^2) )' 20 | 21 | ! Create the EquationParser object 22 | f = EquationParser(eqChar,independentVars) 23 | 24 | ! Evaluate the equation 25 | call cpu_time(t1) 26 | do i = 1,N 27 | x(1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 28 | feval(i) = f%evaluate(x) 29 | enddo 30 | call cpu_time(t2) 31 | print*,"runtime :",(t2-t1)," s" 32 | 33 | endprogram array_with_scalar_eval 34 | -------------------------------------------------------------------------------- /example/gaussian_scalar_multivar.f90: -------------------------------------------------------------------------------- 1 | program gaussian_scalar_multivar 2 | use iso_fortran_env 3 | use FEQParse 4 | 5 | implicit none 6 | type(EquationParser) :: f 7 | character(LEN=1),dimension(2) :: independentVars 8 | character(LEN=30) :: eqChar 9 | real :: x(2) 10 | 11 | ! Specify the independent variables 12 | independentVars = (/'x','a'/) 13 | 14 | ! Specify an equation string that we want to evaluate 15 | eqChar = 'f = exp( -(x^2) ) - a' 16 | ! eqChar = 'f = exp( -(x^2) - a )' 17 | ! eqChar = 'f = (x - a)^2 )' 18 | 19 | ! Create the EquationParser object 20 | f = EquationParser(eqChar,independentVars) 21 | 22 | ! Evaluate the equation 23 | x(1) = 1.0 24 | x(2) = 1.0 25 | print*,f%evaluate(x) 26 | print*,exp(-1.0)-1.0 27 | 28 | endprogram gaussian_scalar_multivar 29 | -------------------------------------------------------------------------------- /example/scalar_function_product.f90: -------------------------------------------------------------------------------- 1 | program scalar_function_product 2 | use iso_fortran_env 3 | use FEQParse 4 | 5 | implicit none 6 | type(EquationParser) :: f 7 | character(LEN=1),dimension(2) :: independentVars 8 | character(LEN=2048) :: eqChar 9 | real :: x(2) 10 | real :: feval 11 | 12 | ! Specify the independent variables 13 | independentVars = (/'x','y'/) 14 | 15 | ! Specify an equation string that we want to evaluate 16 | eqChar = 'f = cos( 2.0*pi*x )*cos( 2.0*pi*y )' 17 | 18 | ! Create the EquationParser object 19 | f = EquationParser(eqChar,independentVars) 20 | 21 | ! Evaluate the equation 22 | x = 0.5 23 | feval = f%evaluate(x) 24 | print*,feval 25 | 26 | endprogram scalar_function_product 27 | -------------------------------------------------------------------------------- /example/scalar_with_scalar_eval.f90: -------------------------------------------------------------------------------- 1 | program scalar_with_scalar_eval 2 | use iso_fortran_env 3 | use FEQParse 4 | 5 | implicit none 6 | type(EquationParser) :: f 7 | character(LEN=1),dimension(1) :: independentVars 8 | character(LEN=30) :: eqChar 9 | real :: x(1) 10 | 11 | ! Specify the independent variables 12 | independentVars = (/'x'/) 13 | 14 | ! Specify an equation string that we want to evaluate 15 | eqChar = 'f = exp( -(x^2) )' 16 | 17 | ! Create the EquationParser object 18 | f = EquationParser(eqChar,independentVars) 19 | 20 | ! Evaluate the equation 21 | x(1) = 0.0 22 | print*,f%evaluate(x) 23 | 24 | endprogram scalar_with_scalar_eval 25 | -------------------------------------------------------------------------------- /feq-parse.md: -------------------------------------------------------------------------------- 1 | --- 2 | project: FEQParse 3 | summary: FEQParse -- Fortran Equation Parser. Parse and evaluate equations in Fortran using characters. 4 | author: Fluid Numerics 5 | author_description: Committed to service for science 6 | github: https://github.com/fluidnumerics 7 | email: support@fluidnumerics.com 8 | project_github: https://github.com/FluidNumerics/FEQParse 9 | project_website: https://feqparse.fluidnumerics.com 10 | src_dir: ./src/ 11 | output_dir: ./docs/ford 12 | exclude_dir: ./src/dev 13 | fpp_extensions: fpp 14 | predocmark: > 15 | docmark_alt: # 16 | predocmark_alt: < 17 | display: public 18 | protected 19 | private 20 | source: true 21 | graph: true 22 | search: true 23 | sort: alpha 24 | coloured_edges: true 25 | print_creation_date: true 26 | creation_date: %Y-%m-%d %H:%M %z 27 | macro: TEST 28 | LOGIC=.true. 29 | license: 3-Clause BSD 30 | extra_filetypes: cpp # 31 | -------------------------------------------------------------------------------- /fpm.toml: -------------------------------------------------------------------------------- 1 | name = "feq-parse" 2 | license = "Other" 3 | author = "Fluid Numerics LLC" 4 | copyright = "Copyright 2020 Fluid Numerics LLC" 5 | description = "An equation parser class for Modern Fortran" 6 | homepage = "https://github.com/FluidNumerics/feq-parse" 7 | version = "2.1.1" 8 | keywords = ["parser"] 9 | 10 | [build] 11 | auto-executables = false 12 | auto-examples = false 13 | auto-tests = true 14 | 15 | [library] 16 | source-dir = "src" 17 | 18 | [install] 19 | library = true 20 | 21 | 22 | [[example]] 23 | name = "array_with_array_eval" 24 | source-dir = "example" 25 | main = "array_with_array_eval.f90" 26 | 27 | [[example]] 28 | name = "array_with_scalar_eval" 29 | source-dir = "example" 30 | main = "array_with_scalar_eval.f90" 31 | 32 | [[example]] 33 | name = "scalar_with_scalar_eval" 34 | source-dir = "example" 35 | main = "scalar_with_scalar_eval.f90" 36 | 37 | [[example]] 38 | name = "scalar_function_product" 39 | source-dir = "example" 40 | main = "scalar_function_product.f90" 41 | 42 | [[example]] 43 | name = "gaussian_scalar_multivar" 44 | source-dir = "example" 45 | main = "gaussian_scalar_multivar.f90" 46 | -------------------------------------------------------------------------------- /fprettify.config: -------------------------------------------------------------------------------- 1 | disable-indent-mod=False 2 | enable-replacements=False 3 | c-relations=False 4 | 5 | # White space settings 6 | indent=2 7 | line-length=132 8 | strict-indent=True 9 | strip-comments=True 10 | whitespace-relational=True 11 | whitespace-logical=True 12 | whitespace-plusminus=False 13 | whitespace-multdiv=False 14 | whitespace-comma=False 15 | whitespace-intrinsics=False 16 | whitespace-print=False 17 | whitespace-type=False 18 | 19 | # Control whitespace around '::' declarations 20 | whitespace-decl=None 21 | enable-decl=False 22 | 23 | # Don't indent pre-processor statements 24 | disable-fypp=True 25 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: Fortran Equation Parser 2 | site_description: Documentation for feq-parse 3 | site_author: Fluid Numerics 4 | site_dir: public 5 | site_url: "" 6 | repo_name: GitHub/fluidnumerics/feq-parse 7 | repo_url: https://github.com/fluidnumerics/feq-parse 8 | edit_uri: edit/main/docs/mkdocs 9 | 10 | # Directory where site content is located 11 | docs_dir: docs 12 | 13 | # Site navigation 14 | nav: 15 | - Home: index.md 16 | - Getting Started: 17 | - Build with feq-parse: build-with-feqparse.md 18 | - Learning: 19 | - Parsing equations: parsing-equations.md 20 | - API Documentation: ford/index.html 21 | 22 | 23 | theme: 24 | name: material 25 | favicon: assets/images/favicon.png 26 | logo: assets/images/logo-fluid-numerics.png 27 | palette: 28 | - scheme: slate 29 | primary: black 30 | accent: cyan 31 | toggle: 32 | icon: material/brightness-4 33 | name: Switch to light mode 34 | 35 | - scheme: default 36 | primary: black 37 | accent: cyan 38 | toggle: 39 | icon: material/brightness-7 40 | name: Switch to dark mode 41 | 42 | markdown_extensions: 43 | - admonition 44 | - pymdownx.arithmatex: 45 | generic: true 46 | - attr_list 47 | - md_in_html 48 | 49 | extra_javascript: 50 | - javascripts/mathjax.js 51 | - https://polyfill.io/v3/polyfill.min.js?features=es6 52 | - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js 53 | 54 | 55 | plugins: 56 | - glightbox 57 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | # ! 3 | # ! Maintainers : support@fluidnumerics.com 4 | # ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | # ! 6 | # ! Copyright © 2024 Fluid Numerics LLC 7 | # ! 8 | # ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | # ! 10 | # ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | # ! 12 | # ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | # ! the documentation and/or other materials provided with the distribution. 14 | # ! 15 | # ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | # ! this software without specific prior written permission. 17 | # ! 18 | # ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | # ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | # ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | # ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | # ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | # ! 25 | # ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | set(CMAKE_VERBOSE_MAKEFILE ON) 27 | file(GLOB FEQPARSE_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.f90") 28 | 29 | set(FEQPARSE_LIB "feqparse") 30 | set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include) 31 | 32 | ADD_LIBRARY(${FEQPARSE_LIB} SHARED ${FEQPARSE_SRC}) 33 | ADD_LIBRARY(${FEQPARSE_LIB}-static STATIC ${FEQPARSE_SRC}) 34 | 35 | 36 | install(TARGETS ${FEQPARSE_LIB} ${FEQPARSE_LIB}-static 37 | ARCHIVE DESTINATION lib 38 | LIBRARY DESTINATION lib) 39 | 40 | set_target_properties(${FEQPARSE_LIB} PROPERTIES LINKER_LANGUAGE Fortran) 41 | set_target_properties(${FEQPARSE_LIB}-static PROPERTIES LINKER_LANGUAGE Fortran) 42 | 43 | 44 | install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION include) 45 | 46 | 47 | -------------------------------------------------------------------------------- /test/abs_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = abs_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function abs_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = abs( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = abs(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction abs_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/abs_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = abs_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function abs_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = abs( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = abs(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction abs_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/abs_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = abs_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function abs_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = abs( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | fexact = abs(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction abs_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/abs_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = abs_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function abs_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | real(real64) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = abs( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | fexact = abs(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction abs_sfp64 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/acos_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = acos_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function acos_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = acos( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = acos(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction acos_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/acos_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = acos_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function acos_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = acos( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = acos(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction acos_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/acos_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = acos_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function acos_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = acos( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | fexact = acos(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction acos_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/acos_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = acos_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function acos_sfp64() result(r) 38 | ! WARNING - acos(x) accurate only to single precision with gfortran 11.4.0 39 | use FEQParse 40 | use iso_fortran_env 41 | implicit none 42 | integer,parameter :: N = 10 43 | type(EquationParser) :: f 44 | character(LEN=1),dimension(1:3) :: independentVars 45 | character(LEN=2048) :: eqChar 46 | real(real64) :: x(1:3) 47 | real(real64) :: feval 48 | real(real64) :: fexact 49 | integer :: i 50 | 51 | ! Specify the independent variables 52 | independentVars = (/'x','y','z'/) 53 | 54 | ! Specify an equation string that we want to evaluate 55 | eqChar = 'f = acos( x )' 56 | 57 | ! Create the EquationParser object 58 | f = EquationParser(eqChar,independentVars) 59 | 60 | x = 0.0_real64 61 | fexact = acos(x(1)) 62 | 63 | ! Evaluate the equation 64 | feval = f%evaluate(x) 65 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 66 | r = 0 67 | else 68 | r = 1 69 | endif 70 | 71 | endfunction acos_sfp64 72 | endprogram test 73 | -------------------------------------------------------------------------------- /test/asin_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = asin_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function asin_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = asin( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = asin(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction asin_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/asin_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = asin_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function asin_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = asin( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = asin(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction asin_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/asin_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = asin_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function asin_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = asin( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | fexact = asin(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction asin_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/asin_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = asin_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function asin_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | real(real64) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = asin( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | fexact = asin(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction asin_sfp64 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/atan_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = atan_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function atan_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = atan( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = atan(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction atan_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/atan_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = atan_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function atan_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = atan( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = atan(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction atan_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/atan_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = atan_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function atan_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = atan( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | fexact = atan(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction atan_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/atan_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = atan_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function atan_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | real(real64) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = atan( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | fexact = atan(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction atan_sfp64 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/cos_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = cos_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function cos_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) 43 | type(EquationParser) :: f 44 | character(LEN=1),dimension(1:3) :: independentVars 45 | character(LEN=2048) :: eqChar 46 | real(real32) :: x(1:3) 47 | real(real32) :: feval 48 | real(real32) :: fexact 49 | integer :: i 50 | 51 | ! Specify the independent variables 52 | independentVars = (/'x','y','z'/) 53 | 54 | ! Specify an equation string that we want to evaluate 55 | eqChar = 'f = cos( 2.0*pi*x )' 56 | 57 | ! Create the EquationParser object 58 | f = EquationParser(eqChar,independentVars) 59 | 60 | x = 0.0_real32 61 | fexact = cos(2.0_real32*pi*x(1)) 62 | 63 | ! Evaluate the equation 64 | feval = f%evaluate(x) 65 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 66 | r = 0 67 | else 68 | r = 1 69 | endif 70 | 71 | endfunction cos_sfp32 72 | endprogram test 73 | -------------------------------------------------------------------------------- /test/cos_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = cos_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function cos_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) 43 | type(EquationParser) :: f 44 | character(LEN=1),dimension(1:3) :: independentVars 45 | character(LEN=2048) :: eqChar 46 | real(real64) :: x(1:3) 47 | real(real64) :: feval 48 | real(real64) :: fexact 49 | integer :: i 50 | 51 | ! Specify the independent variables 52 | independentVars = (/'x','y','z'/) 53 | 54 | ! Specify an equation string that we want to evaluate 55 | eqChar = 'f = cos( 2.0*pi*x )' 56 | 57 | ! Create the EquationParser object 58 | f = EquationParser(eqChar,independentVars) 59 | 60 | x = 0.0_real64 61 | fexact = cos(2.0_real64*pi*x(1)) 62 | 63 | ! Evaluate the equation 64 | feval = f%evaluate(x) 65 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 66 | r = 0 67 | else 68 | r = 1 69 | endif 70 | 71 | endfunction cos_sfp64 72 | endprogram test 73 | -------------------------------------------------------------------------------- /test/custom_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | use iso_fortran_env,only:i1 => int8,i2 => int16,i4 => int32,i8 => int64, & 29 | r4 => real32,r8 => real64,r16 => real128 30 | use FEQParse 31 | 32 | implicit none 33 | 34 | write(*,'(A,I20)') "test ",testing() 35 | 36 | contains 37 | 38 | integer function testing() result(r) 39 | !private 40 | type(EquationParser) :: f 41 | real(r8) :: feval 42 | 43 | call AddFunction("myfunc",myfunc64) 44 | 45 | f = EquationParser("MYFUNC(x)",["x"]) 46 | 47 | feval = f%evaluate([1.0_r8]) 48 | if((abs(feval-0.5_r8)) <= epsilon(1.0_r8)) then 49 | r = 0 50 | else 51 | r = 1 52 | endif 53 | endfunction 54 | 55 | pure real(r8) function myfunc64(x) 56 | real(r8),intent(in) :: x 57 | myfunc64 = x/2.0_r8 58 | endfunction 59 | endprogram 60 | -------------------------------------------------------------------------------- /test/division_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = division_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function division_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = -x/10.0' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = -x(i,1)/10.0_real32 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction division_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/division_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = division_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function division_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = -x/10.0' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = -x(i,1)/10.0_real64 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction division_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/division_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = division_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function division_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = -x/10.0' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | fexact = -x(1)/10.0_real32 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction division_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/division_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = division_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function division_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | real(real64) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = -x/10.0' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | fexact = -x(1)/10.0_real64 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction division_sfp64 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/gaussian3d_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = gaussian3d_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function gaussian3d_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | 47 | ! Specify the independent variables 48 | independentVars = (/'x','y','z'/) 49 | 50 | ! Specify an equation string that we want to evaluate 51 | eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' 52 | 53 | ! Create the EquationParser object 54 | f = EquationParser(eqChar,independentVars) 55 | 56 | ! Evaluate the equation 57 | x = (/0.0,0.0,0.0/) 58 | if(abs(f%evaluate(x)-1.0) <= epsilon(1.0)) then 59 | r = 0 60 | else 61 | r = 1 62 | endif 63 | 64 | endfunction gaussian3d_sfp32 65 | endprogram test 66 | -------------------------------------------------------------------------------- /test/gaussian3d_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = gaussian3d_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function gaussian3d_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | 47 | ! Specify the independent variables 48 | independentVars = (/'x','y','z'/) 49 | 50 | ! Specify an equation string that we want to evaluate 51 | eqChar = 'f = exp( -(x^2 + y^2 + z^2) )' 52 | 53 | ! Create the EquationParser object 54 | f = EquationParser(eqChar,independentVars) 55 | 56 | ! Evaluate the equation 57 | x = (/0.0,0.0,0.0/) 58 | if(abs(f%evaluate(x)-1.0) <= epsilon(1.0)) then 59 | r = 0 60 | else 61 | r = 1 62 | endif 63 | 64 | endfunction gaussian3d_sfp64 65 | endprogram test 66 | -------------------------------------------------------------------------------- /test/linear_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = linear_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function linear_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = x^3-1' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = x(i,1)**3-1.0_real32 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction linear_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/linear_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = linear_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function linear_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = x^3-1' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = x(i,1)**3-1.0_real64 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction linear_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/log10_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = log10_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function log10_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = log10( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = 1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = log10(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction log10_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/log10_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = log10_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function log10_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = log10( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = log10(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction log10_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/log10_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = log10_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function log10_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = log10( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 10.0_real32 60 | fexact = log10(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction log10_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/log10_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = log10_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function log10_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | real(real64) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = log10( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 10.0_real64 60 | fexact = log10(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction log10_sfp64 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/log_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = log_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function log_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = ln( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = 1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = log(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction log_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/log_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = log_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function log_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = ln( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = 1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = log(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction log_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/log_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = log_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function log_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = ln( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 1.0_real32 60 | fexact = log(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction log_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/log_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = log_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function log_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | real(real64) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = ln( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 1.0_real64 60 | fexact = log(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction log_sfp64 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/monadic_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = monadic_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function monadic_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = -(x + 1)' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = -x(i,1)-1.0_real32 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction monadic_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/monadic_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = monadic_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function monadic_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = -(x + 1)' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = -x(i,1)-1.0_real64 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real64)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction monadic_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/monadic_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = monadic_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function monadic_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = -(x + 1)' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | fexact = -(x(1)+1.0_real32) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction monadic_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/monadic_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = monadic_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function monadic_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | real(real64) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = -(x + 1)' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | fexact = -(x(1)+1.0_real64) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction monadic_sfp64 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/print_tokens.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = print_tokens() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function print_tokens() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | type(EquationParser) :: f 42 | character(LEN=1),dimension(1:3) :: independentVars 43 | character(LEN=2048) :: eqChar 44 | 45 | ! Specify the independent variables 46 | independentVars = (/'x','y','z'/) 47 | 48 | ! Specify an equation string that we want to evaluate 49 | eqChar = 'f = -(cos( 2.0*pi*x ) + 5.0)/(sin(2.0*pi*y) + 10.0)*tanh(z)' 50 | 51 | ! Create the EquationParser object 52 | f = EquationParser(eqChar,independentVars) 53 | call f%Print_InfixTokens() 54 | call f%Print_PostfixTokens() 55 | 56 | ! Clean up memory 57 | 58 | r = 0 59 | 60 | endfunction print_tokens 61 | endprogram test 62 | -------------------------------------------------------------------------------- /test/random_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = random_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function random_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | integer :: i 48 | 49 | ! Specify the independent variables 50 | independentVars = (/'x','y','z'/) 51 | 52 | ! Specify an equation string that we want to evaluate 53 | eqChar = 'f = rand( x )' 54 | 55 | ! Create the EquationParser object 56 | f = EquationParser(eqChar,independentVars) 57 | 58 | x = 0.0_real32 59 | do i = 1,N 60 | x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 61 | enddo 62 | 63 | ! Evaluate the equation 64 | feval = f%evaluate(x) 65 | if(maxval(abs(feval)) <= 1.0_real32) then 66 | r = 0 67 | else 68 | r = 1 69 | endif 70 | 71 | endfunction random_r1fp32 72 | endprogram test 73 | -------------------------------------------------------------------------------- /test/random_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = random_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function random_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | integer :: i 48 | 49 | ! Specify the independent variables 50 | independentVars = (/'x','y','z'/) 51 | 52 | ! Specify an equation string that we want to evaluate 53 | eqChar = 'f = rand( x )' 54 | 55 | ! Create the EquationParser object 56 | f = EquationParser(eqChar,independentVars) 57 | 58 | x = 0.0_real64 59 | do i = 1,N 60 | x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 61 | enddo 62 | 63 | ! Evaluate the equation 64 | feval = f%evaluate(x) 65 | if(maxval(abs(feval)) <= 1.0_real64) then 66 | r = 0 67 | else 68 | r = 1 69 | endif 70 | 71 | endfunction random_r1fp64 72 | endprogram test 73 | -------------------------------------------------------------------------------- /test/random_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = random_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function random_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | integer :: i 48 | 49 | ! Specify the independent variables 50 | independentVars = (/'x','y','z'/) 51 | 52 | ! Specify an equation string that we want to evaluate 53 | eqChar = 'f = rand( x )' 54 | 55 | ! Create the EquationParser object 56 | f = EquationParser(eqChar,independentVars) 57 | 58 | x = 0.0_real32 59 | 60 | ! Evaluate the equation 61 | feval = f%evaluate(x) 62 | if((abs(feval)) <= 1.0_real32) then 63 | r = 0 64 | else 65 | r = 1 66 | endif 67 | 68 | endfunction random_sfp32 69 | endprogram test 70 | -------------------------------------------------------------------------------- /test/random_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = random_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function random_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | integer :: i 48 | 49 | ! Specify the independent variables 50 | independentVars = (/'x','y','z'/) 51 | 52 | ! Specify an equation string that we want to evaluate 53 | eqChar = 'f = rand( x )' 54 | 55 | ! Create the EquationParser object 56 | f = EquationParser(eqChar,independentVars) 57 | 58 | x = 0.0_real64 59 | 60 | ! Evaluate the equation 61 | feval = f%evaluate(x) 62 | if((abs(feval)) <= 1.0_real64) then 63 | r = 0 64 | else 65 | r = 1 66 | endif 67 | 68 | endfunction random_sfp64 69 | endprogram test 70 | -------------------------------------------------------------------------------- /test/sech_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = sech_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function sech_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = sech( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = 2.0_real64/(exp(x(i,1))+exp(-x(i,1))) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction sech_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/sech_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = sech_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function sech_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = sech( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | fexact = 2.0_real32/(exp(x(1))+exp(-x(1))) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction sech_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/sech_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = sech_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function sech_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | real(real64) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = sech( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | fexact = 2.0_real64/(exp(x(1))+exp(-x(1))) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction sech_sfp64 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/sin_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = sin_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function sin_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) 43 | type(EquationParser) :: f 44 | character(LEN=1),dimension(1:3) :: independentVars 45 | character(LEN=2048) :: eqChar 46 | real(real32) :: x(1:3) 47 | real(real32) :: feval 48 | real(real32) :: fexact 49 | integer :: i 50 | 51 | ! Specify the independent variables 52 | independentVars = (/'x','y','z'/) 53 | 54 | ! Specify an equation string that we want to evaluate 55 | eqChar = 'f = sin( 2.0*pi*x )' 56 | 57 | ! Create the EquationParser object 58 | f = EquationParser(eqChar,independentVars) 59 | 60 | x = 0.0_real32 61 | fexact = sin(2.0_real32*pi*x(1)) 62 | 63 | ! Evaluate the equation 64 | feval = f%evaluate(x) 65 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 66 | r = 0 67 | else 68 | r = 1 69 | endif 70 | 71 | endfunction sin_sfp32 72 | endprogram test 73 | -------------------------------------------------------------------------------- /test/sin_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = sin_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function sin_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) 43 | type(EquationParser) :: f 44 | character(LEN=1),dimension(1:3) :: independentVars 45 | character(LEN=2048) :: eqChar 46 | real(real64) :: x(1:3) 47 | real(real64) :: feval 48 | real(real64) :: fexact 49 | integer :: i 50 | 51 | ! Specify the independent variables 52 | independentVars = (/'x','y','z'/) 53 | 54 | ! Specify an equation string that we want to evaluate 55 | eqChar = 'f = sin( 2.0*pi*x )' 56 | 57 | ! Create the EquationParser object 58 | f = EquationParser(eqChar,independentVars) 59 | 60 | x = 0.0_real64 61 | fexact = sin(2.0_real64*pi*x(1)) 62 | 63 | ! Evaluate the equation 64 | feval = f%evaluate(x) 65 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 66 | r = 0 67 | else 68 | r = 1 69 | endif 70 | 71 | endfunction sin_sfp64 72 | endprogram test 73 | -------------------------------------------------------------------------------- /test/sqrt_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = sqrt_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function sqrt_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = sqrt( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = (2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = sqrt(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction sqrt_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/sqrt_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = sqrt_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function sqrt_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = sqrt( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = (2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = sqrt(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction sqrt_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/sqrt_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = sqrt_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function sqrt_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = sqrt( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 100.0_real32 60 | fexact = sqrt(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction sqrt_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/sqrt_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = sqrt_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function sqrt_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | real(real64) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = sqrt( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 100.0_real64 60 | fexact = sqrt(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction sqrt_sfp64 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/tan_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = tan_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function tan_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | real(real32),parameter :: pi = 4.0_real32*atan(1.0_real32) 43 | type(EquationParser) :: f 44 | character(LEN=1),dimension(1:3) :: independentVars 45 | character(LEN=2048) :: eqChar 46 | real(real32) :: x(1:3) 47 | real(real32) :: feval 48 | real(real32) :: fexact 49 | integer :: i 50 | 51 | ! Specify the independent variables 52 | independentVars = (/'x','y','z'/) 53 | 54 | ! Specify an equation string that we want to evaluate 55 | eqChar = 'f = tan( 0.5*pi*x )' 56 | 57 | ! Create the EquationParser object 58 | f = EquationParser(eqChar,independentVars) 59 | 60 | x = 0.0_real32 61 | fexact = tan(0.5_real32*pi*x(1)) 62 | 63 | ! Evaluate the equation 64 | feval = f%evaluate(x) 65 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 66 | r = 0 67 | else 68 | r = 1 69 | endif 70 | 71 | endfunction tan_sfp32 72 | endprogram test 73 | -------------------------------------------------------------------------------- /test/tan_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = tan_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function tan_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | real(real64),parameter :: pi = 4.0_real64*atan(1.0_real64) 43 | type(EquationParser) :: f 44 | character(LEN=1),dimension(1:3) :: independentVars 45 | character(LEN=2048) :: eqChar 46 | real(real64) :: x(1:3) 47 | real(real64) :: feval 48 | real(real64) :: fexact 49 | integer :: i 50 | 51 | ! Specify the independent variables 52 | independentVars = (/'x','y','z'/) 53 | 54 | ! Specify an equation string that we want to evaluate 55 | eqChar = 'f = tan( 0.5*pi*x )' 56 | 57 | ! Create the EquationParser object 58 | f = EquationParser(eqChar,independentVars) 59 | 60 | x = 0.0_real64 61 | fexact = tan(0.5_real64*pi*x(1)) 62 | 63 | ! Evaluate the equation 64 | feval = f%evaluate(x) 65 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 66 | r = 0 67 | else 68 | r = 1 69 | endif 70 | 71 | endfunction tan_sfp64 72 | endprogram test 73 | -------------------------------------------------------------------------------- /test/tanh_r1fp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = tanh_r1fp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function tanh_r1fp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:N,1:3) 46 | real(real32) :: feval(1:N) 47 | real(real32) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = tanh( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | do i = 1,N 61 | x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) 62 | fexact(i) = tanh(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0_real32)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction tanh_r1fp32 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/tanh_r1fp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = tanh_r1fp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function tanh_r1fp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:N,1:3) 46 | real(real64) :: feval(1:N) 47 | real(real64) :: fexact(1:N) 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = tanh( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | do i = 1,N 61 | x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) 62 | fexact(i) = tanh(x(i,1)) 63 | enddo 64 | 65 | ! Evaluate the equation 66 | feval = f%evaluate(x) 67 | if(maxval(abs(feval-fexact)) <= epsilon(1.0)) then 68 | r = 0 69 | else 70 | r = 1 71 | endif 72 | 73 | endfunction tanh_r1fp64 74 | endprogram test 75 | -------------------------------------------------------------------------------- /test/tanh_sfp32.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = tanh_sfp32() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function tanh_sfp32() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real32) :: x(1:3) 46 | real(real32) :: feval 47 | real(real32) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = tanh( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real32 60 | fexact = tanh(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real32)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction tanh_sfp32 71 | endprogram test 72 | -------------------------------------------------------------------------------- /test/tanh_sfp64.f90: -------------------------------------------------------------------------------- 1 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 2 | ! 3 | ! Maintainers : support@fluidnumerics.com 4 | ! Official Repository : https://github.com/FluidNumerics/feq-parse/ 5 | ! 6 | ! Copyright © 2024 Fluid Numerics LLC 7 | ! 8 | ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | ! 10 | ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | ! 12 | ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in 13 | ! the documentation and/or other materials provided with the distribution. 14 | ! 15 | ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from 16 | ! this software without specific prior written permission. 17 | ! 18 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 | ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | ! 25 | ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! 26 | 27 | program test 28 | 29 | implicit none 30 | integer :: exit_code 31 | 32 | exit_code = tanh_sfp64() 33 | stop exit_code 34 | 35 | contains 36 | 37 | integer function tanh_sfp64() result(r) 38 | use FEQParse 39 | use iso_fortran_env 40 | implicit none 41 | integer,parameter :: N = 10 42 | type(EquationParser) :: f 43 | character(LEN=1),dimension(1:3) :: independentVars 44 | character(LEN=2048) :: eqChar 45 | real(real64) :: x(1:3) 46 | real(real64) :: feval 47 | real(real64) :: fexact 48 | integer :: i 49 | 50 | ! Specify the independent variables 51 | independentVars = (/'x','y','z'/) 52 | 53 | ! Specify an equation string that we want to evaluate 54 | eqChar = 'f = tanh( x )' 55 | 56 | ! Create the EquationParser object 57 | f = EquationParser(eqChar,independentVars) 58 | 59 | x = 0.0_real64 60 | fexact = tanh(x(1)) 61 | 62 | ! Evaluate the equation 63 | feval = f%evaluate(x) 64 | if((abs(feval-fexact)) <= epsilon(1.0_real64)) then 65 | r = 0 66 | else 67 | r = 1 68 | endif 69 | 70 | endfunction tanh_sfp64 71 | endprogram test 72 | --------------------------------------------------------------------------------