Skip to content

Commit 9b6d6cf

Browse files
committed
test(linear_2d_layer): work around GCC 13
Fortran 2008 allowed for a procedure name to be passed as the actual argument to a dummy argument that is a procedure pointer. This feature was added to gfortran 14.3. This commit works around the lack of the feature in older versions.
1 parent a156df5 commit 9b6d6cf

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

test/linear_2d_layer_test_m.f90

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
#include "language-support.F90"
2+
! This include and the macros below are only required for gfortran versions older than 14.3
3+
! because those versions lacked a Fortran 2008 feature that facilitates more concise code.
4+
15
module linear_2d_layer_test_m
6+
use nf_linear2d_layer, only: linear2d_layer
27
use julienne_m, only : &
38
test_t, test_description_t, test_diagnosis_t, test_result_t &
49
,operator(.equalsExpected.), operator(//), operator(.approximates.), operator(.within.), operator(.also.), operator(.all.)
5-
use nf_linear2d_layer, only: linear2d_layer
10+
#if ! HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY
11+
use julienne_m, only : diagnosis_function_i
12+
#endif
613
implicit none
714

815
type, extends(test_t) :: linear_2d_layer_test_t
@@ -18,6 +25,8 @@ pure function subject() result(test_subject)
1825
test_subject = 'A linear_2d_layer'
1926
end function
2027

28+
#if HAVE_PROCEDURE_ACTUAL_FOR_POINTER_DUMMY
29+
2130
function results() result(test_results)
2231
type(linear_2d_layer_test_t) linear_2d_layer_test
2332
type(test_result_t), allocatable :: test_results(:)
@@ -26,6 +35,23 @@ function results() result(test_results)
2635
])
2736
end function
2837

38+
#else
39+
! Work around a missing Fortran 2008 feature that was added to gfortran in version 14.3
40+
41+
function results() result(test_results)
42+
type(linear_2d_layer_test_t) linear_2d_layer_test
43+
type(test_result_t), allocatable :: test_results(:)
44+
procedure(diagnosis_function_i), pointer :: &
45+
check_gradient_updates_ptr => check_gradient_updates
46+
47+
test_results = linear_2d_layer_test%run( &
48+
[test_description_t('updating gradients', check_gradient_updates_ptr) &
49+
])
50+
end function
51+
52+
#endif
53+
54+
2955
function check_gradient_updates() result(test_diagnosis)
3056
type(test_diagnosis_t) test_diagnosis
3157

0 commit comments

Comments
 (0)