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_S |
9 |
|
|
10 |
SUBROUTINE MNC_CW_RX_W_YY( |
C !INTERFACE: |
11 |
|
SUBROUTINE MNC_CW_RX_W_S( |
12 |
|
I stype, |
13 |
I fbname, bi,bj, |
I fbname, bi,bj, |
14 |
I vtype, |
I vtype, |
|
I indu, |
|
15 |
I var, |
I var, |
16 |
I myThid ) |
I myThid ) |
17 |
|
|
18 |
|
C !DESCRIPTION: |
19 |
|
C A scalar version of MNC_CW_RX_W() for compilers that cannot |
20 |
|
C gracefully handle the conversion on their own. |
21 |
|
|
22 |
|
C !USES: |
23 |
implicit none |
implicit none |
24 |
|
|
25 |
|
C !INPUT PARAMETERS: |
26 |
|
integer myThid, bi,bj |
27 |
|
character*(*) stype, fbname, vtype |
28 |
|
__V var |
29 |
|
__V var_arr(1) |
30 |
|
CEOP |
31 |
|
|
32 |
|
var_arr(1) = var |
33 |
|
CALL MNC_CW_RX_W(stype,fbname,bi,bj,vtype, var_arr, myThid) |
34 |
|
|
35 |
|
RETURN |
36 |
|
END |
37 |
|
|
38 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
39 |
|
CBOP 0 |
40 |
|
C !ROUTINE: MNC_CW_RX_W |
41 |
|
|
42 |
|
C !INTERFACE: |
43 |
|
SUBROUTINE MNC_CW_RX_W( |
44 |
|
I stype, |
45 |
|
I fbname, bi,bj, |
46 |
|
I vtype, |
47 |
|
I var, |
48 |
|
I myThid ) |
49 |
|
|
50 |
|
C !DESCRIPTION: |
51 |
|
C A scalar version of MNC_CW_RX_W() for compilers that cannot |
52 |
|
C gracefully handle the conversion on their own. |
53 |
|
|
54 |
|
C !USES: |
55 |
|
implicit none |
56 |
|
|
57 |
|
C !INPUT PARAMETERS: |
58 |
|
integer myThid, bi,bj |
59 |
|
character*(*) stype, fbname, vtype |
60 |
|
__V var(*) |
61 |
|
INTEGER offsets(9) |
62 |
|
CEOP |
63 |
|
INTEGER i |
64 |
|
|
65 |
|
DO i = 1,9 |
66 |
|
offsets(i) = 0 |
67 |
|
ENDDO |
68 |
|
CALL MNC_CW_RX_W_OFFSET(stype,fbname,bi,bj,vtype, var, |
69 |
|
& offsets, myThid) |
70 |
|
|
71 |
|
RETURN |
72 |
|
END |
73 |
|
|
74 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
75 |
|
CBOP 0 |
76 |
|
C !ROUTINE: MNC_CW_RX_W_OFFSET |
77 |
|
|
78 |
|
C !INTERFACE: |
79 |
|
SUBROUTINE MNC_CW_RX_W_OFFSET( |
80 |
|
I stype, |
81 |
|
I fbname, bi,bj, |
82 |
|
I vtype, |
83 |
|
I var, |
84 |
|
I offsets, |
85 |
|
I myThid ) |
86 |
|
|
87 |
|
C !DESCRIPTION: |
88 |
|
C This subroutine writes one variable to a file or a file group, |
89 |
|
C depending upon the tile indicies. |
90 |
|
|
91 |
|
C !USES: |
92 |
|
implicit none |
93 |
#include "netcdf.inc" |
#include "netcdf.inc" |
94 |
#include "mnc_common.h" |
#include "mnc_common.h" |
|
#include "EEPARAMS.h" |
|
95 |
#include "SIZE.h" |
#include "SIZE.h" |
96 |
|
#include "MNC_SIZE.h" |
97 |
|
#include "EEPARAMS.h" |
98 |
|
#include "PARAMS.h" |
99 |
|
#include "MNC_PARAMS.h" |
100 |
|
|
101 |
#define mnc_rtype_YY |
C !INPUT PARAMETERS: |
102 |
|
integer myThid, bi,bj |
103 |
C Arguments |
character*(*) stype, fbname, vtype |
|
integer myThid, bi,bj, indu |
|
|
character*(*) fbname, vtype |
|
104 |
__V var(*) |
__V var(*) |
105 |
|
INTEGER offsets(*) |
106 |
|
CEOP |
107 |
|
|
108 |
C Functions |
C !LOCAL VARIABLES: |
109 |
integer IFNBLNK, ILNBLNK |
integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot, indu |
110 |
|
integer bis,bie, bjs,bje, uniq_tnum, nfname, iseq |
111 |
C Local Variables |
integer fid, idv, indvids, ndim, indf, err |
112 |
integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot |
integer lbi,lbj, bidim,bjdim, unlim_sz, kr |
113 |
integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv, indvids |
integer p(9),s(9),e(9), dimnc(9) |
114 |
integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr |
integer vstart(9),vcount(9), udo(9) |
|
integer p(9),s(9),e(9), dimnc(9), vstart(9),vcount(9), udo(9) |
|
115 |
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 |
116 |
|
integer indfg, fg1,fg2, npath |
117 |
character*(MAX_LEN_MBUF) msgbuf |
character*(MAX_LEN_MBUF) msgbuf |
118 |
character*(MNC_MAX_CHAR) fname |
character*(MNC_MAX_CHAR) fname |
119 |
|
character*(MNC_MAX_CHAR) path_fname |
120 |
C Temporary storage for the simultaneous type conversion and |
REAL*8 resh_d( MNC_MAX_BUFF ) |
121 |
C re-shaping before passing to NetCDF |
REAL*4 resh_r( MNC_MAX_BUFF ) |
122 |
#ifdef mnc_rtype_D |
INTEGER resh_i( MNC_MAX_BUFF ) |
123 |
REAL*8 resh( sNx + 2*OLx + sNy + 2*OLy ) |
#ifdef HAVE_STAT |
124 |
#endif |
integer ntotenc, ncenc, nbytes, fs_isdone |
125 |
#ifdef mnc_rtype_R |
character*(200) cenc |
126 |
REAL*4 resh( sNx + 2*OLx + sNy + 2*OLy ) |
integer ienc(200) |
127 |
#endif |
REAL*8 fsnu |
|
#ifdef mnc_rtype_I |
|
|
INTEGER resh( sNx + 2*OLx + sNy + 2*OLy ) |
|
128 |
#endif |
#endif |
129 |
|
|
130 |
|
C Functions |
131 |
|
integer IFNBLNK, ILNBLNK |
132 |
|
|
133 |
C Only do I/O if I am the master thread |
C Only do I/O if I am the master thread |
134 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
135 |
|
|
136 |
|
C Get the current index for the unlimited dimension from the file |
137 |
|
C group (or base) name |
138 |
|
fg1 = IFNBLNK(fbname) |
139 |
|
fg2 = ILNBLNK(fbname) |
140 |
|
CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid) |
141 |
|
IF (indfg .LT. 1) THEN |
142 |
|
write(msgbuf,'(3a)') |
143 |
|
& 'MNC_CW_RX_W ERROR: file group name ''', |
144 |
|
& fbname(fg1:fg2), ''' is not defined' |
145 |
|
CALL print_error(msgbuf, mythid) |
146 |
|
STOP 'ABNORMAL END: S/R MNC_CW_RX_W' |
147 |
|
ENDIF |
148 |
|
indu = mnc_cw_fgud(indfg) |
149 |
|
iseq = mnc_cw_fgis(indfg) |
150 |
|
C write(*,*) 'indu,iseq = ', indu, iseq |
151 |
|
|
152 |
C Check that the Variable Type exists |
C Check that the Variable Type exists |
153 |
nvf = IFNBLNK(vtype) |
nvf = IFNBLNK(vtype) |
154 |
nvl = ILNBLNK(vtype) |
nvl = ILNBLNK(vtype) |
155 |
CALL MNC_GET_IND(MNC_MAX_ID, vtype, mnc_cw_vname, indv, myThid) |
CALL MNC_GET_IND(MNC_MAX_ID, vtype, mnc_cw_vname, indv, myThid) |
156 |
IF (indv .LT. 1) THEN |
IF (indv .LT. 1) THEN |
157 |
write(msgbuf,'(3a)') 'MNC_CW_RX_W_YY ERROR: vtype ''', |
write(msgbuf,'(3a)') 'MNC_CW_RX_W ERROR: vtype ''', |
158 |
& vtype(nvf:nvl), ''' is not defined' |
& vtype(nvf:nvl), ''' is not defined' |
159 |
CALL print_error(msgbuf, mythid) |
CALL print_error(msgbuf, mythid) |
160 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_W_YY' |
STOP 'ABNORMAL END: S/R MNC_CW_RX_W' |
161 |
ENDIF |
ENDIF |
162 |
igrid = mnc_cw_vgind(indv) |
igrid = mnc_cw_vgind(indv) |
163 |
|
|
178 |
DO lbj = bjs,bje |
DO lbj = bjs,bje |
179 |
DO lbi = bis,bie |
DO lbi = bis,bie |
180 |
|
|
181 |
|
#ifdef HAVE_STAT |
182 |
|
fs_isdone = 0 |
183 |
|
#endif |
184 |
|
10 CONTINUE |
185 |
|
|
186 |
C Create the file name |
C Create the file name |
187 |
CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid) |
CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid) |
188 |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
192 |
fname(1:ntot) = fbname(n1:n2) |
fname(1:ntot) = fbname(n1:n2) |
193 |
ntot = ntot + 1 |
ntot = ntot + 1 |
194 |
fname(ntot:ntot) = '.' |
fname(ntot:ntot) = '.' |
195 |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
write(fname((ntot+1):(ntot+14)),'(i4.4,a1,i6.6,a3)') |
196 |
nfname = ntot+9 |
& iseq,'.',uniq_tnum, '.nc' |
197 |
|
nfname = ntot + 14 |
198 |
|
|
199 |
|
C Add the path to the file name |
200 |
|
IF (mnc_use_outdir) THEN |
201 |
|
path_fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
202 |
|
npath = ILNBLNK(mnc_out_path) |
203 |
|
path_fname(1:npath) = mnc_out_path(1:npath) |
204 |
|
path_fname((npath+1):(npath+nfname)) = fname(1:nfname) |
205 |
|
fname(1:MNC_MAX_CHAR) = path_fname(1:MNC_MAX_CHAR) |
206 |
|
nfname = npath + nfname |
207 |
|
ENDIF |
208 |
|
|
209 |
C Append to an existing or create a new file |
C Append to an existing or create a new file |
210 |
CALL MNC_CW_FILE_AORC(fname, indf, myThid) |
CALL MNC_CW_FILE_AORC(fname, indf, myThid) |
211 |
fid = mnc_f_info(indf,2) |
fid = mnc_f_info(indf,2) |
212 |
|
|
213 |
|
#ifdef HAVE_STAT |
214 |
|
IF ((mnc_cw_fgig(indfg) .EQ. 1) |
215 |
|
& .AND. (fs_isdone .EQ. 0)) THEN |
216 |
|
C Decide whether to append to the existing or create a new file |
217 |
|
C based on the byte count per unlimited dimension |
218 |
|
ncenc = 70 |
219 |
|
cenc(1:26) = 'abcdefghijklmnopqrstuvwxyz' |
220 |
|
cenc(27:52) = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
221 |
|
cenc(53:70) = '0123456789_.,+-=/~' |
222 |
|
k = nfname |
223 |
|
IF (k .GT. 200) k = 200 |
224 |
|
ntotenc = 0 |
225 |
|
DO i = 1,k |
226 |
|
DO j = 1,ncenc |
227 |
|
IF (fname(i:i) .EQ. cenc(j:j)) THEN |
228 |
|
ntotenc = ntotenc + 1 |
229 |
|
ienc(ntotenc) = j |
230 |
|
GOTO 20 |
231 |
|
ENDIF |
232 |
|
ENDDO |
233 |
|
20 CONTINUE |
234 |
|
ENDDO |
235 |
|
CALL mncfsize(ntotenc, ienc, nbytes) |
236 |
|
IF (nbytes .GT. 0) THEN |
237 |
|
CALL MNC_DIM_UNLIM_SIZE(fname, unlim_sz, myThid) |
238 |
|
fsnu = (1.0 _d 0 + 1.0 _d 0 / DBLE(unlim_sz)) |
239 |
|
& * DBLE(nbytes) |
240 |
|
IF (fsnu .GT. mnc_max_fsize) THEN |
241 |
|
iseq = iseq + 1 |
242 |
|
indu = 1 |
243 |
|
mnc_cw_fgud(indfg) = 1 |
244 |
|
mnc_cw_fgis(indfg) = iseq |
245 |
|
fs_isdone = 1 |
246 |
|
GOTO 10 |
247 |
|
ENDIF |
248 |
|
ENDIF |
249 |
|
ENDIF |
250 |
|
#endif /* HAVE_STAT */ |
251 |
|
|
252 |
C Ensure that all the NetCDF dimensions are defined and create a |
C Ensure that all the NetCDF dimensions are defined and create a |
253 |
C local copy of them |
C local copy of them |
254 |
DO i = 1,9 |
DO i = 1,9 |
269 |
& mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid), myThid) |
& mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid), myThid) |
270 |
|
|
271 |
C Ensure that the variable is defined |
C Ensure that the variable is defined |
272 |
#ifdef mnc_rtype_D |
IF (stype(1:1) .EQ. 'D') |
273 |
CALL MNC_VAR_INIT_DBL(fname,mnc_cw_gname(igrid),vtype, myThid) |
& CALL MNC_VAR_INIT_DBL( |
274 |
#endif |
& fname, mnc_cw_gname(igrid), vtype, myThid) |
275 |
#ifdef mnc_rtype_R |
IF (stype(1:1) .EQ. 'R') |
276 |
CALL MNC_VAR_INIT_REAL(fname,mnc_cw_gname(igrid),vtype, myThid) |
& CALL MNC_VAR_INIT_REAL( |
277 |
#endif |
& fname, mnc_cw_gname(igrid), vtype, myThid) |
278 |
#ifdef mnc_rtype_I |
IF (stype(1:1) .EQ. 'I') |
279 |
CALL MNC_VAR_INIT_INT(fname,mnc_cw_gname(igrid),vtype, myThid) |
& CALL MNC_VAR_INIT_INT( |
280 |
#endif |
& fname, mnc_cw_gname(igrid), vtype, myThid) |
281 |
|
|
282 |
DO i = 1,mnc_fv_ids(indf,1) |
DO i = 1,mnc_fv_ids(indf,1) |
283 |
j = 2 + 3*(i - 1) |
j = 2 + 3*(i - 1) |
284 |
IF (mnc_v_names(mnc_fv_ids(indf,j)) .EQ. vtype) THEN |
IF (mnc_v_names(mnc_fv_ids(indf,j)) .EQ. vtype) THEN |
285 |
idv = mnc_fv_ids(indf,j+1) |
idv = mnc_fv_ids(indf,j+1) |
286 |
indvids = mnc_fd_ind(indf, mnc_f_info(indf, |
indvids = mnc_fd_ind(indf, mnc_f_info(indf, |
287 |
& (mnc_fv_ids(indf,j+2) + 1)) ) |
& (mnc_fv_ids(indf,j+2) + 1)) ) |
288 |
GOTO 10 |
GOTO 30 |
289 |
ENDIF |
ENDIF |
290 |
ENDDO |
ENDDO |
291 |
write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W_YY ERROR: ', |
write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ', |
292 |
& 'cannot reference variable ''', vtype, '''' |
& 'cannot reference variable ''', vtype, '''' |
293 |
CALL print_error(msgbuf, mythid) |
CALL print_error(msgbuf, mythid) |
294 |
STOP 'ABNORMAL END: package MNC' |
STOP 'ABNORMAL END: package MNC' |
295 |
10 CONTINUE |
30 CONTINUE |
296 |
|
|
297 |
C Check for bi,bj indicies |
C Check for bi,bj indicies |
298 |
bidim = mnc_cw_vbij(1,indv) |
bidim = mnc_cw_vbij(1,indv) |
319 |
ELSE |
ELSE |
320 |
p(i) = k * p(i-1) |
p(i) = k * p(i-1) |
321 |
ENDIF |
ENDIF |
322 |
|
IF (offsets(i) .GT. 0) THEN |
323 |
|
k = 1 |
324 |
|
p(i) = k * p(i-1) |
325 |
|
ENDIF |
326 |
ENDDO |
ENDDO |
327 |
|
|
328 |
C Set starting and ending indicies for the in-memory array and |
C Set starting and ending indicies for the in-memory array and |
360 |
s(bjdim) = lbj |
s(bjdim) = lbj |
361 |
e(bjdim) = lbj |
e(bjdim) = lbj |
362 |
ENDIF |
ENDIF |
363 |
CEH3 DO i = 1,9 |
|
364 |
CEH3 write(*,*) 'i,p(i),s(i),e(i) = ', i,p(i),s(i),e(i) |
C Check the offsets |
365 |
CEH3 ENDDO |
DO i = 1,9 |
366 |
|
IF (offsets(i) .GT. 0) THEN |
367 |
|
udo(i) = udo(i) + offsets(i) - 1 |
368 |
|
s(i) = 1 |
369 |
|
e(i) = 1 |
370 |
|
ENDIF |
371 |
|
ENDDO |
372 |
|
|
373 |
C Add the global attributes |
C Add the global attributes |
374 |
CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid) |
CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid) |
393 |
& vtype(nvf:nvl), ''' within file ''', |
& vtype(nvf:nvl), ''' within file ''', |
394 |
& fname(1:nfname), '''' |
& fname(1:nfname), '''' |
395 |
|
|
396 |
|
C DO i = 1,9 |
397 |
|
C write(*,*) 'i,p(i),s(i),e(i),udo(i),offsets(i) = ', |
398 |
|
C & i,p(i),s(i),e(i),udo(i),offsets(i) |
399 |
|
C ENDDO |
400 |
|
|
401 |
C Write the variable one vector at a time |
C Write the variable one vector at a time |
402 |
DO j7 = s(7),e(7) |
DO j7 = s(7),e(7) |
403 |
k7 = (j7 - 1)*p(6) |
k7 = (j7 - 1)*p(6) |
425 |
vcount(2) = 1 |
vcount(2) = 1 |
426 |
|
|
427 |
kr = 0 |
kr = 0 |
|
DO j1 = s(1),e(1) |
|
|
k1 = k2 + j1 |
|
|
kr = kr + 1 |
|
|
resh(kr) = var(k1) |
|
|
ENDDO |
|
|
|
|
428 |
vstart(1) = udo(1) + 1 |
vstart(1) = udo(1) + 1 |
429 |
vcount(1) = e(1) - s(1) + 1 |
vcount(1) = e(1) - s(1) + 1 |
430 |
|
|
431 |
#ifdef mnc_rtype_D |
IF (vcount(1) .GT. MNC_MAX_BUFF) THEN |
432 |
err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh) |
write(msgbuf,'(2a,I7,a)') 'MNC_MAX_BUFF is too small', |
433 |
#endif |
& '--please increase to at least ', |
434 |
#ifdef mnc_rtype_R |
& vcount(1), ' in ''MNC_SIZE.h''' |
435 |
err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh) |
CALL PRINT_ERROR(msgBuf , 1) |
436 |
#endif |
STOP 'ABNORMAL END: S/R MNC_CW_RX_W_OFFSET' |
437 |
#ifdef mnc_rtype_I |
ENDIF |
438 |
err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh) |
|
439 |
#endif |
IF (stype(1:1) .EQ. 'D') THEN |
440 |
|
DO j1 = s(1),e(1) |
441 |
|
k1 = k2 + j1 |
442 |
|
kr = kr + 1 |
443 |
|
resh_d(kr) = var(k1) |
444 |
|
ENDDO |
445 |
|
err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d) |
446 |
|
ENDIF |
447 |
|
IF (stype(1:1) .EQ. 'R') THEN |
448 |
|
DO j1 = s(1),e(1) |
449 |
|
k1 = k2 + j1 |
450 |
|
kr = kr + 1 |
451 |
|
resh_r(kr) = var(k1) |
452 |
|
ENDDO |
453 |
|
err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh_r) |
454 |
|
ENDIF |
455 |
|
IF (stype(1:1) .EQ. 'I') THEN |
456 |
|
DO j1 = s(1),e(1) |
457 |
|
k1 = k2 + j1 |
458 |
|
kr = kr + 1 |
459 |
|
resh_i(kr) = var(k1) |
460 |
|
ENDDO |
461 |
|
err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh_i) |
462 |
|
ENDIF |
463 |
|
|
464 |
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
465 |
|
|
473 |
C Sync the file |
C Sync the file |
474 |
err = NF_SYNC(fid) |
err = NF_SYNC(fid) |
475 |
write(msgbuf,'(3a)') 'sync for file ''', fname, |
write(msgbuf,'(3a)') 'sync for file ''', fname, |
476 |
& ''' in S/R MNC_CW_RX_W_YY' |
& ''' in S/R MNC_CW_RX_W' |
477 |
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
478 |
|
|
479 |
ENDDO |
ENDDO |
486 |
|
|
487 |
|
|
488 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
489 |
|
CBOP 0 |
490 |
|
C !ROUTINE: MNC_CW_RX_R_S |
491 |
|
|
492 |
|
C !INTERFACE: |
493 |
SUBROUTINE MNC_CW_RX_R_YY( |
SUBROUTINE MNC_CW_RX_R_S( |
494 |
|
I stype, |
495 |
I fbname, bi,bj, |
I fbname, bi,bj, |
496 |
I vtype, |
I vtype, |
|
I indu, |
|
497 |
I var, |
I var, |
498 |
I myThid ) |
I myThid ) |
499 |
|
|
500 |
|
C !DESCRIPTION: |
501 |
|
C A scalar version of MNC_CW_RX_R() for compilers that cannot |
502 |
|
C gracefully handle the conversion on their own. |
503 |
|
|
504 |
|
C !USES: |
505 |
implicit none |
implicit none |
506 |
|
|
507 |
|
C !INPUT PARAMETERS: |
508 |
|
integer myThid, bi,bj |
509 |
|
character*(*) stype, fbname, vtype |
510 |
|
__V var |
511 |
|
__V var_arr(1) |
512 |
|
CEOP |
513 |
|
var_arr(1) = var |
514 |
|
|
515 |
|
CALL MNC_CW_RX_R(stype,fbname,bi,bj,vtype, var_arr, myThid) |
516 |
|
|
517 |
|
RETURN |
518 |
|
END |
519 |
|
|
520 |
|
|
521 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
522 |
|
CBOP 0 |
523 |
|
C !ROUTINE: MNC_CW_RX_R |
524 |
|
|
525 |
|
C !INTERFACE: |
526 |
|
SUBROUTINE MNC_CW_RX_R( |
527 |
|
I stype, |
528 |
|
I fbname, bi,bj, |
529 |
|
I vtype, |
530 |
|
I var, |
531 |
|
I myThid ) |
532 |
|
|
533 |
|
C !DESCRIPTION: |
534 |
|
C This subroutine reads one variable from a file or a file group, |
535 |
|
C depending upon the tile indicies. |
536 |
|
|
537 |
|
C !USES: |
538 |
|
implicit none |
539 |
#include "netcdf.inc" |
#include "netcdf.inc" |
540 |
#include "mnc_common.h" |
#include "mnc_common.h" |
|
#include "EEPARAMS.h" |
|
541 |
#include "SIZE.h" |
#include "SIZE.h" |
542 |
|
#include "MNC_SIZE.h" |
543 |
|
#include "EEPARAMS.h" |
544 |
|
#include "PARAMS.h" |
545 |
|
#include "MNC_PARAMS.h" |
546 |
|
|
547 |
#define mnc_rtype_YY |
C !INPUT PARAMETERS: |
548 |
|
integer myThid, bi,bj |
549 |
C Arguments |
character*(*) stype, fbname, vtype |
|
integer myThid, bi,bj, indu |
|
|
character*(*) fbname, vtype |
|
550 |
__V var(*) |
__V var(*) |
551 |
|
CEOP |
552 |
|
|
553 |
C Functions |
C !LOCAL VARIABLES: |
554 |
integer IFNBLNK, ILNBLNK |
integer i,k, nvf,nvl, n1,n2, igrid, ntot, indu |
|
|
|
|
C Local Variables |
|
|
integer i,k, nvf,nvl, n1,n2, igrid, ntot |
|
555 |
integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv |
integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv |
556 |
integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr |
integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr |
557 |
integer ind_fv_ids, ind_vt, ierr, atype, alen |
integer ind_fv_ids, ind_vt, ierr, atype, alen |
558 |
integer f_sNx,f_sNy, ires |
integer f_sNx,f_sNy, npath |
559 |
integer p(9),s(9),e(9), vstart(9),vcount(9), udo(9) |
integer p(9),s(9),e(9), vstart(9),vcount(9), udo(9) |
560 |
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 |
561 |
character*(MAX_LEN_MBUF) msgbuf |
character*(MAX_LEN_MBUF) msgbuf |
562 |
character*(MNC_MAX_CHAR) fname |
character*(MNC_MAX_CHAR) fname |
563 |
|
character*(MNC_MAX_CHAR) path_fname |
564 |
|
integer indfg, fg1,fg2 |
565 |
|
REAL*8 resh_d( MNC_MAX_BUFF ) |
566 |
|
REAL*4 resh_r( MNC_MAX_BUFF ) |
567 |
|
INTEGER resh_i( MNC_MAX_BUFF ) |
568 |
|
|
569 |
C Temporary storage for the simultaneous type conversion and |
C Functions |
570 |
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 |
|
|
#ifdef mnc_rtype_I |
|
|
INTEGER resh( sNx + 2*OLx + sNy + 2*OLy ) |
|
|
#endif |
|
571 |
|
|
572 |
C Only do I/O if I am the master thread |
C Only do I/O if I am the master thread |
573 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
574 |
|
|
575 |
|
C Get the current index for the unlimited dimension from the file |
576 |
|
C group (or base) name |
577 |
|
fg1 = IFNBLNK(fbname) |
578 |
|
fg2 = ILNBLNK(fbname) |
579 |
|
CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid) |
580 |
|
IF (indfg .LT. 1) THEN |
581 |
|
write(msgbuf,'(3a)') |
582 |
|
& 'MNC_CW_RX_W ERROR: file group name ''', |
583 |
|
& fbname(fg1:fg2), ''' is not defined' |
584 |
|
CALL print_error(msgbuf, mythid) |
585 |
|
STOP 'ABNORMAL END: S/R MNC_CW_RX_W' |
586 |
|
ENDIF |
587 |
|
indu = mnc_cw_fgud(indfg) |
588 |
|
|
589 |
C Check that the Variable Type exists |
C Check that the Variable Type exists |
590 |
nvf = IFNBLNK(vtype) |
nvf = IFNBLNK(vtype) |
591 |
nvl = ILNBLNK(vtype) |
nvl = ILNBLNK(vtype) |
592 |
CALL MNC_GET_IND( MNC_MAX_ID, vtype, mnc_cw_vname, ind_vt, myThid) |
CALL MNC_GET_IND( MNC_MAX_ID, vtype, mnc_cw_vname, ind_vt, myThid) |
593 |
IF (ind_vt .LT. 1) THEN |
IF (ind_vt .LT. 1) THEN |
594 |
write(msgbuf,'(3a)') 'MNC_CW_RX_R_YY ERROR: vtype ''', |
write(msgbuf,'(3a)') 'MNC_CW_RX_R ERROR: vtype ''', |
595 |
& vtype(nvf:nvl), ''' is not defined' |
& vtype(nvf:nvl), ''' is not defined' |
596 |
CALL print_error(msgbuf, mythid) |
CALL print_error(msgbuf, mythid) |
597 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R' |
598 |
ENDIF |
ENDIF |
599 |
igrid = mnc_cw_vgind(ind_vt) |
igrid = mnc_cw_vgind(ind_vt) |
600 |
|
|
631 |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc' |
632 |
nfname = ntot+9 |
nfname = ntot+9 |
633 |
|
|
634 |
|
C Add the path to the file name |
635 |
|
IF (mnc_use_indir) THEN |
636 |
|
path_fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR) |
637 |
|
npath = ILNBLNK(mnc_indir_str) |
638 |
|
path_fname(1:npath) = mnc_indir_str(1:npath) |
639 |
|
path_fname((npath+1):(npath+nfname)) = fname(1:nfname) |
640 |
|
fname(1:MNC_MAX_CHAR) = path_fname(1:MNC_MAX_CHAR) |
641 |
|
nfname = npath + nfname |
642 |
|
ENDIF |
643 |
|
|
644 |
C Open the existing file |
C Open the existing file |
645 |
CALL MNC_FILE_TRY_READ( fname, ierr, indf, myThid) |
CALL MNC_FILE_TRY_READ( fname, ierr, indf, myThid) |
646 |
|
|
647 |
C Check that the variable (VType) is defined within the file |
C Check that the variable (VType) is defined within the file |
648 |
CALL MNC_GET_FVINDS( fname, vtype, indf, ind_fv_ids, myThid) |
CALL MNC_GET_FVINDS( fname, vtype, indf, ind_fv_ids, myThid) |
649 |
IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN |
IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN |
650 |
write(msgbuf,'(4a)') 'MNC_CW_RX_R_YY ERROR: vtype ''', |
write(msgbuf,'(4a)') 'MNC_CW_RX_R ERROR: vtype ''', |
651 |
& vtype(nvf:nvl), ''' is not defined within file ''', |
& vtype(nvf:nvl), ''' is not defined within file ''', |
652 |
& fname(1:nfname) |
& fname(1:nfname) |
653 |
CALL print_error(msgbuf, mythid) |
CALL print_error(msgbuf, mythid) |
654 |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
STOP 'ABNORMAL END: S/R MNC_CW_RX_R' |
655 |
ENDIF |
ENDIF |
656 |
fid = mnc_f_info(indf,2) |
fid = mnc_f_info(indf,2) |
657 |
idv = mnc_fv_ids(indf,ind_fv_ids+1) |
idv = mnc_fv_ids(indf,ind_fv_ids+1) |
664 |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
665 |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx) |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx) |
666 |
CALL MNC_HANDLE_ERR(err, |
CALL MNC_HANDLE_ERR(err, |
667 |
& 'reading attribute ''sNx'' in S/R MNC_CW_RX_R_YY', |
& 'reading attribute ''sNx'' in S/R MNC_CW_RX_R', |
668 |
& myThid) |
& myThid) |
669 |
ENDIF |
ENDIF |
670 |
err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen) |
err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen) |
671 |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN |
672 |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy) |
err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy) |
673 |
CALL MNC_HANDLE_ERR(err, |
CALL MNC_HANDLE_ERR(err, |
674 |
& 'reading attribute ''sNy'' in S/R MNC_CW_RX_R_YY', |
& 'reading attribute ''sNy'' in S/R MNC_CW_RX_R', |
675 |
& myThid) |
& myThid) |
676 |
ENDIF |
ENDIF |
677 |
IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN |
IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN |
678 |
write(msgbuf,'(5a)') 'MNC_CW_RX_R_YY WARNING: the ', |
write(msgbuf,'(5a)') 'MNC_CW_RX_R WARNING: the ', |
679 |
& 'attributes ''sNx'' and ''sNy'' within the file ''', |
& 'attributes ''sNx'' and ''sNy'' within the file ''', |
680 |
& fname(1:nfname), ''' do not exist or do not match ', |
& fname(1:nfname), ''' do not exist or do not match ', |
681 |
& 'the current sizes within the model' |
& 'the current sizes within the model' |
688 |
C CALL MNC_CHK_VTYP_R_NCVAR( ind_vt, |
C CALL MNC_CHK_VTYP_R_NCVAR( ind_vt, |
689 |
C & indf, ind_fv_ids, indu, ires) |
C & indf, ind_fv_ids, indu, ires) |
690 |
C IF (ires .LT. 0) THEN |
C IF (ires .LT. 0) THEN |
691 |
C write(msgbuf,'(7a)') 'MNC_CW_RX_R_YY WARNING: the sizes ', |
C write(msgbuf,'(7a)') 'MNC_CW_RX_R WARNING: the sizes ', |
692 |
C & 'of the in-program variable ''', vtype(nvf:nvl), |
C & 'of the in-program variable ''', vtype(nvf:nvl), |
693 |
C & ''' and the corresponding variable within file ''', |
C & ''' and the corresponding variable within file ''', |
694 |
C & fname(1:nfname), ''' are not compatible -- please ', |
C & fname(1:nfname), ''' are not compatible -- please ', |
695 |
C & 'check the sizes' |
C & 'check the sizes' |
696 |
C CALL print_error(msgbuf, mythid) |
C CALL print_error(msgbuf, mythid) |
697 |
C STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY' |
C STOP 'ABNORMAL END: S/R MNC_CW_RX_R' |
698 |
C ENDIF |
C ENDIF |
699 |
|
|
700 |
C Check for bi,bj indicies |
C Check for bi,bj indicies |
795 |
vstart(2) = udo(2) + j2 - s(2) + 1 |
vstart(2) = udo(2) + j2 - s(2) + 1 |
796 |
vcount(2) = 1 |
vcount(2) = 1 |
797 |
|
|
798 |
|
kr = 0 |
799 |
vstart(1) = udo(1) + 1 |
vstart(1) = udo(1) + 1 |
800 |
vcount(1) = e(1) - s(1) + 1 |
vcount(1) = e(1) - s(1) + 1 |
|
|
|
|
#ifdef mnc_rtype_D |
|
|
err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh) |
|
|
#endif |
|
|
#ifdef mnc_rtype_R |
|
|
err = NF_GET_VARA_REAL(fid, idv, vstart, vcount, resh) |
|
|
#endif |
|
|
#ifdef mnc_rtype_I |
|
|
err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh) |
|
|
#endif |
|
801 |
|
|
802 |
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
IF (vcount(1) .GT. MNC_MAX_BUFF) THEN |
803 |
|
write(msgbuf,'(2a,I7,a)') 'MNC_MAX_BUFF is too small', |
804 |
|
& '--please increase to at least ', |
805 |
|
& vcount(1), ' in ''MNC_SIZE.h''' |
806 |
|
CALL PRINT_ERROR(msgBuf , 1) |
807 |
|
STOP 'ABNORMAL END: S/R MNC_CW_RX_R_OFFSET' |
808 |
|
ENDIF |
809 |
|
|
810 |
|
IF (stype(1:1) .EQ. 'D') THEN |
811 |
|
err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d) |
812 |
|
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
813 |
|
DO j1 = s(1),e(1) |
814 |
|
k1 = k2 + j1 |
815 |
|
kr = kr + 1 |
816 |
|
var(k1) = resh_d(kr) |
817 |
|
ENDDO |
818 |
|
ENDIF |
819 |
|
IF (stype(1:1) .EQ. 'R') THEN |
820 |
|
err = NF_GET_VARA_REAL(fid, idv, vstart, vcount, resh_r) |
821 |
|
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
822 |
|
DO j1 = s(1),e(1) |
823 |
|
k1 = k2 + j1 |
824 |
|
kr = kr + 1 |
825 |
|
var(k1) = resh_r(kr) |
826 |
|
ENDDO |
827 |
|
ENDIF |
828 |
|
IF (stype(1:1) .EQ. 'I') THEN |
829 |
|
err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh_i) |
830 |
|
CALL MNC_HANDLE_ERR(err, msgbuf, myThid) |
831 |
|
DO j1 = s(1),e(1) |
832 |
|
k1 = k2 + j1 |
833 |
|
kr = kr + 1 |
834 |
|
var(k1) = resh_i(kr) |
835 |
|
ENDDO |
836 |
|
ENDIF |
837 |
|
|
|
kr = 0 |
|
|
DO j1 = s(1),e(1) |
|
|
k1 = k2 + j1 |
|
|
kr = kr + 1 |
|
|
var(k1) = resh(kr) |
|
|
ENDDO |
|
838 |
|
|
839 |
|
|
840 |
ENDDO |
ENDDO |