ebook img

The F Language Guide PDF

347 Pages·1997·9.136 MB·
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 The F Language Guide

The F Language Guide Springer London Berlin Heidelberg NewYork Barcelona Budapest HongKong Milan Paris SantaClara Singapore Tokyo Wilhelm Gehrke The FLanguage Guide With79figures , Springer WilhelmGehrke RegionalComputingCentre UniversityofHannover Hannover Germany ISBN 978-3-540-76165-5 Springer-VerlagBerlinHeidelbergNewYork ISBN-13:978-3-540-76165-5 e-ISBN-13: 978-1-4471-0989-1 001: 10.1007/978-1-4471-0989-1 BritishLibraryCataloguinginl'ublicationData Gehrke, Wilhelm, 1940- TheFlanguageguide I.FORTRAN (Computerprogramlanguage) I.Title 005.1'33 ISBN 978-3-540-76165-5 LibraryofCongressCataloging-in-PublicationData AcatalogrecordforthisbookisavailablefromtheLibraryofCongress Apartfromanyfairdealingforthepurposesofresearchorprivatestudy,orcriticismorreview, aspermittedundertheCopyright,DesignsandPatentsAct1988,thispublicationmayonlybe reproduced.storedortransmitted,inanyformorbyanymeans,withthepriorpermissionin writingofthe publishers,orinthe case ofreprographicreproduction inaccordance with the termsoflicencesissuedbytheCopyrightLicensingAgency. Enquiriesconcerningreproduction outsidethosetermsshouldbesenttothepublishers. ©Springer-VerlagLondonLimited1997 Reprintoftheoriginaledition 1997 The use ofregisterednames, trademarks etc. in this publication does not imply, evenin the absence ofa specific statement, that such names are exempt from the relevant laws and regulationsandthereforefreeforgeneraluse. Thepublishermakesnorepresentation,expressorimplied,withregardtotheaccuracyofthe informationcontainedinthisbookandcannotacceptanylegalresponsibilityorliabilityforany errorsoromissionsthatmaybemade. Typesetting:Camerareadybyauthor 34/3830-543210Printedonacid-freepaper Preface v PREFACE Fortran has been and will be the most important programminglanguage for the development ofengineering and scientific applications. The current standard of Fortran is Fortran90 but itssuccessor Fortran95 willbeaccepted as international standard still in 1997. F™ is a subset of the Fortran programming language defined by Fortran90. With very few exceptions, Fis also a subset ofFortran95. Since the "deleted language features" of Fortran95 are not included in the F language, an Fprogram is a Fortran90 standard conforming program and also a Fortran95 standard conforming program. With other words: an Fconforming Fortranprogramisbotha Fortran90conformingFortranprogramanda Fortran95 conforming Fortran program. ThesubsetofFortranselectedforthe Flanguagedefinesaprogramminglanguage which is nearly as powerful as its parent language, which contains the modern language features of Fortran, which is significantly smaller than Fortran, which does not contain those Fortran language features that are difficult to use, to debug, and to teach, which does not contain many of the redundant language elements of Fortran, and which enforces methodical programming. The Flanguage does not support: • statement labels. As a consequence, an Fprogramcannot have or use, for instance, GOTO, arithmetic IF, alternate return, labeled do-termination statement, CONTINUE. • storage units and storage sequences. As a consequence, an F program cannot have or use, for instance, EQUIVALENCE, COMMON, ENTRY, SEQUENCE, sequence type, sequence (argument) association. • decremental features of Fortran90 and Fortran95. As a consequence, an F program cannot have or use, statement function, shared DO termination, double precision DO variable, fixed source form. • equivalent or redundant language elements. As a consequence, an F pro gramcannot haveor use, for instance, INCLUDE, DATA, BLOCKDATA, or internal subprograms. • rarly used language elements such as NAMELIST i/o or DO WHILE. The name Fisa trademarkofImaginel,Inc. (http://Wllll.imaginel.com/imaginel/) vi Preface An Fprogram requires that: • all named data objects be declared explicitly • attributes for data objects be specified in the type declaration statement • user-defined Fsubprograms be module subprograms • module entities have an explicitly specified accessibility attribute • Ffunctions have (nearly) no side-effects • user-defined names are different from any reserved name • thesource text (except character literal constants and certain user-defined names) is written in lower case Amoredetailed overview ofthe differences between Fortran90 and F is given in appendix D. "The F Language Guide" is a comprehensible description of the complete F programming language as it is defined in [1]. It is similar in style and structure to my "Fortran90 Language Guide" [4] and is basedona revised versionofthat book which also was the starting text for my "Fortran95 Language Guide" [5]. "TheF Language Guide" isintendedtoserveasalanguagereference manualfor the novice as well as for the experienced programmer, as teaching.material for courses in Fprogramming, and in programming methodology. The guide con centratesonthedescriptionofthelanguageasaprogrammers'toolandabstains from personal, historical, and philosophical comments and interpretations. Though the list of restrictions seems long, F retains the modern features of Fortran. Therefore, "The F Language Guide" can also be used for courses in Fortran programming. And the experienced programmer can use it during the development ofnew Fortran software. Sources [1] Imagine1, BNF Syntax ofthe F Programming Language, http://www.imagine1.com/imagine1/bnf.html [2] Gehrke, Handbuch der Programmiersprache F, 1997, in preparation [3] Gehrke, Fortran9S-Nachschlagewerk, RRZN, 1997 [4] Gehrke, Fortran90 Language Guide, Springer, 1995, ISBN 3-540-19926-8 [5] Gehrke, Fortran9S Language Guide, Springer, 1996, ISBN 3-540-76062-8 [6] ISO/IEC 1539:1991(E), Fortran90, ISO, 1991 [3] is a German handbook similar to [5]. And [2] is the German version of "The F Language Guide". Preface vii Layout The following conventions are used throughout this guide: Upper-case ABC indicate a reserved word which must be written in lower-case within the source text. Lower-case abc in a syntax rule indicate a language element which is to be inserted by the programmer. Special characters +* ofthe Fcharacter set must be written as given. Square brackets [] in a syntax rule enclose an optional language element, which may be used or omitted. Dot sequence in a syntax rule indicate that the preceding optional language element enclosed in brackets may be repeated as necessary. Braces {} in a syntax rule enclose several language elements; one ofthem must be selected. This is the font for normal text. This Isthefontforformal syntax. This is the font for examples. This is the font for definitions. Terms written such are either emphasized or are defined elsewhere in this guide. To increase readability of this guide, keywords and other lexical tokens are printed in upper case when they appear in the text outside examples. Note that statement keywords, intrinsic subprogram names and their dummy argu ment names, logical literal constants and logical operators, the exponent letter in a real literal constant, edit descriptors, etc. must be written using lower-case letters when they appear in the source text ofa program unit. Theformalmetalanguageusedwithinthisguidesupportstheprecisedescription of single language features. Note that it is not the formal meta language used in the original language definition [1]. Appendix E of this guide contains a representation ofthe formal syntax ofthe Flanguage in rail-road form. Technical Terms Thefollowing termsareassumedasknownoraredefinedelsewhereinthisguide; in any case, reading the guide will be easier ifthe reader is aware ofthem: block: A sequence ofexecutable statements which is a part ofan executable construct. data object: A variable or a constant. viii Preface data entity: A data object, the result ofthe evaluation ofan expression, or the result ofa function reference. definition: A derived type definition defines a derived data type. Asubpro gram definition defines a user-defined subroutine or function. A variable or a record ofan internal file are defined ifthey have a valid value. F processor: The computing system consisting ofhardware and software by which programs are transformed for use on that system. parent object: Asubobject is a part ofa parent object. presence: An optional dummy argument is present if an actual argument is associated with it which is either a present dummy argument ofthe caller or which is not a dummy argument ofthe caller. reference: A "data object reference" is the appearance of the data object name or data object designator where its value is required during program exe cution. A "subprogram reference" is the appearance ofthe subprogram name, ofan operator symbol, or ofthe assignment symbol where the execution ofthe subprogram is required during program execution. A "module reference" is the appearance ofa module name in a USE statement. variable: A named variable is a scalar or an array object which has a name. An unnamed variable is an array element (scalar), an array section (array), a structure component (scalar or array), or a character substring (scalar). Acknowledgements I wish to thank Dick Hendricksonfor his help in providingtechnical input. And I would like to thank my wife Katrin and my daughter Meike for their support and for their patience during the preparation ofthis book. Hannover March 1997 W.G. Contents ix CONTENTS 1 SOURCE FORM 1-1 1.1 Classification ofF Statements 1-4 1.2 Statement Ordering. . . . . . 1-5 2 TYPE CONCEPT 2-1 2.1 Intrinsic Types . 2-1 2.1.1 Integer Type 2-1 2.1.2 Real Type. . 2-2 2.1.3 Complex Type 2-3 2.1.4 Logical Type . 2-3 2.1.5 Character Type. 2-4 2.2 Derived Types . . . . . . 2-4 2.2.1 Derived Type Definition. 2-4 2.2.1.1 Type Component Definition 2-6 2.2.1.2 Private/Public Derived Types and Components 2-8 2.2.2 Structure Objects 2-9 3 LEXICAL TOKENS 3-1 3.1 Scoping Units 3-1 3.2 Keywords . . . . . 3-1 3.3 Names . . . . . . . 3-1 3.4 Operators and Assignment Symbol 3-4 3.5 Literal Constants . . . . . . . . . 3-4 3.5.1 Integer Literal Constants . 3-5 3.5.2 Real Literal Constants . . . 3-5 3.5.3 Complex Literal Constants 3-6 3.5.4 Logical Literal Constants . 3-6 3.5.5 Character Literal Constants . 3-7 4 DATA OBJECTS 4-1 4.1 Constants 4-2 4.2 Variables. . . . 4-3 4.3 Scalars . . . . . 4-4 4.3.1 Character Substrings. 4-4 4.4 Arrays . . . . . . . . . . . . . 4-5 x Contents 4.4.1 Inner Structure ofArrays 4-7 4.5 Structure Components 4-9 4.6 Automatic Variables . 4-11 4.7 Association . 4-12 4.7.1 Name Association 4-12 4.7.2 Pointer Association. 4-14 4.8 Definition Status . . . . . . 4-14 5 POINTERS 5-1 5.1 Pointer Concept . . . . . . . . . . . 5-1 5.2 Pointer Processing . 5-2 5.2.1 Creation ofPointer Targets 5-2 5.2.2 Association Status . . . . . 5-3 5.2.3 Deallocation ofPointer Targets 5-4 5.2.4 Nullification ofPointer Associations 5-6 6 ARRAY PROCESSING 6-1 6.1 Array Declaration . 6-1 6.1.1 Explicit-Shape Arrays . 6-2 6.1.2 Assumed-Shape Arrays 6-2 6.2 Reference and Use ... 6-3 6.2.1 Whole Arrays .. 6-3 6.2.2 Array Elements . 6-4 6.2.3 Array Sections . 6-5 6.2.3.1 Subscript-Triplet. 6-8 6.2.3.2 Vector-Subscript. 6-11 6.2.3.3 Array Sections ofSubstrings 6-12 6.3 Memory Management and Dynamic Control 6-12 6.3.1 Automatic Arrays 6-12 6.3.2 Allocatable Arrays 6-13 6.3.3 Array Pointers 6-16 6.4 Array Constructor .... 6-17 6.5 Operations on Arrays . . . 6-19 6.5.1 Array Expressions 6-19 6.5.2 Array Subprograms 6-20 6.5.3 Array Assignments. 6-21 7 EXPRESSIONS 7-1 7.1 Numeric Intrinsic Expressions . 7-3 7.2 Relational Intrinsic Expressions . 7-7 7.2.1 Numeric Relational Intrinsic Expressions 7-8 7.2.2 Character Relational Intrinsic Expressions . 7-8

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.