forked from johannesgerer/jburkardt-f
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gfortran.html
618 lines (562 loc) · 17.6 KB
/
gfortran.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
<html>
<head>
<title>
GFORTRAN - The GFORTRAN Compiler for FORTRAN90 code
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
GFORTRAN <br> The GFORTRAN Compiler for FORTRAN90 code
</h1>
<hr>
<p>
<b>GFORTRAN</b>
is a directory of FORTRAN90 programs which
illustrate the use of the Gnu GFORTRAN compiler.
</p>
<p>
This web page investigates the relationship between <b>GFORTRAN</b>
and FORTRAN90, especially questions involving the implementation of
the various arithmetic precisions.
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this web page
are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>GFORTRAN</b> examples are available in
<a href = "../../f77_src/gfortran/gfortran.html">a FORTRAN77 version</a> and
<a href = "../../f_src/gfortran/gfortran.html">a FORTRAN90 version</a>.
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../c_src/c/c.html">
C</a>,
C programs which
illustrate features of the C language.
</p>
<p>
<a href = "../../cpp_src/cpp/cpp.html">
CPP</a>,
C++ programs which
illustrate features of the C++ language.
</p>
<p>
<a href = "../../f77_src/f77/f77.html">
F77</a>,
FORTRAN77 programs which
illustrate features of the FORTRAN77 language.
</p>
<p>
<a href = "../../f_src/f90/f90.html">
F90</a>,
FORTRAN90 programs which
illustrate features of the FORTRAN90 language.
</p>
<p>
<a href = "../../f_src/f90_intrinsics/f90_intrinsics.html">
F90_INTRINSICS</a>,
FORTRAN90 programs which
illustrate the use of FORTRAN90 intrinsic functions.
</p>
<p>
<a href = "../../f_src/g95_intrinsics/g95_intrinsics.html">
G95_INTRINSICS</a>,
FORTRAN90 programs which
illustrate the use of intrinsic functions peculiar
to the G95 FORTRAN compiler.
</p>
<p>
<a href = "../../f_src/gfortran_intrinsics/gfortran_intrinsics.html">
GFORTRAN_INTRINSICS</a>,
a FORTRAN90 program which
demonstrates the use of some of the intrinsic functions
included with the GFORTRAN compiler.
</p>
<p>
<a href = "../../f_src/gfortran_quadmath/gfortran_quadmath.html">
GFORTRAN_QUADMATH</a>,
a FORTRAN90 program which
illustrates the use of quadruple precision real arithmetic
provided on some systems by the Gnu GFORTRAN compiler.
</p>
<p>
<a href = "../../m_src/matlab/matlab.html">
MATLAB</a>,
MATLAB programs which
illustrate features of MATLAB.
</p>
<p>
<a href = "../../f_src/mixed/mixed.html">
MIXED</a>,
FORTRAN90 programs which
show how to write a program partly in FORTRAN90
and partly in some other language.
</p>
<p>
<a href = "../../f_src/mpi/mpi.html">
MPI</a>,
FORTRAN90 programs which
show how to set up parallel programs in FORTRAN90.
</p>
<p>
<a href = "../../f_src/real_precision/real_precision.html">
REAL_PRECISION</a>,
FORTRAN90 programs which
investigate the somewhat awkward methods for requesting
a real data type with given precision. This is the preferred
method for requesting double or quadruple precision arithmetic;
</p>
<p>
<a href = "../../f_src/timer/timer.html">
TIMER</a>,
FORTRAN90 programs which
show how to compute elapsed CPU time in FORTRAN90.
</p>
<p>
<a href = "../../f_src/timestamp/timestamp.html">
TIMESTAMP</a>,
a FORTRAN90 library which
shows how to get a timestamp in FORTRAN90.
</p>
<h3 align = "center">
Reference:
</h3>
<p>
<ol>
<li>
The Gnu FORTRAN page,
<a href = "http://www.gnu.org/software/fortran/fortran.html">
http://www.gnu.org/software/fortran/fortran.html </a>.
</li>
<li>
The GFORTRAN Manual,
<a href = "http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gfortran.pdf">
http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gfortran.pdf</a>.
</li>
</ol>
</p>
<h3 align = "center">
Examples and Tests:
</h3>
<p>
<b>BIG_INTS</b> shows how you can use the new KIND qualifier to create,
for example, really big integers.
<ul>
<li>
<a href = "big_ints.f90">big_ints.f90</a>, the source code;
</li>
<li>
<a href = "big_ints.sh">big_ints.sh</a>, commands that
compile and run the source code with the F90 compiler;
</li>
<li>
<a href = "big_ints_output.txt">big_ints_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>BINARY_TREE</b> shows how a binary tree can be defined and manipulated,
using the FORTRAN90 "POINTER" type.
<ul>
<li>
<a href = "binary_tree.f90">binary_tree.f90</a>, the source code;
</li>
<li>
<a href = "binary_tree.sh">binary_tree.sh</a>, commands that
compile and run the source code with the F90 compiler;
</li>
<li>
<a href = "binary_tree_output.txt">binary_tree_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>BOUNDS</b> shows GFORTRAN can help you catch illegal array references.
You need to compile with the "-fbounds-check" switch, and your program needs
to correctly declare the dimensions of your arrays. You can't declare an
array to be of size (*) or size (1), or allocate it as (10) in the calling
routine and then declare it to be of size (20) in a routine to which it
is passed!
<ul>
<li>
<a href = "bounds.f90">bounds.f90</a>, the source code;
</li>
<li>
<a href = "bounds.sh">bounds.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "bounds_output.txt">bounds_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>CHAR_ALLOC</b> shows that in FORTRAN90 it is possible to declare
an allocatable array of characters, for which the dimension is not
specified in advance. Note, however, that the "length", that is,
the "LEN" parameter, must be specified explicitly. It is not possible
to make the "LEN" parameter "allocatable" until FORTRAN2003.
<ul>
<li>
<a href = "char_alloc.f90">char_alloc.f90</a>, the source code;
</li>
<li>
<a href = "char_alloc.sh">char_alloc.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "char_alloc_output.txt">char_alloc_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>CONSTANT_TYPE</b> shows that FORTRAN90 constants have a type, and that
if you don't specify it for real values, the default will be
single precision.
<ul>
<li>
<a href = "constant_type.f90">constant_type.f90</a>, the source code;
</li>
<li>
<a href = "constant_type.sh">constant_type.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "constant_type_output.txt">constant_type_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>DIGITS</b> investigates how many digits you can usefully specify
for data.
<ul>
<li>
<a href = "digits.f90">digits.f90</a>, the source code;
</li>
<li>
<a href = "digits.sh">digits.sh</a>, commands that
compile and run the source code with the F90 compiler;
</li>
<li>
<a href = "digits_output.txt">digits_output.txt</a>,
the output file;
</ul>
</p>
<p>
<b>DIVISION</b> shows that, if you're expecting double precision accuracy,
you need to specify your constants carefully, as double precision
values.
<ul>
<li>
<a href = "division.f90">division.f90</a>, the source code;
</li>
<li>
<a href = "division.sh">division.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "division_output.txt">division_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>DOUBLE_COMPLEX</b> shows how you can use the new KIND qualifier to
create and use variables of type "double precision complex".
<ul>
<li>
<a href = "double_complex.f90">double_complex.f90</a>, the source code;
</li>
<li>
<a href = "double_complex.sh">double_complex.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "double_complex_output.txt">double_complex_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>EXPONENT_FORMAT_OVERFLOW</b> shows that (at least some) FORTRAN compilers
<b>cannot properly print real numbers with exponents of magnitude greater than 99</b>.
This becomes an especially serious problem if you write a very large or very
small number out, and then read it back in, only to find that it has suddenly
entirely lost its exponent, and now has magnitude roughly 1!
<ul>
<li>
<a href = "exponent_format_overflow.f90">exponent_format_overflow.f90</a>,
the source code;
</li>
<li>
<a href = "exponent_format_overflow.sh">exponent_format_overflow.sh</a>, commands that
compile and run the source code with the F90 compiler;
</li>
<li>
<a href = "exponent_format_overflow_output.txt">exponent_format_overflow_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>HELLO</b> is just a "Hello, world!" program.
<ul>
<li>
<a href = "hello.f90">hello.f90</a>, the source code;
</li>
<li>
<a href = "hello.sh">hello.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "hello_output.txt">hello_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>LINKED_LIST</b> shows how a linked list can be defined, using the FORTRAN90
"POINTER" type.
<ul>
<li>
<a href = "linked_list.f90">linked_list.f90</a>, the source code;
</li>
<li>
<a href = "linked_list.sh">linked_list.sh</a>, commands that
compile and run the source code with the F90 compiler;
</li>
<li>
<a href = "linked_list_output.txt">linked_list_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>MATRIX_FUNCTION_TEST</b> shows how you may now define a function whose
return value is a matrix.
<ul>
<li>
<a href = "matrix_function_test.f90">matrix_function_test.f90</a>,
the source code;
</li>
<li>
<a href = "matrix_function_test.sh">matrix_function_test.sh</a>,
commands that compile and run the source code;
</li>
<li>
<a href = "matrix_function_test_output.txt">matrix_function_test_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>MAXMIN_TEST</b> shows the use of the very useful MAXVAL and MINVAL
operators for vectors and arrays, and the so-very-fussy and hence
maddeningly useless operators MAXLOC and MINLOC.
<ul>
<li>
<a href = "maxmin_test.f90">maxmin_test.f90</a>,
the source code;
</li>
<li>
<a href = "maxmin_test.sh">maxmin_test.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "maxmin_test_output.txt">maxmin_test_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>MXM</b> multiplies two matrices using the MATMUL intrinsic.
<ul>
<li>
<a href = "mxm.f90">mxm.f90</a>, the source code;
</li>
<li>
<a href = "mxm.sh">mxm.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "mxm_output.txt">mxm_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>RANDOM_PRB</b> demonstrates the random number routines.
<ul>
<li>
<a href = "random_prb.f90">random_prb.f90</a>, the source code;
</li>
<li>
<a href = "random_prb.sh">random_prb.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "random_prb_output.txt">random_prb_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>RANDOM_TEST</b> tests the random number routines.
<ul>
<li>
<a href = "random_test.f90">random_test.f90</a>, the source code;
</li>
<li>
<a href = "random_test.sh">random_test.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "random_test_output.txt">random_test_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>READ_VARIABLE_RECORDS</b> shows how to read lines of data when
you don't know how many items are on each line. We're assuming
that every item is in "I4" format, but the number of such items
variables from line to line.
<ul>
<li>
<a href = "read_variable_records.f90">read_variable_records.f90</a>,
the source code;
</li>
<li>
<a href = "read_variable_records.sh">read_variable_records.sh</a>,
commands that compile and run the source code;
</li>
<li>
<a href = "read_variable_records.txt">read_variable_records.txt</a>,
the input file to be read.
</li>
<li>
<a href = "read_variable_records_output.txt">read_variable_records_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>RECURSIVE_FUN_TEST</b> shows how you can use recursion in a function
definition.
<ul>
<li>
<a href = "recursive_fun_test.f90">recursive_fun_test.f90</a>,
the source code;
</li>
<li>
<a href = "recursive_fun_test.sh">recursive_fun_test.sh</a>,
commands that compile and run the source code;
</li>
<li>
<a href = "recursive_fun_test_output.txt">recursive_fun_test_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>RECURSIVE_SUB_TEST</b> shows how you can use recursion in a
subroutine definition.
<ul>
<li>
<a href = "recursive_sub_test.f90">recursive_sub_test.f90</a>,
the source code;
</li>
<li>
<a href = "recursive_sub_test.sh">recursive_sub_test.sh</a>,
commands that compile and run the source code;
</li>
<li>
<a href = "recursive_sub_test_output.txt">recursive_sub_test_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>SGE_MOD</b> tries to set up an interesting example of the use of
modules.
In this case, the idea is that a set of linear algebra routines
will share a module that stores the value of a matrix, its LU
factor and determinant, and also knows which of these items
have been computed. This hides a lot of information from the
user, and makes for simple calls.
<ul>
<li>
<a href = "sge_mod.f90">sge_mod.f90</a>, the source code;
</li>
<li>
<a href = "sge_mod_prb.f90">sge_mod_prb.f90</a>,
a sample calling code;
</li>
<li>
<a href = "sge_mod_prb.sh">sge_mod_prb.sh</a>, commands that
compile and run the source code and the calling code;
</li>
<li>
<a href = "sge_mod_prb_output.txt">sge_mod_prb_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>SORT_TEST</b> bubble-sorts a real vector.
<ul>
<li>
<a href = "sort_test.f90">sort_test.f90</a>, the source code;
</li>
<li>
<a href = "sort_test.sh">sort_test.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "sort_test_output.txt">sort_test_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
<b>WHERE_TEST</b> demonstrates the WHERE statement.
<ul>
<li>
<a href = "where_test.f90">where_test.f90</a>, the source code;
</li>
<li>
<a href = "where_test.sh">where_test.sh</a>, commands that
compile and run the source code;
</li>
<li>
<a href = "where_test_output.txt">where_test_output.txt</a>,
the output file;
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../f_src.html">
the FORTRAN90 source codes</a>.
</p>
<hr>
<i>
Last revised on 17 January 2011.
</i>
<!-- John Burkardt -->
</body>
</html>