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