Skip to content

Commit

Permalink
Implement workaround for GNU compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
aradi committed Feb 25, 2024
1 parent 02631a0 commit 04b7ee6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
40 changes: 28 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,70 +16,87 @@ env:
jobs:

#
# Test project on Ubuntu with Intel ifx compiler
# Test project in various system configurations
#
ubuntu-ifx:
fortuno-test:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
compilers: [Intel, GNU]

steps:

- name: Check-out code
uses: actions/checkout@v3

- name: Setup Intel oneAPI
- name: Setup Intel compiler
if: ${{ contains(matrix.compilers, 'Intel') }}
uses: rscohn2/setup-oneapi@v0
with:
components: ifx

- name: Set compiler environment
- name: Setup Intel environment
if: ${{ contains(matrix.compilers, 'Intel') }}
run: |
source /opt/intel/oneapi/setvars.sh
printenv >> ${GITHUB_ENV}
echo "FC=ifx" >> ${GITHUB_ENV}
echo "FPM_FC=ifx" >> ${GITHUB_ENV}
- name: Setup GNU compiler
if: ${{ contains(matrix.compilers, 'GNU') }}
uses: fortran-lang/setup-fortran@v1
with:
compiler: gcc
version: 13

- name: Setup GNU environment
if: ${{ contains(matrix.compilers, 'GNU') }}
run: |
echo "FC=${{ env.FC }}" >> ${GITHUB_ENV}
echo "FPM_FC=${{ env.FC }}" >> ${GITHUB_ENV}
- name: Setup build tools
run: |
pip install cmake fpm meson ninja
- name: Build Fortuno
run: |
source /opt/intel/oneapi/setvars.sh
cmake -B ${BUILD_DIR} -G Ninja -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
cmake --build ${BUILD_DIR}
cmake --install ${BUILD_DIR}
rm -rf ${BUILD_DIR}
- name: Test CMake export
run: |
source /opt/intel/oneapi/setvars.sh
CMAKE_PREFIX_PATH=${INSTALL_DIR} cmake -B ${BUILD_DIR} -G Ninja test/export
cmake --build ${BUILD_DIR}
${BUILD_DIR}/testapp
rm -rf ${BUILD_DIR}
- name: Test PkgConfig export
run: |
source /opt/intel/oneapi/setvars.sh
export LD_LIBRARY_PATH="${PWD}/${INSTALL_DIR}/lib:${LD_LIBRARY_PATH}"
export PKG_CONFIG_PATH="${PWD}/${INSTALL_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH}"
cflags="$(pkg-config --cflags fortuno)"
lflags="$(pkg-config --libs fortuno)"
mkdir ${BUILD_DIR}
pushd ${BUILD_DIR}
ifx ${cflags} ${lflags} -o testapp ../test/export/app/testapp.f90
${FC} ${cflags} -o testapp ../test/export/app/testapp.f90 ${lflags}
./testapp
popd
rm -rf ${BUILD_DIR}
- name: Test fpm export
run: |
source /opt/intel/oneapi/setvars.sh
cd test/export
fpm run testapp
- name: Test meson PkgConfig export
run: |
source /opt/intel/oneapi/setvars.sh
export PKG_CONFIG_PATH="${PWD}/${INSTALL_DIR}/lib/pkgconfig:${PKG_CONFIG_PATH}"
cd test/export
meson setup -Dfortuno_subproject=false ${BUILD_DIR}
Expand All @@ -89,7 +106,6 @@ jobs:
- name: Test meson subproject export
run: |
source /opt/intel/oneapi/setvars.sh
FORTUNO_DIR=${PWD}
GIT_REV=$(git rev-parse HEAD)
cd test/export
Expand Down
16 changes: 14 additions & 2 deletions src/fortuno/argumentparser.f90
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ subroutine argument_parser_parse_args(this, argumentvalues, logger, exitcode)
allocate(argumentvalues%argvals(0))
allocate(posargs(0))
optionsallowed = .true.

! Process all arguments
iarg = 0
argloop: do while (iarg < nargs)
iarg = iarg + 1
Expand Down Expand Up @@ -183,10 +185,20 @@ subroutine argument_parser_parse_args(this, argumentvalues, logger, exitcode)
return
end associate
end do argloop

! Check collected positional arguments
associate (argdef => this%argdefs(nargdefs))
! If the last argdef was not an option, store all position arguments under this name
if (.not. allocated(argdef%longopt) .and. argdef%shortopt == "") then
argumentvalues%argvals = [argumentvalues%argvals,&
& argument_value(name=argdef%name, argval=string_list(posargs))]
! argumentvalues%argvals = [argumentvalues%argvals,&
! & argument_value(name=argdef%name, argval=string_list(posargs))]
! Workaround:gfortran:13.2
block
class(*), allocatable :: tmp
tmp = string_list(posargs)
argumentvalues%argvals = [argumentvalues%argvals,&
& argument_value(name=argdef%name, argval=tmp)]
end block
else if (size(posargs) > 1) then
call logger%log_error("Superfluous positional arguments found")
exitcode = 1
Expand Down

0 comments on commit 04b7ee6

Please sign in to comment.