1 |
C $Header: /u/gcmpack/MITgcm/pkg/ptracers/ptracers_readparms.F,v 1.40 2012/04/18 22:05:18 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PTRACERS_OPTIONS.h" |
5 |
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
CBOP |
8 |
C !ROUTINE: PTRACERS_READPARMS |
9 |
|
10 |
C !INTERFACE: |
11 |
SUBROUTINE PTRACERS_READPARMS( myThid ) |
12 |
|
13 |
C !DESCRIPTION: |
14 |
C Initialize PTRACERS parameters, read in data.ptracers |
15 |
|
16 |
C !USES: |
17 |
IMPLICIT NONE |
18 |
#include "SIZE.h" |
19 |
#include "EEPARAMS.h" |
20 |
#ifdef ALLOW_LONGSTEP |
21 |
#include "LONGSTEP_PARAMS.h" |
22 |
#endif |
23 |
#include "PTRACERS_SIZE.h" |
24 |
#include "PTRACERS_PARAMS.h" |
25 |
#include "PARAMS.h" |
26 |
#ifdef ALLOW_MNC |
27 |
#include "MNC_PARAMS.h" |
28 |
#endif |
29 |
|
30 |
C !INPUT PARAMETERS: |
31 |
INTEGER myThid |
32 |
CEOP |
33 |
|
34 |
#ifdef ALLOW_PTRACERS |
35 |
C !FUNCTIONS |
36 |
LOGICAL GAD_VALID_ADVSCHEME |
37 |
EXTERNAL GAD_VALID_ADVSCHEME |
38 |
|
39 |
C !LOCAL VARIABLES: |
40 |
C k,iTracer :: loop indices |
41 |
C iUnit :: unit number for I/O |
42 |
C msgBuf :: message buffer |
43 |
INTEGER k, iTracer |
44 |
INTEGER iUnit |
45 |
INTEGER ic |
46 |
LOGICAL validNum |
47 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
48 |
_RL PTRACERS_diffKr(PTRACERS_num) |
49 |
_RL tauTr1ClimRelax |
50 |
|
51 |
C PTRACERS_taveFreq :: Frequency with which time-averaged PTRACERS |
52 |
C are written to post-processing files. |
53 |
C tauTr1ClimRelax :: old parameter (will be removed 1 day) |
54 |
NAMELIST /PTRACERS_PARM01/ |
55 |
& tauTr1ClimRelax, |
56 |
& PTRACERS_numInUse, |
57 |
& PTRACERS_Iter0, |
58 |
& PTRACERS_addSrelax2EmP, |
59 |
& PTRACERS_startStepFwd, |
60 |
& PTRACERS_resetFreq, |
61 |
& PTRACERS_resetPhase, |
62 |
& PTRACERS_advScheme, |
63 |
& PTRACERS_ImplVertAdv, |
64 |
& PTRACERS_diffKh, |
65 |
& PTRACERS_diffK4, |
66 |
& PTRACERS_diffKr, |
67 |
& PTRACERS_diffKrNr, |
68 |
& PTRACERS_ref, |
69 |
& PTRACERS_EvPrRn, |
70 |
& PTRACERS_useGMRedi, |
71 |
& PTRACERS_useDWNSLP, |
72 |
& PTRACERS_useKPP, |
73 |
& PTRACERS_initialFile, |
74 |
& PTRACERS_names, |
75 |
& PTRACERS_long_names, |
76 |
& PTRACERS_units, |
77 |
& PTRACERS_useRecords, |
78 |
& PTRACERS_dumpFreq, |
79 |
& PTRACERS_taveFreq, |
80 |
& PTRACERS_monitorFreq, |
81 |
& PTRACERS_timeave_mnc, |
82 |
& PTRACERS_snapshot_mnc, |
83 |
& PTRACERS_monitor_mnc, |
84 |
& PTRACERS_pickup_write_mnc, |
85 |
& PTRACERS_pickup_read_mnc |
86 |
|
87 |
_BEGIN_MASTER(myThid) |
88 |
|
89 |
C Set ptracer IO & diagnostics labels (2 characters long) |
90 |
CALL PTRACERS_SET_IOLABEL( |
91 |
O PTRACERS_ioLabel, |
92 |
I PTRACERS_num, myThid ) |
93 |
|
94 |
C Set defaults values for parameters in PTRACERS.h |
95 |
PTRACERS_dumpFreq = dumpFreq |
96 |
PTRACERS_taveFreq = taveFreq |
97 |
PTRACERS_monitorFreq = monitorFreq |
98 |
PTRACERS_Iter0 = 0 |
99 |
PTRACERS_numInUse=-1 |
100 |
DO iTracer=1,PTRACERS_num |
101 |
PTRACERS_startStepFwd(iTracer) = baseTime |
102 |
PTRACERS_resetFreq (iTracer) = 0. |
103 |
PTRACERS_resetPhase(iTracer) = 0. |
104 |
PTRACERS_advScheme(iTracer)=saltAdvScheme |
105 |
PTRACERS_ImplVertAdv(iTracer) = .FALSE. |
106 |
PTRACERS_diffKh(iTracer)=diffKhS |
107 |
PTRACERS_diffK4(iTracer)=diffK4S |
108 |
PTRACERS_diffKr(iTracer)=UNSET_RL |
109 |
DO k=1,Nr |
110 |
PTRACERS_diffKrNr(k,iTracer)=diffKrNrS(k) |
111 |
PTRACERS_ref (k,iTracer)=0. _d 0 |
112 |
ENDDO |
113 |
PTRACERS_EvPrRn(iTracer)=UNSET_RL |
114 |
PTRACERS_useGMRedi(iTracer)=useGMRedi |
115 |
PTRACERS_useDWNSLP(iTracer)=useDOWN_SLOPE |
116 |
PTRACERS_useKPP(iTracer) =useKPP |
117 |
PTRACERS_initialFile(iTracer)=' ' |
118 |
DO ic = 1,MAX_LEN_FNAM |
119 |
PTRACERS_names(iTracer)(ic:ic) = ' ' |
120 |
PTRACERS_long_names(iTracer)(ic:ic) = ' ' |
121 |
PTRACERS_units(iTracer)(ic:ic) = ' ' |
122 |
ENDDO |
123 |
ENDDO |
124 |
PTRACERS_addSrelax2EmP = .FALSE. |
125 |
PTRACERS_useRecords = .FALSE. |
126 |
#ifdef ALLOW_MNC |
127 |
PTRACERS_timeave_mnc = useMNC .AND. timeave_mnc |
128 |
PTRACERS_snapshot_mnc = useMNC .AND. snapshot_mnc |
129 |
PTRACERS_monitor_mnc = useMNC .AND. monitor_mnc |
130 |
PTRACERS_pickup_write_mnc = useMNC .AND. pickup_write_mnc |
131 |
PTRACERS_pickup_read_mnc = useMNC .AND. pickup_read_mnc |
132 |
#else |
133 |
PTRACERS_timeave_mnc = .FALSE. |
134 |
PTRACERS_snapshot_mnc = .FALSE. |
135 |
PTRACERS_monitor_mnc = .FALSE. |
136 |
PTRACERS_pickup_write_mnc = .FALSE. |
137 |
PTRACERS_pickup_read_mnc = .FALSE. |
138 |
#endif |
139 |
tauTr1ClimRelax = 0. |
140 |
DO k = 1,Nr |
141 |
#ifdef ALLOW_LONGSTEP |
142 |
PTRACERS_dTLev(k) = LS_nIter*dTtracerLev(k) |
143 |
#else |
144 |
PTRACERS_dTLev(k) = dTtracerLev(k) |
145 |
#endif |
146 |
ENDDO |
147 |
|
148 |
C Open and read the data.ptracers file |
149 |
WRITE(msgBuf,'(A)') ' PTRACERS_READPARMS: opening data.ptracers' |
150 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
151 |
& SQUEEZE_RIGHT , myThid ) |
152 |
CALL OPEN_COPY_DATA_FILE( |
153 |
I 'data.ptracers', 'PTRACERS_READPARMS', |
154 |
O iUnit, |
155 |
I myThid ) |
156 |
READ(UNIT=iUnit,NML=PTRACERS_PARM01) |
157 |
WRITE(msgBuf,'(A)') |
158 |
& ' PTRACERS_READPARMS: finished reading data.ptracers' |
159 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
160 |
& SQUEEZE_RIGHT , myThid ) |
161 |
|
162 |
C Close the open data file |
163 |
CLOSE(iUnit) |
164 |
|
165 |
C Check for retired parameters: |
166 |
C Tracer 1 climatology relaxation time scale (<- but the code is gone !) |
167 |
IF ( tauTr1ClimRelax .NE. 0. ) THEN |
168 |
#ifndef ALLOW_COST |
169 |
WRITE(msgBuf,'(2A)')' PTRACERS_READPARMS: ', |
170 |
& 'tauTr1ClimRelax has been removed (code is gone)' |
171 |
CALL PRINT_ERROR( msgBuf, myThid ) |
172 |
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS' |
173 |
#else |
174 |
lambdaTr1ClimRelax = 1./tauTr1ClimRelax |
175 |
ELSE |
176 |
lambdaTr1ClimRelax = 0. |
177 |
#endif |
178 |
ENDIF |
179 |
|
180 |
C-- Now set-up any remaining parameters that result from other params |
181 |
|
182 |
C If PTRACERS_numInUse was not set in data.ptracers then we can |
183 |
C assume that all PTRACERS fields will be in use |
184 |
IF (PTRACERS_numInUse.LT.0) THEN |
185 |
PTRACERS_numInUse=PTRACERS_num |
186 |
ENDIF |
187 |
|
188 |
C Check we are not trying to use more tracers than allowed |
189 |
IF (PTRACERS_numInUse.GT.PTRACERS_num) THEN |
190 |
WRITE(msgBuf,'(A,I4,A,I4,A)') |
191 |
& ' PTRACERS_READPARMS: You requested',PTRACERS_numInUse, |
192 |
& ' tracers at run time when only',PTRACERS_num, |
193 |
& ' were specified at compile time. Naughty! ' |
194 |
CALL PRINT_ERROR( msgBuf, myThid ) |
195 |
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS' |
196 |
ENDIF |
197 |
|
198 |
C Set vertical diffusion array |
199 |
DO iTracer=1,PTRACERS_numInUse |
200 |
IF ( PTRACERS_diffKr(iTracer).NE.UNSET_RL ) THEN |
201 |
DO k=1,Nr |
202 |
PTRACERS_diffKrNr(k,iTracer)=PTRACERS_diffKr(iTracer) |
203 |
ENDDO |
204 |
ENDIF |
205 |
ENDDO |
206 |
|
207 |
C Set flag to check when each tracer starts |
208 |
PTRACERS_startAllTrc = .TRUE. |
209 |
DO iTracer=1,PTRACERS_numInUse |
210 |
IF ( PTRACERS_startStepFwd(iTracer) .NE. baseTime ) |
211 |
& PTRACERS_startAllTrc = .FALSE. |
212 |
ENDDO |
213 |
#ifdef ALLOW_AUTODIFF_TAMC |
214 |
IF ( .NOT.PTRACERS_startAllTrc ) THEN |
215 |
WRITE(msgBuf,'(A)') |
216 |
& 'PTRACERS_READPARMS: Compiling AD code does not allow' |
217 |
CALL PRINT_ERROR( msgBuf, myThid ) |
218 |
WRITE(msgBuf,'(A)') |
219 |
& 'to use different starting time (PTRACERS_startStepFwd)' |
220 |
CALL PRINT_ERROR( msgBuf, myThid ) |
221 |
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS' |
222 |
ENDIF |
223 |
#endif /* ALLOW_AUTODIFF_TAMC */ |
224 |
|
225 |
C Check for valid advection-scheme number |
226 |
DO iTracer=1,PTRACERS_numInUse |
227 |
validNum = GAD_VALID_ADVSCHEME( PTRACERS_advScheme(iTracer) ) |
228 |
IF ( .NOT.validNum ) THEN |
229 |
WRITE(msgBuf,'(2A,I6)') 'PTRACERS_READPARMS: ', |
230 |
& 'invalid advection scheme number=',PTRACERS_advScheme(iTracer) |
231 |
CALL PRINT_ERROR( msgBuf, myThid ) |
232 |
WRITE(msgBuf,'(2A,I6)') 'PTRACERS_READPARMS: ', |
233 |
& 'for tracer #', iTracer |
234 |
CALL PRINT_ERROR( msgBuf, myThid ) |
235 |
STOP 'ABNORMAL END: S/R PTRACERS_READPARMS' |
236 |
ENDIF |
237 |
ENDDO |
238 |
|
239 |
#ifdef ALLOW_MNC |
240 |
PTRACERS_timeave_mnc = useMNC .AND. PTRACERS_timeave_mnc |
241 |
PTRACERS_snapshot_mnc = useMNC .AND. PTRACERS_snapshot_mnc |
242 |
PTRACERS_monitor_mnc = useMNC .AND. PTRACERS_monitor_mnc |
243 |
PTRACERS_pickup_write_mnc = useMNC .AND. PTRACERS_pickup_write_mnc |
244 |
PTRACERS_pickup_read_mnc = useMNC .AND. PTRACERS_pickup_read_mnc |
245 |
|
246 |
PTRACERS_timeave_mdsio = (.NOT. PTRACERS_timeave_mnc) |
247 |
& .OR. outputTypesInclusive |
248 |
PTRACERS_snapshot_mdsio = (.NOT. PTRACERS_snapshot_mnc) |
249 |
& .OR. outputTypesInclusive |
250 |
PTRACERS_monitor_stdio = (.NOT. PTRACERS_monitor_mnc) |
251 |
& .OR. outputTypesInclusive |
252 |
PTRACERS_pickup_write_mdsio = (.NOT. PTRACERS_pickup_write_mnc) |
253 |
& .OR. outputTypesInclusive |
254 |
PTRACERS_pickup_read_mdsio = (.NOT. PTRACERS_pickup_read_mnc) |
255 |
& .OR. outputTypesInclusive |
256 |
#else |
257 |
PTRACERS_timeave_mnc = .FALSE. |
258 |
PTRACERS_snapshot_mnc = .FALSE. |
259 |
PTRACERS_monitor_mnc = .FALSE. |
260 |
PTRACERS_pickup_write_mnc = .FALSE. |
261 |
PTRACERS_pickup_read_mnc = .FALSE. |
262 |
PTRACERS_timeave_mdsio = .TRUE. |
263 |
PTRACERS_snapshot_mdsio = .TRUE. |
264 |
PTRACERS_monitor_stdio = .TRUE. |
265 |
PTRACERS_pickup_write_mdsio = .TRUE. |
266 |
PTRACERS_pickup_read_mdsio = .TRUE. |
267 |
#endif |
268 |
|
269 |
C-- Print a summary of pTracer parameter values: |
270 |
|
271 |
_END_MASTER(myThid) |
272 |
C Everyone else must wait for the parameters to be loaded |
273 |
_BARRIER |
274 |
|
275 |
#endif /* ALLOW_PTRACERS */ |
276 |
|
277 |
RETURN |
278 |
END |