Skip to content

Commit

Permalink
Allow GCC 10+ to compile (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikurj authored Nov 14, 2022
1 parent ee52eaf commit a07a21a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
37 changes: 37 additions & 0 deletions config/compilerCheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/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 primary reason for this is that the CGNS library does not provide explicit
# Fortran interface at this time for some of the functions as mentioned
# in the docs https://cgns.github.io/CGNS_docs_current/midlevel/general.html
# and source https://github.com/CGNS/CGNS/blob/develop/src/cgns_f.F90
# Once CGNS lib supports explicit interface this script should be removed
# and any issues with the code addressed.

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"
6 changes: 6 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
include ../config.mk

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

# Append any flags
FFLAGS += $(EXTRA_FFLAGS)

PYTHON_OBJECTS = fortranobject.o \
kd_tree.o \
libcgns_utilsmodule.o \
Expand Down

0 comments on commit a07a21a

Please sign in to comment.