Skip to content

Commit 5816fea

Browse files
committed
fortran: check for ISO_FORTRAN_ENV:REAL16
Though this has not landed into the Fortran standard, some compilers support REAL16 in the ISO_FORTRAN_ENV module. Use it when available, and fallback to REAL*2 and COMPLEX*4 otherwise. Thanks Jeff Hammond for reporting this issue Ref. #8616 Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 1da3f93 commit 5816fea

File tree

9 files changed

+72
-15
lines changed

9 files changed

+72
-15
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
dnl -*- shell-script -*-
2+
dnl
3+
dnl Copyright (c) 2021 Research Organization for Information Science
4+
dnl and Technology (RIST). All rights reserved.
5+
dnl $COPYRIGHT$
6+
dnl
7+
dnl Additional copyrights may follow
8+
dnl
9+
dnl $HEADER$
10+
dnl
11+
12+
# Check whether or not the Fortran compiler supports the non standard
13+
# iso_fortran_env:real16 or not
14+
#
15+
# OMPI_FORTRAN_CHECK_ISO_FORTRAN_ENV_REAL16([action if found], [action if not found])
16+
# ----------------------------------------------------
17+
AC_DEFUN([OMPI_FORTRAN_CHECK_ISO_FORTRAN_ENV_REAL16],[
18+
AS_VAR_PUSHDEF([iso_fortran_env_var_real16], [ompi_cv_fortran_have_iso_fortran_env_real16])
19+
20+
AC_CACHE_CHECK([if Fortran compiler supports ISO_FORTRAN_ENV:REAL16], iso_fortran_env_var_real16,
21+
[AC_LANG_PUSH([Fortran])
22+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[program check_for_iso_fortran_env_real16
23+
use, intrinsic :: iso_fortran_env
24+
real(REAL16) :: var
25+
var = 12.34
26+
end program]])],
27+
[AS_VAR_SET(iso_fortran_env_var_real16, yes)],
28+
[AS_VAR_SET(iso_fortran_env_var_real16, no)])
29+
AC_LANG_POP([Fortran])
30+
])
31+
32+
AS_VAR_IF(iso_fortran_env_var_real16, [yes], [$1], [$2])
33+
AS_VAR_POPDEF([iso_fortran_env_var_real16])
34+
])

config/ompi_setup_mpi_fortran.m4

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dnl Copyright (c) 2006-2008 Sun Microsystems, Inc. All rights reserved.
1515
dnl Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights
1616
dnl reserved.
1717
dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
18-
dnl Copyright (c) 2014-2020 Research Organization for Information Science
18+
dnl Copyright (c) 2014-2021 Research Organization for Information Science
1919
dnl and Technology (RIST). All rights reserved.
2020
dnl Copyright (c) 2016 IBM Corporation. All rights reserved.
2121
dnl Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
@@ -328,6 +328,13 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
328328
[OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV=0])])
329329
AC_SUBST(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV)
330330

331+
# The non standard iso_fortran_env:real16 can be used for MPI_SIZEOF
332+
AS_IF([test $ompi_fortran_happy -eq 1],
333+
[OMPI_FORTRAN_CHECK_ISO_FORTRAN_ENV_REAL16(
334+
[OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16=1],
335+
[OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16=0])])
336+
AC_SUBST(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16)
337+
331338
# Ensure that the fortran compiler supports STORAGE_SIZE for
332339
# enough relevant types.
333340
AS_IF([test $ompi_fortran_happy -eq 1],

ompi/include/Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# All rights reserved.
1212
# Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
1313
# Copyright (c) 2009-2011 Oak Ridge National Labs. All rights reserved.
14-
# Copyright (c) 2014-2015 Research Organization for Information Science
15-
# and Technology (RIST). All rights reserved.
14+
# Copyright (c) 2014-2021 Research Organization for Information Science
15+
# and Technology (RIST). All rights reserved.
1616
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
1717
# $COPYRIGHT$
1818
#
@@ -88,6 +88,7 @@ mpif-sizeof.h:
8888
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
8989
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
9090
--real2=$(OMPI_HAVE_FORTRAN_REAL2) \
91+
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
9192
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
9293
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
9394
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)

