/[MITgcm]/MITgcm/pkg/mnc/mnc_cw_readwrite.template
ViewVC logotype

Diff of /MITgcm/pkg/mnc/mnc_cw_readwrite.template

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

revision 1.13 by edhill, Wed Mar 24 03:38:50 2004 UTC revision 1.33 by edhill, Mon Sep 19 02:24:40 2005 UTC
# Line 4  C $Name$ Line 4  C $Name$
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,
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
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        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"
95  #include "SIZE.h"  #include "SIZE.h"
96    #include "MNC_BUFF.h"
97  #include "EEPARAMS.h"  #include "EEPARAMS.h"
98  #include "PARAMS.h"  #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, uniq_fnum, 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        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        character*(MNC_MAX_CHAR) path_fname
120          character*(MNC_MAX_CHAR) tmpnm
121  C     Temporary storage for the simultaneous type conversion and        REAL*8  resh_d( MNC_MAX_BUFF )
122  C     re-shaping before passing to NetCDF        REAL*4  resh_r( MNC_MAX_BUFF )
123  #ifdef  mnc_rtype_D        INTEGER resh_i( MNC_MAX_BUFF )
124        REAL*8  resh( sNx + 2*OLx + sNy + 2*OLy )  #ifdef HAVE_STAT
125  #endif        integer ntotenc, ncenc, nbytes, fs_isdone
126  #ifdef  mnc_rtype_R        character*(200) cenc
127        REAL*4  resh( sNx + 2*OLx + sNy + 2*OLy )        integer ienc(200)
128  #endif        REAL*8  fsnu
 #ifdef  mnc_rtype_I  
       INTEGER resh( sNx + 2*OLx + sNy + 2*OLy )  
