Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 84 lines (54 sloc) 2.12 kB
184ca75 @jiho Improved punctuation.
jiho authored
1 The `'fmt='` specifier in a `read` or `write` statement can give either the line number of a `format` statement, an actual format string, or a `*` for free format.
69a6947 @infininight Add cheatsheet and new subroutine/function commands. Sent in by jiho.
infininight authored
2
3 # Syntax
4
5 A format specifier is a parenthesized string of format descriptors.
6
7 <table class="pro_table">
8 <tr>
9 <th>Descriptor</th>
10 <th>Meaning</th>
11 </tr>
12
13 <tr>
14 <td>I<em>n</em></td>
15 <td><em>n</em> positions of integer data</td>
16 </tr>
17
18 <tr>
19 <td>F<em>n</em>.d</td>
20 <td><em>n</em> positions of real data (with d decimal places) &mdash; Decimal point form</td>
21 </tr>
22
23 <tr>
24 <td>E<em>n</em>.d</td>
25 <td><em>n</em> positions of real data (with d decimal places) &mdash; Exponent form</td>
26 </tr>
27
28 <tr>
29 <td>L<em>n</em></td>
30 <td><em>n</em> positions of logical data</td>
31 </tr>
32
33 <tr>
34 <td>A[<em>n</em>]</td>
35 <td>[<em>n</em> positions of] character data</td>
36 </tr>
37
38 <tr>
39 <td><em>n</em>X</td>
40 <td>skip <em>n</em> horizontal positions (X spaces)</td>
41 </tr>
42
43 <tr>
44 <td>\</td>
45 <td>skip line</td>
46 </tr>
47
48 <tr>
49 <td>T<em>c</em></td>
50 <td>tab to column number <em>c</em></td>
51 </tr>
52
53 </table>
54
55 Descriptors, or groups of descriptors, can be repeated by prefixing, or parenthesizing and prefixing, with the number of repeats. For example `I4` can be repeated as `2I4` and `I4,1X` as `2(I4,1X)`.
56
57 Plain text strings can be inserted in the format string using double quotes (or two single quotes).
58
59 When the variable cannot be printed entirely given the format specified, it is displayed as placeholders (`'*'` usually)
60
61 # Examples
62
63 NB: &#x2423; is a space
64
65 write(*,'(i6,i2)') 3, 2
66
67 &#x2423;&#x2423;&#x2423;&#x2423;&#x2423;3&#x2423;2
68
69 write(*,'(f10.4,e15.7)') 12.7864, 234.4591
70
71 &#x2423;&#x2423;&#x2423;12.7864&#x2423;&#x2423;0.2344591E+03
72
73
74 write(*,'(2x,"record Nº",i2," is ",A6)') 10, 'Philip'
75
76 &#x2423;&#x2423;record&#x2423;Nº10&#x2423;is&#x2423;Philip
77
78
79 write(*,'(2X,2(I4,1X),''name '',A4,F13.5,1X,E13.5)') 77778, 3, 'ABCDEFGHI', 14.45, 15.5666666
80
81 &#x2423;&#x2423;\*\*\*\*&#x2423;&#x2423;&#x2423;&#x2423;3&#x2423;name&#x2423;ABCD&#x2423;&#x2423;&#x2423;&#x2423;&#x2423;14.45000&#x2423;&#x2423;&#x2423;0.15567E+02
82
83
Something went wrong with that request. Please try again.