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

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

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


Revision 1.53 - (hide annotations) (download)
Fri Feb 2 21:04:48 2001 UTC (23 years, 4 months ago) by adcroft
Branch: MAIN
Changes since 1.52: +9 -23 lines
Merged changes from branch "branch-atmos-merge" into MAIN (checkpoint34)
 - substantial modifications to algorithm sequence (dynamics.F)
 - packaged OBCS, Shapiro filter, Zonal filter, Atmospheric Physics

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

  ViewVC Help
Powered by ViewVC 1.1.22