1 |
C $Header: ini_parms.F,v 1.1.1.1 1998/04/22 19:15:30 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, 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 = 1 |
203 |
endTime = 3600.*300 |
204 |
nIter0 = 0 |
205 |
deltaTtracer = 1200. _d 0 |
206 |
deltaTMom = 1200. _d 0 |
207 |
abEps = 0.01 |
208 |
chkPtFreq = 3600.*25 |
209 |
dumpFreq = 3600.*100 |
210 |
READ(UNIT=iUnit,NML=PARM03,IOSTAT=errIO,err=7) |
211 |
IF ( errIO .GE. 0 ) GOTO 8 |
212 |
7 CONTINUE |
213 |
WRITE(msgBuf,'(A)') |
214 |
& 'S/R INI_PARMS' |
215 |
CALL PRINT_ERROR( msgBuf , 1) |
216 |
WRITE(msgBuf,'(A)') |
217 |
& 'Error reading numerical model ' |
218 |
CALL PRINT_ERROR( msgBuf , 1) |
219 |
WRITE(msgBuf,'(A)') |
220 |
& 'parameter file "data"' |
221 |
CALL PRINT_ERROR( msgBuf , 1) |
222 |
WRITE(msgBuf,'(A)') |
223 |
& 'Problem in namelist PARM03' |
224 |
CALL PRINT_ERROR( msgBuf , 1) |
225 |
CALL MODELDATA_EXAMPLE( myThid ) |
226 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
227 |
8 CONTINUE |
228 |
|
229 |
C-- Grid parameters |
230 |
C In cartesian coords distances are in metres |
231 |
usingCartesianGrid = .TRUE. |
232 |
DO K =1,Nz |
233 |
delZ(K) = 100. _d 0 |
234 |
ENDDO |
235 |
dxSpacing = 20. _d 0 * 1000. _d 0 |
236 |
dySpacing = 20. _d 0 * 1000. _d 0 |
237 |
DO i=1,Nx |
238 |
delX(i) = dxSpacing |
239 |
ENDDO |
240 |
DO j=1,Ny |
241 |
delY(j) = dySpacing |
242 |
ENDDO |
243 |
C In spherical polar distances are in degrees |
244 |
usingSphericalPolarGrid = .FALSE. |
245 |
IF ( usingSphericalPolarGrid ) THEN |
246 |
phiMin = -5.0 |
247 |
thetaMin = 0. |
248 |
dxSpacing = 1. |
249 |
dySpacing = 1. |
250 |
rSphere = 6370. * 1. _d 3 |
251 |
DO I=1,Nx |
252 |
delX(I) = dxSpacing |
253 |
ENDDO |
254 |
DO J=1,Ny |
255 |
delY(J) = dySpacing |
256 |
ENDDO |
257 |
ENDIF |
258 |
|
259 |
READ(UNIT=iUnit,NML=PARM04,IOSTAT=errIO,err=9) |
260 |
IF ( errIO .GE. 0 ) GOTO 10 |
261 |
9 CONTINUE |
262 |
WRITE(msgBuf,'(A)') |
263 |
& 'S/R INI_PARMS' |
264 |
CALL PRINT_ERROR( msgBuf , 1) |
265 |
WRITE(msgBuf,'(A)') |
266 |
& 'Error reading numerical model ' |
267 |
CALL PRINT_ERROR( msgBuf , 1) |
268 |
WRITE(msgBuf,'(A)') |
269 |
& 'parameter file "data"' |
270 |
CALL PRINT_ERROR( msgBuf , 1) |
271 |
WRITE(msgBuf,'(A)') |
272 |
& 'Problem in namelist PARM04' |
273 |
CALL PRINT_ERROR( msgBuf , 1) |
274 |
CALL MODELDATA_EXAMPLE( myThid ) |
275 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
276 |
10 CONTINUE |
277 |
|
278 |
goptCount = 0 |
279 |
IF ( usingCartesianGrid ) goptCount = goptCount+1 |
280 |
IF ( usingSphericalPolarGrid ) goptCount = goptCount+1 |
281 |
IF ( goptCount .NE. 1 ) THEN |
282 |
WRITE(msgBuf,'(A)') |
283 |
& 'S/R INI_PARMS: More than one coordinate system requested' |
284 |
CALL PRINT_ERROR( msgBuf , myThid) |
285 |
STOP 'ABNORMAL END: S/R INI_PARMS' |
286 |
ENDIF |
287 |
|
288 |
C-- Offline config. parameters |
289 |
C Set to 12 equal length one month periods |
290 |
oBandBeg(1) = 0. _d 0 |
291 |
oBandEnd(1) = 2592000. _d 0 |
292 |
DO I=2, nOBands |
293 |
oBandBeg(I) = oBandBeg(I-1) |
294 |
oBandEnd(I) = oBandBeg(I)+2592000. _d 0 |
295 |
ENDDO |
296 |
oPeriodLength = oBandEnd(nOBands) |
297 |
oBandId( 1) = 'jan' |
298 |
oBandId( 2) = 'feb' |
299 |
oBandId( 3) = 'mar' |
300 |
oBandId( 4) = 'apr' |
301 |
oBandId( 5) = 'may' |
302 |
oBandId( 6) = 'jun' |
303 |
oBandId( 7) = 'jul' |
304 |
oBandId( 8) = 'aug' |
305 |
oBandId( 9) = 'sep' |
306 |
oBandId(10) = 'oct' |
307 |
oBandId(11) = 'nov' |
308 |
oBandId(12) = 'dec' |
309 |
numStepsPerPickup = NINT( oBandEnd(1) / deltaTtracer ) |
310 |
|
311 |
_END_MASTER(myThid) |
312 |
|
313 |
C-- Everyone else must wait for the parameters to be loaded |
314 |
_BARRIER |
315 |
C |
316 |
|
317 |
RETURN |
318 |
END |
319 |
|