/[MITgcm]/MITgcm/model/src/external_fields_load.F
ViewVC logotype

Contents of /MITgcm/model/src/external_fields_load.F

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


Revision 1.4 - (show annotations) (download)
Wed Nov 29 22:29:23 2000 UTC (23 years, 6 months ago) by adcroft
Branch: MAIN
CVS Tags: branch-atmos-merge-freeze, branch-atmos-merge-start, branch-atmos-merge-shapiro, checkpoint33, checkpoint34, branch-atmos-merge-zonalfilt, branch-atmos-merge-phase5, branch-atmos-merge-phase4, branch-atmos-merge-phase7, branch-atmos-merge-phase6, branch-atmos-merge-phase1, branch-atmos-merge-phase3, branch-atmos-merge-phase2
Branch point for: branch-atmos-merge
Changes since 1.3: +1 -4 lines
Fixed confusion about units of forcing arrays in FFIELDS.h
namely Fu,Fv,Qnet,Qsw,EmPmR:
  - Removed verification/natl_box/code/external_fields_scale.F
        (did not differ from that in model/src)
  - Changed units of fu,fv,Qnet,Qsw,EmPmR back to proper units
     (see FFIELDS.h for description)
  - Scale fu,fv,Qnet,Qsw,EmPmR when used in external_forcing_surf.F,
    kpp_calc.F and kpp_transport_t.F
  - Removed model/src/external_fields_scale.F and calls to it
  - verification/natl_box uses flux data with "atmospheric" sign so
    a special version of external_fields_load.F is used to
    change the data as it's read in. This way, the arrays
    have the right units and signs at all times tha a user could
    possibly use them.

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

  ViewVC Help
Powered by ViewVC 1.1.22