Skip to content

Commit

Permalink
Merge pull request #33 from FluidNumerics/bugfix/flang-compilers
Browse files Browse the repository at this point in the history
Bugfix/flang compilers
  • Loading branch information
fluidnumerics-joe committed Jun 12, 2024
2 parents 6913d57 + fef4b5a commit 99c5862
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 12 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/linux-amdflang-cmake.yaml
Original file line number Diff line number Diff line change
@@ -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
65 changes: 65 additions & 0 deletions .github/workflows/linux-nvfortran-cmake.yaml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand All @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
13 changes: 7 additions & 6 deletions src/FEQParse.F90
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ module FEQParse

private

type IndepVar
character(:),allocatable :: value
endtype

type,public :: EquationParser
character(:),allocatable :: equation
character(:),allocatable :: variableName
Expand Down Expand Up @@ -81,10 +85,6 @@ module FEQParse

endtype EquationParser

type IndepVar
character(:),allocatable :: value
endtype

interface EquationParser
procedure Construct_EquationParser
endinterface EquationParser
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 99c5862

Please sign in to comment.