129  #endif  #endif
130    
131    C     Functions
132          integer IFNBLNK, ILNBLNK
133    
134  C     Only do I/O if I am the master thread  C     Only do I/O if I am the master thread
135        _BEGIN_MASTER( myThid )        _BEGIN_MASTER( myThid )
136    
# Line 62  C     group (or base) name Line 141  C     group (or base) name
141        CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid)        CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid)
142        IF (indfg .LT. 1) THEN        IF (indfg .LT. 1) THEN
143          write(msgbuf,'(3a)')          write(msgbuf,'(3a)')
144       &       'MNC_CW_RX_W_YY ERROR: file group name ''',       &       'MNC_CW_RX_W ERROR: file group name ''',
145       &       fbname(fg1:fg2), ''' is not defined'       &       fbname(fg1:fg2), ''' is not defined'
146          CALL print_error(msgbuf, mythid)          CALL print_error(msgbuf, mythid)
147          STOP 'ABNORMAL END: S/R MNC_CW_RX_W_YY'          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
148        ENDIF        ENDIF
149        indu = mnc_cw_fgud(indfg)        indu = mnc_cw_fgud(indfg)
150          iseq = mnc_cw_fgis(indfg)
151    C     write(*,*) 'indu,iseq = ', indu, iseq
152    
153  C     Check that the Variable Type exists  C     Check that the Variable Type exists
154        nvf = IFNBLNK(vtype)        nvf = IFNBLNK(vtype)
155        nvl = ILNBLNK(vtype)        nvl = ILNBLNK(vtype)
156        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)
157        IF (indv .LT. 1) THEN        IF (indv .LT. 1) THEN
158          write(msgbuf,'(3a)') 'MNC_CW_RX_W_YY ERROR: vtype ''',          write(msgbuf,'(3a)') 'MNC_CW_RX_W ERROR: vtype ''',
159       &       vtype(nvf:nvl), ''' is not defined'       &       vtype(nvf:nvl), ''' is not defined'
160          CALL print_error(msgbuf, mythid)          CALL print_error(msgbuf, mythid)
161          STOP 'ABNORMAL END: S/R MNC_CW_RX_W_YY'          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
162        ENDIF        ENDIF
163        igrid = mnc_cw_vgind(indv)        igrid = mnc_cw_vgind(indv)
164    
# Line 98  C     Set the bi,bj indicies Line 179  C     Set the bi,bj indicies
179        DO lbj = bjs,bje        DO lbj = bjs,bje
180          DO lbi = bis,bie          DO lbi = bis,bie
181    
182    #ifdef HAVE_STAT
183              fs_isdone = 0
184    #endif
185     10       CONTINUE
186    
187  C         Create the file name  C         Create the file name
188            CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid)            CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid)
189            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
190            n1 = IFNBLNK(fbname)            n1 = IFNBLNK(fbname)
191            n2 = ILNBLNK(fbname)            n2 = ILNBLNK(fbname)
192    
193    #ifdef MNC_WRITE_OLDNAMES
194    
195            ntot = n2 - n1 + 1            ntot = n2 - n1 + 1
196            fname(1:ntot) = fbname(n1:n2)            fname(1:ntot) = fbname(n1:n2)
197            ntot = ntot + 1            ntot = ntot + 1
198            fname(ntot:ntot) = '.'            fname(ntot:ntot) = '.'
199            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'            IF ( mnc_use_name_ni0 ) THEN
200            nfname = ntot+9              write(fname((ntot+1):(ntot+17)),'(i10.10,a1,i6.6)')
201         &           nIter0,'.',uniq_tnum
202                write(fname((ntot+18):(ntot+25)),'(a1,i4.4,a3)')
203         &           '.', iseq, '.nc'
204                nfname = ntot + 25
205              ELSE
206                write(fname((ntot+1):(ntot+14)),'(i4.4,a1,i6.6,a3)')
207         &           iseq,'.',uniq_tnum, '.nc'
208                nfname = ntot + 14
209              ENDIF
210    
211    #else
212    
213              CALL MNC_PSNCM(tmpnm, uniq_tnum, MNC_DEF_TMNC)
214              k = ILNBLNK(tmpnm)
215              IF ( mnc_cw_cit(1,mnc_cw_fgci(indfg)) .GT. -1 ) THEN
216                write(fname,'(a,a1,i10.10,a2,a,a3)') fbname(n1:n2),
217         &           '.', mnc_cw_cit(2,mnc_cw_fgci(indfg)),
218         &           '.t',tmpnm(1:k),'.nc'
219              ELSEIF ( mnc_cw_cit(1,mnc_cw_fgci(indfg)) .EQ. -1 ) THEN
220    C           Leave off the myIter value entirely
221                write(fname,'(a,a2,a,a3)') fbname(n1:n2), '.t',
222         &           tmpnm(1:k),'.nc'
223              ELSE
224    C           We have an error--bad flag value
225                write(msgbuf,'(4a)')
226         &           'MNC_CW_RX_W ERROR: bad mnc_cw_cit(1,...) ',
227         &           'flag value for base name ''', fbname(fg1:fg2),
228         &           ''''
229                CALL print_error(msgbuf, mythid)
230                STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
231              ENDIF
232              nfname = ILNBLNK(fname)
233    
234    #endif
235    
236  C         Add the path to the file name  C         Add the path to the file name
237            IF (mnc_use_outdir) THEN            IF (mnc_use_outdir) THEN
# Line 121  C         Add the path to the file name Line 244  C         Add the path to the file name
244            ENDIF            ENDIF
245    
246  C         Append to an existing or create a new file  C         Append to an existing or create a new file
247            CALL MNC_CW_FILE_AORC(fname, indf, myThid)            CALL MNC_CW_FILE_AORC(fname,indf, lbi,lbj,uniq_tnum, myThid)
248            fid = mnc_f_info(indf,2)            fid = mnc_f_info(indf,2)
249    
250    #ifdef HAVE_STAT
251              IF ((mnc_cw_fgig(indfg) .EQ. 1)
252         &         .AND. (fs_isdone .EQ. 0)) THEN
253    C           Decide whether to append to the existing or create a new
254    C           file based on the byte count per unlimited dimension
255                ncenc = 70
256                cenc(1:26)  = 'abcdefghijklmnopqrstuvwxyz'
257                cenc(27:52) = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
258                cenc(53:70) = '0123456789_.,+-=/~'
259                k = nfname
260                IF (k .GT. 200)  k = 200
261                ntotenc = 0
262                DO i = 1,k
263                  DO j = 1,ncenc
264                    IF (fname(i:i) .EQ. cenc(j:j)) THEN
265                      ntotenc = ntotenc + 1
266                      ienc(ntotenc) = j
267                      GOTO 20
268                    ENDIF
269                  ENDDO
270     20           CONTINUE
271                ENDDO
272                CALL mncfsize(ntotenc, ienc, nbytes)
273                IF (nbytes .GT. 0) THEN
274                  CALL MNC_DIM_UNLIM_SIZE(fname, unlim_sz, myThid)
275                  fsnu = (1.0 _d 0 + 1.0 _d 0 / DBLE(unlim_sz))
276         &             * DBLE(nbytes)
277                  IF (fsnu .GT. mnc_max_fsize) THEN
278    C               Delete the now-full fname from the lookup tables since
279    C               we are all done writing to it.
280                    CALL MNC_FILE_CLOSE(fname, myThid)
281                    indu = 1
282                    mnc_cw_fgud(indfg) = 1
283    
284    #ifdef MNC_WRITE_OLDNAMES
285                    iseq = iseq + 1
286                    mnc_cw_fgis(indfg) = iseq
287    #else
288                    IF (mnc_cw_cit(1,mnc_cw_fgci(indfg)) .LT. 0) THEN
289                      write(msgbuf,'(5a)')
290         &            'MNC_CW_RX_W ERROR: output file for base name ''',
291         &            fbname(fg1:fg2), ''' is about to exceed the max ',
292         &            'file size and is NOT ALLOWED an iteration value ',
293         &            'within its file name'
294                      CALL print_error(msgbuf, mythid)
295                      STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
296                    ELSEIF (mnc_cw_cit(3,mnc_cw_fgci(indfg)) .LT. 0) THEN
297                      write(msgbuf,'(5a)')
298         &            'MNC_CW_RX_W ERROR: output file for base name ''',
299         &            fbname(fg1:fg2), ''' is about to exceed the max ',
300         &            'file size and no next-iter has been specified--',
301         &            'please see the MNC CITER functions'
302                      CALL print_error(msgbuf, mythid)
303                      STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
304                    ENDIF
305                    mnc_cw_cit(2,mnc_cw_fgci(indfg))
306         &               = mnc_cw_cit(3,mnc_cw_fgci(indfg))
307                    mnc_cw_cit(3,mnc_cw_fgci(indfg)) = -1
308    #endif
309                    fs_isdone = 1
310                    GOTO 10
311    
312                  ENDIF
313                ENDIF
314              ENDIF
315    #endif  /*  HAVE_STAT  */
316    
317  C         Ensure that all the NetCDF dimensions are defined and create a  C         Ensure that all the NetCDF dimensions are defined and create a
318  C         local copy of them  C         local copy of them
319            DO i = 1,9            DO i = 1,9
# Line 135  C         local copy of them Line 325  C         local copy of them
325              ELSE              ELSE
326                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
327              ENDIF              ENDIF
328              CALL MNC_DIM_INIT(fname,  
329       &           mnc_cw_dn(i,igrid), dimnc(i), myThid)  C           Add the coordinate variables
330                CALL MNC_DIM_INIT_ALL_CV(fname,
331         &           mnc_cw_dn(i,igrid), dimnc(i), 'Y', lbi,lbj, myThid)
332    
333            ENDDO            ENDDO
334    
335  C         Ensure that the "grid" is defined  C         Ensure that the "grid" is defined
# Line 144  C         Ensure that the "grid" is defi Line 337  C         Ensure that the "grid" is defi
337       &        mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid), myThid)       &        mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid), myThid)
338    
339  C         Ensure that the variable is defined  C         Ensure that the variable is defined
340  #ifdef  mnc_rtype_D            IF (stype(1:1) .EQ. 'D')
341        CALL MNC_VAR_INIT_DBL(fname,mnc_cw_gname(igrid),vtype, myThid)       &         CALL MNC_VAR_INIT_DBL(
342  #endif       &         fname, mnc_cw_gname(igrid), vtype, myThid)
343  #ifdef  mnc_rtype_R            IF (stype(1:1) .EQ. 'R')
344        CALL MNC_VAR_INIT_REAL(fname,mnc_cw_gname(igrid),vtype, myThid)       &         CALL MNC_VAR_INIT_REAL(
345  #endif       &         fname, mnc_cw_gname(igrid), vtype, myThid)
346  #ifdef  mnc_rtype_I            IF (stype(1:1) .EQ. 'I')
347        CALL MNC_VAR_INIT_INT(fname,mnc_cw_gname(igrid),vtype, myThid)       &         CALL MNC_VAR_INIT_INT(
348  #endif       &         fname, mnc_cw_gname(igrid), vtype, myThid)
349    
350            DO i = 1,mnc_fv_ids(indf,1)            DO i = 1,mnc_fv_ids(indf,1)
351              j = 2 + 3*(i - 1)              j = 2 + 3*(i - 1)
352              IF (mnc_v_names(mnc_fv_ids(indf,j)) .EQ. vtype) THEN              IF (mnc_v_names(mnc_fv_ids(indf,j)) .EQ. vtype) THEN
353                idv = mnc_fv_ids(indf,j+1)                idv = mnc_fv_ids(indf,j+1)
354                indvids = mnc_fd_ind(indf, mnc_f_info(indf,                indvids = mnc_fd_ind(indf, mnc_f_info(indf,
355       &             (mnc_fv_ids(indf,j+2) + 1)) )       &             (mnc_fv_ids(indf,j+2) + 1)) )
356                GOTO 10                GOTO 30
357              ENDIF              ENDIF
358            ENDDO            ENDDO
359            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W_YY ERROR: ',            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ',
360       &         'cannot reference variable ''', vtype, ''''       &         'cannot reference variable ''', vtype, ''''
361            CALL print_error(msgbuf, mythid)            CALL print_error(msgbuf, mythid)
362            STOP 'ABNORMAL END: package MNC'            STOP 'ABNORMAL END: package MNC'
363   10       CONTINUE   30       CONTINUE
364    
365  C         Check for bi,bj indicies  C         Check for bi,bj indicies
366            bidim = mnc_cw_vbij(1,indv)            bidim = mnc_cw_vbij(1,indv)
# Line 193  C         Set the dimensions for the in- Line 387  C         Set the dimensions for the in-
387              ELSE              ELSE
388                p(i) = k * p(i-1)                p(i) = k * p(i-1)
389              ENDIF              ENDIF
390                IF (offsets(i) .GT. 0) THEN
391                  k = 1
392                  p(i) = k * p(i-1)
393                ENDIF
394            ENDDO            ENDDO
395    
396  C         Set starting and ending indicies for the in-memory array and  C         Set starting and ending indicies for the in-memory array and
# Line 230  C               Use the current unlimite Line 428  C               Use the current unlimite
428              s(bjdim) = lbj              s(bjdim) = lbj
429              e(bjdim) = lbj              e(bjdim) = lbj
430            ENDIF            ENDIF
431  CEH3      DO i = 1,9            
432  CEH3        write(*,*) 'i,p(i),s(i),e(i) = ', i,p(i),s(i),e(i)  C         Check the offsets
433  CEH3      ENDDO            DO i = 1,9
434                IF (offsets(i) .GT. 0) THEN
435  C         Add the global attributes                udo(i) = udo(i) + offsets(i) - 1
436            CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid)                s(i) = 1
437                  e(i) = 1
438                ENDIF
439              ENDDO
440    
441  C         Add the per-variable attributes  C         Add the per-variable attributes
442            DO i = 1,mnc_cw_vnat(1,indv)            DO i = 1,mnc_cw_vnat(1,indv)
# Line 257  C         Add the per-variable attribute Line 458  C         Add the per-variable attribute
458       &         vtype(nvf:nvl), ''' within file ''',       &         vtype(nvf:nvl), ''' within file ''',
459       &         fname(1:nfname), ''''       &         fname(1:nfname), ''''
460    
461    C         DO i = 1,9
462    C         write(*,*) 'i,p(i),s(i),e(i),udo(i),offsets(i) = ',
463    C         &        i,p(i),s(i),e(i),udo(i),offsets(i)
464    C         ENDDO
465    
466  C         Write the variable one vector at a time  C         Write the variable one vector at a time
467            DO j7 = s(7),e(7)            DO j7 = s(7),e(7)
468              k7 = (j7 - 1)*p(6)              k7 = (j7 - 1)*p(6)
# Line 284  C         Write the variable one vector Line 490  C         Write the variable one vector
490                        vcount(2) = 1                        vcount(2) = 1
491    
492        kr = 0        kr = 0
       DO j1 = s(1),e(1)  
         k1 = k2 + j1  
         kr = kr + 1  
         resh(kr) = var(k1)  
       ENDDO  
         
493        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
494        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
495    
496  #ifdef  mnc_rtype_D        IF (vcount(1) .GT. MNC_MAX_BUFF) THEN
497        err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh)          write(msgbuf,'(2a,I7,a)') 'MNC_MAX_BUFF is too small',
498  #endif       &       '--please increase to at least ',
499  #ifdef  mnc_rtype_R       &       vcount(1), ' in ''MNC_BUFF.h'''
500        err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh)          CALL PRINT_ERROR(msgBuf , 1)
501  #endif          STOP 'ABNORMAL END: S/R MNC_CW_RX_W_OFFSET'
502  #ifdef  mnc_rtype_I        ENDIF
503        err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh)  
504  #endif        IF (stype(1:1) .EQ. 'D') THEN
505            DO j1 = s(1),e(1)
506              k1 = k2 + j1
507              kr = kr + 1
508              resh_d(kr) = var(k1)
509            ENDDO
510            err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)
511          ENDIF
512          IF (stype(1:1) .EQ. 'R') THEN
513            DO j1 = s(1),e(1)
514              k1 = k2 + j1
515              kr = kr + 1
516              resh_r(kr) = var(k1)
517            ENDDO
518            err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh_r)
519          ENDIF
520          IF (stype(1:1) .EQ. 'I') THEN
521            DO j1 = s(1),e(1)
522              k1 = k2 + j1
523              kr = kr + 1
524              resh_i(kr) = MNC2I( var(k1) )
525            ENDDO
526            err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh_i)
527          ENDIF
528    
529        CALL MNC_HANDLE_ERR(err, msgbuf, myThid)        CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
530    
# Line 315  C         Write the variable one vector Line 538  C         Write the variable one vector
538  C         Sync the file  C         Sync the file
539            err = NF_SYNC(fid)            err = NF_SYNC(fid)
540            write(msgbuf,'(3a)') 'sync for file ''', fname,            write(msgbuf,'(3a)') 'sync for file ''', fname,
541       &         ''' in S/R MNC_CW_RX_W_YY'       &         ''' in S/R MNC_CW_RX_W'
542            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
543    
544          ENDDO          ENDDO
# Line 328  C         Sync the file Line 551  C         Sync the file
551                
552    
553  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
554    CBOP 0
555    C !ROUTINE: MNC_CW_RX_R_S
556    
557    C !INTERFACE:
558        SUBROUTINE MNC_CW_RX_R_YY(        SUBROUTINE MNC_CW_RX_R_S(
559         I     stype,
560       I     fbname, bi,bj,       I     fbname, bi,bj,
561       I     vtype,       I     vtype,
562       I     var,       I     var,
563       I     myThid )       I     myThid )
564    
565    C     !DESCRIPTION:
566    C     A scalar version of MNC_CW_RX_R() for compilers that cannot
567    C     gracefully handle the conversion on their own.
568          
569    C     !USES:
570        implicit none        implicit none
571    
572    C     !INPUT PARAMETERS:
573          integer myThid, bi,bj
574          character*(*) stype, fbname, vtype
575          __V var
576          __V var_arr(1)
577    CEOP
578          var_arr(1) = var
579    
580          CALL MNC_CW_RX_R(stype,fbname,bi,bj,vtype, var_arr, myThid)
581    
582          RETURN
583          END
584    
585    
586    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
587    CBOP 0
588    C !ROUTINE: MNC_CW_RX_R
589    
590    C !INTERFACE:
591          SUBROUTINE MNC_CW_RX_R(
592         I     stype,
593         I     fbname, bi,bj,
594         I     vtype,
595         I     var,
596         I     myThid )
597    
598    C     !DESCRIPTION:
599    C     This subroutine reads one variable from a file or a file group,
600    C     depending upon the tile indicies.
601          
602    C     !USES:
603          implicit none
604  #include "netcdf.inc"  #include "netcdf.inc"
605  #include "mnc_common.h"  #include "mnc_common.h"
606  #include "SIZE.h"  #include "SIZE.h"
607    #include "MNC_BUFF.h"
608  #include "EEPARAMS.h"  #include "EEPARAMS.h"
609  #include "PARAMS.h"  #include "PARAMS.h"
610    #include "MNC_PARAMS.h"
611    
612  #define mnc_rtype_YY  C     !INPUT PARAMETERS:
613          integer myThid, bi,bj
614  C     Arguments        character*(*) stype, fbname, vtype
       integer myThid, bi,bj, indu  
       character*(*) fbname, vtype  
