1 |
C $Header: /u/u3/gcmpack/MITgcm/pkg/mnc/mnc_cw_readwrite.template,v 1.5 2004/02/26 22:31:58 edhill Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "MNC_OPTIONS.h" |
5 |
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
|
8 |
SUBROUTINE MNC_CW_RX_W_YY( |
9 |
I myThid, |
10 |
I fbname, bi,bj, |
11 |
I vtype, |
12 |
I indu, |
13 |
I var ) |
14 |
|
15 |
implicit none |
16 |
|
17 |
#include "netcdf.inc" |
18 |
#include "mnc_common.h" |
19 |
#include "EEPARAMS.h" |
20 |
#include "SIZE.h" |
21 |
|
22 |
#define mnc_rtype_YY |
23 |
|
24 |
C Arguments |
25 |
integer myThid, bi,bj, indu |
26 |
character*(*) fbname, vtype |
27 |
__V var(*) |
28 |
|
29 |
C Functions |
30 |
integer IFNBLNK, ILNBLNK |
31 |
|
32 |
C Local Variables |
33 |
integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot |
34 |
integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv, indvids |
35 |
integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr |
36 |
integer p(9),s(9),e(9), dimnc(9), vstart(9),vcount(9), udo(9) |
37 |
integer j1,j2,j3,j4,j5,j6,j7, k1,k2,k3,k4,k5,k6,k7 |
38 |
character*(MAX_LEN_MBUF) msgbuf |
39 |
character*(MNC_MAX_CHAR) fname |
40 |
|
41 |
C Temporary storage for the simultaneous type conversion and |
42 |
C re-shaping before passing to NetCDF |
43 |
#ifdef mnc_rtype_D |
44 |
REAL*8 resh( sNx + 2*OLx + sNy + 2*OLy ) |
45 |
#endif |
46 |
#ifdef mnc_rtype_R |
47 |
REAL*4 resh( sNx + 2*OLx + sNy + 2*OLy ) |
48 |
#endif |
49 |
#ifdef mnc_rtype_I |
50 |
INTEGER resh( sNx + 2*OLx + sNy + 2*OLy ) |
51 |
#endif |
52 |
|
53 |
C Only do I/O if I am the master thread |
54 |
_BEGIN_MASTER( myThid ) |
55 |
|
56 |
C Check that the Variable Type exists |
57 |
nvf = IFNBLNK(vtype) |
58 |
nvl = ILNBLNK(vtype) |
59 |
CALL MNC_GET_IND(myThid, MNC_MAX_ID, vtype, mnc_cw_vname, indv) |
60 |
IF (indv .LT. 1) THEN |
61 |
write(msgbuf,'(3a)') 'MNC_CW_RX_W_YY ERROR: vtype ''', |
62 |
& vtype(nvf:nvl), ''' is not defined' |
63 |
CALL print_error(msgbuf, mythid) |
64 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_W_YY' |
65 |
ENDIF |
66 |
igrid = mnc_cw_vgind(indv) |
67 |
|
68 |
C Set the bi,bj indicies |
69 |
bis = bi |
70 |
bie = bi |
71 |
IF (bi .LT. 1) THEN |
72 |
bis = 1 |
73 |
bie = nSx |
74 |
ENDIF |
75 |
bjs = bj |
76 |
bje = bj |
77 |
IF (bj .LT. 1) THEN |
78 |
bjs = 1 |
79 |
bje = nSy |
80 |
ENDIF |
81 |
|
82 |
DO lbj = bjs,bje |
83 |
DO lbi = bis,bie |
84 |
|
85 |
C Create the file name |
86 |
CALL MNC_CW_GET_TILE_NUM(myThid, lbi,lbj, uniq_tnum) |
87 |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
88 |
n1 = IFNBLNK(fbname) |
89 |
n2 = ILNBLNK(fbname) |
90 |
ntot = n2 - n1 + 1 |
91 |
fname(1:ntot) = fbname(n1:n2) |
92 |
ntot = ntot + 1 |
93 |
fname(ntot:ntot) = '.' |
94 |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
95 |
nfname = ntot+9 |
96 |
|
97 |
C Append to an existing or create a new file |
98 |
CALL MNC_CW_FILE_AORC(myThid, fname, indf) |
99 |
fid = mnc_f_info(indf,2) |
100 |
|
101 |
C Ensure that all the NetCDF dimensions are defined and create a |
102 |
C local copy of them |
103 |
DO i = 1,9 |
104 |
dimnc(i) = 1 |
105 |
ENDDO |
106 |
DO i = 1,mnc_cw_ndim(igrid) |
107 |
IF (mnc_cw_dims(i,igrid) .EQ. -1) THEN |
108 |
dimnc(i) = -1 |
109 |
ELSE |
110 |
dimnc(i) = mnc_cw_ie(i,igrid) - mnc_cw_is(i,igrid) + 1 |
111 |
ENDIF |
112 |
CALL MNC_DIM_INIT(myThid,fname, |
113 |
& mnc_cw_dn(i,igrid), dimnc(i) ) |
114 |
ENDDO |
115 |
|
116 |
C Ensure that the "grid" is defined |
117 |
CALL MNC_GRID_INIT(myThid,fname, mnc_cw_gname(igrid), |
118 |
& mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid)) |
119 |
|
120 |
C Ensure that the variable is defined |
121 |
#ifdef mnc_rtype_D |
122 |
CALL MNC_VAR_INIT_DBL(myThid,fname,mnc_cw_gname(igrid),vtype) |
123 |
#endif |
124 |
#ifdef mnc_rtype_R |
125 |
CALL MNC_VAR_INIT_REAL(myThid,fname,mnc_cw_gname(igrid),vtype) |
126 |
#endif |
127 |
#ifdef mnc_rtype_I |
128 |
CALL MNC_VAR_INIT_INT(myThid,fname,mnc_cw_gname(igrid),vtype) |
129 |
#endif |
130 |
DO i = 1,mnc_fv_ids(indf,1) |
131 |
j = 2 + 3*(i - 1) |
132 |
IF (mnc_v_names(mnc_fv_ids(indf,j)) .EQ. vtype) THEN |
133 |
idv = mnc_fv_ids(indf,j+1) |
134 |
indvids = mnc_fd_ind(indf, mnc_f_info(indf, |
135 |
& (mnc_fv_ids(indf,j+2) + 1)) ) |
136 |
GOTO 10 |
137 |
ENDIF |
138 |
ENDDO |
139 |
write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W_YY ERROR: ', |
140 |
& 'cannot reference variable ''', vtype, '''' |
141 |
CALL print_error(msgbuf, mythid) |
142 |
STOP 'ABNORMAL END: package MNC' |
143 |
10 CONTINUE |
144 |
|
145 |
C Check for bi,bj indicies |
146 |
bidim = mnc_cw_vbij(1,indv) |
147 |
bjdim = mnc_cw_vbij(2,indv) |
148 |
CEH3 write(*,*) 'bidim,bjdim = ', bidim,bjdim |
149 |
|
150 |
C Set the dimensions for the in-memory array |
151 |
ndim = mnc_cw_ndim(igrid) |
152 |
k = mnc_cw_dims(1,igrid) |
153 |
IF (k .GT. 0) THEN |
154 |
p(1) = k |
155 |
ELSE |
156 |
p(1) = 1 |
157 |
ENDIF |
158 |
DO i = 2,9 |
159 |
k = mnc_cw_dims(i,igrid) |
160 |
IF (k .LT. 1) THEN |
161 |
k = 1 |
162 |
ENDIF |
163 |
IF ((bidim .GT. 0) .AND. (i .EQ. bidim)) THEN |
164 |
p(i) = nSx * p(i-1) |
165 |
ELSEIF ((bjdim .GT. 0) .AND. (i .EQ. bjdim)) THEN |
166 |
p(i) = nSy * p(i-1) |
167 |
ELSE |
168 |
p(i) = k * p(i-1) |
169 |
ENDIF |
170 |
ENDDO |
171 |
|
172 |
C Set starting and ending indicies for the in-memory array and |
173 |
C the unlimited dimension offset for the NetCDF array |
174 |
DO i = 1,9 |
175 |
udo(i) = 0 |
176 |
s(i) = 1 |
177 |
e(i) = 1 |
178 |
IF (i .LE. ndim) THEN |
179 |
s(i) = mnc_cw_is(i,igrid) |
180 |
e(i) = mnc_cw_ie(i,igrid) |
181 |
ENDIF |
182 |
C Check for the unlimited dimension |
183 |
IF ((i .EQ. ndim) |
184 |
& .AND. (mnc_cw_dims(i,igrid) .EQ. -1)) THEN |
185 |
IF (indu .GT. 0) THEN |
186 |
C Use the indu value |
187 |
udo(i) = indu - 1 |
188 |
ELSEIF (indu .EQ. -1) THEN |
189 |
C Append one to the current unlimited dim size |
190 |
CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz) |
191 |
udo(i) = unlim_sz |
192 |
ELSE |
193 |
C Use the current unlimited dim size |
194 |
CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz) |
195 |
udo(i) = unlim_sz - 1 |
196 |
ENDIF |
197 |
ENDIF |
198 |
ENDDO |
199 |
IF (bidim .GT. 0) THEN |
200 |
s(bidim) = lbi |
201 |
e(bidim) = lbi |
202 |
ENDIF |
203 |
IF (bjdim .GT. 0) THEN |
204 |
s(bjdim) = lbj |
205 |
e(bjdim) = lbj |
206 |
ENDIF |
207 |
CEH3 DO i = 1,9 |
208 |
CEH3 write(*,*) 'i,p(i),s(i),e(i) = ', i,p(i),s(i),e(i) |
209 |
CEH3 ENDDO |
210 |
|
211 |
C Add the global attributes |
212 |
CALL MNC_CW_SET_GATTR(myThid, fname, lbi,lbj, uniq_tnum) |
213 |
|
214 |
C Add the per-variable attributes |
215 |
DO i = 1,mnc_cw_vnat(1,indv) |
216 |
CALL MNC_VAR_ADD_ATTR_STR(myThid, fname, vtype, |
217 |
& mnc_cw_vtnm(i,indv), mnc_cw_vtat(i,indv)) |
218 |
ENDDO |
219 |
DO i = 1,mnc_cw_vnat(2,indv) |
220 |
CALL MNC_VAR_ADD_ATTR_INT(myThid, fname, vtype, |
221 |
& mnc_cw_vinm(i,indv), 1, mnc_cw_viat(i,indv)) |
222 |
ENDDO |
223 |
DO i = 1,mnc_cw_vnat(3,indv) |
224 |
CALL MNC_VAR_ADD_ATTR_DBL(myThid, fname, vtype, |
225 |
& mnc_cw_vdnm(i,indv), 1, mnc_cw_vdat(i,indv)) |
226 |
ENDDO |
227 |
|
228 |
CALL MNC_FILE_ENDDEF(myThid,fname) |
229 |
|
230 |
C Write the variable one vector at a time |
231 |
DO j7 = s(7),e(7) |
232 |
k7 = (j7 - 1)*p(6) |
233 |
vstart(7) = udo(7) + j7 - s(7) + 1 |
234 |
vcount(7) = 1 |
235 |
DO j6 = s(6),e(6) |
236 |
k6 = (j6 - 1)*p(5) + k7 |
237 |
vstart(6) = udo(6) + j6 - s(6) + 1 |
238 |
vcount(6) = 1 |
239 |
DO j5 = s(5),e(5) |
240 |
k5 = (j5 - 1)*p(4) + k6 |
241 |
vstart(5) = udo(5) + j5 - s(5) + 1 |
242 |
vcount(5) = 1 |
243 |
DO j4 = s(4),e(4) |
244 |
k4 = (j4 - 1)*p(3) + k5 |
245 |
vstart(4) = udo(4) + j4 - s(4) + 1 |
246 |
vcount(4) = 1 |
247 |
DO j3 = s(3),e(3) |
248 |
k3 = (j3 - 1)*p(2) + k4 |
249 |
vstart(3) = udo(3) + j3 - s(3) + 1 |
250 |
vcount(3) = 1 |
251 |
DO j2 = s(2),e(2) |
252 |
k2 = (j2 - 1)*p(1) + k3 |
253 |
vstart(2) = udo(2) + j2 - s(2) + 1 |
254 |
vcount(2) = 1 |
255 |
|
256 |
kr = 0 |
257 |
DO j1 = s(1),e(1) |
258 |
k1 = k2 + j1 |
259 |
kr = kr + 1 |
260 |
resh(kr) = var(k1) |
261 |
ENDDO |
262 |
|
263 |
vstart(1) = udo(1) + 1 |
264 |
vcount(1) = e(1) - s(1) + 1 |
265 |
|
266 |
#ifdef mnc_rtype_D |
267 |
err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh) |
268 |
#endif |
269 |
#ifdef mnc_rtype_R |
270 |
err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh) |
271 |
#endif |
272 |
#ifdef mnc_rtype_I |
273 |
err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh) |
274 |
#endif |
275 |
|
276 |
ENDDO |
277 |
ENDDO |
278 |
ENDDO |
279 |
ENDDO |
280 |
ENDDO |
281 |
ENDDO |
282 |
|
283 |
C Sync the file |
284 |
err = NF_SYNC(fid) |
285 |
write(msgbuf,'(3a)') 'sync for file ''', fname, |
286 |
& ''' in S/R MNC_CW_RX_W_YY' |
287 |
CALL MNC_HANDLE_ERR(myThid, err, msgbuf) |
288 |
|
289 |
ENDDO |
290 |
ENDDO |
291 |
|
292 |
_END_MASTER( myThid ) |
293 |
|
294 |
RETURN |
295 |
END |
296 |
|
297 |
|
298 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
299 |
|
300 |
|
301 |
SUBROUTINE MNC_CW_RX_R_YY( |
302 |
I myThid, |
303 |
I fbname, bi,bj, |
304 |
I vtype, |
305 |
I indu, |
306 |
I var ) |
307 |
|
308 |
implicit none |
309 |
|
310 |
#include "netcdf.inc" |
311 |
#include "mnc_common.h" |
312 |
#include "EEPARAMS.h" |
313 |
#include "SIZE.h" |
314 |
|
315 |
#define mnc_rtype_YY |
316 |
|
317 |
C Arguments |
318 |
integer myThid, bi,bj, indu |
319 |
character*(*) fbname, vtype |
320 |
__V var(*) |
321 |
|
322 |
C Functions |
323 |
integer IFNBLNK, ILNBLNK |
324 |
|
325 |
C Local Variables |
326 |
integer i,k, indv,nvf,nvl, n1,n2, igrid, ntot |
327 |
integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv |
328 |
integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr |
329 |
integer ind_fv_ids, ind_vt, ierr, atype, alen |
330 |
integer f_sNx,f_sNy, ires |
331 |
integer p(9),s(9),e(9), vstart(9),vcount(9), udo(9) |
332 |
integer j1,j2,j3,j4,j5,j6,j7, k1,k2,k3,k4,k5,k6,k7 |
333 |
character*(MAX_LEN_MBUF) msgbuf |
334 |
character*(MNC_MAX_CHAR) fname |
335 |
|
336 |
C Temporary storage for the simultaneous type conversion and |
337 |
C re-shaping before passing to NetCDF |
338 |
#ifdef mnc_rtype_D |
339 |
REAL*8 resh( sNx + 2*OLx + sNy + 2*OLy ) |
340 |
#endif |
341 |
#ifdef mnc_rtype_R |
342 |
REAL*4 resh( sNx + 2*OLx + sNy + 2*OLy ) |
343 |
#endif |
344 |
#ifdef mnc_rtype_I |
345 |
INTEGER resh( sNx + 2*OLx + sNy + 2*OLy ) |
346 |
#endif |
347 |
|
348 |
C Only do I/O if I am the master thread |
349 |
_BEGIN_MASTER( myThid ) |
350 |
|
351 |
C Check that the Variable Type exists |
352 |
nvf = IFNBLNK(vtype) |
353 |
nvl = ILNBLNK(vtype) |
354 |
CALL MNC_GET_IND(myThid, MNC_MAX_ID, vtype, mnc_cw_vname, ind_vt) |
355 |
IF (indv .LT. 1) THEN |
356 |
write(msgbuf,'(3a)') 'MNC_CW_RX_R_YY ERROR: vtype ''', |
357 |
& vtype(nvf:nvl), ''' is not defined' |
358 |
CALL print_error(msgbuf, mythid) |
359 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
360 |
ENDIF |
361 |
igrid = mnc_cw_vgind(ind_vt) |
362 |
|
363 |
C Check for bi,bj indicies |
364 |
bidim = mnc_cw_vbij(1,ind_vt) |
365 |
bjdim = mnc_cw_vbij(2,ind_vt) |
366 |
|
367 |
C Set the bi,bj indicies |
368 |
bis = bi |
369 |
bie = bi |
370 |
IF (bi .LT. 1) THEN |
371 |
bis = 1 |
372 |
bie = nSx |
373 |
ENDIF |
374 |
bjs = bj |
375 |
bje = bj |
376 |
IF (bj .LT. 1) THEN |
377 |
bjs = 1 |
378 |
bje = nSy |
379 |
ENDIF |
380 |
|
381 |
DO lbj = bjs,bje |
382 |
DO lbi = bis,bie |
383 |
|
384 |
C Create the file name |
385 |
CALL MNC_CW_GET_TILE_NUM(myThid, lbi,lbj, uniq_tnum) |
386 |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
387 |
n1 = IFNBLNK(fbname) |
388 |
n2 = ILNBLNK(fbname) |
389 |
ntot = n2 - n1 + 1 |
390 |
fname(1:ntot) = fbname(n1:n2) |
391 |
ntot = ntot + 1 |
392 |
fname(ntot:ntot) = '.' |
393 |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
394 |
nfname = ntot+9 |
395 |
write(*,*) 'The read file is: ', fname(1:nfname) |
396 |
|
397 |
C Open the existing file |
398 |
CALL MNC_FILE_TRY_READ(myThid, fname, ierr, indf) |
399 |
|
400 |
C Check that the variable (VType) is defined within the file |
401 |
CALL MNC_GET_FVINDS(myThid, fname, vtype, indf, ind_fv_ids) |
402 |
IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN |
403 |
write(msgbuf,'(4a)') 'MNC_CW_RX_R_YY ERROR: vtype ''', |
404 |
& vtype(nvf:nvl), ''' is not defined within file ''', |
405 |
& fname(1:nfname) |
406 |
CALL print_error(msgbuf, mythid) |
407 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
408 |
ENDIF |
409 |
fid = mnc_f_info(indf,2) |
410 |
idv = mnc_fv_ids(indf,ind_fv_ids+1) |
411 |
|
412 |
write(*,*) 'indf,ind_fv_ids = ', indf,ind_fv_ids |
413 |
|
414 |
C Check that the current sNy,sNy values and the in-file values |
415 |
C are compatible and WARN (only warn) if not |
416 |
f_sNx = -1 |
417 |
f_sNy = -1 |
418 |
err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNx',atype,alen) |
419 |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
420 |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx) |
421 |
CALL MNC_HANDLE_ERR(myThid, err, |
422 |
& 'reading attribute ''sNx'' in S/R MNC_CW_RX_R_YY') |
423 |
ENDIF |
424 |
err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen) |
425 |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
426 |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy) |
427 |
CALL MNC_HANDLE_ERR(myThid, err, |
428 |
& 'reading attribute ''sNy'' in S/R MNC_CW_RX_R_YY') |
429 |
ENDIF |
430 |
IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN |
431 |
write(msgbuf,'(5a)') 'MNC_CW_RX_R_YY WARNING: the ', |
432 |
& 'attributes ''sNx'' and ''sNy'' within the file ''', |
433 |
& fname(1:nfname), ''' do not exist or do not match ', |
434 |
& 'the current sizes within the model' |
435 |
CALL print_error(msgbuf, mythid) |
436 |
ENDIF |
437 |
|
438 |
C Check that the in-memory variable and the in-file variables |
439 |
C are of compatible sizes |
440 |
ires = 1 |
441 |
CALL MNC_CHK_VTYP_R_NCVAR(myThid, ind_vt, |
442 |
& indf, ind_fv_ids, indu, ires) |
443 |
IF (ires .LT. 0) THEN |
444 |
write(msgbuf,'(7a)') 'MNC_CW_RX_R_YY WARNING: the sizes ', |
445 |
& 'of the in-program variable ''', vtype(nvf:nvl), |
446 |
& ''' and the corresponding variable within file ''', |
447 |
& fname(1:nfname), ''' are not compatible -- please ', |
448 |
& 'check the sizes' |
449 |
CALL print_error(msgbuf, mythid) |
450 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
451 |
ENDIF |
452 |
|
453 |
C Check for bi,bj indicies |
454 |
bidim = mnc_cw_vbij(1,ind_vt) |
455 |
bjdim = mnc_cw_vbij(2,ind_vt) |
456 |
write(*,*) 'bidim,bjdim = ', bidim,bjdim |
457 |
|
458 |
C Set the dimensions for the in-memory array |
459 |
ndim = mnc_cw_ndim(igrid) |
460 |
k = mnc_cw_dims(1,igrid) |
461 |
IF (k .GT. 0) THEN |
462 |
p(1) = k |
463 |
ELSE |
464 |
p(1) = 1 |
465 |
ENDIF |
466 |
DO i = 2,9 |
467 |
k = mnc_cw_dims(i,igrid) |
468 |
IF (k .LT. 1) THEN |
469 |
k = 1 |
470 |
ENDIF |
471 |
IF ((bidim .GT. 0) .AND. (i .EQ. bidim)) THEN |
472 |
p(i) = nSx * p(i-1) |
473 |
ELSEIF ((bjdim .GT. 0) .AND. (i .EQ. bjdim)) THEN |
474 |
p(i) = nSy * p(i-1) |
475 |
ELSE |
476 |
p(i) = k * p(i-1) |
477 |
ENDIF |
478 |
ENDDO |
479 |
|
480 |
C Set starting and ending indicies for the in-memory array and |
481 |
C the unlimited dimension offset for the NetCDF array |
482 |
DO i = 1,9 |
483 |
udo(i) = 0 |
484 |
s(i) = 1 |
485 |
e(i) = 1 |
486 |
IF (i .LE. ndim) THEN |
487 |
s(i) = mnc_cw_is(i,igrid) |
488 |
e(i) = mnc_cw_ie(i,igrid) |
489 |
ENDIF |
490 |
C Check for the unlimited dimension |
491 |
IF ((i .EQ. ndim) |
492 |
& .AND. (mnc_cw_dims(i,igrid) .EQ. -1)) THEN |
493 |
IF (indu .GT. 0) THEN |
494 |
C Use the indu value |
495 |
udo(i) = indu - 1 |
496 |
ELSEIF (indu .EQ. -1) THEN |
497 |
C Append one to the current unlimited dim size |
498 |
CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz) |
499 |
udo(i) = unlim_sz |
500 |
ELSE |
501 |
C Use the current unlimited dim size |
502 |
CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz) |
503 |
udo(i) = unlim_sz - 1 |
504 |
ENDIF |
505 |
ENDIF |
506 |
ENDDO |
507 |
IF (bidim .GT. 0) THEN |
508 |
s(bidim) = lbi |
509 |
e(bidim) = lbi |
510 |
ENDIF |
511 |
IF (bjdim .GT. 0) THEN |
512 |
s(bjdim) = lbj |
513 |
e(bjdim) = lbj |
514 |
ENDIF |
515 |
|
516 |
DO i = 9,1,-1 |
517 |
write(*,*) 'i,p(i),s(i),e(i) = ', i,': ',p(i),s(i),e(i) |
518 |
ENDDO |
519 |
|
520 |
CALL MNC_FILE_ENDDEF(myThid,fname) |
521 |
|
522 |
write(msgbuf,'(5a)') 'reading variable type ''', |
523 |
& vtype(nvf:nvl), ''' within file ''', |
524 |
& fname(1:nfname), '''' |
525 |
|
526 |
C Read the variable one vector at a time |
527 |
DO j7 = s(7),e(7) |
528 |
k7 = (j7 - 1)*p(6) |
529 |
vstart(7) = udo(7) + j7 - s(7) + 1 |
530 |
vcount(7) = 1 |
531 |
DO j6 = s(6),e(6) |
532 |
k6 = (j6 - 1)*p(5) + k7 |
533 |
vstart(6) = udo(6) + j6 - s(6) + 1 |
534 |
vcount(6) = 1 |
535 |
DO j5 = s(5),e(5) |
536 |
k5 = (j5 - 1)*p(4) + k6 |
537 |
vstart(5) = udo(5) + j5 - s(5) + 1 |
538 |
vcount(5) = 1 |
539 |
DO j4 = s(4),e(4) |
540 |
k4 = (j4 - 1)*p(3) + k5 |
541 |
vstart(4) = udo(4) + j4 - s(4) + 1 |
542 |
vcount(4) = 1 |
543 |
DO j3 = s(3),e(3) |
544 |
k3 = (j3 - 1)*p(2) + k4 |
545 |
vstart(3) = udo(3) + j3 - s(3) + 1 |
546 |
vcount(3) = 1 |
547 |
DO j2 = s(2),e(2) |
548 |
k2 = (j2 - 1)*p(1) + k3 |
549 |
vstart(2) = udo(2) + j2 - s(2) + 1 |
550 |
vcount(2) = 1 |
551 |
|
552 |
vstart(1) = udo(1) + 1 |
553 |
vcount(1) = e(1) - s(1) + 1 |
554 |
|
555 |
#ifdef mnc_rtype_D |
556 |
err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh) |
557 |
#endif |
558 |
#ifdef mnc_rtype_R |
559 |
err = NF_GET_VARA_REAL(fid, idv, vstart, vcount, resh) |
560 |
#endif |
561 |
#ifdef mnc_rtype_I |
562 |
err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh) |
563 |
#endif |
564 |
|
565 |
CALL MNC_HANDLE_ERR(myThid, err, msgbuf) |
566 |
|
567 |
kr = 0 |
568 |
DO j1 = s(1),e(1) |
569 |
k1 = k2 + j1 |
570 |
kr = kr + 1 |
571 |
var(k1) = resh(kr) |
572 |
ENDDO |
573 |
|
574 |
|
575 |
ENDDO |
576 |
ENDDO |
577 |
ENDDO |
578 |
ENDDO |
579 |
ENDDO |
580 |
ENDDO |
581 |
|
582 |
C End the lbj,lbi loops |
583 |
ENDDO |
584 |
ENDDO |
585 |
|
586 |
_END_MASTER( myThid ) |
587 |
|
588 |
RETURN |
589 |
END |
590 |
|
591 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
592 |
|
593 |
CEH3 ;;; Local Variables: *** |
594 |
CEH3 ;;; mode:fortran *** |
595 |
CEH3 ;;; End: *** |