diff --git a/.github/workflows/linux-llvmflang-cmake.yaml b/.github/workflows/linux-llvmflang-cmake.yaml new file mode 100644 index 0000000..5818fb5 --- /dev/null +++ b/.github/workflows/linux-llvmflang-cmake.yaml @@ -0,0 +1,65 @@ +name: linux-llvmflang-cmake + +on: + push: + branches: + - master + - main + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + pull_request: + paths-ignore: + - 'AUTHORS.md' + - 'LICENSE.md' + - 'README.md' + +jobs: + linux-tests: + timeout-minutes: 20 + if: "!contains(github.event.head_commit.message, 'skip ci')" + name: ${{ matrix.os }} - flang-new-${{ matrix.llvm_version }} - ${{ matrix.build_type }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-24.04 + llvm_version: 19 + build_type: debug + + - os: ubuntu-24.04 + llvm_version: 20 + build_type: debug + + defaults: + run: + shell: bash + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install LLVM Flang + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${{ matrix.llvm_version }} + sudo apt-get install -y flang-${{ matrix.llvm_version }} + + - name: Show version information + run: | + flang-new-${{ matrix.llvm_version }} --version + clang-${{ matrix.llvm_version }} --version + + - name: Build with Cmake + run: | + mkdir build + cd build + FC=flang-new-${{ matrix.llvm_version }} CC=clang-${{ matrix.llvm_version }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ../ + make VERBOSE=1 + + - name: Run ctests + run: | + cd build/test + ctest || ctest --rerun-failed --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index e403bfd..6535c20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,14 +71,24 @@ elseif( "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "IntelLLVM" ) set( CMAKE_C_FLAGS_COVERAGE "-g -O0") elseif( "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "Flang" ) + # Classic Flang (PGI-derived) set( CMAKE_Fortran_FLAGS "-Mpreprocess" ) set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -O0 -g -Wall -pedantic" ) - set( CMAKE_Fortran_FLAGS_COVERAGE "${CMAKE_Fortran_FLAGS_DEBUG}") # Code coverage not available with ifx + set( CMAKE_Fortran_FLAGS_COVERAGE "${CMAKE_Fortran_FLAGS_DEBUG}") # Code coverage not available + set( CMAKE_Fortran_FLAGS_PROFILE "-O3") + set( CMAKE_Fortran_FLAGS_RELEASE "-O3" ) + set( CMAKE_C_FLAGS_COVERAGE "-g -O0") + +elseif( "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "LLVMFlang" ) + # LLVM Flang (flang-new, LLVM-based) - uses GCC-style flags + set( CMAKE_Fortran_FLAGS "-cpp" ) + set( CMAKE_Fortran_FLAGS_DEBUG "-g -O0 -Wall -pedantic" ) + set( CMAKE_Fortran_FLAGS_COVERAGE "${CMAKE_Fortran_FLAGS_DEBUG}") # Code coverage not available set( CMAKE_Fortran_FLAGS_PROFILE "-O3") set( CMAKE_Fortran_FLAGS_RELEASE "-O3" ) set( CMAKE_C_FLAGS_COVERAGE "-g -O0") - elseif( "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "NVHPC" ) +elseif( "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "NVHPC" ) set( CMAKE_Fortran_FLAGS "-Mpreprocess" ) set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -O0 -Wall -C -g -traceback" ) set( CMAKE_Fortran_FLAGS_COVERAGE "${CMAKE_Fortran_FLAGS_DEBUG}") # Code coverage not available with ifx diff --git a/README.md b/README.md index a5e5c65..91f2cb0 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Copyright 2020 Fluid Numerics LLC [![linux-amdflang-cmake](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-amdflang-cmake.yaml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-amdflang-cmake.yaml) [![linux-nvfortran-cmake](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-nvfortran-cmake.yaml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-nvfortran-cmake.yaml) +[![linux-llvmflang-cmake](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-llvmflang-cmake.yaml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-llvmflang-cmake.yaml) [![windows-gnu-cmake](https://github.com/fluidnumerics/feq-parse/actions/workflows/windows-gnu-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/windows-gnu-cmake.yml) [![windows-gnu-fpm](https://github.com/fluidnumerics/feq-parse/actions/workflows/windows-gnu-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/windows-gnu-fpm.yml) @@ -134,6 +135,7 @@ GNU Fortran | 13.2.0 | Windows Server 2022 (10.0.20348 Build 1547) (MSYS2) | `fp Intel oneAPI (`ifx`)| 2023.2 | Ubuntu 22.04.2 LTS | `fpm`, `cmake` | x86_64 Intel oneAPI classic (`ifort`) | 2021.1 | Ubuntu 22.04.2 LTS | `fpm`, `cmake` | x86_64 Nvidia HPC (`nvfortran`) | 23.11 | Ubuntu 22.04.2 LTS | `cmake` | x86_64 +LLVM Flang (`flang-new`) | 19, 20 | Ubuntu 24.04 LTS | `cmake` | x86_64 ## Usage diff --git a/src/FEQParse_Functions.f90 b/src/FEQParse_Functions.f90 index d7c9001..2edc4a5 100644 --- a/src/FEQParse_Functions.f90 +++ b/src/FEQParse_Functions.f90 @@ -29,7 +29,7 @@ module FEQParse_Functions implicit none - integer,public :: nFunctions = 17 + integer,public :: nFunctions = 16 integer,protected,public :: maxFunctionLength = 0 integer,parameter :: maxFunctions = 100 logical :: isInitialized = .false. @@ -51,7 +51,6 @@ module FEQParse_Functions enumerator :: asin_function = 14 enumerator :: atan_function = 15 enumerator :: sech_function = 16 - enumerator :: rand_function = 17 endenum private @@ -104,18 +103,6 @@ pure real(real64) function f64(x) type(FEQParse_Function),public :: Functions(maxFunctions) - interface - pure real(real32) function randomize_r32() - import - endfunction - endinterface - - interface - pure real(real64) function randomize_r64() - import - endfunction - endinterface - interface AddFunction module procedure :: AddFunction32 module procedure :: AddFunction64 @@ -268,10 +255,6 @@ subroutine InitializeFunctions() Functions(sech_function)%ptr32 => sech32 Functions(sech_function)%ptr64 => sech64 - Functions(rand_function) = Tuple("rand","RAND") - Functions(rand_function)%ptr32 => rand32 - Functions(rand_function)%ptr64 => rand64 - isInitialized = .true. endsubroutine InitializeFunctions @@ -473,24 +456,6 @@ pure real(real64) function sech64(x) result(fx) fx = 2.0_real64/(exp(x)+exp(-x)) endfunction - pure real(real32) function rand32(x) result(fx) - real(real32),intent(in) :: x - !private - real(real32) :: r - associate(r => randomize_r32()) - fx = r*x - endassociate - endfunction - - pure real(real64) function rand64(x) result(fx) - real(real64),intent(in) :: x - !private - real(real64) :: r - associate(r => randomize_r64()) - fx = r*x - endassociate - endfunction - pure function ToUpperCase(str) result(res) character(*),intent(in) :: str character(len(str)) :: res @@ -507,19 +472,3 @@ pure function ToUpperCase(str) result(res) endfunction ToUpperCase endmodule FEQParse_Functions - -real(real32) function randomize_r32() - use,intrinsic :: iso_fortran_env,only:real32 - real(real32) :: r - - call random_number(r) - randomize_r32 = r -endfunction - -real(real64) function randomize_r64() - use,intrinsic :: iso_fortran_env,only:real64 - real(real64) :: r - - call random_number(r) - randomize_r64 = r -endfunction diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 20e432e..40bb627 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -154,16 +154,6 @@ add_fortran_tests ( "monadic_r4fp64.f90" "monadic_sfp32.f90" "monadic_sfp64.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" diff --git a/test/random_r1fp32.f90 b/test/random_r1fp32.f90 deleted file mode 100644 index da3a76e..0000000 --- a/test/random_r1fp32.f90 +++ /dev/null @@ -1,72 +0,0 @@ -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! -! -! Maintainers : support@fluidnumerics.com -! Official Repository : https://github.com/FluidNumerics/feq-parse/ -! -! Copyright © 2024 Fluid Numerics LLC -! -! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -! -! 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. -! -! 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. -! -! 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. -! -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! - -program test - - implicit none - integer :: exit_code - - exit_code = random_r1fp32() - stop exit_code - -contains - - integer function random_r1fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:N,1:3) - real(real32) :: feval(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do i = 1,N - x(i,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) - enddo - - ! Evaluate the equation - feval = f%evaluate(x) - if(maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - endif - - endfunction random_r1fp32 -endprogram test diff --git a/test/random_r1fp64.f90 b/test/random_r1fp64.f90 deleted file mode 100644 index 4e4c629..0000000 --- a/test/random_r1fp64.f90 +++ /dev/null @@ -1,72 +0,0 @@ -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! -! -! Maintainers : support@fluidnumerics.com -! Official Repository : https://github.com/FluidNumerics/feq-parse/ -! -! Copyright © 2024 Fluid Numerics LLC -! -! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -! -! 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. -! -! 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. -! -! 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. -! -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! - -program test - - implicit none - integer :: exit_code - - exit_code = random_r1fp64() - stop exit_code - -contains - - integer function random_r1fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:N,1:3) - real(real64) :: feval(1:N) - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do i = 1,N - x(i,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) - enddo - - ! Evaluate the equation - feval = f%evaluate(x) - if(maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - endif - - endfunction random_r1fp64 -endprogram test diff --git a/test/random_r2fp32.f90 b/test/random_r2fp32.f90 deleted file mode 100644 index 2413bd5..0000000 --- a/test/random_r2fp32.f90 +++ /dev/null @@ -1,80 +0,0 @@ -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! -! -! Maintainers : support@fluidnumerics.com -! Official Repository : https://github.com/FluidNumerics/feq-parse/ -! -! Copyright © 2024 Fluid Numerics LLC -! -! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -! -! 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. -! -! 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. -! -! 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. -! -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! - -program test - - implicit none - integer :: exit_code - - exit_code = random_r2fp32() - stop exit_code - -contains - - integer function random_r2fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:) - real(real32),allocatable :: feval(:,:) - integer :: i,j - - allocate(x(1:N,1:N,1:3), & - feval(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) - x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) - enddo - enddo - - ! Evaluate the equation - feval = f%evaluate(x) - if(maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - endif - - deallocate(x,feval) - - endfunction random_r2fp32 -endprogram test diff --git a/test/random_r2fp64.f90 b/test/random_r2fp64.f90 deleted file mode 100644 index 5601362..0000000 --- a/test/random_r2fp64.f90 +++ /dev/null @@ -1,80 +0,0 @@ -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! -! -! Maintainers : support@fluidnumerics.com -! Official Repository : https://github.com/FluidNumerics/feq-parse/ -! -! Copyright © 2024 Fluid Numerics LLC -! -! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -! -! 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. -! -! 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. -! -! 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. -! -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! - -program test - - implicit none - integer :: exit_code - - exit_code = random_r2fp64() - stop exit_code - -contains - - integer function random_r2fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:) - real(real64),allocatable :: feval(:,:) - integer :: i,j - - allocate(x(1:N,1:N,1:3), & - feval(1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do j = 1,N - do i = 1,N - x(i,j,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) - x(i,j,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) - enddo - enddo - - ! Evaluate the equation - feval = f%evaluate(x) - if(maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - endif - - deallocate(x,feval) - - endfunction random_r2fp64 -endprogram test diff --git a/test/random_r3fp32.f90 b/test/random_r3fp32.f90 deleted file mode 100644 index 9a96ae5..0000000 --- a/test/random_r3fp32.f90 +++ /dev/null @@ -1,85 +0,0 @@ -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! -! -! Maintainers : support@fluidnumerics.com -! Official Repository : https://github.com/FluidNumerics/feq-parse/ -! -! Copyright © 2024 Fluid Numerics LLC -! -! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -! -! 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. -! -! 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. -! -! 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. -! -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! - -program test - - implicit none - integer :: exit_code - - exit_code = random_r3fp32() - stop exit_code - -contains - - integer function random_r3fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:) - real(real32),allocatable :: feval(:,:,:) - real(real32),allocatable :: fexact(:,:,:) - integer :: i,j,k - - allocate(x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real32+(2.0_real32)/real(N,real32)*real(i-1,real32) - x(i,j,k,2) = -1.0_real32+(2.0_real32)/real(N,real32)*real(j-1,real32) - x(i,j,k,3) = -1.0_real32+(2.0_real32)/real(N,real32)*real(k-1,real32) - enddo - enddo - enddo - - ! Evaluate the equation - feval = f%evaluate(x) - if(maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - endif - - deallocate(x,feval,fexact) - - endfunction random_r3fp32 -endprogram test diff --git a/test/random_r3fp64.f90 b/test/random_r3fp64.f90 deleted file mode 100644 index 73016db..0000000 --- a/test/random_r3fp64.f90 +++ /dev/null @@ -1,85 +0,0 @@ -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! -! -! Maintainers : support@fluidnumerics.com -! Official Repository : https://github.com/FluidNumerics/feq-parse/ -! -! Copyright © 2024 Fluid Numerics LLC -! -! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -! -! 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. -! -! 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. -! -! 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. -! -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! - -program test - - implicit none - integer :: exit_code - - exit_code = random_r3fp64() - stop exit_code - -contains - - integer function random_r3fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:) - real(real64),allocatable :: feval(:,:,:) - real(real64),allocatable :: fexact(:,:,:) - integer :: i,j,k - - allocate(x(1:N,1:N,1:N,1:3), & - feval(1:N,1:N,1:N), & - fexact(1:N,1:N,1:N)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,1) = -1.0_real64+(2.0_real64)/real(N,real64)*real(i-1,real64) - x(i,j,k,2) = -1.0_real64+(2.0_real64)/real(N,real64)*real(j-1,real64) - x(i,j,k,3) = -1.0_real64+(2.0_real64)/real(N,real64)*real(k-1,real64) - enddo - enddo - enddo - - ! Evaluate the equation - feval = f%evaluate(x) - if(maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - endif - - deallocate(x,feval,fexact) - - endfunction random_r3fp64 -endprogram test diff --git a/test/random_r4fp32.f90 b/test/random_r4fp32.f90 deleted file mode 100644 index 8768958..0000000 --- a/test/random_r4fp32.f90 +++ /dev/null @@ -1,88 +0,0 @@ -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! -! -! Maintainers : support@fluidnumerics.com -! Official Repository : https://github.com/FluidNumerics/feq-parse/ -! -! Copyright © 2024 Fluid Numerics LLC -! -! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -! -! 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. -! -! 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. -! -! 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. -! -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! - -program test - - implicit none - integer :: exit_code - - exit_code = random_r4fp32() - stop exit_code - -contains - - integer function random_r4fp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real32),allocatable :: x(:,:,:,:,:) - real(real32),allocatable :: feval(:,:,:,:) - real(real32),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l - - allocate(x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real32+(0.1_real32)/real(N,real32)*real(i-1,real32)+0.1_real32*real(l-1,real32) - x(i,j,k,l,2) = -1.0_real32+(0.1_real32)/real(N,real32)*real(j-1,real32) - x(i,j,k,l,3) = -1.0_real32+(0.1_real32)/real(N,real32)*real(k-1,real32) - enddo - enddo - enddo - enddo - - ! Evaluate the equation - feval = f%evaluate(x) - if(maxval(abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - endif - - deallocate(x,feval,fexact) - - endfunction random_r4fp32 -endprogram test diff --git a/test/random_r4fp64.f90 b/test/random_r4fp64.f90 deleted file mode 100644 index bd2025d..0000000 --- a/test/random_r4fp64.f90 +++ /dev/null @@ -1,88 +0,0 @@ -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! -! -! Maintainers : support@fluidnumerics.com -! Official Repository : https://github.com/FluidNumerics/feq-parse/ -! -! Copyright © 2024 Fluid Numerics LLC -! -! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -! -! 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. -! -! 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. -! -! 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. -! -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! - -program test - - implicit none - integer :: exit_code - - exit_code = random_r4fp64() - stop exit_code - -contains - - integer function random_r4fp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 2 - integer,parameter :: M = 5 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=1024) :: eqChar - real(real64),allocatable :: x(:,:,:,:,:) - real(real64),allocatable :: feval(:,:,:,:) - real(real64),allocatable :: fexact(:,:,:,:) - integer :: i,j,k,l - - allocate(x(1:N,1:N,1:N,1:M,1:3), & - feval(1:N,1:N,1:N,1:M), & - fexact(1:N,1:N,1:N,1:M)) - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )*rand( y )*rand( z )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - do l = 1,M - do k = 1,N - do j = 1,N - do i = 1,N - x(i,j,k,l,1) = -1.0_real64+(0.1_real64)/real(N,real64)*real(i-1,real64)+0.1_real64*real(l-1,real64) - x(i,j,k,l,2) = -1.0_real64+(0.1_real64)/real(N,real64)*real(j-1,real64) - x(i,j,k,l,3) = -1.0_real64+(0.1_real64)/real(N,real64)*real(k-1,real64) - enddo - enddo - enddo - enddo - - ! Evaluate the equation - feval = f%evaluate(x) - if(maxval(abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - endif - - deallocate(x,feval,fexact) - - endfunction random_r4fp64 -endprogram test diff --git a/test/random_sfp32.f90 b/test/random_sfp32.f90 deleted file mode 100644 index 2745735..0000000 --- a/test/random_sfp32.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! -! -! Maintainers : support@fluidnumerics.com -! Official Repository : https://github.com/FluidNumerics/feq-parse/ -! -! Copyright © 2024 Fluid Numerics LLC -! -! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -! -! 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. -! -! 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. -! -! 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. -! -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! - -program test - - implicit none - integer :: exit_code - - exit_code = random_sfp32() - stop exit_code - -contains - - integer function random_sfp32() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real32) :: x(1:3) - real(real32) :: feval - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real32 - - ! Evaluate the equation - feval = f%evaluate(x) - if((abs(feval)) <= 1.0_real32) then - r = 0 - else - r = 1 - endif - - endfunction random_sfp32 -endprogram test diff --git a/test/random_sfp64.f90 b/test/random_sfp64.f90 deleted file mode 100644 index a12c6ad..0000000 --- a/test/random_sfp64.f90 +++ /dev/null @@ -1,69 +0,0 @@ -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! -! -! Maintainers : support@fluidnumerics.com -! Official Repository : https://github.com/FluidNumerics/feq-parse/ -! -! Copyright © 2024 Fluid Numerics LLC -! -! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -! -! 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. -! -! 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. -! -! 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. -! -! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! - -program test - - implicit none - integer :: exit_code - - exit_code = random_sfp64() - stop exit_code - -contains - - integer function random_sfp64() result(r) - use FEQParse - use iso_fortran_env - implicit none - integer,parameter :: N = 10 - type(EquationParser) :: f - character(LEN=1),dimension(1:3) :: independentVars - character(LEN=2048) :: eqChar - real(real64) :: x(1:3) - real(real64) :: feval - integer :: i - - ! Specify the independent variables - independentVars = (/'x','y','z'/) - - ! Specify an equation string that we want to evaluate - eqChar = 'f = rand( x )' - - ! Create the EquationParser object - f = EquationParser(eqChar,independentVars) - - x = 0.0_real64 - - ! Evaluate the equation - feval = f%evaluate(x) - if((abs(feval)) <= 1.0_real64) then - r = 0 - else - r = 1 - endif - - endfunction random_sfp64 -endprogram test