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

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

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


Revision 1.4 - (hide annotations) (download)
Mon Nov 1 21:35:24 2004 UTC (20 years, 8 months ago) by molod
Branch: MAIN
Changes since 1.3: +30 -6 lines
Add generality to generate fizhi grid for 40 levels in dynamics

1 molod 1.4 C $Header: /u/gcmpack/MITgcm/pkg/gridalt/make_phys_grid.F,v 1.3 2004/05/05 00:39:21 edhill Exp $
2 edhill 1.3 C $Name: $
3    
4 molod 1.1 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 molod 1.4 c Require 12 (or 15) levels near the surface (300 mb worth) for fizhi.
57     c the dp's are in the dptry arrays:
58     integer ntry,ntry10,ntry40
59     data ntry10 /12/
60     data ntry40 /15/
61     _RL dptry(15),dptry10(12),dptry40(15)
62     _RL dptry_accum(15)
63     data dptry10/300.000,600.000,1000.000,1400.000,1700.000,2500.000,
64 molod 1.1 . 2500.000,2500.000,2500.000,5000.000,5000.000,5000.000/
65 molod 1.4 data dptry40/300.000,600.000,1000.000,1400.000,1700.000,
66     . 2500.000,2500.000,2500.000,2500.000,2500.000,2500.000,
67     . 2500.000,2500.000,2500.000,2500.000/
68 molod 1.1 _RL deltap, dpstar_accum
69     integer nlbotmax, nstart, nlevs, nlphys, ndone
70 molod 1.2 integer nextra
71     c
72 molod 1.4 if( (Nr.eq.10) .or. (Nr.eq.20) ) then
73     ntry = ntry10
74     do L = 1,ntry
75     dptry(L) = dptry10(L)
76     enddo
77     elseif(Nr.eq.40) then
78     ntry = ntry40
79     do L = 1,ntry
80     dptry(L) = dptry40(L)
81     enddo
82     else
83     print *,' Dont know how to make fizhi grid '
84     stop
85     endif
86     c
87 molod 1.2 nextra = ntry
88 molod 1.1 c
89     do L = 1,Nr
90     do j = j1,j2
91     do i = i1,i2+1
92     nlperdyn(i,j,L,bi,bj) = 0
93     enddo
94     enddo
95     enddo
96     c
97     c Figure out how many physics levels there will be
98     c (need 12 between sfc and 300 mb above it - see how many
99     c there are in the dynamics if the surface pressure is at
100     c the sum of drF, ie, the maximum dynamics grid layers possible)
101     nlevs = 0
102     dpstar_accum = 0.
103     do L = 1,Nr
104     dpstar_accum = dpstar_accum + drF(L)
105     if(dpstar_accum.le.30000.) nlevs = nlevs+1
106     enddo
107     numlevphys = Nr - nlevs + ntry + 1
108     c
109     dptry_accum(1) = dptry(1)
110     do Lnew = 2,ntry
111     dptry_accum(Lnew) = dptry_accum(Lnew-1) + dptry(Lnew)
112     enddo
113     c
114     c do for each grid point:
115     do j = j1,j2
116 molod 1.2 do i = i1,i2
117 molod 1.1 Lbotij = Lbot(i,j,bi,bj)
118     c
119     c Find the maximum number of physics levels to fit in the bottom level
120     c
121     nlbotmax = 0
122     do Lnew = 1,ntry
123     if ( (nlbotmax.eq.0) .and.
124     . (dptry_accum(Lnew).gt.(hfacC(i,j,Lbotij,bi,bj)*drF(Lbotij))))then
125     nlbotmax = Lnew
126     endif
127     enddo
128     if(nlbotmax.eq.0)then
129     nlbotmax = ntry
130     endif
131     c
132     c See how many of the physics levs can fit in the bottom level
133     c
134     nlphys = 0
135     deltap = 0.
136     do Lnew = 1,nlbotmax
137     c Test to see if the next physics level fits, if yes, add it
138     if((hfacC(i,j,Lbotij,bi,bj)*drF(Lbotij)).ge.
139     . deltap+dptry(Lnew))then
140     nlphys = nlphys + 1
141     dpphys(i,j,nlphys,bi,bj) = dptry(Lnew)
142     deltap = deltap + dptry(Lnew)
143     else
144     c If the level does not fit, decide whether to make a new thinner
145     c one or make the one below a bit thicker
146     if((dptry(Lnew-1)+(hfacC(i,j,Lbotij,bi,bj)*
147     . drF(Lbotij)-deltap)) .gt. (dptry(Lnew-1)*1.5) ) then
148     c Add a new thin layer
149     nlphys = nlphys + 1
150     dpphys(i,j,nlphys,bi,bj) =
151     . (hfacC(i,j,Lbotij,bi,bj)*drF(Lbotij))-deltap
152     else
153     c Make the one below thicker
154     dpphys(i,j,nlphys,bi,bj) = dpphys(i,j,nlphys,bi,bj) +
155     . (hfacC(i,j,Lbotij,bi,bj)*drF(Lbotij)-deltap)
156     endif
157     deltap = deltap+(hfacC(i,j,Lbotij,bi,bj)*drF(Lbotij)-deltap)
158     endif
159     enddo
160     c
161     nlperdyn(i,j,Lbotij,bi,bj) = nlphys
162     c
163     c Now proceed upwards - see how many physics levels fit in each
164     c subsequent dynamics level - go through all 12 required levels
165     c
166     do L = Lbotij+1,Nr
167     ndone = 0
168     if(nlphys.lt.ntry)then
169     deltap = 0.
170     nstart = nlphys + 1
171     do Lnew = nstart,ntry
172     if((hfacC(i,j,L,bi,bj)*drF(L)).ge.deltap+dptry(Lnew))then
173     nlphys = nlphys + 1
174     dpphys(i,j,nlphys,bi,bj) = dptry(Lnew)
175     deltap = deltap + dptry(Lnew)
176     ndone = 0
177     elseif (ndone.eq.0) then
178     c If the level does not fit, decide whether to make a new thinner
179     c one or make the one below a bit thicker
180     ndone = 1
181     if( (dptry(Lnew-1)+(hfacC(i,j,L,bi,bj)*drF(L)-deltap))
182     . .gt. (dptry(Lnew-1)*1.5) ) then
183     c Add a new thin layer
184     nlphys = nlphys + 1
185     dpphys(i,j,nlphys,bi,bj) =
186     . (hfacC(i,j,L,bi,bj)*drF(L))-deltap
187     deltap = hfacC(i,j,L,bi,bj)*drF(L)
188     else
189     c Make the one below thicker
190     dpphys(i,j,nlphys,bi,bj) = dpphys(i,j,nlphys,bi,bj) +
191     . (hfacC(i,j,L,bi,bj)*drF(L)-deltap)
192     deltap = hfacC(i,j,L,bi,bj)*drF(L)
193     endif
194     endif
195     enddo
196 molod 1.2 C Need one more peice of logic - if we finished Lnew loop and
197     C now we are done adding new physics layers, we need to be sure
198     C that we are at the edge of a dynamics layer. if not, we need
199     C to add one more layer.
200     if(nlphys.ge.ntry)then
201     if(abs(deltap-hfacC(i,j,L-1,bi,bj)*drF(L-1)).gt.0.001)then
202     nlphys = nlphys + 1
203     dpphys(i,j,nlphys,bi,bj) = hfacC(i,j,L-1,bi,bj)*drF(L-1)
204     . - deltap
205     endif
206     endif
207    
208 molod 1.1 elseif(nlphys.eq.ntry)then
209     c Mostly done with new layers - make sure we end at dynamics edge,
210     c if not, make one more thinner (thinner than dyn grid) layer
211     if(abs(deltap-hfacC(i,j,L-1,bi,bj)*drF(L-1)).gt.0.001)then
212     nlphys = nlphys + 1
213     dpphys(i,j,nlphys,bi,bj) = hfacC(i,j,L-1,bi,bj)*drF(L-1)
214     . - deltap
215     nlphys = nlphys + 1
216     dpphys(i,j,nlphys,bi,bj) = hfacC(i,j,L,bi,bj)*drF(L)
217     else
218     nlphys = nlphys + 1
219     dpphys(i,j,nlphys,bi,bj) = hfacC(i,j,L,bi,bj)*drF(L)
220     endif
221     else
222     c we are done adding new physics layers, just copy the rest
223     c of the dynamics grid onto the physics grid
224     nlphys = nlphys + 1
225     dpphys(i,j,nlphys,bi,bj) = hfacC(i,j,L,bi,bj)*drF(L)
226     endif
227     nlperdyn(i,j,L,bi,bj) = nlphys
228     enddo
229     c
230     c All done adding layers - if we need more to make numlevphys, put
231     c them as thin (1 mb) layers near the top
232     if(nlphys.lt.numlevphys)then
233     nlevs = numlevphys-nlphys
234     dpphys(i,j,nlphys,bi,bj) = dpphys(i,j,nlphys,bi,bj)-100. * nlevs
235     do Lnew = nlphys+1,numlevphys
236     dpphys(i,j,Lnew,bi,bj) = 100.
237     enddo
238     nlperdyn(i,j,Nr,bi,bj) = numlevphys
239     endif
240     c END OF LOOP OVER GRID POINTS
241 molod 1.4
242 molod 1.1 enddo
243     enddo
244 molod 1.4
245     stop
246 molod 1.1
247     return
248     end

  ViewVC Help
Powered by ViewVC 1.1.22