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