/[MITgcm]/MITgcm/pkg/rbcs/rbcs_fields_load.F
ViewVC logotype

Annotation of /MITgcm/pkg/rbcs/rbcs_fields_load.F

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


Revision 1.13 - (hide annotations) (download)
Wed Apr 20 01:42:53 2011 UTC (13 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62w, checkpoint62x
Changes since 1.12: +61 -84 lines
call S/R GET_PERIODIC_INTERVAL to get interp. weights and time record number

1 jmc 1.13 C $Header: /u/gcmpack/MITgcm/pkg/rbcs/rbcs_fields_load.F,v 1.12 2011/03/06 23:33:55 jmc Exp $
2 jmc 1.6 C $Name: $
3 stephd 1.1
4 jmc 1.10 #include "RBCS_OPTIONS.h"
5 jmc 1.6
6 stephd 1.1 C !ROUTINE: RBCS_FIELDS_LOAD
7     C !INTERFACE:
8     SUBROUTINE RBCS_FIELDS_LOAD( myTime, myIter, myThid )
9 jmc 1.13
10     C !DESCRIPTION: \bv
11 stephd 1.1 C *==========================================================*
12 jmc 1.6 C | SUBROUTINE RBCS_FIELDS_LOAD
13     C | o Control reading of fields from external source.
14 stephd 1.1 C *==========================================================*
15 jmc 1.13 C | RBCS External source field loading routine.
16 jmc 1.6 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 stephd 1.1 C *==========================================================*
20 jmc 1.13 C \ev
21 stephd 1.1
22     C !USES:
23     IMPLICIT NONE
24     C === Global variables ===
25     #include "SIZE.h"
26     #include "EEPARAMS.h"
27     #include "PARAMS.h"
28     #include "FFIELDS.h"
29     #include "GRID.h"
30     #include "DYNVARS.h"
31     #ifdef ALLOW_PTRACERS
32     #include "PTRACERS_SIZE.h"
33 jmc 1.7 #include "PTRACERS_PARAMS.h"
34 stephd 1.1 #endif
35     #include "RBCS.h"
36    
37     C !INPUT/OUTPUT PARAMETERS:
38     C === Routine arguments ===
39 jmc 1.7 C myTime :: Simulation time
40     C myIter :: Simulation timestep number
41     C myThid :: Thread no. that called this routine.
42 stephd 1.1 _RL myTime
43     INTEGER myIter
44 jmc 1.7 INTEGER myThid
45 stephd 1.1
46 jmc 1.10 C !FUNCTIONS:
47     INTEGER IFNBLNK, ILNBLNK
48     EXTERNAL IFNBLNK, ILNBLNK
49    
50 stephd 1.1 C !LOCAL VARIABLES:
51     C === Local arrays ===
52     C [01] :: End points for interpolation
53     C Above use static heap storage to allow exchange.
54     C aWght, bWght :: Interpolation weights
55    
56 jmc 1.13 INTEGER bi, bj, i, j, k
57     INTEGER intimeP, intime0, intime1
58     _RL aWght, bWght, locTime
59     INTEGER Ifprd
60 jmc 1.10 #ifdef ALLOW_PTRACERS
61 stephd 1.1 INTEGER iTracer
62 jmc 1.10 #endif
63 jahn 1.11 INTEGER IL, initer0, initer1
64     CHARACTER*(MAX_LEN_FNAM) fullName
65 jmc 1.13 CEOP
66 stephd 1.1
67     #ifdef ALLOW_RBCS
68     CALL TIMER_START('RBCS_FIELDS_LOAD [I/O]', myThid)
69    
70 jmc 1.13 C-- First call requires that we initialize everything to zero for safety
71     C <= already done in RBCS_INIT_VARIA
72 stephd 1.1
73 jmc 1.13 C-- Now calculate whether it is time to update the forcing arrays
74     bi = myBxLo(myThid)
75     bj = myByLo(myThid)
76 jahn 1.11 IF (rbcsForcingPeriod.GT.0. _d 0) THEN
77 jmc 1.13 locTime = myTime - rbcsForcingOffset
78     CALL GET_PERIODIC_INTERVAL(
79     O intimeP, intime0, intime1, bWght, aWght,
80     I rbcsForcingCycle, rbcsForcingPeriod,
81     I deltaTclock, locTime, myThid )
82     #ifdef ALLOW_DEBUG
83     IF ( debugLevel.GE.debLevA ) THEN
84     _BEGIN_MASTER(myThid)
85     WRITE(standardMessageUnit,'(A,I10,A,4I5,A,2F14.10)')
86     & ' RBCS_FIELDS_LOAD,', myIter,
87     & ' : iP,iLd,i0,i1=', intimeP,rbcsLdRec(bi,bj), intime0,intime1,
88     & ' ; Wght=', bWght, aWght
89     _END_MASTER(myThid)
90 jahn 1.11 ENDIF
91 jmc 1.13 #endif /* ALLOW_DEBUG */
92 jmc 1.7 ELSE
93 jmc 1.13 intimeP = 1
94 jmc 1.8 intime1 = 1
95     intime0 = 1
96     aWght = .5 _d 0
97     bWght = .5 _d 0
98 jmc 1.7 ENDIF
99 stephd 1.1
100 jmc 1.13 #ifdef ALLOW_AUTODIFF_TAMC
101     C- assuming that we call S/R RBCS_FIELDS_LOAD at each time-step and
102     C with increasing time, this will catch when we need to load new records;
103     C But with Adjoint run, this is not always the case => might end-up using
104     C the wrong time-records
105     IF ( intime0.NE.intimeP .OR. myIter.EQ.nIter0 ) THEN
106     #else /* ALLOW_AUTODIFF_TAMC */
107     C- Make no assumption on sequence of calls to RBCS_FIELDS_LOAD ;
108     C This is the correct formulation (works in Adjoint run).
109     C Unfortunatly, produces many recomputations <== not used until it is fixed
110     IF ( intime1.NE.rbcsLdRec(bi,bj) ) THEN
111     #endif /* ALLOW_AUTODIFF_TAMC */
112 stephd 1.1
113 jmc 1.13 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 jmc 1.7 _BEGIN_MASTER(myThid)
116 jmc 1.13 WRITE(standardMessageUnit,'(A,I10,A,2(2I5,A))')
117     & ' RBCS_FIELDS_LOAD, it=', myIter,
118     & ' : Reading new data, i0,i1=', intime0, intime1,
119     & ' (prev=', intimeP, rbcsLdRec(bi,bj), ' )'
120 jmc 1.7 _END_MASTER(myThid)
121 stephd 1.1
122 jmc 1.13 C for rbcsSingleTimeFiles=.TRUE.
123     Ifprd = NINT(rbcsForcingPeriod/deltaTrbcs)
124     initer0 = rbcsIter0 + intime0*Ifprd
125     initer1 = rbcsIter0 + intime1*Ifprd
126    
127 jmc 1.10 IF ( useRBCtemp .AND. relaxTFile .NE. ' ' ) THEN
128 jahn 1.11 IF ( rbcsSingleTimeFiles ) THEN
129     IL=ILNBLNK( relaxTFile )
130     WRITE(fullName,'(2a,i10.10)') relaxTFile(1:IL),'.',initer0
131     CALL READ_REC_XYZ_RS(fullName, rbct0, 1, myIter, myThid)
132     WRITE(fullName,'(2a,i10.10)') relaxTFile(1:IL),'.',initer1
133     CALL READ_REC_XYZ_RS(fullName, rbct1, 1, myIter, myThid)
134     ELSE
135     CALL READ_REC_XYZ_RS(relaxTFile,rbct0,intime0,myIter,myThid)
136     CALL READ_REC_XYZ_RS(relaxTFile,rbct1,intime1,myIter,myThid)
137     ENDIF
138 stephd 1.1 ENDIF
139 jmc 1.10 IF ( useRBCsalt .AND. relaxSFile .NE. ' ' ) THEN
140 jahn 1.11 IF ( rbcsSingleTimeFiles ) THEN
141     IL=ILNBLNK( relaxSFile )
142     WRITE(fullName,'(2a,i10.10)') relaxSFile(1:IL),'.',initer0
143     CALL READ_REC_XYZ_RS(fullName, rbcs0, 1, myIter, myThid)
144     WRITE(fullName,'(2a,i10.10)') relaxSFile(1:IL),'.',initer1
145     CALL READ_REC_XYZ_RS(fullName, rbcs1, 1, myIter, myThid)
146     ELSE
147     CALL READ_REC_XYZ_RS(relaxSFile,rbcs0,intime0,myIter,myThid)
148     CALL READ_REC_XYZ_RS(relaxSFile,rbcs1,intime1,myIter,myThid)
149     ENDIF
150 stephd 1.1 ENDIF
151    
152     #ifdef ALLOW_PTRACERS
153 jmc 1.10 IF ( usePTRACERS ) THEN
154 jmc 1.7 DO iTracer = 1, PTRACERS_numInUse
155 jmc 1.10 IF ( useRBCptrnum(iTracer) .AND.
156     & relaxPtracerFile(iTracer).NE. ' ' ) THEN
157 jahn 1.11 IF ( rbcsSingleTimeFiles ) THEN
158     IL=ILNBLNK( relaxPtracerFile(iTracer) )
159     WRITE(fullName,'(2a,i10.10)') relaxPtracerFile(iTracer)(1:IL)
160     & ,'.',initer0
161     CALL READ_REC_XYZ_RS( fullName,
162     & rbcptr0(1-Olx,1-Oly,1,1,1,iTracer),
163     & 1, myIter, myThid )
164     WRITE(fullName,'(2a,i10.10)') relaxPtracerFile(iTracer)(1:IL)
165     & ,'.',initer1
166     CALL READ_REC_XYZ_RS( fullName,
167     & rbcptr1(1-Olx,1-Oly,1,1,1,iTracer),
168     & 1, myIter, myThid )
169     ELSE
170 jmc 1.7 CALL READ_REC_XYZ_RS( relaxPtracerFile(iTracer),
171     & rbcptr0(1-Olx,1-Oly,1,1,1,iTracer),
172     & intime0, myIter, myThid )
173     CALL READ_REC_XYZ_RS( relaxPtracerFile(iTracer),
174     & rbcptr1(1-Olx,1-Oly,1,1,1,iTracer),
175     & intime1, myIter, myThid )
176 jahn 1.11 ENDIF
177 jmc 1.7 ENDIF
178     ENDDO
179     ENDIF
180 stephd 1.1 #endif
181    
182 jmc 1.10 IF ( useRBCtemp .AND. relaxTFile .NE. ' ' ) THEN
183     CALL EXCH_XYZ_RS( rbct0 , myThid )
184     CALL EXCH_XYZ_RS( rbct1 , myThid )
185     ENDIF
186     IF ( useRBCsalt .AND. relaxSFile .NE. ' ' ) THEN
187     CALL EXCH_XYZ_RS( rbcs0 , myThid )
188     CALL EXCH_XYZ_RS( rbcs1 , myThid )
189     ENDIF
190 stephd 1.1 #ifdef ALLOW_PTRACERS
191 jmc 1.10 IF (usePTRACERS) THEN
192 jmc 1.7 DO iTracer = 1, PTRACERS_numInUse
193 jmc 1.10 IF ( useRBCptrnum(iTracer) ) THEN
194     CALL EXCH_XYZ_RS( rbcptr0(1-Olx,1-Oly,1,1,1,iTracer),myThid )
195     CALL EXCH_XYZ_RS( rbcptr1(1-Olx,1-Oly,1,1,1,iTracer),myThid )
196     ENDIF
197 jmc 1.7 ENDDO
198     ENDIF
199 jmc 1.10 #endif /* ALLOW_PTRACERS */
200 jmc 1.6
201 jmc 1.13 C- save newly loaded time-record
202     DO bj = myByLo(myThid), myByHi(myThid)
203     DO bi = myBxLo(myThid), myBxHi(myThid)
204     rbcsLdRec(bi,bj) = intime1
205     ENDDO
206     ENDDO
207    
208     C-- end if-block for loading new time-records
209 stephd 1.1 ENDIF
210 jmc 1.6
211     C-- Interpolate
212 stephd 1.1 DO bj = myByLo(myThid), myByHi(myThid)
213     DO bi = myBxLo(myThid), myBxHi(myThid)
214 jmc 1.7 DO k=1,Nr
215     DO j=1-Oly,sNy+Oly
216     DO i=1-Olx,sNx+Olx
217     RBCtemp(i,j,k,bi,bj) = bWght*rbct0(i,j,k,bi,bj)
218     & +aWght*rbct1(i,j,k,bi,bj)
219     RBCsalt(i,j,k,bi,bj) = bWght*rbcs0(i,j,k,bi,bj)
220     & +aWght*rbcs1(i,j,k,bi,bj)
221     ENDDO
222 stephd 1.1 ENDDO
223     ENDDO
224     ENDDO
225     ENDDO
226    
227     #ifdef ALLOW_PTRACERS
228 jmc 1.10 IF ( usePTRACERS ) THEN
229 jmc 1.7 DO iTracer = 1, PTRACERS_numInUse
230     IF (useRBCptrnum(iTracer)) THEN
231     DO bj = myByLo(myThid), myByHi(myThid)
232 stephd 1.1 DO bi = myBxLo(myThid), myBxHi(myThid)
233 jmc 1.7 DO k=1,Nr
234     DO j=1-Oly,sNy+Oly
235     DO i=1-Olx,sNx+Olx
236     RBC_ptracers(i,j,k,bi,bj,iTracer) =
237 stephd 1.5 & bWght*rbcptr0(i,j,k,bi,bj,iTracer)
238     & +aWght*rbcptr1(i,j,k,bi,bj,iTracer)
239 jmc 1.7 ENDDO
240 stephd 1.1 ENDDO
241     ENDDO
242     ENDDO
243 jmc 1.7 ENDDO
244     ENDIF
245     ENDDO
246     ENDIF
247 jmc 1.10 #endif /* ALLOW_PTRACERS */
248 stephd 1.1
249 jmc 1.7 CALL TIMER_STOP ('RBCS_FIELDS_LOAD [I/O]', myThid)
250 stephd 1.1
251 jmc 1.7 #endif /* ALLOW_RBCS */
252 stephd 1.1
253     RETURN
254     END

  ViewVC Help
Powered by ViewVC 1.1.22