forked from altMITgcm/MITgcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rbcs_add_tendency.F
139 lines (123 loc) · 3.8 KB
/
rbcs_add_tendency.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
C $Header: /u/gcmpack/MITgcm/pkg/rbcs/rbcs_add_tendency.F,v 1.10 2014/07/09 16:58:09 jmc Exp $
C $Name: $
#include "RBCS_OPTIONS.h"
CBOP
C !ROUTINE: RBCS_ADD_TENDENCY
C !INTERFACE: ==========================================================
SUBROUTINE RBCS_ADD_TENDENCY(
U gTendency,
I k, bi, bj, tracerNum,
I myTime, myIter, myThid )
C !DESCRIPTION:
C Add to tendency array the contribution from 3-D field relaxation
C !USES: ===============================================================
IMPLICIT NONE
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
c#include "GRID.h"
#include "DYNVARS.h"
#ifdef ALLOW_PTRACERS
#include "PTRACERS_SIZE.h"
#include "PTRACERS_FIELDS.h"
#endif
#include "RBCS_SIZE.h"
#include "RBCS_PARAMS.h"
#include "RBCS_FIELDS.h"
C !INPUT/OUTPUT PARAMETERS: ============================================
C gTendency :: the tendency array
C k :: vertical level index
C bi,bj :: tile indices
C tracerNum :: tracer number (1=Temp, 2=Salt, >2 : ptracer)
C myTime :: current time
C myIter :: current timestep
C myThid :: my Thread Id number
_RL gTendency(1-OLx:sNx+OLx,1-OLy:sNy+OLy)
INTEGER k, bi, bj
INTEGER tracerNum
_RL myTime
INTEGER myIter
INTEGER myThid
C !LOCAL VARIABLES: ====================================================
C i,j :: loop indices
INTEGER i,j
_RL rbcsVanishingFac
#ifdef ALLOW_PTRACERS
INTEGER iTracer
INTEGER irbc
#endif
CEOP
#ifdef ALLOW_RBCS
if (rbcsVanishingTime.GT.0. _d 0) then
rbcsVanishingFac =
& MAX( 0. _d 0 , 1. _d 0 - myTime / rbcsVanishingTime )
else
rbcsVanishingFac = 1. _d 0
endif
#ifndef DISABLE_RBCS_MOM
IF ( tracerNum.EQ.-1 .AND. useRBCuVel ) THEN
DO j=0,sNy+1
DO i=0,sNx+1
gTendency(i,j) = gTendency(i,j)
& - RBC_maskU(i,j,k,bi,bj)/tauRelaxU
& *( uVel(i,j,k,bi,bj)- RBCuVel(i,j,k,bi,bj) )
c & *maskW(i,j,k,bi,bj)
& *rbcsVanishingFac
ENDDO
ENDDO
ENDIF
IF ( tracerNum.EQ.-2 .AND. useRBCvVel ) THEN
DO j=0,sNy+1
DO i=0,sNx+1
gTendency(i,j) = gTendency(i,j)
& - RBC_maskV(i,j,k,bi,bj)/tauRelaxV
& *( vVel(i,j,k,bi,bj)- RBCvVel(i,j,k,bi,bj) )
c & *maskS(i,j,k,bi,bj)
& *rbcsVanishingFac
ENDDO
ENDDO
ENDIF
#endif /* DISABLE_RBCS_MOM */
IF ( tracerNum.EQ.1 .AND. useRBCtemp ) THEN
DO j=1,sNy
DO i=1,sNx
gTendency(i,j) = gTendency(i,j)
& - RBC_mask(i,j,k,bi,bj,1)/tauRelaxT
& *( theta(i,j,k,bi,bj)- RBCtemp(i,j,k,bi,bj) )
c & *maskC(i,j,k,bi,bj)
& *rbcsVanishingFac
ENDDO
ENDDO
ENDIF
IF ( tracerNum.EQ.2 .AND. useRBCsalt ) THEN
DO j=1,sNy
DO i=1,sNx
gTendency(i,j) = gTendency(i,j)
& - RBC_mask(i,j,k,bi,bj,2)/tauRelaxS
& *( salt(i,j,k,bi,bj)- RBCsalt(i,j,k,bi,bj) )
c & *maskC(i,j,k,bi,bj)
& *rbcsVanishingFac
ENDDO
ENDDO
ENDIF
#ifdef ALLOW_PTRACERS
IF ( usePTRACERS .AND. tracerNum.GT.2 ) THEN
iTracer = tracerNum-2
irbc = MIN(maskLEN,tracerNum)
IF ( useRBCpTrNum(iTracer) ) THEN
DO j=1,sNy
DO i=1,sNx
gTendency(i,j) = gTendency(i,j)
& - RBC_mask(i,j,k,bi,bj,irbc)/tauRelaxPTR(iTracer)
& *( pTracer(i,j,k,bi,bj,iTracer)
& - RBC_ptracers(i,j,k,bi,bj,iTracer) )
c & *maskC(i,j,k,bi,bj)
& *rbcsVanishingFac
ENDDO
ENDDO
ENDIF
ENDIF
#endif /* ALLOW_PTRACERS */
#endif /* ALLOW_RBCS */
RETURN
END