1 |
C $Header: /u/gcmpack/MITgcm/verification/natl_box/code/external_fields_load.F,v 1.5.4.1 2002/11/11 21:18:03 heimbach Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: EXTERNAL_FIELDS_LOAD |
8 |
C !INTERFACE: |
9 |
SUBROUTINE EXTERNAL_FIELDS_LOAD( myTime, myIter, myThid ) |
10 |
C !DESCRIPTION: \bv |
11 |
C *==========================================================* |
12 |
C | SUBROUTINE 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 | Conversion of flux fields are described in FFIELDS.h |
32 |
C *==========================================================* |
33 |
C \ev |
34 |
|
35 |
C !USES: |
36 |
IMPLICIT NONE |
37 |
C === Global variables === |
38 |
#include "SIZE.h" |
39 |
#include "EEPARAMS.h" |
40 |
#include "PARAMS.h" |
41 |
#include "FFIELDS.h" |
42 |
#include "GRID.h" |
43 |
#include "DYNVARS.h" |
44 |
LOGICAL DIFFERENT_MULTIPLE |
45 |
EXTERNAL DIFFERENT_MULTIPLE |
46 |
|
47 |
C !INPUT/OUTPUT PARAMETERS: |
48 |
C === Routine arguments === |
49 |
C myThid - Thread no. that called this routine. |
50 |
C myTime - Simulation time |
51 |
C myIter - Simulation timestep number |
52 |
INTEGER myThid |
53 |
_RL myTime |
54 |
INTEGER myIter |
55 |
|
56 |
|
57 |
#ifndef INCLUDE_EXTERNAL_FORCING_PACKAGE |
58 |
|
59 |
C !LOCAL VARIABLES: |
60 |
C === Local arrays === |
61 |
C aWght, bWght :: Interpolation weights |
62 |
INTEGER bi,bj,i,j,intime0,intime1 |
63 |
_RL aWght,bWght,rdt |
64 |
INTEGER nForcingPeriods,Imytm,Ifprd,Ifcyc,Iftm |
65 |
CEOP |
66 |
|
67 |
IF ( periodicExternalForcing ) THEN |
68 |
|
69 |
C First call requires that we initialize everything to zero for safety |
70 |
cph has been shifted to ini_forcing.F |
71 |
cph arrays are now globally visible |
72 |
cph |
73 |
cph IF ( myIter .EQ. nIter0 ) THEN |
74 |
cph CALL LEF_ZERO( taux0 ,myThid ) |
75 |
cph CALL LEF_ZERO( tauy0 ,myThid ) |
76 |
cph CALL LEF_ZERO( Qnet0 ,myThid ) |
77 |
cph CALL LEF_ZERO( EmPmR0 ,myThid ) |
78 |
cph CALL LEF_ZERO( SST0 ,myThid ) |
79 |
cph CALL LEF_ZERO( SSS0 ,myThid ) |
80 |
cph CALL LEF_ZERO( Qsw0 ,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 |
cph CALL LEF_ZERO( Qsw1 ,myThid ) |
88 |
cph ENDIF |
89 |
|
90 |
C Now calculate whether it is time to update the forcing arrays |
91 |
rdt=1. _d 0 / deltaTclock |
92 |
nForcingPeriods=int(externForcingCycle/externForcingPeriod) |
93 |
Imytm=int(myTime*rdt) |
94 |
Ifprd=int(externForcingPeriod*rdt) |
95 |
Ifcyc=int(externForcingCycle*rdt) |
96 |
Iftm=mod( Imytm ,Ifcyc) |
97 |
|
98 |
intime0=int(Iftm/Ifprd) |
99 |
intime1=mod(intime0+1,nForcingPeriods) |
100 |
aWght=mod(myTime/externForcingPeriod,1.) |
101 |
bWght=1.-aWght |
102 |
|
103 |
intime0=intime0+1 |
104 |
intime1=intime1+1 |
105 |
|
106 |
IF ( |
107 |
& Iftm-Ifprd*(intime0-1) .EQ. 0 |
108 |
& .OR. myIter .EQ. nIter0 |
109 |
& ) THEN |
110 |
|
111 |
_BEGIN_MASTER(myThid) |
112 |
|
113 |
C If the above condition is met then we need to read in |
114 |
C data for the period ahead and the period behind myTime. |
115 |
WRITE(*,*) |
116 |
& 'S/R EXTERNAL_FIELDS_LOAD: Reading new data',myTime,myIter |
117 |
|
118 |
IF ( zonalWindFile .NE. ' ' ) THEN |
119 |
CALL MDSREADFIELD ( zonalWindFile, readBinaryPrec, |
120 |
& 'RS', 1, taux0, intime0, myThid ) |
121 |
CALL MDSREADFIELD ( zonalWindFile, readBinaryPrec, |
122 |
& 'RS', 1, taux1, intime1, myThid ) |
123 |
ENDIF |
124 |
IF ( meridWindFile .NE. ' ' ) THEN |
125 |
CALL MDSREADFIELD ( meridWindFile, readBinaryPrec, |
126 |
& 'RS', 1, tauy0, intime0, myThid ) |
127 |
CALL MDSREADFIELD ( meridWindFile, readBinaryPrec, |
128 |
& 'RS', 1, tauy1, intime1, myThid ) |
129 |
ENDIF |
130 |
IF ( surfQFile .NE. ' ' ) THEN |
131 |
CALL MDSREADFIELD ( surfQFile, readBinaryPrec, |
132 |
& 'RS', 1, Qnet0, intime0, myThid ) |
133 |
CALL MDSREADFIELD ( surfQFile, readBinaryPrec, |
134 |
& 'RS', 1, Qnet1, intime1, myThid ) |
135 |
ENDIF |
136 |
IF ( EmPmRfile .NE. ' ' ) THEN |
137 |
CALL MDSREADFIELD ( EmPmRfile, readBinaryPrec, |
138 |
& 'RS', 1, EmPmR0, intime0, myThid ) |
139 |
CALL MDSREADFIELD ( EmPmRfile, readBinaryPrec, |
140 |
& 'RS', 1, EmPmR1, intime1, myThid ) |
141 |
ENDIF |
142 |
IF ( thetaClimFile .NE. ' ' ) THEN |
143 |
CALL MDSREADFIELD ( thetaClimFile, readBinaryPrec, |
144 |
& 'RS', 1, SST0, intime0, myThid ) |
145 |
CALL MDSREADFIELD ( thetaClimFile, readBinaryPrec, |
146 |
& 'RS', 1, SST1, intime1, myThid ) |
147 |
ENDIF |
148 |
IF ( saltClimFile .NE. ' ' ) THEN |
149 |
CALL MDSREADFIELD ( saltClimFile, readBinaryPrec, |
150 |
& 'RS', 1, SSS0, intime0, myThid ) |
151 |
CALL MDSREADFIELD ( saltClimFile, readBinaryPrec, |
152 |
& 'RS', 1, SSS1, intime1, myThid ) |
153 |
ENDIF |
154 |
#ifdef SHORTWAVE_HEATING |
155 |
IF ( surfQswFile .NE. ' ' ) THEN |
156 |
CALL MDSREADFIELD ( surfQswFile, readBinaryPrec, |
157 |
& 'RS', 1, Qsw0, intime0, myThid ) |
158 |
CALL MDSREADFIELD ( surfQswFile, readBinaryPrec, |
159 |
& 'RS', 1, Qsw1, intime1, myThid ) |
160 |
ENDIF |
161 |
#endif |
162 |
|
163 |
_END_MASTER(myThid) |
164 |
C |
165 |
_EXCH_XY_R4(SST0 , myThid ) |
166 |
_EXCH_XY_R4(SST1 , myThid ) |
167 |
_EXCH_XY_R4(SSS0 , myThid ) |
168 |
_EXCH_XY_R4(SSS1 , myThid ) |
169 |
c _EXCH_XY_R4(taux0 , myThid ) |
170 |
c _EXCH_XY_R4(taux1 , myThid ) |
171 |
c _EXCH_XY_R4(tauy0 , myThid ) |
172 |
c _EXCH_XY_R4(tauy1 , myThid ) |
173 |
CALL EXCH_UV_XY_RS(taux0,tauy0,.TRUE.,myThid) |
174 |
CALL EXCH_UV_XY_RS(taux1,tauy1,.TRUE.,myThid) |
175 |
_EXCH_XY_R4(Qnet0, myThid ) |
176 |
_EXCH_XY_R4(Qnet1, myThid ) |
177 |
_EXCH_XY_R4(EmPmR0, myThid ) |
178 |
_EXCH_XY_R4(EmPmR1, myThid ) |
179 |
#ifdef SHORTWAVE_HEATING |
180 |
_EXCH_XY_R4(Qsw0, myThid ) |
181 |
_EXCH_XY_R4(Qsw1, myThid ) |
182 |
#endif |
183 |
C |
184 |
ENDIF |
185 |
|
186 |
C-- Interpolate fu,fv,Qnet,EmPmR,SST,SSS,Qsw |
187 |
DO bj = myByLo(myThid), myByHi(myThid) |
188 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
189 |
DO j=1-Oly,sNy+Oly |
190 |
DO i=1-Olx,sNx+Olx |
191 |
SST(i,j,bi,bj) = bWght*SST0(i,j,bi,bj) |
192 |
& +aWght*SST1(i,j,bi,bj) |
193 |
SSS(i,j,bi,bj) = bWght*SSS0(i,j,bi,bj) |
194 |
& +aWght*SSS1(i,j,bi,bj) |
195 |
fu(i,j,bi,bj) = -(bWght*taux0(i,j,bi,bj) |
196 |
& +aWght*taux1(i,j,bi,bj)) |
197 |
fv(i,j,bi,bj) = -(bWght*tauy0(i,j,bi,bj) |
198 |
& +aWght*tauy1(i,j,bi,bj)) |
199 |
Qnet(i,j,bi,bj) = bWght*Qnet0(i,j,bi,bj) |
200 |
& +aWght*Qnet1(i,j,bi,bj) |
201 |
EmPmR(i,j,bi,bj) = bWght*EmPmR0(i,j,bi,bj) |
202 |
& +aWght*EmPmR1(i,j,bi,bj) |
203 |
#ifdef SHORTWAVE_HEATING |
204 |
Qsw(i,j,bi,bj) = bWght*Qsw0(i,j,bi,bj) |
205 |
& +aWght*Qsw1(i,j,bi,bj) |
206 |
#endif |
207 |
ENDDO |
208 |
ENDDO |
209 |
ENDDO |
210 |
ENDDO |
211 |
|
212 |
C-- Diagnostics |
213 |
cph IF (myThid.EQ.1 .AND. myTime.LT.62208000.) THEN |
214 |
cph write(*,'(a,1p7e12.4,2i6,2e12.4)') |
215 |
cph & 'time,SST,SSS,fu,fv,Q,E-P,i0,i1,a,b = ', |
216 |
cph & myTime, |
217 |
cph & SST(1,sNy,1,1),SSS(1,sNy,1,1), |
218 |
cph & fu(1,sNy,1,1),fv(1,sNy,1,1), |
219 |
cph & Qnet(1,sNy,1,1),EmPmR(1,sNy,1,1), |
220 |
cph & intime0,intime1,aWght,bWght |
221 |
cph write(*,'(a,1p7e12.4)') |
222 |
cph & 'time,fu0,fu1,fu = ', |
223 |
cph & myTime, |
224 |
cph & taux0(1,sNy,1,1),taux1(1,sNy,1,1),fu(1,sNy,1,1), |
225 |
cph & aWght,bWght |
226 |
cph ENDIF |
227 |
|
228 |
C endif for periodicForcing |
229 |
ENDIF |
230 |
|
231 |
#endif /* INCLUDE_EXTERNAL_FORCING_PACKAGE undef */ |
232 |
|
233 |
RETURN |
234 |
END |
235 |
|
236 |
CBOP |
237 |
C !ROUTINE: LEF_ZERO |
238 |
C !INTERFACE: |
239 |
SUBROUTINE LEF_ZERO( arr ,myThid ) |
240 |
C !DESCRIPTION: \bv |
241 |
C This routine simply sets the argument array to zero |
242 |
C Used only by EXTERNAL_FIELDS_LOAD |
243 |
C \ev |
244 |
C !USES: |
245 |
IMPLICIT NONE |
246 |
C === Global variables === |
247 |
#include "SIZE.h" |
248 |
#include "EEPARAMS.h" |
249 |
C !INPUT/OUTPUT PARAMETERS: |
250 |
C === Arguments === |
251 |
_RS arr (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy) |
252 |
INTEGER myThid |
253 |
C !LOCAL VARIABLES: |
254 |
C === Local variables === |
255 |
INTEGER i,j,bi,bj |
256 |
CEOP |
257 |
|
258 |
DO bj = myByLo(myThid), myByHi(myThid) |
259 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
260 |
DO j=1-Oly,sNy+Oly |
261 |
DO i=1-Olx,sNx+Olx |
262 |
arr(i,j,bi,bj)=0. |
263 |
ENDDO |
264 |
ENDDO |
265 |
ENDDO |
266 |
ENDDO |
267 |
|
268 |
RETURN |
269 |
END |