ebook img

Fortran 90: a conversion course for Fortran 77 programmers PDF

105 Pages·1990·0.22 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Fortran 90: a conversion course for Fortran 77 programmers

Fortran 90 A Conversion Course for Fortran 77 Programmers Student Notes S Ramsden, F Lin Manchester and North HPC T&EC M A Pettipher, G S Noland, J M Brooke Manchester Computing Centre, University of Manchester Edition 3.0 July 1995 Acknowledgements These student notes were developed using the Manchester Computing Centre Fortran 90 course, which was compiled by J M Brooke, G S Noland, and M A Pettipher as a basis. Useful comments were also provided by the following: T L Freeman, J Gajjar and A J Grant (The University of Manchester), and A Marshall and J S Morgan (The Univer- sity of Liverpool). Michael Hennecke, University of Kahlsruhe, Germany, provided comprehensive com- ments which were incorporated in edition 3.0 of the materials. Manchester and North HPC T&EC i Fortran 90 ii Fortran 90 Student Notes Table of Contents 1 Introduction 1 History 1 Objectives 1 Language Evolution 2 New Features 3 Organisation 3 Coding Convention 5 Sources, Types and Control Structures 5 Source Form 6 Program and Subprogram Names 6 Specifications 7 Strong Typing 7 The Concept of KIND 10 Derived Types 13 Control Statements 17 Exercises 19 Procedures and Modules 19 Program Units 20 Procedures 28 Modules 31 Overloading 35 Scope 36 Program Structure 39 Exercises 41 Array Processing 41 Terminology and Specifications 43 Whole Array Operations 45 Elemental Intrinsic Procedures 45 WHERE Statement 46 Array Sections 48 Array Assignment 48 Recursion 48 Element Location Versus Subscript 49 Zero Sized Arrays Manchester and North HPC T&EC iii Fortran 77 to Fortran 90 49 Array Constructors 50 Allocatable Arrays 52 Automatic Arrays 54 Assumed Shape Arrays 56 Array Intrinsics 58 Array Example 60 Exercises 63 Pointer Variables 63 What is a Pointer 63 Specifications 64 Pointer Assignments 66 Pointer Association Status 67 Dynamic Storage 68 Pointer Arguments 69 Pointer Functions 69 Arrays of Pointers 70 Linked List 73 Exercises 75 Input/Output 75 Non-advancing I/O 76 INQUIRE by I/O List 76 NAMELIST 77 New Edit Descriptors 77 New Statement Specifiers 79 Exercises 81 Intrinsic Procedures 81 Elemental Procedures 83 Inquiry Functions 84 Transformational Functions 84 Non Elemental Intrinsic Subroutines: 84 Array Intrinsic Procedures 86 Exercises 87 Redundant Features 87 Source Form 87 Data 88 Control 88 Procedures iv Student notes 88 Input/Output 91 Further Development 91 Fortran 95 92 Parallel Computers 95 References Manchester and North HPC T&EC v Fortran 77 to Fortran 90 vi Student notes Introduction 1 Introduction This course covers the transition from the programming language Fortran 77 to the more modern Fortran 90, and is aimed at Fortran 77 programmers who require an understanding of the principles and new features of Fortran 90. The course may also be suitable for programmers familiar with languages such as C or Pascal, but not for complete beginners in programming. 1.1 History The programming language Fortran was originally designed for the solution of prob- lems involving numerical computation. The development of Fortran dates back to the 1950s, the first Fortran system being released in 1957, for the IBM 704. In the early 1960s, as other manufacturers released Fortran compilers for their own computer systems, the need to control and standardise Fortran became apparent. A standards committee was established in 1962, and the first Fortran standard was pub- lished in 1966. Unfortunately, the 1966 Standard did not give a clear, precise definition of Fortran. In the 1970s a new standard was formulated to overcome the problems of Fortran 66 and incorporate several new features. In 1978, the new standard, Fortran 77, was pub- lished. The standards preceding Fortran 90 attempted mainly to standardise existing exten- sions and practices. Fortran 90, however, is much more an attempt to develop the lan- guage, introducing new features using experience from other languages. The next Fortran revision is expected within the next 10 years. 1.2 Objectives The objectives of the new Fortran 90 standard were: • to modernise the language in response to the developments in language design which have been exploited in other languages. • to standardise vendor extensions such that an efficient portable language is pro- vided. • to improve the safety of programming in the language and to tighten the con- formance requirement, such that the risk of error in standard code is reduced. • to keep compatible with Fortran 77 by adopting a language evolution method such that the vast investment in Fortran 77 code is preserved. 1.3 Language Evolution Fortran 90 is a superset of Fortran 77, and so all standard Fortran 77 programs should run. To prevent the language growing progressively larger, however, as new revisions Manchester and North HPC T&EC 1 Fortran 90 are produced, the standards committee has adopted a policy of removing obsolete features. This procedure adopted involves the inclusion of two lists with each new standard. One list contains the deleted features, and the other contains the obsolescent features. The obsolescent list consists of features which are considered to be redundant and may be deleted in the next revision. A feature must appear on the obsolescent list before it can be deleted, thus providing a period of notice of at least one revision cycle. Fortran 90 contains no deleted features, but contains the following obsolescent fea- tures which may be removed at the next revision. • ArithmeticIF • REAL andDOUBLEPRECISIONDO variables and control expressions • SharedDO termination, andDO termination on a statement other than on aCON- TINUE or anEND DO statement • ASSIGN and assigned GOTO statements • AssignedFORMAT specifiers • Branching toEND IF from outsideIF block • AlternateRETURN • PAUSE statement • H edit descriptor 1.4 New Features The following major new features are included in Fortran 90: • Array processing • Dynamic memory allocation, including dynamic arrays • Modules • Procedures: • Optional/Keyword Parameters • Internal Procedures • Recursive Procedures • Pointers Other new features include: • Free format source code • Specifications/IMPLICIT NONE • Parameterised data types • Derived types • Operator overloading • CASE statement • EXIT andCYCLE • Many new intrinsic functions • New I/O features 2 Fortran 90 Student Notes

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.