Skip to content

Commit ab85ccd

Browse files
committed
configury: discover fortran logical false
rather than assuming its '0'/ Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 8a08730 commit ab85ccd

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed

config/ompi_fortran_check_logical_array.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ dnl All rights reserved.
1111
dnl Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
1212
dnl Copyright (c) 2015 Research Organization for Information Science
1313
dnl and Technology (RIST). All rights reserved.
14+
dnl Copyright (c) 2025 Triad National Security, LLC. All rights
15+
dnl reserved.
1416
dnl $COPYRIGHT$
1517
dnl
1618
dnl Additional copyrights may follow
@@ -64,7 +66,7 @@ void ompi_check_f(ompi_fortran_logical_t * logical)
6466
FILE *f=fopen("conftestval", "w");
6567
if (!f) exit(1);
6668

67-
if (logical[[0]] == 0 &&
69+
if (logical[[0]] == $ompi_cv_fortran_false_value &&
6870
logical[[1]] == $ompi_cv_fortran_true_value)
6971
result = 1;
7072
fprintf(f, "%d\n", result);

config/ompi_fortran_get_value_true.m4

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ dnl All rights reserved.
1111
dnl Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
1212
dnl Copyright (c) 2015 Research Organization for Information Science
1313
dnl and Technology (RIST). All rights reserved.
14+
dnl Copyright (c) 2025 Triad National Security, LLC. All rights
15+
dnl reserved.
1416
dnl $COPYRIGHT$
1517
dnl
1618
dnl Additional copyrights may follow
@@ -27,9 +29,14 @@ AC_DEFUN([OMPI_FORTRAN_GET_VALUE_TRUE],[
2729
if test "$ompi_cv_fortran_true_value" = "0" ; then
2830
unset ompi_cv_fortran_true_value
2931
fi
32+
if test "$ompi_cv_fortran_false_value" = "0" ; then
33+
unset ompi_cv_fortran_false_value
34+
fi
3035

3136
AS_VAR_PUSHDEF([fortran_true_var],
3237
[ompi_cv_fortran_true_value])
38+
AS_VAR_PUSHDEF([fortran_false_var],
39+
[ompi_cv_fortran_false_value])
3340

3441
AC_CACHE_CHECK([Fortran value for .TRUE. logical type],
3542
fortran_true_var,
@@ -98,6 +105,14 @@ EOF
98105
CALL ompi_print(value)
99106
end
100107
EOF
108+
cat > conftestf2.f <<EOF
109+
program main
110+
logical value
111+
value=.FALSE.
112+
CALL ompi_print(value)
113+
end
114+
EOF
115+
101116

102117
#
103118
# Try the compilation and run.
@@ -114,11 +129,40 @@ EOF
114129
AS_IF([test "$cross_compiling" = "yes"],
115130
[AC_MSG_ERROR([Can not determine value of .TRUE. when cross-compiling])],
116131
[OPAL_LOG_COMMAND([./conftest],
117-
[value=`sed 's/ *//' conftestval`],
132+
[tvalue=`sed 's/ *//' conftestval`],
118133
[AC_MSG_ERROR([Could not determine value of Fotran .TRUE.. Aborting.])])])
134+
135+
cat > conftestf.f <<EOF
136+
program main
137+
logical value
138+
value=.FALSE.
139+
CALL ompi_print(value)
140+
end
141+
EOF
142+
143+
#
144+
# Try the compilation and run.
145+
#
146+
OPAL_LOG_COMMAND([$CC $CFLAGS -I. -c conftest.c],
147+
[OPAL_LOG_COMMAND([$FC $FCFLAGS -o conftest conftest.o conftestf.f $LDFLAGS $LIBS],
148+
[happy=1], [happy=0])],
149+
[happy=0])
150+
151+
AS_IF([test $happy -eq 0 && test $ompi_fortran_happy -eq 1],
152+
[AC_MSG_ERROR([Could not compile Fortran .FALSE. test. Aborting.])
153+
])
154+
155+
AS_IF([test "$cross_compiling" = "yes"],
156+
[AC_MSG_ERROR([Can not determine value of .FALSE. when cross-compiling])],
157+
[OPAL_LOG_COMMAND([./conftest],
158+
[fvalue=`sed 's/ *//' conftestval`],
159+
[AC_MSG_ERROR([Could not determine value of Fotran .FALSE.. Aborting.])])])
119160
fi
120-
AS_VAR_SET(fortran_true_var, [$value])
121-
unset value
161+
AS_VAR_SET(fortran_true_var, [$tvalue])
162+
unset tvalue
163+
AS_VAR_SET(fortran_false_var, [$fvalue])
164+
unset fvalue
165+
122166
])
123167

124168
AS_VAR_COPY([ompi_fortran_true_value], [fortran_true_var])
@@ -127,6 +171,13 @@ EOF
127171
[Fortran value for LOGICAL .TRUE. value])
128172
AS_VAR_POPDEF([fortran_true_var])
129173

174+
AS_VAR_COPY([ompi_fortran_false_value], [fortran_false_var])
175+
AC_DEFINE_UNQUOTED([OMPI_FORTRAN_VALUE_FALSE],
176+
[$ompi_fortran_false_value],
177+
[Fortran value for LOGICAL .FALSE. value])
178+
AS_VAR_POPDEF([fortran_false_var])
179+
180+
130181
unset happy ompi_print_logical_fn
131182
rm -rf conftest*
132183
])dnl

0 commit comments

Comments
 (0)