next up previous
Next: downwell.F Up: The Proudman Oceanographic Laboratory Previous: diagnoseT.F

Subsections


diffuse.F


subroutine diffuseb

Description

This subroutine performs vertical diffusion of a scalar by a fully implicit scheme, using vertical diffusivities ak. It calls the routine tridag to solve the resulting tridiagonal system of equations.

Numerical Equations

These are based on the diffusion equation in one dimension
$\partial b/\partial t = \partial (D\partial b/\partial z)/\partial z$,
where $D(z)$ is the diffusion coefficient.

If $D$ and $\Delta z$ are constant (this example is given for simplicity: in practice they are not and there is a straightforward modification), the fully implicit scheme is
$b(k,t+\Delta t) - b(k,t)=(\Delta t.D/\Delta z^2)(b(k+1,t+\Delta t)-
2b(k,t+\Delta t)+b(k-1,t+\Delta t))$
This leads to a tridiagonal system of equations, when supplemented by boundary conditions (for example zero diffusion) at the surface and sea bed.

Subroutine Arguments

ba value of scalar variable, returns new diffused value

Local variables

i,j,k, grid indices
hsq square of depth $h$
acr,bcr,ccr,rcr,ucr matrix coefficients

Logical units

Only used in debugging option.

Order of Things

  1. Set tridiagonal matrix coefficients for no diffusion at surface and bed
  2. Set `old' values of scalar at external points
  3. Set matrix coefficients in interior
  4. Call tridag to solve equations
  5. Return diffused value of scalar

Calls

tridag

Called By

baroc

Known Issues

Implicit scheme unconditionally stable but may be inaccurate for some scales.


subroutine diffuseu

Description

This subroutine performs vertical diffusion of velocity by a fully implicit scheme, using vertical eddy viscosity aa. It calls the routine tridag to solve the resulting tridiagonal system of equations.

Numerical Equations

These are based on the diffusion equation in one dimension
$\partial u/\partial t = \partial (D\partial u/\partial z)/\partial z$,
where $D(z)$ is the eddy viscosity.

If $D$ and $\Delta z$ are constant (this example is given for simplicity: in practice they are not and there is a straightforward modification), the fully implicit scheme is
$u(k,t+\Delta t) - u(k,t)=(\Delta t.D/\Delta z^2)(u(k+1,t+\Delta t)-
2u(k,t+\Delta t)+u(k-1,t+\Delta t))$
This leads to a tridiagonal system of equations, when supplemented by boundary conditions, for example wind stress at the surface and friction at the sea bed. For stability, there is a semi-implicit form of quadratic bottom friction, proportional to the `new' value of velocity multiplied by the `old' total speed.

Subroutine Arguments

ua value of velocity variable, returns new diffused value
fsa surface stress

Local variables

i,j,k, grid indices
hsq square of depth $h$
acr,bcr,ccr,rcr,ucr matrix coefficients

Logical units

Only used in debugging option.

Order of Things

  1. Set tridiagonal matrix coefficients for boundary conditions at surface and bed
  2. Set `old' values of velocity at external points
  3. Set matrix coefficients in interior
  4. Call tridag to solve equations
  5. Return diffused value of velocity

Calls

tridag

Called By

baroc

Known Issues

Implicit scheme unconditionally stable but may be inaccurate for some scales.


subroutine diffuseb_n

Description

This subroutine performs vertical diffusion of a number of scalars simultaneously by a fully implicit scheme, using vertical diffusivities ak. It calls the routine tridag_n to solve the resulting tridiagonal system of equations. The simultaneous calculation saves many repeated calls to diffuseb.

Numerical Equations

These are based on the diffusion equation in one dimension
$\partial b/\partial t = \partial (D\partial b/\partial z)/\partial z$,
where $D(z)$ is the diffusion coefficient.

If $D$ and $\Delta z$ are constant (this example is given for simplicity: in practice they are not and there is a straightforward modification), the fully implicit scheme is
$b(k,t+\Delta t) - b(k,t)=(\Delta t.D/\Delta z^2)(b(k+1,t+\Delta t)-
2b(k,t+\Delta t)+b(k-1,t+\Delta t))$
This leads to a tridiagonal system of equations, when supplemented by boundary conditions (for example zero diffusion) at the surface and sea bed.

Subroutine Arguments

ba value of scalar variable, returns new diffused value
nv number of scalars to be diffused

Local variables

i,j,k, grid indices
iv counter for scalars
hsq square of depth $h$
acr,bcr,ccr,rcr,ucr matrix coefficients

Logical units

Only used in debugging option.

Order of Things

  1. Set tridiagonal matrix coefficients for no diffusion at surface and bed
  2. Set `old' values of scalars at external points
  3. Set matrix coefficients in interior
  4. Call tridag_n to solve equations
  5. Return diffused value of scalars

Calls

tridag_n

Called By

Known Issues

Implicit scheme unconditionally stable but may be inaccurate for some scales.


subroutine tridag

Description

This subroutine solves a tridiagonal system of equations. See ``Numerical Recipes in Fortran'', Press W.H., Teukolsky S.A., Vettering W.T. and Flannery B.P., Cambridge University Press, 2nd Ed. 1992, p.42.

They point out that as there is no pivoting tridag can fail, though this rarely happens. Failure lines have been commented out.

Numerical Equations

The tridiagonal system with coefficients $a,b,c$ along the diagonal, the vector $r$ as the right hand side, solved for the vector $u$.

Subroutine Arguments

a,b,c coefficients along the diagonal
r values of right hand side
u vector to be solved for
nt number of equations

Local variables

j counter
bet,gam workspace

Logical units

none

Calls

none

Called By

diffuseb, diffuseu

Known Issues

See comment about failure in description above.


subroutine tridag_n

Description

This subroutine solves a tridiagonal system of equations, but unlike tridag there are multiple right hand sides. This saves repeated calls to tridag.

See the description of tridag for more information.

Numerical Equations

As for tridag, with multiple right hand sides.

Subroutine Arguments

a,b,c coefficients along the diagonal
r values of right hand side
u vector to be solved for
nt number of equations
nrhs number of right hand sides

Local variables

irhs,j counters
bet,gam workspace

Logical units

none

Calls

none

Called By

htmlrefdiffuseb_ndiffuseb_n

Known Issues

See comment about failure in description of tridag.


next up previous
Next: downwell.F Up: The Proudman Oceanographic Laboratory Previous: diagnoseT.F
The AMMP Project 2005-04-20