Extended-I_002fO-specifiers.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1999-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>The GNU Fortran Compiler: Extended I/O specifiers</title>
  20. <meta name="description" content="The GNU Fortran Compiler: Extended I/O specifiers">
  21. <meta name="keywords" content="The GNU Fortran Compiler: Extended I/O specifiers">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Extensions-implemented-in-GNU-Fortran.html#Extensions-implemented-in-GNU-Fortran" rel="up" title="Extensions implemented in GNU Fortran">
  30. <link href="Legacy-PARAMETER-statements.html#Legacy-PARAMETER-statements" rel="next" title="Legacy PARAMETER statements">
  31. <link href="Bitwise-logical-operators.html#Bitwise-logical-operators" rel="prev" title="Bitwise logical operators">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Extended-I_002fO-specifiers"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Legacy-PARAMETER-statements.html#Legacy-PARAMETER-statements" accesskey="n" rel="next">Legacy PARAMETER statements</a>, Previous: <a href="Bitwise-logical-operators.html#Bitwise-logical-operators" accesskey="p" rel="prev">Bitwise logical operators</a>, Up: <a href="Extensions-implemented-in-GNU-Fortran.html#Extensions-implemented-in-GNU-Fortran" accesskey="u" rel="up">Extensions implemented in GNU Fortran</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="Extended-I_002fO-specifiers-1"></a>
  69. <h4 class="subsection">6.1.30 Extended I/O specifiers</h4>
  70. <a name="index-CARRIAGECONTROL"></a>
  71. <a name="index-READONLY"></a>
  72. <a name="index-SHARE"></a>
  73. <a name="index-SHARED"></a>
  74. <a name="index-NOSHARED"></a>
  75. <a name="index-I_002fO-specifiers"></a>
  76. <p>GNU Fortran supports the additional legacy I/O specifiers
  77. <code>CARRIAGECONTROL</code>, <code>READONLY</code>, and <code>SHARE</code> with the
  78. compile flag <samp>-fdec</samp>, for compatibility.
  79. </p>
  80. <dl compact="compact">
  81. <dt><code>CARRIAGECONTROL</code></dt>
  82. <dd><p>The <code>CARRIAGECONTROL</code> specifier allows a user to control line
  83. termination settings between output records for an I/O unit. The specifier has
  84. no meaning for readonly files. When <code>CARRAIGECONTROL</code> is specified upon
  85. opening a unit for formatted writing, the exact <code>CARRIAGECONTROL</code> setting
  86. determines what characters to write between output records. The syntax is:
  87. </p>
  88. <div class="smallexample">
  89. <pre class="smallexample">OPEN(..., CARRIAGECONTROL=cc)
  90. </pre></div>
  91. <p>Where <em>cc</em> is a character expression that evaluates to one of the
  92. following values:
  93. </p>
  94. <table>
  95. <tr><td width="20%"><code>'LIST'</code></td><td width="80%">One line feed between records (default)</td></tr>
  96. <tr><td width="20%"><code>'FORTRAN'</code></td><td width="80%">Legacy interpretation of the first character (see below)</td></tr>
  97. <tr><td width="20%"><code>'NONE'</code></td><td width="80%">No separator between records</td></tr>
  98. </table>
  99. <p>With <code>CARRIAGECONTROL='FORTRAN'</code>, when a record is written, the first
  100. character of the input record is not written, and instead determines the output
  101. record separator as follows:
  102. </p>
  103. <table>
  104. <thead><tr><th width="30%">Leading character</th><th width="30%">Meaning</th><th width="40%">Output separating character(s)</th></tr></thead>
  105. <tr><td width="30%"><code>'+'</code></td><td width="30%">Overprinting</td><td width="40%">Carriage return only</td></tr>
  106. <tr><td width="30%"><code>'-'</code></td><td width="30%">New line</td><td width="40%">Line feed and carriage return</td></tr>
  107. <tr><td width="30%"><code>'0'</code></td><td width="30%">Skip line</td><td width="40%">Two line feeds and carriage return</td></tr>
  108. <tr><td width="30%"><code>'1'</code></td><td width="30%">New page</td><td width="40%">Form feed and carriage return</td></tr>
  109. <tr><td width="30%"><code>'$'</code></td><td width="30%">Prompting</td><td width="40%">Line feed (no carriage return)</td></tr>
  110. <tr><td width="30%"><code>CHAR(0)</code></td><td width="30%">Overprinting (no advance)</td><td width="40%">None</td></tr>
  111. </table>
  112. </dd>
  113. <dt><code>READONLY</code></dt>
  114. <dd><p>The <code>READONLY</code> specifier may be given upon opening a unit, and is
  115. equivalent to specifying <code>ACTION='READ'</code>, except that the file may not be
  116. deleted on close (i.e. <code>CLOSE</code> with <code>STATUS=&quot;DELETE&quot;</code>). The syntax
  117. is:
  118. </p>
  119. <div class="smallexample">
  120. <pre class="smallexample"><code>OPEN(..., READONLY)</code>
  121. </pre></div>
  122. </dd>
  123. <dt><code>SHARE</code></dt>
  124. <dd><p>The <code>SHARE</code> specifier allows system-level locking on a unit upon opening
  125. it for controlled access from multiple processes/threads. The <code>SHARE</code>
  126. specifier has several forms:
  127. </p>
  128. <div class="smallexample">
  129. <pre class="smallexample">OPEN(..., SHARE=sh)
  130. OPEN(..., SHARED)
  131. OPEN(..., NOSHARED)
  132. </pre></div>
  133. <p>Where <em>sh</em> in the first form is a character expression that evaluates to
  134. a value as seen in the table below. The latter two forms are aliases
  135. for particular values of <em>sh</em>:
  136. </p>
  137. <table>
  138. <thead><tr><th width="30%">Explicit form</th><th width="30%">Short form</th><th width="40%">Meaning</th></tr></thead>
  139. <tr><td width="30%"><code>SHARE='DENYRW'</code></td><td width="30%"><code>NOSHARED</code></td><td width="40%">Exclusive (write) lock</td></tr>
  140. <tr><td width="30%"><code>SHARE='DENYNONE'</code></td><td width="30%"><code>SHARED</code></td><td width="40%">Shared (read) lock</td></tr>
  141. </table>
  142. <p>In general only one process may hold an exclusive (write) lock for a given file
  143. at a time, whereas many processes may hold shared (read) locks for the same
  144. file.
  145. </p>
  146. <p>The behavior of locking may vary with your operating system. On POSIX systems,
  147. locking is implemented with <code>fcntl</code>. Consult your corresponding operating
  148. system&rsquo;s manual pages for further details. Locking via <code>SHARE=</code> is not
  149. supported on other systems.
  150. </p>
  151. </dd>
  152. </dl>
  153. <hr>
  154. <div class="header">
  155. <p>
  156. Next: <a href="Legacy-PARAMETER-statements.html#Legacy-PARAMETER-statements" accesskey="n" rel="next">Legacy PARAMETER statements</a>, Previous: <a href="Bitwise-logical-operators.html#Bitwise-logical-operators" accesskey="p" rel="prev">Bitwise logical operators</a>, Up: <a href="Extensions-implemented-in-GNU-Fortran.html#Extensions-implemented-in-GNU-Fortran" accesskey="u" rel="up">Extensions implemented in GNU Fortran</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  157. </div>
  158. </body>
  159. </html>