74
4 Long Waves in a Channel
Zero-gradient boundary conditions are used to eliminate lateral diffusive flu es
of a property C. These conditions read:
C
n
0 = C
n
1
C
n
nx+1 = C
n
nx
Some applications justify the use of so-called cyclic boundary conditions that for
a property C read:
C
n
0 = C
n
nx
C
n
nx+1 = C
n
1
Here, both ends of the model domain are connected to form a channel of infinit
length.
4.2.13 Modular FORTRAN Scripting
It makes sense to split longer FORTRAN codes into several f les containing different
parts of the code containing the main code and separate modules. An example of a
main code and two modules is given in the following. In this example, the main code
is linked with two external modules via the command “USE”.
The f rst module contains declarations of parameters and variables. The second
module includes two subroutines. The statement CONTAINS is used if a module
contains more than one subroutine or function. The f rst subroutine allocates initial
values to parameters and the second one does a simple calculation. Subroutines are
called with a CALL statement. The main code is given by:
PROGRAM main
USE decla
USE calcu
CALL init
CALL squaresum
z = z+c ! fina calculation
write(6,*)“x = ”,x ! print result on screen
END PROGRAM main
The “decla” module reads:
MODULE decla
REAL, PARAMETER :: c = 1.0
REAL :: x,y,z
Précédent

- 87/185

Suivant