1 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/ini_parms.F,v 1.4 1998/04/26 23:41:54 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, rhonil, tAlpha, sBeta, f0, beta, |
55 |
& viscAh, viscAz, viscA4, |
56 |
& diffKhT, diffKzT, diffK4T, |
57 |
& diffKhS, diffKzS, diffK4S, |
58 |
& tRef, sRef, |
59 |
& momViscosity, momAdvection, momForcing, useCoriolis, |
60 |
& tempDiffusion, tempAdvection, tempForcing, |
61 |
& saltDiffusion, saltAdvection, saltForcing |
62 |
|
63 |
C-- Elliptic solver parameters |
64 |
NAMELIST /PARM02/ |
65 |
& cg2dMaxIters, cg2dChkResFreq, cg2dTargetResidual |
66 |
|
67 |
C-- Time stepping parammeters |
68 |
NAMELIST /PARM03/ |
69 |
& nIter0, nTimeSteps, deltaT, deltaTmom, deltaTtracer, abEps, tauCD, rCD, |
70 |
& startTime, endTime, chkPtFreq, dumpFreq |
71 |
|
72 |
C-- Gridding parameters |
73 |
NAMELIST /PARM04/ |
74 |
& usingCartesianGrid, delZ, dxSpacing, dySpacing, delX, delY, |
75 |
& usingSphericalPolarGrid, phiMin, thetaMin, rSphere, |
76 |
& l, m, n |
77 |
|
78 |
C |
79 |
_BEGIN_MASTER(myThid) |
80 |
|
81 |
C-- Open the parameter file |
82 |
OPEN(UNIT=scrUnit1,STATUS='SCRATCH') |
83 |
OPEN(UNIT=scrUnit2,STATUS='SCRATCH') |
84 |
OPEN(UNIT=modelDataUnit,FILE='data',STATUS='OLD',err=1,IOSTAT=errIO) |
85 |
IF ( errIO .GE. 0 ) GOTO 2 |
86 |
1 CONTINUE |
87 |
WRITE(msgBuf,'(A)') |
88 |
& 'S/R INI_PARMS' |
89 |
CALL PRINT_ERROR( msgBuf , 1) |
90 |
WRITE(msgBuf,'(A)') |
91 |
& 'Unable to open model parameter' |
92 |
CALL PRINT_ERROR( msgBuf , 1) |
93 |
WRITE(msgBuf,'(A)') |
94 |
& 'file "data"' |
95 |
CALL PRINT_ERROR( msgBuf , 1) |
96 |
CALL MODELDATA_EXAMPLE( myThid ) |
97 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
98 |
2 CONTINUE |
99 |
|
100 |
1000 CONTINUE |
101 |
READ(modelDataUnit,FMT='(A)',END=1001) RECORD |
102 |
IL = MAX(ILNBLNK(RECORD),1) |
103 |
IF ( RECORD(1:1) .NE. commentCharacter ) |
104 |
& WRITE(UNIT=scrUnit1,FMT='(A)') RECORD(:IL) |
105 |
WRITE(UNIT=scrUnit2,FMT='(A)') RECORD(:IL) |
106 |
GOTO 1000 |
107 |
1001 CONTINUE |
108 |
CLOSE(modelDataUnit) |
109 |
|
110 |
C-- Report contents of model parameter file |
111 |
WRITE(msgBuf,'(A)') |
112 |
&'// =======================================================' |
113 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, SQUEEZE_RIGHT , 1) |
114 |
WRITE(msgBuf,'(A)') '// Model parameter file "data"' |
115 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, SQUEEZE_RIGHT , 1) |
116 |
WRITE(msgBuf,'(A)') |
117 |
&'// =======================================================' |
118 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
119 |
& SQUEEZE_RIGHT , 1) |
120 |
iUnit = scrUnit2 |
121 |
REWIND(iUnit) |
122 |
2000 CONTINUE |
123 |
READ(UNIT=iUnit,FMT='(A)',END=2001) RECORD |
124 |
IL = MAX(ILNBLNK(RECORD),1) |
125 |
WRITE(msgBuf,'(A,A)') '>',RECORD(:IL) |
126 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, SQUEEZE_RIGHT , 1) |
127 |
GOTO 2000 |
128 |
2001 CONTINUE |
129 |
CLOSE(iUnit) |
130 |
WRITE(msgBuf,'(A)') ' ' |
131 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
132 |
& SQUEEZE_RIGHT , 1) |
133 |
|
134 |
|
135 |
C-- Read settings from model parameter file "data". |
136 |
iUnit = scrUnit1 |
137 |
REWIND(iUnit) |
138 |
|
139 |
C-- Set default "physical" parameters |
140 |
DO K =1,Nz |
141 |
tRef(K) = 30.D0 - FLOAT(K) |
142 |
ENDDO |
143 |
gravity = 9.81 D0 |
144 |
rhoNil = 999.8 D0 |
145 |
tAlpha=2.d-4 |
146 |
sBeta=1.d-5 |
147 |
f0=1.D-4 |
148 |
beta = 1. _d -11 |
149 |
viscAh=1.d3 |
150 |
viscA4=0. |
151 |
viscAz=1.d-3 |
152 |
diffKhT=1.0d3 |
153 |
diffKzT=1.d-5 |
154 |
diffKhS=1.0d3 |
155 |
diffKzS=1.d-1 |
156 |
diffK4T=0. |
157 |
diffK4S=0. |
158 |
READ(UNIT=iUnit,NML=PARM01,IOSTAT=errIO,err=3) |
159 |
IF ( errIO .GE. 0 ) GOTO 4 |
160 |
3 CONTINUE |
161 |
WRITE(msgBuf,'(A)') |
162 |
& 'S/R INI_PARMS' |
163 |
CALL PRINT_ERROR( msgBuf , 1) |
164 |
WRITE(msgBuf,'(A)') |
165 |
& 'Error reading numerical model ' |
166 |
CALL PRINT_ERROR( msgBuf , 1) |
167 |
WRITE(msgBuf,'(A)') |
168 |
& 'parameter file "data"' |
169 |
CALL PRINT_ERROR( msgBuf , 1) |
170 |
WRITE(msgBuf,'(A)') |
171 |
& 'Problem in namelist PARM01' |
172 |
CALL PRINT_ERROR( msgBuf , 1) |
173 |
CALL MODELDATA_EXAMPLE( myThid ) |
174 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
175 |
4 CONTINUE |
176 |
|
177 |
C-- Elliptic solver parameters |
178 |
cg2dMaxIters = 150 |
179 |
cg2dTargetResidual = 1. _d -7 |
180 |
cg2dChkResFreq = 1 |
181 |
READ(UNIT=iUnit,NML=PARM02,IOSTAT=errIO,err=5) |
182 |
IF ( errIO .GE. 0 ) GOTO 6 |
183 |
5 CONTINUE |
184 |
WRITE(msgBuf,'(A)') |
185 |
& 'S/R INI_PARMS' |
186 |
CALL PRINT_ERROR( msgBuf , 1) |
187 |
WRITE(msgBuf,'(A)') |
188 |
& 'Error reading numerical model ' |
189 |
CALL PRINT_ERROR( msgBuf , 1) |
190 |
WRITE(msgBuf,'(A)') |
191 |
& 'parameter file "data".' |
192 |
CALL PRINT_ERROR( msgBuf , 1) |
193 |
WRITE(msgBuf,'(A)') |
194 |
& 'Problem in namelist PARM02' |
195 |
CALL PRINT_ERROR( msgBuf , 1) |
196 |
CALL MODELDATA_EXAMPLE( myThid ) |
197 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
198 |
6 CONTINUE |
199 |
|
200 |
C-- Time stepping parameters |
201 |
startTime = 0. |
202 |
nTimeSteps = 0 |
203 |
endTime = 0. |
204 |
nIter0 = 0 |
205 |
deltaT = 0. |
206 |
deltaTtracer = 0. |
207 |
deltaTMom = 0. |
208 |
abEps = 0.01 |
209 |
chkPtFreq = 3600.*25 |
210 |
dumpFreq = 3600.*100 |
211 |
READ(UNIT=iUnit,NML=PARM03,IOSTAT=errIO,err=7) |
212 |
IF ( errIO .GE. 0 ) GOTO 8 |
213 |
7 CONTINUE |
214 |
WRITE(msgBuf,'(A)') |
215 |
& 'S/R INI_PARMS' |
216 |
CALL PRINT_ERROR( msgBuf , 1) |
217 |
WRITE(msgBuf,'(A)') |
218 |
& 'Error reading numerical model ' |
219 |
CALL PRINT_ERROR( msgBuf , 1) |
220 |
WRITE(msgBuf,'(A)') |
221 |
& 'parameter file "data"' |
222 |
CALL PRINT_ERROR( msgBuf , 1) |
223 |
WRITE(msgBuf,'(A)') |
224 |
& 'Problem in namelist PARM03' |
225 |
CALL PRINT_ERROR( msgBuf , 1) |
226 |
CALL MODELDATA_EXAMPLE( myThid ) |
227 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
228 |
8 CONTINUE |
229 |
C Process "timestepping" params |
230 |
C o Time step size |
231 |
IF ( deltaT .EQ. 0. ) deltaT = deltaTmom |
232 |
IF ( deltaT .EQ. 0. ) deltaT = deltaTtracer |
233 |
IF ( deltaTmom .EQ. 0. ) deltaTmom = deltaT |
234 |
IF ( deltaTtracer .EQ. 0. ) deltaTtracer = deltaT |
235 |
C o Time step count |
236 |
IF ( endTime .NE. 0 ) THEN |
237 |
IF ( deltaT .NE. 0 ) nTimeSteps = INT(endTime/deltaT) |
238 |
ENDIF |
239 |
C o Finish time |
240 |
IF ( endTime .EQ. 0. ) endTime = FLOAT(nTimeSteps)*deltaT |
241 |
|
242 |
C-- Grid parameters |
243 |
C In cartesian coords distances are in metres |
244 |
usingCartesianGrid = .TRUE. |
245 |
DO K =1,Nz |
246 |
delZ(K) = 100. _d 0 |
247 |
ENDDO |
248 |
dxSpacing = 20. _d 0 * 1000. _d 0 |
249 |
dySpacing = 20. _d 0 * 1000. _d 0 |
250 |
DO i=1,Nx |
251 |
delX(i) = dxSpacing |
252 |
ENDDO |
253 |
DO j=1,Ny |
254 |
delY(j) = dySpacing |
255 |
ENDDO |
256 |
C In spherical polar distances are in degrees |
257 |
usingSphericalPolarGrid = .FALSE. |
258 |
IF ( usingSphericalPolarGrid ) THEN |
259 |
phiMin = -5.0 |
260 |
thetaMin = 0. |
261 |
dxSpacing = 1. |
262 |
dySpacing = 1. |
263 |
rSphere = 6370. * 1. _d 3 |
264 |
DO I=1,Nx |
265 |
delX(I) = dxSpacing |
266 |
ENDDO |
267 |
DO J=1,Ny |
268 |
delY(J) = dySpacing |
269 |
ENDDO |
270 |
ENDIF |
271 |
|
272 |
READ(UNIT=iUnit,NML=PARM04,IOSTAT=errIO,err=9) |
273 |
IF ( errIO .GE. 0 ) GOTO 10 |
274 |
9 CONTINUE |
275 |
WRITE(msgBuf,'(A)') |
276 |
& 'S/R INI_PARMS' |
277 |
CALL PRINT_ERROR( msgBuf , 1) |
278 |
WRITE(msgBuf,'(A)') |
279 |
& 'Error reading numerical model ' |
280 |
CALL PRINT_ERROR( msgBuf , 1) |
281 |
WRITE(msgBuf,'(A)') |
282 |
& 'parameter file "data"' |
283 |
CALL PRINT_ERROR( msgBuf , 1) |
284 |
WRITE(msgBuf,'(A)') |
285 |
& 'Problem in namelist PARM04' |
286 |
CALL PRINT_ERROR( msgBuf , 1) |
287 |
CALL MODELDATA_EXAMPLE( myThid ) |
288 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
289 |
10 CONTINUE |
290 |
|
291 |
goptCount = 0 |
292 |
IF ( usingCartesianGrid ) goptCount = goptCount+1 |
293 |
IF ( usingSphericalPolarGrid ) goptCount = goptCount+1 |
294 |
IF ( goptCount .NE. 1 ) THEN |
295 |
WRITE(msgBuf,'(A)') |
296 |
& 'S/R INI_PARMS: More than one coordinate system requested' |
297 |
CALL PRINT_ERROR( msgBuf , myThid) |
298 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
299 |
ENDIF |
300 |
|
301 |
_END_MASTER(myThid) |
302 |
|
303 |
C-- Everyone else must wait for the parameters to be loaded |
304 |
_BARRIER |
305 |
C |
306 |
|
307 |
RETURN |
308 |
END |
309 |
|