1 |
C $Header: $ |
2 |
C $Name: $ |
3 |
|
4 |
subroutine dyn2phys(qdyn,pedyn,im1,im2,jm1,jm2,lmdyn,Nsx,Nsy, |
5 |
. idim1,idim2,jdim1,jdim2,bi,bj,windphy,pephy,Lbot,lmphy,nlperdyn, |
6 |
. flg,qphy) |
7 |
C*********************************************************************** |
8 |
C Purpose: |
9 |
C To interpolate an arbitrary quantity from the 'dynamics' eta (pstar) |
10 |
C grid to the higher resolution physics grid |
11 |
C Algorithm: |
12 |
C Routine works one layer (edge to edge pressure) at a time. |
13 |
C Dynamics -> Physics retains the dynamics layer mean value, |
14 |
C weights the field either with the profile of the physics grid |
15 |
C wind speed (for U and V fields), or uniformly (T and Q) |
16 |
C |
17 |
C Input: |
18 |
C qdyn..... [im,jm,lmdyn] Arbitrary Quantity on Input Grid |
19 |
C pedyn.... [im,jm,lmdyn+1] Pressures at bottom edges of input levels |
20 |
C im1,2 ... Limits for Longitude Dimension of Input |
21 |
C jm1,2 ... Limits for Latitude Dimension of Input |
22 |
C lmdyn.... Vertical Dimension of Input |
23 |
C Nsx...... Number of processes in x-direction |
24 |
C Nsy...... Number of processes in y-direction |
25 |
C idim1,2.. Beginning and ending i-values to calculate |
26 |
C jdim1,2.. Beginning and ending j-values to calculate |
27 |
C bi....... Index of process number in x-direction |
28 |
C bj....... Index of process number in x-direction |
29 |
C windphy.. [im,jm,lmphy] Magnitude of the wind on the output levels |
30 |
C pephy.... [im,jm,lmphy+1] Pressures at bottom edges of output levels |
31 |
C lmphy.... Vertical Dimension of Output |
32 |
C nlperdyn. [im,jm,lmdyn] Highest Physics level in each dynamics level |
33 |
C flg...... Flag to indicate field type (0 for T or Q, 1 for U or V) |
34 |
C |
35 |
C Output: |
36 |
C qphy..... [im,jm,lmphy] Quantity at output grid (physics grid) |
37 |
C |
38 |
C Notes: |
39 |
C 1) This algorithm assumes that the output (physics) grid levels |
40 |
C fit exactly into the input (dynamics) grid levels |
41 |
C*********************************************************************** |
42 |
implicit none |
43 |
#include "CPP_OPTIONS.h" |
44 |
|
45 |
integer im1, im2, jm1, jm2, lmdyn, lmphy, Nsx, Nsy, flg |
46 |
integer idim1, idim2, jdim1, jdim2, bi, bj |
47 |
_RL qdyn(im1:im2,jm1:jm2,lmdyn,Nsx,Nsy) |
48 |
_RL pedyn(im1:im2,jm1:jm2,lmdyn+1,Nsx,Nsy) |
49 |
_RL pephy(im1:im2,jm1:jm2,lmphy+1,Nsx,Nsy) |
50 |
_RL windphy(im1:im2,jm1:jm2,lmphy,Nsx,Nsy) |
51 |
integer nlperdyn(im1:im2,jm1:jm2,lmdyn,Nsx,Nsy) |
52 |
_RL qphy(im1:im2,jm1:jm2,lmphy,Nsx,Nsy) |
53 |
integer Lbot(im1:im2,jm1:jm2,Nsx,Nsy) |
54 |
|
55 |
_RL weights(im1:im2,jm1:jm2,lmphy) |
56 |
_RL dpkedyn, dpkephy, windsum, qd |
57 |
integer i,j,L,Lout1,Lout2,Lphy |
58 |
_RL getcon, kappa |
59 |
|
60 |
kappa = getcon('KAPPA') |
61 |
|
62 |
c do loop for all dynamics (input) levels |
63 |
do L = 1,lmdyn |
64 |
c do loop for all grid points |
65 |
do j = jdim1,jdim2 |
66 |
do i = idim1,idim2 |
67 |
qd = qdyn(i,j,L,bi,bj) |
68 |
c Check to make sure we are above ground - if not, do nothing |
69 |
if(L.ge.Lbot(i,j,bi,bj))then |
70 |
if(L.eq.Lbot(i,j,bi,bj)) then |
71 |
Lout1 = 0 |
72 |
else |
73 |
Lout1 = nlperdyn(i,j,L-1,bi,bj) |
74 |
endif |
75 |
Lout2 = nlperdyn(i,j,L,bi,bj) |
76 |
c for U and V fields, need to compute for the weights: |
77 |
if(flg.eq.1)then |
78 |
cinterp1 dpkedyn = (pedyn(i,j,L,bi,bj)**kappa)- |
79 |
cinterp1 (pedyn(i,j,L+1,bi,bj)**kappa) |
80 |
dpkedyn = pedyn(i,j,L,bi,bj)-pedyn(i,j,L+1,bi,bj) |
81 |
windsum = 0. |
82 |
do Lphy = Lout1+1,Lout2 |
83 |
cinterp1 dpkephy = (pephy(i,j,Lphy,bi,bj)**kappa)- |
84 |
cinterp1 (pephy(i,j,Lphy+1,bi,bj)**kappa) |
85 |
dpkephy = pephy(i,j,Lphy,bi,bj)-pephy(i,j,Lphy+1,bi,bj) |
86 |
windsum = windsum+(windphy(i,j,Lphy,bi,bj)*dpkephy)/dpkedyn |
87 |
enddo |
88 |
endif |
89 |
c do loop for all physics levels contained in this dynamics level |
90 |
do Lphy = Lout1+1,Lout2 |
91 |
weights(i,j,Lphy) = 1. |
92 |
if( (flg.eq.1).and.(windsum.ne.0.) ) |
93 |
. weights(i,j,Lphy)=windphy(i,j,Lphy,bi,bj)/windsum |
94 |
qphy(i,j,Lphy,bi,bj) = qd * weights(i,j,Lphy) |
95 |
enddo |
96 |
endif |
97 |
enddo |
98 |
enddo |
99 |
enddo |
100 |
|
101 |
return |
102 |
end |