1 |
C $Header: $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "OBCS_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: OBCS_EXTERNAL_FIELDS_LOAD |
8 |
C !INTERFACE: |
9 |
SUBROUTINE OBCS_EXTERNAL_FIELDS_LOAD( myTime, myIter, myThid ) |
10 |
C !DESCRIPTION: \bv |
11 |
C *==========================================================* |
12 |
C | SUBROUTINE OBCS_EXTERNAL_FIELDS_LOAD |
13 |
C | o Control reading of fields from external source. |
14 |
C *==========================================================* |
15 |
C | External source field loading routine. |
16 |
C | This routine is called every time we want to |
17 |
C | load a a set of external fields. The routine decides |
18 |
C | which fields to load and then reads them in. |
19 |
C | This routine needs to be customised for particular |
20 |
C | experiments. |
21 |
C | Notes |
22 |
C | ===== |
23 |
C | Two-dimensional and three-dimensional I/O are handled in |
24 |
C | the following way under MITgcmUV. A master thread |
25 |
C | performs I/O using system calls. This threads reads data |
26 |
C | into a temporary buffer. At present the buffer is loaded |
27 |
C | with the entire model domain. This is probably OK for now |
28 |
C | Each thread then copies data from the buffer to the |
29 |
C | region of the proper array it is responsible for. |
30 |
C | ===== |
31 |
C | This routine is the complete analogue to external_fields_load, |
32 |
C | except for exchanges of forcing fields. These are done in |
33 |
C | obcs_precribe_exchanges, which is called from dynamics. |
34 |
C | - Forcing period and cycle are the same as for other fields |
35 |
C | in external forcing. |
36 |
C | - constant boundary values are also read here and not |
37 |
C | directly in obcs_init_variables (which calls obcs_calc |
38 |
C | which in turn call this routine) |
39 |
C *==========================================================* |
40 |
C \ev |
41 |
|
42 |
C !USES: |
43 |
IMPLICIT NONE |
44 |
C === Global variables === |
45 |
#include "SIZE.h" |
46 |
#include "EEPARAMS.h" |
47 |
#include "PARAMS.h" |
48 |
#include "GRID.h" |
49 |
LOGICAL DIFFERENT_MULTIPLE |
50 |
EXTERNAL DIFFERENT_MULTIPLE |
51 |
|
52 |
C !INPUT/OUTPUT PARAMETERS: |
53 |
C === Routine arguments === |
54 |
C myThid - Thread no. that called this routine. |
55 |
C myTime - Simulation time |
56 |
C myIter - Simulation timestep number |
57 |
INTEGER myThid |
58 |
_RL myTime |
59 |
INTEGER myIter |
60 |
|
61 |
#if (defined ALLOW_OBCS && defined ALLOW_OBCS_PRESCRIBE) |
62 |
C if external forcing (exf) package is enabled, all loading of external |
63 |
C fields is done by exf |
64 |
#ifndef ALLOW_EXF |
65 |
#include "OBCS.h" |
66 |
|
67 |
C !LOCAL VARIABLES: |
68 |
C === Local arrays === |
69 |
C aWght, bWght :: Interpolation weights |
70 |
INTEGER bi,bj,i,j,k,intime0,intime1 |
71 |
_RL aWght,bWght,rdt |
72 |
INTEGER nForcingPeriods,Imytm,Ifprd,Ifcyc,Iftm |
73 |
CEOP |
74 |
|
75 |
IF ( periodicExternalForcing ) THEN |
76 |
|
77 |
C Now calculate whether it is time to update the forcing arrays |
78 |
rdt=1. _d 0 / deltaTclock |
79 |
nForcingPeriods=int(externForcingCycle/externForcingPeriod+0.5) |
80 |
Imytm=int(myTime*rdt+0.5) |
81 |
Ifprd=int(externForcingPeriod*rdt+0.5) |
82 |
Ifcyc=int(externForcingCycle*rdt+0.5) |
83 |
Iftm=mod( Imytm+Ifcyc-Ifprd/2 ,Ifcyc) |
84 |
|
85 |
intime0=int(Iftm/Ifprd) |
86 |
intime1=mod(intime0+1,nForcingPeriods) |
87 |
aWght=float( Iftm-Ifprd*intime0 )/float( Ifprd ) |
88 |
bWght=1.-aWght |
89 |
|
90 |
intime0=intime0+1 |
91 |
intime1=intime1+1 |
92 |
|
93 |
IF ( |
94 |
& Iftm-Ifprd*(intime0-1) .EQ. 0 |
95 |
& .OR. myIter .EQ. nIter0 |
96 |
& ) THEN |
97 |
|
98 |
_BEGIN_MASTER(myThid) |
99 |
|
100 |
C If the above condition is met then we need to read in |
101 |
C data for the period ahead and the period behind myTime. |
102 |
WRITE(*,*) |
103 |
& 'S/R OBCS_EXTERNAL_FIELDS_LOAD: Reading new data',myTime,myIter |
104 |
|
105 |
#ifdef ALLOW_OBCS_WEST |
106 |
C Eastern boundary |
107 |
IF ( OBEuFile .NE. ' ' ) THEN |
108 |
CALL MDSREADFIELDYZ ( OBEuFile, readBinaryPrec, |
109 |
& 'RL', Nr, OBEu0, intime0, myThid ) |
110 |
CALL MDSREADFIELDXz ( OBEuFile, readBinaryPrec, |
111 |
& 'RL', Nr, OBEu1, intime0, myThid ) |
112 |
ENDIF |
113 |
IF ( OBEvFile .NE. ' ' ) THEN |
114 |
CALL MDSREADFIELDYZ ( OBEvFile, readBinaryPrec, |
115 |
& 'RL', Nr, OBEv0, intime0, myThid ) |
116 |
CALL MDSREADFIELDYZ ( OBEvFile, readBinaryPrec, |
117 |
& 'RL', Nr, OBEv1, intime0, myThid ) |
118 |
ENDIF |
119 |
IF ( OBEuFile .NE. ' ' ) THEN |
120 |
CALL MDSREADFIELDYZ ( OBEtFile, readBinaryPrec, |
121 |
& 'RL', Nr, OBEt0, intime0, myThid ) |
122 |
CALL MDSREADFIELDYZ ( OBEtFile, readBinaryPrec, |
123 |
& 'RL', Nr, OBEt1, intime0, myThid ) |
124 |
ENDIF |
125 |
IF ( OBEuFile .NE. ' ' ) THEN |
126 |
CALL MDSREADFIELDYZ ( OBEsFile, readBinaryPrec, |
127 |
& 'RL', Nr, OBEs0, intime0, myThid ) |
128 |
CALL MDSREADFIELDYZ ( OBEsFile, readBinaryPrec, |
129 |
& 'RL', Nr, OBEs1, intime0, myThid ) |
130 |
ENDIF |
131 |
#endif /* ALLOW_OBCS_WEST */ |
132 |
#ifdef ALLOW_OBCS_WEST |
133 |
C Western boundary |
134 |
IF ( OBWuFile .NE. ' ' ) THEN |
135 |
CALL MDSREADFIELDYZ ( OBWuFile, readBinaryPrec, |
136 |
& 'RL', Nr, OBWu0, intime0, myThid ) |
137 |
CALL MDSREADFIELDXz ( OBWuFile, readBinaryPrec, |
138 |
& 'RL', Nr, OBWu1, intime0, myThid ) |
139 |
ENDIF |
140 |
IF ( OBWvFile .NE. ' ' ) THEN |
141 |
CALL MDSREADFIELDYZ ( OBWvFile, readBinaryPrec, |
142 |
& 'RL', Nr, OBWv0, intime0, myThid ) |
143 |
CALL MDSREADFIELDYZ ( OBWvFile, readBinaryPrec, |
144 |
& 'RL', Nr, OBWv1, intime0, myThid ) |
145 |
ENDIF |
146 |
IF ( OBWuFile .NE. ' ' ) THEN |
147 |
CALL MDSREADFIELDYZ ( OBWtFile, readBinaryPrec, |
148 |
& 'RL', Nr, OBWt0, intime0, myThid ) |
149 |
CALL MDSREADFIELDYZ ( OBWtFile, readBinaryPrec, |
150 |
& 'RL', Nr, OBWt1, intime0, myThid ) |
151 |
ENDIF |
152 |
IF ( OBWuFile .NE. ' ' ) THEN |
153 |
CALL MDSREADFIELDYZ ( OBWsFile, readBinaryPrec, |
154 |
& 'RL', Nr, OBWs0, intime0, myThid ) |
155 |
CALL MDSREADFIELDYZ ( OBWsFile, readBinaryPrec, |
156 |
& 'RL', Nr, OBWs1, intime0, myThid ) |
157 |
ENDIF |
158 |
#endif /* ALLOW_OBCS_WEST */ |
159 |
#ifdef ALLOW_OBCS_NORTH |
160 |
C Northern boundary |
161 |
IF ( OBNuFile .NE. ' ' ) THEN |
162 |
CALL MDSREADFIELDXZ ( OBNuFile, readBinaryPrec, |
163 |
& 'RL', Nr, OBNu0, intime0, myThid ) |
164 |
CALL MDSREADFIELDXz ( OBNuFile, readBinaryPrec, |
165 |
& 'RL', Nr, OBNu1, intime0, myThid ) |
166 |
ENDIF |
167 |
IF ( OBNvFile .NE. ' ' ) THEN |
168 |
CALL MDSREADFIELDXZ ( OBNvFile, readBinaryPrec, |
169 |
& 'RL', Nr, OBNv0, intime0, myThid ) |
170 |
CALL MDSREADFIELDXZ ( OBNvFile, readBinaryPrec, |
171 |
& 'RL', Nr, OBNv1, intime0, myThid ) |
172 |
ENDIF |
173 |
IF ( OBNuFile .NE. ' ' ) THEN |
174 |
CALL MDSREADFIELDXZ ( OBNtFile, readBinaryPrec, |
175 |
& 'RL', Nr, OBNt0, intime0, myThid ) |
176 |
CALL MDSREADFIELDXZ ( OBNtFile, readBinaryPrec, |
177 |
& 'RL', Nr, OBNt1, intime0, myThid ) |
178 |
ENDIF |
179 |
IF ( OBNuFile .NE. ' ' ) THEN |
180 |
CALL MDSREADFIELDXZ ( OBNsFile, readBinaryPrec, |
181 |
& 'RL', Nr, OBNs0, intime0, myThid ) |
182 |
CALL MDSREADFIELDXZ ( OBNsFile, readBinaryPrec, |
183 |
& 'RL', Nr, OBNs1, intime0, myThid ) |
184 |
ENDIF |
185 |
#endif /* ALLOW_OBCS_NORTH */ |
186 |
#ifdef ALLOW_OBCS_SOUTH |
187 |
C Southern boundary |
188 |
IF ( OBSuFile .NE. ' ' ) THEN |
189 |
CALL MDSREADFIELDXZ ( OBSuFile, readBinaryPrec, |
190 |
& 'RL', Nr, OBSu0, intime0, myThid ) |
191 |
CALL MDSREADFIELDXz ( OBSuFile, readBinaryPrec, |
192 |
& 'RL', Nr, OBSu1, intime0, myThid ) |
193 |
ENDIF |
194 |
IF ( OBSvFile .NE. ' ' ) THEN |
195 |
CALL MDSREADFIELDXZ ( OBSvFile, readBinaryPrec, |
196 |
& 'RL', Nr, OBSv0, intime0, myThid ) |
197 |
CALL MDSREADFIELDXZ ( OBSvFile, readBinaryPrec, |
198 |
& 'RL', Nr, OBSv1, intime0, myThid ) |
199 |
ENDIF |
200 |
IF ( OBSuFile .NE. ' ' ) THEN |
201 |
CALL MDSREADFIELDXZ ( OBStFile, readBinaryPrec, |
202 |
& 'RL', Nr, OBSt0, intime0, myThid ) |
203 |
CALL MDSREADFIELDXZ ( OBStFile, readBinaryPrec, |
204 |
& 'RL', Nr, OBSt1, intime0, myThid ) |
205 |
ENDIF |
206 |
IF ( OBSuFile .NE. ' ' ) THEN |
207 |
CALL MDSREADFIELDXZ ( OBSsFile, readBinaryPrec, |
208 |
& 'RL', Nr, OBSs0, intime0, myThid ) |
209 |
CALL MDSREADFIELDXZ ( OBSsFile, readBinaryPrec, |
210 |
& 'RL', Nr, OBSs1, intime0, myThid ) |
211 |
ENDIF |
212 |
#endif /* ALLOW_OBCS_SOUTH */ |
213 |
_END_MASTER(myThid) |
214 |
C |
215 |
C At this point in external_fields_load the input fields are exchanged. |
216 |
C However, we do not have exchange routines for vertical |
217 |
C slices and they are not planned, either, so the approriate fields |
218 |
C are exchanged after the open boundary conditions have been |
219 |
C applied. (in DYNAMICS and DO_FIELDS_BLOCKING_EXCHANGES) |
220 |
C |
221 |
ENDIF |
222 |
|
223 |
C-- Interpolate OBSu, OBSv, OBSt, OBSs |
224 |
DO bj = myByLo(myThid), myByHi(myThid) |
225 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
226 |
DO K = 1, Nr |
227 |
DO j=1-Oly,sNy+Oly |
228 |
#ifdef ALLOW_OBCS_EAST |
229 |
OBEu(j,k,bi,bj) = bWght*OBEu0(j,k,bi,bj) |
230 |
& +aWght*OBEu1(j,k,bi,bj) |
231 |
OBEv(j,k,bi,bj) = bWght*OBEv0(j,k,bi,bj) |
232 |
& +aWght*OBEv1(j,k,bi,bj) |
233 |
OBEt(j,k,bi,bj) = bWght*OBEt0(j,k,bi,bj) |
234 |
& +aWght*OBEt1(j,k,bi,bj) |
235 |
OBEs(j,k,bi,bj) = bWght*OBEs0(j,k,bi,bj) |
236 |
& +aWght*OBEs1(j,k,bi,bj) |
237 |
#endif /* ALLOW_OBCS_EAST */ |
238 |
#ifdef ALLOW_OBCS_WEST |
239 |
OBWu(j,k,bi,bj) = bWght*OBWu0(j,k,bi,bj) |
240 |
& +aWght*OBWu1(j,k,bi,bj) |
241 |
OBWv(j,k,bi,bj) = bWght*OBWv0(j,k,bi,bj) |
242 |
& +aWght*OBWv1(j,k,bi,bj) |
243 |
OBWt(j,k,bi,bj) = bWght*OBWt0(j,k,bi,bj) |
244 |
& +aWght*OBWt1(j,k,bi,bj) |
245 |
OBWs(j,k,bi,bj) = bWght*OBWs0(j,k,bi,bj) |
246 |
& +aWght*OBWs1(j,k,bi,bj) |
247 |
#endif /* ALLOW_OBCS_WEST */ |
248 |
ENDDO |
249 |
DO i=1-Olx,sNx+Olx |
250 |
#ifdef ALLOW_OBCS_NORTH |
251 |
OBNu(i,k,bi,bj) = bWght*OBNu0(i,k,bi,bj) |
252 |
& +aWght*OBNu1(i,k,bi,bj) |
253 |
OBNv(i,k,bi,bj) = bWght*OBNv0(i,k,bi,bj) |
254 |
& +aWght*OBNv1(i,k,bi,bj) |
255 |
OBNt(i,k,bi,bj) = bWght*OBNt0(i,k,bi,bj) |
256 |
& +aWght*OBNt1(i,k,bi,bj) |
257 |
OBNs(i,k,bi,bj) = bWght*OBNs0(i,k,bi,bj) |
258 |
& +aWght*OBNs1(i,k,bi,bj) |
259 |
#endif /* ALLOW_OBCS_NORTH */ |
260 |
#ifdef ALLOW_OBCS_SOUTH |
261 |
OBSu(i,k,bi,bj) = bWght*OBSu0(i,k,bi,bj) |
262 |
& +aWght*OBSu1(i,k,bi,bj) |
263 |
OBSv(i,k,bi,bj) = bWght*OBSv0(i,k,bi,bj) |
264 |
& +aWght*OBSv1(i,k,bi,bj) |
265 |
OBSt(i,k,bi,bj) = bWght*OBSt0(i,k,bi,bj) |
266 |
& +aWght*OBSt1(i,k,bi,bj) |
267 |
OBSs(i,k,bi,bj) = bWght*OBSs0(i,k,bi,bj) |
268 |
& +aWght*OBSs1(i,k,bi,bj) |
269 |
#endif /* ALLOW_OBCS_SOUTH */ |
270 |
ENDDO |
271 |
ENDDO |
272 |
ENDDO |
273 |
ENDDO |
274 |
C if not periodicForcing |
275 |
ELSE |
276 |
C read boundary values once and for all |
277 |
IF ( myIter .EQ. nIter0 ) THEN |
278 |
_BEGIN_MASTER(myThid) |
279 |
C If the above condition is met then we need to read in |
280 |
C data for the period ahead and the period behind myTime. |
281 |
WRITE(*,*) |
282 |
& 'S/R OBCS_EXTERNAl_FIELDS_LOAD: Reading new data',myTime,myIter |
283 |
inTime0 = 1 |
284 |
#ifdef ALLOW_OBCS_WEST |
285 |
C Eastern boundary |
286 |
IF ( OBEuFile .NE. ' ' ) THEN |
287 |
CALL MDSREADFIELDYZ ( OBEuFile, readBinaryPrec, |
288 |
& 'RL', Nr, OBEu, inTime0, myThid ) |
289 |
ENDIF |
290 |
IF ( OBEvFile .NE. ' ' ) THEN |
291 |
CALL MDSREADFIELDYZ ( OBEvFile, readBinaryPrec, |
292 |
& 'RL', Nr, OBEv, inTime0, myThid ) |
293 |
ENDIF |
294 |
IF ( OBEuFile .NE. ' ' ) THEN |
295 |
CALL MDSREADFIELDYZ ( OBEtFile, readBinaryPrec, |
296 |
& 'RL', Nr, OBEt, inTime0, myThid ) |
297 |
ENDIF |
298 |
IF ( OBEuFile .NE. ' ' ) THEN |
299 |
CALL MDSREADFIELDYZ ( OBEsFile, readBinaryPrec, |
300 |
& 'RL', Nr, OBEs, inTime0, myThid ) |
301 |
ENDIF |
302 |
#endif /* ALLOW_OBCS_WEST */ |
303 |
#ifdef ALLOW_OBCS_WEST |
304 |
C Western boundary |
305 |
IF ( OBWuFile .NE. ' ' ) THEN |
306 |
CALL MDSREADFIELDYZ ( OBWuFile, readBinaryPrec, |
307 |
& 'RL', Nr, OBWu, inTime0, myThid ) |
308 |
ENDIF |
309 |
IF ( OBWvFile .NE. ' ' ) THEN |
310 |
CALL MDSREADFIELDYZ ( OBWvFile, readBinaryPrec, |
311 |
& 'RL', Nr, OBWv, inTime0, myThid ) |
312 |
ENDIF |
313 |
IF ( OBWuFile .NE. ' ' ) THEN |
314 |
CALL MDSREADFIELDYZ ( OBWtFile, readBinaryPrec, |
315 |
& 'RL', Nr, OBWt, inTime0, myThid ) |
316 |
ENDIF |
317 |
IF ( OBWuFile .NE. ' ' ) THEN |
318 |
CALL MDSREADFIELDYZ ( OBWsFile, readBinaryPrec, |
319 |
& 'RL', Nr, OBWs, inTime0, myThid ) |
320 |
ENDIF |
321 |
#endif /* ALLOW_OBCS_WEST */ |
322 |
#ifdef ALLOW_OBCS_NORTH |
323 |
C Northern boundary |
324 |
IF ( OBNuFile .NE. ' ' ) THEN |
325 |
CALL MDSREADFIELDXz ( OBNuFile, readBinaryPrec, |
326 |
& 'RL', Nr, OBNu, inTime0, myThid ) |
327 |
ENDIF |
328 |
IF ( OBNvFile .NE. ' ' ) THEN |
329 |
CALL MDSREADFIELDXZ ( OBNvFile, readBinaryPrec, |
330 |
& 'RL', Nr, OBNv, inTime0, myThid ) |
331 |
ENDIF |
332 |
IF ( OBNuFile .NE. ' ' ) THEN |
333 |
CALL MDSREADFIELDXZ ( OBNtFile, readBinaryPrec, |
334 |
& 'RL', Nr, OBNt, inTime0, myThid ) |
335 |
ENDIF |
336 |
IF ( OBNuFile .NE. ' ' ) THEN |
337 |
CALL MDSREADFIELDXZ ( OBNsFile, readBinaryPrec, |
338 |
& 'RL', Nr, OBNs, inTime0, myThid ) |
339 |
ENDIF |
340 |
#endif /* ALLOW_OBCS_NORTH */ |
341 |
#ifdef ALLOW_OBCS_SOUTH |
342 |
C Southern boundary |
343 |
IF ( OBSuFile .NE. ' ' ) THEN |
344 |
CALL MDSREADFIELDXz ( OBSuFile, readBinaryPrec, |
345 |
& 'RL', Nr, OBSu, inTime0, myThid ) |
346 |
ENDIF |
347 |
IF ( OBSvFile .NE. ' ' ) THEN |
348 |
CALL MDSREADFIELDXZ ( OBSvFile, readBinaryPrec, |
349 |
& 'RL', Nr, OBSv, inTime0, myThid ) |
350 |
ENDIF |
351 |
IF ( OBSuFile .NE. ' ' ) THEN |
352 |
CALL MDSREADFIELDXZ ( OBStFile, readBinaryPrec, |
353 |
& 'RL', Nr, OBSt, inTime0, myThid ) |
354 |
ENDIF |
355 |
IF ( OBSuFile .NE. ' ' ) THEN |
356 |
CALL MDSREADFIELDXZ ( OBSsFile, readBinaryPrec, |
357 |
& 'RL', Nr, OBSs, inTime0, myThid ) |
358 |
ENDIF |
359 |
#endif /* ALLOW_OBCS_SOUTH */ |
360 |
_END_MASTER(myThid) |
361 |
C endif myIter .EQ. nIter0 |
362 |
ENDIF |
363 |
C endif for periodicForcing |
364 |
ENDIF |
365 |
|
366 |
#endif /* ALLOW_EXF */ |
367 |
#endif /* ALLOw_OBCS AND ALLOW_OBCS_PRESCRIBE */ |
368 |
|
369 |
RETURN |
370 |
END |
371 |
|