615        __V var(*)        __V var(*)
616    CEOP
617    
618  C     Functions  C     !LOCAL VARIABLES:
619        integer IFNBLNK, ILNBLNK        integer i,k, nvf,nvl, n1,n2, igrid, ntot, indu
620          integer bis,bie, bjs,bje, uniq_tnum,uniq_fnum, nfname, fid, idv
621  C     Local Variables        integer ndim, err, lbi,lbj, bidim,bjdim, unlim_sz, kr
622        integer i,k, nvf,nvl, n1,n2, igrid, ntot        integer ind_vt, npath, unlid, f_or_t, ixoff,iyoff
623        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv  C     integer f_sNx,f_sNy, alen, atype, ind_fv_ids, ierr, indf
       integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr  
       integer ind_fv_ids, ind_vt, ierr, atype, alen  
       integer f_sNx,f_sNy, npath  
624        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)
625        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
626        character*(MAX_LEN_MBUF) msgbuf        character*(MAX_LEN_MBUF) msgbuf
627        character*(MNC_MAX_CHAR) fname        character*(MNC_MAX_CHAR) fname
628          character*(MNC_MAX_CHAR) fname_zs
629          character*(MNC_MAX_CHAR) tmpnm
630        character*(MNC_MAX_CHAR) path_fname        character*(MNC_MAX_CHAR) path_fname
631        integer indfg, fg1,fg2        integer indfg, fg1,fg2
632          REAL*8  resh_d( MNC_MAX_BUFF )
633          REAL*4  resh_r( MNC_MAX_BUFF )
634          INTEGER resh_i( MNC_MAX_BUFF )
635    
636  C     Temporary storage for the simultaneous type conversion and  C     Functions
637  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  
638    
639  C     Only do I/O if I am the master thread  C     Only do I/O if I am the master thread
640        _BEGIN_MASTER( myThid )        _BEGIN_MASTER( myThid )
# Line 389  C     group (or base) name Line 646  C     group (or base) name
646        CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid)        CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid)
647        IF (indfg .LT. 1) THEN        IF (indfg .LT. 1) THEN
648          write(msgbuf,'(3a)')          write(msgbuf,'(3a)')
649       &       'MNC_CW_RX_W_YY ERROR: file group name ''',       &       'MNC_CW_RX_W ERROR: file group name ''',
650       &       fbname(fg1:fg2), ''' is not defined'       &       fbname(fg1:fg2), ''' is not defined'
651          CALL print_error(msgbuf, mythid)          CALL print_error(msgbuf, mythid)
652          STOP 'ABNORMAL END: S/R MNC_CW_RX_W_YY'          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
653        ENDIF        ENDIF
654        indu = mnc_cw_fgud(indfg)        indu = mnc_cw_fgud(indfg)
655    
# Line 401  C     Check that the Variable Type exist Line 658  C     Check that the Variable Type exist
658        nvl = ILNBLNK(vtype)        nvl = ILNBLNK(vtype)
659        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)
660        IF (ind_vt .LT. 1) THEN        IF (ind_vt .LT. 1) THEN
661          write(msgbuf,'(3a)') 'MNC_CW_RX_R_YY ERROR: vtype ''',          write(msgbuf,'(3a)') 'MNC_CW_RX_R ERROR: vtype ''',
662       &       vtype(nvf:nvl), ''' is not defined'       &       vtype(nvf:nvl), ''' is not defined'
663          CALL print_error(msgbuf, mythid)          CALL print_error(msgbuf, mythid)
664          STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY'          STOP 'ABNORMAL END: S/R MNC_CW_RX_R'
665        ENDIF        ENDIF
666        igrid = mnc_cw_vgind(ind_vt)        igrid = mnc_cw_vgind(ind_vt)
667    
# Line 432  C     Set the bi,bj indicies Line 689  C     Set the bi,bj indicies
689  C         Create the file name  C         Create the file name
690            CALL MNC_CW_GET_TILE_NUM( lbi,lbj, uniq_tnum, myThid)            CALL MNC_CW_GET_TILE_NUM( lbi,lbj, uniq_tnum, myThid)
691            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
692    
693    #ifdef MNC_READ_OLDNAMES
694    
695            n1 = IFNBLNK(fbname)            n1 = IFNBLNK(fbname)
696            n2 = ILNBLNK(fbname)            n2 = ILNBLNK(fbname)
697            ntot = n2 - n1 + 1            ntot = n2 - n1 + 1
# Line 451  C         Add the path to the file name Line 711  C         Add the path to the file name
711              nfname = npath + nfname              nfname = npath + nfname
712            ENDIF            ENDIF
713    
714  C         Open the existing file            WRITE(fname_zs,'(2a,i4.4,a1,i6.6,a3)')
715            CALL MNC_FILE_TRY_READ( fname, ierr, indf, myThid)       &         mnc_indir_str(1:npath), fbname(n1:n2),
716         &         0, '.', uniq_tnum, '.nc'
717    
718    C         The steps are:
719    C         (1) open the file in a READ-ONLY mode,
720    C         (2) get the var id for the current variable,
721    C         (3) read the data, and then
722    C         (4) close the file--theres no need to keep it open!
723    
724              write(msgbuf,'(4a)') 'MNC_CW_RX_R: cannot open',
725         &         ' file ''', fname(1:nfname), ''' in read-only mode'
726              err = NF_OPEN(fname, NF_NOWRITE, fid)
727              IF ( err .NE. NF_NOERR ) THEN
728    C           If the initial open fails, try again using a name with a
729    C           zero sequence number inserted
730                err = NF_OPEN(fname_zs, NF_NOWRITE, fid)
731              ENDIF
732              CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
733    
734  C         Check that the variable (VType) is defined within the file            write(msgbuf,'(5a)')
735            CALL MNC_GET_FVINDS( fname, vtype, indf, ind_fv_ids, myThid)       &         'MNC_CW_RX_R: cannot get id for variable ''',
736            IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN       &         vtype(nvf:nvl), '''in file ''', fname(1:nfname), ''''
737              write(msgbuf,'(4a)') 'MNC_CW_RX_R_YY ERROR: vtype ''',            err = NF_INQ_VARID(fid, vtype, idv)
738       &           vtype(nvf:nvl), ''' is not defined within file ''',            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
739       &           fname(1:nfname)            f_or_t = 0
740              CALL print_error(msgbuf, mythid)  
741              STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY'  #else
742    
743    C         The sequence for PER-FACE and PER-TILE is:
744    C         (1) check whether a PER-FACE file exists
745    C         .   (a) if only one face is used for the entire domain,
746    C         .       then omit the face index from the file name
747    C         .   (b) if the PER-FACE file exists and is somehow faulty,
748    C         .       then we die with an error message
749    C         (2) if no PER-FACE file exists, then use a PER-TILE file
750    
751    C         Create the PER-FACE file name
752              n1 = IFNBLNK(fbname)
753              n2 = ILNBLNK(fbname)
754    C         Add an iteraton count to the file name if its requested
755              IF (mnc_cw_cit(1,mnc_cw_fgci(indfg)) .LT. 0) THEN
756                WRITE(fname,'(a,a1)') fbname(n1:n2), '.'
757              ELSE
758                WRITE(fname,'(a,a1,i10.10,a1)') fbname(n1:n2), '.',
759         &            mnc_cw_cit(2,mnc_cw_fgci(indfg)), '.'
760            ENDIF            ENDIF
761            fid = mnc_f_info(indf,2)            ntot = ILNBLNK(fname)
762            idv = mnc_fv_ids(indf,ind_fv_ids+1)            path_fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
763              npath = ILNBLNK(mnc_indir_str)
764    C         Add the face index
765              CALL MNC_CW_GET_FACE_NUM( lbi,lbj, uniq_fnum, myThid)
766              IF ( uniq_fnum .EQ. -1 ) THEN
767    C           There is only one face
768                WRITE(path_fname,'(2a,a2)')
769         &           mnc_indir_str(1:npath), fname(1:ntot), 'nc'
770              ELSE
771                CALL MNC_PSNCM(tmpnm, uniq_fnum, MNC_DEF_FMNC)
772                k = ILNBLNK(tmpnm)
773                WRITE(path_fname,'(2a,a1,a,a3)')
774         &           mnc_indir_str(1:npath), fname(1:ntot), 'f',
775         &           tmpnm(1:k), '.nc'
776              ENDIF
777    
778    C         Try to open the PER-FACE file
779    C         WRITE(*,*) 'trying: "', path_fname, '"'
780              err = NF_OPEN(path_fname, NF_NOWRITE, fid)
781              IF ( err .EQ. NF_NOERR ) THEN
782                f_or_t = 1
783              ELSE
784    
785    C           Create the PER-TILE file name
786                CALL MNC_PSNCM(tmpnm, uniq_tnum, MNC_DEF_TMNC)
787                k = ILNBLNK(tmpnm)
788                path_fname(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR)
789                WRITE(path_fname,'(2a,a1,a,a3)')
790         &           mnc_indir_str(1:npath), fname(1:ntot), 't',
791         &           tmpnm(1:k), '.nc'
792    C           WRITE(*,*) 'trying: "', path_fname, '"'
793                err = NF_OPEN(path_fname, NF_NOWRITE, fid)
794                IF ( err .EQ. NF_NOERR ) THEN
795                  f_or_t = 0
796                ELSE
797                  k = ILNBLNK(path_fname)
798                  write(msgbuf,'(4a)')
799         &             'MNC_CW_RX_R: cannot open either a per-face or a ',
800         &             'per-tile file: last try was ''', path_fname(1:k),
801         &             ''''
802                  CALL print_error(msgbuf, mythid)
803                  STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
804                ENDIF
805    
806              ENDIF
807    
808              ntot = ILNBLNK(path_fname)
809              write(msgbuf,'(5a)')
810         &         'MNC_CW_RX_R: cannot get netCDF id for variable ''',
811         &         vtype(nvf:nvl), ''' in file ''', path_fname(1:ntot),
812         &         ''''
813              err = NF_INQ_VARID(fid, vtype, idv)
814              CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
815    
816              k = ILNBLNK(path_fname)
817              fname(1:k) = path_fname(1:k)
818              nfname = k
819    
820    #endif
821    
822              IF ( f_or_t .EQ. 1 ) THEN
823    
824    C           write(msgbuf,'(2a)')
825    C           &           'MNC_CW_RX_R: per-face reads are not yet ',
826    C           &           'implemented -- so pester Ed to finish them'
827    C           CALL print_error(msgbuf, mythid)
828    C           STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
829                
830    C           Get the X,Y PER-FACE offsets
831                CALL MNC_CW_GET_XYFO(lbi,lbj, ixoff,iyoff, myThid)
832    
833              ENDIF
834    
835    C         WRITE(*,*) 'f_or_t = ',f_or_t
836    
837  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
838  C         are compatible and WARN (only warn) if not  C         are compatible and WARN (only warn) if not
839            f_sNx = -1  C           f_sNx = -1
840            f_sNy = -1  C           f_sNy = -1
841            err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNx',atype,alen)  C           err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNx',atype,alen)
842            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN  C           IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN
843              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx)  C             err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx)
844              CALL MNC_HANDLE_ERR(err,  C             CALL MNC_HANDLE_ERR(err,
845       &           'reading attribute ''sNx'' in S/R MNC_CW_RX_R_YY',  C      &           'reading attribute ''sNx'' in S/R MNC_CW_RX_R',
846       &           myThid)  C      &           myThid)
847            ENDIF  C           ENDIF
848            err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen)  C           err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen)
849            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN  C           IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN
850              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy)  C             err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy)
851              CALL MNC_HANDLE_ERR(err,  C             CALL MNC_HANDLE_ERR(err,
852       &           'reading attribute ''sNy'' in S/R MNC_CW_RX_R_YY',  C      &           'reading attribute ''sNy'' in S/R MNC_CW_RX_R',
853       &           myThid)  C      &           myThid)
854            ENDIF  C           ENDIF
855            IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN  C           IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN
856              write(msgbuf,'(5a)') 'MNC_CW_RX_R_YY WARNING: the ',  C             write(msgbuf,'(5a)') 'MNC_CW_RX_R WARNING: the ',
857       &           'attributes ''sNx'' and ''sNy'' within the file ''',  C      &           'attributes ''sNx'' and ''sNy'' within the file ''',
858       &           fname(1:nfname), ''' do not exist or do not match ',  C      &           fname(1:nfname), ''' do not exist or do not match ',
859       &           'the current sizes within the model'  C      &           'the current sizes within the model'
860              CALL print_error(msgbuf, mythid)  C             CALL print_error(msgbuf, mythid)
861            ENDIF  C           ENDIF
862    
863  C         Check that the in-memory variable and the in-file variables  C         Check that the in-memory variable and the in-file variables
864  C         are of compatible sizes  C         are of compatible sizes
# Line 498  C           ires = 1 Line 866  C           ires = 1
866  C           CALL MNC_CHK_VTYP_R_NCVAR( ind_vt,  C           CALL MNC_CHK_VTYP_R_NCVAR( ind_vt,
867  C      &         indf, ind_fv_ids, indu, ires)  C      &         indf, ind_fv_ids, indu, ires)
868  C           IF (ires .LT. 0) THEN  C           IF (ires .LT. 0) THEN
869  C             write(msgbuf,'(7a)') 'MNC_CW_RX_R_YY WARNING: the sizes ',  C             write(msgbuf,'(7a)') 'MNC_CW_RX_R WARNING: the sizes ',
870  C      &           'of the in-program variable ''', vtype(nvf:nvl),  C      &           'of the in-program variable ''', vtype(nvf:nvl),
871  C      &           ''' and the corresponding variable within file ''',  C      &           ''' and the corresponding variable within file ''',
872  C      &           fname(1:nfname), ''' are not compatible -- please ',  C      &           fname(1:nfname), ''' are not compatible -- please ',
873  C      &           'check the sizes'  C      &           'check the sizes'
874  C             CALL print_error(msgbuf, mythid)  C             CALL print_error(msgbuf, mythid)
875  C             STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY'  C             STOP 'ABNORMAL END: S/R MNC_CW_RX_R'
876  C           ENDIF  C           ENDIF
877    
878  C         Check for bi,bj indicies  C         Check for bi,bj indicies
# Line 542  C         the unlimited dimension offset Line 910  C         the unlimited dimension offset
910              IF (i .LE. ndim) THEN              IF (i .LE. ndim) THEN
911                s(i) = mnc_cw_is(i,igrid)                s(i) = mnc_cw_is(i,igrid)
912                e(i) = mnc_cw_ie(i,igrid)                e(i) = mnc_cw_ie(i,igrid)
913    
914                  IF ( f_or_t .EQ. 1 ) THEN
915    C               Add the per-face X,Y offsets to the udo offset vector
916    C               since they accomplish the same thing
917                    IF ( mnc_cw_dn(i,igrid)(1:1) .EQ. 'X' ) THEN
918                      udo(i) = ixoff - 1
919                    ELSEIF ( mnc_cw_dn(i,igrid)(1:1) .EQ. 'Y' ) THEN
920                      udo(i) = iyoff - 1
921                    ENDIF
922                  ENDIF
923    
924              ENDIF              ENDIF
925  C           Check for the unlimited dimension  C           Check for the unlimited dimension
926              IF ((i .EQ. ndim)              IF ((i .EQ. ndim)
# Line 549  C           Check for the unlimited dime Line 928  C           Check for the unlimited dime
928                IF (indu .GT. 0) THEN                IF (indu .GT. 0) THEN
929  C               Use the indu value  C               Use the indu value
930                  udo(i) = indu - 1                  udo(i) = indu - 1
               ELSEIF (indu .EQ. -1) THEN  
 C               Append one to the current unlimited dim size  
                 CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid)  
                 udo(i) = unlim_sz  
931                ELSE                ELSE
932  C               Use the current unlimited dim size  C               We need the current unlim dim size
933                  CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid)                  write(msgbuf,'(5a)') 'MNC_CW_RX_R: getting the ',
934                  udo(i) = unlim_sz - 1       &               'unlim dim id within file ''',
935         &               fname(1:nfname), ''''
936                    err = NF_INQ_UNLIMDIM(fid, unlid)
937                    CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
938                    write(msgbuf,'(5a)') 'MNC_CW_RX_R: getting the ',
939         &               'unlim dim size within file ''',
940         &               fname(1:nfname), ''''
941                    err = NF_INQ_DIMLEN(fid, unlid, unlim_sz)
942                    CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
943                    udo(i) = unlim_sz
944                ENDIF                ENDIF
945              ENDIF              ENDIF
946            ENDDO            ENDDO
# Line 573  C     DO i = 9,1,-1 Line 957  C     DO i = 9,1,-1
957  C     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)
958  C     ENDDO  C     ENDDO
959                        
           CALL MNC_FILE_ENDDEF(fname, myThid)  
   
960            write(msgbuf,'(5a)') 'reading variable type ''',            write(msgbuf,'(5a)') 'reading variable type ''',
961       &         vtype(nvf:nvl), ''' within file ''',       &         vtype(nvf:nvl), ''' within file ''',
962       &         fname(1:nfname), ''''       &         fname(1:nfname), ''''
# Line 605  C         Read the variable one vector a Line 987  C         Read the variable one vector a
987                        vstart(2) = udo(2) + j2 - s(2) + 1                        vstart(2) = udo(2) + j2 - s(2) + 1
988                        vcount(2) = 1                        vcount(2) = 1
989    
990          kr = 0
991        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
992        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  
993    
994        CALL MNC_HANDLE_ERR(err, msgbuf, myThid)        IF (vcount(1) .GT. MNC_MAX_BUFF) THEN
995            write(msgbuf,'(2a,I7,a)') 'MNC_MAX_BUFF is too small',
996         &       '--please increase to at least ',
997         &       vcount(1), ' in ''MNC_BUFF.h'''
998            CALL PRINT_ERROR(msgBuf , 1)
999            STOP 'ABNORMAL END: S/R MNC_CW_RX_R_OFFSET'
1000          ENDIF
1001    
1002          IF (stype(1:1) .EQ. 'D') THEN
1003            err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)
1004            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
1005            DO j1 = s(1),e(1)
1006              k1 = k2 + j1
1007              kr = kr + 1
1008              var(k1) = MNCI2( resh_d(kr) )
1009            ENDDO
1010          ENDIF
1011          IF (stype(1:1) .EQ. 'R') THEN
1012            err = NF_GET_VARA_REAL(fid, idv, vstart, vcount, resh_r)
1013            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
1014            DO j1 = s(1),e(1)
1015              k1 = k2 + j1
1016              kr = kr + 1
1017              var(k1) = MNCI2( resh_r(kr) )
1018            ENDDO
1019          ENDIF
1020          IF (stype(1:1) .EQ. 'I') THEN
1021            err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh_i)
1022            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
1023            DO j1 = s(1),e(1)
1024              k1 = k2 + j1
1025              kr = kr + 1
1026              var(k1) = resh_i(kr)
1027            ENDDO
1028          ENDIF
1029    
       kr = 0  
       DO j1 = s(1),e(1)  
         k1 = k2 + j1  
         kr = kr + 1  
         var(k1) = resh(kr)  
       ENDDO  
         
1030    
1031                      ENDDO                      ENDDO
1032                    ENDDO                    ENDDO
# Line 636  C         Read the variable one vector a Line 1036  C         Read the variable one vector a
1036            ENDDO            ENDDO
1037    
1038  C         Close the file  C         Close the file
1039            CALL MNC_FILE_CLOSE(fname, myThid)  C         CALL MNC_FILE_CLOSE(fname, myThid)
1040              err = NF_CLOSE(fid)
1041              write(msgbuf,'(3a)') 'MNC_CW_RX_R:  cannot close file ''',
1042         &         fname(1:nfname), ''''
1043              CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
1044    
1045    
1046  C         End the lbj,lbi loops  C         End the lbj,lbi loops
1047          ENDDO          ENDDO

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.22