4 |
#include "MNC_OPTIONS.h" |
#include "MNC_OPTIONS.h" |
5 |
|
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
|
CBOP 0 |
8 |
|
C !ROUTINE: MNC_CW_RX_W |
9 |
|
|
10 |
SUBROUTINE MNC_CW_RX_W_YY( |
C !INTERFACE: |
11 |
I myThid, |
SUBROUTINE MNC_CW_RX_W( |
12 |
|
I stype, |
13 |
I fbname, bi,bj, |
I fbname, bi,bj, |
14 |
I vtype, |
I vtype, |
15 |
I indu, |
I var, |
16 |
I var ) |
I myThid ) |
17 |
|
|
18 |
|
C !DESCRIPTION: |
19 |
|
C This subroutine writes one variable to a file or a file group, |
20 |
|
C depending upon the tile indicies. |
21 |
|
|
22 |
|
C !USES: |
23 |
implicit none |
implicit none |
|
|
|
24 |
#include "netcdf.inc" |
#include "netcdf.inc" |
25 |
#include "mnc_common.h" |
#include "mnc_common.h" |
|
#include "EEPARAMS.h" |
|
26 |
#include "SIZE.h" |
#include "SIZE.h" |
27 |
|
#include "EEPARAMS.h" |
28 |
|
#include "PARAMS.h" |
29 |
|
|
30 |
#define mnc_rtype_YY |
C !INPUT PARAMETERS: |
|
|
|
|
C Arguments |
|
31 |
integer myThid, bi,bj, indu |
integer myThid, bi,bj, indu |
32 |
character*(*) fbname, vtype |
character*(*) stype, fbname, vtype |
33 |
_RX var(*) |
__V var(*) |
34 |
|
CEOP |
35 |
|
|
36 |
C Functions |
C !LOCAL VARIABLES: |
|
integer IFNBLNK, ILNBLNK |
|
|
|
|
|
C Local Variables |
|
37 |
integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot |
integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot |
38 |
integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv, indvids |
integer bis,bie, bjs,bje, uniq_tnum, nfname |
39 |
integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr |
integer fid, idv, indvids, ndim, indf, err |
40 |
integer p(9),s(9),e(9), dimnc(9), vstart(9),vcount(9), udo(9) |
integer lbi,lbj, bidim,bjdim, unlim_sz, kr |
41 |
|
integer p(9),s(9),e(9), dimnc(9) |
42 |
|
integer vstart(9),vcount(9), udo(9) |
43 |
integer j1,j2,j3,j4,j5,j6,j7, k1,k2,k3,k4,k5,k6,k7 |
integer j1,j2,j3,j4,j5,j6,j7, k1,k2,k3,k4,k5,k6,k7 |
44 |
|
integer indfg, fg1,fg2, npath |
45 |
character*(MAX_LEN_MBUF) msgbuf |
character*(MAX_LEN_MBUF) msgbuf |
46 |
character*(MNC_MAX_CHAR) fname |
character*(MNC_MAX_CHAR) fname |
47 |
|
character*(MNC_MAX_CHAR) path_fname |
48 |
|
REAL*8 resh_d( sNx + 2*OLx + sNy + 2*OLy ) |
49 |
|
REAL*4 resh_r( sNx + 2*OLx + sNy + 2*OLy ) |
50 |
|
INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy ) |
51 |
|
|
52 |
C Temporary storage for the simultaneous type conversion and |
C Functions |
53 |
C re-shaping before passing to NetCDF |
integer IFNBLNK, ILNBLNK |
|
#ifdef mnc_rtype_D |
|
|
REAL*8 resh( sNx + 2*OLx + sNy + 2*OLy ) |
|
|
#endif |
|
|
#ifdef mnc_rtype_R |
|
|
REAL*4 resh( sNx + 2*OLx + sNy + 2*OLy ) |
|
|
#endif |
|
54 |
|
|
55 |
C Only do I/O if I am the master thread |
C Only do I/O if I am the master thread |
56 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
57 |
|
|
58 |
|
C Get the current index for the unlimited dimension from the file |
59 |
|
C group (or base) name |
60 |
|
fg1 = IFNBLNK(fbname) |
61 |
|
fg2 = ILNBLNK(fbname) |
62 |
|
CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid) |
63 |
|
IF (indfg .LT. 1) THEN |
64 |
|
write(msgbuf,'(3a)') |
65 |
|
& 'MNC_CW_RX_W ERROR: file group name ''', |
66 |
|
& fbname(fg1:fg2), ''' is not defined' |
67 |
|
CALL print_error(msgbuf, mythid) |
68 |
|
STOP 'ABNORMAL END: S/R MNC_CW_RX_W' |
69 |
|
ENDIF |
70 |
|
indu = mnc_cw_fgud(indfg) |
71 |
|
|
72 |
C Check that the Variable Type exists |
C Check that the Variable Type exists |
73 |
nvf = IFNBLNK(vtype) |
nvf = IFNBLNK(vtype) |
74 |
nvl = ILNBLNK(vtype) |
nvl = ILNBLNK(vtype) |
75 |
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) |
76 |
IF (indv .LT. 1) THEN |
IF (indv .LT. 1) THEN |
77 |
write(msgbuf,'(3a)') 'MNC_CW_RX_WRITES_YY ERROR: vtype ''', |
write(msgbuf,'(3a)') 'MNC_CW_RX_W ERROR: vtype ''', |
78 |
& vtype(nvf:nvl), ''' is not defined' |
& vtype(nvf:nvl), ''' is not defined' |
79 |
CALL print_error(msgbuf, mythid) |
CALL print_error(msgbuf, mythid) |
80 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_WRITES_YY' |
STOP 'ABNORMAL END: S/R MNC_CW_RX_W' |
81 |
ENDIF |
ENDIF |
82 |
igrid = mnc_cw_vgind(indv) |
igrid = mnc_cw_vgind(indv) |
83 |
|
|
99 |
DO lbi = bis,bie |
DO lbi = bis,bie |
100 |
|
|
101 |
C Create the file name |
C Create the file name |
102 |
CALL MNC_CW_GET_TILE_NUM(myThid, lbi,lbj, uniq_tnum) |
CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid) |
103 |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
104 |
n1 = IFNBLNK(fbname) |
n1 = IFNBLNK(fbname) |
105 |
n2 = ILNBLNK(fbname) |
n2 = ILNBLNK(fbname) |
110 |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
111 |
nfname = ntot+9 |
nfname = ntot+9 |
112 |
|
|
113 |
|
C Add the path to the file name |
114 |
|
IF (mnc_use_outdir) THEN |
115 |
|
path_fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
116 |
|
npath = ILNBLNK(mnc_out_path) |
117 |
|
path_fname(1:npath) = mnc_out_path(1:npath) |
118 |
|
path_fname((npath+1):(npath+nfname)) = fname(1:nfname) |
119 |
|
fname(1:MNC_MAX_CHAR) = path_fname(1:MNC_MAX_CHAR) |
120 |
|
nfname = npath + nfname |
121 |
|
ENDIF |
122 |
|
|
123 |
C Append to an existing or create a new file |
C Append to an existing or create a new file |
124 |
CALL MNC_CW_FILE_AORC(myThid, fname, indf) |
CALL MNC_CW_FILE_AORC(fname, indf, myThid) |
125 |
fid = mnc_f_info(indf,2) |
fid = mnc_f_info(indf,2) |
126 |
|
|
127 |
C Ensure that all the NetCDF dimensions are defined and create a |
C Ensure that all the NetCDF dimensions are defined and create a |
135 |
ELSE |
ELSE |
136 |
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 |
137 |
ENDIF |
ENDIF |
138 |
CALL MNC_DIM_INIT(myThid,fname, |
CALL MNC_DIM_INIT(fname, |
139 |
& mnc_cw_dn(i,igrid), dimnc(i) ) |
& mnc_cw_dn(i,igrid), dimnc(i), myThid) |
140 |
ENDDO |
ENDDO |
141 |
|
|
142 |
C Ensure that the "grid" is defined |
C Ensure that the "grid" is defined |
143 |
CALL MNC_GRID_INIT(myThid,fname, mnc_cw_gname(igrid), |
CALL MNC_GRID_INIT(fname, mnc_cw_gname(igrid), |
144 |
& mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid)) |
& mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid), myThid) |
145 |
|
|
146 |
C Ensure that the variable is defined |
C Ensure that the variable is defined |
147 |
#ifdef mnc_rtype_D |
IF (stype(1:1) .EQ. 'D') |
148 |
CALL MNC_VAR_INIT_DBL(myThid,fname,mnc_cw_gname(igrid),vtype) |
& CALL MNC_VAR_INIT_DBL( |
149 |
#endif |
& fname, mnc_cw_gname(igrid), vtype, myThid) |
150 |
#ifdef mnc_rtype_R |
IF (stype(1:1) .EQ. 'R') |
151 |
CALL MNC_VAR_INIT_REAL(myThid,fname,mnc_cw_gname(igrid),vtype) |
& CALL MNC_VAR_INIT_REAL( |
152 |
#endif |
& fname, mnc_cw_gname(igrid), vtype, myThid) |
153 |
|
IF (stype(1:1) .EQ. 'I') |
154 |
|
& CALL MNC_VAR_INIT_INT( |
155 |
|
& fname, mnc_cw_gname(igrid), vtype, myThid) |
156 |
|
|
157 |
DO i = 1,mnc_fv_ids(indf,1) |
DO i = 1,mnc_fv_ids(indf,1) |
158 |
j = 2 + 3*(i - 1) |
j = 2 + 3*(i - 1) |
159 |
IF (mnc_v_names(mnc_fv_ids(indf,j)) .EQ. vtype) THEN |
IF (mnc_v_names(mnc_fv_ids(indf,j)) .EQ. vtype) THEN |
163 |
GOTO 10 |
GOTO 10 |
164 |
ENDIF |
ENDIF |
165 |
ENDDO |
ENDDO |
166 |
write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_WRITES_YY ERROR: ', |
write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ', |
167 |
& 'cannot reference variable ''', vtype, '''' |
& 'cannot reference variable ''', vtype, '''' |
168 |
CALL print_error(msgbuf, mythid) |
CALL print_error(msgbuf, mythid) |
169 |
STOP 'ABNORMAL END: package MNC' |
STOP 'ABNORMAL END: package MNC' |
214 |
udo(i) = indu - 1 |
udo(i) = indu - 1 |
215 |
ELSEIF (indu .EQ. -1) THEN |
ELSEIF (indu .EQ. -1) THEN |
216 |
C Append one to the current unlimited dim size |
C Append one to the current unlimited dim size |
217 |
CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz) |
CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid) |
218 |
udo(i) = unlim_sz |
udo(i) = unlim_sz |
219 |
ELSE |
ELSE |
220 |
C Use the current unlimited dim size |
C Use the current unlimited dim size |
221 |
CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz) |
CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid) |
222 |
udo(i) = unlim_sz - 1 |
udo(i) = unlim_sz - 1 |
223 |
ENDIF |
ENDIF |
224 |
ENDIF |
ENDIF |
236 |
CEH3 ENDDO |
CEH3 ENDDO |
237 |
|
|
238 |
C Add the global attributes |
C Add the global attributes |
239 |
CALL MNC_CW_SET_GATTR(myThid, fname, lbi,lbj, uniq_tnum) |
CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid) |
240 |
|
|
241 |
C Add the per-variable attributes |
C Add the per-variable attributes |
242 |
DO i = 1,mnc_cw_vnat(1,indv) |
DO i = 1,mnc_cw_vnat(1,indv) |
243 |
CALL MNC_VAR_ADD_ATTR_STR(myThid, fname, vtype, |
CALL MNC_VAR_ADD_ATTR_STR( fname, vtype, |
244 |
& mnc_cw_vtnm(i,indv), mnc_cw_vtat(i,indv)) |
& mnc_cw_vtnm(i,indv), mnc_cw_vtat(i,indv), myThid) |
245 |
ENDDO |
ENDDO |
246 |
DO i = 1,mnc_cw_vnat(2,indv) |
DO i = 1,mnc_cw_vnat(2,indv) |
247 |
CALL MNC_VAR_ADD_ATTR_INT(myThid, fname, vtype, |
CALL MNC_VAR_ADD_ATTR_INT( fname, vtype, |
248 |
& mnc_cw_vinm(i,indv), 1, mnc_cw_viat(i,indv)) |
& mnc_cw_vinm(i,indv), 1, mnc_cw_viat(i,indv), myThid) |
249 |
ENDDO |
ENDDO |
250 |
DO i = 1,mnc_cw_vnat(3,indv) |
DO i = 1,mnc_cw_vnat(3,indv) |
251 |
CALL MNC_VAR_ADD_ATTR_DBL(myThid, fname, vtype, |
CALL MNC_VAR_ADD_ATTR_DBL( fname, vtype, |
252 |
& mnc_cw_vdnm(i,indv), 1, mnc_cw_vdat(i,indv)) |
& mnc_cw_vdnm(i,indv), 1, mnc_cw_vdat(i,indv), myThid) |
253 |
ENDDO |
ENDDO |
254 |
|
|
255 |
CALL MNC_FILE_ENDDEF(myThid,fname) |
CALL MNC_FILE_ENDDEF(fname, myThid) |
256 |
|
|
257 |
|
write(msgbuf,'(5a)') 'writing variable type ''', |
258 |
|
& vtype(nvf:nvl), ''' within file ''', |
259 |
|
& fname(1:nfname), '''' |
260 |
|
|
261 |
C Write the variable one vector at a time |
C Write the variable one vector at a time |
262 |
DO j7 = s(7),e(7) |
DO j7 = s(7),e(7) |
285 |
vcount(2) = 1 |
vcount(2) = 1 |
286 |
|
|
287 |
kr = 0 |
kr = 0 |
|
DO j1 = s(1),e(1) |
|
|
k1 = k2 + j1 |
|
|
kr = kr + 1 |
|
|
resh(kr) = var(k1) |
|
|
ENDDO |
|
|
|
|
288 |
vstart(1) = udo(1) + 1 |
vstart(1) = udo(1) + 1 |
289 |
vcount(1) = e(1) - s(1) + 1 |
vcount(1) = e(1) - s(1) + 1 |
290 |
|
|
291 |
#ifdef mnc_rtype_D |
IF (stype(1:1) .EQ. 'D') THEN |
292 |
err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh) |
DO j1 = s(1),e(1) |
293 |
#endif |
k1 = k2 + j1 |
294 |
#ifdef mnc_rtype_R |
kr = kr + 1 |
295 |
err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh) |
resh_d(kr) = var(k1) |
296 |
#endif |
ENDDO |
297 |
|
err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d) |
298 |
|
ENDIF |
299 |
|
IF (stype(1:1) .EQ. 'R') THEN |
300 |
|
DO j1 = s(1),e(1) |
301 |
|
k1 = k2 + j1 |
302 |
|
kr = kr + 1 |
303 |
|
resh_r(kr) = var(k1) |
304 |
|
ENDDO |
305 |
|
err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh_r) |
306 |
|
ENDIF |
307 |
|
IF (stype(1:1) .EQ. 'I') THEN |
308 |
|
DO j1 = s(1),e(1) |
309 |
|
k1 = k2 + j1 |
310 |
|
kr = kr + 1 |
311 |
|
resh_i(kr) = var(k1) |
312 |
|
ENDDO |
313 |
|
err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh_i) |
314 |
|
ENDIF |
315 |
|
|
316 |
|
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
317 |
|
|
318 |
ENDDO |
ENDDO |
319 |
ENDDO |
ENDDO |
325 |
C Sync the file |
C Sync the file |
326 |
err = NF_SYNC(fid) |
err = NF_SYNC(fid) |
327 |
write(msgbuf,'(3a)') 'sync for file ''', fname, |
write(msgbuf,'(3a)') 'sync for file ''', fname, |
328 |
& ''' in S/R MNC_CW_RX_WRITES_YY' |
& ''' in S/R MNC_CW_RX_W' |
329 |
CALL MNC_HANDLE_ERR(myThid, err, msgbuf) |
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
330 |
|
|
331 |
ENDDO |
ENDDO |
332 |
ENDDO |
ENDDO |
338 |
|
|
339 |
|
|
340 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
341 |
|
CBOP 0 |
342 |
|
C !ROUTINE: MNC_CW_RX_R |
343 |
|
|
344 |
|
C !INTERFACE: |
345 |
SUBROUTINE MNC_CW_RX_R_YY( |
SUBROUTINE MNC_CW_RX_R( |
346 |
I myThid, |
I stype, |
347 |
I fbname, bi,bj, |
I fbname, bi,bj, |
348 |
I vtype, |
I vtype, |
349 |
I indu, |
I var, |
350 |
I var ) |
I myThid ) |
351 |
|
|
352 |
|
C !DESCRIPTION: |
353 |
|
C This subroutine reads one variable from a file or a file group, |
354 |
|
C depending upon the tile indicies. |
355 |
|
|
356 |
|
C !USES: |
357 |
implicit none |
implicit none |
|
|
|
358 |
#include "netcdf.inc" |
#include "netcdf.inc" |
359 |
#include "mnc_common.h" |
#include "mnc_common.h" |
|
#include "EEPARAMS.h" |
|
360 |
#include "SIZE.h" |
#include "SIZE.h" |
361 |
|
#include "EEPARAMS.h" |
362 |
|
#include "PARAMS.h" |
363 |
|
|
364 |
#define mnc_rtype_YY |
C !INPUT PARAMETERS: |
|
|
|
|
C Arguments |
|
365 |
integer myThid, bi,bj, indu |
integer myThid, bi,bj, indu |
366 |
character*(*) fbname, vtype |
character*(*) stype, fbname, vtype |
367 |
_RX var(*) |
__V var(*) |
368 |
|
CEOP |
369 |
C Functions |
|
370 |
integer IFNBLNK, ILNBLNK |
C !LOCAL VARIABLES: |
371 |
|
integer i,k, nvf,nvl, n1,n2, igrid, ntot |
372 |
C Local Variables |
integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv |
|
integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot |
|
|
integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv, indvids |
|
373 |
integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr |
integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr |
374 |
integer ind_fv_ids, ind_vt |
integer ind_fv_ids, ind_vt, ierr, atype, alen |
375 |
integer f_sNx,f_sNy,f_OLx,f_OLy, ires |
integer f_sNx,f_sNy, npath |
376 |
|
integer p(9),s(9),e(9), vstart(9),vcount(9), udo(9) |
377 |
|
integer j1,j2,j3,j4,j5,j6,j7, k1,k2,k3,k4,k5,k6,k7 |
378 |
character*(MAX_LEN_MBUF) msgbuf |
character*(MAX_LEN_MBUF) msgbuf |
379 |
character*(MNC_MAX_CHAR) fname |
character*(MNC_MAX_CHAR) fname |
380 |
|
character*(MNC_MAX_CHAR) path_fname |
381 |
|
integer indfg, fg1,fg2 |
382 |
|
REAL*8 resh_d( sNx + 2*OLx + sNy + 2*OLy ) |
383 |
|
REAL*4 resh_r( sNx + 2*OLx + sNy + 2*OLy ) |
384 |
|
INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy ) |
385 |
|
|
386 |
C Temporary storage for the simultaneous type conversion and |
C Functions |
387 |
C re-shaping before passing to NetCDF |
integer IFNBLNK, ILNBLNK |
|
#ifdef mnc_rtype_D |
|
|
REAL*8 resh( sNx + 2*OLx + sNy + 2*OLy ) |
|
|
#endif |
|
|
#ifdef mnc_rtype_R |
|
|
REAL*4 resh( sNx + 2*OLx + sNy + 2*OLy ) |
|
|
#endif |
|
388 |
|
|
389 |
C Only do I/O if I am the master thread |
C Only do I/O if I am the master thread |
390 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
391 |
|
|
392 |
|
C Get the current index for the unlimited dimension from the file |
393 |
|
C group (or base) name |
394 |
|
fg1 = IFNBLNK(fbname) |
395 |
|
fg2 = ILNBLNK(fbname) |
396 |
|
CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid) |
397 |
|
IF (indfg .LT. 1) THEN |
398 |
|
write(msgbuf,'(3a)') |
399 |
|
& 'MNC_CW_RX_W ERROR: file group name ''', |
400 |
|
& fbname(fg1:fg2), ''' is not defined' |
401 |
|
CALL print_error(msgbuf, mythid) |
402 |
|
STOP 'ABNORMAL END: S/R MNC_CW_RX_W' |
403 |
|
ENDIF |
404 |
|
indu = mnc_cw_fgud(indfg) |
405 |
|
|
406 |
C Check that the Variable Type exists |
C Check that the Variable Type exists |
407 |
nvf = IFNBLNK(vtype) |
nvf = IFNBLNK(vtype) |
408 |
nvl = ILNBLNK(vtype) |
nvl = ILNBLNK(vtype) |
409 |
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) |
410 |
IF (indv .LT. 1) THEN |
IF (ind_vt .LT. 1) THEN |
411 |
write(msgbuf,'(3a)') 'MNC_CW_RX_R_YY ERROR: vtype ''', |
write(msgbuf,'(3a)') 'MNC_CW_RX_R ERROR: vtype ''', |
412 |
& vtype(nvf:nvl), ''' is not defined' |
& vtype(nvf:nvl), ''' is not defined' |
413 |
CALL print_error(msgbuf, mythid) |
CALL print_error(msgbuf, mythid) |
414 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R' |
415 |
ENDIF |
ENDIF |
416 |
igrid = mnc_cw_vgind(ind_vt) |
igrid = mnc_cw_vgind(ind_vt) |
417 |
|
|
418 |
C Check for bi,bj indicies |
C Check for bi,bj indicies |
419 |
bidim = mnc_cw_vbij(1,indv) |
bidim = mnc_cw_vbij(1,ind_vt) |
420 |
bjdim = mnc_cw_vbij(2,indv) |
bjdim = mnc_cw_vbij(2,ind_vt) |
421 |
|
|
422 |
C Set the bi,bj indicies |
C Set the bi,bj indicies |
423 |
bis = bi |
bis = bi |
437 |
DO lbi = bis,bie |
DO lbi = bis,bie |
438 |
|
|
439 |
C Create the file name |
C Create the file name |
440 |
CALL MNC_CW_GET_TILE_NUM(myThid, lbi,lbj, uniq_tnum) |
CALL MNC_CW_GET_TILE_NUM( lbi,lbj, uniq_tnum, myThid) |
441 |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
442 |
n1 = IFNBLNK(fbname) |
n1 = IFNBLNK(fbname) |
443 |
n2 = ILNBLNK(fbname) |
n2 = ILNBLNK(fbname) |
448 |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
449 |
nfname = ntot+9 |
nfname = ntot+9 |
450 |
|
|
451 |
|
C Add the path to the file name |
452 |
|
IF (mnc_use_indir) THEN |
453 |
|
path_fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
454 |
|
npath = ILNBLNK(mnc_indir_str) |
455 |
|
path_fname(1:npath) = mnc_indir_str(1:npath) |
456 |
|
path_fname((npath+1):(npath+nfname)) = fname(1:nfname) |
457 |
|
fname(1:MNC_MAX_CHAR) = path_fname(1:MNC_MAX_CHAR) |
458 |
|
nfname = npath + nfname |
459 |
|
ENDIF |
460 |
|
|
461 |
C Open the existing file |
C Open the existing file |
462 |
CALL MNC_FILE_OPEN(myThid, fname, 1, indf) |
CALL MNC_FILE_TRY_READ( fname, ierr, indf, myThid) |
463 |
|
|
464 |
C Check that the variable (VType) is defined within the file |
C Check that the variable (VType) is defined within the file |
465 |
CALL MNC_GET_FVINDS(myThid, fname, vtype, indf, ind_fv_ids) |
CALL MNC_GET_FVINDS( fname, vtype, indf, ind_fv_ids, myThid) |
466 |
IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN |
IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN |
467 |
write(msgbuf,'(4a)') 'MNC_CW_RX_R_YY ERROR: vtype ''', |
write(msgbuf,'(4a)') 'MNC_CW_RX_R ERROR: vtype ''', |
468 |
& vtype(nvf:nvl), ''' is not defined within file ''', |
& vtype(nvf:nvl), ''' is not defined within file ''', |
469 |
& fname(1:nfname) |
& fname(1:nfname) |
470 |
CALL print_error(msgbuf, mythid) |
CALL print_error(msgbuf, mythid) |
471 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R' |
472 |
ENDIF |
ENDIF |
473 |
fid = mnc_f_info(indf,2) |
fid = mnc_f_info(indf,2) |
474 |
|
idv = mnc_fv_ids(indf,ind_fv_ids+1) |
475 |
|
|
476 |
C Check that the VType sizes and in-file sizes match |
C Check that the current sNy,sNy values and the in-file values |
477 |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', NF_INT, 1, f_sNx) |
C are compatible and WARN (only warn) if not |
478 |
CALL MNC_HANDLE_ERR(myThid, err, |
f_sNx = -1 |
479 |
& 'reading attribute ''sNx'' in S/R MNC_CW_RX_R_YY') |
f_sNy = -1 |
480 |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', NF_INT, 1, f_sNy) |
err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNx',atype,alen) |
481 |
CALL MNC_HANDLE_ERR(myThid, err, |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
482 |
& 'reading attribute ''sNy'' in S/R MNC_CW_RX_R_YY') |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx) |
483 |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'OLx', NF_INT, 1, f_OLx) |
CALL MNC_HANDLE_ERR(err, |
484 |
CALL MNC_HANDLE_ERR(myThid, err, |
& 'reading attribute ''sNx'' in S/R MNC_CW_RX_R', |
485 |
& 'reading attribute ''OLx'' in S/R MNC_CW_RX_R_YY') |
& myThid) |
486 |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'OLy', NF_INT, 1, f_OLy) |
ENDIF |
487 |
CALL MNC_HANDLE_ERR(myThid, err, |
err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen) |
488 |
& 'reading attribute ''OLy'' in S/R MNC_CW_RX_R_YY') |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
489 |
|
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy) |
490 |
|
CALL MNC_HANDLE_ERR(err, |
491 |
|
& 'reading attribute ''sNy'' in S/R MNC_CW_RX_R', |
492 |
|
& myThid) |
493 |
|
ENDIF |
494 |
IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN |
IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN |
495 |
write(msgbuf,'(5a)') 'MNC_CW_RX_R_YY ERROR: the sizes of ', |
write(msgbuf,'(5a)') 'MNC_CW_RX_R WARNING: the ', |
496 |
& '''sNx'' and ''sNy'' within the file ''', |
& 'attributes ''sNx'' and ''sNy'' within the file ''', |
497 |
& fname(1:nfname), ''' do not match the current sizes', |
& fname(1:nfname), ''' do not exist or do not match ', |
498 |
& ' within the model' |
& 'the current sizes within the model' |
499 |
CALL print_error(msgbuf, mythid) |
CALL print_error(msgbuf, mythid) |
|
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
|
500 |
ENDIF |
ENDIF |
501 |
|
|
502 |
CALL MNC_COMP_VTYPE_VAR(myThid,ind_vt, indf,ind_fv_ids, ires) |
C Check that the in-memory variable and the in-file variables |
503 |
|
C are of compatible sizes |
504 |
|
C ires = 1 |
505 |
|
C CALL MNC_CHK_VTYP_R_NCVAR( ind_vt, |
506 |
|
C & indf, ind_fv_ids, indu, ires) |
507 |
|
C IF (ires .LT. 0) THEN |
508 |
|
C write(msgbuf,'(7a)') 'MNC_CW_RX_R WARNING: the sizes ', |
509 |
|
C & 'of the in-program variable ''', vtype(nvf:nvl), |
510 |
|
C & ''' and the corresponding variable within file ''', |
511 |
|
C & fname(1:nfname), ''' are not compatible -- please ', |
512 |
|
C & 'check the sizes' |
513 |
|
C CALL print_error(msgbuf, mythid) |
514 |
|
C STOP 'ABNORMAL END: S/R MNC_CW_RX_R' |
515 |
|
C ENDIF |
516 |
|
|
517 |
IF (ires .LT. 0) THEN |
C Check for bi,bj indicies |
518 |
write(msgbuf,'(7a)') 'MNC_CW_RX_R_YY ERROR: the sizes of ', |
bidim = mnc_cw_vbij(1,ind_vt) |
519 |
& ' the in-program variable ''', vtype(nvf:nvl), |
bjdim = mnc_cw_vbij(2,ind_vt) |
520 |
& ''' and the corresponding variable within file ''', |
|
521 |
& fname(1:nfname), ''' are not compatible -- please ', |
C Set the dimensions for the in-memory array |
522 |
& 'check the sizes!' |
ndim = mnc_cw_ndim(igrid) |
523 |
CALL print_error(msgbuf, mythid) |
k = mnc_cw_dims(1,igrid) |
524 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
IF (k .GT. 0) THEN |
525 |
|
p(1) = k |
526 |
|
ELSE |
527 |
|
p(1) = 1 |
528 |
ENDIF |
ENDIF |
529 |
|
DO i = 2,9 |
530 |
|
k = mnc_cw_dims(i,igrid) |
531 |
|
IF (k .LT. 1) THEN |
532 |
|
k = 1 |
533 |
|
ENDIF |
534 |
|
IF ((bidim .GT. 0) .AND. (i .EQ. bidim)) THEN |
535 |
|
p(i) = nSx * p(i-1) |
536 |
|
ELSEIF ((bjdim .GT. 0) .AND. (i .EQ. bjdim)) THEN |
537 |
|
p(i) = nSy * p(i-1) |
538 |
|
ELSE |
539 |
|
p(i) = k * p(i-1) |
540 |
|
ENDIF |
541 |
|
ENDDO |
542 |
|
|
543 |
|
C Set starting and ending indicies for the in-memory array and |
544 |
|
C the unlimited dimension offset for the NetCDF array |
545 |
|
DO i = 1,9 |
546 |
|
udo(i) = 0 |
547 |
|
s(i) = 1 |
548 |
|
e(i) = 1 |
549 |
|
IF (i .LE. ndim) THEN |
550 |
|
s(i) = mnc_cw_is(i,igrid) |
551 |
|
e(i) = mnc_cw_ie(i,igrid) |
552 |
|
ENDIF |
553 |
|
C Check for the unlimited dimension |
554 |
|
IF ((i .EQ. ndim) |
555 |
|
& .AND. (mnc_cw_dims(i,igrid) .EQ. -1)) THEN |
556 |
|
IF (indu .GT. 0) THEN |
557 |
|
C Use the indu value |
558 |
|
udo(i) = indu - 1 |
559 |
|
ELSEIF (indu .EQ. -1) THEN |
560 |
|
C Append one to the current unlimited dim size |
561 |
|
CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid) |
562 |
|
udo(i) = unlim_sz |
563 |
|
ELSE |
564 |
|
C Use the current unlimited dim size |
565 |
|
CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid) |
566 |
|
udo(i) = unlim_sz - 1 |
567 |
|
ENDIF |
568 |
|
ENDIF |
569 |
|
ENDDO |
570 |
|
IF (bidim .GT. 0) THEN |
571 |
|
s(bidim) = lbi |
572 |
|
e(bidim) = lbi |
573 |
|
ENDIF |
574 |
|
IF (bjdim .GT. 0) THEN |
575 |
|
s(bjdim) = lbj |
576 |
|
e(bjdim) = lbj |
577 |
|
ENDIF |
578 |
|
|
579 |
|
C DO i = 9,1,-1 |
580 |
|
C write(*,*) 'i,p(i),s(i),e(i) = ', i,': ',p(i),s(i),e(i) |
581 |
|
C ENDDO |
582 |
|
|
583 |
|
CALL MNC_FILE_ENDDEF(fname, myThid) |
584 |
|
|
585 |
|
write(msgbuf,'(5a)') 'reading variable type ''', |
586 |
|
& vtype(nvf:nvl), ''' within file ''', |
587 |
|
& fname(1:nfname), '''' |
588 |
|
|
589 |
|
C Read the variable one vector at a time |
590 |
|
DO j7 = s(7),e(7) |
591 |
|
k7 = (j7 - 1)*p(6) |
592 |
|
vstart(7) = udo(7) + j7 - s(7) + 1 |
593 |
|
vcount(7) = 1 |
594 |
|
DO j6 = s(6),e(6) |
595 |
|
k6 = (j6 - 1)*p(5) + k7 |
596 |
|
vstart(6) = udo(6) + j6 - s(6) + 1 |
597 |
|
vcount(6) = 1 |
598 |
|
DO j5 = s(5),e(5) |
599 |
|
k5 = (j5 - 1)*p(4) + k6 |
600 |
|
vstart(5) = udo(5) + j5 - s(5) + 1 |
601 |
|
vcount(5) = 1 |
602 |
|
DO j4 = s(4),e(4) |
603 |
|
k4 = (j4 - 1)*p(3) + k5 |
604 |
|
vstart(4) = udo(4) + j4 - s(4) + 1 |
605 |
|
vcount(4) = 1 |
606 |
|
DO j3 = s(3),e(3) |
607 |
|
k3 = (j3 - 1)*p(2) + k4 |
608 |
|
vstart(3) = udo(3) + j3 - s(3) + 1 |
609 |
|
vcount(3) = 1 |
610 |
|
DO j2 = s(2),e(2) |
611 |
|
k2 = (j2 - 1)*p(1) + k3 |
612 |
|
vstart(2) = udo(2) + j2 - s(2) + 1 |
613 |
|
vcount(2) = 1 |
614 |
|
|
615 |
|
kr = 0 |
616 |
|
vstart(1) = udo(1) + 1 |
617 |
|
vcount(1) = e(1) - s(1) + 1 |
618 |
|
|
619 |
|
IF (stype(1:1) .EQ. 'D') THEN |
620 |
|
err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d) |
621 |
|
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
622 |
|
DO j1 = s(1),e(1) |
623 |
|
k1 = k2 + j1 |
624 |
|
kr = kr + 1 |
625 |
|
var(k1) = resh_d(kr) |
626 |
|
ENDDO |
627 |
|
ENDIF |
628 |
|
IF (stype(1:1) .EQ. 'R') THEN |
629 |
|
err = NF_GET_VARA_REAL(fid, idv, vstart, vcount, resh_r) |
630 |
|
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
631 |
|
DO j1 = s(1),e(1) |
632 |
|
k1 = k2 + j1 |
633 |
|
kr = kr + 1 |
634 |
|
var(k1) = resh_r(kr) |
635 |
|
ENDDO |
636 |
|
ENDIF |
637 |
|
IF (stype(1:1) .EQ. 'I') THEN |
638 |
|
err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh_i) |
639 |
|
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
640 |
|
DO j1 = s(1),e(1) |
641 |
|
k1 = k2 + j1 |
642 |
|
kr = kr + 1 |
643 |
|
var(k1) = resh_i(kr) |
644 |
|
ENDDO |
645 |
|
ENDIF |
646 |
|
|
647 |
|
|
648 |
|
|
649 |
|
ENDDO |
650 |
|
ENDDO |
651 |
|
ENDDO |
652 |
|
ENDDO |
653 |
|
ENDDO |
654 |
|
ENDDO |
655 |
|
|
656 |
|
C Close the file |
657 |
|
CALL MNC_FILE_CLOSE(fname, myThid) |
658 |
|
|
659 |
|
C End the lbj,lbi loops |
660 |
ENDDO |
ENDDO |
661 |
ENDDO |
ENDDO |
662 |
|
|