/[MITgcm]/MITgcm_contrib/SOSE/BoxAdj/code_ad/ctrl_getobcss.F
ViewVC logotype

Contents of /MITgcm_contrib/SOSE/BoxAdj/code_ad/ctrl_getobcss.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.9 - (show annotations) (download)
Wed Apr 20 19:20:20 2011 UTC (14 years, 8 months ago) by mmazloff
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +1 -1 lines
FILE REMOVED
cleaning

1 C $Header: /u/gcmpack/MITgcm_contrib/SOSE/BoxAdj/code_ad/ctrl_getobcss.F,v 1.8 2011/04/19 23:33:00 mmazloff Exp $
2 C $Name: $
3
4 #include "CTRL_CPPOPTIONS.h"
5 #ifdef ALLOW_OBCS
6 # include "OBCS_OPTIONS.h"
7 #endif
8
9
10 subroutine ctrl_getobcss(
11 I mytime,
12 I myiter,
13 I mythid
14 & )
15
16 c ==================================================================
17 c SUBROUTINE ctrl_getobcss
18 c ==================================================================
19 c
20 c o Get southern obc of the control vector and add it
21 c to dyn. fields
22 c
23 c started: heimbach@mit.edu, 29-Aug-2001
24 c
25 c new flags: gebbie@mit.edu, 25 Jan 2003.
26 c
27 c ==================================================================
28 c SUBROUTINE ctrl_getobcss
29 c ==================================================================
30
31 implicit none
32
33 #ifdef ALLOW_OBCSS_CONTROL
34
35 c == global variables ==
36
37 #include "EEPARAMS.h"
38 #include "SIZE.h"
39 #include "PARAMS.h"
40 #include "GRID.h"
41 #include "OBCS.h"
42
43 #include "ctrl.h"
44 #include "ctrl_dummy.h"
45 #include "optim.h"
46
47 c == routine arguments ==
48
49 _RL mytime
50 integer myiter
51 integer mythid
52
53 c == local variables ==
54
55 integer bi,bj
56 integer i,j,k
57 integer itlo,ithi
58 integer jtlo,jthi
59 integer jmin,jmax
60 integer imin,imax
61 integer ilobcss
62 integer iobcs
63
64 _RL dummy
65 _RL obcssfac
66 logical obcssfirst
67 logical obcsschanged
68 integer obcsscount0
69 integer obcsscount1
70 integer jp1
71
72 cgg _RL maskxz (1-olx:snx+olx,nr,nsx,nsy)
73 _RL tmpfldxz (1-olx:snx+olx,nr,nsx,nsy)
74
75 logical doglobalread
76 logical ladinit
77
78 character*(80) fnameobcss
79
80 #ifdef ALLOW_OBCS_CONTROL_MODES
81 integer nk,nz
82 _RL tmpz (nr,nsx,nsy)
83 _RL stmp
84 #endif
85
86 c == external functions ==
87
88 integer ilnblnk
89 external ilnblnk
90
91
92 c == end of interface ==
93
94 jtlo = mybylo(mythid)
95 jthi = mybyhi(mythid)
96 itlo = mybxlo(mythid)
97 ithi = mybxhi(mythid)
98 jmin = 1-oly
99 jmax = sny+oly
100 imin = 1-olx
101 imax = snx+olx
102 jp1 = 1
103
104 c-- Now, read the control vector.
105 doglobalread = .false.
106 ladinit = .false.
107
108 if (optimcycle .ge. 0) then
109 ilobcss=ilnblnk( xx_obcss_file )
110 write(fnameobcss(1:80),'(2a,i10.10)')
111 & xx_obcss_file(1:ilobcss), '.', optimcycle
112 endif
113
114 c-- Get the counters, flags, and the interpolation factor.
115 call ctrl_get_gen_rec(
116 I xx_obcssstartdate, xx_obcssperiod,
117 O obcssfac, obcssfirst, obcsschanged,
118 O obcsscount0,obcsscount1,
119 I mytime, myiter, mythid )
120
121 do iobcs = 1,nobcs
122 if ( obcssfirst ) then
123 call active_read_xz( fnameobcss, tmpfldxz,
124 & (obcsscount0-1)*nobcs+iobcs,
125 & doglobalread, ladinit, optimcycle,
126 & mythid, xx_obcss_dummy )
127
128 do bj = jtlo,jthi
129 do bi = itlo,ithi
130 #ifdef ALLOW_OBCS_CONTROL_MODES
131 if (iobcs .gt. 2) then
132 do i = imin,imax
133 j = OB_Js(i,bi,bj)
134 cih Determine number of open vertical layers.
135 nz = 0
136 do k = 1,Nr
137 if (iobcs .eq. 3) then
138 nz = nz + maskS(i,j+jp1,k,bi,bj)
139 else
140 nz = nz + maskW(i,j,k,bi,bj)
141 endif
142 end do
143 cih Compute absolute velocities from the barotropic-baroclinic modes.
144 do k = 1,Nr
145 if (k.le.nz) then
146 stmp = 0.
147 do nk = 1,nz
148 stmp = stmp +
149 & modesv(k,nk,nz)*tmpfldxz(i,nk,bi,bj)
150 end do
151 tmpz(k,bi,bj) = stmp
152 else
153 tmpz(k,bi,bj) = 0.
154 end if
155 end do
156 do k = 1,Nr
157 if (iobcs .eq. 3) then
158 tmpfldxz(i,k,bi,bj) = tmpz(k,bi,bj)
159 & *recip_hFacS(i,j+jp1,k,bi,bj)
160 else
161 tmpfldxz(i,k,bi,bj) = tmpz(k,bi,bj)
162 & *recip_hFacW(i,j,k,bi,bj)
163 endif
164 end do
165 enddo
166 endif
167 #endif
168 do k = 1,nr
169 do i = imin,imax
170 xx_obcss1(i,k,bi,bj,iobcs) = tmpfldxz (i,k,bi,bj)
171 cgg & * maskxz (i,k,bi,bj)
172 enddo
173 enddo
174 enddo
175 enddo
176 endif
177
178 if ( (obcssfirst) .or. (obcsschanged)) then
179
180 do bj = jtlo,jthi
181 do bi = itlo,ithi
182 do k = 1,nr
183 do i = imin,imax
184 xx_obcss0(i,k,bi,bj,iobcs) = xx_obcss1(i,k,bi,bj,iobcs)
185 tmpfldxz (i,k,bi,bj) = 0. _d 0
186 enddo
187 enddo
188 enddo
189 enddo
190
191 call active_read_xz( fnameobcss, tmpfldxz,
192 & (obcsscount1-1)*nobcs+iobcs,
193 & doglobalread, ladinit, optimcycle,
194 & mythid, xx_obcss_dummy )
195
196 do bj = jtlo,jthi
197 do bi = itlo,ithi
198 #ifdef ALLOW_OBCS_CONTROL_MODES
199 if (iobcs .gt. 2) then
200 do i = imin,imax
201 j = OB_Js(i,bi,bj)
202 cih Determine number of open vertical layers.
203 nz = 0
204 do k = 1,Nr
205 if (iobcs .eq. 3) then
206 nz = nz + maskS(i,j+jp1,k,bi,bj)
207 else
208 nz = nz + maskW(i,j,k,bi,bj)
209 endif
210 end do
211 cih Compute absolute velocities from the barotropic-baroclinic modes.
212 do k = 1,Nr
213 if (k.le.nz) then
214 stmp = 0.
215 do nk = 1,nz
216 stmp = stmp +
217 & modesv(k,nk,nz)*tmpfldxz(i,nk,bi,bj)
218 end do
219 tmpz(k,bi,bj) = stmp
220 else
221 tmpz(k,bi,bj) = 0.
222 end if
223 end do
224 do k = 1,Nr
225 if (iobcs .eq. 3) then
226 tmpfldxz(i,k,bi,bj) = tmpz(k,bi,bj)
227 & *recip_hFacS(i,j+jp1,k,bi,bj)
228 else
229 tmpfldxz(i,k,bi,bj) = tmpz(k,bi,bj)
230 & *recip_hFacW(i,j,k,bi,bj)
231 endif
232 end do
233 enddo
234 endif
235 #endif
236 do k = 1,nr
237 do i = imin,imax
238 xx_obcss1 (i,k,bi,bj,iobcs) = tmpfldxz (i,k,bi,bj)
239 cgg & * maskxz (i,k,bi,bj)
240 enddo
241 enddo
242 enddo
243 enddo
244 endif
245
246 c-- Add control to model variable.
247 do bj = jtlo,jthi
248 do bi = itlo,ithi
249 c-- Calculate mask for tracer cells (0 => land, 1 => water).
250 do k = 1,nr
251 do i = 1,snx
252 j = OB_Js(I,bi,bj)
253 if (iobcs .EQ. 1) then
254 OBSt(i,k,bi,bj) = OBSt (i,k,bi,bj)
255 & + obcssfac *xx_obcss0(i,k,bi,bj,iobcs)
256 & + (1. _d 0 - obcssfac)*xx_obcss1(i,k,bi,bj,iobcs)
257 OBSt(i,k,bi,bj) = OBSt(i,k,bi,bj)
258 & *maskS(i,j+jp1,k,bi,bj)
259 else if (iobcs .EQ. 2) then
260 OBSs(i,k,bi,bj) = OBSs (i,k,bi,bj)
261 & + obcssfac *xx_obcss0(i,k,bi,bj,iobcs)
262 & + (1. _d 0 - obcssfac)*xx_obcss1(i,k,bi,bj,iobcs)
263 OBSs(i,k,bi,bj) = OBSs(i,k,bi,bj)
264 & *maskS(i,j+jp1,k,bi,bj)
265 else if (iobcs .EQ. 4) then
266 OBSu(i,k,bi,bj) = OBSu (i,k,bi,bj)
267 & + obcssfac *xx_obcss0(i,k,bi,bj,iobcs)
268 & + (1. _d 0 - obcssfac)*xx_obcss1(i,k,bi,bj,iobcs)
269 OBSu(i,k,bi,bj) = OBSu(i,k,bi,bj)
270 & *maskW(i,j,k,bi,bj)
271 else if (iobcs .EQ. 3) then
272 OBSv(i,k,bi,bj) = OBSv (i,k,bi,bj)
273 & + obcssfac *xx_obcss0(i,k,bi,bj,iobcs)
274 & + (1. _d 0 - obcssfac)*xx_obcss1(i,k,bi,bj,iobcs)
275 OBSv(i,k,bi,bj) = OBSv(i,k,bi,bj)
276 & *maskS(i,j+jp1,k,bi,bj)
277 endif
278 enddo
279 enddo
280 enddo
281 enddo
282
283 C-- End over iobcs loop
284 enddo
285
286 #else /* ALLOW_OBCSS_CONTROL undefined */
287
288 c == routine arguments ==
289
290 _RL mytime
291 integer myiter
292 integer mythid
293
294 c-- CPP flag ALLOW_OBCSS_CONTROL undefined.
295
296 #endif /* ALLOW_OBCSS_CONTROL */
297
298 end
299

  ViewVC Help
Powered by ViewVC 1.1.22