mpi-forum / mpi-forum-historic

Migration of old MPI Forum Trac Tickets to GitHub. New issues belong on mpi-forum/mpi-issues.
http://www.mpi-forum.org
2 stars 3 forks source link

New MPI-3 Fortran Support - #B: New module "USE mpi_f08" #230

Closed mpiforumbot closed 8 years ago

mpiforumbot commented 8 years ago

Originally by RolfRabenseifner on 2010-09-01 10:39:40 -0500


230-B: New module "USE mpi_f08"See Ticket #229-A for an overview on the New MPI-3 Fortran Support.

Description

-Major decisions in this ticket:*

Further details are handled in further tickets:

None.

History

Current MPI-2.2 requires that mpif.h contains full MPI-2.2 because in the Extended Fortran Support, the standard requires (MPI-2.2, page 489, line 7):

Applications may use either the mpi module or the mpif.h include file.

Proposed Solution

''The ticket numbers in parenthesis (#xxx-X) indicate sentences that are removed if the appropriate ticket is not voted in.''

-MPI-2.2, Chapter 1, Introduction, Page 1, lines 23-25 read*

MPI is not a language, and all MPI operations are expressed as functions, subroutines, or methods, according to the appropriate language bindings, which for C, C++, Fortran-77, and Fortran-95, are part of the MPI standard.

-but should read*

MPI is not a language, and all MPI operations are expressed as functions, subroutines, or methods, according to the appropriate language bindings, which for C, C++, Fortran-77, and Fortran-95, and Fortran, are part of the MPI standard.

-MPI-2.2, Chapter 1, Introduction, Page 2, line 1 reads*

Allow convenient C, C++, Fortran-77, and Fortran-95 bindings for the interface.

-but should read*

Allow convenient C, C++, Fortran-77, and Fortran-95, and Fortran bindings for the interface.

-MPI-2.2, Chapter 1, Introduction, Page 4, line 34: Add in the new section "1.6 Background of MPI-3.0":*

A new Fortran mpi_f08 module is introduced to provide extended compile-time argument checking and buffer handling in nonblocking routines. (#230-B) The existing mpi module provides compile-time argument checking on the basis of existing MPI-2.2 routine definitions. (#232-D) The use of mpif.h is strongly discouraged. (#233-E)

-MPI-2.2, Chapter 2, Terms and Convention, Page 9, line 18 reads*

Some of the major areas of difference are the naming conventions, some semantic definitions, file objects, Fortran 90 vs Fortran 77, C++, processes, and interaction with signals.

-and should not be modified*

-MPI-2.2, Chapter 2, Terms and Convention, Section 2.3 Procedure Specification, page 11, lines 20-23 read*

All MPI functions are first specified in the language-independent notation. Immediately below this, the ISO C version of the function is shown followed by a version of the same function in Fortran and then the C++ binding. Fortran in this document refers to Fortran 90; see Section 2.6.

-but should read*

All MPI functions are first specified in the language-independent notation. Immediately below this, language dependent bindings follow:

-MPI-2.2, Chapter 2, Terms and Conventions, Section 2.6.2 Fortran Binding Issues, page 18, line 6-9 reads*

The MPI Fortran binding is inconsistent with the Fortran 90 standard in several respects. These inconsistencies, such as register optimization problems, have implications for user codes that are discussed in detail in Section 16.2.2. They are also inconsistent with Fortran 77.

-but should read*

The MPI Fortran bindings are is inconsistent with the Fortran 90 standard in several respects. These inconsistencies, such as register optimization problems, have implications for user codes that are discussed in detail in Section 16.2.2. They are also inconsistent with Fortran 77.

-_MPI-2.2, Section 13.6.7 MPIOffset Type, page 442, lines 14-15 read*

In Fortran, the corresponding integer is an integer of kind MPI_OFFSET_KIND, defined in mpif.h and the mpi module.

-but should read*

In Fortran, the corresponding integer is an integer with of kind parameter MPI_OFFSET_KIND, which is defined in the mpi_f08 module, the mpi module and the
mpif.h include file
.

'''MPI-2.2, Chapter 16.2, Fortran Support: [[BR]] Section 16.2.1 Overview, MPI-2.2, page 480, lines 23-47 '''

The Fortran MPI-2 language bindings have been designed to be compatible with the Fortran 90 standard (and later). These bindings are in most cases compatible with Fortran 77, implicit-style interfaces.

-Rationale.* Fortran 90 contains numerous features designed to make it a more "modern"
language than Fortran 77. It seems natural that MPI should be able to take
advantage of these new features with a set of bindings tailored to Fortran 90. MPI
does not (yet) use many of these features because of a number of technical difficulties.
-(End of rationale.)*

MPI defines two levels of Fortran support, described in Sections 16.2.3 and 16.2.4. In the rest of this section, "Fortran" and "Fortran 90" shall refer to "Fortran 90" and its successors, unless qualified.

  1. Basic Fortran Support An implementation with this level of Fortran support provides the original Fortran bindings specified in MPI-1, with small additional requirements specified in Section 16.2.3.
  2. Extended Fortran Support An implementation with this level of Fortran support provides Basic Fortran Support plus additional features that specifically support Fortran 90, as described in Section 16.2.4.

    A compliant MPI-2 implementation providing a Fortran interface must provide Extended Fortran Support unless the target compiler does not support modules or KIND- parameterized types.

-together with MPI-2.2, page 488, lines 19-24*

A new set of functions to provide additional support for Fortran intrinsic numeric types, including parameterized types: MPI_SIZEOF, MPI_TYPE_MATCH_SIZE, MPI_TYPE_CREATE_F90_INTEGER, MPI_TYPE_CREATE_F90_REAL and MPI_TYPE_CREATE_F90_COMPLEX. Parameterized types are Fortran intrinsic types which are specified using KIND type parameters. These routines are described in detail in Section 16.2.5.

-together with MPI-2.2, page 489, lines 7-14*

Applications may use either the mpi module or the mpif.h include file. An implementation may require use of the module to prevent type mismatch errors (see below).

-Advice to users.* It is recommended to use the mpi module even if it is not necessary to
use it to avoid type mismatch errors on a particular system. Using a module provides
several potential advantages over using an include file. *(End of advice to users.)*

It must be possible to link together routines some of which USE mpi and others of which INCLUDE mpif.h.

-but should read (TODO: check whether "the only new language feature" is true)*

The Fortran MPI-2 language bindings have been designed to be generally compatible with the Fortran 90 standard (and later). ~~These bindings are in most cases compatible with Fortran 77, implicit-style interfaces.~~

-Rationale.* Fortran 90 contains numerous features designed to make it a more "modern"
language than Fortran 77. It seems natural that MPI should be able to take
advantage of these new features with a set of bindings tailored to Fortran 90.
~~MPI does not (yet) use many of these features because of a number of technical difficulties.~~
__In Fortran 2008, the only new language features used, are  of assumed type and assumed rank.
They were defined to
allow the definition of choice arguments as part of the Fortran language.__
-(End of rationale.)*

MPI defines two levels three methods of Fortran support: ~~, described in Sections 16.2.3 and 16.2.4. In the rest of this section, "Fortran" and "Fortran 90" shall refer to "Fortran 90" and its successors, unless qualified.~~

1. __**`INCLUDE 'mpif.h'`**__ ~~**Basic Fortran Support**~~
__This method is described__
~~An implementation with this level of Fortran support provides
the original Fortran bindings specified in MPI-1, with small additional requirements
specified~~
in Section 16.2.3.
__The use of the include file `mpif.h` is strongly discouraged since MPI-3.0 **(#233-E)**.__

2. __**`USE mpi`**__ ~~**Extended Fortran Support**~~
__This method is__
~~An implementation with this level of Fortran support
provides Basic Fortran Support plus additional features that specifically support
Fortran 90, as~~ described
in Section 16.2.4__ and requires compile-time argument checking__.

3. __**`USE mpi_f08`** This method is described in Section 16.2.5
and requires compile-time argument checking that includes also unique handle types.__

A compliant MPI-23 implementation providing a Fortran interface must provide ~~Extended Fortran Support unless the target compiler does not support modules or KIND- parameterized types~~all three Fortran support methods.

Applications subroutines and functions may use either one of the mpi modules or the mpif.h include file. An implementation may require use of one of the modules to prevent type mismatch errors~~ (see below)~~.

-Advice to users.* It is recommended to use __one of__ the ~~mpi~~__MPI__ module__s__ even
if it is not necessary to
use it to avoid type mismatch errors on a particular system. Using a module provides
several potential advantages over using an include file. *(End of advice to users.)*

In a single application, it must be possible to link together routines some of which USE mpi and others of which USE mpi_f08 or INCLUDE mpif.h.

The INTEGER compile-time constant MPI_SUBARRAYS is MPI_SUBARRAYS_SUPPORTED if all choice arguments are defined in explicit interfaces with standardized assumed type and assumed rank, otherwise it equals MPI_SUBARRAYS_UNSUPPORTED. This constant exists with each Fortran support method, but not in the C/C++ header files. The value may be different for each Fortran support method. (#234-F)****

Section 16.2.2 gives an overview on known problems when using Fortran together with MPI. Section 16.2.5new and (#238-J) Section 16.2.5 describe additional functionality that is part of the Fortran support. func{MPI_F_SYNC_REG} is needed for one of the methods to prevent register optimization problems. (#238-J) A new set of functions to provide additional support for Fortran intrinsic numeric types, including parameterized types. The functions are: MPI_SIZEOF, MPI_TYPE_MATCH_SIZE, MPI_TYPE_CREATE_F90_INTEGER, MPI_TYPE_CREATE_F90_REAL and MPI_TYPE_CREATE_F90_COMPLEX. Parameterized types are Fortran intrinsic types which are specified using KIND type parameters. ~~These routines are described in detail in Section 16.2.5.~~

-MPI-2.2, Section 16.2.3 Basic Fortran Support, page 487, line 43 - page 488, line 4, reads*

16.2.3 Basic Fortran Support

Because Fortran 90 is (for all practical purposes) a superset of Fortran 77, Fortran 90 (and future) programs can use the original Fortran interface. The following additional requirements are added:

  1. Implementations are required to provide the file mpif.h, as described in the original MPI-1 specification.
  2. mpif.h must be valid and equivalent for both fixed- and free- source form.

-but should read *

16.2.3 Basic Fortran Support Through the mpif.h Include File

The use of the mpif.h include file is strongly discouraged (#233-E).

Because Fortran 90 is (for all practical purposes) a superset of Fortran 77, Fortran 90 (and future) programs can use the original Fortran interface. The Fortran bindings are compatible with Fortran 77 implicit-style interfaces in most cases. The following additional requirements are added: The include file mpif.h must:

~~1. Implementations are required to provide the file mpif.h, as described in the original MPI-1 specification.~~

-MPI-2.2, Section 16.2.4 Extended Fortran Support, page 488, lines 14-40 read*

16.2.4 Extended Fortran Support

Implementations with Extended Fortran support must provide:

1. An mpi module
2. A new set of functions to provide additional support for Fortran intrinsic numeric
types, including parameterized types: MPI_SIZEOF, MPI_TYPE_MATCH_SIZE,
MPI_TYPE_CREATE_F90_INTEGER, MPI_TYPE_CREATE_F90_REAL and
MPI_TYPE_CREATE_F90_COMPLEX. Parameterized types are Fortran intrinsic types
which are specified using KIND type parameters. These routines are described in detail
in Section 16.2.5.

Additionally, high-quality implementations should provide a mechanism to prevent fatal type mismatch errors for MPI routines with choice arguments.

The mpi Module

An MPI implementation must provide a module named mpi that can be used in a Fortran 90 program. This module must:

-but should read*

16.2.4 Extended Fortran Support Through the mpi Module

Implementations with Extended Fortran support must provide:

~~1. An mpi module~~[[BR]]
~~2. A new set of functions to provide additional support for Fortran intrinsic numeric
types, including parameterized types: MPI_SIZEOF, MPI_TYPE_MATCH_SIZE,
MPI_TYPE_CREATE_F90_INTEGER, MPI_TYPE_CREATE_F90_REAL and
MPI_TYPE_CREATE_F90_COMPLEX. Parameterized types are Fortran intrinsic types
which are specified using KIND type parameters. These routines are described in detail
in Section 16.2.5.~~

~~Additionally, high-quality implementations should provide a mechanism to prevent fatal type mismatch errors for MPI routines with choice arguments.~~

The mpi Module

An MPI implementation must provide a module named mpi that can be used in a Fortran 90 program. This module must:

'''MPI-2.2, Section 16.2.4, page 489, lines 7-14 are removed (they have been already used in Section 16.2.1)'''

-After MPI-2.2, Section 16.2.4, page 489, line 30, the following section is added* (for better readability of this ticket, the following new text is not underlined although it should):

16.2.5 Fortran Support Through the mpi_f08 Module

An MPI implementation must provide a module named mpi_f08 that can be used in a Fortran program. With this module, new Fortran definitions are added for each MPI routine (#247-S), except for routines that are deprecated (#241-M). This module must:

-With the following new entries in refs.bib:*

@Manual{fortran2008,
  title        = "Information technology -- Programming languages 
                  -- Fortran -- Part 1: Base language",
  organization = "International Organization for Standardization",
  address      = "Geneva",
  year         = 2010, 
  month        = "November",
  annote       = "ISO/IEC 1539-1:2010"
}

@Manual{fortran2008:tr-interop:N1845,
  title        = "TR on further interoperability with C",
  organization = "International Organization for Standardization, 
                  ISO/IEC/SC22/WG5 (Fortran)",
  address      = "Geneva",
  year         = 2011, 
  month        = "March, 3",
  annote       = "Draft N1845 TR29113",
  source={http://www.nag.co.uk/sc22wg5/ and 
          ftp://ftp.nag.co.uk/sc22wg5/N1801-N1850/N1845.pdf}
}

'''Renumbering of MPI-2.2, Section 16.2.5 in Section 16.2.6, on page 489, line 31.

Impact on Implementations

This module requires mainly

None, as long they do not use this new module.

If they want to use this new mpi_f08 module then they must modify:

MPI-2.2, Section xxxx on page xxx.[[BR]] yyy.

mpiforumbot commented 8 years ago

Originally by RolfRabenseifner on 2012-06-12 04:42:15 -0500


Ticket is only a helper-ticket for passed #229, therefore this ticket is now marked as resolved. For forther information, see status of ticket #229.