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

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

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


Revision 1.2 - (show annotations) (download)
Tue Mar 30 18:53:12 2004 UTC (20 years, 2 months ago) by molod
Branch: MAIN
Changes since 1.1: +6 -4 lines
Change from p**kappa to p interpolations in vertical - speed it up

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

  ViewVC Help
Powered by ViewVC 1.1.22