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

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

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


Revision 1.4 - (hide annotations) (download)
Tue Mar 30 23:44:43 2004 UTC (20 years, 2 months ago) by molod
Branch: MAIN
Changes since 1.3: +10 -9 lines
Speed up vertical interpolation - use cache better

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

  ViewVC Help
Powered by ViewVC 1.1.22