ompi/mpi/fortran/base/gen-mpi-sizeof.pl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env perl
22
#
33
# Copyright (c) 2014-2015 Cisco Systems, Inc. All rights reserved.
4-
# Copyright (c) 2015-2018 Research Organization for Information Science
4+
# Copyright (c) 2015-2021 Research Organization for Information Science
55
# and Technology (RIST). All rights reserved.
66
# $COPYRIGHT$
77
#
@@ -33,6 +33,7 @@
3333
my $generate_arg;
3434
my $mpi_arg;
3535
my $mpi_real2;
36+
my $mpi_iso_real16;
3637
my $mpi_real16;
3738
my $mpi_complex4;
3839
my $mpi_complex32;
@@ -51,6 +52,7 @@
5152
"pmpi" => \$pmpi_arg,
5253
"real16=i" => \$mpi_real16,
5354
"real2=i" => \$mpi_real2,
55+
"iso_real16=i" => \$mpi_iso_real16,
5456
"help|h" => \$help_arg);
5557

5658
die "Must specify header and/or impl filenames to output"
@@ -64,8 +66,8 @@
6466
die "Must specify --pmpi and/or --mpi if --impl is specified"
6567
if (defined($generate_arg) && $generate_arg &&
6668
(defined($impl_arg) && !defined($mpi_arg) && !defined($pmpi_arg)));
67-
die "Must specify real2, real16, complex4, and complex32"
68-
if (!defined($mpi_real2) || !defined($mpi_real16) ||
69+
die "Must specify real2, iso_real16, real16, complex4, and complex32"
70+
if (!defined($mpi_real2) || !defined($mpi_iso_real16) || !defined($mpi_real16) ||
6971
!defined($mpi_complex4) || !defined($mpi_complex32));
7072

7173
#############################################################################
@@ -98,7 +100,7 @@ sub queue_sub {
98100
# For long type names and large ranks, this first line gets very
99101
# long and only narrowly squeezed in before 72 columns. Use no
100102
# whitespace.
101-
$start .= $indent . uc($f_type) . "^DIMENSION^::x
103+
$start .= $indent . " " . uc($f_type) . "^DIMENSION^::x
102104
${indent} INTEGER, INTENT(OUT) :: size
103105
${indent} INTEGER$optional_ierror_param, INTENT(OUT) :: ierror";
104106
$subr->{start} = $start;
@@ -154,15 +156,19 @@ sub generate {
154156
queue_sub("integer(int${size})", "int${size}", "int${size}");
155157
}
156158
for my $size (qw/16 32 64 128/) {
157-
if (!($size == 16 && $mpi_real2 == 0) &&
158-
!($size == 128 &&$mpi_real16 == 0)) {
159+
if (!($size == 16 && $mpi_real2 == 0 && $mpi_iso_real16 == 0) &&
160+
!($size == 128 && $mpi_real16 == 0)) {
159161
queue_sub("real(real${size})", "real${size}", "real${size}");
160162
}
161-
if (!($size == 16 && $mpi_complex4 == 0) &&
163+
if (!($size == 16 && $mpi_complex4 == 0 && $mpi_iso_real16 == 0) &&
162164
!($size == 128 && $mpi_complex32 == 0)) {
163165
queue_sub("complex(real${size})", "complex${size}", "real${size}");
164166
}
165167
}
168+
if ($mpi_real2 == 1 && $mpi_iso_real16 == 0) {
169+
queue_sub("real*2", "real16");
170+
queue_sub("complex*4", "complex16");
171+
}
166172
queue_sub("character", "character");
167173
queue_sub("logical", "logical");
168174

ompi/mpi/fortran/mpif-h/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Copyright (c) 2011-2013 Universite Bordeaux 1
1515
# Copyright (c) 2013-2018 Los Alamos National Security, LLC. All rights
1616
# reserved.
17-
# Copyright (c) 2015-2020 Research Organization for Information Science
17+
# Copyright (c) 2015-2021 Research Organization for Information Science
1818
# and Technology (RIST). All rights reserved.
1919
# Copyright (c) 2016 IBM Corporation. All rights reserved.
2020
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
@@ -122,6 +122,7 @@ sizeof_f.f90:
122122
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
123123
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
124124
--real2=$(OMPI_HAVE_FORTRAN_REAL2) \
125+
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
125126
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
126127
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
127128
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)

ompi/mpi/fortran/mpif-h/profile/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Copyright (c) 2011-2013 Universite Bordeaux 1
1616
# Copyright (c) 2013-2014 Los Alamos National Security, LLC. All rights
1717
# reserved.
18-
# Copyright (c) 2015-2020 Research Organization for Information Science
18+
# Copyright (c) 2015-2021 Research Organization for Information Science
1919
# and Technology (RIST). All rights reserved.
2020
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
2121
# $COPYRIGHT$
@@ -446,6 +446,7 @@ psizeof_f.f90:
446446
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
447447
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
448448
--real2=$(OMPI_HAVE_FORTRAN_REAL2) \
449+
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
449450
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
450451
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
451452
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)

ompi/mpi/fortran/use-mpi-f08/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Copyright (c) 2012-2013 Inria. All rights reserved.
88
# Copyright (c) 2013-2018 Los Alamos National Security, LLC. All rights
99
# reserved.
10-
# Copyright (c) 2015-2020 Research Organization for Information Science
10+
# Copyright (c) 2015-2021 Research Organization for Information Science
1111
# and Technology (RIST). All rights reserved.
1212
# Copyright (c) 2016 IBM Corporation. All rights reserved.
1313
# Copyright (c) 2017-2018 FUJITSU LIMITED. All rights reserved.
@@ -75,6 +75,7 @@ sizeof_f08.h:
7575
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
7676
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
7777
--real2=$(OMPI_HAVE_FORTRAN_REAL2) \
78+
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
7879
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
7980
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
8081
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)
@@ -87,6 +88,7 @@ sizeof_f08.f90:
8788
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
8889
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
8990
--real2=$(OMPI_HAVE_FORTRAN_REAL2) \
91+
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
9092
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
9193
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
9294
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)
@@ -99,6 +101,7 @@ profile/psizeof_f08.f90:
99101
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
100102
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
101103
--real2=$(OMPI_HAVE_FORTRAN_REAL2) \
104+
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
102105
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
103106
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
104107
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)

ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- makefile -*-
22
#
33
# Copyright (c) 2006-2019 Cisco Systems, Inc. All rights reserved.
4-
# Copyright (c) 2015-2020 Research Organization for Information Science
4+
# Copyright (c) 2015-2021 Research Organization for Information Science
55
# and Technology (RIST). All rights reserved.
66
# Copyright (c) 2016 IBM Corporation. All rights reserved.
77
#
@@ -102,6 +102,7 @@ mpi-ignore-tkr-sizeof.h:
102102
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
103103
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
104104
--real2=$(OMPI_HAVE_FORTRAN_REAL2) \
105+
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
105106
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
106107
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
107108
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)
@@ -114,6 +115,7 @@ mpi-ignore-tkr-sizeof.f90:
114115
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
115116
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
116117
--real2=$(OMPI_HAVE_FORTRAN_REAL2) \
118+
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
117119
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
118120
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
119121
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)

