The GFORTRAN Compiler for FORTRAN90 code

**GFORTRAN**
is a directory of FORTRAN90 programs which
illustrate the use of the Gnu GFORTRAN compiler.

This web page investigates the relationship between GFORTRAN and FORTRAN90, especially questions involving the implementation of the various arithmetic precisions.

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

**GFORTRAN** examples are available in
a FORTRAN77 version and
a FORTRAN90 version.

C, C programs which illustrate features of the C language.

CPP, C++ programs which illustrate features of the C++ language.

F77, FORTRAN77 programs which illustrate features of the FORTRAN77 language.

F90, FORTRAN90 programs which illustrate features of the FORTRAN90 language.

F90_INTRINSICS, FORTRAN90 programs which illustrate the use of FORTRAN90 intrinsic functions.

G95_INTRINSICS, FORTRAN90 programs which illustrate the use of intrinsic functions peculiar to the G95 FORTRAN compiler.

GFORTRAN_INTRINSICS, a FORTRAN90 program which demonstrates the use of some of the intrinsic functions included with the GFORTRAN compiler.

GFORTRAN_QUADMATH, a FORTRAN90 program which illustrates the use of quadruple precision real arithmetic provided on some systems by the Gnu GFORTRAN compiler.

MATLAB, MATLAB programs which illustrate features of MATLAB.

MIXED, FORTRAN90 programs which show how to write a program partly in FORTRAN90 and partly in some other language.

MPI, FORTRAN90 programs which show how to set up parallel programs in FORTRAN90.

REAL_PRECISION, 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;

TIMER, FORTRAN90 programs which show how to compute elapsed CPU time in FORTRAN90.

TIMESTAMP, a FORTRAN90 library which shows how to get a timestamp in FORTRAN90.

- The Gnu FORTRAN page, http://www.gnu.org/software/fortran/fortran.html .
- The GFORTRAN Manual, http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gfortran.pdf.

**BIG_INTS** shows how you can use the new KIND qualifier to create,
for example, really big integers.

- big_ints.f90, the source code;
- big_ints_output.txt, the output file;

**BINARY_TREE** shows how a binary tree can be defined and manipulated,
using the FORTRAN90 "POINTER" type.

- binary_tree.f90, the source code;
- binary_tree_output.txt, the output file;

**BOUNDS** 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!

- bounds.f90, the source code;
- bounds_output.txt, the output file;

**CHAR_ALLOC** 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.

- char_alloc.f90, the source code;
- char_alloc_output.txt, the output file;

**CONSTANT_TYPE** shows that FORTRAN90 constants have a type, and that
if you don't specify it for real values, the default will be
single precision.

- constant_type.f90, the source code;
- constant_type_output.txt, the output file;

**DIGITS** investigates how many digits you can usefully specify
for data.

- digits.f90, the source code;
- digits_output.txt, the output file;

**DIVISION** shows that, if you're expecting double precision accuracy,
you need to specify your constants carefully, as double precision
values.

- division.f90, the source code;
- division_output.txt, the output file;

**DOUBLE_COMPLEX** shows how you can use the new KIND qualifier to
create and use variables of type "double precision complex".

- double_complex.f90, the source code;
- double_complex_output.txt, the output file;

**EXPONENT_FORMAT_OVERFLOW** shows that (at least some) FORTRAN compilers
**cannot properly print real numbers with exponents of magnitude greater than 99**.
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!

- exponent_format_overflow.f90, the source code;
- exponent_format_overflow_output.txt, the output file;

**HELLO** is just a "Hello, world!" program.

- hello.f90, the source code;
- hello_output.txt, the output file;

**LINKED_LIST** shows how a linked list can be defined, using the FORTRAN90
"POINTER" type.

- linked_list.f90, the source code;
- linked_list_output.txt, the output file;

**MATRIX_FUNCTION_TEST** shows how you may now define a function whose
return value is a matrix.

- matrix_function_test.f90, the source code;
- matrix_function_test_output.txt, the output file;

**MAXMIN_TEST** 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.

- maxmin_test.f90, the source code;
- maxmin_test_output.txt, the output file;

**MXM** multiplies two matrices using the MATMUL intrinsic.

- mxm.f90, the source code;
- mxm_output.txt, the output file;

**RANDOM_PRB** demonstrates the random number routines.

- random_prb.f90, the source code;
- random_prb_output.txt, the output file;

**RANDOM_TEST** tests the random number routines.

- random_test.f90, the source code;
- random_test_output.txt, the output file;

**READ_VARIABLE_RECORDS** 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.

- read_variable_records.f90, the source code;
- read_variable_records.txt, the input file to be read.
- read_variable_records_output.txt, the output file;

**RECURSIVE_FUN_TEST** shows how you can use recursion in a function
definition.

- recursive_fun_test.f90, the source code;
- recursive_fun_test_output.txt, the output file;

**RECURSIVE_SUB_TEST** shows how you can use recursion in a
subroutine definition.

- recursive_sub_test.f90, the source code;
- recursive_sub_test_output.txt, the output file;

**SGE_MOD** 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.

- sge_mod.f90, the source code;
- sge_mod_prb.f90, a sample calling code;
- sge_mod_prb_output.txt, the output file;

**SORT_TEST** bubble-sorts a real vector.

- sort_test.f90, the source code;
- sort_test_output.txt, the output file;

**WHERE_TEST** demonstrates the WHERE statement.

- where_test.f90, the source code;
- where_test_output.txt, the output file;

You can go up one level to the FORTRAN90 source codes.