-
Notifications
You must be signed in to change notification settings - Fork 13
/
obcs_calc.F
206 lines (189 loc) · 5.85 KB
/
obcs_calc.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#include "OBCS_OPTIONS.h"
SUBROUTINE OBCS_CALC( futureTime, futureIter,
& uVel, vVel, wVel, theta, salt,
& myThid )
C *==========================================================*
C | SUBROUTINE OBCS_CALC
C | o Calculate future boundary data at open boundaries
C | at time = futureTime
C *==========================================================*
IMPLICIT NONE
C === Global variables ===
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#ifdef ALLOW_EXCH2
# include "W2_EXCH2_SIZE.h"
#endif /* ALLOW_EXCH2 */
#include "SET_GRID.h"
#include "GRID.h"
#include "OBCS_PARAMS.h"
#include "OBCS_GRID.h"
#include "OBCS_FIELDS.h"
#include "EOS.h"
C == Routine arguments ==
INTEGER futureIter
_RL futureTime
_RL uVel (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
_RL vVel (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
_RL wVel (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
_RL theta(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
_RL salt (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy)
INTEGER myThid
#ifdef ALLOW_OBCS
C == Local variables ==
INTEGER bi, bj
INTEGER I, J ,K
_RL obTimeScale,Uinflow,rampTime2
_RL vertStructWst(Nr)
_RL mz,strat,kx
_RL tmpsum
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
#ifdef ALLOW_DEBUG
IF (debugMode) CALL DEBUG_ENTER('OBCS_CALC',myThid)
#endif
C Vertical mode number
mz=1.0 _d 0
C Stratification
strat = 1.0 _d -6 / (gravity*tAlpha)
C Create a vertical structure function with zero mean
tmpsum=0.
do K=1,Nr
vertStructWst(K)=cos(mz*PI* (rC(K)/rF(Nr+1)) )
tmpsum=tmpsum+vertStructWst(K)*drF(K)
enddo
tmpsum=tmpsum/rF(Nr+1)
do K=1,Nr
vertStructWst(K)=vertStructWst(K)-tmpsum
enddo
c
obTimeScale = 44567.0 _d 0
kx=mz*2. _d 0*pi/400.0 _d 0
& *sqrt((2.0 _d 0*pi*2.0 _d 0*pi/(obTimeScale*obTimeScale)
& - f0*f0)/(1.0 _d -6
& - 2.0 _d 0*pi*2.0 _d 0*pi/(obTimeScale*obTimeScale)))
Uinflow = 0.024 _d 0
C *NOTE* I have commented out the ramp function below
C just to speed things up. You will probably want to use it
C for smoother looking solutions.
rampTime2 = 4. _d 0*44567.0 _d 0
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
C Eastern OB
IF (useOrlanskiEast) THEN
CALL ORLANSKI_EAST(
& bi, bj, futureTime,
& uVel, vVel, wVel, theta, salt,
& myThid )
ELSE
DO K=1,Nr
DO J=1-Oly,sNy+Oly
OBEu(J,K,bi,bj)=0.
OBEv(J,K,bi,bj)=0.
OBEt(J,K,bi,bj)=tRef(K)
OBEs(J,K,bi,bj)=sRef(K)
#ifdef ALLOW_NONHYDROSTATIC
OBEw(J,K,bi,bj)=0.
#endif
ENDDO
ENDDO
ENDIF
C Western OB
IF (useOrlanskiWest) THEN
CALL ORLANSKI_WEST(
& bi, bj, futureTime,
& uVel, vVel, wVel, theta, salt,
& myThid )
ELSE
DO K=1,Nr
DO J=1-Oly,sNy+Oly
OBWu(J,K,bi,bj)=0. _d 0
& +Uinflow
& *vertStructWst(K)
& *sin(2. _d 0*PI*futureTime/obTimeScale)
c & *(exp(futureTime/rampTime2)
c & - exp(-futureTime/rampTime2))
c & /(exp(futureTime/rampTime2)
c & + exp(-futureTime/rampTime2))
& *cos(kx*(3. _d 0-2. _d 0-0.5 _d 0)*delX(1))
OBWv(J,K,bi,bj)=0. _d 0
& +Uinflow
& *f0/(2.0 _d 0*PI/obTimeScale)
& *vertStructWst(K)
& *cos(2. _d 0*PI*futureTime/obTimeScale )
& * (exp(futureTime/rampTime2)
& - exp(-futureTime/rampTime2))
& /(exp(futureTime/rampTime2)
& + exp(-futureTime/rampTime2))
OBWt(J,K,bi,bj)=tRef(K)
& + Uinflow*sin(mz*PI*(float(k)-0.5 _d 0)/float(Nr))
& * sin(2.0 _d 0*PI*futureTime/obTimeScale)
& *sqrt(strat/(tAlpha*gravity))
& *sqrt(2.0 _d 0*PI/obTimeScale*2.0*PI/obTimeScale - f0*f0)
& /(2.0 _d 0*PI/obTimeScale)
c & * (exp(futureTime/rampTime2)
c & - exp(-futureTime/rampTime2))
c & /(exp(futureTime/rampTime2)
c & + exp(-futureTime/rampTime2))
#ifdef ALLOW_NONHYDROSTATIC
OBWw(J,K,bi,bj)=-Uinflow
& *sqrt(2.0 _d 0*PI/obTimeScale*2.0 _d 0*PI/obTimeScale - f0*f0)
& /sqrt(strat*strat -
& 2.0 _d 0*PI/obTimeScale*2.0 _d 0*PI/obTimeScale)
& *sin(mz*PI*(float(k)-0.5 _d 0)/float(Nr))
& *cos(2. _d 0*PI*futureTime/obTimeScale)
c & *(exp(futureTime/rampTime2)
c & - exp(-futureTime/rampTime2))
c & /(exp(futureTime/rampTime2)
c & + exp(-futureTime/rampTime2))
#endif
ENDDO
ENDDO
ENDIF
C Northern OB, template for forcing
IF (useOrlanskiNorth) THEN
CALL ORLANSKI_NORTH(
& bi, bj, futureTime,
& uVel, vVel, wVel, theta, salt,
& myThid )
ELSE
DO K=1,Nr
DO I=1-Olx,sNx+Olx
OBNv(I,K,bi,bj)=0.
OBNu(I,K,bi,bj)=0.
OBNt(I,K,bi,bj)=tRef(K)
OBNs(I,K,bi,bj)=sRef(K)
#ifdef ALLOW_NONHYDROSTATIC
OBNw(I,K,bi,bj)=0.
#endif
ENDDO
ENDDO
ENDIF
C Southern OB, template for forcing
IF (useOrlanskiSouth) THEN
CALL ORLANSKI_SOUTH(
& bi, bj, futureTime,
& uVel, vVel, wVel, theta, salt,
& myThid )
ELSE
DO K=1,Nr
DO I=1-Olx,sNx+Olx
OBSu(I,K,bi,bj)=0.
OBSv(I,K,bi,bj)=0.
OBSt(I,K,bi,bj)=tRef(K)
OBSs(I,K,bi,bj)=sRef(K)
#ifdef ALLOW_NONHYDROSTATIC
OBSw(I,K,bi,bj)=0.
#endif
ENDDO
ENDDO
ENDIF
C-- end bi,bj loops.
ENDDO
ENDDO
#ifdef ALLOW_DEBUG
IF (debugMode) CALL DEBUG_LEAVE('OBCS_CALC',myThid)
#endif
#endif /* ALLOW_OBCS */
RETURN
END