Fortran 77 Version 5.0

Download Fortran 77 Version 5.0

Post on 03-Apr-2018

218 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

<ul><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 1/372</p><p>FORTRAN 77 Language Reference</p><p>FORTRAN 77 Version 5.0</p><p>901 San Antonio RoadPalo Alto, , CA 94303-4900</p><p>USA 650 960-1300 fax 650 969-9131</p><p>Part No: 805-4939Revision A, February 1999</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 2/372</p><p>Copyright Copyright 1999 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California 94303-4900 U.S.A. All rights reserved.</p><p>All rights reserved. This product or document is protected by copyright and distributed under licenses restricting its use, copying,distribution, and decompilation. No part of this product or document may be reproduced in any form by any means without prior writtenauthorization of Sun and its licensors, if any.</p><p>Portions of this product may be derived from the UNIX system, licensed from Novell, Inc., and from the Berkeley 4.3 BSD system,licensed from the University of California. UNIX is a registered trademark in the United States and in other countries and is exclusivelylicensed by X/Open Company Ltd. Third-party software, including font technology in this product, is protected by copyright and licensedfrom Suns suppliers. RESTRICTED RIGHTS: Use, duplication, or disclosure by the U.S. Government is subject to restrictions of FAR52.227-14(g)(2)(6/87) and FAR 52.227-19(6/87), or DFAR 252.227-7015(b)(6/95) and DFAR 227.7202-3(a).</p><p>Sun, Sun Microsystems, the Sun logo, SunDocs, SunExpress, Solaris, Sun Performance Library, Sun Performance WorkShop, Sun VisualWorkShop, Sun WorkShop, and Sun WorkShop Professional are trademarks or registered trademarks of Sun Microsystems, Inc. in theUnited States and in other countries. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARCInternational, Inc. in the United States and in other countries. Products bearing SPARC trademarks are based upon an architecturedeveloped by Sun Microsystems, Inc.</p><p>The OPEN LOOK and SunTM</p><p>Graphical User Interfaces were developed by Sun Microsystems, Inc. for its users and licensees. Sunacknowledges the pioneering efforts of Xerox Corporation in researching and developing the concept of visual or graphical user interfacesfor the computer industry. Sun holds a nonexclusive license from Xerox to the Xerox Graphical User Interface, which license also coversSuns licensees who implement OPEN LOOK GUIs and otherwise comply with Suns written license agreements.</p><p>THIS PUBLICATION IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, ORNON-INFRINGEMENT.</p><p>Copyright 1999 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, Californie 94303-4900 U.S.A. Tous droits rservs.</p><p>Ce produit ou document est protg par un copyright et distribu avec des licences qui en restreignent lutilisation, la copie et ladcompilation. Aucune partie de ce produit ou de sa documentation associe ne peut tre reproduite sous aucune forme, par quelquemoyen que ce soit, sans lautorisation pralable et crite de Sun et de ses bailleurs de licence, sil y en a.</p><p>Des parties de ce produit pourront tre derives du systme UNIX licenci par Novell, Inc. et du systme Berkeley 4.3 BSD licenci parlUniversit de Californie. UNIX est une marque enregistre aux Etats-Unis et dans dautres pays, et licencie exclusivement par X/OpenCompany Ltd. Le logiciel dtenu par des tiers, et qui comprend la technologie relative aux polices de caractres, est protg par uncopyright et licenci par des fournisseurs de Sun.</p><p>Sun, Sun Microsystems, le logo Sun, SunDocs, SunExpress, Solaris, Sun Performance Library, Sun Performance WorkShop, Sun VisualWorkShop, Sun WorkShop, et Sun WorkShop Professional sont des marques dposes ou enregistres de Sun Microsystems, Inc. auxEtats-Unis et dans dautres pays. Toutes les marques SPARC, utilises sous licence, sont des marques dposes ou enregistres de SPARCInternational, Inc. aux Etats-Unis et dans dautres pays. Les produits portant les marques SPARC sont bass sur une architecturedveloppe par Sun Microsystems, Inc.</p><p>Les utilisateurs dinterfaces graphiques OPEN LOOK et SunTM</p><p>ont t dvelopps de Sun Microsystems, Inc. pour ses utilisateurs etlicencis. Sun reconnat les efforts de pionniers de Xerox Corporation pour la recherche et le dveloppement du concept des interfacesdutilisation visuelle ou graphique pour lindustrie de linformatique. Sun dtient une licence non exclusive de Xerox sur linterfacedutilisation graphique, cette licence couvrant aussi les licencis de Sun qui mettent en place les utilisateurs dinterfaces graphiques OPENLOOK et qui en outre se conforment aux licences crites de Sun.</p><p>CETTE PUBLICATION EST FOURNIE "EN LETAT" SANS GARANTIE DAUCUNE SORTE, NI EXPRESSE NI IMPLICITE, Y COMPRIS,ET SANS QUE CETTE LISTE NE SOIT LIMITATIVE, DES GARANTIES CONCERNANT LA VALEUR MARCHANDE, LAPTITUDE DESPRODUITS A REPONDRE A UNE UTILISATION PARTICULIERE OU LE FAIT QUILS NE SOIENT PAS CONTREFAISANTS DEPRODUITS DE TIERS.</p><p>PleaseRecycle</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 3/372</p><p>Contents</p><p>Preface xix</p><p>1. Elements of FORTRAN 1</p><p>Standards Conformance 1</p><p>Extensions 2</p><p>Basic Terms 2</p><p>Character Set 2</p><p>Symbolic Names 4</p><p>Program Units 6</p><p>Statements 7</p><p>Executable and Nonexecutable Statements 7</p><p>FORTRAN Statements 7</p><p>Source Line Formats 8</p><p>Standard Fixed Format 9</p><p>Tab-Format 9</p><p>Mixing Formats 9</p><p>Continuation Lines 9</p><p>Extended Lines 10</p><p>Padding 10</p><p>Comments and Blank Lines 10</p><p>Contents iii</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 4/372</p><p>Directives 11</p><p>2. Data Types and Data Items 13</p><p>Types 13</p><p>Rules for Data Typing 13</p><p>Array Elements 14</p><p>Functions 14Properties of Data Types 15</p><p>Size and Alignment of Data Types 20</p><p>Constants 24</p><p>Character Constants 24</p><p>Complex Constants 27</p><p>COMPLEX*16 Constants 27</p><p>COMPLEX*32 (Quad Complex) Constants 27</p><p>Integer Constants 28</p><p>Logical Constants 29</p><p>Real Constants 29</p><p>REAL*8 (Double-Precision Real) Constants 31</p><p>REAL*16 (Quad Real) Constants 32</p><p>Typeless Constants (Binary, Octal, Hexadecimal) 32</p><p>Fortran 90-Style Constants @ 36</p><p>Variables 36</p><p>Arrays 37</p><p>Array Declarators 37</p><p>Array Names with No Subscripts 40</p><p>Array Subscripts 40</p><p>Array Ordering 42</p><p>Substrings 43</p><p>Structures 45</p><p>iv FORTRAN 77 Language Reference Revision A, February 1999</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 5/372</p><p>Syntax 45</p><p>Field Declaration 45</p><p>Rules and Restrictions for Structures 46</p><p>Rules and Restrictions for Fields 46</p><p>Record Declaration 47</p><p>Record and Field Reference 48Substructure Declaration 49</p><p>Unions and Maps 50</p><p>Pointers 52</p><p>Syntax Rules 52</p><p>Usage of Pointers 53</p><p>Address and Memory 53</p><p>Optimization and Pointers 55</p><p>3. Expressions 59</p><p>Expressions, Operators, and Operands 59</p><p>Arithmetic Expressions 60</p><p>Basic Arithmetic Expressions 61</p><p>Mixed Mode 62</p><p>Arithmetic Assignment 65</p><p>Character Expressions 66</p><p>Character String Assignment 67</p><p>Rules of Assignment 69</p><p>Logical Expressions 69</p><p>Relational Operator 72</p><p>Constant Expressions 73</p><p>Record Assignment 74</p><p>Evaluation of Expressions 75</p><p>4. Statements 77</p><p>Contents v</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 6/372</p><p>ACCEPT 77</p><p>Description 78</p><p>ASSIGN 78</p><p>Description 78</p><p>Restrictions 78</p><p>Examples 79Assignment 79</p><p>Description 80</p><p>Examples 82</p><p>AUTOMATIC 84</p><p>Description 84</p><p>Restrictions 84</p><p>Examples 85</p><p>Restrictions 85</p><p>BACKSPACE 85</p><p>Description 86</p><p>Examples 86</p><p>BLOCK DATA 87</p><p>Description 87</p><p>Restrictions 88</p><p>Example 88</p><p>BYTE 88</p><p>Description 89</p><p>Example 89</p><p>CALL 89</p><p>Description 89</p><p>Examples 91</p><p>CHARACTER 92</p><p>vi FORTRAN 77 Language Reference Revision A, February 1999</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 7/372</p><p>Description 93</p><p>Examples 93</p><p>CLOSE 95</p><p>Description 95</p><p>Comments 96</p><p>Examples 96COMMON 97</p><p>Description 97</p><p>Restrictions 97</p><p>Examples 98</p><p>COMPLEX 98</p><p>Description 99</p><p>Comments 100</p><p>Examples 100</p><p>CONTINUE 101</p><p>Description 101</p><p>Example 101</p><p>DATA 102</p><p>Description 102</p><p>Examples 104</p><p>DECODE/ENCODE 105</p><p>Description 105</p><p>Example 106</p><p>DIMENSION 107</p><p>Description 107</p><p>Examples 108</p><p>DO 109</p><p>Description 110</p><p>Contents vii</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 8/372</p><p>Restrictions 112</p><p>Comments 112</p><p>Examples 112</p><p>DO WHILE 113</p><p>Description 114</p><p>Restrictions 115Comments 115</p><p>Examples 116</p><p>DOUBLE COMPLEX 116</p><p>Description 116</p><p>Comments 117</p><p>DOUBLE PRECISION 117</p><p>Description 118</p><p>Example 118</p><p>ELSE 118</p><p>Description 119</p><p>Restrictions 119</p><p>Examples 119</p><p>ELSE IF 120</p><p>Description 120</p><p>Restrictions 121</p><p>Example 121</p><p>ENCODE/DECODE 121</p><p>Description 122</p><p>Example 122</p><p>END 122</p><p>Description 122</p><p>Example 123</p><p>viii FORTRAN 77 Language Reference Revision A, February 1999</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 9/372</p><p>END DO 123</p><p>Description 123</p><p>Examples 123</p><p>END FILE 124</p><p>Description 124</p><p>Restrictions 125Examples 125</p><p>END IF 125</p><p>Description 126</p><p>Examples 126</p><p>END MAP 126</p><p>Description 126</p><p>Restrictions 126</p><p>Example 127</p><p>END STRUCTURE 127</p><p>Description 127</p><p>Example 127</p><p>END UNION 127</p><p>Description 128</p><p>Example 128</p><p>ENTRY 128</p><p>Description 128</p><p>Restrictions 129</p><p>Examples 129</p><p>EQUIVALENCE 130</p><p>Description 131</p><p>Restrictions 131</p><p>Example 132</p><p>Contents ix</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 10/372</p><p>EXTERNAL 132</p><p>Description 133</p><p>Restrictions 133</p><p>Examples 133</p><p>FORMAT 134</p><p>Description 136Restrictions 137</p><p>Warnings 137</p><p>Examples 137</p><p>FUNCTION (External) 138</p><p>Description 140</p><p>Restrictions 141</p><p>Examples 141</p><p>GO TO (Assigned) 142</p><p>Description 142</p><p>Restrictions 143</p><p>Example 143</p><p>GO TO (Computed) 143</p><p>Description 144</p><p>Restrictions 144</p><p>Example 144</p><p>GO TO (Unconditional) 145</p><p>Description 145</p><p>Restrictions 145</p><p>Example 145</p><p>IF (Arithmetic) 145</p><p>Description 146</p><p>Example 146</p><p>x FORTRAN 77 Language Reference Revision A, February 1999</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 11/372</p><p>IF (Block) 146</p><p>Description 147</p><p>Restrictions 148</p><p>Examples 148</p><p>IF (Logical) 149</p><p>Description 149Example 150</p><p>IMPLICIT 150</p><p>Description 152</p><p>Restrictions 152</p><p>Examples 153</p><p>INCLUDE 154</p><p>Description 154</p><p>Examples 155</p><p>INQUIRE 156</p><p>Description 157</p><p>Examples 162</p><p>INTEGER 163</p><p>Description 163</p><p>Restrictions 164</p><p>Examples 164</p><p>INTRINSIC 164</p><p>Description 165</p><p>Restrictions 165</p><p>LOGICAL 166</p><p>Description 167</p><p>Examples 168</p><p>MAP 168</p><p>Contents xi</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 12/372</p><p>Description 168</p><p>Example 169</p><p>NAMELIST 169</p><p>Description 169</p><p>Restrictions 170</p><p>Example 170OPEN 171</p><p>Description 171</p><p>Examples 176</p><p>OPTIONS 178</p><p>Description 178</p><p>Restrictions 179</p><p>Example 179</p><p>PARAMETER 179</p><p>Description 180</p><p>Restrictions 180</p><p>Examples 181</p><p>PAUSE 182</p><p>Description 182</p><p>POINTER 183</p><p>Description 183</p><p>Examples 184</p><p>PRINT 186</p><p>Description 187</p><p>Restrictions 188</p><p>Examples 188</p><p>PROGRAM 189</p><p>Description 189</p><p>xii FORTRAN 77 Language Reference Revision A, February 1999</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 13/372</p><p>Restrictions 190</p><p>Example 190</p><p>READ 190</p><p>Description 191</p><p>Examples 194</p><p>REAL 196Description 196</p><p>Examples 197</p><p>RECORD 198</p><p>Description 198</p><p>Restrictions 198</p><p>Example 199</p><p>RETURN 200</p><p>Description 200</p><p>Examples 200</p><p>REWIND 201</p><p>Description 202</p><p>Examples 202</p><p>SAVE 202</p><p>Description 203</p><p>Restrictions 203</p><p>Example 203</p><p>Statement Function 204</p><p>Description 204</p><p>Restrictions 205</p><p>Examples 205</p><p>STATIC 206</p><p>Description 206</p><p>Contents xiii</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 14/372</p><p>Example 207</p><p>STOP 207</p><p>Description 207</p><p>Examples 208</p><p>STRUCTURE 208</p><p>Description 209Restrictions 209</p><p>Restrictions for Fields 209</p><p>Examples 210</p><p>SUBROUTINE 211</p><p>Description 211</p><p>Examples 212</p><p>TYPE 213</p><p>Description 213</p><p>Example 213</p><p>The Type Statement 214</p><p>Description 216</p><p>Restrictions 217</p><p>Example 217</p><p>UNION and MAP 217</p><p>Description 218</p><p>Example 218</p><p>VIRTUAL 219</p><p>Description 219</p><p>Example 219</p><p>VOLATILE 220</p><p>Description 220</p><p>Example 220</p><p>xiv FORTRAN 77 Language Reference Revision A, February 1999</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 15/372</p><p>WRITE 220</p><p>Description 221</p><p>Restrictions 224</p><p>Comments 224</p><p>Examples 225</p><p>5. Input and Output 227Essential FORTRAN I/O Concepts 227</p><p>Logical Units 227</p><p>I/O Errors 228</p><p>General Restriction 228</p><p>Kinds of I/O 229</p><p>Combinations of I/O 229</p><p>Printing Files 230</p><p>Special Uses of OPEN 231</p><p>Scratch Files 232</p><p>Changing I/O Initialization with IOINIT 232</p><p>Direct Access 234</p><p>Unformatted I/O 234</p><p>Formatted I/O 235</p><p>Internal Files 235</p><p>Sequential Formatted I/O 235</p><p>Direct Access I/O 235</p><p>Formatted I/O 236</p><p>Input Actions 236</p><p>Output Actions 237</p><p>Format Specifiers 237</p><p>Runtime Formats 267</p><p>Variable Format Expressions () 268</p><p>Contents xv</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 16/372</p><p>Unformatted I/O 269</p><p>Sequential Access I/O 269</p><p>Direct Access I/O 270</p><p>List-Directed I/O 271</p><p>Output Format 272</p><p>Unquoted Strings 274Internal I/O 275</p><p>NAMELIST I/O 275</p><p>Syntax Rules 275</p><p>Restrictions 276</p><p>Output Actions 277</p><p>Input Actions 278</p><p>Data Syntax 278</p><p>Name Requests 282</p><p>6. Intrinsic Functions 283</p><p>Arithmetic and Mathematical Functions 284</p><p>Arithmetic 284</p><p>Type Conversion 286</p><p>Trigonometric Functions 288</p><p>Other Mathematical Functions 291</p><p>Character Functions 292</p><p>Miscellaneous Functions 294</p><p>Bit Manipulation @ 294</p><p>Environmental Inquiry Functions @ 295</p><p>Memory @ 296</p><p>Remarks 296</p><p>Notes on Functions 298</p><p>VMS Intrinsic Functions 302</p><p>xvi FORTRAN 77 Language Reference Revision A, February 1999</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 17/372</p><p>VMS Double-Precision Complex 302</p><p>VMS Degree-Based Trigonometric 302</p><p>VMS Bit-Manipulation 303</p><p>VMS Multiple Integer Types 305</p><p>Functions Coerced to a Particular Type 306</p><p>Functions Translated to a Generic Name 307Zero Extend 307</p><p>A. ASCII Character Set 309</p><p>B. Sample Statements 313</p><p>C. Data Representations 329</p><p>Real, Double, and Quadruple Precision 329</p><p>Extreme Exponents 330</p><p>Zero (signed) 330</p><p>Subnormal Number 330</p><p>Signed Infinity 330</p><p>Not a Number (NaN) 330</p><p>IEEE Representation of Selected Numbers 331</p><p>Arithmetic Operations on Extreme Values 331</p><p>Bits and Bytes by Architecture 334</p><p>D. VMS Language Extensions 337</p><p>Background 337</p><p>VMS Language Features in Sun Fortran 337</p><p>VMS Features Requiring -xl or -vax=spec 341</p><p>Summary of Features That Require -xl[d] 341</p><p>Details of Features That Require -xl[d] 341</p><p>Unsupported VMS FORTRAN 344</p><p>Index 347</p><p>Contents xvii</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 18/372</p><p>xviii FORTRAN 77 Language Reference Revision A, February 1999</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 19/372</p><p>Preface</p><p>This manual provides a reference to the Fortran 77 language accepted by the SunTM</p><p>FORTRAN 5.0 compiler f77.</p><p>Who Should Use This BookThis is a reference manual intended for programmers with a working knowledge ofthe Fortran language and some understanding of the Solaris</p><p>TM</p><p>operating environmentand UNIX commands.</p><p>How This Book Is OrganizedThis book is organized into the following chapters and appendixes:</p><p>Chapter 1, "Elements of FORTRAN" introduces the basic parts of Sun FORTRAN 77,standards conformance, and elements of the language.</p><p>Chapter 2, "Data Types and Data Items" describes the data types and data structuresin the language, including arrays, substrings, structures, and pointers.</p><p>Chapter 3, "Expressions" discusses FORTRAN expressions and how they areevaluated.</p><p>Chapter 4, "Statements" details the statements in the FORTRAN 77 language and theextensions recognized by the Sun compiler.</p><p>Preface xix</p></li><li><p>7/28/2019 Fortran 77 Version 5.0</p><p> 20/372</p><p>Chapter 5, "Input and Output" describes the general concepts of FORTRAN input/output and provides details on the different I/O operations.</p><p>Chapter 6, "Intrinsic Functions" tabulates and explains the intrinsic functions that arepart of Sun FORTRAN 77, including VAX VMS extensions.</p><p>Appendix A, "ASCII Character Set" lists the standard ASCII character set.</p><p>Appendix B, "Sample Statements" shows samples of selected FORTRAN 77statements...</p></li></ul>

Recommended

View more >