1 |
C $Header: /u/gcmpack/MITgcm/model/src/ini_depths.F,v 1.50 2011/07/19 22:33:10 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
|
7 |
CBOP |
8 |
C !ROUTINE: INI_DEPTHS |
9 |
C !INTERFACE: |
10 |
SUBROUTINE INI_DEPTHS( myThid ) |
11 |
|
12 |
C !DESCRIPTION: \bv |
13 |
C *==========================================================* |
14 |
C | SUBROUTINE INI_DEPTHS |
15 |
C | o define R_position of Lower and Surface Boundaries |
16 |
C *==========================================================* |
17 |
C |atmosphere orography: |
18 |
C | define either in term of P_topo or converted from Z_topo |
19 |
C |ocean bathymetry: |
20 |
C | The depths of the bottom of the model is specified in |
21 |
C | terms of an XY map with one depth for each column of |
22 |
C | grid cells. Depths do not have to coincide with the |
23 |
C | model levels. The model lopping algorithm makes it |
24 |
C | possible to represent arbitrary depths. |
25 |
C | The mode depths map also influences the models topology |
26 |
C | By default the model domain wraps around in X and Y. |
27 |
C | This default doubly periodic topology is "supressed" |
28 |
C | if a depth map is defined which closes off all wrap |
29 |
C | around flow. |
30 |
C *==========================================================* |
31 |
C \ev |
32 |
|
33 |
C !USES: |
34 |
IMPLICIT NONE |
35 |
C === Global variables === |
36 |
#include "SIZE.h" |
37 |
#include "EEPARAMS.h" |
38 |
#include "PARAMS.h" |
39 |
#include "GRID.h" |
40 |
#include "SURFACE.h" |
41 |
#ifdef ALLOW_MNC |
42 |
# include "MNC_PARAMS.h" |
43 |
#endif |
44 |
|
45 |
C !INPUT/OUTPUT PARAMETERS: |
46 |
C == Routine arguments == |
47 |
C myThid :: my Thread Id number |
48 |
INTEGER myThid |
49 |
|
50 |
C !LOCAL VARIABLES: |
51 |
C == Local variables == |
52 |
C iG, jG :: Global coordinate index |
53 |
C bi, bj :: Tile indices |
54 |
C i, j :: Loop counters |
55 |
C oldPrec :: Temporary used in controlling binary input dataset precision |
56 |
C msgBuf :: Informational/error message buffer |
57 |
INTEGER iG, jG |
58 |
INTEGER bi, bj |
59 |
INTEGER i, j |
60 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
61 |
CEOP |
62 |
|
63 |
IF (usingPCoords .AND. bathyFile .NE. ' ' |
64 |
& .AND. topoFile .NE. ' ' ) THEN |
65 |
WRITE(msgBuf,'(A,A)') |
66 |
& 'S/R INI_DEPTHS: both bathyFile & topoFile are specified:', |
67 |
& ' select the right one !' |
68 |
CALL PRINT_ERROR( msgBuf , myThid) |
69 |
STOP 'ABNORMAL END: S/R INI_DEPTHS' |
70 |
ENDIF |
71 |
|
72 |
C------ |
73 |
C 0) Initialize R_low and Ro_surf (define an empty domain) |
74 |
C------ |
75 |
DO bj = myByLo(myThid), myByHi(myThid) |
76 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
77 |
DO j=1-OLy,sNy+OLy |
78 |
DO i=1-OLx,sNx+OLx |
79 |
R_low(i,j,bi,bj) = 0. _d 0 |
80 |
Ro_surf(i,j,bi,bj) = 0. _d 0 |
81 |
topoZ(i,j,bi,bj) = 0. _d 0 |
82 |
ENDDO |
83 |
ENDDO |
84 |
ENDDO |
85 |
ENDDO |
86 |
|
87 |
C- Need to synchronize here before doing master-thread IO |
88 |
C this is done within IO routines => no longer needed |
89 |
c _BARRIER |
90 |
|
91 |
C------ |
92 |
C 1) Set R_low = the Lower (in r sense) boundary of the fluid column : |
93 |
C------ |
94 |
IF (usingPCoords .OR. bathyFile .EQ. ' ') THEN |
95 |
C- e.g., atmosphere : R_low = Top of atmosphere |
96 |
C- ocean : R_low = Bottom |
97 |
DO bj = myByLo(myThid), myByHi(myThid) |
98 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
99 |
DO j=1,sNy |
100 |
DO i=1,sNx |
101 |
R_low(i,j,bi,bj) = rF(Nr+1) |
102 |
ENDDO |
103 |
ENDDO |
104 |
ENDDO |
105 |
ENDDO |
106 |
ELSE |
107 |
|
108 |
#ifdef ALLOW_MNC |
109 |
IF (useMNC .AND. mnc_read_bathy) THEN |
110 |
CALL MNC_CW_ADD_VNAME('bathy', 'Cen_xy_Hn__-__-', 3,4, myThid) |
111 |
CALL MNC_FILE_CLOSE_ALL_MATCHING(bathyFile, myThid) |
112 |
CALL MNC_CW_SET_UDIM(bathyFile, 1, myThid) |
113 |
CALL MNC_CW_SET_CITER(bathyFile, 2, -1, -1, -1, myThid) |
114 |
CALL MNC_CW_SET_UDIM(bathyFile, 1, myThid) |
115 |
CALL MNC_CW_RS_R('D',bathyFile,0,0,'bathy',R_low, myThid) |
116 |
CALL MNC_FILE_CLOSE_ALL_MATCHING(bathyFile, myThid) |
117 |
CALL MNC_CW_DEL_VNAME('bathy', myThid) |
118 |
ELSE |
119 |
#endif /* ALLOW_MNC */ |
120 |
C Read the bathymetry using the mid-level I/O package read_write_rec |
121 |
C The 0 is the "iteration" argument. The 1 is the record number. |
122 |
CALL READ_REC_XY_RS( bathyFile, R_low, 1, 0, myThid ) |
123 |
C Read the bathymetry using the mid-level I/O package read_write_fld |
124 |
C The 0 is the "iteration" argument. The ' ' is an empty suffix |
125 |
c CALL READ_FLD_XY_RS( bathyFile, ' ', R_low, 0, myThid ) |
126 |
C Read the bathymetry using the low-level I/O package |
127 |
c CALL MDSREADFIELD( bathyFile, readBinaryPrec, |
128 |
c & 'RS', 1, R_low, 1, myThid ) |
129 |
|
130 |
#ifdef ALLOW_MNC |
131 |
ENDIF |
132 |
#endif /* ALLOW_MNC */ |
133 |
|
134 |
ENDIF |
135 |
C- end setup R_low in the interior |
136 |
|
137 |
C- fill in the overlap (+ BARRIER): |
138 |
_EXCH_XY_RS(R_low, myThid ) |
139 |
|
140 |
IF ( plotLevel.GE.debLevC ) THEN |
141 |
c PRINT *, ' Calling plot field', myThid |
142 |
CALL PLOT_FIELD_XYRS( R_low, 'Bottom depths (ini_depths)', |
143 |
& -1, myThid ) |
144 |
ENDIF |
145 |
c CALL WRITE_FLD_XY_RS( 'R_low' ,' ', R_low, 0,myThid) |
146 |
|
147 |
c---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
148 |
|
149 |
C------ |
150 |
C 2) Set R_surf = Surface boundary: ocean surface / ground for the atmosphere |
151 |
C------ |
152 |
|
153 |
IF ( usingPCoords .AND. bathyFile.NE.' ' ) THEN |
154 |
C------ read directly Po_surf from bathyFile (only for backward compatibility) |
155 |
|
156 |
CALL READ_REC_XY_RS( bathyFile, Ro_surf, 1, 0, myThid ) |
157 |
|
158 |
ELSEIF ( topoFile.EQ.' ' ) THEN |
159 |
C------ set default value: |
160 |
|
161 |
DO bj = myByLo(myThid), myByHi(myThid) |
162 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
163 |
DO j=1,sNy |
164 |
DO i=1,sNx |
165 |
Ro_surf(i,j,bi,bj) = rF(1) |
166 |
ENDDO |
167 |
ENDDO |
168 |
ENDDO |
169 |
ENDDO |
170 |
|
171 |
ELSE |
172 |
C------ read from file: |
173 |
|
174 |
C- read surface topography (in m) from topoFile (case topoFile.NE.' '): |
175 |
|
176 |
CALL READ_REC_XY_RS( topoFile, topoZ, 1, 0, myThid ) |
177 |
_EXCH_XY_RS( topoZ, myThid ) |
178 |
|
179 |
IF (buoyancyRelation .EQ. 'ATMOSPHERIC') THEN |
180 |
C---- |
181 |
C Convert Surface Geopotential to (reference) Surface Pressure |
182 |
C according to Tref profile, using same discretisation as in calc_phi_hyd |
183 |
C---- |
184 |
c CALL WRITE_FLD_XY_RS( 'topo_Z',' ',topoZ,0,myThid) |
185 |
|
186 |
CALL INI_P_GROUND( 2, topoZ, |
187 |
O Ro_surf, |
188 |
I myThid ) |
189 |
|
190 |
C This I/O is now done in write_grid.F |
191 |
c CALL WRITE_FLD_XY_RS( 'topo_P',' ',Ro_surf,0,myThid) |
192 |
|
193 |
ELSEIF ( buoyancyRelation.EQ.'OCEANICP' ) THEN |
194 |
|
195 |
WRITE(msgBuf,'(A,A)') 'S/R INI_DEPTHS: ', |
196 |
& 'from topoFile (in m) to ref.bottom pressure: Not yet coded' |
197 |
CALL PRINT_ERROR( msgBuf , myThid) |
198 |
STOP 'ABNORMAL END: S/R INI_DEPTHS' |
199 |
|
200 |
ELSE |
201 |
C---- |
202 |
C Direct Transfer to Ro_surf (e.g., to specify upper ocean boundary |
203 |
C below an ice-shelf - NOTE - actually not yet implemented ) |
204 |
DO bj = myByLo(myThid), myByHi(myThid) |
205 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
206 |
DO j=1,sNy |
207 |
DO i=1,sNx |
208 |
Ro_surf(i,j,bi,bj) = topoZ(i,j,bi,bj) |
209 |
ENDDO |
210 |
ENDDO |
211 |
ENDDO |
212 |
ENDDO |
213 |
|
214 |
ENDIF |
215 |
|
216 |
C------ end case "read topoFile" |
217 |
ENDIF |
218 |
|
219 |
C----- fill in the overlap (+ BARRIER): |
220 |
_EXCH_XY_RS(Ro_surf, myThid ) |
221 |
|
222 |
c---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
223 |
|
224 |
C------ |
225 |
C 3) Close the Domain (special configuration). |
226 |
C------ |
227 |
IF (usingPCoords) THEN |
228 |
DO bj = myByLo(myThid), myByHi(myThid) |
229 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
230 |
DO j=1-OLy,sNy+OLy |
231 |
DO i=1-OLx,sNx+OLx |
232 |
iG = myXGlobalLo-1+(bi-1)*sNx+i |
233 |
jG = myYGlobalLo-1+(bj-1)*sNy+j |
234 |
C Test for eastern edge |
235 |
c IF ( iG .EQ. Nx ) Ro_surf(i,j,bi,bj) = 0. |
236 |
C Test for northern edge |
237 |
c IF ( jG .EQ. Ny ) Ro_surf(i,j,bi,bj) = 0. |
238 |
C- Domain : Symetric % Eq. & closed at N & S boundaries: |
239 |
c IF ( usingSphericalPolarGrid .AND. |
240 |
c & ABS(yC(i,j,bi,bj)).GE.ABS(ygOrigin) ) |
241 |
c & Ro_surf(i,j,bi,bj) = rF(Nr+1) |
242 |
IF ( usingSphericalPolarGrid .AND. |
243 |
& ABS(yC(i,j,bi,bj)).GE.90. ) |
244 |
& Ro_surf(i,j,bi,bj) = rF(Nr+1) |
245 |
ENDDO |
246 |
ENDDO |
247 |
ENDDO |
248 |
ENDDO |
249 |
ELSE |
250 |
DO bj = myByLo(myThid), myByHi(myThid) |
251 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
252 |
DO j=1-OLy,sNy+OLy |
253 |
DO i=1-OLx,sNx+OLx |
254 |
iG = myXGlobalLo-1+(bi-1)*sNx+i |
255 |
jG = myYGlobalLo-1+(bj-1)*sNy+j |
256 |
C Test for eastern edge |
257 |
c IF ( iG .EQ. Nx ) R_low(i,j,bi,bj) = 0. |
258 |
C Test for northern edge |
259 |
c IF ( jG .EQ. Ny ) R_low(i,j,bi,bj) = 0. |
260 |
C- Domain : Symetric % Eq. & closed at N & S boundaries: |
261 |
c IF ( usingSphericalPolarGrid .AND. |
262 |
c & ABS(yC(i,j,bi,bj)).GE.ABS(ygOrigin) ) |
263 |
c & R_low(i,j,bi,bj) = rF(1) |
264 |
IF ( usingSphericalPolarGrid .AND. |
265 |
& ABS(yC(i,j,bi,bj)).GE.90. ) |
266 |
& R_low(i,j,bi,bj) = rF(1) |
267 |
ENDDO |
268 |
ENDDO |
269 |
ENDDO |
270 |
ENDDO |
271 |
ENDIF |
272 |
|
273 |
IF ( plotLevel.GE.debLevC ) THEN |
274 |
_BARRIER |
275 |
CALL PLOT_FIELD_XYRS( Ro_surf, |
276 |
& 'Surface reference r-position (ini_depths)', |
277 |
& -1, myThid ) |
278 |
ENDIF |
279 |
c CALL WRITE_FLD_XY_RS('Ro_surf',' ',Ro_surf,0,myThid) |
280 |
|
281 |
C-- Everyone else must wait for the depth to be loaded |
282 |
C- note: not necessary since all single-thread IO above are followed |
283 |
C by an EXCH (with BARRIER) + BARRIER within IO routine |
284 |
c _BARRIER |
285 |
|
286 |
#ifdef ALLOW_OBCS |
287 |
IF ( useOBCS ) THEN |
288 |
C check for inconsistent topography along boundaries and fix it |
289 |
CALL OBCS_CHECK_DEPTHS( myThid ) |
290 |
C update the overlaps |
291 |
_EXCH_XY_RS( R_low, myThid ) |
292 |
ENDIF |
293 |
#endif /* ALLOW_OBCS */ |
294 |
|
295 |
#ifdef ALLOW_EXCH2 |
296 |
C Check domain boundary (e.g., in case of missing tiles) |
297 |
CALL EXCH2_CHECK_DEPTHS( R_low, Ro_surf, myThid ) |
298 |
#endif |
299 |
|
300 |
RETURN |
301 |
END |