1 |
C $Header: /u/gcmpack/MITgcm/pkg/mnc/mnc_cwrapper.F,v 1.14 2004/07/06 03:55:53 edhill Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "MNC_OPTIONS.h" |
5 |
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
CBOP 0 |
8 |
C !ROUTINE: MNC_CW_ADD_GNAME |
9 |
|
10 |
C !INTERFACE: |
11 |
SUBROUTINE MNC_CW_ADD_GNAME( |
12 |
I name, |
13 |
I ndim, |
14 |
I dlens, |
15 |
I dnames, |
16 |
I inds_beg, inds_end, |
17 |
I myThid ) |
18 |
|
19 |
C !DESCRIPTION: |
20 |
C Add a grid name to the MNC convenience wrapper layer. |
21 |
|
22 |
C !USES: |
23 |
implicit none |
24 |
#include "mnc_common.h" |
25 |
#include "EEPARAMS.h" |
26 |
|
27 |
C !INPUT PARAMETERS: |
28 |
integer myThid, ndim |
29 |
character*(*) name |
30 |
integer dlens(*), inds_beg(*), inds_end(*) |
31 |
character*(*) dnames(*) |
32 |
CEOP |
33 |
|
34 |
C !LOCAL VARIABLES: |
35 |
integer i, nnf,nnl, indg |
36 |
character*(MAX_LEN_MBUF) msgbuf |
37 |
|
38 |
C Functions |
39 |
integer IFNBLNK, ILNBLNK |
40 |
|
41 |
nnf = IFNBLNK(name) |
42 |
nnl = ILNBLNK(name) |
43 |
|
44 |
C Check that this name is not already defined |
45 |
CALL MNC_GET_IND(MNC_MAX_ID, name, mnc_cw_gname, indg, myThid) |
46 |
IF (indg .GT. 0) THEN |
47 |
write(msgbuf,'(3a)') 'MNC_CW_ADD_GNAME ERROR: ''', name, |
48 |
& ''' is already defined' |
49 |
CALL print_error(msgbuf, mythid) |
50 |
stop 'ABNORMAL END: S/R MNC_CW_ADD_GNAME' |
51 |
ENDIF |
52 |
CALL MNC_GET_NEXT_EMPTY_IND(MNC_MAX_ID, mnc_cw_gname, |
53 |
& indg, myThid) |
54 |
|
55 |
mnc_cw_gname(indg)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
56 |
mnc_cw_gname(indg)(1:(nnl-nnf+1)) = name(nnf:nnl) |
57 |
mnc_cw_ndim(indg) = ndim |
58 |
|
59 |
DO i = 1,ndim |
60 |
mnc_cw_dn(i,indg)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
61 |
nnf = IFNBLNK(dnames(i)) |
62 |
nnl = ILNBLNK(dnames(i)) |
63 |
mnc_cw_dn(i,indg)(1:(nnl-nnf+1)) = dnames(i)(nnf:nnl) |
64 |
mnc_cw_dims(i,indg) = dlens(i) |
65 |
mnc_cw_is(i,indg) = inds_beg(i) |
66 |
mnc_cw_ie(i,indg) = inds_end(i) |
67 |
ENDDO |
68 |
|
69 |
RETURN |
70 |
END |
71 |
|
72 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
73 |
CBOP 0 |
74 |
C !ROUTINE: MNC_CW_DEL_GNAME |
75 |
|
76 |
C !INTERFACE: |
77 |
SUBROUTINE MNC_CW_DEL_GNAME( |
78 |
I name, |
79 |
I myThid ) |
80 |
|
81 |
C !DESCRIPTION: |
82 |
C Delete a grid name from the MNC convenience wrapper layer. |
83 |
|
84 |
C !USES: |
85 |
implicit none |
86 |
#include "mnc_common.h" |
87 |
#include "EEPARAMS.h" |
88 |
|
89 |
C !INPUT PARAMETERS: |
90 |
integer myThid |
91 |
character*(*) name |
92 |
CEOP |
93 |
|
94 |
C !LOCAL VARIABLES: |
95 |
integer nnf,nnl, indg |
96 |
|
97 |
C Functions |
98 |
integer IFNBLNK, ILNBLNK |
99 |
|
100 |
nnf = IFNBLNK(name) |
101 |
nnl = ILNBLNK(name) |
102 |
|
103 |
C Check that this name is not already defined |
104 |
CALL MNC_GET_IND(MNC_MAX_ID, name, mnc_cw_gname, indg, myThid) |
105 |
IF (indg .LT. 1) THEN |
106 |
RETURN |
107 |
ENDIF |
108 |
|
109 |
mnc_cw_gname(indg)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
110 |
mnc_cw_ndim(indg) = 0 |
111 |
|
112 |
RETURN |
113 |
END |
114 |
|
115 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
116 |
CBOP 1 |
117 |
C !ROUTINE: MNC_CW_DUMP |
118 |
|
119 |
C !INTERFACE: |
120 |
SUBROUTINE MNC_CW_DUMP( myThid ) |
121 |
|
122 |
C !DESCRIPTION: |
123 |
C Write a condensed view of the current state of the MNC look-up |
124 |
C tables for the convenience wrapper section. |
125 |
|
126 |
C !USES: |
127 |
implicit none |
128 |
#include "mnc_common.h" |
129 |
#include "SIZE.h" |
130 |
#include "EEPARAMS.h" |
131 |
#include "PARAMS.h" |
132 |
|
133 |
C !INPUT PARAMETERS: |
134 |
integer myThid |
135 |
CEOP |
136 |
|
137 |
C !LOCAL VARIABLES: |
138 |
integer i,j, ntot |
139 |
integer NBLNK |
140 |
parameter ( NBLNK = 150 ) |
141 |
character s1*(NBLNK), blnk*(NBLNK) |
142 |
|
143 |
_BEGIN_MASTER(myThid) |
144 |
|
145 |
DO i = 1,NBLNK |
146 |
blnk(i:i) = ' ' |
147 |
ENDDO |
148 |
|
149 |
s1(1:NBLNK) = blnk(1:NBLNK) |
150 |
write(s1,'(a5,a)') 'MNC: ', |
151 |
& 'The currently defined Grid Types are:' |
152 |
CALL PRINT_MESSAGE( |
153 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
154 |
ntot = 0 |
155 |
DO j = 1,MNC_MAX_ID |
156 |
IF (mnc_cw_gname(j)(1:MNC_MAX_CHAR) |
157 |
& .NE. mnc_blank_name(1:MNC_MAX_CHAR)) THEN |
158 |
|
159 |
ntot = ntot + 1 |
160 |
s1(1:NBLNK) = blnk(1:NBLNK) |
161 |
write(s1,'(a5,2i5,a3,a20,i3,a3,5i4,a4,5i4,a4,5i4,6a8)') |
162 |
& 'MNC: ', |
163 |
& j, ntot, ' : ', mnc_cw_gname(j)(1:20), mnc_cw_ndim(j), |
164 |
& ' : ', (mnc_cw_dims(i,j), i=1,5), |
165 |
& ' | ', (mnc_cw_is(i,j), i=1,5), |
166 |
& ' | ', (mnc_cw_ie(i,j), i=1,5), |
167 |
& ' | ', (mnc_cw_dn(i,j)(1:7), i=1,5) |
168 |
CALL PRINT_MESSAGE( |
169 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
170 |
|
171 |
ENDIF |
172 |
ENDDO |
173 |
|
174 |
s1(1:NBLNK) = blnk(1:NBLNK) |
175 |
write(s1,'(a5,a)') 'MNC: ', |
176 |
& 'The currently defined Variable Types are:' |
177 |
CALL PRINT_MESSAGE( |
178 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
179 |
ntot = 0 |
180 |
DO j = 1,MNC_MAX_ID |
181 |
IF (mnc_cw_vname(j)(1:MNC_MAX_CHAR) |
182 |
& .NE. mnc_blank_name(1:MNC_MAX_CHAR)) THEN |
183 |
|
184 |
ntot = ntot + 1 |
185 |
s1(1:NBLNK) = blnk(1:NBLNK) |
186 |
write(s1,'(a5,2i5,a3,a25,a3,i4)') 'MNC: ', |
187 |
& j, ntot, ' | ', |
188 |
& mnc_cw_vname(j)(1:20), ' | ', mnc_cw_vgind(j) |
189 |
CALL PRINT_MESSAGE( |
190 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
191 |
|
192 |
DO i = 1,mnc_cw_vnat(1,j) |
193 |
s1(1:NBLNK) = blnk(1:NBLNK) |
194 |
write(s1,'(a5,a14,i4,a3,a25,a3,a55)') |
195 |
& 'MNC: ',' text_at:',i, |
196 |
& ' : ', mnc_cw_vtnm(i,j)(1:25), ' : ', |
197 |
& mnc_cw_vtat(i,j)(1:55) |
198 |
CALL PRINT_MESSAGE( |
199 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
200 |
ENDDO |
201 |
DO i = 1,mnc_cw_vnat(2,j) |
202 |
s1(1:NBLNK) = blnk(1:NBLNK) |
203 |
write(s1,'(a5,a14,i4,a3,a25,a3,i20)') |
204 |
& 'MNC: ',' int__at:',i, |
205 |
& ' : ', mnc_cw_vinm(i,j)(1:25), ' : ', |
206 |
& mnc_cw_viat(i,j) |
207 |
CALL PRINT_MESSAGE( |
208 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
209 |
ENDDO |
210 |
DO i = 1,mnc_cw_vnat(3,j) |
211 |
s1(1:NBLNK) = blnk(1:NBLNK) |
212 |
write(s1,'(a5,a14,i4,a3,a25,a3,f25.10)') |
213 |
& 'MNC: ',' dbl__at:',i, |
214 |
& ' : ', mnc_cw_vdnm(i,j)(1:25), ' : ', |
215 |
& mnc_cw_vdat(i,j) |
216 |
CALL PRINT_MESSAGE( |
217 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
218 |
ENDDO |
219 |
|
220 |
ENDIF |
221 |
ENDDO |
222 |
IF (ntot .EQ. 0) THEN |
223 |
s1(1:NBLNK) = blnk(1:NBLNK) |
224 |
write(s1,'(a)') 'MNC: None defined!' |
225 |
CALL PRINT_MESSAGE( |
226 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
227 |
ENDIF |
228 |
|
229 |
_END_MASTER(myThid) |
230 |
|
231 |
RETURN |
232 |
END |
233 |
|
234 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
235 |
CBOP 0 |
236 |
C !ROUTINE: MNC_CW_INIT |
237 |
|
238 |
C !INTERFACE: |
239 |
SUBROUTINE MNC_CW_INIT( |
240 |
I sNx,sNy, OLx,OLy, nSx,nSy, nPx,nPy, Nr, NrPhys, |
241 |
I myThid ) |
242 |
|
243 |
C !DESCRIPTION: |
244 |
C Create the pre-defined grid types and variable types. |
245 |
|
246 |
C The grid type is a character string that encodes the presence and |
247 |
C types associated with the four possible dimensions. The character |
248 |
C string follows the format |
249 |
C \begin{center} |
250 |
C \texttt{H0\_H1\_H2\_\_V\_\_T} |
251 |
C \end{center} |
252 |
C where the terms \textit{H0}, \textit{H1}, \textit{H2}, \textit{V}, |
253 |
C \textit{T} can be almost any combination of the following: |
254 |
C \begin{center} |
255 |
C \begin{tabular}[h]{|ccc|c|c|}\hline |
256 |
C \multicolumn{3}{|c|}{Horizontal} & Vertical & Time \\ |
257 |
C \textit{H0}: location & \textit{H1}: dimensions & \textit{H2}: halo |
258 |
C & \textit{V}: location & \textit{T}: level \\\hline |
259 |
C \texttt{-} & xy & Hn & \texttt{-} & \texttt{-} \\ |
260 |
C U & x & Hy & i & t \\ |
261 |
C V & y & & c & \\ |
262 |
C Cen & & & & \\ |
263 |
C Cor & & & & \\\hline |
264 |
C \end{tabular} |
265 |
C \end{center} |
266 |
|
267 |
|
268 |
C !USES: |
269 |
implicit none |
270 |
#include "mnc_common.h" |
271 |
#include "EEPARAMS.h" |
272 |
|
273 |
C !INPUT PARAMETERS: |
274 |
integer myThid |
275 |
integer sNx,sNy, OLx,OLy, nSx,nSy, nPx,nPy, Nr |
276 |
integer NrPhys |
277 |
CEOP |
278 |
|
279 |
C !LOCAL VARIABLES: |
280 |
integer CW_MAX_LOC |
281 |
parameter ( CW_MAX_LOC = 5 ) |
282 |
integer i, ihorz,ihsub,ivert,itime,ihalo, is,ih, n,ntot |
283 |
integer ndim, ncomb, nvch, NrPh |
284 |
character*(MNC_MAX_CHAR) name |
285 |
character*(MNC_MAX_CHAR) dn(CW_MAX_LOC) |
286 |
character*(5) horz_dat(CW_MAX_LOC), hsub_dat(CW_MAX_LOC), |
287 |
& vert_dat(CW_MAX_LOC), time_dat(CW_MAX_LOC), |
288 |
& halo_dat(CW_MAX_LOC) |
289 |
integer dim(CW_MAX_LOC), ib(CW_MAX_LOC), ie(CW_MAX_LOC) |
290 |
|
291 |
C Functions |
292 |
integer ILNBLNK |
293 |
external ILNBLNK |
294 |
|
295 |
C ......12345....12345....12345....12345....12345... |
296 |
data horz_dat / |
297 |
& '- ', 'U ', 'V ', 'Cen ', 'Cor ' / |
298 |
data hsub_dat / |
299 |
& 'xy ', 'x ', 'y ', '- ', ' ' / |
300 |
data halo_dat / |
301 |
& 'Hn ', 'Hy ', '-- ', ' ', ' ' / |
302 |
data vert_dat / |
303 |
& '- ', 'C ', 'I ', 'Phys ', 'PhysI' / |
304 |
data time_dat / |
305 |
& '- ', 't ', ' ', ' ', ' ' / |
306 |
|
307 |
if (NrPhys .lt. 1) then |
308 |
NrPh = Nr |
309 |
else |
310 |
NrPh = NrPhys |
311 |
endif |
312 |
|
313 |
ncomb = 0 |
314 |
DO ihorz = 1,5 |
315 |
DO is = 1,3 |
316 |
DO ih = 1,2 |
317 |
|
318 |
C Loop just ONCE if the Horiz component is "-" |
319 |
ihsub = is |
320 |
ihalo = ih |
321 |
IF (ihorz .EQ. 1) THEN |
322 |
IF ((is .EQ. 1) .AND. (ih .EQ. 1)) THEN |
323 |
ihsub = 4 |
324 |
ihalo = 3 |
325 |
ELSE |
326 |
GOTO 10 |
327 |
ENDIF |
328 |
ENDIF |
329 |
|
330 |
DO ivert = 1,5 |
331 |
DO itime = 1,2 |
332 |
|
333 |
C horiz and hsub |
334 |
name(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
335 |
n = ILNBLNK(horz_dat(ihorz)) |
336 |
name(1:n) = horz_dat(ihorz)(1:n) |
337 |
ntot = n + 1 |
338 |
name(ntot:ntot) = '_' |
339 |
n = ILNBLNK(hsub_dat(ihsub)) |
340 |
name((ntot+1):(ntot+n)) = hsub_dat(ihsub)(1:n) |
341 |
ntot = ntot + n |
342 |
|
343 |
C halo, vert, and time |
344 |
write(name((ntot+1):(ntot+5)), '(a1,2a2)') |
345 |
& '_', halo_dat(ihalo)(1:2), '__' |
346 |
nvch = ILNBLNK(vert_dat(ivert)) |
347 |
n = ntot+6+nvch-1 |
348 |
name((ntot+6):(n)) = vert_dat(ivert)(1:nvch) |
349 |
write(name((n+1):(n+3)), '(a2,a1)') |
350 |
& '__', time_dat(itime)(1:1) |
351 |
|
352 |
ndim = 0 |
353 |
DO i = 1,CW_MAX_LOC |
354 |
dn(i)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
355 |
dim(i) = 0 |
356 |
ib(i) = 0 |
357 |
ie(i) = 0 |
358 |
ENDDO |
359 |
|
360 |
C Horizontal dimensions |
361 |
IF (halo_dat(ihalo)(1:5) .EQ. 'Hn ') THEN |
362 |
|
363 |
IF (hsub_dat(ihsub)(1:1) .EQ. 'x') THEN |
364 |
ndim = ndim + 1 |
365 |
IF ( (horz_dat(ihorz)(1:3) .EQ. 'Cen') |
366 |
& .OR. (horz_dat(ihorz)(1:1) .EQ. 'V') ) THEN |
367 |
dn(ndim)(1:1) = 'X' |
368 |
dim(ndim) = sNx + 2*OLx |
369 |
ib(ndim) = OLx + 1 |
370 |
ie(ndim) = OLx + sNx |
371 |
ENDIF |
372 |
IF ( (horz_dat(ihorz)(1:3) .EQ. 'Cor') |
373 |
& .OR. (horz_dat(ihorz)(1:1) .EQ. 'U') ) THEN |
374 |
dn(ndim)(1:3) = 'Xp1' |
375 |
dim(ndim) = sNx + 2*OLx |
376 |
ib(ndim) = OLx + 1 |
377 |
ie(ndim) = OLx + sNx + 1 |
378 |
ENDIF |
379 |
ENDIF |
380 |
IF ((hsub_dat(ihsub)(1:1) .EQ. 'y') |
381 |
& .OR. (hsub_dat(ihsub)(2:2) .EQ. 'y')) THEN |
382 |
ndim = ndim + 1 |
383 |
IF ( (horz_dat(ihorz)(1:3) .EQ. 'Cen') |
384 |
& .OR. (horz_dat(ihorz)(1:1) .EQ. 'U') ) THEN |
385 |
dn(ndim)(1:1) = 'Y' |
386 |
dim(ndim) = sNy + 2*OLy |
387 |
ib(ndim) = OLy + 1 |
388 |
ie(ndim) = OLy + sNy |
389 |
ENDIF |
390 |
IF ( (horz_dat(ihorz)(1:3) .EQ. 'Cor') |
391 |
& .OR. (horz_dat(ihorz)(1:1) .EQ. 'V') ) THEN |
392 |
dn(ndim)(1:3) = 'Yp1' |
393 |
dim(ndim) = sNy + 2*OLy |
394 |
ib(ndim) = OLy + 1 |
395 |
ie(ndim) = OLy + sNy + 1 |
396 |
ENDIF |
397 |
ENDIF |
398 |
|
399 |
ELSEIF (halo_dat(ihalo)(1:5) .EQ. 'Hy ') THEN |
400 |
|
401 |
IF (hsub_dat(ihsub)(1:1) .EQ. 'x') THEN |
402 |
ndim = ndim + 1 |
403 |
dn(ndim)(1:3) = 'Xwh' |
404 |
dim(ndim) = sNx + 2*OLx |
405 |
ib(ndim) = 1 |
406 |
ie(ndim) = sNx + 2*OLx |
407 |
ENDIF |
408 |
IF ((hsub_dat(ihsub)(1:1) .EQ. 'y') |
409 |
& .OR. (hsub_dat(ihsub)(2:2) .EQ. 'y')) THEN |
410 |
ndim = ndim + 1 |
411 |
dn(ndim)(1:3) = 'Ywh' |
412 |
dim(ndim) = sNy + 2*OLy |
413 |
ib(ndim) = 1 |
414 |
ie(ndim) = sNy + 2*OLy |
415 |
ENDIF |
416 |
|
417 |
ENDIF |
418 |
|
419 |
C Vertical dimension |
420 |
IF (vert_dat(ivert)(1:1) .EQ. 'C') THEN |
421 |
ndim = ndim + 1 |
422 |
dn(ndim)(1:1) = 'Z' |
423 |
dim(ndim) = Nr |
424 |
ib(ndim) = 1 |
425 |
ie(ndim) = Nr |
426 |
ENDIF |
427 |
IF (vert_dat(ivert)(1:1) .EQ. 'I') THEN |
428 |
ndim = ndim + 1 |
429 |
dn(ndim)(1:3) = 'Zp1' |
430 |
dim(ndim) = Nr + 1 |
431 |
ib(ndim) = 1 |
432 |
ie(ndim) = Nr + 1 |
433 |
ENDIF |
434 |
IF (vert_dat(ivert)(1:5) .EQ. 'Phys ') THEN |
435 |
ndim = ndim + 1 |
436 |
dn(ndim)(1:5) = 'Zphys' |
437 |
dim(ndim) = NrPh |
438 |
ib(ndim) = 1 |
439 |
ie(ndim) = NrPh |
440 |
ENDIF |
441 |
IF (vert_dat(ivert)(1:5) .EQ. 'PhysI') THEN |
442 |
ndim = ndim + 1 |
443 |
dn(ndim)(1:7) = 'Zphysm1' |
444 |
dim(ndim) = NrPh - 1 |
445 |
ib(ndim) = 1 |
446 |
ie(ndim) = NrPh - 1 |
447 |
ENDIF |
448 |
|
449 |
C Time dimension |
450 |
IF (time_dat(itime)(1:1) .EQ. 't') THEN |
451 |
ndim = ndim + 1 |
452 |
dn(ndim)(1:1) = 'T' |
453 |
dim(ndim) = -1 |
454 |
ib(ndim) = 1 |
455 |
ie(ndim) = 1 |
456 |
ENDIF |
457 |
|
458 |
IF (ndim .GT. 0) THEN |
459 |
#ifdef MNC_DEBUG |
460 |
ncomb = ncomb + 1 |
461 |
write(*,'(i4,a3,a15,i3,a3,5i4,a4,5i4,a4,5i4,6a4)') |
462 |
& ncomb, ' : ', name(1:15), ndim, |
463 |
& ' : ', (dim(i), i=1,5), |
464 |
& ' | ', (ib(i), i=1,5), |
465 |
& ' | ', (ie(i), i=1,5), |
466 |
& ' | ', (dn(i)(1:4), i=1,5) |
467 |
#endif |
468 |
|
469 |
CALL MNC_CW_ADD_GNAME(name, ndim, |
470 |
& dim, dn, ib, ie, myThid) |
471 |
ENDIF |
472 |
|
473 |
ENDDO |
474 |
ENDDO |
475 |
|
476 |
10 CONTINUE |
477 |
ENDDO |
478 |
ENDDO |
479 |
ENDDO |
480 |
|
481 |
RETURN |
482 |
END |
483 |
|
484 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
485 |
CBOP 0 |
486 |
C !ROUTINE: MNC_CW_APPEND_VNAME |
487 |
|
488 |
C !INTERFACE: |
489 |
SUBROUTINE MNC_CW_APPEND_VNAME( |
490 |
I vname, |
491 |
I gname, |
492 |
I bi_dim, bj_dim, |
493 |
I myThid ) |
494 |
|
495 |
C !DESCRIPTION: |
496 |
C If it is not yet defined within the MNC CW layer, append a |
497 |
C variable type. Calls MNC\_CW\_ADD\_VNAME(). |
498 |
|
499 |
C !USES: |
500 |
implicit none |
501 |
#include "mnc_common.h" |
502 |
|
503 |
C !INPUT PARAMETERS: |
504 |
integer myThid, bi_dim, bj_dim |
505 |
character*(*) vname, gname |
506 |
CEOP |
507 |
|
508 |
C !LOCAL VARIABLES: |
509 |
integer indv |
510 |
|
511 |
C Check whether vname is defined |
512 |
CALL MNC_GET_IND(MNC_MAX_ID, vname, mnc_cw_vname, indv, myThid) |
513 |
IF (indv .LT. 1) THEN |
514 |
CALL MNC_CW_ADD_VNAME(vname, gname, bi_dim, bj_dim, myThid) |
515 |
ENDIF |
516 |
|
517 |
|
518 |
RETURN |
519 |
END |
520 |
|
521 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
522 |
CBOP 0 |
523 |
C !ROUTINE: MNC_CW_ADD_VNAME |
524 |
|
525 |
C !INTERFACE: |
526 |
SUBROUTINE MNC_CW_ADD_VNAME( |
527 |
I vname, |
528 |
I gname, |
529 |
I bi_dim, bj_dim, |
530 |
I myThid ) |
531 |
|
532 |
C !DESCRIPTION: |
533 |
C Add a variable type to the MNC CW layer. The variable type is an |
534 |
C association between a variable type name and the following items: |
535 |
C \begin{center} |
536 |
C \begin{tabular}[h]{|ll|}\hline |
537 |
C \textbf{Item} & \textbf{Purpose} \\\hline |
538 |
C grid type & defines the in-memory arrangement \\ |
539 |
C \texttt{bi,bj} dimensions & tiling indices, if present \\\hline |
540 |
C \end{tabular} |
541 |
C \end{center} |
542 |
|
543 |
C !USES: |
544 |
implicit none |
545 |
#include "mnc_common.h" |
546 |
#include "EEPARAMS.h" |
547 |
|
548 |
C !INPUT PARAMETERS: |
549 |
integer myThid, bi_dim, bj_dim |
550 |
character*(*) vname, gname |
551 |
CEOP |
552 |
|
553 |
C !LOCAL VARIABLES: |
554 |
integer i, nvf,nvl, ngf,ngl, indv,indg |
555 |
character*(MAX_LEN_MBUF) msgbuf |
556 |
|
557 |
C Functions |
558 |
integer IFNBLNK, ILNBLNK |
559 |
|
560 |
nvf = IFNBLNK(vname) |
561 |
nvl = ILNBLNK(vname) |
562 |
ngf = IFNBLNK(gname) |
563 |
ngl = ILNBLNK(gname) |
564 |
|
565 |
C Check that this vname is not already defined |
566 |
CALL MNC_GET_IND(MNC_MAX_ID, vname, mnc_cw_vname, indv, myThid) |
567 |
IF (indv .GT. 0) THEN |
568 |
write(msgbuf,'(3a)') 'MNC_CW_ADD_VNAME ERROR: ''', |
569 |
& vname(nvf:nvl), ''' is already defined' |
570 |
CALL print_error(msgbuf, mythid) |
571 |
stop 'ABNORMAL END: S/R MNC_CW_ADD_VNAME' |
572 |
ENDIF |
573 |
CALL MNC_GET_NEXT_EMPTY_IND(MNC_MAX_ID, mnc_cw_vname, |
574 |
& indv, myThid) |
575 |
|
576 |
C Check that gname exists |
577 |
CALL MNC_GET_IND(MNC_MAX_ID, gname, mnc_cw_gname, indg, myThid) |
578 |
IF (indg .LT. 1) THEN |
579 |
write(msgbuf,'(3a)') 'MNC_CW_ADD_VNAME ERROR: ''', |
580 |
& gname(ngf:ngl), ''' is not defined' |
581 |
CALL print_error(msgbuf, mythid) |
582 |
stop 'ABNORMAL END: S/R MNC_CW_ADD_VNAME' |
583 |
ENDIF |
584 |
|
585 |
mnc_cw_vname(indv)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
586 |
mnc_cw_vname(indv)(1:(nvl-nvf+1)) = vname(nvf:nvl) |
587 |
mnc_cw_vgind(indv) = indg |
588 |
DO i = 1,3 |
589 |
mnc_cw_vnat(i,indv) = 0 |
590 |
ENDDO |
591 |
mnc_cw_vbij(1,indv) = bi_dim |
592 |
mnc_cw_vbij(2,indv) = bj_dim |
593 |
|
594 |
CALL MNC_CW_ADD_VATTR_TEXT(vname,1,'mitgcm_grid',gname, myThid) |
595 |
|
596 |
RETURN |
597 |
END |
598 |
|
599 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
600 |
CBOP 0 |
601 |
C !ROUTINE: MNC_CW_DEL_VNAME |
602 |
|
603 |
C !INTERFACE: |
604 |
SUBROUTINE MNC_CW_DEL_VNAME( |
605 |
I vname, |
606 |
I myThid ) |
607 |
|
608 |
C !DESCRIPTION: |
609 |
C Delete a variable type from the MNC CW layer. |
610 |
|
611 |
C !USES: |
612 |
implicit none |
613 |
#include "mnc_common.h" |
614 |
#include "EEPARAMS.h" |
615 |
|
616 |
C !INPUT PARAMETERS: |
617 |
integer myThid |
618 |
character*(*) vname |
619 |
CEOP |
620 |
|
621 |
C !LOCAL VARIABLES: |
622 |
integer i, indv |
623 |
|
624 |
C Check that this vname is not already defined |
625 |
CALL MNC_GET_IND(MNC_MAX_ID, vname, mnc_cw_vname, indv, myThid) |
626 |
IF (indv .LT. 1) THEN |
627 |
RETURN |
628 |
ENDIF |
629 |
|
630 |
mnc_cw_vname(indv)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
631 |
mnc_cw_vgind(indv) = 0 |
632 |
DO i = 1,3 |
633 |
mnc_cw_vnat(i,indv) = 0 |
634 |
ENDDO |
635 |
|
636 |
RETURN |
637 |
END |
638 |
|
639 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
640 |
CBOP 0 |
641 |
C !ROUTINE: MNC_CW_ADD_VATTR_TEXT |
642 |
|
643 |
C !INTERFACE: |
644 |
SUBROUTINE MNC_CW_ADD_VATTR_TEXT( |
645 |
I vname, |
646 |
I ntat, |
647 |
I tnames, |
648 |
I tvals, |
649 |
I myThid ) |
650 |
|
651 |
C !DESCRIPTION: |
652 |
C Add a text attribute |
653 |
|
654 |
C !USES: |
655 |
implicit none |
656 |
|
657 |
C !INPUT PARAMETERS: |
658 |
integer myThid, ntat |
659 |
character*(*) vname, tnames(*), tvals(*) |
660 |
CEOP |
661 |
|
662 |
CALL MNC_CW_ADD_VATTR_ANY(vname, |
663 |
& ntat, 0, 0, |
664 |
& tnames, ' ', ' ', |
665 |
& tvals, 0, 0.0D0, myThid ) |
666 |
|
667 |
RETURN |
668 |
END |
669 |
|
670 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
671 |
CBOP |
672 |
C !ROUTINE: MNC_CW_ADD_VATTR_INT |
673 |
|
674 |
C !INTERFACE: |
675 |
SUBROUTINE MNC_CW_ADD_VATTR_INT( |
676 |
I vname, |
677 |
I niat, |
678 |
I inames, |
679 |
I ivals, |
680 |
I myThid ) |
681 |
|
682 |
C !DESCRIPTION: |
683 |
|
684 |
C !USES: |
685 |
implicit none |
686 |
|
687 |
C !INPUT PARAMETERS: |
688 |
integer myThid, niat |
689 |
character*(*) vname, inames(*) |
690 |
integer ivals(*) |
691 |
CEOP |
692 |
|
693 |
CALL MNC_CW_ADD_VATTR_ANY(vname, |
694 |
& 0, niat, 0, |
695 |
& ' ', inames, ' ', |
696 |
& ' ', ivals, 0.0D0, myThid ) |
697 |
|
698 |
RETURN |
699 |
END |
700 |
|
701 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
702 |
CBOP 0 |
703 |
C !ROUTINE: MNC_CW_ADD_VATTR_DBL |
704 |
|
705 |
C !INTERFACE: |
706 |
SUBROUTINE MNC_CW_ADD_VATTR_DBL( |
707 |
I vname, |
708 |
I ndat, |
709 |
I dnames, |
710 |
I dvals, |
711 |
I myThid ) |
712 |
|
713 |
C !DESCRIPTION: |
714 |
|
715 |
C !USES: |
716 |
implicit none |
717 |
|
718 |
C !INPUT PARAMETERS: |
719 |
integer myThid, ndat |
720 |
character*(*) vname, dnames(*) |
721 |
REAL*8 dvals(*) |
722 |
CEOP |
723 |
|
724 |
CALL MNC_CW_ADD_VATTR_ANY(vname, |
725 |
& 0, 0, ndat, |
726 |
& ' ', ' ', dnames, |
727 |
& ' ', 0, dvals, myThid ) |
728 |
|
729 |
RETURN |
730 |
END |
731 |
|
732 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
733 |
CBOP 1 |
734 |
C !ROUTINE: MNC_CW_ADD_VATTR_ANY |
735 |
|
736 |
C !INTERFACE: |
737 |
SUBROUTINE MNC_CW_ADD_VATTR_ANY( |
738 |
I vname, |
739 |
I ntat, niat, ndat, |
740 |
I tnames, inames, dnames, |
741 |
I tvals, ivals, dvals, |
742 |
I myThid ) |
743 |
|
744 |
C !DESCRIPTION: |
745 |
|
746 |
C !USES: |
747 |
implicit none |
748 |
#include "mnc_common.h" |
749 |
#include "EEPARAMS.h" |
750 |
|
751 |
C !INPUT PARAMETERS: |
752 |
integer myThid, ntat, niat, ndat |
753 |
character*(*) vname |
754 |
character*(*) tnames(*), inames(*), dnames(*) |
755 |
character*(*) tvals(*) |
756 |
integer ivals(*) |
757 |
REAL*8 dvals(*) |
758 |
CEOP |
759 |
|
760 |
C !LOCAL VARIABLES: |
761 |
integer i, n, nvf,nvl, n1,n2, indv |
762 |
character*(MAX_LEN_MBUF) msgbuf |
763 |
|
764 |
C Functions |
765 |
integer IFNBLNK, ILNBLNK |
766 |
|
767 |
nvf = IFNBLNK(vname) |
768 |
nvl = ILNBLNK(vname) |
769 |
|
770 |
C Check that vname is defined |
771 |
CALL MNC_GET_IND(MNC_MAX_ID, vname, mnc_cw_vname, indv, myThid) |
772 |
IF (indv .LT. 1) THEN |
773 |
write(msgbuf,'(3a)') 'MNC_CW_ADD_VATTR_ANY ERROR: ''', |
774 |
& vname(nvf:nvl), ''' is not defined' |
775 |
CALL print_error(msgbuf, mythid) |
776 |
stop 'ABNORMAL END: S/R MNC_CW_ADD_VATTR_ANY' |
777 |
ENDIF |
778 |
|
779 |
C Text Attributes |
780 |
n = mnc_cw_vnat(1,indv) |
781 |
DO i = 1,ntat |
782 |
n1 = IFNBLNK(tnames(i)) |
783 |
n2 = ILNBLNK(tnames(i)) |
784 |
mnc_cw_vtnm(n+i,indv)(1:(n2-n1+1)) = tnames(i)(n1:n2) |
785 |
n1 = IFNBLNK(tvals(i)) |
786 |
n2 = ILNBLNK(tvals(i)) |
787 |
mnc_cw_vtat(n+i,indv)(1:(n2-n1+1)) = tvals(i)(n1:n2) |
788 |
ENDDO |
789 |
mnc_cw_vnat(1,indv) = n + ntat |
790 |
|
791 |
C Integer Attributes |
792 |
n = mnc_cw_vnat(2,indv) |
793 |
DO i = 1,niat |
794 |
n1 = IFNBLNK(inames(i)) |
795 |
n2 = ILNBLNK(inames(i)) |
796 |
mnc_cw_vinm(n+i,indv)(1:(n2-n1+1)) = inames(i)(n1:n2) |
797 |
mnc_cw_viat(n+i,indv) = ivals(i) |
798 |
ENDDO |
799 |
mnc_cw_vnat(2,indv) = n + niat |
800 |
|
801 |
C Double Attributes |
802 |
n = mnc_cw_vnat(3,indv) |
803 |
DO i = 1,ndat |
804 |
n1 = IFNBLNK(dnames(i)) |
805 |
n2 = ILNBLNK(dnames(i)) |
806 |
mnc_cw_vdnm(n+i,indv)(1:(n2-n1+1)) = dnames(i)(n1:n2) |
807 |
mnc_cw_vdat(n+i,indv) = dvals(i) |
808 |
ENDDO |
809 |
mnc_cw_vnat(3,indv) = n + ndat |
810 |
|
811 |
RETURN |
812 |
END |
813 |
|
814 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
815 |
CBOP 1 |
816 |
C !ROUTINE: MNC_CW_GET_TILE_NUM |
817 |
|
818 |
C !INTERFACE: |
819 |
SUBROUTINE MNC_CW_GET_TILE_NUM( |
820 |
I bi, bj, |
821 |
O uniq_tnum, |
822 |
I myThid ) |
823 |
|
824 |
C !DESCRIPTION: |
825 |
|
826 |
C !USES: |
827 |
implicit none |
828 |
#include "EEPARAMS.h" |
829 |
#include "SIZE.h" |
830 |
#ifdef ALLOW_EXCH2 |
831 |
#include "W2_EXCH2_TOPOLOGY.h" |
832 |
#include "W2_EXCH2_PARAMS.h" |
833 |
#endif |
834 |
|
835 |
C !INPUT PARAMETERS: |
836 |
integer myThid, bi,bj, uniq_tnum |
837 |
CEOP |
838 |
|
839 |
C !LOCAL VARIABLES: |
840 |
integer iG,jG |
841 |
|
842 |
iG = 0 |
843 |
jG = 0 |
844 |
|
845 |
#ifdef ALLOW_EXCH2 |
846 |
|
847 |
uniq_tnum = W2_myTileList(bi) |
848 |
|
849 |
#else |
850 |
|
851 |
C Global tile number for simple (non-cube) domains |
852 |
iG = bi+(myXGlobalLo-1)/sNx |
853 |
jG = bj+(myYGlobalLo-1)/sNy |
854 |
|
855 |
uniq_tnum = (jG - 1)*(nPx*nSx) + iG |
856 |
|
857 |
#endif |
858 |
|
859 |
CEH3 write(*,*) 'iG,jG,uniq_tnum :', iG,jG,uniq_tnum |
860 |
|
861 |
RETURN |
862 |
END |
863 |
|
864 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
865 |
CBOP 1 |
866 |
C !ROUTINE: MNC_CW_FILE_AORC |
867 |
|
868 |
C !INTERFACE: |
869 |
SUBROUTINE MNC_CW_FILE_AORC( |
870 |
I fname, |
871 |
O indf, |
872 |
I myThid ) |
873 |
|
874 |
C !DESCRIPTION: |
875 |
C Open a NetCDF file, appending to the file if it already exists |
876 |
C and, if not, creating a new file. |
877 |
|
878 |
C !USES: |
879 |
implicit none |
880 |
#include "netcdf.inc" |
881 |
#include "mnc_common.h" |
882 |
#include "EEPARAMS.h" |
883 |
|
884 |
C !INPUT PARAMETERS: |
885 |
integer myThid, indf |
886 |
character*(*) fname |
887 |
CEOP |
888 |
|
889 |
C !LOCAL VARIABLES: |
890 |
integer ierr |
891 |
|
892 |
C Check if the file is already open |
893 |
CALL MNC_GET_IND(MNC_MAX_ID, fname, mnc_f_names, indf, myThid) |
894 |
IF (indf .GT. 0) THEN |
895 |
RETURN |
896 |
ENDIF |
897 |
|
898 |
C Try to open an existing file |
899 |
CALL MNC_FILE_TRY_READ(fname, ierr, indf, myThid) |
900 |
IF (ierr .EQ. NF_NOERR) THEN |
901 |
RETURN |
902 |
ENDIF |
903 |
|
904 |
C Try to create a new one |
905 |
CALL MNC_FILE_OPEN(fname, 0, indf, myThid) |
906 |
|
907 |
RETURN |
908 |
END |
909 |
|
910 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
911 |
|