diff --git a/.github/workflows/linux-amdflang-cmake.yaml b/.github/workflows/linux-amdflang-cmake.yaml new file mode 100644 index 0000000..5319dcd --- /dev/null +++ b/.github/workflows/linux-amdflang-cmake.yaml @@ -0,0 +1,68 @@ +name: linux-amdflang-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 }} - ${{ matrix.fcompiler }} - ${{ matrix.build_type }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-22.04 + fcompiler: amdflang + ccompiler: amdclang + shell: bash + build_type: debug + memcheck: false + + defaults: + run: + shell: ${{ matrix.shell }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + + - name: rocm-setup + run: | + sudo apt update -y + wget https://repo.radeon.com/amdgpu-install/6.1.1/ubuntu/jammy/amdgpu-install_6.1.60101-1_all.deb + sudo apt install -y ./amdgpu-install_6.1.60101-1_all.deb + sudo amdgpu-install --accept-eula -y --usecase=openmpsdk --no-dkms + + - name: Show version information + run: | + export PATH=${PATH}:/opt/rocm/bin + ${{ matrix.fcompiler }} --version + ${{ matrix.ccompiler }} --version + + - name: Build with Cmake + run: | + export PATH=${PATH}:/opt/rocm/bin + mkdir build + cd build + FC=${{ matrix.fcompiler }} CC=${{ matrix.ccompiler }} 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/.github/workflows/linux-nvfortran-cmake.yaml b/.github/workflows/linux-nvfortran-cmake.yaml new file mode 100644 index 0000000..957b508 --- /dev/null +++ b/.github/workflows/linux-nvfortran-cmake.yaml @@ -0,0 +1,65 @@ +name: linux-nvidia-hpc-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 }} - ${{ matrix.toolchain.compiler }} - ${{ matrix.build_type }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + toolchain: + - {compiler: nvidia-hpc, version: '23.11'} + include: + - os: ubuntu-22.04 + shell: bash + build_type: debug + toolchain: {compiler: nvidia-hpc, version: '23.11'} + + defaults: + run: + shell: ${{ matrix.shell }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - uses: fortran-lang/setup-fortran@v1 + id: setup-fortran + with: + compiler: ${{ matrix.toolchain.compiler }} + version: ${{ matrix.toolchain.version }} + + - name: Show version information + run: | + ${{ env.FC }} --version + ${{ env.CC }} --version + + - name: Build with Cmake + run: | + export PATH=${PATH}:/opt/rocm/bin + mkdir build + cd build + FC=${{ env.FC }} CC=${{ env.CC }} 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 4dc8642..2e5b54e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,8 @@ ENDIF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90) # Default Fortran compiler flags # Fortran compiler flags +message(CMAKE_Fortran_COMPILER_ID="${CMAKE_Fortran_COMPILER_ID}") + if( "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU" ) set( CMAKE_Fortran_FLAGS "-cpp -ffree-line-length-512" ) set( CMAKE_Fortran_FLAGS_DEBUG "-g -O0 -C -Wall -fbounds-check -fbacktrace -ffpe-trap=invalid,zero,overflow" ) @@ -41,6 +43,22 @@ elseif( "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "IntelLLVM" ) 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 "Flang" ) + 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_PROFILE "-O3") + set( CMAKE_Fortran_FLAGS_RELEASE "-O3" ) + set( CMAKE_C_FLAGS_COVERAGE "-g -O0") + + 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 + set( CMAKE_Fortran_FLAGS_PROFILE "-O3 -Mstack_arrays -Minfo") + set( CMAKE_Fortran_FLAGS_RELEASE "-O3 -Mstack_arrays -Minfo" ) + set( CMAKE_C_FLAGS_COVERAGE "-g -O0") endif() ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/src) diff --git a/README.md b/README.md index d45b08b..9709d51 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,18 @@ # Fortran Equation Parser Copyright 2020 Fluid Numerics LLC -[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-gnu-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-gnu-cmake.yml) -[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-gnu-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-gnu-fpm.yml) +[![linux-gnu-cmake](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-gnu-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-gnu-cmake.yml) +[![linux-gnu-fpm](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-gnu-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-gnu-fpm.yml) -[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-intel-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-intel-cmake.yml) -[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-intel-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-intel-fpm.yml) +[![linux-intel-cmake](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-intel-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-intel-cmake.yml) +[![linux-intel-fpm](https://github.com/fluidnumerics/feq-parse/actions/workflows/linux-intel-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/linux-intel-fpm.yml) +[![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) -[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/windows-gnu-cmake.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/windows-gnu-cmake.yml) -[![Build Status](https://github.com/fluidnumerics/feq-parse/actions/workflows/windows-gnu-fpm.yml/badge.svg)](https://github.com/FluidNumerics/feq-parse/actions/workflows/windows-gnu-fpm.yml) +[![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) [![codecov](https://codecov.io/gh/FluidNumerics/feq-parse/graph/badge.svg?token=IBNDDI4MHB)](https://codecov.io/gh/FluidNumerics/feq-parse) diff --git a/src/FEQParse.F90 b/src/FEQParse.F90 index 377bc9b..1674796 100644 --- a/src/FEQParse.F90 +++ b/src/FEQParse.F90 @@ -49,6 +49,10 @@ module FEQParse private + type IndepVar + character(:),allocatable :: value + endtype + type,public :: EquationParser character(:),allocatable :: equation character(:),allocatable :: variableName @@ -81,10 +85,6 @@ module FEQParse endtype EquationParser - type IndepVar - character(:),allocatable :: value - endtype - interface EquationParser procedure Construct_EquationParser endinterface EquationParser @@ -330,7 +330,6 @@ subroutine ConvertToPostFix(parser) call operator_stack%Construct(Stack_Length) do i = 1,parser%infix%top_index - !print*, parser % inFix % tokens(i) % tokenString if(parser%inFix%tokens(i)%tokenType == Variable_Token .or. & parser%inFix%tokens(i)%tokenType == Number_Token) then @@ -349,7 +348,8 @@ subroutine ConvertToPostFix(parser) do while(trim(tok%tokenString) /= '(' .and. & parser%Priority(tok) > & - parser%Priority(parser%inFix%tokens(i))) + parser%Priority(parser%inFix%tokens(i)) .and. & + .not. operator_stack%IsEmpty()) call parser%postFix%push(tok) call operator_stack%pop(tok) @@ -836,6 +836,7 @@ function Evaluate_r2fp32(parser,x) result(f) do k = 1,parser%postfix%top_index t = parser%postfix%tokens(k)%Copy() + print*,trim(t%tokenString) select case(t%tokenType)