Skip to content

Commit

Permalink
Allow GCC 10+ compilation (#21)
Browse files Browse the repository at this point in the history
* add -fallow-argument-mismatch for GCC 10+

* use compiler flag from config

* typo fix
  • Loading branch information
sseraj authored Nov 10, 2022
1 parent 3f2f060 commit f7de7a4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion common_real.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ MAKE_CLEAN_ARGUMENTS = *~ *.o *.mod *.il *.stb c_* *.a
# * *
# ******************************************************************

# Check compiler and version and add flags if needed
EXTRA_FF77_FLAGS = $(shell bash ../../config/compilerCheck.sh $(FF90))

FF77_ALL_FLAGS = -I$(MODDIR) \
$(CGNS_INCLUDE_FLAGS) \
$(FF77_FLAGS)
$(FF77_FLAGS) \
$(EXTRA_FF77_FLAGS)

FF90_ALL_FLAGS = -I$(MODDIR) \
$(CGNS_INCLUDE_FLAGS) \
Expand Down
32 changes: 32 additions & 0 deletions config/compilerCheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Need one argument at least
if [ -z $1 ]; then
echo "$0 needs to be called with the compiler name as an argument"; exit 1
fi

# Initialize variables
FF90=$1
FFLAGS=""

# Allow argument mismatch for gfortran >= 10

# NOTE: The reason for adding this flag is because Tapenade 3.16's ADFirstAidKit is not compliant with GCC 10+.
# This should be removed once Tapenade fixes this or removes the ADFirstAidKit.

fc=$("$FF90" --version 2>&1 | grep -i 'gnu')
if [ ! -z "$fc" ]; then
# Get the GNU compiler version
version=$("$FF90" -v 2>&1 | grep 'gcc version' | cut -d' ' -f3)
if [ ! -z "$version" ]; then
# Get the major version
version_major=`echo $version | cut -f1 -d.`
fi

if [ $version_major -ge 10 ]; then
FFLAGS="-fallow-argument-mismatch"
fi
fi

# Print at end to add to the makefile
echo "$FFLAGS"

0 comments on commit f7de7a4

Please sign in to comment.