1 |
|
2 |
#include "CPP_OPTIONS.h" |
3 |
#include "OFFLINE_OPTIONS.h" |
4 |
|
5 |
C !ROUTINE: OFFLINE_FIELDS_LOAD |
6 |
C !INTERFACE: |
7 |
SUBROUTINE OFFLINE_FIELDS_LOAD( myTime, myIter, myThid ) |
8 |
C *==========================================================* |
9 |
C | SUBROUTINE OFFLINE_FIELDS_LOAD |
10 |
C | o Control reading of fields from external source. |
11 |
C *==========================================================* |
12 |
C | Offline External source field loading routine. |
13 |
C | This routine is called every time we want to |
14 |
C | load a a set of external fields. The routine decides |
15 |
C | which fields to load and then reads them in. |
16 |
C | This routine needs to be customised for particular |
17 |
C | experiments. |
18 |
C | Notes |
19 |
C | ===== |
20 |
C | Two-dimensional and three-dimensional I/O are handled in |
21 |
C | the following way under MITgcmUV. A master thread |
22 |
C | performs I/O using system calls. This threads reads data |
23 |
C | into a temporary buffer. At present the buffer is loaded |
24 |
C | with the entire model domain. This is probably OK for now |
25 |
C | Each thread then copies data from the buffer to the |
26 |
C | region of the proper array it is responsible for. |
27 |
C | ===== |
28 |
C | Conversion of flux fields are described in FFIELDS.h |
29 |
C *==========================================================* |
30 |
|
31 |
C !USES: |
32 |
IMPLICIT NONE |
33 |
C === Global variables === |
34 |
#include "SIZE.h" |
35 |
#include "EEPARAMS.h" |
36 |
#include "PARAMS.h" |
37 |
#include "FFIELDS.h" |
38 |
#include "GRID.h" |
39 |
#include "DYNVARS.h" |
40 |
#ifdef ALLOW_GMREDI |
41 |
#include "GMREDI.h" |
42 |
#include "GMREDI_DIAGS.h" |
43 |
#endif |
44 |
#ifdef ALLOW_OFFLINE |
45 |
#include "OFFLINE.h" |
46 |
#endif |
47 |
|
48 |
LOGICAL DIFFERENT_MULTIPLE |
49 |
EXTERNAL DIFFERENT_MULTIPLE |
50 |
|
51 |
C !INPUT/OUTPUT PARAMETERS: |
52 |
C === Routine arguments === |
53 |
C myThid - Thread no. that called this routine. |
54 |
C myTime - Simulation time |
55 |
C myIter - Simulation timestep number |
56 |
INTEGER myThid |
57 |
_RL myTime |
58 |
INTEGER myIter |
59 |
|
60 |
c fn :: Temp. for building file name. |
61 |
CHARACTER*(MAX_LEN_FNAM) fn |
62 |
INTEGER prec |
63 |
|
64 |
|
65 |
|
66 |
C !LOCAL VARIABLES: |
67 |
C === Local arrays === |
68 |
C uvel[01] :: Temp. for u |
69 |
C vvel[01] :: Temp. for v |
70 |
C wvel[01] :: Temp. for w |
71 |
c conv[01] :: Temp for Convection Count |
72 |
C [01] :: End points for interpolation |
73 |
C Above use static heap storage to allow exchange. |
74 |
C aWght, bWght :: Interpolation weights |
75 |
COMMON /OFFLINEFFIELDS/ |
76 |
& uvel0, vvel0, wvel0, tave0, save0, |
77 |
& conv0, |
78 |
& uvel1, vvel1, wvel1, tave1, save1, |
79 |
& conv1 |
80 |
_RS uvel0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
81 |
_RS uvel1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
82 |
_RS vvel0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
83 |
_RS vvel1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
84 |
_RS wvel0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
85 |
_RS wvel1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
86 |
_RS tave0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
87 |
_RS tave1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
88 |
_RS save0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
89 |
_RS save1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
90 |
_RS conv0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
91 |
_RS conv1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
92 |
_RS gmkx0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
93 |
_RS gmkx1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
94 |
_RS gmky0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
95 |
_RS gmky1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
96 |
_RS gmkz0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
97 |
_RS gmkz1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
98 |
c _RS tmp (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
99 |
_RL tmp |
100 |
_RL sfac (1-OLy:sNy+OLy,nSy) |
101 |
|
102 |
|
103 |
INTEGER bi,bj,i,j,k,intime0,intime1 |
104 |
_RL aWght,bWght,rdt, KGM |
105 |
INTEGER nForcingPeriods,Imytm,Ifprd,Ifcyc,Iftm |
106 |
|
107 |
#ifdef ALLOW_OFFLINE |
108 |
CALL TIMER_START('OFFLINE_FIELDS_LOAD [I/O]', myThid) |
109 |
prec = precFloat32 |
110 |
KGM=1.d0 |
111 |
|
112 |
IF ( periodicExternalForcing ) THEN |
113 |
|
114 |
C First call requires that we initialize everything to zero for safety |
115 |
IF ( myIter .EQ. nIter0 ) THEN |
116 |
CALL LEF_ZERO3( uvel0 ,myThid ) |
117 |
CALL LEF_ZERO3( vvel0 ,myThid ) |
118 |
CALL LEF_ZERO3( wvel0 ,myThid ) |
119 |
CALL LEF_ZERO3( tave0 ,myThid ) |
120 |
CALL LEF_ZERO3( save0 ,myThid ) |
121 |
CALL LEF_ZERO3( conv0 ,myThid ) |
122 |
CALL LEF_ZERO3( gmkx0 ,myThid ) |
123 |
CALL LEF_ZERO3( gmky0 ,myThid ) |
124 |
CALL LEF_ZERO3( gmkz0 ,myThid ) |
125 |
CALL LEF_ZERO3( uvel1 ,myThid ) |
126 |
CALL LEF_ZERO3( vvel1 ,myThid ) |
127 |
CALL LEF_ZERO3( wvel1 ,myThid ) |
128 |
CALL LEF_ZERO3( tave1 ,myThid ) |
129 |
CALL LEF_ZERO3( save1 ,myThid ) |
130 |
CALL LEF_ZERO3( conv1 ,myThid ) |
131 |
CALL LEF_ZERO3( gmkx1 ,myThid ) |
132 |
CALL LEF_ZERO3( gmky1 ,myThid ) |
133 |
CALL LEF_ZERO3( gmkz1 ,myThid ) |
134 |
|
135 |
ENDIF |
136 |
|
137 |
C Now calculate whether it is time to update the forcing arrays |
138 |
rdt=1. _d 0 / deltaTclock |
139 |
nForcingPeriods=int(offlineForcingCycle/offlineForcingPeriod+0.5) |
140 |
Imytm=int(myTime*rdt+0.5) |
141 |
Ifprd=int(offlineForcingPeriod*rdt+0.5) |
142 |
Ifcyc=int(offlineForcingCycle*rdt+0.5) |
143 |
Iftm=mod( Imytm+Ifcyc-Ifprd/2 ,Ifcyc) |
144 |
|
145 |
intime0=int(Iftm/Ifprd) |
146 |
intime1=mod(intime0+1,nForcingPeriods) |
147 |
aWght=float( Iftm-Ifprd*intime0 )/float( Ifprd ) |
148 |
bWght=1.-aWght |
149 |
|
150 |
intime0=intime0+1 |
151 |
INTIME1=intime1+1 |
152 |
|
153 |
IF ( |
154 |
& Iftm-Ifprd*(intime0-1) .EQ. 0 |
155 |
& .OR. myIter .EQ. nIter0 |
156 |
& ) THEN |
157 |
|
158 |
_BEGIN_MASTER(myThid) |
159 |
|
160 |
C If the above condition is met then we need to read in |
161 |
C data for the period ahead and the period behind myTime. |
162 |
WRITE(*,*) |
163 |
& 'S/R OFFLINE_FIELDS_LOAD: Reading new data',myTime,myIter |
164 |
& , nIter0, intime0,intime1 |
165 |
|
166 |
#ifdef NOT_MODEL_FILES |
167 |
c if reading own files setup reading here |
168 |
#else |
169 |
c |
170 |
IF ( Uvelfile .NE. ' ' ) THEN |
171 |
WRITE(fn,'(A,I10.10)') 'uVeltave.',intime0*Ifprd+offlineIter0 |
172 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,uvel0, 1,myThid) |
173 |
WRITE(fn,'(A,I10.10)') 'uVeltave.',intime1*Ifprd+offlineIter0 |
174 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,uvel1, 1,myThid) |
175 |
ENDIF |
176 |
c |
177 |
IF ( Vvelfile .NE. ' ' ) THEN |
178 |
WRITE(fn,'(A,I10.10)') 'vVeltave.',intime0*Ifprd+offlineIter0 |
179 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,vvel0, 1,myThid) |
180 |
WRITE(fn,'(A,I10.10)') 'vVeltave.',intime1*Ifprd+offlineIter0 |
181 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,vvel1, 1,myThid) |
182 |
ENDIF |
183 |
c |
184 |
IF (Wvelfile .NE. ' ' ) THEN |
185 |
WRITE(fn,'(A,I10.10)') 'wVeltave.',intime0*Ifprd+offlineIter0 |
186 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,wvel0, 1,myThid) |
187 |
WRITE(fn,'(A,I10.10)') 'wVeltave.',intime1*Ifprd+offlineIter0 |
188 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,wvel1, 1,myThid) |
189 |
ENDIF |
190 |
|
191 |
IF (Thetfile .NE. ' ' ) THEN |
192 |
WRITE(fn,'(A,I10.10)') 'Ttave.',intime0*Ifprd+offlineIter0 |
193 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,tave0, 1,myThid) |
194 |
WRITE(fn,'(A,I10.10)') 'Ttave.',intime1*Ifprd+offlineIter0 |
195 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,tave1, 1,myThid) |
196 |
ENDIF |
197 |
|
198 |
IF (Saltfile .NE. ' ' ) THEN |
199 |
WRITE(fn,'(A,I10.10)') 'Stave.',intime0*Ifprd+offlineIter0 |
200 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,save0, 1,myThid) |
201 |
WRITE(fn,'(A,I10.10)') 'Stave.',intime1*Ifprd+offlineIter0 |
202 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,save1, 1,myThid) |
203 |
ENDIF |
204 |
|
205 |
IF (ConvFile .NE. ' ' ) THEN |
206 |
WRITE(fn,'(A,I10.10)') 'Convtave.',intime0*Ifprd+offlineIter0 |
207 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,conv0, 1,myThid) |
208 |
WRITE(fn,'(A,I10.10)') 'Convtave.',intime1*Ifprd+offlineIter0 |
209 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,conv1, 1,myThid) |
210 |
ENDIF |
211 |
c |
212 |
|
213 |
IF (GMwxFile .NE. ' ' ) THEN |
214 |
WRITE(fn,'(A,I10.10)') 'GM_Kwx-T.',intime0*Ifprd+offlineIter0 |
215 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,gmkx0, 1,myThid) |
216 |
WRITE(fn,'(A,I10.10)') 'GM_Kwx-T.',intime1*Ifprd+offlineIter0 |
217 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,gmkx1, 1,myThid) |
218 |
ENDIF |
219 |
|
220 |
IF (GMwyFile .NE. ' ') THEN |
221 |
WRITE(fn,'(A,I10.10)') 'GM_Kwy-T.',intime0*Ifprd+offlineIter0 |
222 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,gmky0, 1,myThid) |
223 |
WRITE(fn,'(A,I10.10)') 'GM_Kwy-T.',intime1*Ifprd+offlineIter0 |
224 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,gmky1, 1,myThid) |
225 |
ENDIF |
226 |
c |
227 |
IF (GMwzFile .NE. ' ') THEN |
228 |
WRITE(fn,'(A,I10.10)') 'GM_Kwz-T.',intime0*Ifprd+offlineIter0 |
229 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,gmkz0, 1,myThid) |
230 |
WRITE(fn,'(A,I10.10)') 'GM_Kwz-T.',intime1*Ifprd+offlineIter0 |
231 |
CALL MDSREADFIELD(fn,prec,'RL',Nr,gmkz1, 1,myThid) |
232 |
ENDIF |
233 |
|
234 |
#endif /* NOT_MODEL_FILES */ |
235 |
|
236 |
_END_MASTER(myThid) |
237 |
|
238 |
C |
239 |
_EXCH_XYZ_R4(uvel0 , myThid ) |
240 |
_EXCH_XYZ_R4(uvel1 , myThid ) |
241 |
_EXCH_XYZ_R4(vvel0 , myThid ) |
242 |
_EXCH_XYZ_R4(vvel1 , myThid ) |
243 |
_EXCH_XYZ_R4(wvel0, myThid ) |
244 |
_EXCH_XYZ_R4(wvel1, myThid ) |
245 |
_EXCH_XYZ_R4(tave0 , myThid ) |
246 |
_EXCH_XYZ_R4(tave1 , myThid ) |
247 |
_EXCH_XYZ_R4(save0, myThid ) |
248 |
_EXCH_XYZ_R4(save1, myThid ) |
249 |
_EXCH_XYZ_R4(conv0, myThid ) |
250 |
_EXCH_XYZ_R4(conv1, myThid ) |
251 |
_EXCH_XYZ_R4(gmkx0, myThid ) |
252 |
_EXCH_XYZ_R4(gmkx1, myThid ) |
253 |
_EXCH_XYZ_R4(gmky0 , myThid ) |
254 |
_EXCH_XYZ_R4(gmky1 , myThid ) |
255 |
_EXCH_XYZ_R4(gmkz0, myThid ) |
256 |
_EXCH_XYZ_R4(gmkz1, myThid ) |
257 |
|
258 |
c |
259 |
ENDIF |
260 |
c |
261 |
|
262 |
C-- Interpolate uvel, vvel, wvel |
263 |
DO bj = myByLo(myThid), myByHi(myThid) |
264 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
265 |
do k=1,Nr |
266 |
DO j=1-Oly,sNy+Oly |
267 |
DO i=1-Olx,sNx+Olx |
268 |
Uvel(i,j,k,bi,bj) = bWght*uvel0(i,j,k,bi,bj) |
269 |
& +aWght*uvel1(i,j,k,bi,bj) |
270 |
Vvel(i,j,k,bi,bj) = bWght*vvel0(i,j,k,bi,bj) |
271 |
& +aWght*vvel1(i,j,k,bi,bj) |
272 |
Wvel(i,j,k,bi,bj) = bWght*wvel0(i,j,k,bi,bj) |
273 |
& +aWght*wvel1(i,j,k,bi,bj) |
274 |
theta(i,j,k,bi,bj) = bWght*tave0(i,j,k,bi,bj) |
275 |
& +aWght*tave1(i,j,k,bi,bj) |
276 |
salt(i,j,k,bi,bj) = bWght*save0(i,j,k,bi,bj) |
277 |
& +aWght*save1(i,j,k,bi,bj) |
278 |
ConvectCount(i,j,k,bi,bj) = bWght*conv0(i,j,k,bi,bj) |
279 |
& +aWght*conv1(i,j,k,bi,bj) |
280 |
IVDConvCount(i,j,k,bi,bj) = bWght*conv0(i,j,k,bi,bj) |
281 |
& +aWght*conv1(i,j,k,bi,bj) |
282 |
#ifdef ALLOW_GMREDI |
283 |
Kwx(i,j,k,bi,bj) = bWght*gmkx0(i,j,k,bi,bj) |
284 |
& +aWght*gmkx1(i,j,k,bi,bj) |
285 |
Kwy(i,j,k,bi,bj) = bWght*gmky0(i,j,k,bi,bj) |
286 |
& +aWght*gmky1(i,j,k,bi,bj) |
287 |
Kwz(i,j,k,bi,bj) = bWght*gmkz0(i,j,k,bi,bj) |
288 |
& +aWght*gmkz1(i,j,k,bi,bj) |
289 |
#endif |
290 |
ENDDO |
291 |
ENDDO |
292 |
ENDDO |
293 |
ENDDO |
294 |
ENDDO |
295 |
|
296 |
CC-- Diagnostics |
297 |
C IF (myThid.EQ.1 .AND. myTime.LT.62208000.) THEN |
298 |
C write(*,'(a,1p5e12.4,3i6,2e12.4)') |
299 |
C & 'time,U,V,W,i0,i1,a,b = ', |
300 |
C & myTime, |
301 |
C & Uvel(1,sNy,1,1,1),Vvel(1,sNy,1,1,1), |
302 |
C & Wvel(1,sNy,1,1,1), |
303 |
C & intime0,intime1,aWght,bWght |
304 |
C write(*,'(a,1p4e12.4,2e12.4)') |
305 |
C & 'time,uvel0,uvel1,U = ', |
306 |
C & myTime, |
307 |
C & uvel0(1,sNy,1,1,1),uvel1(1,sNy,1,1,1),Uvel(1,sNy,1,1,1), |
308 |
C & aWght,bWght |
309 |
C ENDIF |
310 |
|
311 |
C endif for periodicForcing |
312 |
ENDIF |
313 |
|
314 |
#endif |
315 |
c! ALLOW_OFFLINE |
316 |
|
317 |
RETURN |
318 |
END |
319 |
|
320 |
C !ROUTINE: LEF_ZERO3 |
321 |
C !INTERFACE: |
322 |
SUBROUTINE LEF_ZERO3( arr ,myThid ) |
323 |
C !DESCRIPTION: \bv |
324 |
C This routine simply sets the argument array to zero |
325 |
C Used only by EXTERNAL_FIELDS_LOAD |
326 |
C \ev |
327 |
C !USES: |
328 |
IMPLICIT NONE |
329 |
C === Global variables === |
330 |
#include "SIZE.h" |
331 |
#include "EEPARAMS.h" |
332 |
C !INPUT/OUTPUT PARAMETERS: |
333 |
C === Arguments === |
334 |
_RS arr (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
335 |
INTEGER myThid |
336 |
C !LOCAL VARIABLES: |
337 |
C === Local variables === |
338 |
INTEGER i,j,bi,bj,k |
339 |
CEOP |
340 |
|
341 |
DO bj = myByLo(myThid), myByHi(myThid) |
342 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
343 |
do k=1,Nr |
344 |
DO j=1-Oly,sNy+Oly |
345 |
DO i=1-Olx,sNx+Olx |
346 |
arr(i,j,k,bi,bj)=0. |
347 |
ENDDO |
348 |
ENDDO |
349 |
enddo |
350 |
ENDDO |
351 |
ENDDO |
352 |
CALL TIMER_STOP ('OFFLINE_FIELDS_LOAD [I/O]', myThid) |
353 |
|
354 |
RETURN |
355 |
END |
356 |
|