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

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

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


Revision 1.65 - (show annotations) (download)
Wed Aug 15 15:51:46 2001 UTC (22 years, 9 months ago) by adcroft
Branch: MAIN
Changes since 1.64: +3 -2 lines
Added run-time control of advection schemes.
 - advection scheme determines method of forward integration.
 - unfortunately, we have to use integers in "data" since ENUM_CENTERED_2ND
   doesn't mean anything to fortran
 - defaults are centered second
 - output differs due to these mods! This is due to the g77 optimization.
   I have tested that using -ffloat-store, these mods do not affect
   the output so am confident about changes.

                T           S           U           V
C D M    c        m  s        m  s        m  s        m  s
n p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .
f n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d
g d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  .

Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 22 16 16 pass  adjustment.128x64x1
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 pass  adjustment.cs-32x32x1
Y Y N N -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- N/O   aim.5l_Equatorial_Channel
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 pass  aim.5l_LatLon
Y Y N N -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- N/O   aim.5l_zon-ave
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 22 16 pass  exp0
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 22 16 pass  exp1
Y Y Y Y 13 16 16 16 16 16 16 16 13 16 13 13 13 13 13 13 16 pass  exp2
Y Y Y Y 12 16 16 13 16 16 16 16 16 13 16 16 16 16 13 13 16 FAIL  exp4
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 22 16 16 16 22 16 pass  exp5
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 pass  front_relax
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 22 16 16 16 11 16 pass  hs94.128x64x5
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 22 16 pass  hs94.1x64x5
Y Y Y Y 14 16 16 16 16 16 16 16 16 16 13 16 16 16 16 16 13 pass  hs94.cs-32x32x5
Y Y Y Y 16 16 16 22 16 16 16 16 16 16 16 22 16 16 16 16 16 pass  internal_wave
Y Y Y Y 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 pass  natl_box
Y Y Y Y 16 16 16 16 16 13 16 13 16 16 16 16 16 16 16 16 16 pass  solid-body.cs-32x32x1

