1、 Reference number ISO/IEC TS 29113:2012(E) ISO/IEC 2012TECHNICAL SPECIFICATION ISO/IEC TS 29113 First edition 2012-12-01Information technology Further interoperability of Fortran with C Technologies de linformation Interoprabilit ultrieure de Fortran avec C ISO/IEC TS 29113:2012(E) COPYRIGHT PROTECT
2、ED DOCUMENT ISO/IEC 2012 All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm, without permission in writing from either ISO at the address below or ISOs
3、member body in the country of the requester. ISO copyright office Case postale 56 CH-1211 Geneva 20 Tel. + 41 22 749 01 11 Fax + 41 22 749 09 47 E-mail copyrightiso.org Web www.iso.org Published in Switzerland ii ISO/IEC 2012 All rights reservedContents 1 Scope . . . . . . . . . . . . . . . . . . .
4、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 Normative references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 Terms and denitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5、 . . 5 4 Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.1 New intrinsic procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.2 Fortran 2008 compatibility . . . . . . . . . . . . . . . .
6、 . . . . . . . . . . . . . . . . . . . . . . . . 7 5 Type speciers and attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5.1 Assumed-type objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5.2 Assumed-rank obje
7、cts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5.3 ALLOCATABLE, OPTIONAL, and POINTER attributes . . . . . . . . . . . . . . . . . . . . . . 10 5.4 ASYNCHRONOUS attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 5.4.1
8、 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 5.4.2 Asynchronous communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 6 Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9、. . . . . . . . . . . 13 6.1 Characteristics of dummy data objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6.2 Explicit interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6.3 Argument association . . . . . . . . . . . .
10、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6.4 Intrinsic procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6.4.1 SHAPE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6.4.2 SIZE
11、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 6.4.3 UBOUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 7 New intrinsic procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12、 . . . . . . . . 15 7.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 7.2 RANK (A) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 8 Interoperability with C . . . . . . . . . . . .
13、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 8.1 Removed restrictions on ISO C BINDING module procedures . . . . . . . . . . . . . . . . . . . . 17 8.2 C descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 8.3 ISO Fo
14、rtran binding.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 8.3.1 Summary of contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 8.3.2 CFI dim t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15、. . . . . . 18 8.3.3 CFI cdesc t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 8.3.4 Macros and typedefs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 8.3.5 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16、 . . . . . . . . . . . . . . . . 22 8.4 Restrictions on C descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 8.5 Restrictions on formal parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 8.6 Restrictions on lifetimes . . .
17、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 8.7 Interoperability of procedures and procedure interfaces . . . . . . . . . . . . . . . . . . . . . . . . 30 9 Required editorial changes to ISO/IEC 1539-1:2010(E) . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
18、3 9.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 9.2 Edits to Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 i ISO/IEC 2012 All rights reserved ISO/IEC TS 29113:2012(E) 9.3 Ed
19、its to clause 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 9.4 Edits to clause 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 9.5 Edits to clause 5 . . . . . . . . . . . . . . . . . . . . . . . . .
20、. . . . . . . . . . . . . . . . . . . . . 34 9.6 Edits to clause 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 9.7 Edits to clause 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 9.8 Edits to clause 13
21、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 9.9 Edits to clause 15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 9.10 Edits to clause 16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22、. . . . . . . . . . . . 41 9.11 Edits to annex A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 9.12 Edits to annex C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Annex A (informative) Extended notes . . .
23、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 A.1 Clause 5 notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 A.1.1 Using assumed type in the context of interoperation with C . . . . . . . . . . . . . . . . 43 A.1.2 Mappi
24、ng of interfaces with void * C parameters to Fortran . . . . . . . . . . . . . . . . . 43 A.1.3 Using assumed-type variables in Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 A.1.4 Simplifying interfaces for arbitrary rank procedures . . . . . . . . . . . . . . . . . . . . . 46 A.2
25、 Clause 8 notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 A.2.1 Dummy arguments of any type and rank . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 A.2.2 Creating a contiguous copy of an array . . . . . . . . . . . . . . . . . . . . .
26、. . . . . . . 48 A.2.3 Changing the attributes of an array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 A.2.4 Creating an array section in C using CFI section . . . . . . . . . . . . . . . . . . . . . . 50 A.2.5 Use of CFI setpointer . . . . . . . . . . . . . . . . . . . . . . . .
27、. . . . . . . . . . . . . . 51 A.2.6 Mapping of MPI interfaces to Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 ii ISO/IEC 2012 All rights reserved ISO/IEC TS 29113:2012(E) List of Tables 8.1 Macros specifying attribute codes . . . . . . . . . . . . . . . . . . . . . . . . . .
28、 . . . . . . . . 20 8.2 Macros specifying type codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 8.3 Macros specifying error codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 iii ISO/IEC 2012 All rights reserved ISO/IEC TS 29113:2012(E)
29、 Foreword ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commis- sion) form the specialized system for worldwide standardization. National bodies that are members of ISO or IEC participate in the development of International Standards through tec
30、hnical committees established by the respective organization to deal with particular elds of technical activity. ISO and IEC technical committees collaborate in elds of mutual interest. Other international organizations, governmental and nongovernmental, in liaison with ISO and IEC, also take part i
31、n the work. In the eld of information technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1. International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 2. The main task of the joint technical committee is to prepare Internatio
32、nal Standards. Draft International Stand- ards adopted by the joint technical committee are circulated to national bodies for voting. Publication as an International Standard requires approval by at least 75 % of the national bodies casting a vote. In other circumstances, particularly when there is
33、an urgent market requirement for such documents, the joint technical committee may decide to publish an ISO/IEC Technical Specication (ISO/IEC TS), which represents an agreement between the members of the joint technical committee and is accepted for publication if it is approved by 2/3 of the membe
34、rs of the committee casting a vote. An ISO/IEC TS is reviewed after three years in order to decide whether it will be conrmed for a further three years, revised to become an International Standard, or withdrawn. If the ISO/IEC TS is conrmed, it is reviewed again after a further three years, at which
35、 time it must either be transformed into an International Standard or be withdrawn. Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights. ISO/IEC T
36、S 29113:2012 was prepared by Joint Technical Committee ISO/IEC JTC 1, Information technology, Subcommittee SC22, Programming languages, their environments and system software interfaces. iv ISO/IEC 2012 All rights reserved ISO/IEC TS 29113:2012(E) Introduction The system for interoperability between
37、 the C language, as standardized by ISO/IEC 9899:1999, and Fortran, as standardized by ISO/IEC 1539-1:2010, provides for interoperability of procedure interfaces with arguments that are non-optional scalars, explicit-shape arrays, or assumed-size arrays. These are the cases where the Fortran and C d
38、ata concepts directly correspond. Interoperability is not provided for important cases where there is not a direct correspondence between C and Fortran. The existing system for interoperability does not provide for interoperability of interfaces with Fortran dummy ar- guments that are assumed-shape
39、arrays, have assumed character length, or have the ALLOCATABLE, POINTER, or OPTIONAL attributes. As a consequence, a signicant class of Fortran subprograms is not portably accessible from C, limiting the usefulness of the facility. The provision in the existing system for interoperability with a C f
40、ormal parameter that is a pointer to void is inconvenient to use and error-prone. C functions with such parameters are widely used. This Technical Specication extends the facility of Fortran for interoperating with C to provide for interoperability of procedure interfaces that specify dummy argument
41、s that are assumed-shape arrays, have assumed character length, or have the ALLOCATABLE, POINTER, or OPTIONAL attributes. New Fortran concepts of assumed type and assumed rank are introduced. The former simplies interoperation with formal parameters of type (void *). The latter facilitates interoper
42、ability with C functions that can accept arguments of arbitrary rank. An intrinsic function, RANK, is specied to obtain the rank of an assumed-rank variable. The facility specied in this Technical Specication is a compatible extension of Fortran as standardized by ISO/IEC 1539-1:2010. It does not re
43、quire that any changes be made to the C language as standardized by ISO/IEC 9899:1999. It is the intention of ISO/IEC JTC 1/SC22 that the semantics and syntax specied by this Technical Specication be included in the next revision of ISO/IEC 1539-1 without change unless experience in the implementati
44、on and use of this feature identies errors that need to be corrected, or changes are needed to achieve proper integration, in which case every reasonable eort will be made to minimize the impact of such changes on existing implementations. This Technical Specication is organized in 9 clauses: Scope
45、Clause 1 Normative references Clause 2 Terms and denitions Clause 3 Compatibility Clause 4 Type speciers and attributes Clause 5 Procedures Clause 6 New intrinsic procedure Clause 7 Interoperability with C Clause 8 Required editorial changes to ISO/IEC 1539-1:2010(E) Clause 9 It also contains the fo
46、llowing nonnormative material: Extended notes Annex A NOTE 0.1 ISO/IEC 1539-1:2010 references ISO/IEC 9899:1999. For consistency, this Technical Specication also references ISO/IEC 9899:1999, not ISO/IEC 9899:2011. v ISO/IEC 2012 All rights reserved ISO/IEC TS 29113:2012(E) 1 Scope This Technical Sp
47、ecication species the form and establishes the interpretation of facilities that extend the Fortran language dened by ISO/IEC 1539-1:2010. The purpose of this Technical Specication is to promote portability, reliability, maintainability, and ecient execution of programs containing parts written in F
48、ortran and parts written in C, for use on a variety of computing systems. 1 ISO/IEC 2012 All rights reserved TECHNICAL SPECIFICATION ISO/IEC TS 29113:2012(E)Information technology Further interoperability of Fortran with C (Blank page) 2 ISO/IEC 2012 All rights reserved ISO/IEC TS 29113:2012(E) 2 No
49、rmative references The following referenced standards are indispensable for the application of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies. ISO/IEC 1539-1:2010, Information technology|Programming languages|Fortran|Part 1:Base language ISO/IEC 9899:1999, Programming languages|C 3 ISO/IEC 2012 All rights reserved ISO/IEC TS 29113:2012(E) (Blank page) 4 ISO/IEC 2012 All rights reserved