/[MITgcm]/MITgcm/pkg/gridalt/make_phys_grid.F
ViewVC logotype

Contents of /MITgcm/pkg/gridalt/make_phys_grid.F

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


Revision 1.3 - (show annotations) (download)
Wed May 5 00:39:21 2004 UTC (21 years, 2 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint52n_post, checkpoint53d_post, checkpoint54a_pre, checkpoint55c_post, checkpoint54e_post, checkpoint54a_post, checkpoint53c_post, checkpoint55d_pre, checkpoint55h_post, checkpoint54b_post, checkpoint53b_pre, checkpoint55b_post, checkpoint54d_post, checkpoint55, checkpoint53a_post, checkpoint54, checkpoint54f_post, checkpoint53b_post, checkpoint55g_post, checkpoint55f_post, checkpoint55i_post, checkpoint53, checkpoint53g_post, checkpoint55e_post, checkpoint53f_post, checkpoint55a_post, checkpoint53d_pre, checkpoint54c_post, checkpoint55d_post
Changes since 1.2: +3 -0 lines
 o adding cvs 'Header:' and 'Name:' strings

1 C $Header: $
2 C $Name: $
3
4 subroutine make_phys_grid(drF,hfacC,im1,im2,jm1,jm2,Nr,
5 . Nsx,Nsy,i1,i2,j1,j2,bi,bj,Nrphys,Lbot,dpphys,numlevphys,nlperdyn)
6 c***********************************************************************
7 c subroutine make_phys_grid
8 c
9 c Purpose: Define the grid that the will be used to run the high-end
10 c atmospheric physics.
11 c
12 c Algorithm: Fit additional levels of some (~) known thickness in
13 c between existing levels of the grid used for the dynamics
14 c
15 c Need: Information about the dynamics grid vertical spacing
16 c
17 c Input: drF - delta r (p*) edge-to-edge
18 c hfacC - fraction of grid box above topography
19 c im1, im2 - beginning and ending i - dimensions
20 c jm1, jm2 - beginning and ending j - dimensions
21 c Nr - number of levels in dynamics grid
22 c Nsx,Nsy - number of processes in x and y direction
23 c i1, i2 - beginning and ending i - index to fill
24 c j1, j2 - beginning and ending j - index to fill
25 c bi, bj - x-dir and y-dir index of process
26 c Nrphys - number of levels in physics grid
27 c
28 c Output: dpphys - delta r (p*) edge-to-edge of physics grid
29 c numlevphys - number of levels used in the physics
30 c nlperdyn - physics level number atop each dynamics layer
31 c
32 c NOTES: 1) Pressure levs are built up from bottom, using p0, ps and dp:
33 c p(i,j,k)=p(i,j,k-1) + dp(k)*ps(i,j)/p0(i,j)
34 c 2) Output dp's are aligned to fit EXACTLY between existing
35 c levels of the dynamics vertical grid
36 c 3) IMPORTANT! This routine assumes the levels are numbered
37 c from the bottom up, ie, level 1 is the surface.
38 c IT WILL NOT WORK OTHERWISE!!!
39 c 4) This routine does NOT work for surface pressures less
40 c (ie, above in the atmosphere) than about 350 mb
41 c***********************************************************************
42 implicit none
43 c
44 #include "CPP_OPTIONS.h"
45
46 integer im1,im2,jm1,jm2,Nr,Nsx,Nsy,Nrphys
47 integer i1,i2,j1,j2,bi,bj
48 integer numlevphys
49 _RL hfacC(im1:im2,jm1:jm2,Nr,Nsx,Nsy)
50 _RL dpphys(im1:im2,jm1:jm2,Nrphys,Nsx,Nsy)
51 _RL drF(Nr)
52 integer Lbot(im1:im2,jm1:jm2,Nsx,Nsy)
53 integer nlperdyn(im1:im2,jm1:jm2,Nr,Nsx,Nsy)
54 c
55 integer i,j,L,Lbotij,Lnew
56 c Require 12 bottom levels (300 mb worth) for the physics, the dp's are:
57 integer ntry
58 data ntry /12/
59 _RL dptry(12), dptry_accum(12)
60 data dptry /300.000, 600.000,1000.000,1400.000,1700.000,2500.000,
61 . 2500.000,2500.000,2500.000,5000.000,5000.000,5000.000/
62 _RL deltap, dpstar_accum
63 integer nlbotmax, nstart, nlevs, nlphys, ndone
64 integer nextra
65 c
66 nextra = ntry
67 c
68 do L = 1,Nr
69 do j = j1,j2
70 do i = i1,i2+1
71 nlperdyn(i,j,L,bi,bj) = 0
72 enddo
73 enddo
74 enddo
75 c
76 c Figure out how many physics levels there will be
77 c (need 12 between sfc and 300 mb above it - see how many
78 c there are in the dynamics if the surface pressure is at
79 c the sum of drF, ie, the maximum dynamics grid layers possible)
80 nlevs = 0
81 dpstar_accum = 0.
82 do L = 1,Nr
83 dpstar_accum = dpstar_accum + drF(L)
84 if(dpstar_accum.le.30000.) nlevs = nlevs+1
85 enddo
86 numlevphys = Nr - nlevs + ntry + 1
87 c
88 dptry_accum(1) = dptry(1)
89 do Lnew = 2,ntry
90 dptry_accum(Lnew) = dptry_accum(Lnew-1) + dptry(Lnew)
91 enddo
92 c
93 c do for each grid point:
94 do j = j1,j2
95 do i = i1,i2
96 Lbotij = Lbot(i,j,bi,bj)
97 c
98 c Find the maximum number of physics levels to fit in the bottom level
99 c
100 nlbotmax = 0
101 do Lnew = 1,ntry
102 if ( (nlbotmax.eq.0) .and.
103 . (dptry_accum(Lnew).gt.(hfacC(i,j,Lbotij,bi,bj)*drF(Lbotij))))then
104 nlbotmax = Lnew
105 endif
106 enddo
107 if(nlbotmax.eq.0)then
108 nlbotmax = ntry
109 endif
110 c
111 c See how many of the physics levs can fit in the bottom level
112 c
113 nlphys = 0
114 deltap = 0.
115 do Lnew = 1,nlbotmax
116 c Test to see if the next physics level fits, if yes, add it
117 if((hfacC(i,j,Lbotij,bi,bj)*drF(Lbotij)).ge.
118 . deltap+dptry(Lnew))then
119 nlphys = nlphys + 1
120 dpphys(i,j,nlphys,bi,bj) = dptry(Lnew)
121 deltap = deltap + dptry(Lnew)
122 else
123 c If the level does not fit, decide whether to make a new thinner
124 c one or make the one below a bit thicker
125 if((dptry(Lnew-1)+(hfacC(i,j,Lbotij,bi,bj)*
126 . drF(Lbotij)-deltap)) .gt. (dptry(Lnew-1)*1.5) ) then
127 c Add a new thin layer
128 nlphys = nlphys + 1
129 dpphys(i,j,nlphys,bi,bj) =
130 . (hfacC(i,j,Lbotij,bi,bj)*drF(Lbotij))-deltap
131 else
132 c Make the one below thicker
133 dpphys(i,j,nlphys,bi,bj) = dpphys(i,j,nlphys,bi,bj) +
134 . (hfacC(i,j,Lbotij,bi,bj)*drF(Lbotij)-deltap)
135 endif
136 deltap = deltap+(hfacC(i,j,Lbotij,bi,bj)*drF(Lbotij)-deltap)
137 endif
138 enddo
139 c
140 nlperdyn(i,j,Lbotij,bi,bj) = nlphys
141 c
142 c Now proceed upwards - see how many physics levels fit in each
143 c subsequent dynamics level - go through all 12 required levels
144 c
145 do L = Lbotij+1,Nr
146 ndone = 0
147 if(nlphys.lt.ntry)then
148 deltap = 0.
149 nstart = nlphys + 1
150 do Lnew = nstart,ntry
151 if((hfacC(i,j,L,bi,bj)*drF(L)).ge.deltap+dptry(Lnew))then
152 nlphys = nlphys + 1
153 dpphys(i,j,nlphys,bi,bj) = dptry(Lnew)
154 deltap = deltap + dptry(Lnew)
155 ndone = 0
156 elseif (ndone.eq.0) then
157 c If the level does not fit, decide whether to make a new thinner
158 c one or make the one below a bit thicker
159 ndone = 1
160 if( (dptry(Lnew-1)+(hfacC(i,j,L,bi,bj)*drF(L)-deltap))
161 . .gt. (dptry(Lnew-1)*1.5) ) then
162 c Add a new thin layer
163 nlphys = nlphys + 1
164 dpphys(i,j,nlphys,bi,bj) =
165 . (hfacC(i,j,L,bi,bj)*drF(L))-deltap
166 deltap = hfacC(i,j,L,bi,bj)*drF(L)
167 else
168 c Make the one below thicker
169 dpphys(i,j,nlphys,bi,bj) = dpphys(i,j,nlphys,bi,bj) +
170 . (hfacC(i,j,L,bi,bj)*drF(L)-deltap)
171 deltap = hfacC(i,j,L,bi,bj)*drF(L)
172 endif
173 endif
174 enddo
175 C Need one more peice of logic - if we finished Lnew loop and
176 C now we are done adding new physics layers, we need to be sure
177 C that we are at the edge of a dynamics layer. if not, we need
178 C to add one more layer.
179 if(nlphys.ge.ntry)then
180 if(abs(deltap-hfacC(i,j,L-1,bi,bj)*drF(L-1)).gt.0.001)then
181 nlphys = nlphys + 1
182 dpphys(i,j,nlphys,bi,bj) = hfacC(i,j,L-1,bi,bj)*drF(L-1)
183 . - deltap
184 endif
185 endif
186
187 elseif(nlphys.eq.ntry)then
188 c Mostly done with new layers - make sure we end at dynamics edge,
189 c if not, make one more thinner (thinner than dyn grid) layer
190 if(abs(deltap-hfacC(i,j,L-1,bi,bj)*drF(L-1)).gt.0.001)then
191 nlphys = nlphys + 1
192 dpphys(i,j,nlphys,bi,bj) = hfacC(i,j,L-1,bi,bj)*drF(L-1)
193 . - deltap
194 nlphys = nlphys + 1
195 dpphys(i,j,nlphys,bi,bj) = hfacC(i,j,L,bi,bj)*drF(L)
196 else
197 nlphys = nlphys + 1
198 dpphys(i,j,nlphys,bi,bj) = hfacC(i,j,L,bi,bj)*drF(L)
199 endif
200 else
201 c we are done adding new physics layers, just copy the rest
202 c of the dynamics grid onto the physics grid
203 nlphys = nlphys + 1
204 dpphys(i,j,nlphys,bi,bj) = hfacC(i,j,L,bi,bj)*drF(L)
205 endif
206 nlperdyn(i,j,L,bi,bj) = nlphys
207 enddo
208 c
209 c All done adding layers - if we need more to make numlevphys, put
210 c them as thin (1 mb) layers near the top
211 if(nlphys.lt.numlevphys)then
212 nlevs = numlevphys-nlphys
213 dpphys(i,j,nlphys,bi,bj) = dpphys(i,j,nlphys,bi,bj)-100. * nlevs
214 do Lnew = nlphys+1,numlevphys
215 dpphys(i,j,Lnew,bi,bj) = 100.
216 enddo
217 nlperdyn(i,j,Nr,bi,bj) = numlevphys
218 endif
219 c END OF LOOP OVER GRID POINTS
220 enddo
221 enddo
222
223 return
224 end

  ViewVC Help
Powered by ViewVC 1.1.22