Compilation Technology SCINET compiler workshop | February 17-18, 2009 © 2009 IBM Corporation Software Group Fortran 2003 Jim Xia IBM Toronto Lab

Slides:



Advertisements
Similar presentations
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Advertisements

The new features of Fortran 2003 David Muxworthy BSI Fortran Convenor.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
Fortran: Array Features Session Five ICoCSIS. Outline 1.Zero-sized Array 2.Assumed-shaped Array 3.Automatic Objects 4.Allocation of Data 5.Elemental Operations.
Introduction to Fortran Fortran Evolution Drawbacks of FORTRAN 77 Fortran 90 New features Advantages of Additions.
Fortran 9x HTML version. New F90 features Free source form Modules User-defined data types and operators Generic user-defined procedures Interface blocks.
Chapter 9 Modules and Programming with Functions.
Abstract Data Types and Encapsulation Concepts
Chapter 12 Pointers and linked structures. 2 Introduction  The data structures that expand or contract as required during the program execution is called.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
Review of C++ Programming Part II Sheng-Fang Huang.
OOP Languages: Java vs C++
Fortran: Specification Statements Session Six ICoCSIS.
Engr 691 Special Topics in Engineering Science Software Architecture Spring Semester 2004 Lecture Notes.
Programming Languages and Paradigms Object-Oriented Programming.
Classes Mark Hennessy Dept. Computer Science NUI Maynooth C++ Workshop 18 th – 22 nd Spetember 2006.
Operator Overloading and Type Conversions
Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes
Chapter 12: Adding Functionality to Your Classes.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes.
Pointer Data Type and Pointer Variables
Data Structures Using C++ 2E Chapter 3 Pointers and Array-Based Lists.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Taken from slides of Starting Out with C++ Early Objects Seventh Edition.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 14: Pointers, Classes, Virtual Functions, and Abstract Classes.
Chapter 11: Inheritance and Composition. Objectives In this chapter, you will: – Learn about inheritance – Learn about derived and base classes – Redefine.
1 Week 12 Arrays, vectors, matrices and cubes. Introduction to Scientific & Engineering Computing 2 Array subscript expressions n Each subscript in an.
Requirements for Fortran Procedures and Progress David Muxworthy BSI Fortran Convenor Prepared for the BCS FSG meeting on 10 March 2005 Almost all.
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Names Variables Type Checking Strong Typing Type Compatibility 1.
5-1 Chapter 5: Names, Bindings, Type Checking, and Scopes Variables The Concept of Binding Type Checking Strong Typing Type Compatibility Scope and Lifetime.
C Tokens Identifiers Keywords Constants Operators Special symbols.
Compilation Technology SCINET compiler workshop | February 17-18, 2009 © 2009 IBM Corporation Software Group Coarray: a parallel extension to Fortran Jim.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Fortran 90, 95, and Fortran 90 ● Generalities: format changes, portable numerics ● Arrays: syntax, classes of arrays, dynamic storage ● Structures.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Module and Data Sharing. Programming in the Large Software, in general, is large having multiple units Multiple units designed and developed independently.
GUIDED BY- A.S.MODI MADE BY- 1. SHWETA ALWANI 2. PRIYANKA.
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
Data Structures Using C++ 2E Chapter 3 Pointers. Data Structures Using C++ 2E2 Objectives Learn about the pointer data type and pointer variables Explore.
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes.
Introduction to the Fortran 2003 Standard Tom Clune SIVO Hamid Oloso SIVO/AMTI Code Tom Clune SIVO Hamid Oloso SIVO/AMTI Code
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Parameterized modules, BITS, and other features that may or may not be included in the revision of Fortran 2003 David Muxworthy BSI Fortran Convenor Prepared.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
FORTRAN 90+ Yetmen Wang Fortran 90/95/2000 INTRODUCTION FORTRAN VERSIONS PROGRAM STRUCTURE NEW SOURCE FORM OO PROGRAMMING ARRAY PROGRAMMING SIGNIFICANT.
COM S 228 Introduction to Data Structures Instructor: Ying Cai Department of Computer Science Iowa State University Office: Atanasoff.
CPS120: Introduction to Computer Science Lecture 16 Data Structures, OOP & Advanced Strings.
Chapter 11: Inheritance and Composition. Introduction Two common ways to relate two classes in a meaningful way are: – Inheritance (“is-a” relationship)
OBJECT ORIENTED PROGRAMMING. Design principles for organizing code into user-defined types Principles include: Encapsulation Inheritance Polymorphism.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering CSCE 330 Programming Language Structures Operational Semantics (Slides mainly.
Chapter 12: Pointers, Classes, Virtual Functions, Abstract Classes, and Lists.
Announcements. Practice questions, with and without solutions will be uploaded by Friday 5 th November, make sure to check them before the weekend \\netstorage\Subjects\ITCA-b\Exam.
Names and Attributes Names are a key programming language feature
Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes
Array processing and Matrix manipulation
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
Chapter 12: Pointers, Classes, Virtual Functions, and Abstract Classes
CS212: Object Oriented Analysis and Design
Chapter 11: Inheritance and Composition
ICOM 4029 Fall 2003 Lecture 2 (Adapted from Prof. Necula UCB CS 164)
Array processing and Matrix manipulation
CUDA Fortran Programming with the IBM XL Fortran Compiler
Presentation transcript:

Compilation Technology SCINET compiler workshop | February 17-18, 2009 © 2009 IBM Corporation Software Group Fortran 2003 Jim Xia IBM Toronto Lab

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 2 Agenda  Background  What’s new in Fortran 2003  IBM XL Fortran  Q&A

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 3 Background  50 year anniversary in 2007  Fortran 2003 published in Nov, 2004 –Fourth edition of Fortran standard –number of pages increased from 356 (Fortran 95) to 569 –many new features added –include many interpretations to Fortran 95 –include two Technical Reports  allocatable dummy arguments and allocatable components  support for IEEE Floating Point Standard (IEEE 1989) (IEEE intrinsic modules)‏  Next revision (Fortran 2008) is near FCD phase –Publication date is set in 2010 –Major features added: coarrays, submodules

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 4 What’s new in Fortran 2003  Object-oriented programming support  I/O Enhancements  Scoping and data manipulation enhancements  C interoperability  Procedure enhancements  Parameterized derived type

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 5 Object-oriented programming  type extension (inheritance) type fluid real :: viscosity  real, allocatable :: velocity(:,:,:) end type  type, extends(fluid) :: magnetofluid real, allocatable :: magnetic_field(:,:,:) end type – type magnetofluid inherited ALL of properties of fluid: viscosity and velocity – Only support single-rooted inheritance hierarchy

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 6 Object-oriented programming (cont’d)‏  type-bound procedures type point real x, y contains procedure :: length => lenBetween2Points end type ...!definition of lenBetween2Points  real function lenBetween2Points(this, p)‏  class(point), intent(in) :: this, p ... ! compute the length  end function ...! in main program type(point) :: pa, pb...  distance = pa%length(pb)

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 7 Object-oriented programming (cont’d)‏  Declaration of polymorphic data –CLASS keyword  class(fluid) A !could be fluid or magnetofluid  SELECT TYPE construct –Allows execution flow controled by dynamic type of the selector select type(A) type is (fluid)... !block for fluid class is (magnetofluid)... !block for magnetofluid class default... end select

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 8 Object-oriented programming (cont’d)‏  abstract types and deferred binding –No concrete objects can be declared to have an abstract type –Deferred binding: defer implementation for type-bound procedures to extending types, only providing well-defined interfaces type, abstract :: shape contains procedure(shapeArea), deferred :: area end type – abstract interface real function shapeArea (this) import shape class(shape), intent(in) :: this – end function end interface

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 9 I/O enhancements  user-defined derived-type I/O –allows user to provide procedures (subroutines) to be used for reading or writing a derived type –user defined procedures are invoked by Fortran's READ, WRITE or PRINT statement as if an intrinsic IO –useful for derived types with POINTER/ALLOCATABLE components  stream access I/O  asynchronous I/O  Infinities and NaNs in formatted READ and WRITE – [+/-]INF or [+/-]INFINITY for infinities – NaN[(...)], for NaNs. e.g. NaN(Q)‏

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 10 I/O enhancements (cont’d)‏  specifier enhancements: allow more control at data transfer –BLANK= specifier –PAD= specifier –DELIM= specifier  New specifiers for more control –SIGN= specifier controls whether the plus sign is displayed for positive numbers in formatted I/O –DECIMAL= specifier specifies the decimal separator for floating-point number –ROUND= specifier controls the rounding mode for formatted I/O

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 11 Data manipulation and scoping enhancements  allocatable components for derived type  fine-grained data protection –private derived type components  deferred length type parameters: –character(:), allocatable :: str ! Length of str can be changed at run-time  array constructors enhancement –square brackets in array constructors [ 1, 2, 3 ] is equivalent to (/ 1, 2, 3 /)‏ –allow type specification [ real :: 1, 2, 3, 4, 5 ]  pointer assignment enhancement –allow lower bounds to be specified for pointer objects p(0:,0:) => a !p's lower bounds are [0,0] –remapping of the elements of a rank-one array p(1:m,1:2*m) => b !b is a rank-one array

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 12 Data manipulation and scoping enhancements (cont’d)‏  allow character dummy arguments for MIN, MAX, MINLOC, MAXLOC, MINVAL and MAXVAL  access host entities via IMPORT statement in interface block integer, parameter :: dp = selected_real_kind(15)‏ !in the same scope of definition of dp interface function distribution_function (x) result (res)‏ IMPORT dp real(kind = dp), intent(in) :: x real(kind=dp) res end function end interface

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 13 Data manipulation and scoping enhancements (cont’d)‏  allocate statement with source-expr integer, dimension(4,20) :: arr0 ... allocate(arr1(4,20), source=arr0)  allocatable array automatic reallocation on assignment real, dimension(:,:), allocatable :: A  real :: B(2, 10), C (5, 5), D(5,5)‏  A = B ! A is automatically allocated as 2 x 10 ...  A = C ! A is automatically reallocated as 5 x 5  !reallocation == deallocate -> allocate  A(:,:) = D !NO reallocation here

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 14 Data manipulation and scoping enhancements (cont’d)‏  rename operators on USE statement use a_mod, operator (.plus.) => operator (.add.)‏  PROTECTED module data module temperature_mod real, protected :: temperature contains subroutine set_temperature (temp)‏ real, intent(in) :: temp temperature = temp end subroutine end module

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 15 C interoperability  provide a standardized mechanism for interoperating with C  intrinsic module ISO_C_BINDING – contains named constant holding kind type parameter values for intrinsic types type named constant C type or types integer C_INT int... real C_FLOAT float C_DOUBLE double  provide facilities of interoperability with C data, pointers, struct, and procedures –Interop with C global data variables real(C_FLOAT),dimension(100),bind(C,name='Alpha')::alpha bound to float Alpha[100];

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 16 C interoperability (cont'd)‏ –Interop with C struct type, BIND(C) :: point real(C_FLOAT) :: x, y end type interoperable with typedef struct{ float x1, x2; } point_t;

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 17 C interoperability (cont'd)‏ –Interop with C procedure and procedure interfaces interface subroutine sub (i, r) bind(C, name='proc')‏ integer(C_INT), VALUE :: i real(C_DOUBLE) r end subroutine end interface Fortran interface interoperable with C prototype void proc (int, double *); Call sub in Fortran resolves to an invocation on a procedure named “proc”

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 18 More C interoperability  enumerations enum, bind(C) enumerator :: two=2, five=5 enumerator :: six end enum declares an enumerator with constants 2, 5 and 6

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 19 Procedure enhancements  VALUE attribute on dummy argument –call by value  abstract interface –declares a procedure interface without declaring an actual procedure  declare procedures using procedure interface name (prototype)‏ procedure(problem_solver) :: forward_euler, backward_euler  procedure pointer procedure(problem_solver), pointer :: solution solution => forward_euler

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 20 Parameterized derived types  derived type allowed to have KIND and LENGTH type parameters integer, parameter::dp = selected_real_kind(15) type matrix(kind,m,n) integer, kind :: kind=dp integer, len :: m, n real(kind) :: element(m,n) end type  type(matrix(dp,10,20)) :: a declares a double-precision matrix of size 10 x 20  type(matrix(dp, :, :)), allocatable :: mat ...  ALLOCATE (matrix(dp, m, n) :: mat)‏  size of matrix mat is determined at runtime

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 21 IBM XL Fortran  standard compliance is one of the XL compiler priorities  IBM actively participates in the standard development  implement Fortran 2003 features since V8.1 (GA 2002)‏  V12.1 contains all Fortran 2003 features except parameterized derived types –First OO Fortran compiler in the industry  V12.1 supports most OpenMP3.0 features  implemented features are available on all supported platforms  for more information, please visit

Compilation Technology SCINET compiler workshop | Fortran 2003 © 2009 IBM Corporation Software Group 22 Q & A