ompi/mpi/fortran/use-mpi-tkr/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# Copyright (c) 2006-2019 Cisco Systems, Inc. All rights reserved
1414
# Copyright (c) 2007 Los Alamos National Security, LLC. All rights
1515
# reserved.
16-
# Copyright (c) 2014-2020 Research Organization for Information Science
16+
# Copyright (c) 2014-2021 Research Organization for Information Science
1717
# and Technology (RIST). All rights reserved.
1818
# Copyright (c) 2016 IBM Corporation. All rights reserved.
1919
# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
@@ -138,6 +138,7 @@ mpi-tkr-sizeof.h:
138138
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
139139
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
140140
--real2=$(OMPI_HAVE_FORTRAN_REAL2) \
141+
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
141142
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
142143
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
143144
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)
@@ -150,6 +151,7 @@ mpi-tkr-sizeof.f90:
150151
--maxrank=$(OMPI_FORTRAN_MAX_ARRAY_RANK) \
151152
--generate=$(OMPI_FORTRAN_BUILD_SIZEOF) \
152153
--real2=$(OMPI_HAVE_FORTRAN_REAL2) \
154+
--iso_real16=$(OMPI_FORTRAN_HAVE_ISO_FORTRAN_ENV_REAL16) \
153155
--real16=$(OMPI_HAVE_FORTRAN_REAL16) \
154156
--complex4=$(OMPI_HAVE_FORTRAN_COMPLEX4) \
155157
--complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32)

0 commit comments

Comments
 (0)