/[MITgcm]/MITgcm/verification/natl_box/code/external_fields_load.F
ViewVC logotype

Contents of /MITgcm/verification/natl_box/code/external_fields_load.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download)
Sat Nov 1 04:50:03 2003 UTC (20 years, 6 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint53f_post, checkpoint54a_pre, checkpoint53b_pre, checkpoint52l_pre, checkpoint52e_pre, checkpoint52j_post, checkpoint52e_post, checkpoint53c_post, checkpoint53d_post, checkpoint52j_pre, checkpoint54a_post, branch-netcdf, checkpoint51r_post, checkpoint52b_pre, checkpoint52n_post, checkpoint54b_post, checkpoint52m_post, checkpoint53a_post, checkpoint53b_post, checkpoint52l_post, checkpoint52k_post, checkpoint54, checkpoint53, checkpoint52, checkpoint52d_post, checkpoint52a_post, checkpoint52b_post, checkpoint53g_post, checkpoint52f_post, checkpoint52c_post, ecco_c52_e35, checkpoint52a_pre, checkpoint51t_post, checkpoint53d_pre, checkpoint52i_post, checkpoint52i_pre, checkpoint51u_post, checkpoint52h_pre, checkpoint52f_pre, checkpoint51s_post
Branch point for: netcdf-sm0, branch-nonh
Changes since 1.7: +3 -3 lines
 o convert all "INCLUDE_EXTERNAL_FORCING_PACKAGE" defines to the
   more consistent ALLOW_EXF
 o passed all the basic verification tests on shelley

1 C $Header: /u/u3/gcmpack/MITgcm/verification/natl_box/code/external_fields_load.F,v 1.7 2003/10/30 17:35:31 jmc 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 ALLOW_EXF
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( Qsw0 ,myThid )
82 cph CALL LEF_ZERO( taux1 ,myThid )
83 cph CALL LEF_ZERO( tauy1 ,myThid )
84 cph CALL LEF_ZERO( Qnet1 ,myThid )
85 cph CALL LEF_ZERO( EmPmR1 ,myThid )
86 cph CALL LEF_ZERO( SST1 ,myThid )
87 cph CALL LEF_ZERO( SSS1 ,myThid )
88 cph CALL LEF_ZERO( Qsw1 ,myThid )
89 cph ENDIF
90
91 C Now calculate whether it is time to update the forcing arrays
92 rdt=1. _d 0 / deltaTclock
93 nForcingPeriods=int(externForcingCycle/externForcingPeriod)
94 Imytm=int(myTime*rdt)
95 Ifprd=int(externForcingPeriod*rdt)
96 Ifcyc=int(externForcingCycle*rdt)
97 Iftm=mod( Imytm ,Ifcyc)
98
99 intime0=int(Iftm/Ifprd)
100 intime1=mod(intime0+1,nForcingPeriods)
101 aWght=mod(myTime/externForcingPeriod,1.)
102 bWght=1.-aWght
103
104 intime0=intime0+1
105 intime1=intime1+1
106
107 IF (
108 & Iftm-Ifprd*(intime0-1) .EQ. 0
109 & .OR. myIter .EQ. nIter0
110 & ) THEN
111
112 _BEGIN_MASTER(myThid)
113
114 C If the above condition is met then we need to read in
115 C data for the period ahead and the period behind myTime.
116 WRITE(*,*)
117 & 'S/R EXTERNAL_FIELDS_LOAD: Reading new data',myTime,myIter
118
119 IF ( zonalWindFile .NE. ' ' ) THEN
120 CALL MDSREADFIELD ( zonalWindFile, readBinaryPrec,
121 & 'RS', 1, taux0, intime0, myThid )
122 CALL MDSREADFIELD ( zonalWindFile, readBinaryPrec,
123 & 'RS', 1, taux1, intime1, myThid )
124 ENDIF
125 IF ( meridWindFile .NE. ' ' ) THEN
126 CALL MDSREADFIELD ( meridWindFile, readBinaryPrec,
127 & 'RS', 1, tauy0, intime0, myThid )
128 CALL MDSREADFIELD ( meridWindFile, readBinaryPrec,
129 & 'RS', 1, tauy1, intime1, myThid )
130 ENDIF
131 IF ( surfQFile .NE. ' ' ) THEN
132 CALL MDSREADFIELD ( surfQFile, readBinaryPrec,
133 & 'RS', 1, Qnet0, intime0, myThid )
134 CALL MDSREADFIELD ( surfQFile, readBinaryPrec,
135 & 'RS', 1, Qnet1, intime1, myThid )
136 ENDIF
137 IF ( EmPmRfile .NE. ' ' ) THEN
138 CALL MDSREADFIELD ( EmPmRfile, readBinaryPrec,
139 & 'RS', 1, EmPmR0, intime0, myThid )
140 CALL MDSREADFIELD ( EmPmRfile, readBinaryPrec,
141 & 'RS', 1, EmPmR1, intime1, myThid )
142 ENDIF
143 IF ( thetaClimFile .NE. ' ' ) THEN
144 CALL MDSREADFIELD ( thetaClimFile, readBinaryPrec,
145 & 'RS', 1, SST0, intime0, myThid )
146 CALL MDSREADFIELD ( thetaClimFile, readBinaryPrec,
147 & 'RS', 1, SST1, intime1, myThid )
148 ENDIF
149 IF ( saltClimFile .NE. ' ' ) THEN
150 CALL MDSREADFIELD ( saltClimFile, readBinaryPrec,
151 & 'RS', 1, SSS0, intime0, myThid )
152 CALL MDSREADFIELD ( saltClimFile, readBinaryPrec,
153 & 'RS', 1, SSS1, intime1, myThid )
154 ENDIF
155 #ifdef SHORTWAVE_HEATING
156 IF ( surfQswFile .NE. ' ' ) THEN
157 CALL MDSREADFIELD ( surfQswFile, readBinaryPrec,
158 & 'RS', 1, Qsw0, intime0, myThid )
159 CALL MDSREADFIELD ( surfQswFile, readBinaryPrec,
160 & 'RS', 1, Qsw1, intime1, myThid )
161 ENDIF
162 #endif
163
164 _END_MASTER(myThid)
165 C
166 _EXCH_XY_R4(SST0 , myThid )
167 _EXCH_XY_R4(SST1 , myThid )
168 _EXCH_XY_R4(SSS0 , myThid )
169 _EXCH_XY_R4(SSS1 , myThid )
170 c _EXCH_XY_R4(taux0 , myThid )
171 c _EXCH_XY_R4(taux1 , myThid )
172 c _EXCH_XY_R4(tauy0 , myThid )
173 c _EXCH_XY_R4(tauy1 , myThid )
174 CALL EXCH_UV_XY_RS(taux0,tauy0,.TRUE.,myThid)
175 CALL EXCH_UV_XY_RS(taux1,tauy1,.TRUE.,myThid)
176 _EXCH_XY_R4(Qnet0, myThid )
177 _EXCH_XY_R4(Qnet1, myThid )
178 _EXCH_XY_R4(EmPmR0, myThid )
179 _EXCH_XY_R4(EmPmR1, myThid )
180 #ifdef SHORTWAVE_HEATING
181 _EXCH_XY_R4(Qsw0, myThid )
182 _EXCH_XY_R4(Qsw1, myThid )
183 #endif
184 C
185 ENDIF
186
187 C-- Interpolate fu,fv,Qnet,EmPmR,SST,SSS,Qsw
188 DO bj = myByLo(myThid), myByHi(myThid)
189 DO bi = myBxLo(myThid), myBxHi(myThid)
190 DO j=1-Oly,sNy+Oly
191 DO i=1-Olx,sNx+Olx
192 SST(i,j,bi,bj) = bWght*SST0(i,j,bi,bj)
193 & +aWght*SST1(i,j,bi,bj)
194 SSS(i,j,bi,bj) = bWght*SSS0(i,j,bi,bj)
195 & +aWght*SSS1(i,j,bi,bj)
196 fu(i,j,bi,bj) = -(bWght*taux0(i,j,bi,bj)
197 & +aWght*taux1(i,j,bi,bj))
198 fv(i,j,bi,bj) = -(bWght*tauy0(i,j,bi,bj)
199 & +aWght*tauy1(i,j,bi,bj))
200 Qnet(i,j,bi,bj) = bWght*Qnet0(i,j,bi,bj)
201 & +aWght*Qnet1(i,j,bi,bj)
202 EmPmR(i,j,bi,bj) = bWght*EmPmR0(i,j,bi,bj)
203 & +aWght*EmPmR1(i,j,bi,bj)
204 #ifdef SHORTWAVE_HEATING
205 Qsw(i,j,bi,bj) = bWght*Qsw0(i,j,bi,bj)
206 & +aWght*Qsw1(i,j,bi,bj)
207 #endif
208 ENDDO
209 ENDDO
210 ENDDO
211 ENDDO
212
213 C-- Diagnostics
214 cph IF (myThid.EQ.1 .AND. myTime.LT.62208000.) THEN
215 cph write(*,'(a,1p7e12.4,2i6,2e12.4)')
216 cph & 'time,SST,SSS,fu,fv,Q,E-P,i0,i1,a,b = ',
217 cph & myTime,
218 cph & SST(1,sNy,1,1),SSS(1,sNy,1,1),
219 cph & fu(1,sNy,1,1),fv(1,sNy,1,1),
220 cph & Qnet(1,sNy,1,1),EmPmR(1,sNy,1,1),
221 cph & intime0,intime1,aWght,bWght
222 cph write(*,'(a,1p7e12.4)')
223 cph & 'time,fu0,fu1,fu = ',
224 cph & myTime,
225 cph & taux0(1,sNy,1,1),taux1(1,sNy,1,1),fu(1,sNy,1,1),
226 cph & aWght,bWght
227 cph ENDIF
228
229 C endif for periodicForcing
230 ENDIF
231
232 #endif /* ALLOW_EXF */
233
234 RETURN
235 END
236
237 CBOP
238 C !ROUTINE: LEF_ZERO
239 C !INTERFACE:
240 SUBROUTINE LEF_ZERO( arr ,myThid )
241 C !DESCRIPTION: \bv
242 C This routine simply sets the argument array to zero
243 C Used only by EXTERNAL_FIELDS_LOAD
244 C \ev
245 C !USES:
246 IMPLICIT NONE
247 C === Global variables ===
248 #include "SIZE.h"
249 #include "EEPARAMS.h"
250 C !INPUT/OUTPUT PARAMETERS:
251 C === Arguments ===
252 _RS arr (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
253 INTEGER myThid
254 C !LOCAL VARIABLES:
255 C === Local variables ===
256 INTEGER i,j,bi,bj
257 CEOP
258
259 DO bj = myByLo(myThid), myByHi(myThid)
260 DO bi = myBxLo(myThid), myBxHi(myThid)
261 DO j=1-Oly,sNy+Oly
262 DO i=1-Olx,sNx+Olx
263 arr(i,j,bi,bj)=0.
264 ENDDO
265 ENDDO
266 ENDDO
267 ENDDO
268
269 RETURN
270 END

  ViewVC Help
Powered by ViewVC 1.1.22