1
-
2
- ## Language elements
1
+ # Language elements
3
2
4
3
Fortran is <a href="case-insensitive" class="wikilink"
5
4
title="case-insensitive">case-insensitive</a >. The convention of writing
@@ -11,7 +10,7 @@ transfer</a> and
11
10
<a href="#Operations_on_external_files" class="wikilink"
12
11
title="Operations on external files">Operations on external files</a >).
13
12
14
- ### Basics
13
+ ## Basics
15
14
16
15
The basic component of the Fortran language is its * character set* . Its
17
16
members are
64
63
65
64
a leading ` & ` on the continued line is also required.
66
65
67
- ### Intrinsic data types
66
+ ## Intrinsic data types
68
67
69
68
Fortran has five * intrinsic data types* : ` INTEGER ` , ` REAL ` , ` COMPLEX ` ,
70
69
` LOGICAL ` and ` CHARACTER ` . Each of those types can be additionally
@@ -81,9 +80,9 @@ corresponding form of *literal constant*. The numeric types `INTEGER`
81
80
and ` REAL ` can only be signed (there is no concept of sign for type
82
81
` COMPLEX ` ).
83
82
84
- #### Literal constants and kinds
83
+ ### Literal constants and kinds
85
84
86
- ##### INTEGER
85
+ #### INTEGER
87
86
88
87
Integer literal constants of the default kind take the form
89
88
@@ -137,7 +136,7 @@ constants"):
137
136
B'01010101' O'01234567' Z'10fa'
138
137
```
139
138
140
- ##### REAL
139
+ #### REAL
141
140
142
141
There are at least two real kindsthe default and one with greater
143
142
precision (this replaces
@@ -175,15 +174,15 @@ KIND(1.7_long) PRECISION(1.7_long) RANGE(1.7_long)
175
174
that give in turn the kind type value, the actual precision (here at
176
175
least 9), and the actual range (here at least 99).
177
176
178
- ##### COMPLEX
177
+ #### COMPLEX
179
178
180
179
` COMPLEX ` data type is built of two integer or real components:
181
180
182
181
``` f90
183
182
(1, 3.7_long)
184
183
```
185
184
186
- ##### LOGICAL
185
+ #### LOGICAL
187
186
188
187
There are only two basic values of logical constants: ` .TRUE. ` and
189
188
` .FALSE. ` . Here, there may also be different kinds. Logicals don't have
@@ -200,7 +199,7 @@ and the `KIND` function operates as expected:
200
199
KIND(.TRUE.)
201
200
```
202
201
203
- ##### CHARACTER
202
+ #### CHARACTER
204
203
205
204
The forms of literal constants for ` CHARACTER ` data type are
206
205
@@ -219,7 +218,7 @@ the `KIND` function:
219
218
KIND('ASCII')
220
219
```
221
220
222
- #### Number model and intrinsic functions
221
+ ### Number model and intrinsic functions
223
222
224
223
The numeric types are based on number models with associated inquiry
225
224
functions (whose values are independent of the values of their
@@ -238,7 +237,7 @@ important for portable numerical software:
238
237
| ` RANGE(X) ` | Decimal exponent range |
239
238
| ` TINY(X) ` | Smallest positive number (real) |
240
239
241
- ### Scalar variables
240
+ ## Scalar variables
242
241
243
242
Scalar <a href="Variable_ (programming)" class="wikilink"
244
243
title="variables">variables</a > corresponding to the five intrinsic
@@ -306,7 +305,7 @@ Finally, there is a set of intrinsic character functions, examples being
306
305
| ` REPEAT ` | ` SCAN ` (for one of a set) |
307
306
| ` TRIM ` | ` VERIFY ` (for all of a set) |
308
307
309
- ### Derived data types
308
+ ## Derived data types
310
309
311
310
For derived data types, the form of the type must be defined first:
312
311
@@ -369,7 +368,7 @@ t%a%x t%a%y t%b%x etc.
369
368
(Note that the ` % ` qualifier was chosen rather than dot (` . ` ) because of
370
369
potential ambiguity with operator notation, like ` .OR. ` ).
371
370
372
- ### Implicit and explicit typing
371
+ ## Implicit and explicit typing
373
372
374
373
Unless specified otherwise, all variables starting with letters I, J, K,
375
374
L, M and N are default ` INTEGER ` s, and all others are default ` REAL ` ;
@@ -392,7 +391,7 @@ IMPLICIT NONE
392
391
393
392
at the beginning of each program unit.
394
393
395
- ### Arrays
394
+ ## Arrays
396
395
397
396
Arrays are considered to be variables in their own right. Every array is
398
397
characterized by its
@@ -467,7 +466,7 @@ so that
467
466
468
467
is an array component of a scalar
469
468
470
- ### Data initialization
469
+ ## Data initialization
471
470
472
471
Variables can be given initial values as specified in a specification
473
472
statement:
@@ -503,7 +502,7 @@ causes local variables to retain their value after a procedure call and
503
502
then to initialize the variable to the saved value upon returning to the
504
503
procedure.
505
504
506
- #### PARAMETER attribute
505
+ ### PARAMETER attribute
507
506
508
507
A named constant can be specified directly by adding the ` PARAMETER `
509
508
attribute and the constant values to a type statement:
@@ -513,7 +512,7 @@ REAL, DIMENSION(3), PARAMETER :: field = (/ 0., 1., 2. /)
513
512
TYPE(triplet), PARAMETER :: t = triplet( (/ 0., 0., 0. /) )
514
513
```
515
514
516
- #### DATA statement
515
+ ### DATA statement
517
516
518
517
The ` DATA ` statement can be used for scalars and also for arrays and
519
518
variables of derived type. It is also the only way to initialise just
@@ -527,7 +526,7 @@ DATA array(1:64) / 64*0/
527
526
DATA i, j, k/ B'01010101', O'77', Z'ff'/
528
527
```
529
528
530
- #### Initialization expressions
529
+ ### Initialization expressions
531
530
532
531
The values used in ` DATA ` and ` PARAMETER ` statements, or with these
533
532
attributes, are constant expressions that may include references to:
@@ -542,7 +541,7 @@ INTEGER, PARAMETER :: long = SELECTED_REAL_KIND(12), &
542
541
array(3) = (/ 1, 2, 3 /)
543
542
```
544
543
545
- ### Specification expressions
544
+ ## Specification expressions
546
545
547
546
It is possible to specify details of variables using any non-constant,
548
547
scalar, integer expression that may also include inquiry function
0 commit comments