1 |
C $Header: /u/gcmpack/MITgcm/model/src/ini_linear_phisurf.F,v 1.21 2012/07/13 22:07:09 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
|
7 |
CBOP |
8 |
C !ROUTINE: INI_LINEAR_PHISURF |
9 |
C !INTERFACE: |
10 |
SUBROUTINE INI_LINEAR_PHISURF( myThid ) |
11 |
|
12 |
C !DESCRIPTION: \bv |
13 |
C *==========================================================* |
14 |
C | SUBROUTINE INI_LINEAR_PHISURF |
15 |
C | o Initialise the Linear Relation Phi_surf(eta) |
16 |
C *==========================================================* |
17 |
C | Initialise -Buoyancy at surface level (Bo_surf) |
18 |
C | to setup the Linear relation: Phi_surf(eta)=Bo_surf*eta |
19 |
C | Initialise phi0surf = starting point for integrating |
20 |
C | phiHyd (= phiHyd at r=RoSurf) |
21 |
C *==========================================================* |
22 |
C \ev |
23 |
|
24 |
C !USES: |
25 |
IMPLICIT NONE |
26 |
C === Global variables === |
27 |
#include "SIZE.h" |
28 |
#include "EEPARAMS.h" |
29 |
#include "PARAMS.h" |
30 |
#include "GRID.h" |
31 |
#include "SURFACE.h" |
32 |
|
33 |
C !INPUT/OUTPUT PARAMETERS: |
34 |
C === Routine arguments === |
35 |
C myThid :: my Thread Id number |
36 |
INTEGER myThid |
37 |
|
38 |
C == Local variables in common == |
39 |
C topoHloc had to be in common for multi threading but no longer |
40 |
C needed since MDSIO now allows (2009/06/07) to write local arrays |
41 |
|
42 |
C !LOCAL VARIABLES: |
43 |
C === Local variables === |
44 |
C topoHloc :: Temporary array used to write surface topography |
45 |
C bi,bj :: tile indices |
46 |
C i,j,k :: Loop counters |
47 |
_RS topoHloc(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
48 |
INTEGER bi, bj |
49 |
INTEGER i, j, k |
50 |
_RL pLoc, rhoLoc |
51 |
_RL dPIdp |
52 |
CEOP |
53 |
|
54 |
C-- Initialisation |
55 |
#ifdef ALLOW_AUTODIFF |
56 |
DO bj=myByLo(myThid),myByHi(myThid) |
57 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
58 |
DO j=1-OLy,sNy+OLy |
59 |
DO i=1-OLx,sNx+OLx |
60 |
Bo_surf(i,j,bi,bj) = 0. _d 0 |
61 |
recip_Bo(i,j,bi,bj) = 0. _d 0 |
62 |
ENDDO |
63 |
ENDDO |
64 |
ENDDO |
65 |
ENDDO |
66 |
#endif /* ALLOW_AUTODIFF */ |
67 |
|
68 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
69 |
|
70 |
C-- Initialise -Buoyancy at surface level : Bo_surf |
71 |
C Bo_surf is defined as d/dr(Phi_surf) and set to g/z2rUnit with |
72 |
C z2rUnit = conversion factor from z-unit to r-unit: [z] * z2rUnit = [r] |
73 |
C an accurate formulation includes P_surf and T,S_ref effects on rho_surf: |
74 |
C (setting uniformLin_PhiSurf=.FALSE.): |
75 |
C z-coord (z2rUnit=1): Bo_surf = - Buoyancy |
76 |
C = g * rho_surf(Tref,Sref,pSurf_0)/rho_0 |
77 |
C p-coord (z2rUnit=rho*g): Bo_surf = 1/rho(Tref(ksurf),pSurf_0) |
78 |
C Note: on Phi_surf splitting : Non-linear Time-dependent effects on B_surf |
79 |
C [through eta & (T-tRef)_surf] are included in PhiHyd rather than in Bo_surf |
80 |
C-- |
81 |
IF ( usingZCoords ) THEN |
82 |
C- gBaro = gravity (except for External mode test with reduced gravity) |
83 |
DO bj=myByLo(myThid),myByHi(myThid) |
84 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
85 |
DO J=1-OLy,sNy+OLy |
86 |
DO I=1-OLx,sNx+OLx |
87 |
Bo_surf(I,J,bi,bj) = gBaro |
88 |
recip_Bo(I,J,bi,bj) = 1. _d 0 / gBaro |
89 |
ENDDO |
90 |
ENDDO |
91 |
ENDDO |
92 |
ENDDO |
93 |
ELSEIF ( uniformLin_PhiSurf ) THEN |
94 |
C- use a linear (in ps) uniform relation : Phi'_surf = 1/rhoConst * ps'_surf |
95 |
DO bj=myByLo(myThid),myByHi(myThid) |
96 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
97 |
DO J=1-OLy,sNy+OLy |
98 |
DO I=1-OLx,sNx+OLx |
99 |
c Bo_surf(I,J,bi,bj) = rVel2wUnit(1)*gravity |
100 |
c recip_Bo(I,J,bi,bj) = wUnit2rVel(1)*recip_gravity |
101 |
Bo_surf(I,J,bi,bj) = recip_rhoConst |
102 |
recip_Bo(I,J,bi,bj) = rhoConst |
103 |
ENDDO |
104 |
ENDDO |
105 |
ENDDO |
106 |
ENDDO |
107 |
ELSEIF ( fluidIsWater ) THEN |
108 |
DO bj=myByLo(myThid),myByHi(myThid) |
109 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
110 |
DO J=1-OLy,sNy+OLy |
111 |
DO I=1-OLx,sNx+OLx |
112 |
IF ( Ro_surf(I,J,bi,bj).GT.0. _d 0 |
113 |
& .AND. kSurfC(I,J,bi,bj).LE.Nr ) THEN |
114 |
k = kSurfC(I,J,bi,bj) |
115 |
pLoc = Ro_surf(I,J,bi,bj) |
116 |
CALL FIND_RHO_SCALAR( |
117 |
I tRef(k), sRef(k), pLoc, |
118 |
O rhoLoc, myThid ) |
119 |
IF ( rhoLoc .EQ. 0. _d 0 ) THEN |
120 |
Bo_surf(I,J,bi,bj) = 0. _d 0 |
121 |
ELSE |
122 |
Bo_surf(I,J,bi,bj) = 1. _d 0/rhoLoc |
123 |
ENDIF |
124 |
recip_Bo(I,J,bi,bj) = rhoLoc |
125 |
ELSE |
126 |
Bo_surf(I,J,bi,bj) = 0. _d 0 |
127 |
recip_Bo(I,J,bi,bj) = 0. _d 0 |
128 |
ENDIF |
129 |
ENDDO |
130 |
ENDDO |
131 |
ENDDO |
132 |
ENDDO |
133 |
ELSEIF ( fluidIsAir ) THEN |
134 |
C- use a linearized (in ps) Non-uniform relation : Bo_surf(Po_surf,tRef_surf) |
135 |
C--- Bo = d/d_p(Phi_surf) = tRef_surf*d/d_p(PI) ; PI = Cp*(p/Po)^kappa |
136 |
DO bj=myByLo(myThid),myByHi(myThid) |
137 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
138 |
DO J=1-OLy,sNy+OLy |
139 |
DO I=1-OLx,sNx+OLx |
140 |
IF ( Ro_surf(I,J,bi,bj).GT.0. _d 0 |
141 |
& .AND. kSurfC(I,J,bi,bj).LE.Nr ) THEN |
142 |
dPIdp = (atm_Cp*atm_kappa/atm_Po)* |
143 |
& (Ro_surf(I,J,bi,bj)/atm_Po)**(atm_kappa-1. _d 0) |
144 |
Bo_surf(I,J,bi,bj) = dPIdp*tRef(kSurfC(I,J,bi,bj)) |
145 |
recip_Bo(I,J,bi,bj) = 1. _d 0 / Bo_surf(I,J,bi,bj) |
146 |
ELSE |
147 |
Bo_surf(I,J,bi,bj) = 0. |
148 |
recip_Bo(I,J,bi,bj) = 0. |
149 |
ENDIF |
150 |
ENDDO |
151 |
ENDDO |
152 |
ENDDO |
153 |
ENDDO |
154 |
ELSE |
155 |
STOP 'INI_LINEAR_PHISURF: We should never reach this point!' |
156 |
ENDIF |
157 |
|
158 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
159 |
|
160 |
C-- Update overlap regions (jmc: is it really needed ?) |
161 |
_EXCH_XY_RL(Bo_surf, myThid) |
162 |
_EXCH_XY_RL(recip_Bo, myThid) |
163 |
|
164 |
IF ( usingPCoords .AND. .NOT.uniformLin_PhiSurf ) THEN |
165 |
CALL WRITE_FLD_XY_RL( 'Bo_surf',' ',Bo_surf,0,myThid) |
166 |
ENDIF |
167 |
|
168 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
169 |
|
170 |
C-- Initialise phi0surf: used for atmos. surf. P-loading (ocean, z-coord) |
171 |
C or topographic geopotential anom. (p-coord) |
172 |
|
173 |
DO bj=myByLo(myThid),myByHi(myThid) |
174 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
175 |
DO J=1-OLy,sNy+OLy |
176 |
DO I=1-OLx,sNx+OLx |
177 |
phi0surf(I,J,bi,bj) = 0. |
178 |
ENDDO |
179 |
ENDDO |
180 |
ENDDO |
181 |
ENDDO |
182 |
|
183 |
IF ( fluidIsAir .AND. topoFile.NE.' ' ) THEN |
184 |
|
185 |
#ifdef ALLOW_AUTODIFF |
186 |
STOP 'CANNOT PRESENTLY USE THIS OPTION WITH ADJOINT' |
187 |
#else |
188 |
|
189 |
C-- Compute topoH = PhiRef(Po_surf)/g ; is different from original |
190 |
C topoZ(read from file) because of truncation of Po_surf. |
191 |
C NOTE: not clear for now which topoZ needs to be saved in common block |
192 |
C-- AND set phi0surf = starting point for integrating Geopotential; |
193 |
|
194 |
CALL INI_P_GROUND( -2, |
195 |
O topoHloc, |
196 |
I Ro_surf, myThid ) |
197 |
|
198 |
|
199 |
IF (selectFindRoSurf.NE.0) THEN |
200 |
_EXCH_XY_RS(phi0surf, myThid) |
201 |
CALL WRITE_FLD_XY_RS( 'phi0surf',' ',phi0surf,0,myThid) |
202 |
ENDIF |
203 |
|
204 |
CALL WRITE_FLD_XY_RS( 'topo_H',' ',topoHloc,0,myThid) |
205 |
|
206 |
#endif /* ALLOW_AUTODIFF */ |
207 |
|
208 |
ENDIF |
209 |
|
210 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
211 |
RETURN |
212 |
END |