SPMODEL: A Series of Hierarchical Spectral Models for GFD
| << Prev | Index| Next >> |

"SPMOEL library" (spml) ^{[4]}
is a library which provides basic
functions for numerical fluid dynamics calculations with the spectral method.
These functions are provided by wrapping the subroutines of
ISPACK^{[2]}, which
is an existing FORTRAN77 library for spectral calculations, and by the use of
the Fortran90 array-handling features described
in Section 2.

As an example of the subprograms of the SPMODEL library, subroutines and functions for a one-dimensional domain with cyclic boundaries are listed below.

Initialization: setups of the number of grid points, the truncation wavenumber, and the computational domain.

subroutine ae_initial(im,km,xmin,xmax)

Forward and backward spectral transformations.

function g_e(e) real(8), dimension(0:im-1) :: g_e real(8), dimension(-km:km), intent(in) :: e function e_g(g) real(8), dimension(-km:km) :: e_g real(8), dimension(0:im-1), intent(in) :: g

Differentiation: spectral transform of spatial differentiation (multiplying spectral transformed function by wavenumbers).

function e_Dx_e(e) real(8), dimension(-km:km) :: e_Dx_e real(8), dimension(-km:km), intent(in) :: e

Integration: spatial integration and spatial average

function Int_g(g), function Avr_g(g) real(8), dimension(0:im-1), intent(in) :: g real(8) :: Int_g, Avr_g

All functions of SPMODEL library are named systematically in the fashion below:

(output data space identifier)_(action)_(input data space identifier)

By indicating the characters of function in the function name as the action of the function and the spaces, like real or spectral, on which the input and the output data of the function are defined, we expect that, in exchange for the lengthy names, the procedure of functional operation will be in a more recognizable form, which will consequently reduce the danger of programming errors.

Conforming to the naming convention of functions, we recommend that the grid and the spectral data arrays be named in the following manner,

(data space identifier)_(variable name).

By the use of the systematic naming style of functions and variables on which these functions operate, we can arrange the program code in a form resembling the mathematical formula often used in the tensor calculus, as described below.

As an example, let us show the functions of the module for one-dimensional domain with cyclic boundaries. As listed above, the function names of spectral transformation and differentiation are given as:

g_e(e_Data) ! conversion from spectral to grid data e_g(g_Data) ! conversion from grid to spectral data e_Dx_e(e_Data) ! differentiation on the x coordinate ! (multiplication of wavenumber)

Prefixes "e_" and "g_" of the functions are the data space identifiers which indicate that the outputs of the functions are the data arrays defined on a spectral and a real (grid) space, respectively. Suffixes "_e" and "_g" of the functions are the data space identifiers which indicate that the inputs of the functions are the data arrays defined on a spectral and a real (grid) space, respectively. The data arrays also conform to the same naming rule; e_Data and g_Data indicate that they are the data arrays defined on a spectral and real (grid) space, respectively.

By using these functions, differentiation of a real data array "g_Data1" with respect to x with spectral transformation and storage into a real data array "g_Data2" can be written as follows, in one statement.

g_Data2 = g_e(e_Dx_e(e_g(g_Data1)))

Note that the prefixes and the suffixes appear in pairs in a manner similar to the contraction convention of the tensor calculus.

SPMODEL: A Series of Hierarchical Spectral Models for GFD
| << Prev | Index| Next >> |