next up previous contents
Next: main program Up: The finite difference program Previous: Dimensionless equations   Contents

Program structure

The finite difference program has been implemented in FORTRAN 77. First, because there are highly optimized compilers and mathematics libraries for the ``Alpha processors'' in the workstations, which have been used for the calculations. Secondly, compatibility with the finite element package, which has been implemented in FORTRAN 77, saved development time, because it was not necessary to rewrite the time integration algorithm. Only the interface of the subroutine had to be adapted.

Since there is no standard method in FORTRAN 77 to allocate memory at run time, all array sizes have to be defined at compile time. This makes the maintenance of the source code difficult and leads to inconsistencies easily. In order to avoid these pitfalls, the C preprocessor is used to substitute the desired array sizes for symbolic constants just before compilation. This method is also used for file names, file handles, output strings, and, most importantly, simulation parameters. All integer simulation parameters, like the maximum number of time steps, the frequency of log file entries, the choice of the time integration algorithm, etc., are stored in a single array of type integer. In the same way all floating point parameters, like the material parameters, the external field, and the time step size, are stored in a single array of type double precision. However, they are not accessed with the array name and an index, but with symbolic names, which more easily identify their content. A precompiler directive in each source code file makes the precompiler read a special header file, in which the translation of the symbolic names into proper Fortran variables is defined.

In figure [*] the head of the function, which reads the simulation parameters from files into the corresponding Fortran data structures, is given. The parameters iparm and dparm are arrays of integer and double precision parameters. Their entries are defined in the header file, of which a few lines are given in figure [*].

Figure: Function header with precompiler directive

#include "parm.h"
      integer function init_par(
     &                   liparm,iparm,ldparm,dparm,
     &                   eaxis,m,nn)

Figure: Header file with precompiler directives
\begin{figure}\centering\tt\begin{tabular}{ll}
\hline
\char93 define nx & 1 \\
...
...rm(11) \\
\char93 define dz & dparm(12) \\
\hline
\end{tabular}\rm\end{figure}

Figure [*] shows a flow chart of the finite difference program. Its main parts are described in the following.

Figure: Flow chart of the finite difference program
\includegraphics[scale=1]{fig/flowfd.eps}


next up previous contents
Next: main program Up: The finite difference program Previous: Dimensionless equations   Contents
Werner Scholz 2000-05-16