/[MITgcm]/MITgcm_contrib/sciascia/rbcs/rbcs_readparms.F
ViewVC logotype

Contents of /MITgcm_contrib/sciascia/rbcs/rbcs_readparms.F

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


Revision 1.1 - (show annotations) (download)
Wed Aug 8 01:57:14 2012 UTC (11 years, 8 months ago) by heimbach
Branch: MAIN
CVS Tags: HEAD
Add a modified version of pkg/rbcs that allows several rbcs
fields to be read with independent frequencies.
The idea is for each i = 1 , ... , U/V/WnLEN
one can define a separate mask and relaxation file
and separate/independent periods.

1 C $Header: /u/gcmpack/MITgcm/pkg/rbcs/rbcs_readparms.F,v 1.10 2012/06/26 22:19:17 gforget Exp $
2 C $Name: $
3
4 #include "RBCS_OPTIONS.h"
5
6 CBOP
7 C !ROUTINE: RBCS_READPARMS
8
9 C !INTERFACE: ==========================================================
10 SUBROUTINE RBCS_READPARMS( myThid )
11
12 C !DESCRIPTION:
13 C Initialize RBCS parameters, read in data.rbcs
14
15 C !USES: ===============================================================
16 IMPLICIT NONE
17 #include "SIZE.h"
18 #include "EEPARAMS.h"
19 #include "PARAMS.h"
20 #ifdef ALLOW_PTRACERS
21 #include "PTRACERS_SIZE.h"
22 #endif
23 #include "RBCS_SIZE.h"
24 #include "RBCS_PARAMS.h"
25
26 C !INPUT PARAMETERS: ===================================================
27 C myThid :: my thread Id. number
28 INTEGER myThid
29
30 C !OUTPUT PARAMETERS: ==================================================
31 C none
32
33 #ifdef ALLOW_RBCS
34
35 C === Local variables ===
36 C msgBuf :: Informational/error message buffer
37 C iUnit :: Work variable for IO unit number
38 CHARACTER*(MAX_LEN_MBUF) msgBuf
39 INTEGER iUnit
40 INTEGER irbc
41 INTEGER ium,ivm,iwm
42 #ifdef ALLOW_PTRACERS
43 INTEGER iTracer
44 #endif
45 C-- useRBCptracers is no longer used
46 LOGICAL useRBCptracers
47 CEOP
48
49 C-- RBCS parameters:
50 NAMELIST /RBCS_PARM01/
51 & tauRelaxU,
52 & tauRelaxV,
53 & tauRelaxT,
54 & tauRelaxS,
55 & relaxMaskUFile,
56 & relaxMaskVFile,
57 & relaxMaskFile,
58 & relaxUFile,
59 & relaxVFile,
60 & relaxTFile,
61 & relaxSFile,
62 & useRBCuVel,
63 & useRBCvVel,
64 & useRBCtemp,
65 & useRBCsalt,
66 & useRBCptracers,
67 & rbcsIniter,
68 & rbcsForcingPeriod,
69 & rbcsForcingCycle,
70 & rbcsForcingOffset,
71 & rbcsForcingUPeriod,
72 & rbcsForcingUCycle,
73 & rbcsForcingUOffset,
74 & rbcsForcingVPeriod,
75 & rbcsForcingVCycle,
76 & rbcsForcingVOffset,
77 #ifdef ALLOW_NONHYDROSTATIC
78 & tauRelaxW,
79 & relaxMaskWFile,
80 & relaxWFile,
81 & useRBCwVel,
82 & rbcsForcingWPeriod,
83 & rbcsForcingWCycle,
84 & rbcsForcingWOffset,
85 #endif
86 & rbcsVanishingTime,
87 & rbcsSingleTimeFiles,
88 & deltaTrbcs,
89 & rbcsIter0
90
91 #ifdef ALLOW_PTRACERS
92 NAMELIST /RBCS_PARM02/
93 & useRBCptrnum, tauRelaxPTR,
94 & relaxPtracerFile
95 #endif
96
97 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
98
99 _BEGIN_MASTER(myThid)
100
101 C-- Default values
102 DO ium=1,UmLEN
103 useRBCuVel(ium) =.FALSE.
104 tauRelaxU(ium) = 0.
105 relaxMaskUFile(ium) = ' '
106 relaxUFile = ' '
107 rbcsForcingUPeriod(ium) = 0. _d 0
108 rbcsForcingUCycle(ium) = 0. _d 0
109 rbcsForcingUOffset(ium) = 0. _d 0
110 ENDDO
111 DO ivm=1,VmLEN
112 useRBCvVel(ivm) =.FALSE.
113 tauRelaxV(ivm) = 0.
114 relaxMaskVFile = ' '
115 relaxVFile = ' '
116 rbcsForcingVPeriod(ivm) = 0. _d 0
117 rbcsForcingVCycle(ivm) = 0. _d 0
118 rbcsForcingVOffset(ivm) = 0. _d 0
119 ENDDO
120 #ifdef ALLOW_NONHYDROSTATIC
121 DO iwm=1,WmLEN
122 useRBCwVel(iwm) =.FALSE.
123 tauRelaxW(iwm) = 0.
124 relaxMaskWFile(iwm) = ' '
125 relaxWFile = ' '
126 rbcsForcingWPeriod(iwm) = 0. _d 0
127 rbcsForcingWCycle(iwm) = 0. _d 0
128 rbcsForcingWOffset(iwm) = 0. _d 0
129 ENDDO
130 #endif
131 tauRelaxT = 0.
132 tauRelaxS = 0.
133 useRBCtemp =.FALSE.
134 useRBCsalt =.FALSE.
135 DO irbc=1,maskLEN
136 relaxMaskFile(irbc) = ' '
137 ENDDO
138 relaxTFile = ' '
139 relaxSFile = ' '
140 rbcsIniter = 0
141 rbcsForcingPeriod = 0. _d 0
142 rbcsForcingCycle = 0. _d 0
143 rbcsForcingOffset = 0. _d 0
144 rbcsVanishingTime = 0. _d 0
145 rbcsSingleTimeFiles = .FALSE.
146 deltaTrbcs = deltaTclock
147 rbcsIter0 = 0
148 #ifdef ALLOW_PTRACERS
149 DO iTracer=1,PTRACERS_num
150 useRBCptrnum(iTracer)=.FALSE.
151 tauRelaxPTR(iTracer) = 0.
152 relaxPtracerFile(iTracer) = ' '
153 ENDDO
154 #endif
155 useRBCptracers=.FALSE.
156
157 C-- Open and read the data.rbcs file
158
159 WRITE(msgBuf,'(A)') ' RBCS_READPARMS: opening data.rbcs'
160 CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
161 & SQUEEZE_RIGHT , 1)
162 CALL OPEN_COPY_DATA_FILE(
163 I 'data.rbcs', 'RBCS_READPARMS',
164 O iUnit,
165 I myThid )
166 READ(UNIT=iUnit,NML=RBCS_PARM01)
167 #ifdef ALLOW_PTRACERS
168 READ(UNIT=iUnit,NML=RBCS_PARM02)
169 #endif
170 WRITE(msgBuf,'(A)')
171 & ' RBCS_READPARMS: finished reading data.rbcs'
172 CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,
173 & SQUEEZE_RIGHT , 1)
174
175 C-- Close the open data file
176 CLOSE(iUnit)
177
178 C--- Check RBCS config and params:
179 #ifdef DISABLE_RBCS_MOM
180 DO ium=1,UmLEN
181 IF ( useRBCuVel(ium)) THEN
182 WRITE(msgBuf,'(2A,2(L2,A))') 'RBCS_READPARMS: ',
183 & 'cannot use RBC for U
184 & (useRBCuVel(ium)=',useRBCuVel(ium)')'
185 CALL PRINT_ERROR( msgBuf, myThid )
186 WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ',
187 & 'when DISABLE_RBCS_MOM
188 & is defined (in RBCS_OPTIONS.h)'
189 CALL PRINT_ERROR( msgBuf, myThid )
190 STOP 'ABNORMAL END: S/R RBCS_READPARMS'
191 ENDIF
192 ENDDO
193 DO ivm=1,VmLEN
194 IF ( useRBCvVel(ivm)) THEN
195 WRITE(msgBuf,'(2A,2(L2,A))') 'RBCS_READPARMS: ',
196 & 'cannot use RBC for V
197 & (useRBCvVel(ivm)=',useRBCvVel(ivm)')'
198 CALL PRINT_ERROR( msgBuf, myThid )
199 WRITE(msgBuf,'(2A)') 'RBCS_READPARMS:',
200 & 'when DISABLE_RBCS_MOM
201 & is defined (in RBCS_OPTIONS.h)'
202 CALL PRINT_ERROR( msgBuf, myThid )
203 STOP 'ABNORMAL END: S/R RBCS_READPARMS'
204 ENDIF
205 ENDDO
206 #ifdef ALLOW_NONHYDROSTATIC
207 DO iwm=1,WmLEN
208 IF ( useRBCvVel(iwm)) THEN
209 WRITE(msgBuf,'(2A,2(L2,A))') 'RBCS_READPARMS: ',
210 & 'cannot use RBC for W
211 & (useRBCwVel(iwm)=',useRBCwVel(iwm)')'
212 CALL PRINT_ERROR( msgBuf, myThid )
213 WRITE(msgBuf,'(2A)') 'RBCS_READPARMS:',
214 & 'when DISABLE_RBCS_MOM
215 & is defined (in RBCS_OPTIONS.h)'
216 CALL PRINT_ERROR( msgBuf, myThid )
217 STOP 'ABNORMAL END: S/R RBCS_READPARMS'
218 ENDIF
219 ENDDO
220 #endif
221 #endif /* DISABLE_RBCS_MOM */
222 IF (rbcsIniter.NE.0) THEN
223 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
224 & 'rbcsIniter has been replaced by rbcsForcingOffset '
225 CALL PRINT_ERROR( msgBuf, myThid )
226 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
227 & 'which is in seconds. Please change your data.rbcs'
228 CALL PRINT_ERROR( msgBuf, myThid )
229 STOP 'ABNORMAL END: S/R RBCS_READPARAMS'
230 ENDIF
231 IF (startTime.LT.rbcsForcingOffset+0.5*rbcsForcingPeriod .AND.
232 & .NOT. rbcsSingleTimeFiles) THEN
233 IF (rbcsForcingCycle.GT.0) THEN
234 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
235 & 'startTime before rbcsForcingOffset
236 & +0.5*rbcsForcingPeriod '
237 CALL PRINT_ERROR( msgBuf, myThid )
238 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
239 & 'will use last record'
240 CALL PRINT_ERROR( msgBuf, myThid )
241 ELSE
242 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
243 & 'startTime before rbcsForcingOffset
244 & +0.5*rbcsForcingPeriod '
245 CALL PRINT_ERROR( msgBuf, myThid )
246 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
247 & 'not allowed with rbcsForcingCycle=0
248 & unless rbcsSingleTimeFiles'
249 CALL PRINT_ERROR( msgBuf, myThid )
250 STOP 'ABNORMAL END: S/R RBCS_READPARAMS'
251 ENDIF
252 ENDIF
253
254 DO ium=1,UmLEN
255 IF (startTime.LT.rbcsForcingUOffset(ium)
256 & +0.5*rbcsForcingUPeriod(ium) .AND.
257 & .NOT. rbcsSingleTimeFiles) THEN
258 IF (rbcsForcingUCycle(ium).GT.0) THEN
259 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
260 & 'startTime before rbcsForcingUOffset(ium)
261 & +0.5*rbcsForcingUPeriod(ium) '
262 CALL PRINT_ERROR( msgBuf, myThid )
263 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
264 & 'will use last record'
265 CALL PRINT_ERROR( msgBuf, myThid )
266 ELSE
267 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
268 & 'startTime before rbcsForcingUOffset(ium)
269 & +0.5*rbcsForcingUPeriod(ium) '
270 CALL PRINT_ERROR( msgBuf, myThid )
271 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
272 & 'not allowed with rbcsForcingUCycle=0
273 & unless rbcsSingleTimeFiles'
274 CALL PRINT_ERROR( msgBuf, myThid )
275 STOP 'ABNORMAL END: S/R RBCS_READPARAMS'
276 ENDIF
277 ENDIF
278 ENDDO
279 DO ivm=1,VmLEN
280 IF (startTime.LT.rbcsForcingVOffset(ivm)
281 & +0.5*rbcsForcingVPeriod(ivm) .AND.
282 & .NOT. rbcsSingleTimeFiles) THEN
283 IF (rbcsForcingVCycle(ivm).GT.0) THEN
284 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
285 & 'startTime before rbcsForcingVOffset(ivm)
286 & +0.5*rbcsForcingVPeriod(ivm) '
287 CALL PRINT_ERROR( msgBuf, myThid )
288 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
289 & 'will use last record'
290 CALL PRINT_ERROR( msgBuf, myThid )
291 ELSE
292 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
293 & 'startTime before rbcsForcingVOffset(ivm)
294 & +0.5*rbcsForcingVPeriod(ivm) '
295 CALL PRINT_ERROR( msgBuf, myThid )
296 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
297 & 'not allowed with rbcsForcingCycle=0
298 & unless rbcsSingleTimeFiles'
299 CALL PRINT_ERROR( msgBuf, myThid )
300 STOP 'ABNORMAL END: S/R RBCS_READPARAMS'
301 ENDIF
302 ENDIF
303 ENDDO
304 #ifdef ALLOW_NONHYDROSTATIC
305 DO iwm=1,WmLEN
306 IF (startTime.LT.rbcsForcingWOffset(iwm)
307 & +0.5*rbcsForcingWPeriod(iwm) .AND.
308 & .NOT. rbcsSingleTimeFiles) THEN
309 IF (rbcsForcingWCycle(iwm).GT.0) THEN
310 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
311 & 'startTime before rbcsForcingWOffset(iwm)
312 & +0.5*rbcsForcingWPeriod(iwm) '
313 CALL PRINT_ERROR( msgBuf, myThid )
314 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
315 & 'will use last record'
316 CALL PRINT_ERROR( msgBuf, myThid )
317 ELSE
318 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
319 & 'startTime before rbcsForcingWOffset(iwm)
320 & +0.5*rbcsForcingWPeriod(iwm) '
321 CALL PRINT_ERROR( msgBuf, myThid )
322 WRITE(msgBuf,'(2A)')' RBCS_READPARAMS: ',
323 & 'not allowed with rbcsForcingCycle=0
324 & unless rbcsSingleTimeFiles'
325 CALL PRINT_ERROR( msgBuf, myThid )
326 STOP 'ABNORMAL END: S/R RBCS_READPARAMS'
327 ENDIF
328 ENDIF
329 ENDDO
330 #endif
331 DO ium=1,UmLEN
332 IF ( useRBCuVel(ium) .AND. tauRelaxU(ium).LE.0. ) THEN
333 WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ',
334 & 'tauRelaxU(ium) cannot be zero with useRBCuVel(ium)'
335 CALL PRINT_ERROR( msgBuf, myThid )
336 STOP 'ABNORMAL END: S/R RBCS_READPARMS'
337 ENDIF
338 ENDDO
339 DO ivm=1,VmLEN
340 IF ( useRBCvVel(ivm) .AND. tauRelaxV(ivm).LE.0. ) THEN
341 WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ',
342 & 'tauRelaxV(ivm) cannot be zero with useRBCvVel(ivm)'
343 CALL PRINT_ERROR( msgBuf, myThid )
344 STOP 'ABNORMAL END: S/R RBCS_READPARMS'
345 ENDIF
346 ENDDO
347 #ifdef ALLOW_NONHYDROSTATIC
348 DO iwm=1,WmLEN
349 IF ( useRBCwVel(iwm) .AND. tauRelaxW(iwm).LE.0. ) THEN
350 WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ',
351 & 'tauRelaxW(iwm) cannot be zero with useRBCwVel(iwm)'
352 CALL PRINT_ERROR( msgBuf, myThid )
353 STOP 'ABNORMAL END: S/R RBCS_READPARMS'
354 ENDIF
355 ENDDO
356 #endif
357 IF ( useRBCtemp .AND. tauRelaxT.LE.0. ) THEN
358 WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ',
359 & 'tauRelaxT cannot be zero with useRBCtemp'
360 CALL PRINT_ERROR( msgBuf, myThid )
361 STOP 'ABNORMAL END: S/R RBCS_READPARMS'
362 ENDIF
363 IF ( useRBCsalt .AND. tauRelaxS.LE.0. ) THEN
364 WRITE(msgBuf,'(2A)') 'RBCS_READPARMS: ',
365 & 'tauRelaxS cannot be zero with useRBCsalt'
366 CALL PRINT_ERROR( msgBuf, myThid )
367 STOP 'ABNORMAL END: S/R RBCS_READPARMS'
368 ENDIF
369 #ifdef ALLOW_PTRACERS
370 DO iTracer=1,PTRACERS_num
371 IF ( useRBCptrnum(iTracer) ) THEN
372 IF ( .NOT.usePTRACERS ) THEN
373 WRITE(msgBuf,'(2A,I6,A)') 'RBCS_READPARMS: ',
374 & 'usePTRACERS=F => cannot use RBCS for tracer:', iTracer
375 CALL PRINT_ERROR( msgBuf, myThid )
376 STOP 'ABNORMAL END: S/R RBCS_READPARMS'
377 ENDIF
378 c IF ( iTracer.GT.PTRACERS_numInUse ) THEN
379 c STOP 'ABNORMAL END: S/R RBCS_READPARMS'
380 c ENDIF
381 IF ( tauRelaxPTR(iTracer).LE.0. ) THEN
382 WRITE(msgBuf,'(2A,I6,A)') 'RBCS_READPARMS: ',
383 & 'tauRelaxPTR(itr=', iTracer, ' ) = 0. is'
384 CALL PRINT_ERROR( msgBuf, myThid )
385 WRITE(msgBuf,'(2A,I6,A)') 'RBCS_READPARMS: ',
386 & 'not allowed with useRBCptr(itr)=T'
387 CALL PRINT_ERROR( msgBuf, myThid )
388 STOP 'ABNORMAL END: S/R RBCS_READPARMS'
389 ENDIF
390 ENDIF
391 ENDDO
392 #endif
393 _END_MASTER(myThid)
394
395 C Everyone else must wait for the parameters to be loaded
396 _BARRIER
397
398 #endif /* ALLOW_RBCS */
399
400 RETURN
401 END

  ViewVC Help
Powered by ViewVC 1.1.22