1 |
C $Header$ |
C $Header$ |
2 |
C $Name$ |
C $Name$ |
3 |
|
|
4 |
|
CBOI |
5 |
|
C !TITLE: pkg/generic\_advdiff |
6 |
|
C !AUTHORS: adcroft@mit.edu |
7 |
|
C !INTRODUCTION: |
8 |
|
C \section{Generica Advection Diffusion Package} |
9 |
|
C |
10 |
|
C Package "generic\_advdiff" provides a common set of routines for calculating |
11 |
|
C advective/diffusive fluxes for tracers (cell centered quantities on a C-grid). |
12 |
|
C |
13 |
|
C Many different advection schemes are available: the standard centered |
14 |
|
C second order, centered fourth order and upwind biased third order schemes |
15 |
|
C are known as linear methods and require some stable time-stepping method |
16 |
|
C such as Adams-Bashforth. Alternatives such as flux-limited schemes are |
17 |
|
C stable in the forward sense and are best combined with the multi-dimensional |
18 |
|
C method provided in gad\_advection. |
19 |
|
C |
20 |
|
C There are two high-level routines: |
21 |
|
C \begin{itemize} |
22 |
|
C \item{GAD\_CALC\_RHS} calculates all fluxes at time level "n" and is used |
23 |
|
C for the standard linear schemes. This must be used in conjuction with |
24 |
|
C Adams-Bashforth time-stepping. Diffusive and parameterized fluxes are |
25 |
|
C always calculated here. |
26 |
|
C \item{GAD\_ADVECTION} calculates just the advective fluxes using the |
27 |
|
C non-linear schemes and can not be used in conjuction with Adams-Bashforth |
28 |
|
C time-stepping. |
29 |
|
C \end{itemize} |
30 |
|
CEOI |
31 |
|
|
32 |
#include "GAD_OPTIONS.h" |
#include "GAD_OPTIONS.h" |
33 |
|
|
34 |
|
CBOP |
35 |
|
C !ROUTINE: GAD_ADVECTION |
36 |
|
|
37 |
|
C !INTERFACE: ========================================================== |
38 |
SUBROUTINE GAD_ADVECTION(bi,bj,advectionScheme,tracerIdentity, |
SUBROUTINE GAD_ADVECTION(bi,bj,advectionScheme,tracerIdentity, |
39 |
U Tracer,Gtracer, |
U Tracer,Gtracer, |
40 |
I myTime,myIter,myThid) |
I myTime,myIter,myThid) |
|
C /==========================================================\ |
|
|
C | SUBROUTINE GAD_ADVECTION | |
|
|
C | o Solves the pure advection tracer equation. | |
|
|
C |==========================================================| |
|
|
C \==========================================================/ |
|
|
IMPLICIT NONE |
|
41 |
|
|
42 |
C == Global variables === |
C !DESCRIPTION: |
43 |
|
C Calculates the tendancy of a tracer due to advection. |
44 |
|
C It uses the multi-dimensional method given in \ref{sect:multiDimAdvection} |
45 |
|
C and can only be used for the non-linear advection schemes such as the |
46 |
|
C direct-space-time method and flux-limiters. |
47 |
|
C |
48 |
|
C The algorithm is as follows: |
49 |
|
C \begin{itemize} |
50 |
|
C \item{$\theta^{(n+1/3)} = \theta^{(n)} |
51 |
|
C - \Delta t \partial_x (u\theta) + \theta \partial_x u$} |
52 |
|
C \item{$\theta^{(n+2/3)} = \theta^{(n+1/3)} |
53 |
|
C - \Delta t \partial_y (v\theta) + \theta \partial_y v$} |
54 |
|
C \item{$\theta^{(n+3/3)} = \theta^{(n+2/3)} |
55 |
|
C - \Delta t \partial_r (w\theta) + \theta \partial_r w$} |
56 |
|
C \item{$G_\theta = ( \theta^{(n+3/3)} - \theta^{(n)} )/\Delta t$} |
57 |
|
C \end{itemize} |
58 |
|
C |
59 |
|
C The tendancy (output) is over-written by this routine. |
60 |
|
|
61 |
|
C !USES: =============================================================== |
62 |
|
IMPLICIT NONE |
63 |
#include "SIZE.h" |
#include "SIZE.h" |
64 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
65 |
#include "PARAMS.h" |
#include "PARAMS.h" |
67 |
#include "GRID.h" |
#include "GRID.h" |
68 |
#include "GAD.h" |
#include "GAD.h" |
69 |
|
|
70 |
C == Routine arguments == |
C !INPUT PARAMETERS: =================================================== |
71 |
|
C bi,bj :: tile indices |
72 |
|
C advectionScheme :: advection scheme to use |
73 |
|
C tracerIdentity :: identifier for the tracer (required only for OBCS) |
74 |
|
C Tracer :: tracer field |
75 |
|
C myTime :: current time |
76 |
|
C myIter :: iteration number |
77 |
|
C myThid :: thread number |
78 |
INTEGER bi,bj |
INTEGER bi,bj |
79 |
INTEGER advectionScheme |
INTEGER advectionScheme |
80 |
INTEGER tracerIdentity |
INTEGER tracerIdentity |
|
_RL Tracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
|
81 |
_RL Gtracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
_RL Gtracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
82 |
_RL myTime |
_RL myTime |
83 |
INTEGER myIter |
INTEGER myIter |
84 |
INTEGER myThid |
INTEGER myThid |
85 |
|
|
86 |
C == Local variables |
C !OUTPUT PARAMETERS: ================================================== |
87 |
|
C gTracer :: tendancy array |
88 |
|
_RL Tracer(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
89 |
|
|
90 |
|
C !LOCAL VARIABLES: ==================================================== |
91 |
|
C maskUp :: 2-D array for mask at W points |
92 |
|
C iMin,iMax,jMin,jMax :: loop range for called routines |
93 |
|
C i,j,k :: loop indices |
94 |
|
C kup :: index into 2 1/2D array, toggles between 1 and 2 |
95 |
|
C kdown :: index into 2 1/2D array, toggles between 2 and 1 |
96 |
|
C kp1 :: =k+1 for k<Nr, =Nr for k=Nr |
97 |
|
C xA,yA :: areas of X and Y face of tracer cells |
98 |
|
C uTrans,vTrans,rTrans :: 2-D arrays of volume transports at U,V and W points |
99 |
|
C af :: 2-D array for horizontal advective flux |
100 |
|
C fVerT :: 2 1/2D arrays for vertical advective flux |
101 |
|
C localTij :: 2-D array used as temporary local copy of tracer fld |
102 |
|
C localTijk :: 3-D array used as temporary local copy of tracer fld |
103 |
|
C kp1Msk :: flag (0,1) to act as over-riding mask for W levels |
104 |
|
C calc_fluxes_X :: logical to indicate to calculate fluxes in X dir |
105 |
|
C calc_fluxes_Y :: logical to indicate to calculate fluxes in Y dir |
106 |
|
C nipass :: number of passes to make in multi-dimensional method |
107 |
|
C ipass :: number of the current pass being made |
108 |
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
_RS maskUp (1-OLx:sNx+OLx,1-OLy:sNy+OLy) |
109 |
INTEGER iMin,iMax,jMin,jMax |
INTEGER iMin,iMax,jMin,jMax |
110 |
INTEGER i,j,k,kup,kDown,kp1 |
INTEGER i,j,k,kup,kDown,kp1 |
120 |
_RL kp1Msk |
_RL kp1Msk |
121 |
LOGICAL calc_fluxes_X,calc_fluxes_Y |
LOGICAL calc_fluxes_X,calc_fluxes_Y |
122 |
INTEGER nipass,ipass |
INTEGER nipass,ipass |
123 |
|
CEOP |
124 |
|
|
125 |
C-- Set up work arrays with valid (i.e. not NaN) values |
C-- Set up work arrays with valid (i.e. not NaN) values |
126 |
C These inital values do not alter the numerical results. They |
C These inital values do not alter the numerical results. They |