diff --git a/common_real.mk b/common_real.mk index 0238661..6d644f1 100644 --- a/common_real.mk +++ b/common_real.mk @@ -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) \ diff --git a/config/compilerCheck.sh b/config/compilerCheck.sh new file mode 100644 index 0000000..336b197 --- /dev/null +++ b/config/compilerCheck.sh @@ -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"