1 |
C $Header: /u/gcmpack/MITgcm/pkg/fizhi/fizhi_wrapper.F,v 1.34 2009/04/02 21:29:34 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "FIZHI_OPTIONS.h" |
5 |
subroutine fizhi_wrapper (myTime, myIter, myThid) |
6 |
c----------------------------------------------------------------------- |
7 |
c Subroutine fizhi_wrapper - 'Wrapper' routine to interface |
8 |
c with physics driver. |
9 |
c 1) Set up "bi, bj loop" and some timers and clocks. |
10 |
c 2) Call do_fizhi - driver for physics which computes tendencies |
11 |
c 3) Interpolate tendencies to dynamics grid in vertical |
12 |
c 4) Convert u,v tendencies to C-Grid |
13 |
c |
14 |
c Calls: do_fizhi (get u,v,t,s tend, step tke, etc and tc, etc. forward) |
15 |
c phys2dyn (4 calls - all physics tendencies) |
16 |
c AtoC (u and v tendencies) |
17 |
c----------------------------------------------------------------------- |
18 |
implicit none |
19 |
#include "SIZE.h" |
20 |
#include "GRID.h" |
21 |
#include "EEPARAMS.h" |
22 |
#include "PARAMS.h" |
23 |
#include "SURFACE.h" |
24 |
#include "DYNVARS.h" |
25 |
#include "fizhi_land_SIZE.h" |
26 |
#include "fizhi_SIZE.h" |
27 |
#include "fizhi_coms.h" |
28 |
#include "gridalt_mapping.h" |
29 |
#include "fizhi_land_coms.h" |
30 |
#include "fizhi_earth_coms.h" |
31 |
#include "fizhi_ocean_coms.h" |
32 |
#include "fizhi_chemistry_coms.h" |
33 |
#ifdef ALLOW_DIAGNOSTICS |
34 |
#include "fizhi_SHP.h" |
35 |
#endif |
36 |
|
37 |
integer myIter, myThid |
38 |
_RL myTime |
39 |
logical diagnostics_is_on |
40 |
external diagnostics_is_on |
41 |
|
42 |
c pe on dynamics and physics grid refers to bottom edge |
43 |
_RL pephy4fiz(1-OLx:sNx+Olx,1-Oly:sNy+Oly,Nrphys+1,nSx,nSy) |
44 |
_RL pephy(1-OLx:sNx+Olx,1-Oly:sNy+Oly,Nrphys+1,nSx,nSy) |
45 |
_RL pedyn(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr+1,nSx,nSy) |
46 |
_RL tempphy(1-OLx:sNx+Olx,1-Oly:sNy+Oly,Nrphys,nSx,nSy) |
47 |
_RL fracland(sNx,sNy,Nsx,Nsy) |
48 |
_RL tempLdiag(sNx,sNy,Nrphys+1) |
49 |
_RL tempLdiag2(sNx,sNy,Nrphys) |
50 |
_RL tempdiag(sNx,sNy) |
51 |
_RL slp(sNx,sNy) |
52 |
|
53 |
integer i, j, L, Lbotij, bi, bj |
54 |
integer im1, im2, jm1, jm2, idim1, idim2, jdim1, jdim2 |
55 |
_RL grav, getcon |
56 |
|
57 |
grav = getcon('GRAVITY') |
58 |
idim1 = 1-OLx |
59 |
idim2 = sNx+OLx |
60 |
jdim1 = 1-OLy |
61 |
jdim2 = sNy+OLy |
62 |
im1 = 1 |
63 |
im2 = sNx |
64 |
jm1 = 1 |
65 |
jm2 = sNy |
66 |
|
67 |
#ifdef ALLOW_DIAGNOSTICS |
68 |
if ( useDiagnostics ) then |
69 |
if(diagnostics_is_on('TENDUFIZ',myThid) .or. |
70 |
. diagnostics_is_on('CORRDU ',myThid) ) then |
71 |
do bj = myByLo(myThid), myByHi(myThid) |
72 |
do bi = myBxLo(myThid), myBxHi(myThid) |
73 |
do L = 1,Nrphys |
74 |
do j = 1,sNy |
75 |
do i = 1,sNx |
76 |
ubef(i,j,L,bi,bj) = uphy(i,j,L,bi,bj) |
77 |
enddo |
78 |
enddo |
79 |
enddo |
80 |
do L = 1,Nr |
81 |
do j = 1,sNy |
82 |
do i = 1,sNx+1 |
83 |
udynbef(i,j,L,bi,bj) = uvel(i,j,L,bi,bj) |
84 |
enddo |
85 |
enddo |
86 |
enddo |
87 |
enddo |
88 |
enddo |
89 |
endif |
90 |
if(diagnostics_is_on('TENDVFIZ',myThid) .or. |
91 |
. diagnostics_is_on('CORRDV ',myThid) ) then |
92 |
do bj = myByLo(myThid), myByHi(myThid) |
93 |
do bi = myBxLo(myThid), myBxHi(myThid) |
94 |
do L = 1,Nrphys |
95 |
do j = 1,sNy |
96 |
do i = 1,sNx |
97 |
vbef(i,j,L,bi,bj) = vphy(i,j,L,bi,bj) |
98 |
enddo |
99 |
enddo |
100 |
enddo |
101 |
do L = 1,Nr |
102 |
do j = 1,sNy+1 |
103 |
do i = 1,sNx |
104 |
vdynbef(i,j,L,bi,bj) = vvel(i,j,L,bi,bj) |
105 |
enddo |
106 |
enddo |
107 |
enddo |
108 |
enddo |
109 |
enddo |
110 |
endif |
111 |
if(diagnostics_is_on('TENDTFIZ',myThid) .or. |
112 |
. diagnostics_is_on('CORRDT ',myThid) ) then |
113 |
do bj = myByLo(myThid), myByHi(myThid) |
114 |
do bi = myBxLo(myThid), myBxHi(myThid) |
115 |
do L = 1,Nrphys |
116 |
do j = 1,sNy |
117 |
do i = 1,sNx |
118 |
thbef(i,j,L,bi,bj) = thphy(i,j,L,bi,bj) |
119 |
enddo |
120 |
enddo |
121 |
enddo |
122 |
do L = 1,Nr |
123 |
do j = 1,sNy |
124 |
do i = 1,sNx |
125 |
thdynbef(i,j,L,bi,bj) = theta(i,j,L,bi,bj) |
126 |
enddo |
127 |
enddo |
128 |
enddo |
129 |
enddo |
130 |
enddo |
131 |
endif |
132 |
if(diagnostics_is_on('TENDQFIZ',myThid) .or. |
133 |
. diagnostics_is_on('CORRDQ ',myThid) ) then |
134 |
do bj = myByLo(myThid), myByHi(myThid) |
135 |
do bi = myBxLo(myThid), myBxHi(myThid) |
136 |
do L = 1,Nrphys |
137 |
do j = 1,sNy |
138 |
do i = 1,sNx |
139 |
sbef(i,j,L,bi,bj) = sphy(i,j,L,bi,bj) |
140 |
enddo |
141 |
enddo |
142 |
enddo |
143 |
do L = 1,Nr |
144 |
do j = 1,sNy |
145 |
do i = 1,sNx |
146 |
sdynbef(i,j,L,bi,bj) = salt(i,j,L,bi,bj) |
147 |
enddo |
148 |
enddo |
149 |
enddo |
150 |
enddo |
151 |
enddo |
152 |
endif |
153 |
endif |
154 |
#endif |
155 |
|
156 |
do bj = myByLo(myThid), myByHi(myThid) |
157 |
do bi = myBxLo(myThid), myBxHi(myThid) |
158 |
|
159 |
c Construct the physics grid pressures |
160 |
C Note: Need one array to send to fizhi (top-down) and another |
161 |
C For the interpolations between physics and dynamics (bottom-up) |
162 |
do j = 1,sNy |
163 |
do i = 1,sNx |
164 |
pephy(i,j,1,bi,bj)=(Ro_surf(i,j,bi,bj) + etaH(i,j,bi,bj)) |
165 |
do L = 2,Nrphys+1 |
166 |
pephy(i,j,L,bi,bj)=pephy(i,j,L-1,bi,bj)-dpphys(i,j,L-1,bi,bj) |
167 |
enddo |
168 |
c Do not use a zero field as the top edge pressure for interpolation |
169 |
do L = 1,Nrphys+1 |
170 |
pephy4fiz(i,j,Nrphys+2-L,bi,bj)=pephy(i,j,L,bi,bj) |
171 |
enddo |
172 |
if(pephy(i,j,Nrphys+1,bi,bj).lt.1.e-5) |
173 |
. pephy(i,j,Nrphys+1,bi,bj) = 1.e-5 |
174 |
enddo |
175 |
enddo |
176 |
C Build pressures on dynamics grid |
177 |
do j = 1,sNy |
178 |
do i = 1,sNx |
179 |
do L = 1,Nr |
180 |
pedyn(i,j,L,bi,bj) = 0. |
181 |
enddo |
182 |
enddo |
183 |
enddo |
184 |
do j = 1,sNy |
185 |
do i = 1,sNx |
186 |
Lbotij = ksurfC(i,j,bi,bj) |
187 |
if(Lbotij.ne.0.) |
188 |
. pedyn(i,j,Lbotij,bi,bj) = (Ro_surf(i,j,bi,bj) + etaH(i,j,bi,bj)) |
189 |
enddo |
190 |
enddo |
191 |
do j = 1,sNy |
192 |
do i = 1,sNx |
193 |
Lbotij = ksurfC(i,j,bi,bj) |
194 |
do L = Lbotij+1,Nr+1 |
195 |
pedyn(i,j,L,bi,bj) = pedyn(i,j,L-1,bi,bj) - |
196 |
. drF(L-1)* rStarExpC(i,j,bi,bj)*hfacC(i,j,L-1,bi,bj) |
197 |
enddo |
198 |
c Do not use a zero field as the top edge pressure for interpolation |
199 |
if(pedyn(i,j,Nr+1,bi,bj).lt.1.e-5) |
200 |
. pedyn(i,j,Nr+1,bi,bj) = 1.e-5 |
201 |
enddo |
202 |
enddo |
203 |
enddo |
204 |
enddo |
205 |
|
206 |
#ifdef ALLOW_DIAGNOSTICS |
207 |
if ( useDiagnostics ) then |
208 |
if(diagnostics_is_on('FIZPRES ',myThid) ) then |
209 |
do bj = myByLo(myThid), myByHi(myThid) |
210 |
do bi = myBxLo(myThid), myBxHi(myThid) |
211 |
do j = 1,sNy |
212 |
do i = 1,sNx |
213 |
do L = 1,Nrphys |
214 |
tempphy(i,j,L,bi,bj) = pephy4fiz(i,j,L,bi,bj) |
215 |
enddo |
216 |
enddo |
217 |
enddo |
218 |
enddo |
219 |
enddo |
220 |
call diagnostics_fill(tempphy,'FIZPRES ',0, |
221 |
. Nrphys,0,1,1,myThid) |
222 |
endif |
223 |
endif |
224 |
#endif |
225 |
|
226 |
CALL TIMER_START ('DO_FIZHI [FIZHI_WRAPPER]',mythid) |
227 |
do bj = myByLo(myThid), myByHi(myThid) |
228 |
do bi = myBxLo(myThid), myBxHi(myThid) |
229 |
call get_landfrac(im2,jm2,Nsx,Nsy,bi,bj,maxtyp, |
230 |
. surftype,tilefrac,fracland(1,1,bi,bj)) |
231 |
|
232 |
#ifdef ALLOW_DIAGNOSTICS |
233 |
if ( useDiagnostics ) then |
234 |
if(diagnostics_is_on('SLP ',myThid) ) then |
235 |
L = Nrphys+1 |
236 |
do j = 1,sNy |
237 |
do i = 1,sNx |
238 |
tempdiag(i,j) = topoZ(i,j,bi,bj)*grav |
239 |
tempLdiag(i,j,L) = pephy4fiz(i,j,L,bi,bj)/100. |
240 |
enddo |
241 |
enddo |
242 |
do L = 1,Nrphys |
243 |
do j = 1,sNy |
244 |
do i = 1,sNx |
245 |
tempLdiag(i,j,L) = pephy4fiz(i,j,L,bi,bj)/100. |
246 |
tempLdiag2(i,j,L) = thphy(i,j,L,bi,bj) * |
247 |
. (1.+0.609*sphy(i,j,L,bi,bj)) |
248 |
|
249 |
enddo |
250 |
enddo |
251 |
enddo |
252 |
call slprs( tempdiag, tempLdiag, tempLdiag2, |
253 |
. fracland(1,1,bi,bj),sNx,sNy,Nrphys,slp) |
254 |
call diagnostics_fill( slp,'SLP ',1,1,3,bi,bj,myThid ) |
255 |
endif |
256 |
endif |
257 |
#endif |
258 |
c |
259 |
c Compute physics increments |
260 |
|
261 |
call do_fizhi(myIter,myThid, |
262 |
. idim1,idim2,jdim1,jdim2,Nrphys,Nsx,Nsy,im1,im2,jm1,jm2,bi,bj, |
263 |
. nchp,nchptot,nchpland, |
264 |
. uphy,vphy,thphy,sphy,pephy4fiz,xC,yC,topoZ, |
265 |
. ctmt,xxmt,yymt,zetamt,xlmt,khmt,tke, |
266 |
. tgz,sst,sice,phis_var,landtype,fracland,emiss,albnirdr,albnirdf, |
267 |
. albvisdr,albvisdf,ityp,chfr,alai,agrn,igrd,chlt,chlon, |
268 |
. tcanopy,tdeep,ecanopy,swetshal,swetroot,swetdeep,snodep,capac, |
269 |
. o3,qstr,co2,cfc11,cfc12,cfc22,n2o,methane, |
270 |
. iras,nlwcld,cldtot_lw,cldras_lw,cldlsp_lw,nlwlz,lwlz, |
271 |
. nswcld,cldtot_sw,cldras_sw,cldlsp_sw,nswlz,swlz, |
272 |
. imstturbsw,imstturblw,qliqavesw,qliqavelw,fccavesw,fccavelw, |
273 |
. raincon,rainlsp,snowfall, |
274 |
. duphy,dvphy,dthphy,dsphy) |
275 |
enddo |
276 |
enddo |
277 |
|
278 |
CALL TIMER_STOP ('DO_FIZHI [FIZHI_WRAPPER]',mythid) |
279 |
|
280 |
CALL TIMER_START ('PHYS2DYN [FIZHI_WRAPPER]',mythid) |
281 |
do bj = myByLo(myThid), myByHi(myThid) |
282 |
do bi = myBxLo(myThid), myBxHi(myThid) |
283 |
c Interpolate (A-Grid) physics increments to dynamics grid |
284 |
C First flip the physics arrays (which are top-down) |
285 |
C into bottom-up arrays for interpolation to dynamics grid |
286 |
do j = 1,sNy |
287 |
do i = 1,sNx |
288 |
do L = 1,Nrphys |
289 |
tempphy(i,j,Nrphys+1-L,bi,bj)=duphy(i,j,L,bi,bj) |
290 |
enddo |
291 |
enddo |
292 |
enddo |
293 |
call phys2dyn(tempphy,pephy,idim1,idim2,jdim1,jdim2,Nrphys, |
294 |
. Nsx,Nsy,im1,im2,jm1,jm2,bi,bj,pedyn,ksurfC,Nr,nlperdyn,guphy) |
295 |
do j = 1,sNy |
296 |
do i = 1,sNx |
297 |
do L = 1,Nrphys |
298 |
tempphy(i,j,Nrphys+1-L,bi,bj)=dvphy(i,j,L,bi,bj) |
299 |
enddo |
300 |
enddo |
301 |
enddo |
302 |
call phys2dyn(tempphy,pephy,idim1,idim2,jdim1,jdim2,Nrphys, |
303 |
. Nsx,Nsy,im1,im2,jm1,jm2,bi,bj,pedyn,ksurfC,Nr,nlperdyn,gvphy) |
304 |
do j = 1,sNy |
305 |
do i = 1,sNx |
306 |
do L = 1,Nrphys |
307 |
tempphy(i,j,Nrphys+1-L,bi,bj)=dthphy(i,j,L,bi,bj) |
308 |
enddo |
309 |
enddo |
310 |
enddo |
311 |
call phys2dyn(tempphy,pephy,idim1,idim2,jdim1,jdim2,Nrphys, |
312 |
. Nsx,Nsy,im1,im2,jm1,jm2,bi,bj,pedyn,ksurfC,Nr,nlperdyn,gthphy) |
313 |
do j = 1,sNy |
314 |
do i = 1,sNx |
315 |
do L = 1,Nrphys |
316 |
tempphy(i,j,Nrphys+1-L,bi,bj)=dsphy(i,j,L,bi,bj) |
317 |
enddo |
318 |
enddo |
319 |
enddo |
320 |
call phys2dyn(tempphy,pephy,idim1,idim2,jdim1,jdim2,Nrphys, |
321 |
. Nsx,Nsy,im1,im2,jm1,jm2,bi,bj,pedyn,ksurfC,Nr,nlperdyn,gsphy) |
322 |
|
323 |
enddo |
324 |
enddo |
325 |
|
326 |
CALL TIMER_STOP ('PHYS2DYN [FIZHI_WRAPPER]',mythid) |
327 |
|
328 |
c Convert guphy and gvphy from A-grid to C-grid for use by dynamics |
329 |
CALL TIMER_START ('ATOC [FIZHI_WRAPPER]',mythid) |
330 |
call AtoC(myThid,guphy,gvphy,maskC,idim1,idim2,jdim1,jdim2,Nr, |
331 |
. Nsx,Nsy,im1,im2,jm1,jm2,guphy,gvphy) |
332 |
CALL TIMER_STOP ('ATOC [FIZHI_WRAPPER]',mythid) |
333 |
|
334 |
CALL TIMER_START ('EXCHANGES [FIZHI_WRAPPER]',mythid) |
335 |
c Call the c-grid exchange routine to fill in the halo regions (du,dv) |
336 |
call exch_uv_xyz_RL(guphy,gvphy,.TRUE.,myThid) |
337 |
c Call the a-grid exchange routine to fill in the halo regions (dth,ds) |
338 |
_EXCH_XYZ_RL(gthphy,myThid) |
339 |
_EXCH_XYZ_RL(gsphy,myThid) |
340 |
CALL TIMER_STOP ('EXCHANGES [FIZHI_WRAPPER]',mythid) |
341 |
|
342 |
return |
343 |
end |