Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow GCC 10+ compilation #21

Merged
merged 3 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"