/[MITgcm]/MITgcm/pkg/diagnostics/prestopres.F
ViewVC logotype

Contents of /MITgcm/pkg/diagnostics/prestopres.F

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


Revision 1.4 - (show annotations) (download)
Sun Dec 24 20:15:42 2006 UTC (17 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
FILE REMOVED
vertical interpolation:
- prestopres.F moved to diagnostics_interp_p2p.F
- more flexible: p-levels are set in data.diagnostics (no longer limited
  to 3 hard coded scales)
- safer (few diagnostics options were not giving the right output).

1 C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/prestopres.F,v 1.3 2005/10/25 16:27:30 molod Exp $
2 C $Name: $
3 #include "DIAG_OPTIONS.h"
4 subroutine prestopres (qprs,qinp,pkz,pksrf,ptop,p,im,jm,lm,myThid)
5 C***********************************************************************
6 C
7 C PURPOSE
8 C To interpolate an arbitrary quantity to Specified Pressure Levels
9 C
10 C INPUT
11 C QINP .. QINP (im,jm,lm) Arbitrary Input Quantity
12 C PKZ ... PKZ (im,jm,lm) Pressure to the Kappa at Input Levels
13 C PKSRF . PKSRF(im,jm) Surface Pressure to the Kappa
14 C PTOP .. Pressure at Input-Level-Edge (1) (top of model)
15 C P ..... Output Pressure Level (mb)
16 C IM .... Longitude Dimension of Input
17 C JM .... Latitude Dimension of Input
18 C LM .... Vertical Dimension of Input
19 C
20 C OUTPUT
21 C QPRS .. QPRS (im,jm) Arbitrary Quantity at Pressure p
22 C
23 C NOTE
24 C Quantity is interpolated Linear in P**Kappa.
25 C Between PTOP**Kappa and PKZ(1), quantity is extrapolated.
26 C Between PKSRF**Kappa and PKZ(LM), quantity is extrapolated.
27 C Undefined Input quantities are not used.
28 C Finally: This routine assumes that pressure levels are counted
29 C top down -- ie, level 1 is the top, level lm is the bottom
30 C
31 C***********************************************************************
32 C
33 implicit none
34 integer i,l,im,jm,lm,myThid
35
36 _RL qprs(im,jm)
37 _RL qinp(im,jm,lm)
38 _RL pkz(im,jm,lm)
39 _RL pksrf(im,jm)
40
41 _RL ptop,p,undef,kappa,getcon
42 _RL pk,pkmin,pkmax,pktop,temp
43
44 undef = getcon('UNDEF')
45 kappa = getcon('KAPPA')
46
47 pk = p**kappa
48 if(ptop.ne.0.) then
49 pktop = ptop**kappa
50 else
51 pktop = 0.
52 endif
53
54 c Initialize to UNDEFINED
55 c -----------------------
56 do i=1,im*jm
57 qprs(i,1) = undef
58 enddo
59
60 c Interpolate to Pressure Between Input Levels
61 c --------------------------------------------
62 do L=1,lm-1
63 pkmin = pkz(1,1,L)
64 pkmax = pkz(1,1,L+1)
65
66 do i=2,im*jm
67 if( pkz(i,1,L) .lt.pkmin ) pkmin = pkz(i,1,L)
68 if( pkz(i,1,L+1).gt.pkmax ) pkmax = pkz(i,1,L+1)
69 enddo
70
71 if( pk.le.pkmax .and. pk.ge.pkmin ) then
72 do i=1,im*jm
73 if( pk.le.pkz(i,1,L+1) .and. pk.ge.pkz(i,1,L) ) then
74 temp = ( pkz(i,1,L)-pk ) / ( pkz(i,1,L)-pkz(i,1,L+1) )
75
76 if( qinp(i,1,L) .ne.undef .and.
77 . qinp(i,1,L+1).ne.undef ) then
78 qprs(i,1) = qinp(i,1,L+1)*temp + qinp(i,1,L)*(1.-temp)
79 else if( qinp(i,1,L+1).ne.undef .and. temp.ge.0.5 ) then
80 qprs(i,1) = qinp(i,1,L+1)
81 else if( qinp(i,1,L) .ne.undef .and. temp.le.0.5 ) then
82 qprs(i,1) = qinp(i,1,L)
83 endif
84
85 endif
86 enddo
87 endif
88
89 enddo
90
91 do i=1,im*jm
92 c Extrapolate to Pressure between Ptop and First Input Level
93 c ----------------------------------------------------------
94 if( pk.le.pkz(i,1,1) .and. pk.ge.pktop ) then
95 temp = ( pkz(i,1,1)-pk ) / ( pkz(i,1,1)-pkz(i,1,2) )
96
97 if( qinp(i,1,1).ne.undef .and.
98 . qinp(i,1,2).ne.undef ) then
99 qprs(i,1) = qinp(i,1,2)*temp + qinp(i,1,1)*(1.-temp)
100 else if( qinp(i,1,1).ne.undef ) then
101 qprs(i,1) = qinp(i,1,1)
102 endif
103
104 endif
105
106 c Extrapolate to Pressure between Psurf and Lowest Input Level
107 c ------------------------------------------------------------
108 if( pk.le.pksrf(i,1) .and. pk.ge.pkz(i,1,lm ) ) then
109 temp = ( pkz(i,1,lm)-pk ) / ( pkz(i,1,lm)-pkz(i,1,lm-1) )
110
111 if( qinp(i,1,lm) .ne.undef .and.
112 . qinp(i,1,lm-1).ne.undef ) then
113 qprs(i,1) = qinp(i,1,lm-1)*temp + qinp(i,1,lm)*(1.-temp)
114 else if( qinp(i,1,lm) .ne.undef ) then
115 qprs(i,1) = qinp(i,1,lm)
116 endif
117
118 endif
119 enddo
120
121 return
122 end

  ViewVC Help
Powered by ViewVC 1.1.22