Currently the fortran-2.eclass Fortran compiler dialect is restricted with 
check of Fortran 2003 standard.
Some packages could require to check at least Fortran 2008 support.

The proposed attached patch offer to check Fortran 2008 compatibility via one 
of the new most notable feature - Coarrays support (parallel processing 
feature).
Besides the new test file the current check require the passing of GCC 
(gfortran) compiler option `-fcoarray=single` to check Fortran 2008 
compatibility.

The same patch is available via GIthub pull request: 
https://github.com/gentoo/gentoo/pull/25920
From 8edf89bdfb35797b95b1dd061a126ed869fe6504 Mon Sep 17 00:00:00 2001
From: Sergey Torokhov <torokhov-...@yandex.ru>
Date: Thu, 16 Jun 2022 01:31:02 +0300
Subject: [PATCH] fortran-2.eclass: simple check F2008 Standard Coarray support

The GCC compiller support Coarrary only with '-fcoarray=single'
while parallel GCC implementations require external library.

Signed-off-by: Sergey Torokhov <torokhov-...@yandex.ru>
---
 eclass/fortran-2.eclass | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass
index e26dd700f7c..ccf3e12c0bb 100644
--- a/eclass/fortran-2.eclass
+++ b/eclass/fortran-2.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: fortran-2.eclass
@@ -50,7 +50,7 @@ if [[ ! ${_FORTRAN_2_CLASS} ]]; then
 # Set this, if a special dialect needs to be supported.
 # Generally not needed as default is sufficient.
 #
-# Valid settings are any combination of: 77 90 95 2003
+# Valid settings are any combination of: 77 90 95 2003 2008
 : ${FORTRAN_STANDARD:=77}
 
 # @ECLASS_VARIABLE: FORTRAN_NEEDED
@@ -138,6 +138,12 @@ _fortran_write_testsuite() {
 	       procedure(), pointer :: p
 	       end
 	EOF
+
+	# f2008 code: check base coarray support
+	cat <<- EOF > "${filebase}.f08" || die
+	       integer :: value[*]
+	       end
+	EOF
 }
 
 # @FUNCTION: _fortran_compile_test
@@ -145,6 +151,7 @@ _fortran_write_testsuite() {
 # @INTERNAL
 # @DESCRIPTION:
 # Takes fortran compiler as first argument and dialect as second.
+# Pass fortran compiler feature option if needed as third argument.
 # Checks whether the passed fortran compiler speaks the fortran dialect
 _fortran_compile_test() {
 	debug-print-function ${FUNCNAME} "${@}"
@@ -152,6 +159,7 @@ _fortran_compile_test() {
 	local filebase=${T}/test-fortran
 	local fcomp=${1}
 	local fdia=${2}
+	local fopt=${3}
 	local fcode=${filebase}.f${fdia}
 	local ret
 
@@ -160,7 +168,7 @@ _fortran_compile_test() {
 
 	[[ -f ${fcode} ]] || _fortran_write_testsuite
 
-	${fcomp} "${fcode}" -o "${fcode}.x" \
+	${fcomp} ${fopt} "${fcode}" -o "${fcode}.x" \
 		>> "${T}"/_fortran_compile_test.log 2>&1
 	ret=$?
 
@@ -235,7 +243,9 @@ _fortran_test_function() {
 				_fortran_die_msg ;;
 			2003) _fortran_compile_test "$(tc-getFC)" 03 || \
 				_fortran_die_msg ;;
-			2008) die "Future" ;;
+			2008) _fortran_compile_test "$(tc-getFC)" 08 "-fcoarray=single" || \
+				_fortran_die_msg ;;
+			2018) die "Future" ;;
 			*) die "${dialect} is not a Fortran dialect." ;;
 		esac
 	done
-- 
2.35.1

Reply via email to