/[MITgcm]/MITgcm/verification/aim.5l_LatLon/code/external_fields_load.F
ViewVC logotype

Contents of /MITgcm/verification/aim.5l_LatLon/code/external_fields_load.F

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


Revision 1.3 - (show annotations) (download)
Fri Oct 31 20:35:32 2003 UTC (20 years, 7 months ago) by edhill
Branch: MAIN
CVS Tags: branch-netcdf, checkpoint51r_post, checkpoint52b_pre, checkpoint52, checkpoint52a_post, checkpoint52b_post, checkpoint52c_post, ecco_c52_e35, checkpoint52a_pre, checkpoint51t_post, checkpoint51u_post, checkpoint51s_post
Branch point for: branch-nonh
Changes since 1.2: +2 -1 lines
 o remove all '#include "PACACKAGES_CONFIG.h"' from model/inc/* and cleanup
   the verification tests that this breaks
 o this was confirmed to work for the basic tests ("testreport -ieee") on
   shelley

1 C $Header: /u/u3/gcmpack/MITgcm/verification/aim.5l_LatLon/code/external_fields_load.F,v 1.2 2002/11/12 20:39:46 heimbach Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "CPP_OPTIONS.h"
6
7 CStartOfInterface
8 SUBROUTINE EXTERNAL_FIELDS_LOAD( myTime, myIter, myThid )
9 C /==========================================================\
10 C | SUBROUTINE EXTERNAL_FIELDS_LOAD |
11 C | o Control reading of fields from external source. |
12 C |==========================================================|
13 C | External source field loading routine. |
14 C | This routine is called every time we want to |
15 C | load a a set of external fields. The routine decides |
16 C | which fields to load and then reads them in. |
17 C | This routine needs to be customised for particular |
18 C | experiments. |
19 C | Notes |
20 C | ===== |
21 C | Two-dimensional and three-dimensional I/O are handled in |
22 C | the following way under MITgcmUV. A master thread |
23 C | performs I/O using system calls. This threads reads data |
24 C | into a temporary buffer. At present the buffer is loaded |
25 C | with the entire model domain. This is probably OK for now|
26 C | Each thread then copies data from the buffer to the |
27 C | region of the proper array it is responsible for. |
28 C | ===== |
29 C | Conversion of flux fields are described in FFIELDS.h |
30 C \==========================================================/
31 IMPLICIT NONE
32
33 C === Global variables ===
34 #include "SIZE.h"
35 #include "EEPARAMS.h"
36 #include "PARAMS.h"
37 #include "FFIELDS.h"
38 #include "GRID.h"
39 #include "DYNVARS.h"
40
41 C === Routine arguments ===
42 C myThid - Thread no. that called this routine.
43 C myTime - Simulation time
44 C myIter - Simulation timestep number
45 INTEGER myThid
46 _RL myTime
47 INTEGER myIter
48 CEndOfInterface
49
50 C === Functions ===
51 LOGICAL DIFFERENT_MULTIPLE
52 EXTERNAL DIFFERENT_MULTIPLE
53
54 C === Local arrays ===
55
56 C === Local variables ===
57 INTEGER bi,bj,i,j,intime0,intime1
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(0,*)
109 & 'S/R LOAD_INTERPOLATE_FORCING: Reading new data',myTime,myIter
110
111 IF ( zonalWindFile .NE. ' ' ) THEN
112 CALL READ_REC_XY_RS( zonalWindFile,taux0,intime0,myIter,myThid )
113 CALL READ_REC_XY_RS( zonalWindFile,taux1,intime1,myIter,myThid )
114 ENDIF
115 IF ( meridWindFile .NE. ' ' ) THEN
116 CALL READ_REC_XY_RS( meridWindFile,tauy0,intime0,myIter,myThid )
117 CALL READ_REC_XY_RS( meridWindFile,tauy1,intime1,myIter,myThid )
118 ENDIF
119 IF ( surfQFile .NE. ' ' ) THEN
120 CALL READ_REC_XY_RS( surfQFile,Qnet0,intime0,myIter,myThid )
121 CALL READ_REC_XY_RS( surfQFile,Qnet1,intime1,myIter,myThid )
122 ENDIF
123 IF ( EmPmRfile .NE. ' ' ) THEN
124 Cfixed CALL READ_REC_XY_RS( EmPmRfile,EmPmR0,intime0,myIter,myThid )
125 Cfixed CALL READ_REC_XY_RS( EmPmRfile,EmPmR1,intime1,myIter,myThid )
126 CALL READ_REC_XY_RS( EmPmRfile,EmPmR0,1,myIter,myThid )
127 CALL READ_REC_XY_RS( EmPmRfile,EmPmR1,1,myIter,myThid )
128 ENDIF
129 IF ( thetaClimFile .NE. ' ' ) THEN
130 CALL READ_REC_XY_RS( thetaClimFile,SST0,intime0,myIter,myThid )
131 CALL READ_REC_XY_RS( thetaClimFile,SST1,intime1,myIter,myThid )
132 ENDIF
133 IF ( saltClimFile .NE. ' ' ) THEN
134 CALL READ_REC_XY_RS( saltClimFile,SSS0,intime0,myIter,myThid )
135 CALL READ_REC_XY_RS( saltClimFile,SSS1,intime1,myIter,myThid )
136 ENDIF
137 #ifdef SHORTWAVE_HEATING
138 IF ( surfQswFile .NE. ' ' ) THEN
139 CALL READ_REC_XY_RS( surfQswFile,Qsw0,intime0,myIter,myThid )
140 CALL READ_REC_XY_RS( surfQswFile,Qsw1,intime1,myIter,myThid )
141 ENDIF
142 #endif
143
144 _END_MASTER(myThid)
145 C
146 _EXCH_XY_R4(SST0 , myThid )
147 _EXCH_XY_R4(SST1 , myThid )
148 _EXCH_XY_R4(SSS0 , myThid )
149 _EXCH_XY_R4(SSS1 , myThid )
150 _EXCH_XY_R4(taux0 , myThid )
151 _EXCH_XY_R4(taux1 , myThid )
152 _EXCH_XY_R4(tauy0 , myThid )
153 _EXCH_XY_R4(tauy1 , myThid )
154 _EXCH_XY_R4(Qnet0, myThid )
155 _EXCH_XY_R4(Qnet1, myThid )
156 _EXCH_XY_R4(EmPmR0, myThid )
157 _EXCH_XY_R4(EmPmR1, myThid )
158 #ifdef SHORTWAVE_HEATING
159 _EXCH_XY_R4(Qsw0, myThid )
160 _EXCH_XY_R4(Qsw1, myThid )
161 #endif
162 C
163 ENDIF
164
165 C-- Interpolate fu,fv,Qnet,EmPmR,SST,SSS,Qsw
166 DO bj = myByLo(myThid), myByHi(myThid)
167 DO bi = myBxLo(myThid), myBxHi(myThid)
168 DO j=1-Oly,sNy+Oly
169 DO i=1-Olx,sNx+Olx
170 SST(i,j,bi,bj) = bWght*SST0(i,j,bi,bj)
171 & +aWght*SST1(i,j,bi,bj)
172 SSS(i,j,bi,bj) = bWght*SSS0(i,j,bi,bj)
173 & +aWght*SSS1(i,j,bi,bj)
174 fu(i,j,bi,bj) = bWght*taux0(i,j,bi,bj)
175 & +aWght*taux1(i,j,bi,bj)
176 fv(i,j,bi,bj) = bWght*tauy0(i,j,bi,bj)
177 & +aWght*tauy1(i,j,bi,bj)
178 Qnet(i,j,bi,bj) = bWght*Qnet0(i,j,bi,bj)
179 & +aWght*Qnet1(i,j,bi,bj)
180 EmPmR(i,j,bi,bj) = bWght*EmPmR0(i,j,bi,bj)
181 & +aWght*EmPmR1(i,j,bi,bj)
182 #ifdef SHORTWAVE_HEATING
183 Qsw(i,j,bi,bj) = bWght*Qsw0(i,j,bi,bj)
184 & +aWght*Qsw1(i,j,bi,bj)
185 #endif
186 ENDDO
187 ENDDO
188 ENDDO
189 ENDDO
190
191 C-- Diagnostics
192 IF (myThid.EQ.1 .AND. myTime.LT.62208000.) THEN
193 write(0,'(a,1p7e12.4,2i6,2e12.4)')
194 & 'time,SST,SSS,fu,fv,Q,E-P,i0,i1,a,b = ',
195 & myTime,
196 & SST(1,sNy,1,1),SSS(1,sNy,1,1),
197 & fu(1,sNy,1,1),fv(1,sNy,1,1),
198 & Qnet(1,sNy,1,1),EmPmR(1,sNy,1,1),
199 & intime0,intime1,aWght,bWght
200 write(0,'(a,1p7e12.4)')
201 & 'time,fu0,fu1,fu = ',
202 & myTime,
203 & taux0(1,sNy,1,1),taux1(1,sNy,1,1),fu(1,sNy,1,1),
204 & aWght,bWght
205 ENDIF
206
207 C endif for periodicForcing
208 ENDIF
209
210 #ifdef ALLOW_AIM
211 IF ( useAIM ) THEN
212 C Update AIM bottom boundary data
213 CALL AIM_EXTERNAL_FIELDS_LOAD( myTime, myIter, myThid )
214 ENDIF
215 #endif
216
217 RETURN
218 END
219
220 SUBROUTINE LEF_ZERO( arr ,myThid )
221 C This routine simply sets the argument array to zero
222 C Used only by EXTERNAL_FIELDS_LOAD
223 IMPLICIT NONE
224 C === Global variables ===
225 #include "SIZE.h"
226 #include "EEPARAMS.h"
227 C === Arguments ===
228 _RS arr (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
229 INTEGER myThid
230 C === Local variables ===
231 INTEGER i,j,bi,bj
232
233 DO bj = myByLo(myThid), myByHi(myThid)
234 DO bi = myBxLo(myThid), myBxHi(myThid)
235 DO j=1-Oly,sNy+Oly
236 DO i=1-Olx,sNx+Olx
237 arr(i,j,bi,bj)=0.
238 ENDDO
239 ENDDO
240 ENDDO
241 ENDDO
242
243 RETURN
244 END

  ViewVC Help
Powered by ViewVC 1.1.22