/[MITgcm]/MITgcm/pkg/mnc/mnc_cwrapper.F
ViewVC logotype

Annotation of /MITgcm/pkg/mnc/mnc_cwrapper.F

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


Revision 1.15 - (hide annotations) (download)
Tue Jul 6 21:04:28 2004 UTC (19 years, 10 months ago) by edhill
Branch: MAIN
Changes since 1.14: +84 -1 lines
 o add delete subroutines for the CW-layer grids and variables

1 edhill 1.15 C $Header: /u/gcmpack/MITgcm/pkg/mnc/mnc_cwrapper.F,v 1.14 2004/07/06 03:55:53 edhill Exp $
2 edhill 1.1 C $Name: $
3    
4     #include "MNC_OPTIONS.h"
5    
6     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
7 edhill 1.12 CBOP 0
8 edhill 1.11 C !ROUTINE: MNC_CW_ADD_GNAME
9 edhill 1.1
10 edhill 1.11 C !INTERFACE:
11 edhill 1.2 SUBROUTINE MNC_CW_ADD_GNAME(
12 edhill 1.1 I name,
13     I ndim,
14     I dlens,
15     I dnames,
16 edhill 1.9 I inds_beg, inds_end,
17     I myThid )
18 edhill 1.1
19 edhill 1.11 C !DESCRIPTION:
20     C Add a grid name to the MNC convenience wrapper layer.
21    
22     C !USES:
23 edhill 1.1 implicit none
24     #include "mnc_common.h"
25     #include "EEPARAMS.h"
26    
27 edhill 1.11 C !INPUT PARAMETERS:
28 edhill 1.1 integer myThid, ndim
29     character*(*) name
30     integer dlens(*), inds_beg(*), inds_end(*)
31     character*(*) dnames(*)
32 edhill 1.12 CEOP
33 edhill 1.1
34 edhill 1.11 C !LOCAL VARIABLES:
35     integer i, nnf,nnl, indg
36     character*(MAX_LEN_MBUF) msgbuf
37 edhill 1.12
38 edhill 1.2 C Functions
39     integer IFNBLNK, ILNBLNK
40    
41 edhill 1.1 nnf = IFNBLNK(name)
42     nnl = ILNBLNK(name)
43    
44     C Check that this name is not already defined
45 edhill 1.9 CALL MNC_GET_IND(MNC_MAX_ID, name, mnc_cw_gname, indg, myThid)
46 edhill 1.1 IF (indg .GT. 0) THEN
47 edhill 1.2 write(msgbuf,'(3a)') 'MNC_CW_ADD_GNAME ERROR: ''', name,
48 edhill 1.1 & ''' is already defined'
49     CALL print_error(msgbuf, mythid)
50 edhill 1.2 stop 'ABNORMAL END: S/R MNC_CW_ADD_GNAME'
51 edhill 1.1 ENDIF
52 edhill 1.9 CALL MNC_GET_NEXT_EMPTY_IND(MNC_MAX_ID, mnc_cw_gname,
53     & indg, myThid)
54 edhill 1.1
55 edhill 1.2 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 edhill 1.1 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 edhill 1.2 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
73 edhill 1.15 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 edhill 1.12 CBOP 1
117 edhill 1.11 C !ROUTINE: MNC_CW_DUMP
118 edhill 1.2
119 edhill 1.11 C !INTERFACE:
120 edhill 1.10 SUBROUTINE MNC_CW_DUMP( myThid )
121 edhill 1.2
122 edhill 1.11 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 edhill 1.2 implicit none
128     #include "mnc_common.h"
129 edhill 1.10 #include "SIZE.h"
130     #include "EEPARAMS.h"
131     #include "PARAMS.h"
132    
133 edhill 1.11 C !INPUT PARAMETERS:
134 edhill 1.10 integer myThid
135 edhill 1.12 CEOP
136 edhill 1.2
137 edhill 1.11 C !LOCAL VARIABLES:
138 edhill 1.2 integer i,j, ntot
139 edhill 1.10 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 edhill 1.2 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 edhill 1.10 s1(1:NBLNK) = blnk(1:NBLNK)
161 edhill 1.14 write(s1,'(a5,2i5,a3,a20,i3,a3,5i4,a4,5i4,a4,5i4,6a8)')
162 edhill 1.10 & 'MNC: ',
163 edhill 1.2 & 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 edhill 1.14 & ' | ', (mnc_cw_dn(i,j)(1:7), i=1,5)
168 edhill 1.10 CALL PRINT_MESSAGE(
169     & s1, standardMessageUnit, SQUEEZE_RIGHT, mythid)
170    
171 edhill 1.2 ENDIF
172     ENDDO
173 edhill 1.10
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 edhill 1.3 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 edhill 1.10
184 edhill 1.3 ntot = ntot + 1
185 edhill 1.10 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 edhill 1.3 DO i = 1,mnc_cw_vnat(1,j)
193 edhill 1.10 s1(1:NBLNK) = blnk(1:NBLNK)
194     write(s1,'(a5,a14,i4,a3,a25,a3,a55)')
195     & 'MNC: ',' text_at:',i,
196 edhill 1.3 & ' : ', mnc_cw_vtnm(i,j)(1:25), ' : ',
197 edhill 1.8 & mnc_cw_vtat(i,j)(1:55)
198 edhill 1.10 CALL PRINT_MESSAGE(
199     & s1, standardMessageUnit, SQUEEZE_RIGHT, mythid)
200 edhill 1.3 ENDDO
201     DO i = 1,mnc_cw_vnat(2,j)
202 edhill 1.10 s1(1:NBLNK) = blnk(1:NBLNK)
203     write(s1,'(a5,a14,i4,a3,a25,a3,i20)')
204     & 'MNC: ',' int__at:',i,
205 edhill 1.3 & ' : ', mnc_cw_vinm(i,j)(1:25), ' : ',
206     & mnc_cw_viat(i,j)
207 edhill 1.10 CALL PRINT_MESSAGE(
208     & s1, standardMessageUnit, SQUEEZE_RIGHT, mythid)
209 edhill 1.3 ENDDO
210     DO i = 1,mnc_cw_vnat(3,j)
211 edhill 1.10 s1(1:NBLNK) = blnk(1:NBLNK)
212     write(s1,'(a5,a14,i4,a3,a25,a3,f25.10)')
213     & 'MNC: ',' dbl__at:',i,
214 edhill 1.3 & ' : ', mnc_cw_vdnm(i,j)(1:25), ' : ',
215     & mnc_cw_vdat(i,j)
216 edhill 1.10 CALL PRINT_MESSAGE(
217     & s1, standardMessageUnit, SQUEEZE_RIGHT, mythid)
218     ENDDO
219    
220 edhill 1.3 ENDIF
221     ENDDO
222     IF (ntot .EQ. 0) THEN
223 edhill 1.10 s1(1:NBLNK) = blnk(1:NBLNK)
224     write(s1,'(a)') 'MNC: None defined!'
225     CALL PRINT_MESSAGE(
226     & s1, standardMessageUnit, SQUEEZE_RIGHT, mythid)
227 edhill 1.3 ENDIF
228 edhill 1.10
229     _END_MASTER(myThid)
230 edhill 1.3
231 edhill 1.2 RETURN
232     END
233 edhill 1.1
234     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
235 edhill 1.12 CBOP 0
236 edhill 1.11 C !ROUTINE: MNC_CW_INIT
237 edhill 1.1
238 edhill 1.11 C !INTERFACE:
239 edhill 1.1 SUBROUTINE MNC_CW_INIT(
240 edhill 1.14 I sNx,sNy, OLx,OLy, nSx,nSy, nPx,nPy, Nr, NrPhys,
241 edhill 1.9 I myThid )
242 edhill 1.1
243 edhill 1.11 C !DESCRIPTION:
244 edhill 1.12 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 edhill 1.11 C !USES:
269 edhill 1.1 implicit none
270     #include "mnc_common.h"
271     #include "EEPARAMS.h"
272    
273 edhill 1.11 C !INPUT PARAMETERS:
274 edhill 1.1 integer myThid
275     integer sNx,sNy, OLx,OLy, nSx,nSy, nPx,nPy, Nr
276 edhill 1.14 integer NrPhys
277 edhill 1.12 CEOP
278 edhill 1.1
279 edhill 1.11 C !LOCAL VARIABLES:
280 edhill 1.1 integer CW_MAX_LOC
281     parameter ( CW_MAX_LOC = 5 )
282 edhill 1.2 integer i, ihorz,ihsub,ivert,itime,ihalo, is,ih, n,ntot
283 edhill 1.14 integer ndim, ncomb, nvch, NrPh
284 edhill 1.1 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 edhill 1.12
291 edhill 1.11 C Functions
292 edhill 1.14 integer ILNBLNK
293     external ILNBLNK
294 edhill 1.1
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 edhill 1.2 data halo_dat /
301     & 'Hn ', 'Hy ', '-- ', ' ', ' ' /
302 edhill 1.1 data vert_dat /
303 edhill 1.14 & '- ', 'C ', 'I ', 'Phys ', 'PhysI' /
304 edhill 1.1 data time_dat /
305     & '- ', 't ', ' ', ' ', ' ' /
306    
307 edhill 1.14 if (NrPhys .lt. 1) then
308     NrPh = Nr
309     else
310     NrPh = NrPhys
311     endif
312    
313 edhill 1.2 ncomb = 0
314 edhill 1.1 DO ihorz = 1,5
315     DO is = 1,3
316 edhill 1.2 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 edhill 1.1 ENDIF
329 edhill 1.2
330 edhill 1.14 DO ivert = 1,5
331 edhill 1.2 DO itime = 1,2
332    
333 edhill 1.1 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 edhill 1.14 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 edhill 1.1
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 edhill 1.2 ib(i) = 0
357     ie(i) = 0
358 edhill 1.1 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 edhill 1.2 ie(ndim) = sNy + 2*OLy
415 edhill 1.1 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 edhill 1.14 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 edhill 1.1
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 edhill 1.2 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 edhill 1.1
469 edhill 1.9 CALL MNC_CW_ADD_GNAME(name, ndim,
470     & dim, dn, ib, ie, myThid)
471 edhill 1.1 ENDIF
472    
473     ENDDO
474     ENDDO
475 edhill 1.2
476     10 CONTINUE
477 edhill 1.1 ENDDO
478     ENDDO
479     ENDDO
480    
481 edhill 1.2 RETURN
482     END
483    
484     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
485 edhill 1.12 CBOP 0
486 edhill 1.13 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 edhill 1.11 C !ROUTINE: MNC_CW_ADD_VNAME
524 edhill 1.2
525 edhill 1.11 C !INTERFACE:
526 edhill 1.2 SUBROUTINE MNC_CW_ADD_VNAME(
527     I vname,
528 edhill 1.5 I gname,
529 edhill 1.9 I bi_dim, bj_dim,
530     I myThid )
531 edhill 1.2
532 edhill 1.13 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 edhill 1.12 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 edhill 1.11 C !USES:
544 edhill 1.2 implicit none
545     #include "mnc_common.h"
546     #include "EEPARAMS.h"
547    
548 edhill 1.11 C !INPUT PARAMETERS:
549 edhill 1.5 integer myThid, bi_dim, bj_dim
550 edhill 1.2 character*(*) vname, gname
551 edhill 1.12 CEOP
552 edhill 1.2
553 edhill 1.11 C !LOCAL VARIABLES:
554     integer i, nvf,nvl, ngf,ngl, indv,indg
555     character*(MAX_LEN_MBUF) msgbuf
556 edhill 1.12
557 edhill 1.2 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 edhill 1.9 CALL MNC_GET_IND(MNC_MAX_ID, vname, mnc_cw_vname, indv, myThid)
567 edhill 1.2 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 edhill 1.9 CALL MNC_GET_NEXT_EMPTY_IND(MNC_MAX_ID, mnc_cw_vname,
574     & indv, myThid)
575 edhill 1.2
576     C Check that gname exists
577 edhill 1.9 CALL MNC_GET_IND(MNC_MAX_ID, gname, mnc_cw_gname, indg, myThid)
578 edhill 1.2 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 edhill 1.5 mnc_cw_vbij(1,indv) = bi_dim
592     mnc_cw_vbij(2,indv) = bj_dim
593 edhill 1.6
594 edhill 1.9 CALL MNC_CW_ADD_VATTR_TEXT(vname,1,'mitgcm_grid',gname, myThid)
595 edhill 1.2
596     RETURN
597     END
598    
599     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
600 edhill 1.12 CBOP 0
601 edhill 1.15 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 edhill 1.11 C !ROUTINE: MNC_CW_ADD_VATTR_TEXT
642 edhill 1.2
643 edhill 1.11 C !INTERFACE:
644 edhill 1.3 SUBROUTINE MNC_CW_ADD_VATTR_TEXT(
645     I vname,
646     I ntat,
647     I tnames,
648 edhill 1.9 I tvals,
649     I myThid )
650 edhill 1.3
651 edhill 1.11 C !DESCRIPTION:
652     C Add a text attribute
653    
654     C !USES:
655 edhill 1.3 implicit none
656    
657 edhill 1.11 C !INPUT PARAMETERS:
658 edhill 1.3 integer myThid, ntat
659     character*(*) vname, tnames(*), tvals(*)
660 edhill 1.11 CEOP
661 edhill 1.3
662 edhill 1.9 CALL MNC_CW_ADD_VATTR_ANY(vname,
663 edhill 1.3 & ntat, 0, 0,
664     & tnames, ' ', ' ',
665 edhill 1.9 & tvals, 0, 0.0D0, myThid )
666 edhill 1.3
667     RETURN
668     END
669    
670     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
671 edhill 1.11 CBOP
672     C !ROUTINE: MNC_CW_ADD_VATTR_INT
673 edhill 1.3
674 edhill 1.11 C !INTERFACE:
675 edhill 1.3 SUBROUTINE MNC_CW_ADD_VATTR_INT(
676     I vname,
677     I niat,
678     I inames,
679 edhill 1.9 I ivals,
680     I myThid )
681 edhill 1.3
682 edhill 1.11 C !DESCRIPTION:
683    
684     C !USES:
685 edhill 1.3 implicit none
686    
687 edhill 1.11 C !INPUT PARAMETERS:
688 edhill 1.3 integer myThid, niat
689     character*(*) vname, inames(*)
690     integer ivals(*)
691 edhill 1.11 CEOP
692 edhill 1.3
693 edhill 1.9 CALL MNC_CW_ADD_VATTR_ANY(vname,
694 edhill 1.3 & 0, niat, 0,
695     & ' ', inames, ' ',
696 edhill 1.9 & ' ', ivals, 0.0D0, myThid )
697 edhill 1.3
698     RETURN
699     END
700    
701     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
702 edhill 1.12 CBOP 0
703 edhill 1.11 C !ROUTINE: MNC_CW_ADD_VATTR_DBL
704 edhill 1.3
705 edhill 1.11 C !INTERFACE:
706 edhill 1.3 SUBROUTINE MNC_CW_ADD_VATTR_DBL(
707     I vname,
708     I ndat,
709     I dnames,
710 edhill 1.9 I dvals,
711     I myThid )
712 edhill 1.3
713 edhill 1.11 C !DESCRIPTION:
714    
715     C !USES:
716 edhill 1.3 implicit none
717    
718 edhill 1.11 C !INPUT PARAMETERS:
719 edhill 1.3 integer myThid, ndat
720     character*(*) vname, dnames(*)
721     REAL*8 dvals(*)
722 edhill 1.11 CEOP
723 edhill 1.3
724 edhill 1.9 CALL MNC_CW_ADD_VATTR_ANY(vname,
725 edhill 1.3 & 0, 0, ndat,
726     & ' ', ' ', dnames,
727 edhill 1.9 & ' ', 0, dvals, myThid )
728 edhill 1.3
729     RETURN
730     END
731    
732     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
733 edhill 1.12 CBOP 1
734 edhill 1.11 C !ROUTINE: MNC_CW_ADD_VATTR_ANY
735 edhill 1.3
736 edhill 1.11 C !INTERFACE:
737 edhill 1.2 SUBROUTINE MNC_CW_ADD_VATTR_ANY(
738     I vname,
739     I ntat, niat, ndat,
740     I tnames, inames, dnames,
741 edhill 1.9 I tvals, ivals, dvals,
742     I myThid )
743 edhill 1.2
744 edhill 1.11 C !DESCRIPTION:
745    
746     C !USES:
747 edhill 1.2 implicit none
748     #include "mnc_common.h"
749     #include "EEPARAMS.h"
750    
751 edhill 1.11 C !INPUT PARAMETERS:
752 edhill 1.2 integer myThid, ntat, niat, ndat
753     character*(*) vname
754     character*(*) tnames(*), inames(*), dnames(*)
755     character*(*) tvals(*)
756     integer ivals(*)
757     REAL*8 dvals(*)
758 edhill 1.12 CEOP
759 edhill 1.2
760 edhill 1.11 C !LOCAL VARIABLES:
761     integer i, n, nvf,nvl, n1,n2, indv
762     character*(MAX_LEN_MBUF) msgbuf
763 edhill 1.12
764 edhill 1.2 C Functions
765     integer IFNBLNK, ILNBLNK
766    
767     nvf = IFNBLNK(vname)
768     nvl = ILNBLNK(vname)
769    
770     C Check that vname is defined
771 edhill 1.9 CALL MNC_GET_IND(MNC_MAX_ID, vname, mnc_cw_vname, indv, myThid)
772 edhill 1.2 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 edhill 1.3
811     RETURN
812     END
813    
814     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
815 edhill 1.12 CBOP 1
816 edhill 1.11 C !ROUTINE: MNC_CW_GET_TILE_NUM
817 edhill 1.3
818 edhill 1.11 C !INTERFACE:
819 edhill 1.3 SUBROUTINE MNC_CW_GET_TILE_NUM(
820     I bi, bj,
821 edhill 1.9 O uniq_tnum,
822     I myThid )
823 edhill 1.3
824 edhill 1.11 C !DESCRIPTION:
825    
826     C !USES:
827 edhill 1.3 implicit none
828     #include "EEPARAMS.h"
829     #include "SIZE.h"
830 edhill 1.7 #ifdef ALLOW_EXCH2
831     #include "W2_EXCH2_TOPOLOGY.h"
832     #include "W2_EXCH2_PARAMS.h"
833     #endif
834 edhill 1.3
835 edhill 1.11 C !INPUT PARAMETERS:
836 edhill 1.3 integer myThid, bi,bj, uniq_tnum
837 edhill 1.12 CEOP
838 edhill 1.3
839 edhill 1.11 C !LOCAL VARIABLES:
840 edhill 1.3 integer iG,jG
841    
842 edhill 1.4 iG = 0
843     jG = 0
844    
845 edhill 1.3 #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 edhill 1.4
855     uniq_tnum = (jG - 1)*(nPx*nSx) + iG
856 edhill 1.3
857     #endif
858    
859 edhill 1.4 CEH3 write(*,*) 'iG,jG,uniq_tnum :', iG,jG,uniq_tnum
860    
861 edhill 1.3 RETURN
862     END
863    
864     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
865 edhill 1.12 CBOP 1
866 edhill 1.11 C !ROUTINE: MNC_CW_FILE_AORC
867    
868     C !INTERFACE:
869 edhill 1.3 SUBROUTINE MNC_CW_FILE_AORC(
870 edhill 1.4 I fname,
871 edhill 1.9 O indf,
872     I myThid )
873 edhill 1.3
874 edhill 1.11 C !DESCRIPTION:
875 edhill 1.13 C Open a NetCDF file, appending to the file if it already exists
876     C and, if not, creating a new file.
877 edhill 1.11
878     C !USES:
879 edhill 1.3 implicit none
880     #include "netcdf.inc"
881     #include "mnc_common.h"
882     #include "EEPARAMS.h"
883    
884 edhill 1.11 C !INPUT PARAMETERS:
885 edhill 1.4 integer myThid, indf
886 edhill 1.3 character*(*) fname
887 edhill 1.12 CEOP
888 edhill 1.3
889 edhill 1.11 C !LOCAL VARIABLES:
890 edhill 1.14 integer ierr
891 edhill 1.3
892     C Check if the file is already open
893 edhill 1.9 CALL MNC_GET_IND(MNC_MAX_ID, fname, mnc_f_names, indf, myThid)
894 edhill 1.3 IF (indf .GT. 0) THEN
895     RETURN
896     ENDIF
897    
898     C Try to open an existing file
899 edhill 1.9 CALL MNC_FILE_TRY_READ(fname, ierr, indf, myThid)
900 edhill 1.3 IF (ierr .EQ. NF_NOERR) THEN
901     RETURN
902     ENDIF
903    
904     C Try to create a new one
905 edhill 1.9 CALL MNC_FILE_OPEN(fname, 0, indf, myThid)
906 edhill 1.2
907 edhill 1.1 RETURN
908     END
909    
910     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
911    

  ViewVC Help
Powered by ViewVC 1.1.22