1 |
C $Header: /u/gcmpack/MITgcm/model/src/external_fields_load.F,v 1.13 2003/10/16 15:47:57 edhill Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
6 |
|
7 |
CBOP |
8 |
C !ROUTINE: EXTERNAL_FIELDS_LOAD |
9 |
C !INTERFACE: |
10 |
SUBROUTINE EXTERNAL_FIELDS_LOAD( myTime, myIter, myThid ) |
11 |
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
13 |
C | SUBROUTINE EXTERNAL_FIELDS_LOAD |
14 |
C | o Control reading of fields from external source. |
15 |
C *==========================================================* |
16 |
C | External source field loading routine. |
17 |
C | This routine is called every time we want to |
18 |
C | load a a set of external fields. The routine decides |
19 |
C | which fields to load and then reads them in. |
20 |
C | This routine needs to be customised for particular |
21 |
C | experiments. |
22 |
C | Notes |
23 |
C | ===== |
24 |
C | Two-dimensional and three-dimensional I/O are handled in |
25 |
C | the following way under MITgcmUV. A master thread |
26 |
C | performs I/O using system calls. This threads reads data |
27 |
C | into a temporary buffer. At present the buffer is loaded |
28 |
C | with the entire model domain. This is probably OK for now |
29 |
C | Each thread then copies data from the buffer to the |
30 |
C | region of the proper array it is responsible for. |
31 |
C | ===== |
32 |
C | Conversion of flux fields are described in FFIELDS.h |
33 |
C *==========================================================* |
34 |
C \ev |
35 |
|
36 |
C !USES: |
37 |
IMPLICIT NONE |
38 |
C === Global variables === |
39 |
#include "SIZE.h" |
40 |
#include "EEPARAMS.h" |
41 |
#include "PARAMS.h" |
42 |
#include "FFIELDS.h" |
43 |
#include "GRID.h" |
44 |
#include "DYNVARS.h" |
45 |
LOGICAL DIFFERENT_MULTIPLE |
46 |
EXTERNAL DIFFERENT_MULTIPLE |
47 |
|
48 |
C !INPUT/OUTPUT PARAMETERS: |
49 |
C === Routine arguments === |
50 |
C myThid - Thread no. that called this routine. |
51 |
C myTime - Simulation time |
52 |
C myIter - Simulation timestep number |
53 |
INTEGER myThid |
54 |
_RL myTime |
55 |
INTEGER myIter |
56 |
|
57 |
|
58 |
#ifndef INCLUDE_EXTERNAL_FORCING_PACKAGE |
59 |
|
60 |
C !LOCAL VARIABLES: |
61 |
C === Local arrays === |
62 |
C aWght, bWght :: Interpolation weights |
63 |
INTEGER bi,bj,i,j,intime0,intime1 |
64 |
_RL aWght,bWght,rdt |
65 |
INTEGER nForcingPeriods,Imytm,Ifprd,Ifcyc,Iftm |
66 |
CEOP |
67 |
|
68 |
IF ( periodicExternalForcing ) THEN |
69 |
|
70 |
C First call requires that we initialize everything to zero for safety |
71 |
cph has been shifted to ini_forcing.F |
72 |
cph arrays are now globally visible |
73 |
cph |
74 |
cph IF ( myIter .EQ. nIter0 ) THEN |
75 |
cph CALL LEF_ZERO( taux0 ,myThid ) |
76 |
cph CALL LEF_ZERO( tauy0 ,myThid ) |
77 |
cph CALL LEF_ZERO( Qnet0 ,myThid ) |
78 |
cph CALL LEF_ZERO( EmPmR0 ,myThid ) |
79 |
cph CALL LEF_ZERO( SST0 ,myThid ) |
80 |
cph CALL LEF_ZERO( SSS0 ,myThid ) |
81 |
cph CALL LEF_ZERO( taux1 ,myThid ) |
82 |
cph CALL LEF_ZERO( tauy1 ,myThid ) |
83 |
cph CALL LEF_ZERO( Qnet1 ,myThid ) |
84 |
cph CALL LEF_ZERO( EmPmR1 ,myThid ) |
85 |
cph CALL LEF_ZERO( SST1 ,myThid ) |
86 |
cph CALL LEF_ZERO( SSS1 ,myThid ) |
87 |
#ifdef ATMOSPHERIC_LOADING |
88 |
cph CALL LEF_ZERO( pload0 ,myThid ) |
89 |
cph CALL LEF_ZERO( pload1 ,myThid ) |
90 |
#endif |
91 |
#ifdef SHORTWAVE_HEATING |
92 |
cph CALL LEF_ZERO( Qsw0 ,myThid ) |
93 |
cph CALL LEF_ZERO( Qsw1 ,myThid ) |
94 |
#endif |
95 |
cph ENDIF |
96 |
|
97 |
C Now calculate whether it is time to update the forcing arrays |
98 |
rdt=1. _d 0 / deltaTclock |
99 |
nForcingPeriods=int(externForcingCycle/externForcingPeriod+0.5) |
100 |
Imytm=int(myTime*rdt+0.5) |
101 |
Ifprd=int(externForcingPeriod*rdt+0.5) |
102 |
Ifcyc=int(externForcingCycle*rdt+0.5) |
103 |
Iftm=mod( Imytm+Ifcyc-Ifprd/2 ,Ifcyc) |
104 |
|
105 |
intime0=int(Iftm/Ifprd) |
106 |
intime1=mod(intime0+1,nForcingPeriods) |
107 |
aWght=float( Iftm-Ifprd*intime0 )/float( Ifprd ) |
108 |
bWght=1.-aWght |
109 |
|
110 |
intime0=intime0+1 |
111 |
intime1=intime1+1 |
112 |
|
113 |
IF ( |
114 |
& Iftm-Ifprd*(intime0-1) .EQ. 0 |
115 |
& .OR. myIter .EQ. nIter0 |
116 |
& ) THEN |
117 |
|
118 |
_BEGIN_MASTER(myThid) |
119 |
|
120 |
C If the above condition is met then we need to read in |
121 |
C data for the period ahead and the period behind myTime. |
122 |
WRITE(*,*) |
123 |
& 'S/R EXTERNAL_FIELDS_LOAD: Reading new data',myTime,myIter |
124 |
|
125 |
IF ( zonalWindFile .NE. ' ' ) THEN |
126 |
CALL MDSREADFIELD ( zonalWindFile, readBinaryPrec, |
127 |
& 'RS', 1, taux0, intime0, myThid ) |
128 |
CALL MDSREADFIELD ( zonalWindFile, readBinaryPrec, |
129 |
& 'RS', 1, taux1, intime1, myThid ) |
130 |
ENDIF |
131 |
IF ( meridWindFile .NE. ' ' ) THEN |
132 |
CALL MDSREADFIELD ( meridWindFile, readBinaryPrec, |
133 |
& 'RS', 1, tauy0, intime0, myThid ) |
134 |
CALL MDSREADFIELD ( meridWindFile, readBinaryPrec, |
135 |
& 'RS', 1, tauy1, intime1, myThid ) |
136 |
ENDIF |
137 |
IF ( surfQFile .NE. ' ' ) THEN |
138 |
CALL MDSREADFIELD ( surfQFile, readBinaryPrec, |
139 |
& 'RS', 1, Qnet0, intime0, myThid ) |
140 |
CALL MDSREADFIELD ( surfQFile, readBinaryPrec, |
141 |
& 'RS', 1, Qnet1, intime1, myThid ) |
142 |
ENDIF |
143 |
IF ( EmPmRfile .NE. ' ' ) THEN |
144 |
CALL MDSREADFIELD ( EmPmRfile, readBinaryPrec, |
145 |
& 'RS', 1, EmPmR0, intime0, myThid ) |
146 |
CALL MDSREADFIELD ( EmPmRfile, readBinaryPrec, |
147 |
& 'RS', 1, EmPmR1, intime1, myThid ) |
148 |
ENDIF |
149 |
IF ( thetaClimFile .NE. ' ' ) THEN |
150 |
CALL MDSREADFIELD ( thetaClimFile, readBinaryPrec, |
151 |
& 'RS', 1, SST0, intime0, myThid ) |
152 |
CALL MDSREADFIELD ( thetaClimFile, readBinaryPrec, |
153 |
& 'RS', 1, SST1, intime1, myThid ) |
154 |
ENDIF |
155 |
IF ( saltClimFile .NE. ' ' ) THEN |
156 |
CALL MDSREADFIELD ( saltClimFile, readBinaryPrec, |
157 |
& 'RS', 1, SSS0, intime0, myThid ) |
158 |
CALL MDSREADFIELD ( saltClimFile, readBinaryPrec, |
159 |
& 'RS', 1, SSS1, intime1, myThid ) |
160 |
ENDIF |
161 |
#ifdef SHORTWAVE_HEATING |
162 |
IF ( surfQswFile .NE. ' ' ) THEN |
163 |
CALL MDSREADFIELD ( surfQswFile, readBinaryPrec, |
164 |
& 'RS', 1, Qsw0, intime0, myThid ) |
165 |
CALL MDSREADFIELD ( surfQswFile, readBinaryPrec, |
166 |
& 'RS', 1, Qsw1, intime1, myThid ) |
167 |
ENDIF |
168 |
#endif |
169 |
#ifdef ATMOSPHERIC_LOADING |
170 |
IF ( pLoadFile .NE. ' ' ) THEN |
171 |
CALL MDSREADFIELD ( pLoadFile, readBinaryPrec, |
172 |
& 'RS', 1, pload0, intime0, myThid ) |
173 |
CALL MDSREADFIELD ( pLoadFile, readBinaryPrec, |
174 |
& 'RS', 1, pload1, intime1, myThid ) |
175 |
ENDIF |
176 |
#endif |
177 |
|
178 |
_END_MASTER(myThid) |
179 |
C |
180 |
_EXCH_XY_R4(SST0 , myThid ) |
181 |
_EXCH_XY_R4(SST1 , myThid ) |
182 |
_EXCH_XY_R4(SSS0 , myThid ) |
183 |
_EXCH_XY_R4(SSS1 , myThid ) |
184 |
c _EXCH_XY_R4(taux0 , myThid ) |
185 |
c _EXCH_XY_R4(taux1 , myThid ) |
186 |
c _EXCH_XY_R4(tauy0 , myThid ) |
187 |
c _EXCH_XY_R4(tauy1 , myThid ) |
188 |
CALL EXCH_UV_XY_RS(taux0,tauy0,.TRUE.,myThid) |
189 |
CALL EXCH_UV_XY_RS(taux1,tauy1,.TRUE.,myThid) |
190 |
_EXCH_XY_R4(Qnet0, myThid ) |
191 |
_EXCH_XY_R4(Qnet1, myThid ) |
192 |
_EXCH_XY_R4(EmPmR0, myThid ) |
193 |
_EXCH_XY_R4(EmPmR1, myThid ) |
194 |
#ifdef SHORTWAVE_HEATING |
195 |
_EXCH_XY_R4(Qsw0, myThid ) |
196 |
_EXCH_XY_R4(Qsw1, myThid ) |
197 |
#endif |
198 |
#ifdef ATMOSPHERIC_LOADING |
199 |
_EXCH_XY_R4(pload0, myThid ) |
200 |
_EXCH_XY_R4(pload1, myThid ) |
201 |
#endif |
202 |
C |
203 |
ENDIF |
204 |
|
205 |
C-- Interpolate fu,fv,Qnet,EmPmR,SST,SSS,Qsw |
206 |
DO bj = myByLo(myThid), myByHi(myThid) |
207 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
208 |
DO j=1-Oly,sNy+Oly |
209 |
DO i=1-Olx,sNx+Olx |
210 |
SST(i,j,bi,bj) = bWght*SST0(i,j,bi,bj) |
211 |
& +aWght*SST1(i,j,bi,bj) |
212 |
SSS(i,j,bi,bj) = bWght*SSS0(i,j,bi,bj) |
213 |
& +aWght*SSS1(i,j,bi,bj) |
214 |
fu(i,j,bi,bj) = bWght*taux0(i,j,bi,bj) |
215 |
& +aWght*taux1(i,j,bi,bj) |
216 |
fv(i,j,bi,bj) = bWght*tauy0(i,j,bi,bj) |
217 |
& +aWght*tauy1(i,j,bi,bj) |
218 |
Qnet(i,j,bi,bj) = bWght*Qnet0(i,j,bi,bj) |
219 |
& +aWght*Qnet1(i,j,bi,bj) |
220 |
EmPmR(i,j,bi,bj) = bWght*EmPmR0(i,j,bi,bj) |
221 |
& +aWght*EmPmR1(i,j,bi,bj) |
222 |
saltFlux(i,j,bi,bj) = 0. _d 0 |
223 |
#ifdef SHORTWAVE_HEATING |
224 |
Qsw(i,j,bi,bj) = bWght*Qsw0(i,j,bi,bj) |
225 |
& +aWght*Qsw1(i,j,bi,bj) |
226 |
#endif |
227 |
#ifdef ATMOSPHERIC_LOADING |
228 |
pload(i,j,bi,bj) = bWght*pload0(i,j,bi,bj) |
229 |
& +aWght*pload1(i,j,bi,bj) |
230 |
#endif |
231 |
ENDDO |
232 |
ENDDO |
233 |
ENDDO |
234 |
ENDDO |
235 |
|
236 |
C-- Diagnostics |
237 |
IF (myThid.EQ.1 .AND. myTime.LT.62208000.) THEN |
238 |
write(*,'(a,1p7e12.4,2i6,2e12.4)') |
239 |
& 'time,SST,SSS,fu,fv,Q,E-P,i0,i1,a,b = ', |
240 |
& myTime, |
241 |
& SST(1,sNy,1,1),SSS(1,sNy,1,1), |
242 |
& fu(1,sNy,1,1),fv(1,sNy,1,1), |
243 |
& Qnet(1,sNy,1,1),EmPmR(1,sNy,1,1), |
244 |
& intime0,intime1,aWght,bWght |
245 |
write(*,'(a,1p7e12.4)') |
246 |
& 'time,fu0,fu1,fu = ', |
247 |
& myTime, |
248 |
& taux0(1,sNy,1,1),taux1(1,sNy,1,1),fu(1,sNy,1,1), |
249 |
& aWght,bWght |
250 |
ENDIF |
251 |
|
252 |
C endif for periodicForcing |
253 |
ENDIF |
254 |
|
255 |
#endif /* INCLUDE_EXTERNAL_FORCING_PACKAGE undef */ |
256 |
|
257 |
RETURN |
258 |
END |
259 |
|
260 |
CBOP |
261 |
C !ROUTINE: LEF_ZERO |
262 |
C !INTERFACE: |
263 |
SUBROUTINE LEF_ZERO( arr ,myThid ) |
264 |
C !DESCRIPTION: \bv |
265 |
C This routine simply sets the argument array to zero |
266 |
C Used only by EXTERNAL_FIELDS_LOAD |
267 |
C \ev |
268 |
C !USES: |
269 |
IMPLICIT NONE |
270 |
C === Global variables === |
271 |
#include "SIZE.h" |
272 |
#include "EEPARAMS.h" |
273 |
C !INPUT/OUTPUT PARAMETERS: |
274 |
C === Arguments === |
275 |
_RS arr (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
276 |
INTEGER myThid |
277 |
C !LOCAL VARIABLES: |
278 |
C === Local variables === |
279 |
INTEGER i,j,bi,bj |
280 |
CEOP |
281 |
|
282 |
DO bj = myByLo(myThid), myByHi(myThid) |
283 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
284 |
DO j=1-Oly,sNy+Oly |
285 |
DO i=1-Olx,sNx+Olx |
286 |
arr(i,j,bi,bj)=0. |
287 |
ENDDO |
288 |
ENDDO |
289 |
ENDDO |
290 |
ENDDO |
291 |
|
292 |
RETURN |
293 |
END |