6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
|
|
8 |
SUBROUTINE MNC_CW_RX_W_YY( |
SUBROUTINE MNC_CW_RX_W_YY( |
|
I myThid, |
|
9 |
I fbname, bi,bj, |
I fbname, bi,bj, |
10 |
I vtype, |
I vtype, |
11 |
I indu, |
I indu, |
12 |
I var ) |
I var, |
13 |
|
I myThid ) |
14 |
|
|
15 |
implicit none |
implicit none |
16 |
|
|
56 |
C Check that the Variable Type exists |
C Check that the Variable Type exists |
57 |
nvf = IFNBLNK(vtype) |
nvf = IFNBLNK(vtype) |
58 |
nvl = ILNBLNK(vtype) |
nvl = ILNBLNK(vtype) |
59 |
CALL MNC_GET_IND(myThid, MNC_MAX_ID, vtype, mnc_cw_vname, indv) |
CALL MNC_GET_IND(MNC_MAX_ID, vtype, mnc_cw_vname, indv, myThid) |
60 |
IF (indv .LT. 1) THEN |
IF (indv .LT. 1) THEN |
61 |
write(msgbuf,'(3a)') 'MNC_CW_RX_W_YY ERROR: vtype ''', |
write(msgbuf,'(3a)') 'MNC_CW_RX_W_YY ERROR: vtype ''', |
62 |
& vtype(nvf:nvl), ''' is not defined' |
& vtype(nvf:nvl), ''' is not defined' |
83 |
DO lbi = bis,bie |
DO lbi = bis,bie |
84 |
|
|
85 |
C Create the file name |
C Create the file name |
86 |
CALL MNC_CW_GET_TILE_NUM(myThid, lbi,lbj, uniq_tnum) |
CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid) |
87 |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
88 |
n1 = IFNBLNK(fbname) |
n1 = IFNBLNK(fbname) |
89 |
n2 = ILNBLNK(fbname) |
n2 = ILNBLNK(fbname) |
95 |
nfname = ntot+9 |
nfname = ntot+9 |
96 |
|
|
97 |
C Append to an existing or create a new file |
C Append to an existing or create a new file |
98 |
CALL MNC_CW_FILE_AORC(myThid, fname, indf) |
CALL MNC_CW_FILE_AORC(fname, indf, myThid) |
99 |
fid = mnc_f_info(indf,2) |
fid = mnc_f_info(indf,2) |
100 |
|
|
101 |
C Ensure that all the NetCDF dimensions are defined and create a |
C Ensure that all the NetCDF dimensions are defined and create a |
109 |
ELSE |
ELSE |
110 |
dimnc(i) = mnc_cw_ie(i,igrid) - mnc_cw_is(i,igrid) + 1 |
dimnc(i) = mnc_cw_ie(i,igrid) - mnc_cw_is(i,igrid) + 1 |
111 |
ENDIF |
ENDIF |
112 |
CALL MNC_DIM_INIT(myThid,fname, |
CALL MNC_DIM_INIT(fname, |
113 |
& mnc_cw_dn(i,igrid), dimnc(i) ) |
& mnc_cw_dn(i,igrid), dimnc(i), myThid) |
114 |
ENDDO |
ENDDO |
115 |
|
|
116 |
C Ensure that the "grid" is defined |
C Ensure that the "grid" is defined |
117 |
CALL MNC_GRID_INIT(myThid,fname, mnc_cw_gname(igrid), |
CALL MNC_GRID_INIT(fname, mnc_cw_gname(igrid), |
118 |
& mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid)) |
& mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid), myThid) |
119 |
|
|
120 |
C Ensure that the variable is defined |
C Ensure that the variable is defined |
121 |
#ifdef mnc_rtype_D |
#ifdef mnc_rtype_D |
122 |
CALL MNC_VAR_INIT_DBL(myThid,fname,mnc_cw_gname(igrid),vtype) |
CALL MNC_VAR_INIT_DBL(fname,mnc_cw_gname(igrid),vtype, myThid) |
123 |
#endif |
#endif |
124 |
#ifdef mnc_rtype_R |
#ifdef mnc_rtype_R |
125 |
CALL MNC_VAR_INIT_REAL(myThid,fname,mnc_cw_gname(igrid),vtype) |
CALL MNC_VAR_INIT_REAL(fname,mnc_cw_gname(igrid),vtype, myThid) |
126 |
#endif |
#endif |
127 |
#ifdef mnc_rtype_I |
#ifdef mnc_rtype_I |
128 |
CALL MNC_VAR_INIT_INT(myThid,fname,mnc_cw_gname(igrid),vtype) |
CALL MNC_VAR_INIT_INT(fname,mnc_cw_gname(igrid),vtype, myThid) |
129 |
#endif |
#endif |
130 |
DO i = 1,mnc_fv_ids(indf,1) |
DO i = 1,mnc_fv_ids(indf,1) |
131 |
j = 2 + 3*(i - 1) |
j = 2 + 3*(i - 1) |
187 |
udo(i) = indu - 1 |
udo(i) = indu - 1 |
188 |
ELSEIF (indu .EQ. -1) THEN |
ELSEIF (indu .EQ. -1) THEN |
189 |
C Append one to the current unlimited dim size |
C Append one to the current unlimited dim size |
190 |
CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz) |
CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid) |
191 |
udo(i) = unlim_sz |
udo(i) = unlim_sz |
192 |
ELSE |
ELSE |
193 |
C Use the current unlimited dim size |
C Use the current unlimited dim size |
194 |
CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz) |
CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid) |
195 |
udo(i) = unlim_sz - 1 |
udo(i) = unlim_sz - 1 |
196 |
ENDIF |
ENDIF |
197 |
ENDIF |
ENDIF |
209 |
CEH3 ENDDO |
CEH3 ENDDO |
210 |
|
|
211 |
C Add the global attributes |
C Add the global attributes |
212 |
CALL MNC_CW_SET_GATTR(myThid, fname, lbi,lbj, uniq_tnum) |
CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid) |
213 |
|
|
214 |
C Add the per-variable attributes |
C Add the per-variable attributes |
215 |
DO i = 1,mnc_cw_vnat(1,indv) |
DO i = 1,mnc_cw_vnat(1,indv) |
216 |
CALL MNC_VAR_ADD_ATTR_STR(myThid, fname, vtype, |
CALL MNC_VAR_ADD_ATTR_STR( fname, vtype, |
217 |
& mnc_cw_vtnm(i,indv), mnc_cw_vtat(i,indv)) |
& mnc_cw_vtnm(i,indv), mnc_cw_vtat(i,indv), myThid) |
218 |
ENDDO |
ENDDO |
219 |
DO i = 1,mnc_cw_vnat(2,indv) |
DO i = 1,mnc_cw_vnat(2,indv) |
220 |
CALL MNC_VAR_ADD_ATTR_INT(myThid, fname, vtype, |
CALL MNC_VAR_ADD_ATTR_INT( fname, vtype, |
221 |
& mnc_cw_vinm(i,indv), 1, mnc_cw_viat(i,indv)) |
& mnc_cw_vinm(i,indv), 1, mnc_cw_viat(i,indv), myThid) |
222 |
ENDDO |
ENDDO |
223 |
DO i = 1,mnc_cw_vnat(3,indv) |
DO i = 1,mnc_cw_vnat(3,indv) |
224 |
CALL MNC_VAR_ADD_ATTR_DBL(myThid, fname, vtype, |
CALL MNC_VAR_ADD_ATTR_DBL( fname, vtype, |
225 |
& mnc_cw_vdnm(i,indv), 1, mnc_cw_vdat(i,indv)) |
& mnc_cw_vdnm(i,indv), 1, mnc_cw_vdat(i,indv), myThid) |
226 |
ENDDO |
ENDDO |
227 |
|
|
228 |
CALL MNC_FILE_ENDDEF(myThid,fname) |
CALL MNC_FILE_ENDDEF(fname, myThid) |
229 |
|
|
230 |
|
write(msgbuf,'(5a)') 'writing variable type ''', |
231 |
|
& vtype(nvf:nvl), ''' within file ''', |
232 |
|
& fname(1:nfname), '''' |
233 |
|
|
234 |
C Write the variable one vector at a time |
C Write the variable one vector at a time |
235 |
DO j7 = s(7),e(7) |
DO j7 = s(7),e(7) |
277 |
err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh) |
err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh) |
278 |
#endif |
#endif |
279 |
|
|
280 |
|
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
281 |
|
|
282 |
ENDDO |
ENDDO |
283 |
ENDDO |
ENDDO |
284 |
ENDDO |
ENDDO |
290 |
err = NF_SYNC(fid) |
err = NF_SYNC(fid) |
291 |
write(msgbuf,'(3a)') 'sync for file ''', fname, |
write(msgbuf,'(3a)') 'sync for file ''', fname, |
292 |
& ''' in S/R MNC_CW_RX_W_YY' |
& ''' in S/R MNC_CW_RX_W_YY' |
293 |
CALL MNC_HANDLE_ERR(myThid, err, msgbuf) |
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
294 |
|
|
295 |
ENDDO |
ENDDO |
296 |
ENDDO |
ENDDO |
305 |
|
|
306 |
|
|
307 |
SUBROUTINE MNC_CW_RX_R_YY( |
SUBROUTINE MNC_CW_RX_R_YY( |
|
I myThid, |
|
308 |
I fbname, bi,bj, |
I fbname, bi,bj, |
309 |
I vtype, |
I vtype, |
310 |
I indu, |
I indu, |
311 |
I var ) |
I var, |
312 |
|
I myThid ) |
313 |
|
|
314 |
implicit none |
implicit none |
315 |
|
|
329 |
integer IFNBLNK, ILNBLNK |
integer IFNBLNK, ILNBLNK |
330 |
|
|
331 |
C Local Variables |
C Local Variables |
332 |
integer i,k, indv,nvf,nvl, n1,n2, igrid, ntot |
integer i,k, nvf,nvl, n1,n2, igrid, ntot |
333 |
integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv |
integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv |
334 |
integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr |
integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr |
335 |
integer ind_fv_ids, ind_vt, ierr, atype, alen |
integer ind_fv_ids, ind_vt, ierr, atype, alen |
357 |
C Check that the Variable Type exists |
C Check that the Variable Type exists |
358 |
nvf = IFNBLNK(vtype) |
nvf = IFNBLNK(vtype) |
359 |
nvl = ILNBLNK(vtype) |
nvl = ILNBLNK(vtype) |
360 |
CALL MNC_GET_IND(myThid, MNC_MAX_ID, vtype, mnc_cw_vname, ind_vt) |
CALL MNC_GET_IND( MNC_MAX_ID, vtype, mnc_cw_vname, ind_vt, myThid) |
361 |
IF (ind_vt .LT. 1) THEN |
IF (ind_vt .LT. 1) THEN |
362 |
write(msgbuf,'(3a)') 'MNC_CW_RX_R_YY ERROR: vtype ''', |
write(msgbuf,'(3a)') 'MNC_CW_RX_R_YY ERROR: vtype ''', |
363 |
& vtype(nvf:nvl), ''' is not defined' |
& vtype(nvf:nvl), ''' is not defined' |
388 |
DO lbi = bis,bie |
DO lbi = bis,bie |
389 |
|
|
390 |
C Create the file name |
C Create the file name |
391 |
CALL MNC_CW_GET_TILE_NUM(myThid, lbi,lbj, uniq_tnum) |
CALL MNC_CW_GET_TILE_NUM( lbi,lbj, uniq_tnum, myThid) |
392 |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
393 |
n1 = IFNBLNK(fbname) |
n1 = IFNBLNK(fbname) |
394 |
n2 = ILNBLNK(fbname) |
n2 = ILNBLNK(fbname) |
398 |
fname(ntot:ntot) = '.' |
fname(ntot:ntot) = '.' |
399 |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
400 |
nfname = ntot+9 |
nfname = ntot+9 |
|
write(*,*) 'The read file is: ', fname(1:nfname) |
|
401 |
|
|
402 |
C Open the existing file |
C Open the existing file |
403 |
CALL MNC_FILE_TRY_READ(myThid, fname, ierr, indf) |
CALL MNC_FILE_TRY_READ( fname, ierr, indf, myThid) |
404 |
|
|
405 |
C Check that the variable (VType) is defined within the file |
C Check that the variable (VType) is defined within the file |
406 |
CALL MNC_GET_FVINDS(myThid, fname, vtype, indf, ind_fv_ids) |
CALL MNC_GET_FVINDS( fname, vtype, indf, ind_fv_ids, myThid) |
407 |
IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN |
IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN |
408 |
write(msgbuf,'(4a)') 'MNC_CW_RX_R_YY ERROR: vtype ''', |
write(msgbuf,'(4a)') 'MNC_CW_RX_R_YY ERROR: vtype ''', |
409 |
& vtype(nvf:nvl), ''' is not defined within file ''', |
& vtype(nvf:nvl), ''' is not defined within file ''', |
414 |
fid = mnc_f_info(indf,2) |
fid = mnc_f_info(indf,2) |
415 |
idv = mnc_fv_ids(indf,ind_fv_ids+1) |
idv = mnc_fv_ids(indf,ind_fv_ids+1) |
416 |
|
|
|
write(*,*) 'indf,ind_fv_ids = ', indf,ind_fv_ids |
|
|
|
|
417 |
C Check that the current sNy,sNy values and the in-file values |
C Check that the current sNy,sNy values and the in-file values |
418 |
C are compatible and WARN (only warn) if not |
C are compatible and WARN (only warn) if not |
419 |
f_sNx = -1 |
f_sNx = -1 |
421 |
err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNx',atype,alen) |
err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNx',atype,alen) |
422 |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
423 |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx) |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx) |
424 |
CALL MNC_HANDLE_ERR(myThid, err, |
CALL MNC_HANDLE_ERR(err, |
425 |
& 'reading attribute ''sNx'' in S/R MNC_CW_RX_R_YY') |
& 'reading attribute ''sNx'' in S/R MNC_CW_RX_R_YY', |
426 |
|
& myThid) |
427 |
ENDIF |
ENDIF |
428 |
err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen) |
err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen) |
429 |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
430 |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy) |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy) |
431 |
CALL MNC_HANDLE_ERR(myThid, err, |
CALL MNC_HANDLE_ERR(err, |
432 |
& 'reading attribute ''sNy'' in S/R MNC_CW_RX_R_YY') |
& 'reading attribute ''sNy'' in S/R MNC_CW_RX_R_YY', |
433 |
|
& myThid) |
434 |
ENDIF |
ENDIF |
435 |
IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN |
IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN |
436 |
write(msgbuf,'(5a)') 'MNC_CW_RX_R_YY WARNING: the ', |
write(msgbuf,'(5a)') 'MNC_CW_RX_R_YY WARNING: the ', |
442 |
|
|
443 |
C Check that the in-memory variable and the in-file variables |
C Check that the in-memory variable and the in-file variables |
444 |
C are of compatible sizes |
C are of compatible sizes |
445 |
ires = 1 |
C ires = 1 |
446 |
CALL MNC_CHK_VTYP_R_NCVAR(myThid, ind_vt, |
C CALL MNC_CHK_VTYP_R_NCVAR( ind_vt, |
447 |
& indf, ind_fv_ids, indu, ires) |
C & indf, ind_fv_ids, indu, ires) |
448 |
IF (ires .LT. 0) THEN |
C IF (ires .LT. 0) THEN |
449 |
write(msgbuf,'(7a)') 'MNC_CW_RX_R_YY WARNING: the sizes ', |
C write(msgbuf,'(7a)') 'MNC_CW_RX_R_YY WARNING: the sizes ', |
450 |
& 'of the in-program variable ''', vtype(nvf:nvl), |
C & 'of the in-program variable ''', vtype(nvf:nvl), |
451 |
& ''' and the corresponding variable within file ''', |
C & ''' and the corresponding variable within file ''', |
452 |
& fname(1:nfname), ''' are not compatible -- please ', |
C & fname(1:nfname), ''' are not compatible -- please ', |
453 |
& 'check the sizes' |
C & 'check the sizes' |
454 |
CALL print_error(msgbuf, mythid) |
C CALL print_error(msgbuf, mythid) |
455 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
C STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
456 |
ENDIF |
C ENDIF |
457 |
|
|
458 |
C Check for bi,bj indicies |
C Check for bi,bj indicies |
459 |
bidim = mnc_cw_vbij(1,ind_vt) |
bidim = mnc_cw_vbij(1,ind_vt) |
460 |
bjdim = mnc_cw_vbij(2,ind_vt) |
bjdim = mnc_cw_vbij(2,ind_vt) |
|
write(*,*) 'bidim,bjdim = ', bidim,bjdim |
|
461 |
|
|
462 |
C Set the dimensions for the in-memory array |
C Set the dimensions for the in-memory array |
463 |
ndim = mnc_cw_ndim(igrid) |
ndim = mnc_cw_ndim(igrid) |
499 |
udo(i) = indu - 1 |
udo(i) = indu - 1 |
500 |
ELSEIF (indu .EQ. -1) THEN |
ELSEIF (indu .EQ. -1) THEN |
501 |
C Append one to the current unlimited dim size |
C Append one to the current unlimited dim size |
502 |
CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz) |
CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid) |
503 |
udo(i) = unlim_sz |
udo(i) = unlim_sz |
504 |
ELSE |
ELSE |
505 |
C Use the current unlimited dim size |
C Use the current unlimited dim size |
506 |
CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz) |
CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid) |
507 |
udo(i) = unlim_sz - 1 |
udo(i) = unlim_sz - 1 |
508 |
ENDIF |
ENDIF |
509 |
ENDIF |
ENDIF |
517 |
e(bjdim) = lbj |
e(bjdim) = lbj |
518 |
ENDIF |
ENDIF |
519 |
|
|
520 |
DO i = 9,1,-1 |
C DO i = 9,1,-1 |
521 |
write(*,*) 'i,p(i),s(i),e(i) = ', i,': ',p(i),s(i),e(i) |
C write(*,*) 'i,p(i),s(i),e(i) = ', i,': ',p(i),s(i),e(i) |
522 |
ENDDO |
C ENDDO |
523 |
|
|
524 |
CALL MNC_FILE_ENDDEF(myThid,fname) |
CALL MNC_FILE_ENDDEF(fname, myThid) |
525 |
|
|
526 |
write(msgbuf,'(5a)') 'reading variable type ''', |
write(msgbuf,'(5a)') 'reading variable type ''', |
527 |
& vtype(nvf:nvl), ''' within file ''', |
& vtype(nvf:nvl), ''' within file ''', |
566 |
err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh) |
err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh) |
567 |
#endif |
#endif |
568 |
|
|
569 |
CALL MNC_HANDLE_ERR(myThid, err, msgbuf) |
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
570 |
|
|
571 |
kr = 0 |
kr = 0 |
572 |
DO j1 = s(1),e(1) |
DO j1 = s(1),e(1) |
583 |
ENDDO |
ENDDO |
584 |
ENDDO |
ENDDO |
585 |
|
|
586 |
|
C Close the file |
587 |
|
CALL MNC_FILE_CLOSE(fname, myThid) |
588 |
|
|
589 |
C End the lbj,lbi loops |
C End the lbj,lbi loops |
590 |
ENDDO |
ENDDO |
591 |
ENDDO |
ENDDO |