1 C $Header: /u/gcmpack/models/MITgcmUV/model/src/ini_parms.F,v 1.64 2001/07/13 14:26:57 heimbach Exp $
2 C $Name: $
3
4 #include "CPP_OPTIONS.h"
5
6 SUBROUTINE INI_PARMS( myThid )
7 C /==========================================================\
8 C | SUBROUTINE INI_PARMS |
9 C | o Routine to set model "parameters" |
10 C |==========================================================|
11 C | Notes: |
12 C | ====== |
13 C | The present version of this routine is a place-holder. |
14 C | A production version needs to handle parameters from an |
15 C | external file and possibly reading in some initial field |
16 C | values. |
17 C \==========================================================/
18 IMPLICIT NONE
19
20 C === Global variables ===
21 #include "SIZE.h"
22 #include "EEPARAMS.h"
23 #include "PARAMS.h"
24 #include "GRID.h"
25
26 C === Routine arguments ===
27 C myThid - Number of this instance of INI_PARMS
28 INTEGER myThid
29
30 C === Local variables ===
31 C dxSpacing, dySpacing - Default spacing in X and Y.
32 C Units are that of coordinate system
33 C i.e. cartesian => metres
34 C s. polar => degrees
35 C goptCount - Used to count the nuber of grid options
36 C (only one is allowed! )
37 C msgBuf - Informational/error meesage buffer
38 C errIO - IO error flag
39 C iUnit - Work variable for IO unit number
40 C record - Work variable for IO buffer
41 C K, I, J - Loop counters
42 C xxxDefault - Default value for variable xxx
43 _RL dxSpacing
44 _RL dySpacing
45 CHARACTER*(MAX_LEN_FNAM) delXfile
46 CHARACTER*(MAX_LEN_FNAM) delYfile
47 CHARACTER*(MAX_LEN_MBUF) msgBuf
48 CHARACTER*(MAX_LEN_PREC) record
49 INTEGER goptCount
50 INTEGER K, I, J, IL, iUnit
51 INTEGER errIO
52 INTEGER IFNBLNK
53 EXTERNAL IFNBLNK
54 INTEGER ILNBLNK
55 EXTERNAL ILNBLNK
56 C Default values for variables which have vertical coordinate system
57 C dependency.
58 _RL viscArDefault
59 _RL diffKrTDefault
60 _RL diffKrSDefault
61 _RL hFacMinDrDefault
62 _RL delRDefault(Nr)
63 _RS rkFacDefault
64 C zCoordInputData - These are used to select between different coordinate systems.
65 C pCoordInputData The vertical coordinate system in the rest of the model is
66 C rCoordInputData written in terms of r. In the model "data" file input data can
67 C coordsSet be interms of z, p or r.
68 C e.g. delZ or delP or delR for the vertical grid spacing.
69 C The following rules apply:
70 C All parameters must use the same vertical coordinate system.
71 C e.g. delZ and viscAz is legal but
72 C delZ and viscAr is an error.
73 C Similarly specifyinh delZ and delP is an error.
74 C zCoord..., pCoord..., rCoord... are used to flag when z, p or r are
75 C used. coordsSet counts how many vertical coordinate systems have been
76 C used to specify variables. coordsSet > 1 is an error.
77 C
78 LOGICAL zCoordInputData
79 LOGICAL pCoordInputData
80 LOGICAL rCoordInputData
81 INTEGER coordsSet
82
83 C-- Continuous equation parameters
84 NAMELIST /PARM01/
85 & gravity, gBaro, rhonil, tAlpha, sBeta, f0, beta, omega,
86 & viscAh, viscAz, viscA4, cosPower,
87 & diffKhT, diffKzT, diffK4T,
88 & diffKhS, diffKzS, diffK4S,
89 & tRef, sRef, eosType, Integr_GeoPot,
90 & no_slip_sides,no_slip_bottom,
91 & momViscosity, momAdvection, momForcing, useCoriolis,
92 & momPressureForcing, metricTerms,
93 & tempDiffusion, tempAdvection, tempForcing,
94 & saltDiffusion, saltAdvection, saltForcing,
95 & implicSurfPress, implicDiv2DFlow,
96 & implicitFreeSurface, rigidLid, freeSurfFac, hFacMin, hFacMinDz,
97 & exactConserv,uniformLin_PhiSurf,nonlinFreeSurf,hFacInf,hFacSup,
98 & staggerTimeStep,
99 & tempStepping, saltStepping, momStepping, tr1Stepping,
100 & implicitDiffusion, implicitViscosity,
101 & viscAr, diffKrT, diffKrS, hFacMinDr,
102 & viscAp, diffKpT, diffKpS, hFacMinDp,
103 & rhoConst, buoyancyRelation, HeatCapacity_Cp,
104 & writeBinaryPrec, readBinaryPrec, writeStatePrec,
105 & nonHydrostatic, globalFiles,
106 & allowFreezing, ivdc_kappa,
107 & zonal_filt_lat, zonal_filt_sinpow, zonal_filt_cospow,
108 & bottomDragLinear,bottomDragQuadratic,
109 & usePickupBeforeC35, debugMode,
110 & readPickupWithTracer, writePickupWithTracer,
111 & tempAdvScheme, saltAdvScheme, tracerAdvScheme
112
113 C-- Elliptic solver parameters
114 NAMELIST /PARM02/
115 & cg2dMaxIters, cg2dChkResFreq, cg2dTargetResidual,
116 & cg2dTargetResWunit, cg2dpcOffDFac,
117 & cg3dMaxIters, cg3dChkResFreq, cg3dTargetResidual
118
119 C-- Time stepping parammeters
120 NAMELIST /PARM03/
121 & nIter0, nTimeSteps, nEndIter, deltaT, deltaTmom, deltaTtracer,
122 & abEps, tauCD, rCD,
123 & startTime, endTime, chkPtFreq, dumpFreq, taveFreq, deltaTClock,
124 & monitorFreq, pChkPtFreq, cAdjFreq,
125 & tauThetaClimRelax, tauSaltClimRelax, tauTr1ClimRelax,
126 & periodicExternalForcing, externForcingPeriod, externForcingCycle
127
128 C-- Gridding parameters
129 NAMELIST /PARM04/
130 & usingCartesianGrid, dxSpacing, dySpacing, delX, delY, delZ,
131 & usingSphericalPolarGrid, phiMin, thetaMin, rSphere,
132 & usingCurvilinearGrid,
133 & delP, delR, rkFac, Ro_SeaLevel, groundAtK1,
134 & delXfile, delYfile
135
136 C-- Input files
137 NAMELIST /PARM05/
138 & bathyFile, topoFile, hydrogThetaFile, hydrogSaltFile,
139 & zonalWindFile, meridWindFile,
140 & thetaClimFile, saltClimFile,
141 & surfQfile, EmPmRfile, surfQswfile,
142 & uVelInitFile, vVelInitFile, pSurfInitFile,
143 & dQdTFile
144
145 C
146 _BEGIN_MASTER(myThid)
147
148 C Defaults values for input parameters
149 CALL SET_DEFAULTS(
150 O viscArDefault, diffKrTDefault, diffKrSDefault,
151 O hFacMinDrDefault, delRdefault, rkFacDefault,
152 I myThid )
153
154 C-- Initialise "which vertical coordinate system used" flags.
155 zCoordInputData = .FALSE.
156 pCoordInputData = .FALSE.
157 rCoordInputData = .FALSE.
158 usingPCoords = .FALSE.
159 usingZCoords = .FALSE.
160 coordsSet = 0
161
162 C-- Open the parameter file
163 OPEN(UNIT=scrUnit1,STATUS='SCRATCH')
164 OPEN(UNIT=scrUnit2,STATUS='SCRATCH')
165 OPEN(UNIT=modelDataUnit,FILE='data',STATUS='OLD',
166 & IOSTAT=errIO)
167 IF ( errIO .LT. 0 ) THEN
168 WRITE(msgBuf,'(A)')
169 & 'S/R INI_PARMS'
170 CALL PRINT_ERROR( msgBuf , 1)
171 WRITE(msgBuf,'(A)')
172 & 'Unable to open model parameter'
173 CALL PRINT_ERROR( msgBuf , 1)
174 WRITE(msgBuf,'(A)')
175 & 'file "data"'
176 CALL PRINT_ERROR( msgBuf , 1)
177 CALL MODELDATA_EXAMPLE( myThid )
178 STOP 'ABNORMAL END: S/R INI_PARMS'
179 ENDIF
180
181 DO WHILE ( .TRUE. )
182 READ(modelDataUnit,FMT='(A)',END=1001) RECORD
183 IL = MAX(ILNBLNK(RECORD),1)
184 IF ( RECORD(1:1) .NE. commentCharacter )
185 & WRITE(UNIT=scrUnit1,FMT='(A)') RECORD(:IL)
186 WRITE(UNIT=scrUnit2,FMT='(A)') RECORD(:IL)
187 ENDDO
188 1001 CONTINUE
189 CLOSE(modelDataUnit)
190
191 C-- Report contents of model parameter file
192 WRITE(msgBuf,'(A)')
193 &'// ======================================================='
194 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
195 & SQUEEZE_RIGHT , 1)
196 WRITE(msgBuf,'(A)') '// Model parameter file "data"'
197 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
198 & SQUEEZE_RIGHT , 1)
199 WRITE(msgBuf,'(A)')
200 &'// ======================================================='
201 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
202 & SQUEEZE_RIGHT , 1)
203 iUnit = scrUnit2
204 REWIND(iUnit)
205 DO WHILE ( .TRUE. )
206 READ(UNIT=iUnit,FMT='(A)',END=2001) RECORD
207 IL = MAX(ILNBLNK(RECORD),1)
208 WRITE(msgBuf,'(A,A)') '>',RECORD(:IL)
209 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
210 & SQUEEZE_RIGHT , 1)
211 ENDDO
212 2001 CONTINUE
213 CLOSE(iUnit)
214 WRITE(msgBuf,'(A)') ' '
215 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
216 & SQUEEZE_RIGHT , 1)
217
218
219 C-- Read settings from model parameter file "data".
220 iUnit = scrUnit1
221 REWIND(iUnit)
222
223 C-- Set default "physical" parameters
224 viscAz = UNSET_RL
225 viscAr = UNSET_RL
226 viscAp = UNSET_RL
227 diffKzT = UNSET_RL
228 diffKpT = UNSET_RL
229 diffKrT = UNSET_RL
230 diffKzS = UNSET_RL
231 diffKpS = UNSET_RL
232 diffKrS = UNSET_RL
233 gBaro = UNSET_RL
234 rhoConst = UNSET_RL
235 hFacMinDr = UNSET_RL
236 hFacMinDz = UNSET_RL
237 hFacMinDp = UNSET_RL
238 READ(UNIT=iUnit,NML=PARM01) !,IOSTAT=errIO)
239 IF ( errIO .LT. 0 ) THEN
240 WRITE(msgBuf,'(A)')
241 & 'S/R INI_PARMS'
242 CALL PRINT_ERROR( msgBuf , 1)
243 WRITE(msgBuf,'(A)')
244 & 'Error reading numerical model '
245 CALL PRINT_ERROR( msgBuf , 1)
246 WRITE(msgBuf,'(A)')
247 & 'parameter file "data"'
248 CALL PRINT_ERROR( msgBuf , 1)
249 WRITE(msgBuf,'(A)')
250 & 'Problem in namelist PARM01'
251 CALL PRINT_ERROR( msgBuf , 1)
252 CALL MODELDATA_EXAMPLE( myThid )
253 STOP 'ABNORMAL END: S/R INI_PARMS'
254 ENDIF
255 IF ( implicitFreeSurface ) freeSurfFac = 1.D0
256 IF ( rigidLid ) freeSurfFac = 0.D0
257 IF ( gBaro .EQ. UNSET_RL ) gBaro=gravity
258 IF ( rhoConst .EQ. UNSET_RL ) rhoConst=rhoNil
259 C-- Momentum viscosity on/off flag.
260 IF ( momViscosity ) THEN
261 vfFacMom = 1.D0
262 ELSE
263 vfFacMom = 0.D0
264 ENDIF
265 C-- Momentum advection on/off flag.
266 IF ( momAdvection ) THEN
267 afFacMom = 1.D0
268 ELSE
269 afFacMom = 0.D0
270 ENDIF
271 C-- Momentum forcing on/off flag.
272 IF ( momForcing ) THEN
273 foFacMom = 1.D0
274 ELSE
275 foFacMom = 0.D0
276 ENDIF
277 C-- Coriolis term on/off flag.
278 IF ( useCoriolis ) THEN
279 cfFacMom = 1.D0
280 ELSE
281 cfFacMom = 0.D0
282 ENDIF
283 C-- Pressure term on/off flag.
284 IF ( momPressureForcing ) THEN
285 pfFacMom = 1.D0
286 ELSE
287 pfFacMom = 0.D0
288 ENDIF
289 C-- Metric terms on/off flag.
290 IF ( metricTerms ) THEN
291 mTFacMom = 1.D0
292 ELSE
293 mTFacMom = 0.D0
294 ENDIF
295 C-- z,p,r coord input switching.
296 IF ( viscAz .NE. UNSET_RL ) zCoordInputData = .TRUE.
297 IF ( viscAp .NE. UNSET_RL ) pCoordInputData = .TRUE.
298 IF ( viscAr .NE. UNSET_RL ) rCoordInputData = .TRUE.
299 IF ( viscAr .EQ. UNSET_RL ) viscAr = viscAz
300 IF ( viscAr .EQ. UNSET_RL ) viscAr = viscAp
301 IF ( viscAr .EQ. UNSET_RL ) viscAr = viscArDefault
302
303 IF ( diffKzT .NE. UNSET_RL ) zCoordInputData = .TRUE.
304 IF ( diffKpT .NE. UNSET_RL ) pCoordInputData = .TRUE.
305 IF ( diffKrT .NE. UNSET_RL ) rCoordInputData = .TRUE.
306 IF ( diffKrT .EQ. UNSET_RL ) diffKrT = diffKzT
307 IF ( diffKrT .EQ. UNSET_RL ) diffKrT = diffKpT
308 IF ( diffKrT .EQ. UNSET_RL ) diffKrT = diffKrTDefault
309
310 IF ( diffKzS .NE. UNSET_RL ) zCoordInputData = .TRUE.
311 IF ( diffKpS .NE. UNSET_RL ) pCoordInputData = .TRUE.
312 IF ( diffKrS .NE. UNSET_RL ) rCoordInputData = .TRUE.
313 IF ( diffKrS .EQ. UNSET_RL ) diffKrS = diffKzS
314 IF ( diffKrS .EQ. UNSET_RL ) diffKrS = diffKpS
315 IF ( diffKrS .EQ. UNSET_RL ) diffKrS = diffKrSDefault
316
317 IF ( hFacMinDz .NE. UNSET_RL ) zCoordInputData = .TRUE.
318 IF ( hFacMinDp .NE. UNSET_RL ) pCoordInputData = .TRUE.
319 IF ( hFacMinDr .NE. UNSET_RL ) rCoordInputData = .TRUE.
320 IF ( hFacMinDr .EQ. UNSET_RL ) hFacMinDr = hFacMinDz
321 IF ( hFacMinDr .EQ. UNSET_RL ) hFacMinDr = hFacMinDp
322 IF ( hFacMinDr .EQ. UNSET_RL ) hFacMinDr = hFacMinDrDefault
323
324 IF ( ivdc_kappa .NE. 0. .AND. .NOT. implicitDiffusion ) THEN
325 WRITE(msgBuf,'(A,A)')
326 & 'S/R INI_PARMS: To use ivdc_kappa you must enable implicit',
327 & ' vertical diffusion.'
328 CALL PRINT_ERROR( msgBuf , myThid)
329 STOP 'ABNORMAL END: S/R INI_PARMS'
330 ENDIF
331
332 IF ( implicitFreeSurface .AND. rigidLid ) THEN
333 WRITE(msgBuf,'(A,A)')
334 & 'S/R INI_PARMS: Cannot select both implicitFreeSurface',
335 & ' and rigidLid.'
336 CALL PRINT_ERROR( msgBuf , myThid)
337 STOP 'ABNORMAL END: S/R INI_PARMS'
338 ENDIF
339 IF ( (implicSurfPress.NE.1. .OR. implicDiv2DFlow.NE.1.)
340 & .AND. nonHydrostatic ) THEN
341 WRITE(msgBuf,'(A,A)') 'S/R INI_PARMS: nonHydrostatic',
342 & ' NOT SAFE with non-fully implicit Barotropic solver'
343 CALL PRINT_ERROR( msgBuf , myThid)
344 WRITE(msgBuf,'(A,A)') 'S/R INI_PARMS: To by-pass this',
345 & 'STOP, comment this test and re-compile ini_params'
346 CALL PRINT_ERROR( msgBuf , myThid)
347 STOP 'ABNORMAL END: S/R INI_PARMS'
348 ENDIF
349
350 coordsSet = 0
351 IF ( zCoordInputData ) coordsSet = coordsSet + 1
352 IF ( pCoordInputData ) coordsSet = coordsSet + 1
353 IF ( rCoordInputData ) coordsSet = coordsSet + 1
354 IF ( coordsSet .GT. 1 ) THEN
355 WRITE(msgBuf,'(A)')
356 & 'S/R INI_PARMS: Cannot mix z, p and r in the input data.'
357 CALL PRINT_ERROR( msgBuf , myThid)
358 STOP 'ABNORMAL END: S/R INI_PARMS'
359 ENDIF
360 IF ( rhoConst .LE. 0. ) THEN
361 WRITE(msgBuf,'(A)')
362 & 'S/R INI_PARMS: rhoConst must be greater than 0.'
363 CALL PRINT_ERROR( msgBuf , myThid)
364 STOP 'ABNORMAL END: S/R INI_PARMS'
365 ELSE
366 recip_rhoConst = 1.D0 / rhoConst
367 ENDIF
368 IF ( rhoNil .LE. 0. ) THEN
369 WRITE(msgBuf,'(A)')
370 & 'S/R INI_PARMS: rhoNil must be greater than 0.'
371 CALL PRINT_ERROR( msgBuf , myThid)
372 STOP 'ABNORMAL END: S/R INI_PARMS'
373 ELSE
374 recip_rhoNil = 1.D0 / rhoNil
375 ENDIF
376 IF ( HeatCapacity_Cp .LE. 0. ) THEN
377 WRITE(msgBuf,'(A)')
378 & 'S/R INI_PARMS: HeatCapacity_Cp must be greater than 0.'
379 CALL PRINT_ERROR( msgBuf , myThid)
380 STOP 'ABNORMAL END: S/R INI_PARMS'
381 ELSE
382 recip_Cp = 1.D0 / HeatCapacity_Cp
383 ENDIF
384 IF ( gravity .LE. 0. ) THEN
385 WRITE(msgBuf,'(A)')
386 & 'S/R INI_PARMS: gravity must be greater than 0.'
387 CALL PRINT_ERROR( msgBuf , myThid)
388 STOP 'ABNORMAL END: S/R INI_PARMS'
389 ELSE
390 recip_gravity = 1.D0 / gravity
391 ENDIF
392 C Set globalFiles flag for READ_WRITE_FLD package
393 CALL SET_WRITE_GLOBAL_FLD( globalFiles )
394 C Set globalFiles flag for READ_WRITE_REC package
395 CALL SET_WRITE_GLOBAL_REC( globalFiles )
396 C Set globalFiles flag for READ_WRITE_REC package
397 CALL SET_WRITE_GLOBAL_PICKUP( globalFiles )
398
399 C-- Elliptic solver parameters
400 READ(UNIT=iUnit,NML=PARM02) !,IOSTAT=errIO)
401 IF ( errIO .LT. 0 ) THEN
402 WRITE(msgBuf,'(A)')
403 & 'S/R INI_PARMS'
404 CALL PRINT_ERROR( msgBuf , 1)
405 WRITE(msgBuf,'(A)')
406 & 'Error reading numerical model '
407 CALL PRINT_ERROR( msgBuf , 1)
408 WRITE(msgBuf,'(A)')
409 & 'parameter file "data".'
410 CALL PRINT_ERROR( msgBuf , 1)
411 WRITE(msgBuf,'(A)')
412 & 'Problem in namelist PARM02'
413 CALL PRINT_ERROR( msgBuf , 1)
414 CALL MODELDATA_EXAMPLE( myThid )
415 STOP 'ABNORMAL END: S/R INI_PARMS'
416 ENDIF
417
418 C-- Time stepping parameters
419 rCD = -1.D0
420 READ(UNIT=iUnit,NML=PARM03) !,IOSTAT=errIO)
421 IF ( errIO .LT. 0 ) THEN
422 WRITE(msgBuf,'(A)')
423 & 'S/R INI_PARMS'
424 CALL PRINT_ERROR( msgBuf , 1)
425 WRITE(msgBuf,'(A)')
426 & 'Error reading numerical model '
427 CALL PRINT_ERROR( msgBuf , 1)
428 WRITE(msgBuf,'(A)')
429 & 'parameter file "data"'
430 CALL PRINT_ERROR( msgBuf , 1)
431 WRITE(msgBuf,'(A)')
432 & 'Problem in namelist PARM03'
433 CALL PRINT_ERROR( msgBuf , 1)
434 CALL MODELDATA_EXAMPLE( myThid )
435 STOP 'ABNORMAL END: S/R INI_PARMS'
436 ENDIF
437 C Process "timestepping" params
438 C o Time step size
439 IF ( deltaT .EQ. 0. ) deltaT = deltaTmom
440 IF ( deltaT .EQ. 0. ) deltaT = deltaTtracer
441 IF ( deltaTmom .EQ. 0. ) deltaTmom = deltaT
442 IF ( deltaTtracer .EQ. 0. ) deltaTtracer = deltaT
443 IF ( deltaTClock .EQ. 0. ) deltaTClock = deltaT
444 IF ( periodicExternalForcing ) THEN
445 IF ( externForcingCycle*externForcingPeriod .EQ. 0. ) THEN
446 WRITE(msgBuf,'(A)')
447 & 'S/R INI_PARMS: externForcingCycle,externForcingPeriod =0'
448 CALL PRINT_ERROR( msgBuf , 1)
449 STOP 'ABNORMAL END: S/R INI_PARMS'
450 ENDIF
451 IF ( INT(externForcingCycle/externForcingPeriod) .NE.
452 & externForcingCycle/externForcingPeriod ) THEN
453 WRITE(msgBuf,'(A)')
454 & 'S/R INI_PARMS: externForcingCycle <> N*externForcingPeriod'
455 CALL PRINT_ERROR( msgBuf , 1)
456 STOP 'ABNORMAL END: S/R INI_PARMS'
457 ENDIF
458 IF ( externForcingCycle.le.externForcingPeriod ) THEN
459 WRITE(msgBuf,'(A)')
460 & 'S/R INI_PARMS: externForcingCycle < externForcingPeriod'
461 CALL PRINT_ERROR( msgBuf , 1)
462 STOP 'ABNORMAL END: S/R INI_PARMS'
463 ENDIF
464 IF ( externForcingPeriod.lt.deltaTclock ) THEN
465 WRITE(msgBuf,'(A)')
466 & 'S/R INI_PARMS: externForcingPeriod < deltaTclock'
467 CALL PRINT_ERROR( msgBuf , 1)
468 STOP 'ABNORMAL END: S/R INI_PARMS'
469 ENDIF
470 ENDIF
471 C o Convection frequency
472 IF ( cAdjFreq .LT. 0. ) THEN
473 cAdjFreq = deltaTClock
474 ENDIF
475 IF ( ivdc_kappa .NE. 0. .AND. cAdjFreq .NE. 0. ) THEN
476 WRITE(msgBuf,'(A,A)')
477 & 'S/R INI_PARMS: You have enabled both ivdc_kappa and',
478 & ' convective adjustment.'
479 CALL PRINT_ERROR( msgBuf , myThid)
480 STOP 'ABNORMAL END: S/R INI_PARMS'
481 ENDIF
482 C o CD coupling
483 IF ( tauCD .EQ. 0.D0 ) THEN
484 tauCD = deltaTmom
485 ENDIF
486 IF ( rCD .LT. 0. ) THEN
487 rCD = 1. - deltaTMom/tauCD
488 ENDIF
489 C o Temperature climatology relaxation time scale
490 IF ( tauThetaClimRelax .EQ. 0.D0 ) THEN
491 doThetaClimRelax = .FALSE.
492 lambdaThetaClimRelax = 0.D0
493 ELSE
494 doThetaClimRelax = .TRUE.
495 lambdaThetaClimRelax = 1./tauThetaClimRelax
496 ENDIF
497 C o Salinity climatology relaxation time scale
498 IF ( tauSaltClimRelax .EQ. 0.D0 ) THEN
499 doSaltClimRelax = .FALSE.
500 lambdaSaltClimRelax = 0.D0
501 ELSE
502 doSaltClimRelax = .TRUE.
503 lambdaSaltClimRelax = 1./tauSaltClimRelax
504 ENDIF
505 C o Tracer 1 climatology relaxation time scale
506 IF ( tauTr1ClimRelax .EQ. 0.D0 ) THEN
507 doTr1ClimRelax = .FALSE.
508 lambdaTr1ClimRelax = 0.D0
509 ELSE
510 doTr1ClimRelax = .TRUE.
511 lambdaTr1ClimRelax = 1./tauTr1ClimRelax
512 ENDIF
513
514 C o Start time
515 IF ( nIter0 .NE. 0 .AND. startTime .EQ. 0. )
516 & startTime = deltaTClock*float(nIter0)
517 C o nIter0
518 IF ( nIter0 .EQ. 0 .AND. startTime .NE. 0. )
519 & nIter0 = INT( startTime/deltaTClock )
520
521 C o nTimeSteps 1
522 IF ( nTimeSteps .EQ. 0 .AND. nEndIter .NE. 0 )
523 & nTimeSteps = nEndIter-nIter0
524 C o nTimeSteps 2
525 IF ( nTimeSteps .EQ. 0 .AND. endTime .NE. 0. )
526 & nTimeSteps = int(0.5+(endTime-startTime)/deltaTclock)
527 C o nEndIter 1
528 IF ( nEndIter .EQ. 0 .AND. nTimeSteps .NE. 0 )
529 & nEndIter = nIter0+nTimeSteps
530 C o nEndIter 2
531 IF ( nEndIter .EQ. 0 .AND. endTime .NE. 0. )
532 & nEndIter = int(0.5+endTime/deltaTclock)
533 C o End Time 1
534 IF ( endTime .EQ. 0. .AND. nTimeSteps .NE. 0 )
535 & endTime = startTime + deltaTClock*float(nTimeSteps)
536 C o End Time 2
537 IF ( endTime .EQ. 0. .AND. nEndIter .NE. 0 )
538 & endTime = deltaTClock*float(nEndIter)
539
540 C o Consistent?
541 IF ( nEndIter .NE. nIter0+nTimeSteps ) THEN
542 WRITE(msgBuf,'(A)')
543 & 'S/R INI_PARMS: nIter0, nTimeSteps and nEndIter are inconsistent'
544 CALL PRINT_ERROR( msgBuf , 1)
545 WRITE(msgBuf,'(A)')
546 & 'S/R INI_PARMS: Perhaps more than two were set at once'
547 CALL PRINT_ERROR( msgBuf , 1)
548 STOP 'ABNORMAL END: S/R INI_PARMS'
549 ENDIF
550 IF ( nTimeSteps .NE. int(0.5+(endTime-startTime)/deltaTClock) )
551 & THEN
552 WRITE(msgBuf,'(A)')
553 & 'S/R INI_PARMS: both endTime and nTimeSteps have been set'
554 CALL PRINT_ERROR( msgBuf , 1)
555 WRITE(msgBuf,'(A)')
556 & 'S/R INI_PARMS: but are inconsistent'
557 CALL PRINT_ERROR( msgBuf , 1)
558 STOP 'ABNORMAL END: S/R INI_PARMS'
559 ENDIF
560
561 C o Monitor (should also add CPP flag for monitor?)
562 IF (monitorFreq.LT.0.) THEN
563 monitorFreq=0.
564 IF (dumpFreq.NE.0.) monitorFreq=dumpFreq
565 IF (taveFreq.NE.0..AND.taveFreq.LT.monitorFreq)
566 & monitorFreq=taveFreq
567 IF (chkPtFreq.NE.0..AND.chkPtFreq.LT.monitorFreq)
568 & monitorFreq=chkPtFreq
569 IF (pChkPtFreq.NE.0..AND.pChkPtFreq.LT.monitorFreq)
570 & monitorFreq=pChkPtFreq
571 IF (monitorFreq.EQ.0.) monitorFreq=deltaTclock
572 ENDIF
573
574 C o If taveFreq is finite, then we must make sure the diagnostics
575 C code is being compiled
576 #ifndef ALLOW_TIMEAVE
577 IF (taveFreq.NE.0.) THEN
578 WRITE(msgBuf,'(A)')
579 & 'S/R INI_PARMS: taveFreq <> 0 but you have'
580 CALL PRINT_ERROR( msgBuf , 1)
581 WRITE(msgBuf,'(A)')
582 & 'not compiled the model with the diagnostics routines.'
583 CALL PRINT_ERROR( msgBuf , 1)
584 WRITE(msgBuf,'(A,A)')
585 & 'Re-compile with: #define ALLOW_TIMEAVE',
586 & ' or -DALLOW_TIMEAVE'
587 CALL PRINT_ERROR( msgBuf , 1)
588 STOP 'ABNORMAL END: S/R INI_PARMS'
589 ENDIF
590 #endif
591
592 C-- Grid parameters
593 C In cartesian coords distances are in metres
594 rkFac = UNSET_RS
595 DO K =1,Nr
596 delZ(K) = UNSET_RL
597 delP(K) = UNSET_RL
598 delR(K) = UNSET_RL
599 ENDDO
600 C In spherical polar distances are in degrees
601 recip_rSphere = 1.D0/rSphere
602 dxSpacing = UNSET_RL
603 dySpacing = UNSET_RL
604 delXfile = ' '
605 delYfile = ' '
606 READ(UNIT=iUnit,NML=PARM04) !,IOSTAT=errIO)
607 IF ( errIO .LT. 0 ) THEN
608 WRITE(msgBuf,'(A)')
609 & 'S/R INI_PARMS'
610 CALL PRINT_ERROR( msgBuf , 1)
611 WRITE(msgBuf,'(A)')
612 & 'Error reading numerical model '
613 CALL PRINT_ERROR( msgBuf , 1)
614 WRITE(msgBuf,'(A)')
615 & 'parameter file "data"'
616 CALL PRINT_ERROR( msgBuf , 1)
617 WRITE(msgBuf,'(A)')
618 & 'Problem in namelist PARM04'
619 CALL PRINT_ERROR( msgBuf , 1)
620 CALL MODELDATA_EXAMPLE( myThid )
621 STOP 'ABNORMAL END: S/R INI_PARMS'
622 ENDIF
623
624 C X coordinate
625 IF ( delXfile .NE. ' ' ) THEN
626 IF ( delX(1) .NE. UNSET_RL .OR. dxSpacing .NE. UNSET_RL ) THEN
627 WRITE(msgBuf,'(A,A)') 'Too many specifications for delX:',
628 & 'Specify only one of delX, dxSpacing or delXfile'
629 CALL PRINT_ERROR( msgBuf , 1)
630 STOP 'ABNORMAL END: S/R INI_PARMS'
631 ELSE
632 _BEGIN_MASTER( myThid )
633 IF (readBinaryPrec.EQ.precFloat32) THEN
634 OPEN(37,FILE=delXfile,STATUS='OLD',FORM='UNFORMATTED',
635 & ACCESS='DIRECT',RECL=WORDLENGTH*Nx)
636 READ(37,rec=1) delX
637 #ifdef _BYTESWAPIO
638 call MDS_BYTESWAPR4( Nx, delX )
639 #endif
640 CLOSE(37)
641 ELSEIF (readBinaryPrec.EQ.precFloat64) THEN
642 OPEN(37,FILE=delXfile,STATUS='OLD',FORM='UNFORMATTED',
643 & ACCESS='DIRECT',RECL=WORDLENGTH*2*Nx)
644 READ(37,rec=1) delX
645 #ifdef _BYTESWAPIO
646 call MDS_BYTESWAPR8( Nx, delX )
647 #endif
648 CLOSE(37)
649 ENDIF
650 _END_MASTER(myThid)
651 ENDIF
652 ENDIF
653 IF ( dxSpacing .NE. UNSET_RL ) THEN
654 DO i=1,Nx
655 delX(i) = dxSpacing
656 ENDDO
657 ENDIF
658 C Y coordinate
659 IF ( delYfile .NE. ' ' ) THEN
660 IF ( delY(1) .NE. UNSET_RL .OR. dySpacing .NE. UNSET_RL ) THEN
661 WRITE(msgBuf,'(A,A)') 'Too many specifications for delY:',
662 & 'Specify only one of delY, dySpacing or delYfile'
663 CALL PRINT_ERROR( msgBuf , 1)
664 STOP 'ABNORMAL END: S/R INI_PARMS'
665 ELSE
666 _BEGIN_MASTER( myThid )
667 IF (readBinaryPrec.EQ.precFloat32) THEN
668 OPEN(37,FILE=delYfile,STATUS='OLD',FORM='UNFORMATTED',
669 & ACCESS='DIRECT',RECL=WORDLENGTH*Ny)
670 READ(37,rec=1) delY
671 #ifdef _BYTESWAPIO
672 call MDS_BYTESWAPR4( Ny, delY )
673 #endif
674 CLOSE(37)
675 ELSEIF (readBinaryPrec.EQ.precFloat64) THEN
676 OPEN(37,FILE=delYfile,STATUS='OLD',FORM='UNFORMATTED',
677 & ACCESS='DIRECT',RECL=WORDLENGTH*2*Ny)
678 READ(37,rec=1) delY
679 #ifdef _BYTESWAPIO
680 call MDS_BYTESWAPR8( Ny, delY )
681 #endif
682 CLOSE(37)
683 ENDIF
684 _END_MASTER(myThid)
685 ENDIF
686 ENDIF
687 IF ( dySpacing .NE. UNSET_RL ) THEN
688 DO i=1,Ny
689 delY(i) = dySpacing
690 ENDDO
691 ENDIF
692 C
693 IF ( rSphere .NE. 0 ) THEN
694 recip_rSphere = 1.D0/rSphere
695 ELSE
696 recip_rSphere = 0.
697 ENDIF
698 C-- Initialize EOS coefficients (3rd order polynomial)
699 IF (eostype.eq.'POLY3') THEN
700 OPEN(37,FILE='POLY3.COEFFS',STATUS='OLD',FORM='FORMATTED')
701 READ(37,*) I
702 IF (I.NE.Nr) THEN
703 WRITE(msgBuf,'(A)')
704 & 'ini_parms: attempt to read POLY3.COEFFS failed'
705 CALL PRINT_ERROR( msgBuf , 1)
706 WRITE(msgBuf,'(A)')
707 & ' because bad # of levels in data'
708 CALL PRINT_ERROR( msgBuf , 1)
709 STOP 'Bad data in POLY3.COEFFS'
710 ENDIF
711 READ(37,*) (eosRefT(K),eosRefS(K),eosSig0(K),K=1,Nr)
712 DO K=1,Nr
713 READ(37,*) (eosC(I,K),I=1,9)
714 ENDDO
715 CLOSE(37)
716 ENDIF
717 C-- Check for conflicting grid definitions.
718 goptCount = 0
719 IF ( usingCartesianGrid ) goptCount = goptCount+1
720 IF ( usingSphericalPolarGrid ) goptCount = goptCount+1
721 IF ( usingCurvilinearGrid ) goptCount = goptCount+1
722 IF ( goptCount .GT. 1 ) THEN
723 WRITE(msgBuf,'(A)')
724 & 'S/R INI_PARMS: More than one coordinate system requested'
725 CALL PRINT_ERROR( msgBuf , myThid)
726 STOP 'ABNORMAL END: S/R INI_PARMS'
727 ENDIF
728 IF ( goptCount .LT. 1 ) THEN
729 WRITE(msgBuf,'(A)')
730 & 'S/R INI_PARMS: No coordinate system requested'
731 CALL PRINT_ERROR( msgBuf , myThid)
732 STOP 'ABNORMAL END: S/R INI_PARMS'
733 ENDIF
734 C-- Make metric term settings consistent with underlying grid.
735 IF ( usingCartesianGrid ) THEN
736 usingSphericalPolarMterms = .FALSE.
737 metricTerms = .FALSE.
738 mTFacMom = 0.
739 useBetaPlaneF = .TRUE.
740 ENDIF
741 IF ( usingSphericalPolarGrid ) THEN
742 useConstantF = .FALSE.
743 useBetaPlaneF = .FALSE.
744 useSphereF = .TRUE.
745 usingSphericalPolarMterms = metricTerms
746 ENDIF
747 IF ( usingCurvilinearGrid ) THEN
748 useSphereF = .TRUE.
749 ENDIF
750 C-- p, z, r coord parameters
751 DO K = 1, Nr
752 IF ( delZ(K) .NE. UNSET_RL ) zCoordInputData = .TRUE.
753 IF ( delP(K) .NE. UNSET_RL ) pCoordInputData = .TRUE.
754 IF ( delR(K) .NE. UNSET_RL ) rCoordInputData = .TRUE.
755 IF ( delR(K) .EQ. UNSET_RL ) delR(K) = delZ(K)
756 IF ( delR(K) .EQ. UNSET_RL ) delR(K) = delP(K)
757 IF ( delR(K) .EQ. UNSET_RL ) delR(K) = delRDefault(K)
758 IF ( delR(K) .EQ. 0. ) THEN
759 WRITE(msgBuf,'(A,I4)')
760 & 'S/R INI_PARMS: No value for delZ/delP/delR at K = ',K
761 CALL PRINT_ERROR( msgBuf , 1)
762 STOP 'ABNORMAL END: S/R INI_PARMS'
763 ENDIF
764 ENDDO
765 C Check for multiple coordinate systems
766 CoordsSet = 0
767 IF ( zCoordInputData ) coordsSet = coordsSet + 1
768 IF ( pCoordInputData ) coordsSet = coordsSet + 1
769 IF ( rCoordInputData ) coordsSet = coordsSet + 1
770 IF ( coordsSet .GT. 1 ) THEN
771 WRITE(msgBuf,'(A)')
772 & 'S/R INI_PARMS: Cannot mix z, p and r in the input data.'
773 CALL PRINT_ERROR( msgBuf , myThid)
774 STOP 'ABNORMAL END: S/R INI_PARMS'
775 ENDIF
776
777 C-- Input files
778 READ(UNIT=iUnit,NML=PARM05) !,IOSTAT=errIO)
779 IF ( errIO .LT. 0 ) THEN
780 WRITE(msgBuf,'(A)')
781 & 'Error reading numerical model '
782 CALL PRINT_ERROR( msgBuf , 1)
783 WRITE(msgBuf,'(A)')
784 & 'parameter file "data"'
785 CALL PRINT_ERROR( msgBuf , 1)
786 WRITE(msgBuf,'(A)')
787 & 'Problem in namelist PARM05'
788 CALL PRINT_ERROR( msgBuf , 1)
789 CALL MODELDATA_EXAMPLE( myThid )
790 STOP 'ABNORMAL END: S/R INI_PARMS'
791 ENDIF
792
793 C
794 C-- Set factors required for mixing pressure and meters as vertical coordinate.
795 C rkFac is a "sign" parameter which is used where the orientation of the vertical
796 C coordinate (pressure or meters) relative to the vertical index (K) is important.
797 C rkFac = 1 applies when K and the coordinate are in the opposite sense.
798 C rkFac = -1 applies when K and the coordinate are in the same sense.
799 C horiVertRatio is a parameter that maps horizontal units to vertical units.
800 C It is used in certain special cases where lateral and vertical terms are
801 C being combined and a single frame of reference is needed.
802 IF ( zCoordInputData .AND. rkFac .EQ. UNSET_RS ) THEN
803 rkFac = 1.D0
804 horiVertRatio = 1.D0
805 ENDIF
806 IF ( pCoordInputData .AND. rkFac .EQ. UNSET_RS ) THEN
807 rkFac = -1.D0
808 horiVertRatio = Gravity * rhoConst
809 ENDIF
810 IF ( rCoordInputData .AND. rkFac .EQ. UNSET_RS ) THEN
811 rkFac = 1.D0
812 horiVertRatio = 1.D0
813 ENDIF
814 IF (buoyancyRelation.EQ.'ATMOSPHERIC')
815 & horiVertRatio = Gravity * rhoConst
816 IF ( rkFac .EQ. UNSET_RS ) rkFac=rkFacDefault
817 recip_rkFac = 1.D0 / rkFac
818 recip_horiVertRatio = 1./horiVertRatio
819 IF ( zCoordInputData ) usingZCoords = .TRUE.
820 IF ( pCoordInputData ) usingPCoords = .TRUE.
821
822 C
823 CLOSE(iUnit)
824
825 _END_MASTER(myThid)
826
827 C-- Everyone else must wait for the parameters to be loaded
828 _BARRIER
829 C
830
831 RETURN
832 END
833

  ViewVC Help
Powered by ViewVC 1.1.22