1 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/ini_parms.F,v 1.8 1998/05/25 16:17:36 cnh Exp $ |
2 |
|
3 |
#include "CPP_EEOPTIONS.h" |
4 |
|
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 |
|
18 |
C === Global variables === |
19 |
#include "SIZE.h" |
20 |
#include "EEPARAMS.h" |
21 |
#include "PARAMS.h" |
22 |
#include "CG2D.h" |
23 |
|
24 |
C === Routine arguments === |
25 |
C myThid - Number of this instance of INI_PARMS |
26 |
INTEGER myThid |
27 |
|
28 |
C === Local variables === |
29 |
C dxSpacing, dySpacing - Default spacing in X and Y. |
30 |
C Units are that of coordinate system |
31 |
C i.e. cartesian => metres |
32 |
C s. polar => degrees |
33 |
C goptCount - Used to count the nuber of grid options |
34 |
C (only one is allowed! ) |
35 |
C msgBuf - Informational/error meesage buffer |
36 |
C errIO - IO error flag |
37 |
C iUnit - Work variable for IO unit number |
38 |
C record - Work variable for IO buffer |
39 |
C K, I, J - Loop counters |
40 |
REAL dxSpacing |
41 |
REAL dySpacing |
42 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
43 |
CHARACTER*(MAX_LEN_PREC) record |
44 |
INTEGER goptCount |
45 |
INTEGER K, I, J, IL, iUnit |
46 |
INTEGER errIO |
47 |
INTEGER IFNBLNK |
48 |
EXTERNAL IFNBLNK |
49 |
INTEGER ILNBLNK |
50 |
EXTERNAL ILNBLNK |
51 |
|
52 |
C-- Continuous equation parameters |
53 |
NAMELIST /PARM01/ |
54 |
& gravity, gBaro, rhonil, tAlpha, sBeta, f0, beta, |
55 |
& viscAh, viscAz, viscA4, |
56 |
& diffKhT, diffKzT, diffK4T, |
57 |
& diffKhS, diffKzS, diffK4S, |
58 |
& GMmaxslope,GMlength,GMalpha,GMdepth,GMkbackground, |
59 |
& tRef, sRef, |
60 |
& momViscosity, momAdvection, momForcing, useCoriolis, |
61 |
& momPressureForcing, |
62 |
& tempDiffusion, tempAdvection, tempForcing, |
63 |
& saltDiffusion, saltAdvection, saltForcing, |
64 |
& implicitFreeSurface, rigidLid, freeSurfFac |
65 |
|
66 |
C-- Elliptic solver parameters |
67 |
NAMELIST /PARM02/ |
68 |
& cg2dMaxIters, cg2dChkResFreq, cg2dTargetResidual, cg2dpcOffDFac |
69 |
|
70 |
C-- Time stepping parammeters |
71 |
NAMELIST /PARM03/ |
72 |
& nIter0, nTimeSteps, deltaT, deltaTmom, deltaTtracer, abEps, tauCD, rCD, |
73 |
& startTime, endTime, chkPtFreq, dumpFreq, deltaTClock, pChkPtFreq, |
74 |
& cAdjFreq |
75 |
|
76 |
C-- Gridding parameters |
77 |
NAMELIST /PARM04/ |
78 |
& usingCartesianGrid, delZ, dxSpacing, dySpacing, delX, delY, |
79 |
& usingSphericalPolarGrid, phiMin, thetaMin, rSphere, |
80 |
& l, m, n |
81 |
|
82 |
C |
83 |
_BEGIN_MASTER(myThid) |
84 |
|
85 |
C-- Open the parameter file |
86 |
OPEN(UNIT=scrUnit1,STATUS='SCRATCH') |
87 |
OPEN(UNIT=scrUnit2,STATUS='SCRATCH') |
88 |
OPEN(UNIT=modelDataUnit,FILE='data',STATUS='OLD',err=1,IOSTAT=errIO) |
89 |
IF ( errIO .GE. 0 ) GOTO 2 |
90 |
1 CONTINUE |
91 |
WRITE(msgBuf,'(A)') |
92 |
& 'S/R INI_PARMS' |
93 |
CALL PRINT_ERROR( msgBuf , 1) |
94 |
WRITE(msgBuf,'(A)') |
95 |
& 'Unable to open model parameter' |
96 |
CALL PRINT_ERROR( msgBuf , 1) |
97 |
WRITE(msgBuf,'(A)') |
98 |
& 'file "data"' |
99 |
CALL PRINT_ERROR( msgBuf , 1) |
100 |
CALL MODELDATA_EXAMPLE( myThid ) |
101 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
102 |
2 CONTINUE |
103 |
|
104 |
1000 CONTINUE |
105 |
READ(modelDataUnit,FMT='(A)',END=1001) RECORD |
106 |
IL = MAX(ILNBLNK(RECORD),1) |
107 |
IF ( RECORD(1:1) .NE. commentCharacter ) |
108 |
& WRITE(UNIT=scrUnit1,FMT='(A)') RECORD(:IL) |
109 |
WRITE(UNIT=scrUnit2,FMT='(A)') RECORD(:IL) |
110 |
GOTO 1000 |
111 |
1001 CONTINUE |
112 |
CLOSE(modelDataUnit) |
113 |
|
114 |
C-- Report contents of model parameter file |
115 |
WRITE(msgBuf,'(A)') |
116 |
&'// =======================================================' |
117 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, SQUEEZE_RIGHT , 1) |
118 |
WRITE(msgBuf,'(A)') '// Model parameter file "data"' |
119 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, SQUEEZE_RIGHT , 1) |
120 |
WRITE(msgBuf,'(A)') |
121 |
&'// =======================================================' |
122 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
123 |
& SQUEEZE_RIGHT , 1) |
124 |
iUnit = scrUnit2 |
125 |
REWIND(iUnit) |
126 |
2000 CONTINUE |
127 |
READ(UNIT=iUnit,FMT='(A)',END=2001) RECORD |
128 |
IL = MAX(ILNBLNK(RECORD),1) |
129 |
WRITE(msgBuf,'(A,A)') '>',RECORD(:IL) |
130 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, SQUEEZE_RIGHT , 1) |
131 |
GOTO 2000 |
132 |
2001 CONTINUE |
133 |
CLOSE(iUnit) |
134 |
WRITE(msgBuf,'(A)') ' ' |
135 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
136 |
& SQUEEZE_RIGHT , 1) |
137 |
|
138 |
|
139 |
C-- Read settings from model parameter file "data". |
140 |
iUnit = scrUnit1 |
141 |
REWIND(iUnit) |
142 |
|
143 |
C-- Set default "physical" parameters |
144 |
DO K =1,Nz |
145 |
tRef(K) = 30.D0 - FLOAT(K) |
146 |
ENDDO |
147 |
gravity = 9.81 D0 |
148 |
gBaro = gravity |
149 |
rhoNil = 999.8 D0 |
150 |
tAlpha=2.d-4 |
151 |
sBeta=1.d-5 |
152 |
f0=1.D-4 |
153 |
beta = 1. _d -11 |
154 |
viscAh=1.d3 |
155 |
viscA4=0. |
156 |
viscAz=1.d-3 |
157 |
diffKhT=1.0d3 |
158 |
diffKzT=1.d-5 |
159 |
diffKhS=1.0d3 |
160 |
diffKzS=1.d-1 |
161 |
diffK4T=0. |
162 |
diffK4S=0. |
163 |
GMmaxslope=1.d-2 |
164 |
GMlength=200.d3 |
165 |
GMalpha=0. |
166 |
GMdepth=1000. |
167 |
GMkbackground=0. |
168 |
implicitFreeSurface = .TRUE. |
169 |
rigidLid = .FALSE. |
170 |
freeSurfFac = 1. _d 0 |
171 |
momViscosity = .TRUE. |
172 |
momAdvection = .TRUE. |
173 |
momForcing = .TRUE. |
174 |
useCoriolis = .TRUE. |
175 |
momPressureForcing = .TRUE. |
176 |
READ(UNIT=iUnit,NML=PARM01,IOSTAT=errIO,err=3) |
177 |
IF ( errIO .GE. 0 ) GOTO 4 |
178 |
3 CONTINUE |
179 |
WRITE(msgBuf,'(A)') |
180 |
& 'S/R INI_PARMS' |
181 |
CALL PRINT_ERROR( msgBuf , 1) |
182 |
WRITE(msgBuf,'(A)') |
183 |
& 'Error reading numerical model ' |
184 |
CALL PRINT_ERROR( msgBuf , 1) |
185 |
WRITE(msgBuf,'(A)') |
186 |
& 'parameter file "data"' |
187 |
CALL PRINT_ERROR( msgBuf , 1) |
188 |
WRITE(msgBuf,'(A)') |
189 |
& 'Problem in namelist PARM01' |
190 |
CALL PRINT_ERROR( msgBuf , 1) |
191 |
CALL MODELDATA_EXAMPLE( myThid ) |
192 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
193 |
4 CONTINUE |
194 |
IF ( implicitFreeSurface ) freeSurfFac = 1. _d 0 |
195 |
IF ( rigidLid ) freeSurfFac = 0. _d 0 |
196 |
IF ( momViscosity ) THEN |
197 |
vfFacMom = 1. _d 0 |
198 |
ELSE |
199 |
vfFacMom = 0. _d 0 |
200 |
ENDIF |
201 |
IF ( momAdvection ) THEN |
202 |
afFacMom = 1. _d 0 |
203 |
ELSE |
204 |
afFacMom = 0. _d 0 |
205 |
ENDIF |
206 |
IF ( momForcing ) THEN |
207 |
foFacMom = 1. _d 0 |
208 |
ELSE |
209 |
foFacMom = 0. _d 0 |
210 |
ENDIF |
211 |
IF ( useCoriolis ) THEN |
212 |
cfFacMom = 1. _d 0 |
213 |
ELSE |
214 |
cfFacMom = 0. _d 0 |
215 |
ENDIF |
216 |
IF ( momPressureForcing ) THEN |
217 |
pfFacMom = 1. _d 0 |
218 |
ELSE |
219 |
pfFacMom = 0. _d 0 |
220 |
ENDIF |
221 |
|
222 |
IF ( implicitFreeSurface .AND. rigidLid ) THEN |
223 |
WRITE(msgBuf,'(A)') |
224 |
& 'S/R INI_PARMS: Cannot select implicitFreeSurface and rigidLid.' |
225 |
CALL PRINT_ERROR( msgBuf , myThid) |
226 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
227 |
ENDIF |
228 |
|
229 |
C-- Elliptic solver parameters |
230 |
cg2dMaxIters = 150 |
231 |
cg2dTargetResidual = 1. _d -7 |
232 |
cg2dChkResFreq = 1 |
233 |
cg2dpcOffDFac = 0.51 _d 0 |
234 |
READ(UNIT=iUnit,NML=PARM02,IOSTAT=errIO,err=5) |
235 |
IF ( errIO .GE. 0 ) GOTO 6 |
236 |
5 CONTINUE |
237 |
WRITE(msgBuf,'(A)') |
238 |
& 'S/R INI_PARMS' |
239 |
CALL PRINT_ERROR( msgBuf , 1) |
240 |
WRITE(msgBuf,'(A)') |
241 |
& 'Error reading numerical model ' |
242 |
CALL PRINT_ERROR( msgBuf , 1) |
243 |
WRITE(msgBuf,'(A)') |
244 |
& 'parameter file "data".' |
245 |
CALL PRINT_ERROR( msgBuf , 1) |
246 |
WRITE(msgBuf,'(A)') |
247 |
& 'Problem in namelist PARM02' |
248 |
CALL PRINT_ERROR( msgBuf , 1) |
249 |
CALL MODELDATA_EXAMPLE( myThid ) |
250 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
251 |
6 CONTINUE |
252 |
|
253 |
C-- Time stepping parameters |
254 |
startTime = 0. |
255 |
nTimeSteps = 0 |
256 |
endTime = 0. |
257 |
nIter0 = 0 |
258 |
deltaT = 0. |
259 |
deltaTClock = 0. |
260 |
deltaTtracer = 0. |
261 |
deltaTMom = 0. |
262 |
abEps = 0.01 |
263 |
pchkPtFreq = 0. |
264 |
chkPtFreq = 3600.*25 |
265 |
dumpFreq = 3600.*100 |
266 |
writeStatePrec = precFloat32 |
267 |
nCheckLev = 1 |
268 |
checkPtSuff(1) = 'ckptA' |
269 |
checkPtSuff(2) = 'ckptB' |
270 |
cAdjFreq = -1. _d 0 |
271 |
READ(UNIT=iUnit,NML=PARM03,IOSTAT=errIO,err=7) |
272 |
IF ( errIO .GE. 0 ) GOTO 8 |
273 |
7 CONTINUE |
274 |
WRITE(msgBuf,'(A)') |
275 |
& 'S/R INI_PARMS' |
276 |
CALL PRINT_ERROR( msgBuf , 1) |
277 |
WRITE(msgBuf,'(A)') |
278 |
& 'Error reading numerical model ' |
279 |
CALL PRINT_ERROR( msgBuf , 1) |
280 |
WRITE(msgBuf,'(A)') |
281 |
& 'parameter file "data"' |
282 |
CALL PRINT_ERROR( msgBuf , 1) |
283 |
WRITE(msgBuf,'(A)') |
284 |
& 'Problem in namelist PARM03' |
285 |
CALL PRINT_ERROR( msgBuf , 1) |
286 |
CALL MODELDATA_EXAMPLE( myThid ) |
287 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
288 |
8 CONTINUE |
289 |
C Process "timestepping" params |
290 |
C o Time step size |
291 |
IF ( deltaT .EQ. 0. ) deltaT = deltaTmom |
292 |
IF ( deltaT .EQ. 0. ) deltaT = deltaTtracer |
293 |
IF ( deltaTmom .EQ. 0. ) deltaTmom = deltaT |
294 |
IF ( deltaTtracer .EQ. 0. ) deltaTtracer = deltaT |
295 |
IF ( deltaTClock .EQ. 0. ) deltaTClock = deltaT |
296 |
C o Convection frequency |
297 |
IF ( cAdjFreq .LT. 0. ) THEN |
298 |
cAdjFreq = deltaTClock |
299 |
ENDIF |
300 |
C o Time step count |
301 |
IF ( endTime .NE. 0 ) THEN |
302 |
IF ( deltaTClock .NE. 0 ) nTimeSteps = |
303 |
& INT((endTime-startTime)/deltaTClock) |
304 |
ENDIF |
305 |
C o Finish time |
306 |
IF ( endTime .EQ. 0. ) endTime = FLOAT(nTimeSteps)*deltaTClock |
307 |
|
308 |
C-- Grid parameters |
309 |
C In cartesian coords distances are in metres |
310 |
usingCartesianGrid = .TRUE. |
311 |
DO K =1,Nz |
312 |
delZ(K) = 100. _d 0 |
313 |
ENDDO |
314 |
dxSpacing = 20. _d 0 * 1000. _d 0 |
315 |
dySpacing = 20. _d 0 * 1000. _d 0 |
316 |
DO i=1,Nx |
317 |
delX(i) = dxSpacing |
318 |
ENDDO |
319 |
DO j=1,Ny |
320 |
delY(j) = dySpacing |
321 |
ENDDO |
322 |
C In spherical polar distances are in degrees |
323 |
usingSphericalPolarGrid = .FALSE. |
324 |
IF ( usingSphericalPolarGrid ) THEN |
325 |
phiMin = -5.0 |
326 |
thetaMin = 0. |
327 |
dxSpacing = 1. |
328 |
dySpacing = 1. |
329 |
rSphere = 6370. * 1. _d 3 |
330 |
DO I=1,Nx |
331 |
delX(I) = dxSpacing |
332 |
ENDDO |
333 |
DO J=1,Ny |
334 |
delY(J) = dySpacing |
335 |
ENDDO |
336 |
ENDIF |
337 |
|
338 |
READ(UNIT=iUnit,NML=PARM04,IOSTAT=errIO,err=9) |
339 |
IF ( errIO .GE. 0 ) GOTO 10 |
340 |
9 CONTINUE |
341 |
WRITE(msgBuf,'(A)') |
342 |
& 'S/R INI_PARMS' |
343 |
CALL PRINT_ERROR( msgBuf , 1) |
344 |
WRITE(msgBuf,'(A)') |
345 |
& 'Error reading numerical model ' |
346 |
CALL PRINT_ERROR( msgBuf , 1) |
347 |
WRITE(msgBuf,'(A)') |
348 |
& 'parameter file "data"' |
349 |
CALL PRINT_ERROR( msgBuf , 1) |
350 |
WRITE(msgBuf,'(A)') |
351 |
& 'Problem in namelist PARM04' |
352 |
CALL PRINT_ERROR( msgBuf , 1) |
353 |
CALL MODELDATA_EXAMPLE( myThid ) |
354 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
355 |
10 CONTINUE |
356 |
|
357 |
goptCount = 0 |
358 |
IF ( usingCartesianGrid ) goptCount = goptCount+1 |
359 |
IF ( usingSphericalPolarGrid ) goptCount = goptCount+1 |
360 |
IF ( goptCount .NE. 1 ) THEN |
361 |
WRITE(msgBuf,'(A)') |
362 |
& 'S/R INI_PARMS: More than one coordinate system requested' |
363 |
CALL PRINT_ERROR( msgBuf , myThid) |
364 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
365 |
ENDIF |
366 |
|
367 |
_END_MASTER(myThid) |
368 |
|
369 |
C-- Everyone else must wait for the parameters to be loaded |
370 |
_BARRIER |
371 |
C |
372 |
|
373 |
RETURN |
374 |
END |
375 |
|