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

Contents of /MITgcm/pkg/mnc/mnc_dim.F

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


Revision 1.17 - (show annotations) (download)
Fri Jun 20 20:36:58 2008 UTC (15 years, 10 months ago) by utke
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint61, checkpoint62, checkpoint63, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61n, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y, HEAD
Changes since 1.16: +3 -3 lines
move netcdf.inc includes
to avoid conflict when common block includes are turned into module uses

1 C $Header: /u/gcmpack/MITgcm/pkg/mnc/mnc_dim.F,v 1.16 2008/05/22 12:21:19 mlosch 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_DIM_INIT
9
10 C !INTERFACE:
11 SUBROUTINE MNC_DIM_INIT(
12 I fname,
13 I dname,
14 I dlen,
15 I myThid )
16
17 C !DESCRIPTION:
18 C Create a dimension within the MNC look-up tables.
19
20 C !INPUT PARAMETERS:
21 integer myThid, dlen
22 character*(*) fname, dname
23 CEOP
24
25 CALL MNC_DIM_INIT_ALL(fname, dname, dlen, 'Y', myThid)
26
27 RETURN
28 END
29
30 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
31 CBOP 1
32 C !ROUTINE: MNC_DIM_INIT_ALL
33
34 C !INTERFACE:
35 SUBROUTINE MNC_DIM_INIT_ALL(
36 I fname,
37 I dname,
38 I dlen,
39 I doWrite,
40 I myThid )
41
42 C !DESCRIPTION:
43 C Create a dimension within the MNC look-up tables.
44
45 C !USES:
46 implicit none
47
48 C !INPUT PARAMETERS:
49 integer myThid, dlen
50 character*(*) fname, dname
51 character*(1) doWrite
52 CEOP
53
54 CALL MNC_DIM_INIT_ALL_CV(fname,dname,dlen,doWrite,-1,-1,myThid)
55
56 RETURN
57 END
58
59 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
60 CBOP 1
61 C !ROUTINE: MNC_DIM_INIT_ALL_CV
62
63 C !INTERFACE:
64 SUBROUTINE MNC_DIM_INIT_ALL_CV(
65 I fname,
66 I dname,
67 I dlen,
68 I doWrite,
69 I bi,bj,
70 I myThid )
71
72 C !DESCRIPTION:
73 C Create a dimension within the MNC look-up tables.
74
75 C !USES:
76 implicit none
77 #include "MNC_COMMON.h"
78 #include "EEPARAMS.h"
79 #include "netcdf.inc"
80
81 C !INPUT PARAMETERS:
82 integer myThid, dlen, bi,bj
83 character*(*) fname, dname
84 character*(1) doWrite
85 CEOP
86
87 C !LOCAL VARIABLES:
88 integer i,j, indf,indd, n,nf, dnf,dnl
89 integer ntmp, idd, err, tlen
90 character*(MAX_LEN_MBUF) msgbuf
91
92 C Functions
93 integer ILNBLNK, IFNBLNK
94
95 nf = ILNBLNK(fname)
96
97 dnf = IFNBLNK(dname)
98 dnl = ILNBLNK(dname)
99
100 C Verify that the file exists
101 CALL MNC_GET_IND(MNC_MAX_FID, fname, mnc_f_names, indf, myThid)
102 IF ( indf .LT. 1 ) THEN
103 write(msgbuf,'(3a)') 'MNC ERROR: file ''', fname(1:nf),
104 & ''' does not exist'
105 CALL print_error( msgbuf, mythid )
106 stop 'ABNORMAL END: S/R MNC_DIM_INIT'
107 ENDIF
108
109 C Verify that the dim is not currently defined within the file
110 n = mnc_f_alld(indf,1)
111 DO i = 1,n
112 j = mnc_f_alld(indf,i+1)
113 ntmp = ILNBLNK(mnc_d_names(j))
114 IF ((ntmp .EQ. (dnl-dnf+1))
115 & .AND. (dname(dnf:dnl) .EQ. mnc_d_names(j)(1:ntmp))) THEN
116 IF (mnc_d_size(j) .NE. dlen) THEN
117 IF ((mnc_d_size(j) .GT. 0) .OR. (dlen .GT. 0)) THEN
118 write(msgbuf,'(5a)') 'MNC ERROR: dimension ''',
119 & dname(dnf:dnl), ''' already exists within file ''',
120 & fname(1:nf), ''' and its size cannot be changed'
121 CALL print_error(msgbuf, mythid)
122 stop 'ABNORMAL END: S/R MNC_DIM_INIT'
123 ELSE
124 C Its OK, the names are the same and both are specifying the
125 C unlimited dimension
126 RETURN
127 ENDIF
128 ELSE
129 C Its OK, the names and sizes are identical
130 RETURN
131 ENDIF
132 ENDIF
133 ENDDO
134
135 CALL MNC_GET_NEXT_EMPTY_IND(MNC_MAX_ID, mnc_d_names,
136 & 'mnc_d_names', indd, myThid)
137
138 C Create the dim within the file
139 IF (doWrite(1:1) .EQ. 'Y') THEN
140
141 tlen = dlen
142 IF (dlen .LT. 1) tlen = NF_UNLIMITED
143
144 CALL MNC_FILE_REDEF(fname, myThid)
145 err = NF_DEF_DIM(mnc_f_info(indf,2), dname(dnf:dnl), tlen, idd)
146 write(msgbuf,'(5a)') 'MNC_DIM_INIT ERROR: cannot create ',
147 & 'dim ''', dname(dnf:dnl), ''' in file ''', fname(1:nf)
148 CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
149
150 C Create and write the associated CF-convention
151 C coordinate variable
152 IF (bi .GT. -1) THEN
153 CALL MNC_CW_WRITE_CVAR(fname, dname(dnf:dnl),
154 & mnc_f_info(indf,2), idd, bi, bj, myThid)
155 ENDIF
156
157 ENDIF
158
159 C Add to tables
160 mnc_d_names(indd)(1:(dnl-dnf+1)) = dname(dnf:dnl)
161 mnc_d_size(indd) = dlen
162 mnc_d_ids(indd) = idd
163 mnc_f_alld(indf,1) = n + 1
164 mnc_f_alld(indf,n+2) = indd
165
166 RETURN
167 END
168
169 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
170 CBOP 1
171 C !ROUTINE: MNC_DIM_UNLIM_SIZE
172
173 C !INTERFACE:
174 SUBROUTINE MNC_DIM_UNLIM_SIZE(
175 I fname,
176 I unlim_sz,
177 I myThid )
178
179 C !DESCRIPTION:
180 C Get the size of the unlimited dimension.
181
182 C !USES:
183 implicit none
184 #include "MNC_COMMON.h"
185 #include "EEPARAMS.h"
186 #include "netcdf.inc"
187
188 C !INPUT PARAMETERS:
189 integer myThid, unlim_sz
190 character*(*) fname
191 CEOP
192
193 C !LOCAL VARIABLES:
194 integer i,j, nf, indf, fid, unlimid, err
195 character*(MAX_LEN_MBUF) msgbuf
196
197 C Functions
198 integer ILNBLNK
199
200 nf = ILNBLNK(fname)
201
202 C Verify that the file exists
203 CALL MNC_GET_IND(MNC_MAX_FID, fname, mnc_f_names, indf, myThid)
204 IF (indf .LT. 1) THEN
205 write(msgbuf,'(3a)') 'MNC ERROR: file ''', fname(1:nf),
206 & ''' does not exist'
207 CALL print_error(msgbuf, mythid)
208 stop 'ABNORMAL END: S/R MNC_DIM_UNLIM_SIZE'
209 ENDIF
210 fid = mnc_f_info(indf,2)
211
212 C Find the unlimited dim and its current size
213 unlim_sz = -1
214 DO i = 1,mnc_f_alld(indf,1)
215 j = mnc_f_alld(indf,i+1)
216 IF (mnc_d_size(j) .EQ. -1) THEN
217 unlimid = mnc_d_ids(j)
218 err = NF_INQ_DIMLEN(fid, unlimid, unlim_sz)
219 write(msgbuf,'(3a)') 'MNC_DIM_UNLIM_SIZE ERROR: cannot ',
220 & 'determine unlimited dim size in file ''', fname(1:nf)
221 CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
222 RETURN
223 ENDIF
224 ENDDO
225
226 RETURN
227 END
228
229
230 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
231

  ViewVC Help
Powered by ViewVC 1.1.22