Skip to content

Commit 23ed2f4

Browse files
committed
fortran/use-mpi-f08: revamp constant declarations
In order to work around an issue with flang based compilers, avoid declaring bind(C) constants and use plain Fortran parameter instead. For example, type(MPI_Comm), bind(C, name="ompi_f08_mpi_comm_world") OMPI_PROTECTED :: MPI_COMM_WORLD is changed to type(MPI_Comm), parameter :: MPI_COMM_WORLD = MPI_Comm(OMPI_MPI_COMM_WORLD) Note that in order to preserve ABI compatibility, ompi/mpi/fortran/use-mpi-f08/constants.{c,h} have been kept even if its symbols are no more referenced by Open MPI. Refs. open-mpi#7091 Signed-off-by: Gilles Gouaillardet <[email protected]> (back-ported from commit open-mpi/ompi@b10a60a)
1 parent 56d2865 commit 23ed2f4

File tree

4 files changed

+171
-110
lines changed

4 files changed

+171
-110
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ ompi/mpi/fortran/mpif-h/sizeof_f.f90
213213
ompi/mpi/fortran/mpif-h/profile/p*.c
214214
ompi/mpi/fortran/mpif-h/profile/psizeof_f.f90
215215

216+
ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-constants.h
216217
ompi/mpi/fortran/use-mpi-f08/constants.h
217218
ompi/mpi/fortran/use-mpi-f08/sizeof_f08.f90
218219
ompi/mpi/fortran/use-mpi-f08/sizeof_f08.h

ompi/include/mpif-values.pl

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env perl
22
#
33
# Copyright (c) 2011-2014 Cisco Systems, Inc. All rights reserved.
4-
# Copyright (c) 2016-2017 Research Organization for Information Science
5-
# and Technology (RIST). All rights reserved.
4+
# Copyright (c) 2016-2019 Research Organization for Information Science
5+
# and Technology (RIST). All rights reserved.
66
# Copyright (c) 2016 FUJITSU LIMITED. All rights reserved.
77
# $COPYRIGHT$
88
#
@@ -526,4 +526,62 @@ sub write_fortran_file {
526526

527527
write_file("$topdir/ompi/mpi/fortran/use-mpi-f08/constants.h", $output);
528528

529+
$output = '! WARNING! THIS IS A GENERATED FILE!!
530+
! ANY EDITS YOU PUT HERE WILL BE LOST!
531+
! Instead, edit topdir/ompi/include/mpif-values.pl
532+
!
533+
534+
!
535+
! Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
536+
! University Research and Technology
537+
! Corporation. All rights reserved.
538+
! Copyright (c) 2004-2006 The University of Tennessee and The University
539+
! of Tennessee Research Foundation. All rights
540+
! reserved.
541+
! Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
542+
! University of Stuttgart. All rights reserved.
543+
! Copyright (c) 2004-2005 The Regents of the University of California.
544+
! All rights reserved.
545+
! Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved.
546+
! Copyright (c) 2008-2009 Sun Microsystems, Inc. All rights reserved.
547+
! Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
548+
! Copyright (c) 2009-2012 Los Alamos National Security, LLC.
549+
! All rights reserved.
550+
! Copyright (c) 2016-2019 Research Organization for Information Science
551+
! and Technology (RIST). All rights reserved.
552+
! $COPYRIGHT$
553+
!
554+
! Additional copyrights may follow
555+
!
556+
! $HEADER$
557+
!
558+
559+
#ifndef USE_MPI_F08_CONSTANTS_H
560+
#define USE_MPI_F08_CONSTANTS_H
561+
562+
';
563+
564+
foreach my $key (sort(keys(%{$constants}))) {
565+
$output .= "#define OMPI_$key $constants->{$key}\n";
566+
}
567+
$output .= "\n";
568+
foreach my $key (sort(keys(%{$handles}))) {
569+
$output .= "#define OMPI_$key $handles->{$key}\n";
570+
}
571+
572+
foreach my $key (sort(keys(%{$io_constants}))) {
573+
$output .= "#define OMPI_$key $io_constants->{$key}\n";
574+
}
575+
foreach my $key (sort(keys(%{$lio_constants}))) {
576+
$output .= "#define OMPI_$key $lio_constants->{$key}\n";
577+
}
578+
$output .= "\n";
579+
foreach my $key (sort(keys(%{$io_handles}))) {
580+
$output .= "#define OMPI_$key $io_handles->{$key}\n";
581+
}
582+
$output .= "\n";
583+
$output .= "#endif\n";
584+
585+
write_file("$topdir/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-constants.h", $output);
586+
529587
exit(0);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ libforce_usempif08_internal_modules_to_be_built_la_SOURCES = \
4848
mpi-f08-interfaces.F90 \
4949
mpi-f08-interfaces-callbacks.F90 \
5050
mpi-f08-callbacks.F90 \
51+
mpi-f08-constants.h \
5152
pmpi-f08-interfaces.F90
5253

5354
config_h = \

0 commit comments

Comments
 (0)