University Arms and Title

Faculty of Mathematics Fortran Course


Fortran Programming Example Files

1/   Downloading the Example Routines and Data Files :

        The Source and Data Files to Compile and run the example Fortran Programs and Routines presented over the course are listed below, and in Appendix 2 of the course notes. The Files may be copied by using the links in the "File to Download" column. All Routines are coded in Fortran 77 unless otherwise indicated. For a description of the processing refer to the comments at the beginning of the Program Source Files '*.for' or '*.f90'.

Fortran Routine Source Files, Program Binaries and Data :



  Type of File   Description   File to Download
Spacer
  Fortran
  Source Code
  Pentagonal Numbers, Fortran 77   clpent.for
  Pentagonal Numbers, Fortran 90   clpent.f90
  Pentagonal Numbers, with Subroutine   clptsb.for
  Subroutine computing Pentagonal Number   sbpent.for
  Pseudo Random Number (return) Function   fnduwh.for
  Pseudo Random Number Subroutine   rnduwh.for
  Pseudo Random Number Display Program   ttrand.for
  Interactive Version of Example Program   splref.for
  Course Example Program   splrfb.for
Spacer
  Linux
  Binary
  Executable
  Compiled Linux Binary for 'clpent.for'   clpent.bin
  Compiled Linux Binary for 'clptsb.for'   clptsb.bin
  Compiled Linux Binary for 'splref.for'   splref.bin
  Compiled Linux Binary for 'splrfb.for'   splrfb.bin
  Compiled Linux Binary for 'ttrand.for'   ttrand.bin
Spacer
  Sample Data
  to run the
  Example Program 
  Data Parameters for 'splrfb.bin'   SPLCDT
  Sample Input Data for example Program   SPLRIN
  Sample Output Data off Example Program   SPLROU

2/   Compiling and Running the Example Routines :

        To run the Example Programs, download the Source Files with 'for' and 'f90' Extensions and then Compile them, or pick the ready made Binary 'bin' Files, which should run directly on a recent version of Linux. In addition, 'splref.bin' and 'splrfb.bin' will need the Data File 'SPLRIN' and in the case of 'splrfb.bin', the Control Parameters File 'SPLCDT' too.

To compile the Source Files, on a Unix computer or PC with Linux, either the GNU 'gfortran' or Intel 'ifort' Compilers should work. The latter requires a licence. 'gfortran' does not, and comes as part of recent Linux Distributions. Both accept Fortran 77 'for', or Fortran 90 'f90' Source Files.

For example, using the 'clpent' Program :

          gfortran -o clpent.bin clpent.for

          ifort    -o clpent.bin clpent.for

produce a local Version of the Binary 'clpent.bin'.

When a Subroutines or Functions are involved, with the Source Code in separate Files, the Main Program File and all Subprogram Files should be jointly submitted to the Compiler. For example :

          gfortran -o clptsb.bin clptsb.for sbpent.for

writes a Binary for the Program 'clptsb' and Subroutine 'sbpent'.

On some older Linux systems, the GNU Fortran compiler may be 'g77', with only partial support for Fortran 90, or any later standards.

Invoke the Binary on the Command Line, and respond to the Prompts.

The Interactive Version of the Course Example Program, 'splref.bin' will successfully run with replies  'SPLRIN',  'SPLROU',  '12',  '64', and '1' or '2'. The first two and last may be defaulted. The Values correspond to those in the 'SPLCDT' Control File for 'splrfb.bin'.




© Faculty of Mathematics, University of Cambridge.