Technical Specification on further interoperability with C

Similar documents
Technical Report on further interoperability with C

TS Further Interoperability of Fortran with C WG5/N1917

Chapter 4. Fortran Arrays

Fortran 2008: what s in it for high-performance computing

Co-arrays to be included in the Fortran 2008 Standard

Parallel Programming in Fortran with Coarrays

Report from WG5 convener

NAGWare f95 and reliable, portable programming.

NAGWare f95 Recent and Future Developments

Fortran Coarrays John Reid, ISO Fortran Convener, JKR Associates and Rutherford Appleton Laboratory

ISO/IEC : TECHNICAL CORRIGENDUM 2

Page 1 of 7. Date: 1998/05/31 To: WG5 From: J3/interop Subject: Interoperability syntax (Part 1) References: J3/98-132r1, J3/98-139

2 3. Syllabus Time Event 9:00{10:00 morning lecture 10:00{10:30 morning break 10:30{12:30 morning practical session 12:30{1:30 lunch break 1:30{2:00 a

C interfaces to HSL routines. J. D. Hogg. Version 1.0 5th December Numerical Analysis Group Internal Report

C++ For Science and Engineering Lecture 15

Compiler Support for the Fortran 2003 and 2008 Standards Revision 17

Dynamic Data Structures. CSCI 112: Programming in C

(13-2) Dynamic Data Structures I H&K Chapter 13. Instructor - Andrew S. O Fallon CptS 121 (November 17, 2017) Washington State University

C for Engineers and Scientists: An Interpretive Approach. Chapter 10: Arrays

The new features of Fortran 2003

Language Vulnerabilities Report: The Fortran Annex

More Coarray Features. SC10 Tutorial, November 15 th 2010 Parallel Programming with Coarray Fortran

Review of the C Programming Language for Principles of Operating Systems

Character Strings. String-copy Example

COMP26120: Linked List in C (2018/19) Lucas Cordeiro

Type Checking. Prof. James L. Frankel Harvard University

Information technology Programming languages Fortran Part 1: Base language

MM1_ doc Page E-1 of 12 Rüdiger Siol :21

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

MACHINE-LEVEL PROGRAMMING IV: Computer Organization and Architecture

Types II. Hwansoo Han

Pointers. A pointer value is the address of the first byte of the pointed object in the memory. A pointer does not know how many bytes it points to.

Reusing this material

A Fast Review of C Essentials Part I

MPI: A Message-Passing Interface Standard

Fortran 2003 and Beyond. Bill Long, Cray Inc. 17-May-2005

CSE 374 Programming Concepts & Tools

Compiler Support for the Fortran 2003 and 2008 Standards Revision 21

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

ESC101N Fundamentals of Computing

ISO/IEC JTC 1/SC 22/OWGV N 0220

DECLARAING AND INITIALIZING POINTERS

Declaring Pointers. Declaration of pointers <type> *variable <type> *variable = initial-value Examples:

Review of the C Programming Language

Stream Computing using Brook+

In Java we have the keyword null, which is the value of an uninitialized reference type

ECE 2035 Programming HW/SW Systems Fall problems, 5 pages Exam Three 28 November 2012

COSC 6374 Parallel Computation. Introduction to MPI V Derived Data Types. Edgar Gabriel Fall Derived Datatypes

Review More Arrays Modules Final Review

Structures. Basics of Structures (6.1) EECS l Now struct point is a valid type. l Defining struct variables: struct point { int x; int y; };

Short Notes of CS201

C Structures & Dynamic Memory Management

Low-Level C Programming. Memory map Pointers Arrays Structures

Fortran Bill Long, Cray Inc. 21-May Cray Proprietary

CS201 - Introduction to Programming Glossary By

COSC 6374 Parallel Computation. Derived Data Types in MPI. Edgar Gabriel. Spring Derived Datatypes

CS240: Programming in C

Lecture 8: Pointer Arithmetic (review) Endianness Functions and pointers

LOÏC CAPPANERA. 1. Memory management The variables involved in a C program can be stored either statically or dynamically.

BLM2031 Structured Programming. Zeyneb KURT

Fortran 90 - A thumbnail sketch

FOR Loop. FOR Loop has three parts:initialization,condition,increment. Syntax. for(initialization;condition;increment){ body;

FORTRAN - ARRAYS. For example, to declare a one-dimensional array named number, of real numbers containing 5 elements, you write,

Assembler Programming. Lecture 10

Programming with MPI

by Pearson Education, Inc. All Rights Reserved.

CSCI 171 Chapter Outlines

Lectures 5-6: Introduction to C

PACKAGE SPECIFICATION HSL 2013

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

Fortran's Relevance Today and in the Future. Peter Crouch, Chairman Fortran Specialist Group Member Groups Convention 5 April 2011

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Evolution of Fortran. Presented by: Tauqeer Ahmad. Seminar on Languages for Scientific Computing

Lecture V: Introduction to parallel programming with Fortran coarrays

More about BOOLEAN issues

Programming with MPI

INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS

ECE 2035 Programming HW/SW Systems Fall problems, 5 pages Exam Three 20 November 2013

CS 261 Data Structures. Introduction to C Programming

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

Introduction to Fortran95 Programming Part II. By Deniz Savas, CiCS, Shef. Univ., 2018

PRINCIPLES OF OPERATING SYSTEMS

Programming for High Performance Computing in Modern Fortran. Bill Long, Cray Inc. 17-May-2005

Lectures 5-6: Introduction to C

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline

Single Dimension Arrays

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

Advanced Fortran Programming

CS429: Computer Organization and Architecture

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.

CS61C Machine Structures. Lecture 5 C Structs & Memory Mangement. 1/27/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

Pointers. Cedric Saule

Computer System and programming in C

Data Representation and Storage. Some definitions (in C)

Template Issue Resolutions from the Stockholm Meeting

UNIT V Sub u P b ro r g o r g a r m a s

Compiler Support for the Fortran 2003, 2008, TS29113, and 2018 Standards Revision 24

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Allocating Space

M4.1-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

More in-class activities / questions

Transcription:

Technical Specification on further interoperability with C John Reid, ISO Fortran Convener Fortran 2003 (or 2008) provides for interoperability of procedures with nonoptional arguments that are scalars, explicit-shape arrays, or assumed-size arrays, but not with arguments that are assumed-shape, allocatable, pointer, or optional. We summarize the present draft of a Technical Specification that is intended to fill this gap and allow C fuctions to accept arguments of any rank or any type and report on its recent ballot. BCS Fortran Specialist Group London, 29 September 2011.

C header file The C header file ISO_Fortran_binding.h provides the C programmer with standardized C structs, macro definitions, and C prototypes for C functions to allow access in C to additional Fortran features. Type for bounds and strides The struct type CFI_dim_t has components: lower_bound Lower bound of an array in a given dimension. extent Extent of an array in a given dimension. sm Stride multiplier (distance in bytes between successive elements) in a given dimension. 2

C descriptor A C descriptor for an object is a struct of the type CFI_cdesc_t. This type has components: base_addr C address of the first element of the object. NULL if unallocated or not associated. elem_len The sizeof() of an element of the object. rank Rank of the object. type Code (see slide on macros) for the type of the object. attribute Code (see slide on macros) to indicate whether the object is allocatable, a pointer, assumed-shape, or otherwise. dim[] Lower bounds, extents, and stride multipliers. 3

The new calling mechanism A dummy argument in a Fortran interface that is allocatable, assumed-shape, or a pointer may correspond to a formal parameter in a C prototype that is a pointer to a C descriptor. When calling the C function from Fortran, a suitable C descriptor is provided by the system. 4

Assumed-rank object A dummy argument in an interface may be of assumed rank. E.g. interface subroutine scale(a) real a(..) end subroutine scale end interface It may correspond to a pointer to a C descriptor in a C function prototype. Allows a C function to accept an allocatable, assumed-shape, or a pointer array of any rank. Severely restricted in Fortran. Can be passed around, remaining as assumed rank, or passed as the first argument to an inquiry function. 5

Assumed-type objects A dummy argument may be of assumed type. E.g. interface subroutine archive(a) type(*) a end subroutine archive end interface Allows a C function to accept an allocatable, assumed-shape, or a pointer array of any type. If it is not allocatable, assumed-shape, assumedrank, or a pointer, it may correspond to a pointer to void in a C function prototype. Allows a C function to accept a Fortran object of any type. Helpful for calling MPI. Severely restricted in Fortran. Can be passed around, remaining as assumed type, or passed as the first argument to some inquiry functions. 6

Optional arguments An absent actual argument in a reference is indicated by a formal parameter with the value NULL. 7

Macros CFI_MAX_RANK : Largest rank supported. Attribute codes: CFI_attribute_assumed : assumed-shape CFI_attribute_allocatable : allocatable CFI_attribute_pointer : pointer CFI_attribute_unknown_size : assumed size Type codes: CFI_type_struct : interoperable struct CFI_type_signed_char : signed char CFI_type_short : short CFI_type_int : int CFI_type_float : float CFI_type_double : double CFI_type_cptr : void * CFI_type_cfunptr : pointer to a function... Lots more types. 8

Constructing C descriptors in C Important changes have been made in the last year for the sake of safety when Fortran is called from C. A C descriptor must not be initialized, updated, or copied other than by calling one of these functions. CFI_allocate does a Fortran allocation CFI_deallocate does a Fortran deallocation CFI_establish establishes a C descriptor CFI_section updates a C descriptor to describe an ordinary array section CFI_select_part updates a C descriptor to describe an array section such as array%part CFI_setpointer updates a C descriptor to point to the whole of an object or be disassociated. No mixing of C and Fortran allocation mechanisms is allowed. 9

Other functions CFI_address computes the C address of an object described by a C descriptor CFI_is contiguous tests the contiguity of an array described by a C descriptor 10

The DTR ballot The ballot has just finished and the result was 12 Approval as presented 1 Approval with comments (Germany) 1 Disapproval (UK) 5 Abstentions The comments are not very severe and I expect the TS to complete next year. 11