forked from altMITgcm/MITgcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bulkf_fields_load.F
437 lines (404 loc) · 15.8 KB
/
bulkf_fields_load.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
C $Header: /u/gcmpack/MITgcm/pkg/bulk_force/bulkf_fields_load.F,v 1.17 2011/06/07 20:45:30 jmc Exp $
C $Name: $
#include "BULK_FORCE_OPTIONS.h"
C !ROUTINE: BULKF_FIELDS_LOAD
C !INTERFACE:
SUBROUTINE BULKF_FIELDS_LOAD( myTime, myIter, myThid )
C !DESCRIPTION:
C *==========================================================*
C | SUBROUTINE BULKF_FIELDS_LOAD
C | o Control reading of fields from external source.
C *==========================================================*
C | Bulk formula External source field loading routine.
C | This routine is called every time we want to
C | load a a set of external fields. The routine decides
C | which fields to load and then reads them in.
C | This routine needs to be customised for particular
C | experiments.
C | Notes
C | =====
C | Two-dimensional and three-dimensional I/O are handled in
C | the following way under MITgcmUV. A master thread
C | performs I/O using system calls. This threads reads data
C | into a temporary buffer. At present the buffer is loaded
C | with the entire model domain. This is probably OK for now
C | Each thread then copies data from the buffer to the
C | region of the proper array it is responsible for.
C | =====
C | Conversion of flux fields are described in FFIELDS.h
C *==========================================================*
C !USES:
IMPLICIT NONE
C === Global variables ===
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#include "BULKF_PARAMS.h"
#include "BULKF.h"
C !INPUT/OUTPUT PARAMETERS:
C === Routine arguments ===
C myTime :: Simulation time
C myIter :: Simulation timestep number
C myThid :: Thread no. that called this routine.
_RL myTime
INTEGER myIter
INTEGER myThid
#ifdef ALLOW_BULK_FORCE
C !LOCAL VARIABLES:
C === Local arrays in common block ===
C bulkfRec :: time-record currently loaded (in temp arrays *[1])
C tair[01] :: Temp. for air temperature
C qair[01] :: Temp. for air specific humidity
C solar[01] :: Temp. for incoming solar radition
C flwdwn[01] :: Temp. for downward longwave flux
C cloud[01] :: Temp for cloud
C wspeed[01] :: Temp. for wind speed
C uwind[01] :: Temp. for zonal wind speed
C vwind[01] :: Temp. for meridional wind speed
C rain[01] :: Temp. for rain
C runoff[01] :: Temp. for runoff
C snow[01] :: Temp for snow
C thAir[01] :: Temp for Air potential temp. in the BL [K]
c qnetch[01] :: Temp for qnet (cheating)
C empch[01] :: Temp for empmr (cheating)
C [01] :: End points for interpolation
COMMON /BULKF_FIELDS_LOAD_I/ bulkfRec
COMMON /BULKF_FIELDS_LOAD_RS/
& tair0, tair1, qair0, qair1,
& solar0, solar1, flwdwn0, flwdwn1,
& cloud0, cloud1, wspeed0, wspeed1,
& uwind0, uwind1, vwind0, vwind1,
& rain0, rain1, runoff0, runoff1,
& snow0, snow1,
#ifdef ALLOW_FORMULA_AIM
& thAir0, thAir1,
#endif
& qnetch0, qnetch1, empch0, empch1
INTEGER bulkfRec(nSx,nSy)
_RS tair0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS tair1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS qair0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS qair1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS solar0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS solar1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS flwdwn0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS flwdwn1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS cloud0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS cloud1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS wspeed0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS wspeed1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS uwind0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS uwind1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS vwind0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS vwind1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS rain0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS rain1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS runoff0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS runoff1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS snow0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS snow1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
#ifdef ALLOW_FORMULA_AIM
_RS thAir0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS thAir1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
#endif
_RS qnetch0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS qnetch1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS empch0 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
_RS empch1 (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
C === Local variables ===
C aWght, bWght :: Interpolation weights
_RL aWght,bWght
INTEGER intimeP, intime0, intime1
INTEGER bi, bj, i, j
CEOP
IF ( periodicExternalForcing ) THEN
C First call requires that we initialize everything to zero for safety
IF ( myIter .EQ. nIter0 ) THEN
DO bj=myByLo(myThid),myByHi(myThid)
DO bi=myBxLo(myThid),myBxHi(myThid)
bulkfRec(bi,bj) = 0
DO j = 1-Oly,sNy+Oly
DO i = 1-Olx,sNx+Olx
tair0(i,j,bi,bj) = 0. _d 0
tair1(i,j,bi,bj) = 0. _d 0
qair0(i,j,bi,bj) = 0. _d 0
qair1(i,j,bi,bj) = 0. _d 0
rain0(i,j,bi,bj) = 0. _d 0
rain1(i,j,bi,bj) = 0. _d 0
solar0(i,j,bi,bj) = 0. _d 0
solar1(i,j,bi,bj) = 0. _d 0
flwdwn0(i,j,bi,bj) = 0. _d 0
flwdwn1(i,j,bi,bj) = 0. _d 0
cloud0(i,j,bi,bj) = 0. _d 0
cloud1(i,j,bi,bj) = 0. _d 0
wspeed0(i,j,bi,bj) = 0. _d 0
wspeed1(i,j,bi,bj) = 0. _d 0
uwind0(i,j,bi,bj) = 0. _d 0
uwind1(i,j,bi,bj) = 0. _d 0
vwind0(i,j,bi,bj) = 0. _d 0
vwind1(i,j,bi,bj) = 0. _d 0
runoff0(i,j,bi,bj) = 0. _d 0
runoff1(i,j,bi,bj) = 0. _d 0
snow0(i,j,bi,bj) = 0. _d 0
snow1(i,j,bi,bj) = 0. _d 0
#ifdef ALLOW_FORMULA_AIM
thAir0(i,j,bi,bj) = 0. _d 0
thAir1(i,j,bi,bj) = 0. _d 0
#endif
qnetch0(i,j,bi,bj) = 0. _d 0
qnetch1(i,j,bi,bj) = 0. _d 0
empch0(i,j,bi,bj) = 0. _d 0
empch1(i,j,bi,bj) = 0. _d 0
ENDDO
ENDDO
ENDDO
ENDDO
ENDIF
C-- Now calculate whether it is time to update the forcing arrays
CALL GET_PERIODIC_INTERVAL(
O intimeP, intime0, intime1, bWght, aWght,
I externForcingCycle, externForcingPeriod,
I deltaTclock, myTime, myThid )
bi = myBxLo(myThid)
bj = myByLo(myThid)
#ifdef ALLOW_DEBUG
IF ( debugLevel.GE.debLevB ) THEN
_BEGIN_MASTER(myThid)
WRITE(standardMessageUnit,'(A,I10,A,4I5,A,2F14.10)')
& ' BULKF_FIELDS_LOAD,', myIter,
& ' : iP,iLd,i0,i1=', intimeP,bulkfRec(bi,bj), intime0,intime1,
& ' ; Wght=', bWght, aWght
_END_MASTER(myThid)
ENDIF
#endif /* ALLOW_DEBUG */
C- Make no assumption on sequence of calls to BULKF_FIELDS_LOAD ;
C This is the correct formulation (works in Adjoint run).
IF ( intime1.NE.bulkfRec(bi,bj) ) THEN
_BARRIER
C-- If the above condition is met then we need to read in
C data for the period ahead and the period behind myTime.
IF ( debugLevel.GE.debLevZero ) THEN
_BEGIN_MASTER(myThid)
WRITE(standardMessageUnit,'(A,I10,A,2(2I5,A))')
& ' BULKF_FIELDS_LOAD, it=', myIter,
& ' : Reading new data, i0,i1=', intime0, intime1,
& ' (prev=', intimeP, bulkfRec(bi,bj), ' )'
_END_MASTER(myThid)
ENDIF
IF ( AirTempFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( AirTempFile,tair0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( AirTempFile,tair1,intime1,
& myIter,myThid )
ENDIF
IF ( AirHumidityFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( AirhumidityFile,qair0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( AirhumidityFile,qair1,intime1,
& myIter,myThid )
ENDIF
IF ( SolarFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( SolarFile,solar0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( SolarFile,solar1,intime1,
& myIter,myThid )
ENDIF
IF ( LongwaveFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( LongwaveFile,flwdwn0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( LongwaveFile,flwdwn1,intime1,
& myIter,myThid )
ENDIF
IF ( CloudFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( CloudFile,cloud0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( CloudFile,cloud1,intime1,
& myIter,myThid )
ENDIF
IF ( WSpeedFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( WSpeedFile,wspeed0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( WSpeedFile,wspeed1,intime1,
& myIter,myThid )
ENDIF
IF ( UwindFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( UWindFile,uwind0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( UWindFile,uwind1,intime1,
& myIter,myThid )
ENDIF
IF ( VwindFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( VWindFile,vwind0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( VWindFile,vwind1,intime1,
& myIter,myThid )
ENDIF
IF ( RainFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( RainFile,rain0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( RainFile,rain1,intime1,
& myIter,myThid )
ENDIF
IF ( RunoffFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( RunoffFile,runoff0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( RunoffFile,runoff1,intime1,
& myIter,myThid )
ENDIF
IF ( SnowFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( SnowFile,snow0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( SnowFile,snow1,intime1,
& myIter,myThid )
ENDIF
#ifdef ALLOW_FORMULA_AIM
IF ( airPotTempFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( airPotTempFile, thAir0, intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( airPotTempFile, thAir1, intime1,
& myIter,myThid )
ENDIF
#endif
IF ( QnetFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( QnetFile,qnetch0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( QnetFile,qnetch1,intime1,
& myIter,myThid )
ENDIF
IF ( EmPFile .NE. ' ' ) THEN
CALL READ_REC_XY_RS( EmpFile,empch0,intime0,
& myIter,myThid )
CALL READ_REC_XY_RS( EmpFile,empch1,intime1,
& myIter,myThid )
c IF ( convertEmP2rUnit.EQ.mass2rUnit ) THEN
C- EmPmR is now (after c59h) expressed in kg/m2/s (fresh water mass flux)
_BARRIER
DO bj = myByLo(myThid), myByHi(myThid)
DO bi = myBxLo(myThid), myBxHi(myThid)
DO j=1-Oly,sNy+Oly
DO i=1-Olx,sNx+Olx
empch0(i,j,bi,bj) = empch0(i,j,bi,bj)*rhoConstFresh
empch1(i,j,bi,bj) = empch1(i,j,bi,bj)*rhoConstFresh
ENDDO
ENDDO
ENDDO
ENDDO
c ENDIF
ENDIF
C note: no need for extra barrier here since EXCH contains threads synchronization
c _BARRIER
_EXCH_XY_RS(tair0 , myThid )
_EXCH_XY_RS(tair1 , myThid )
_EXCH_XY_RS(qair0 , myThid )
_EXCH_XY_RS(qair1 , myThid )
_EXCH_XY_RS(solar0, myThid )
_EXCH_XY_RS(solar1, myThid )
_EXCH_XY_RS(flwdwn0, myThid )
_EXCH_XY_RS(flwdwn1, myThid )
_EXCH_XY_RS(cloud0, myThid )
_EXCH_XY_RS(cloud1, myThid )
_EXCH_XY_RS(wspeed0, myThid )
_EXCH_XY_RS(wspeed1, myThid )
c _EXCH_XY_RS(uwind0, myThid )
c _EXCH_XY_RS(uwind1, myThid )
c _EXCH_XY_RS(vwind0, myThid )
c _EXCH_XY_RS(vwind1, myThid )
CALL EXCH_UV_AGRID_3D_RS( uwind0, vwind0, .TRUE., 1, myThid )
CALL EXCH_UV_AGRID_3D_RS( uwind1, vwind1, .TRUE., 1, myThid )
_EXCH_XY_RS(rain0, myThid )
_EXCH_XY_RS(rain1, myThid )
_EXCH_XY_RS(runoff0, myThid )
_EXCH_XY_RS(runoff1, myThid )
_EXCH_XY_RS(snow0 , myThid )
_EXCH_XY_RS(snow1 , myThid )
#ifdef ALLOW_FORMULA_AIM
IF ( useFluxFormula_AIM ) THEN
_EXCH_XY_RS( thAir0, myThid )
_EXCH_XY_RS( thAir1, myThid )
ENDIF
#endif
_EXCH_XY_RS(qnetch0, myThid )
_EXCH_XY_RS(qnetch1, myThid )
_EXCH_XY_RS(empch0, myThid )
_EXCH_XY_RS(empch1, myThid )
C- save newly loaded time-record
DO bj = myByLo(myThid), myByHi(myThid)
DO bi = myBxLo(myThid), myBxHi(myThid)
bulkfRec(bi,bj) = intime1
ENDDO
ENDDO
C-- end if-block for loading new time-records
ENDIF
C-- Interpolate TAIR, QAIR, RAIN, SOLAR
DO bj = myByLo(myThid), myByHi(myThid)
DO bi = myBxLo(myThid), myBxHi(myThid)
DO j=1-Oly,sNy+Oly
DO i=1-Olx,sNx+Olx
Cswdblkf -- QQQQQ check if tair is K or C ------
C -- dasilva data in C, ncep data in K ---
TAIR(i,j,bi,bj) = bWght*tair0(i,j,bi,bj)
& +aWght*tair1(i,j,bi,bj)
c +273.15 _d 0
Cswdblkf -- QQQQQ set to kg.kg??? ---
C -- dasilva data in g, ncep in kg ---
QAIR(i,j,bi,bj) =(bWght*qair0(i,j,bi,bj)
& +aWght*qair1(i,j,bi,bj) )
SOLAR(i,j,bi,bj) = bWght*solar0(i,j,bi,bj)
& +aWght*solar1(i,j,bi,bj)
FLWDWN(i,j,bi,bj) = bWght*flwdwn0(i,j,bi,bj)
& +aWght*flwdwn1(i,j,bi,bj)
CLOUD(i,j,bi,bj) = bWght*cloud0(i,j,bi,bj)
& +aWght*cloud1(i,j,bi,bj)
WSPEED(i,j,bi,bj) = bWght*wspeed0(i,j,bi,bj)
& +aWght*wspeed1(i,j,bi,bj)
UWIND(i,j,bi,bj) = bWght*uwind0(i,j,bi,bj)
& +aWght*uwind1(i,j,bi,bj)
VWIND(i,j,bi,bj) = bWght*vwind0(i,j,bi,bj)
& +aWght*vwind1(i,j,bi,bj)
RAIN(i,j,bi,bj) = bWght*rain0(i,j,bi,bj)
& +aWght*rain1(i,j,bi,bj)
RUNOFF(i,j,bi,bj) = bWght*runoff0(i,j,bi,bj)
& +aWght*runoff1(i,j,bi,bj)
c#ifdef ALLOW_THSICE
c SNOW(i,j,bi,bj) = bWght*snow0(i,j,bi,bj)
c & +aWght*snow1(i,j,bi,bj)
c#endif
Qnetch(i,j,bi,bj) = bWght*qnetch0(i,j,bi,bj)
& +aWght*qnetch1(i,j,bi,bj)
EmPch(i,j,bi,bj) = bWght*empch0(i,j,bi,bj)
& +aWght*empch1(i,j,bi,bj)
ENDDO
ENDDO
#ifdef ALLOW_FORMULA_AIM
IF ( useFluxFormula_AIM ) THEN
DO j=1-Oly,sNy+Oly
DO i=1-Olx,sNx+Olx
thAir(i,j,bi,bj) = bWght*thAir0(i,j,bi,bj)
& + aWght*thAir1(i,j,bi,bj)
ENDDO
ENDDO
ENDIF
#endif
ENDDO
ENDDO
C- jmc: not needed since local fields have been exchanged.
c _EXCH_XY_RL(tair , myThid )
C-- Diagnostics
c IF (myThid.EQ.1 .AND. myTime.LT.62208000.) THEN
c write(*,'(a,1p5e12.4,2i6,2e12.4)')
c & 'time,TAIR,QAIR,RAIN,SOLAR,i0,i1,a,b = ',
c & myTime,
c & TAIR(1,sNy,1,1),QAIR(1,sNy,1,1),
c & RAIN(1,sNy,1,1),SOLAR(1,sNy,1,1),
c & intime0,intime1,aWght,bWght
c write(*,'(a,1p4e12.4,2e12.4)')
c & 'time,tair0,tair1,TAIR = ',
c & myTime,
c & tair0(1,sNy,1,1),tair1(1,sNy,1,1),TAIR(1,sNy,1,1),
c & aWght,bWght
c ENDIF
C endif for periodicForcing
ENDIF
#endif /*ALLOW_BULK_FORCE*/
RETURN
END