Fortran 90 Handbook Complete ANSI / ISO Reference

Total Page:16

File Type:pdf, Size:1020Kb

Fortran 90 Handbook Complete ANSI / ISO Reference Fortran 90 Handbook Complete ANSI / ISO Reference Jeanne C. Adams Walter S. Brainerd Jeanne T. Martin Brian T. Smith Jerrold L. Wagener Intertext Publications McGraw-Hill Book Company Library of Congress Catalog Card Number 91-77211 Copyright © 1992 by Jeanne C. Adams, Walter S. Brainerd, Jeanne T. Martin, Brian T. Smith, and Jerrold L. Wagener. All rights reserved. Printed in the United States of America. Except as permitted under the United States Copyright Act of 1976, no part of this book may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system without the prior written permission of the authors and the publisher. 10 9 8 7 6 5 4 3 2 1 ISBN 0-07-000406-4 Intertext Publications/Multiscience Press, Inc. One Lincoln Plaza New York, NY 10023 McGraw-Hill Book Company 1221 Avenue of the Americas New York, NY 10020 Composition by UNICOMP Preface The Fortran 90 Handbook is a definitive and comprehensive guide to Fortran 90 and its use. Fortran 90, the latest standard version of Fortran, has many excellent new features that will assist the programmer in writing efficient, portable, and maintainable programs. The Fortran 90 Handbook is an informal description of Fortran 90, developed to provide not only a readable explanation of features, but also some rationale for the inclusion of features and their use. In addition, “models” give the reader better insight as to why things are done as they are in the language. This handbook is intended for anyone who wants a comprehensive survey of Fortran 90, including those familiar with programming language concepts but unfamiliar with Fortran. Experienced Fortran 77 programmers will be able to use this volume to assimilate quickly those features in Fortran 90 that are not in Fortran 77 (Fortran 90 is a superset of Fortran 77). Chapter 0 provides a brief overview of several of the most important features that are new in Fortran 90. Chapters 1–14 correspond to Sections 1–14 in the standard. (The standard is the complete official description of the language, but it is written in a legally airtight, formal style without tutorial material and can be difficult to understand in places.) The handbook and the standard can be examined in parallel for insights into the Fortran language. This makes it feasible to use this handbook to “decipher” the standard, and this is an ideal use of this book. Although the handbook is written for use in conjunction with the standard, it is also designed as a practical stand-alone description of Fortran 90. In the interest of readability, a few of the more obscure aspects of the standard may iii not be treated rigorously; any such cases should not impact the usefulness of this handbook in describing Fortran 90. On the other hand, in places where the standard is not completely clear, a reasonable interpretation is often given, together with ways to implement and program that will avoid potential problems due to misinterpretation of the standard. Of course, if information is being sought to understand a fine point of compiler implementation, settle a bet, resolve a court case, or determine the answer to a Fortran trivia question, the standard itself should be considered the final authority. The syntactic features of the language are described completely in the appendices, and these can serve as continual concise references for Fortran 90. Other Sources of Information Other parts of the book can be used to help find information. • Each of the intrinsic functions is described in detail in Appendix A, although a general discussion of the intrinsic functions is included in Chapter 13. • The complete syntax of Fortran 90 may be found in Appendix B. The syntax rules are numbered exactly as they are in the Fortran standard. There is a cross reference that lists, for each nonterminal syntactic term, the number of the rule in which it is defined, and all rules in which it is referenced. • Appendix C contains a listing of the obsolescent features. • The index is unusually comprehensive. • There is an index of examples, giving the location of program examples that illustrate the use of many Fortran 90 features. For an informal and tutorial approach to learning Fortran 90, the book, Programmers Guide to Fortran 90, Second Edition, by Brainerd, Goldberg, and Adams (Unicomp, Albuquerque, NM, 1993) is more appropriate. Style of the Programming Examples In order to illustrate many features of the language and as many uses of these features as possible, no single particular style has been used when writing the examples. In many cases, the style illustrated is not necessarily one that the authors recommend. iv FORTRAN User’s Guide Acknowledgments Material in the appendices of this book was developed by the ANSI committee X3J3 and the ISO committee SC22/WG5 for inclusion in the Fortran 90 standard ISO/IEC 1539 : 1991. This material is reprinted with the permission of the International Standards Organization. Comments provided by Charles Goldberg have increased the accuracy and readability of this book enormously. Copyright Fortran 90 Handbook is reproduced herein with the permission of McGraw- Hill, Inc., Copyright 1992, by Walter S. Brainerd, Jeanne C. Adams, Jeanne T. Martin, Brian T. Smith, and Jerrold L. Wagener. All rights reserved. Printed Copies Printed copies of this book may be obtained by ordering from Unicomp, Inc. 1874 San Bernardino Ave NE Albuquerque, NM 87122 USA +1-505-275-0800 +1-505-856-1501 (fax) Visit the Fortran market: http://www.fortran.com/fortran The home page includes how to order this book in hard copy. Jeanne C. Adams Walter S. Brainerd, [email protected] Jeanne. T. Martin Brian T. Smith Jerrold L. Wagener January 1992 v vi FORTRAN User’s Guide Table of Contents Preface. iii Sneak Preview . 1 1. Introduction . 13 1.1 History . 13 1.2 Why a New Standard? . 15 1.3 Why Not Use Another Language? . 17 1.4 Development of Fortran 90 . 18 1.5 Fortran 77 Compatibility . 19 1.6 Extensibility. 20 1.7 Intrinsic and Standard Modules . 20 1.8 The Fortran 90 Language Standard . 21 1.9 References . 24 2. Fortran Concepts and Terms . 27 2.1 Scope and Association . 27 2.2 Program Organization . 35 2.3 Data Environment . 39 2.4 Program Execution . 43 2.5 Terms . 46 2.6 Summary of Forms. 52 2.7 Ordering Requirements . 57 vii Copyright © 1992 J. Adams, W. Brainerd, J. Martin, B. Smith, and J. Wagener 2.8 Example Fortran 90 Program . 59 2.9 Summary . 59 3. Language Elements and Source Form . 65 3.1 The Processor Character Set . 66 3.2 Lexical Tokens. 69 3.3 Source Form . 73 3.4 Rules for Fixed/Free Source Form . 82 3.5 The INCLUDE Line . 83 3.6 Low-Level Syntax. 84 3.7 Summary . 84 4. Data Types . 89 4.1 Building the Data Environment for a Problem Solution . 91 4.2 What Is Meant by “Type” in Fortran? . 96 4.3 Intrinsic Data Types . 99 4.4 Derived Types . 110 4.5 Structure Constructors. 121 4.6 Array Constructors. 124 4.7 Summary . 127 5. Declarations . 131 5.1 Type Declaration Statements. 134 5.2 Implicit Typing . 142 5.3 Array Properties . 144 5.4 Pointer Properties. 152 5.5 Value Attributes . 155 5.6 Object Accessibility and Use . 161 5.7 Procedure Properties . 171 5.8 Automatic Data Objects. 174 5.9 NAMELIST Statement . 175 5.10 Storage Association . 176 5.11 Summary . 186 viii Fortran 90 Handbook Copyright © 1992 J. Adams, W. Brainerd, J. Martin, B. Smith, and J. Wagener 6. Using Data . 197 6.1 Constants and Variables . 199 6.2 Substrings . 201 6.3 Structure Components . 203 6.4 Arrays . 205 6.5 Pointers and Allocatable Arrays. 215 6.6 Summary . 222 7. Expressions and Assignment . 227 7.1 Introduction to Fortran 90 Expressions . 228 7.2 Formation of Expressions . 234 7.3 Interpretation of Expressions . 276 7.4 Evaluation of Expressions . 284 7.5 Assignment . 290 7.6 Summary . 303 8. Controlling Execution . 309 8.1 The Execution Sequence . 310 8.2 Blocks and Executable Constructs . 310 8.3 IF Construct and IF Statement . 312 8.4 The CASE Construct. 316 8.5 The DO Construct. 321 8.6 Branching. 333 8.7 Obsolescent Control Statements . 337 8.8 Summary . 341 9. Input and Output Processing . ..
Recommended publications
  • PHP Programming Cookbook I
    PHP Programming Cookbook i PHP Programming Cookbook PHP Programming Cookbook ii Contents 1 PHP Tutorial for Beginners 1 1.1 Introduction......................................................1 1.1.1 Where is PHP used?.............................................1 1.1.2 Why PHP?..................................................2 1.2 XAMPP Setup....................................................3 1.3 PHP Language Basics.................................................5 1.3.1 Escaping to PHP...............................................5 1.3.2 Commenting PHP..............................................5 1.3.3 Hello World..................................................6 1.3.4 Variables in PHP...............................................6 1.3.5 Conditional Statements in PHP........................................7 1.3.6 Loops in PHP.................................................8 1.4 PHP Arrays...................................................... 10 1.5 PHP Functions.................................................... 12 1.6 Connecting to a Database............................................... 14 1.6.1 Connecting to MySQL Databases...................................... 14 1.6.2 Connecting to MySQLi Databases (Procedurial).............................. 14 1.6.3 Connecting to MySQLi databases (Object-Oriented)............................ 15 1.6.4 Connecting to PDO Databases........................................ 15 1.7 PHP Form Handling................................................. 15 1.8 PHP Include & Require Statements.........................................
    [Show full text]
  • Object-Oriented Programming Basics with Java
    Object-Oriented Programming Object-Oriented Programming Basics With Java In his keynote address to the 11th World Computer Congress in 1989, renowned computer scientist Donald Knuth said that one of the most important lessons he had learned from his years of experience is that software is hard to write! Computer scientists have struggled for decades to design new languages and techniques for writing software. Unfortunately, experience has shown that writing large systems is virtually impossible. Small programs seem to be no problem, but scaling to large systems with large programming teams can result in $100M projects that never work and are thrown out. The only solution seems to lie in writing small software units that communicate via well-defined interfaces and protocols like computer chips. The units must be small enough that one developer can understand them entirely and, perhaps most importantly, the units must be protected from interference by other units so that programmers can code the units in isolation. The object-oriented paradigm fits these guidelines as designers represent complete concepts or real world entities as objects with approved interfaces for use by other objects. Like the outer membrane of a biological cell, the interface hides the internal implementation of the object, thus, isolating the code from interference by other objects. For many tasks, object-oriented programming has proven to be a very successful paradigm. Interestingly, the first object-oriented language (called Simula, which had even more features than C++) was designed in the 1960's, but object-oriented programming has only come into fashion in the 1990's.
    [Show full text]
  • BUGS Code for Item Response Theory
    JSS Journal of Statistical Software August 2010, Volume 36, Code Snippet 1. http://www.jstatsoft.org/ BUGS Code for Item Response Theory S. McKay Curtis University of Washington Abstract I present BUGS code to fit common models from item response theory (IRT), such as the two parameter logistic model, three parameter logisitic model, graded response model, generalized partial credit model, testlet model, and generalized testlet models. I demonstrate how the code in this article can easily be extended to fit more complicated IRT models, when the data at hand require a more sophisticated approach. Specifically, I describe modifications to the BUGS code that accommodate longitudinal item response data. Keywords: education, psychometrics, latent variable model, measurement model, Bayesian inference, Markov chain Monte Carlo, longitudinal data. 1. Introduction In this paper, I present BUGS (Gilks, Thomas, and Spiegelhalter 1994) code to fit several models from item response theory (IRT). Several different software packages are available for fitting IRT models. These programs include packages from Scientific Software International (du Toit 2003), such as PARSCALE (Muraki and Bock 2005), BILOG-MG (Zimowski, Mu- raki, Mislevy, and Bock 2005), MULTILOG (Thissen, Chen, and Bock 2003), and TESTFACT (Wood, Wilson, Gibbons, Schilling, Muraki, and Bock 2003). The Comprehensive R Archive Network (CRAN) task view \Psychometric Models and Methods" (Mair and Hatzinger 2010) contains a description of many different R packages that can be used to fit IRT models in the R computing environment (R Development Core Team 2010). Among these R packages are ltm (Rizopoulos 2006) and gpcm (Johnson 2007), which contain several functions to fit IRT models using marginal maximum likelihood methods, and eRm (Mair and Hatzinger 2007), which contains functions to fit several variations of the Rasch model (Fischer and Molenaar 1995).
    [Show full text]
  • The Machine That Builds Itself: How the Strengths of Lisp Family
    Khomtchouk et al. OPINION NOTE The Machine that Builds Itself: How the Strengths of Lisp Family Languages Facilitate Building Complex and Flexible Bioinformatic Models Bohdan B. Khomtchouk1*, Edmund Weitz2 and Claes Wahlestedt1 *Correspondence: [email protected] Abstract 1Center for Therapeutic Innovation and Department of We address the need for expanding the presence of the Lisp family of Psychiatry and Behavioral programming languages in bioinformatics and computational biology research. Sciences, University of Miami Languages of this family, like Common Lisp, Scheme, or Clojure, facilitate the Miller School of Medicine, 1120 NW 14th ST, Miami, FL, USA creation of powerful and flexible software models that are required for complex 33136 and rapidly evolving domains like biology. We will point out several important key Full list of author information is features that distinguish languages of the Lisp family from other programming available at the end of the article languages and we will explain how these features can aid researchers in becoming more productive and creating better code. We will also show how these features make these languages ideal tools for artificial intelligence and machine learning applications. We will specifically stress the advantages of domain-specific languages (DSL): languages which are specialized to a particular area and thus not only facilitate easier research problem formulation, but also aid in the establishment of standards and best programming practices as applied to the specific research field at hand. DSLs are particularly easy to build in Common Lisp, the most comprehensive Lisp dialect, which is commonly referred to as the “programmable programming language.” We are convinced that Lisp grants programmers unprecedented power to build increasingly sophisticated artificial intelligence systems that may ultimately transform machine learning and AI research in bioinformatics and computational biology.
    [Show full text]
  • Fortran Reference Guide
    FORTRAN REFERENCE GUIDE Version 2018 TABLE OF CONTENTS Preface............................................................................................................ xv Audience Description......................................................................................... xv Compatibility and Conformance to Standards............................................................ xv Organization................................................................................................... xvi Hardware and Software Constraints...................................................................... xvii Conventions................................................................................................... xvii Related Publications........................................................................................ xviii Chapter 1. Language Overview............................................................................... 1 1.1. Elements of a Fortran Program Unit.................................................................. 1 1.1.1. Fortran Statements................................................................................. 1 1.1.2. Free and Fixed Source............................................................................. 2 1.1.3. Statement Ordering................................................................................. 2 1.2. The Fortran Character Set.............................................................................. 3 1.3. Free Form Formatting..................................................................................
    [Show full text]
  • SPSS to Orthosim File Conversion Utility Helpfile V.1.4
    SPSS to Orthosim File Conversion Utility Helpfile v.1.4 Paul Barrett Advanced Projects R&D Ltd. Auckland New Zealand email: [email protected] Web: www.pbarrett.net 30th December, 2019 Contents 3 Table of Contents Part I Introduction 5 1 Installation Details ................................................................................................................................... 7 2 Extracting Matrices from SPSS - Cut and Paste ................................................................................................................................... 8 3 Extracting Matrices from SPSS: Orthogonal Factors - E.x..c..e..l. .E..x..p..o..r.t................................................................................................................. 17 4 Extracting Matrices from SPSS: Oblique Factors - Exce.l. .E..x..p..o..r..t...................................................................................................................... 24 5 Creating Orthogonal Factor Orthosim Files ................................................................................................................................... 32 6 Creating Oblique Factor Orthosim Files ................................................................................................................................... 41 3 Paul Barrett Part I 6 SPSS to Orthosim File Conversion Utility Helpfile v.1.4 1 Introduction SPSS-to-Orthosim converts SPSS 11/12/13/14 factor loading and factor correlation matrices into the fixed-format .vf (simple ASCII text) files
    [Show full text]
  • Preview Fortran Tutorial (PDF Version)
    Fortran i Fortran About the Tutorial Fortran was originally developed by a team at IBM in 1957 for scientific calculations. Later developments made it into a high level programming language. In this tutorial, we will learn the basic concepts of Fortran and its programming code. Audience This tutorial is designed for the readers who wish to learn the basics of Fortran. Prerequisites This tutorial is designed for beginners. A general awareness of computer programming languages is the only prerequisite to make the most of this tutorial. Copyright & Disclaimer Copyright 2017 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected] i Fortran Table of Contents About the Tutorial ····································································································································i Audience ··················································································································································i
    [Show full text]
  • A Quick Reference to C Programming Language
    A Quick Reference to C Programming Language Structure of a C Program #include(stdio.h) /* include IO library */ #include... /* include other files */ #define.. /* define constants */ /* Declare global variables*/) (variable type)(variable list); /* Define program functions */ (type returned)(function name)(parameter list) (declaration of parameter types) { (declaration of local variables); (body of function code); } /* Define main function*/ main ((optional argc and argv arguments)) (optional declaration parameters) { (declaration of local variables); (body of main function code); } Comments Format: /*(body of comment) */ Example: /*This is a comment in C*/ Constant Declarations Format: #define(constant name)(constant value) Example: #define MAXIMUM 1000 Type Definitions Format: typedef(datatype)(symbolic name); Example: typedef int KILOGRAMS; Variables Declarations: Format: (variable type)(name 1)(name 2),...; Example: int firstnum, secondnum; char alpha; int firstarray[10]; int doublearray[2][5]; char firststring[1O]; Initializing: Format: (variable type)(name)=(value); Example: int firstnum=5; Assignments: Format: (name)=(value); Example: firstnum=5; Alpha='a'; Unions Declarations: Format: union(tag) {(type)(member name); (type)(member name); ... }(variable name); Example: union demotagname {int a; float b; }demovarname; Assignment: Format: (tag).(member name)=(value); demovarname.a=1; demovarname.b=4.6; Structures Declarations: Format: struct(tag) {(type)(variable); (type)(variable); ... }(variable list); Example: struct student {int
    [Show full text]
  • Php Tutorial
    PHP About the Tutorial The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web-based software applications. This tutorial will help you understand the basics of PHP and how to put it in practice. Audience This tutorial has been designed to meet the requirements of all those readers who are keen to learn the basics of PHP. Prerequisites Before proceeding with this tutorial, you should have a basic understanding of computer programming, Internet, Database, and MySQL. Copyright & Disclaimer © Copyright 2016 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected] i PHP Table of Contents About the Tutorial ...........................................................................................................................................
    [Show full text]
  • Lecture 2: Introduction to C Programming Language [email protected]
    CSCI-UA 201 Joanna Klukowska Lecture 2: Introduction to C Programming Language [email protected] Lecture 2: Introduction to C Programming Language Notes include some materials provided by Andrew Case, Jinyang Li, Mohamed Zahran, and the textbooks. Reading materials Chapters 1-6 in The C Programming Language, by B.W. Kernighan and Dennis M. Ritchie Section 1.2 and Aside on page 4 in Computer Systems, A Programmer’s Perspective by R.E. Bryant and D.R. O’Hallaron Contents 1 Intro to C and Unix/Linux 3 1.1 Why C?............................................................3 1.2 C vs. Java...........................................................3 1.3 Code Development Process (Not Only in C).........................................4 1.4 Basic Unix Commands....................................................4 2 First C Program and Stages of Compilation 6 2.1 Writing and running hello world in C.............................................6 2.2 Hello world line by line....................................................7 2.3 What really happens when we compile a program?.....................................8 3 Basics of C 9 3.1 Data types (primitive types)..................................................9 3.2 Using printf to print different data types.........................................9 3.3 Control flow.......................................................... 10 3.4 Functions........................................................... 11 3.5 Variable scope........................................................ 12 3.6 Header files.........................................................
    [Show full text]
  • A Tutorial Introduction to the Language B
    A TUTORIAL INTRODUCTION TO THE LANGUAGE B B. W. Kernighan Bell Laboratories Murray Hill, New Jersey 1. Introduction B is a new computer language designed and implemented at Murray Hill. It runs and is actively supported and documented on the H6070 TSS system at Murray Hill. B is particularly suited for non-numeric computations, typified by system programming. These usually involve many complex logical decisions, computations on integers and fields of words, especially charac- ters and bit strings, and no floating point. B programs for such operations are substantially easier to write and understand than GMAP programs. The generated code is quite good. Implementation of simple TSS subsystems is an especially good use for B. B is reminiscent of BCPL [2] , for those who can remember. The original design and implementation are the work of K. L. Thompson and D. M. Ritchie; their original 6070 version has been substantially improved by S. C. Johnson, who also wrote the runtime library. This memo is a tutorial to make learning B as painless as possible. Most of the features of the language are mentioned in passing, but only the most important are stressed. Users who would like the full story should consult A User’s Reference to B on MH-TSS, by S. C. Johnson [1], which should be read for details any- way. We will assume that the user is familiar with the mysteries of TSS, such as creating files, text editing, and the like, and has programmed in some language before. Throughout, the symbolism (->n) implies that a topic will be expanded upon in section n of this manual.
    [Show full text]
  • ILE C/C++ Programmer's Guide
    IBM i 7.2 Programming IBM Rational Development Studio for i ILE C/C++ Programmer's Guide IBM SC09-2712-07 Note Before using this information and the product it supports, read the information in “Notices” on page 441. This edition applies to version 7, release 2, modification 0 of IBM Rational Development Studio for i (product number 5770-WDS) and to all subsequent releases and modifications until otherwise indicated in new editions. This version does not run on all reduced instruction set computer (RISC) models nor does it run on CISC models. This document may contain references to Licensed Internal Code. Licensed Internal Code is Machine Code and is licensed to you under the terms of the IBM License Agreement for Machine Code. © Copyright International Business Machines Corporation 1993, 2013. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents ILE C/C++ Programmer’s Guide..............................................................................1 PDF file for ILE C/C++ Programmer’s Guide............................................................................................... 3 About ILE C/C++ Programmer's Guide........................................................................................................5 Install Licensed Program Information................................................................................................... 5 Notes About Examples..........................................................................................................................
    [Show full text]