GFORTRAN
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.

Licensing:

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

Languages:

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

Related Data and Programs:

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.

Reference:

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

Examples and Tests:

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

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

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!

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.

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.

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

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

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

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!

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

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

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

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.

MXM multiplies two matrices using the MATMUL intrinsic.

RANDOM_PRB demonstrates the random number routines.

RANDOM_TEST tests the random number routines.

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.

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

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

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.

SORT_TEST bubble-sorts a real vector.

WHERE_TEST demonstrates the WHERE statement.

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


Last revised on 17 January 2011.