/[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.6 by edhill, Mon Mar 8 21:15:49 2004 UTC revision 1.14 by edhill, Wed Mar 24 15:29:33 2004 UTC
# Line 5  C $Name$ Line 5  C $Name$
5                
6  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
7    
8        SUBROUTINE MNC_CW_RX_W_YY(        SUBROUTINE MNC_CW_RX_W(
9       I     myThid,       I     stype,
10       I     fbname, bi,bj,       I     fbname, bi,bj,
11       I     vtype,       I     vtype,
12       I     indu,       I     var,
13       I     var )       I     myThid )
14    
15        implicit none        implicit none
16    
17  #include "netcdf.inc"  #include "netcdf.inc"
18  #include "mnc_common.h"  #include "mnc_common.h"
 #include "EEPARAMS.h"  
19  #include "SIZE.h"  #include "SIZE.h"
20    #include "EEPARAMS.h"
21  #define mnc_rtype_YY  #include "PARAMS.h"
22    
23  C     Arguments  C     Arguments
24        integer myThid, bi,bj, indu        integer myThid, bi,bj, indu
25        character*(*) fbname, vtype        character*(*) stype, fbname, vtype
26        __V var(*)        __V var(*)
27    
28  C     Functions  C     Functions
# Line 35  C     Local Variables Line 34  C     Local Variables
34        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr
35        integer p(9),s(9),e(9), dimnc(9), vstart(9),vcount(9), udo(9)        integer p(9),s(9),e(9), dimnc(9), vstart(9),vcount(9), udo(9)
36        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
37          integer indfg, fg1,fg2, npath
38        character*(MAX_LEN_MBUF) msgbuf        character*(MAX_LEN_MBUF) msgbuf
39        character*(MNC_MAX_CHAR) fname        character*(MNC_MAX_CHAR) fname
40          character*(MNC_MAX_CHAR) path_fname
41    
42  C     Temporary storage for the simultaneous type conversion and  C     Temporary storage for the simultaneous type conversion and
43  C     re-shaping before passing to NetCDF  C     re-shaping before passing to NetCDF
44  #ifdef  mnc_rtype_D        REAL*8  resh_d( sNx + 2*OLx + sNy + 2*OLy )
45        REAL*8  resh( sNx + 2*OLx + sNy + 2*OLy )        REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )
46  #endif        INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )
 #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  
47    
48  C     Only do I/O if I am the master thread  C     Only do I/O if I am the master thread
49        _BEGIN_MASTER( myThid )        _BEGIN_MASTER( myThid )
50    
51    C     Get the current index for the unlimited dimension from the file
52    C     group (or base) name
53          fg1 = IFNBLNK(fbname)
54          fg2 = ILNBLNK(fbname)
55          CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid)
56          IF (indfg .LT. 1) THEN
57            write(msgbuf,'(3a)')
58         &       'MNC_CW_RX_W ERROR: file group name ''',
59         &       fbname(fg1:fg2), ''' is not defined'
60            CALL print_error(msgbuf, mythid)
61            STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
62          ENDIF
63          indu = mnc_cw_fgud(indfg)
64    
65  C     Check that the Variable Type exists  C     Check that the Variable Type exists
66        nvf = IFNBLNK(vtype)        nvf = IFNBLNK(vtype)
67        nvl = ILNBLNK(vtype)        nvl = ILNBLNK(vtype)
68        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)
69        IF (indv .LT. 1) THEN        IF (indv .LT. 1) THEN
70          write(msgbuf,'(3a)') 'MNC_CW_RX_W_YY ERROR: vtype ''',          write(msgbuf,'(3a)') 'MNC_CW_RX_W ERROR: vtype ''',
71       &       vtype(nvf:nvl), ''' is not defined'       &       vtype(nvf:nvl), ''' is not defined'
72          CALL print_error(msgbuf, mythid)          CALL print_error(msgbuf, mythid)
73          STOP 'ABNORMAL END: S/R MNC_CW_RX_W_YY'          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
74        ENDIF        ENDIF
75        igrid = mnc_cw_vgind(indv)        igrid = mnc_cw_vgind(indv)
76    
# Line 83  C     Set the bi,bj indicies Line 92  C     Set the bi,bj indicies
92          DO lbi = bis,bie          DO lbi = bis,bie
93    
94  C         Create the file name  C         Create the file name
95            CALL MNC_CW_GET_TILE_NUM(myThid, lbi,lbj, uniq_tnum)            CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid)
96            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
97            n1 = IFNBLNK(fbname)            n1 = IFNBLNK(fbname)
98            n2 = ILNBLNK(fbname)            n2 = ILNBLNK(fbname)
# Line 94  C         Create the file name Line 103  C         Create the file name
103            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'
104            nfname = ntot+9            nfname = ntot+9
105    
106    C         Add the path to the file name
107              IF (mnc_use_outdir) THEN
108                path_fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
109                npath = ILNBLNK(mnc_out_path)
110                path_fname(1:npath) = mnc_out_path(1:npath)
111                path_fname((npath+1):(npath+nfname)) = fname(1:nfname)
112                fname(1:MNC_MAX_CHAR) = path_fname(1:MNC_MAX_CHAR)
113                nfname = npath + nfname
114              ENDIF
115    
116  C         Append to an existing or create a new file  C         Append to an existing or create a new file
117            CALL MNC_CW_FILE_AORC(myThid, fname, indf)            CALL MNC_CW_FILE_AORC(fname, indf, myThid)
118            fid = mnc_f_info(indf,2)            fid = mnc_f_info(indf,2)
119    
120  C         Ensure that all the NetCDF dimensions are defined and create a  C         Ensure that all the NetCDF dimensions are defined and create a
# Line 109  C         local copy of them Line 128  C         local copy of them
128              ELSE              ELSE
129                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
130              ENDIF              ENDIF
131              CALL MNC_DIM_INIT(myThid,fname,              CALL MNC_DIM_INIT(fname,
132       &           mnc_cw_dn(i,igrid), dimnc(i) )       &           mnc_cw_dn(i,igrid), dimnc(i), myThid)
133            ENDDO            ENDDO
134    
135  C         Ensure that the "grid" is defined  C         Ensure that the "grid" is defined
136            CALL MNC_GRID_INIT(myThid,fname, mnc_cw_gname(igrid),            CALL MNC_GRID_INIT(fname, mnc_cw_gname(igrid),
137       &        mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid))       &        mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid), myThid)
138    
139  C         Ensure that the variable is defined  C         Ensure that the variable is defined
140  #ifdef  mnc_rtype_D            IF (stype(1:1) .EQ. 'D')
141        CALL MNC_VAR_INIT_DBL(myThid,fname,mnc_cw_gname(igrid),vtype)       &         CALL MNC_VAR_INIT_DBL(
142  #endif       &         fname, mnc_cw_gname(igrid), vtype, myThid)
143  #ifdef  mnc_rtype_R            IF (stype(1:1) .EQ. 'R')
144        CALL MNC_VAR_INIT_REAL(myThid,fname,mnc_cw_gname(igrid),vtype)       &         CALL MNC_VAR_INIT_REAL(
145  #endif       &         fname, mnc_cw_gname(igrid), vtype, myThid)
146  #ifdef  mnc_rtype_I            IF (stype(1:1) .EQ. 'I')
147        CALL MNC_VAR_INIT_INT(myThid,fname,mnc_cw_gname(igrid),vtype)       &         CALL MNC_VAR_INIT_INT(
148  #endif       &         fname, mnc_cw_gname(igrid), vtype, myThid)
149    
150            DO i = 1,mnc_fv_ids(indf,1)            DO i = 1,mnc_fv_ids(indf,1)
151              j = 2 + 3*(i - 1)              j = 2 + 3*(i - 1)
152              IF (mnc_v_names(mnc_fv_ids(indf,j)) .EQ. vtype) THEN              IF (mnc_v_names(mnc_fv_ids(indf,j)) .EQ. vtype) THEN
# Line 136  C         Ensure that the variable is de Line 156  C         Ensure that the variable is de
156                GOTO 10                GOTO 10
157              ENDIF              ENDIF
158            ENDDO            ENDDO
159            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W_YY ERROR: ',            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ',
160       &         'cannot reference variable ''', vtype, ''''       &         'cannot reference variable ''', vtype, ''''
161            CALL print_error(msgbuf, mythid)            CALL print_error(msgbuf, mythid)
162            STOP 'ABNORMAL END: package MNC'            STOP 'ABNORMAL END: package MNC'
# Line 187  C               Use the indu value Line 207  C               Use the indu value
207                  udo(i) = indu - 1                  udo(i) = indu - 1
208                ELSEIF (indu .EQ. -1) THEN                ELSEIF (indu .EQ. -1) THEN
209  C               Append one to the current unlimited dim size  C               Append one to the current unlimited dim size
210                  CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz)                  CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid)
211                  udo(i) = unlim_sz                  udo(i) = unlim_sz
212                ELSE                ELSE
213  C               Use the current unlimited dim size  C               Use the current unlimited dim size
214                  CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz)                  CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid)
215                  udo(i) = unlim_sz - 1                  udo(i) = unlim_sz - 1
216                ENDIF                ENDIF
217              ENDIF              ENDIF
# Line 209  CEH3        write(*,*) 'i,p(i),s(i),e(i) Line 229  CEH3        write(*,*) 'i,p(i),s(i),e(i)
229  CEH3      ENDDO  CEH3      ENDDO
230    
231  C         Add the global attributes  C         Add the global attributes
232            CALL MNC_CW_SET_GATTR(myThid, fname, lbi,lbj, uniq_tnum)            CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid)
233    
234  C         Add the per-variable attributes  C         Add the per-variable attributes
235            DO i = 1,mnc_cw_vnat(1,indv)            DO i = 1,mnc_cw_vnat(1,indv)
236              CALL MNC_VAR_ADD_ATTR_STR(myThid, fname, vtype,              CALL MNC_VAR_ADD_ATTR_STR( fname, vtype,
237       &           mnc_cw_vtnm(i,indv), mnc_cw_vtat(i,indv))       &           mnc_cw_vtnm(i,indv), mnc_cw_vtat(i,indv), myThid)
238            ENDDO            ENDDO
239            DO i = 1,mnc_cw_vnat(2,indv)            DO i = 1,mnc_cw_vnat(2,indv)
240              CALL MNC_VAR_ADD_ATTR_INT(myThid, fname, vtype,              CALL MNC_VAR_ADD_ATTR_INT( fname, vtype,
241       &           mnc_cw_vinm(i,indv), 1, mnc_cw_viat(i,indv))       &           mnc_cw_vinm(i,indv), 1, mnc_cw_viat(i,indv), myThid)
242            ENDDO            ENDDO
243            DO i = 1,mnc_cw_vnat(3,indv)            DO i = 1,mnc_cw_vnat(3,indv)
244              CALL MNC_VAR_ADD_ATTR_DBL(myThid, fname, vtype,              CALL MNC_VAR_ADD_ATTR_DBL( fname, vtype,
245       &           mnc_cw_vdnm(i,indv), 1, mnc_cw_vdat(i,indv))       &           mnc_cw_vdnm(i,indv), 1, mnc_cw_vdat(i,indv), myThid)
246            ENDDO            ENDDO
247    
248            CALL MNC_FILE_ENDDEF(myThid,fname)            CALL MNC_FILE_ENDDEF(fname, myThid)
249    
250              write(msgbuf,'(5a)') 'writing variable type ''',
251         &         vtype(nvf:nvl), ''' within file ''',
252         &         fname(1:nfname), ''''
253    
254  C         Write the variable one vector at a time  C         Write the variable one vector at a time
255            DO j7 = s(7),e(7)            DO j7 = s(7),e(7)
# Line 254  C         Write the variable one vector Line 278  C         Write the variable one vector
278                        vcount(2) = 1                        vcount(2) = 1
279    
280        kr = 0        kr = 0
       DO j1 = s(1),e(1)  
         k1 = k2 + j1  
         kr = kr + 1  
         resh(kr) = var(k1)  
       ENDDO  
         
281        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
282        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
283    
284  #ifdef  mnc_rtype_D        IF (stype(1:1) .EQ. 'D') THEN
285        err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh)          DO j1 = s(1),e(1)
286  #endif            k1 = k2 + j1
287  #ifdef  mnc_rtype_R            kr = kr + 1
288        err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh)            resh_d(kr) = var(k1)
289  #endif          ENDDO
290  #ifdef  mnc_rtype_I          err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)
291        err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh)        ENDIF
292  #endif        IF (stype(1:1) .EQ. 'R') THEN
293            DO j1 = s(1),e(1)
294              k1 = k2 + j1
295              kr = kr + 1
296              resh_r(kr) = var(k1)
297            ENDDO
298            err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh_r)
299          ENDIF
300          IF (stype(1:1) .EQ. 'I') THEN
301            DO j1 = s(1),e(1)
302              k1 = k2 + j1
303              kr = kr + 1
304              resh_i(kr) = var(k1)
305            ENDDO
306            err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh_i)
307          ENDIF
308    
309          CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
310    
311                      ENDDO                      ENDDO
312                    ENDDO                    ENDDO
# Line 283  C         Write the variable one vector Line 318  C         Write the variable one vector
318  C         Sync the file  C         Sync the file
319            err = NF_SYNC(fid)            err = NF_SYNC(fid)
320            write(msgbuf,'(3a)') 'sync for file ''', fname,            write(msgbuf,'(3a)') 'sync for file ''', fname,
321       &         ''' in S/R MNC_CW_RX_W_YY'       &         ''' in S/R MNC_CW_RX_W'
322            CALL MNC_HANDLE_ERR(myThid, err, msgbuf)            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
323    
324          ENDDO          ENDDO
325        ENDDO        ENDDO
# Line 298  C         Sync the file Line 333  C         Sync the file
333  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
334    
335    
336        SUBROUTINE MNC_CW_RX_R_YY(        SUBROUTINE MNC_CW_RX_R(
337       I     myThid,       I     stype,
338       I     fbname, bi,bj,       I     fbname, bi,bj,
339       I     vtype,       I     vtype,
340       I     indu,       I     var,
341       I     var )       I     myThid )
342    
343        implicit none        implicit none
344    
345  #include "netcdf.inc"  #include "netcdf.inc"
346  #include "mnc_common.h"  #include "mnc_common.h"
 #include "EEPARAMS.h"  
347  #include "SIZE.h"  #include "SIZE.h"
348    #include "EEPARAMS.h"
349  #define mnc_rtype_YY  #include "PARAMS.h"
350    
351  C     Arguments  C     Arguments
352        integer myThid, bi,bj, indu        integer myThid, bi,bj, indu
353        character*(*) fbname, vtype        character*(*) stype, fbname, vtype
354        __V var(*)        __V var(*)
355    
356  C     Functions  C     Functions
357        integer IFNBLNK, ILNBLNK        integer IFNBLNK, ILNBLNK
358    
359  C     Local Variables  C     Local Variables
360        integer i,k, indv,nvf,nvl, n1,n2, igrid, ntot        integer i,k, nvf,nvl, n1,n2, igrid, ntot
361        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv
362        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr
363        integer ind_fv_ids, ind_vt, ierr, atype, alen        integer ind_fv_ids, ind_vt, ierr, atype, alen
364        integer f_sNx,f_sNy, ires        integer f_sNx,f_sNy, npath
365        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)
366        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
367        character*(MAX_LEN_MBUF) msgbuf        character*(MAX_LEN_MBUF) msgbuf
368        character*(MNC_MAX_CHAR) fname        character*(MNC_MAX_CHAR) fname
369          character*(MNC_MAX_CHAR) path_fname
370          integer indfg, fg1,fg2
371    
372  C     Temporary storage for the simultaneous type conversion and  C     Temporary storage for the simultaneous type conversion and
373  C     re-shaping before passing to NetCDF  C     re-shaping before passing to NetCDF
374  #ifdef  mnc_rtype_D        REAL*8  resh_d( sNx + 2*OLx + sNy + 2*OLy )
375        REAL*8  resh( sNx + 2*OLx + sNy + 2*OLy )        REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )
376  #endif        INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )
 #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  
377    
378  C     Only do I/O if I am the master thread  C     Only do I/O if I am the master thread
379        _BEGIN_MASTER( myThid )        _BEGIN_MASTER( myThid )
380    
381    C     Get the current index for the unlimited dimension from the file
382    C     group (or base) name
383          fg1 = IFNBLNK(fbname)
384          fg2 = ILNBLNK(fbname)
385          CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid)
386          IF (indfg .LT. 1) THEN
387            write(msgbuf,'(3a)')
388         &       'MNC_CW_RX_W ERROR: file group name ''',
389         &       fbname(fg1:fg2), ''' is not defined'
390            CALL print_error(msgbuf, mythid)
391            STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
392          ENDIF
393          indu = mnc_cw_fgud(indfg)
394    
395  C     Check that the Variable Type exists  C     Check that the Variable Type exists
396        nvf = IFNBLNK(vtype)        nvf = IFNBLNK(vtype)
397        nvl = ILNBLNK(vtype)        nvl = ILNBLNK(vtype)
398        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)
399        IF (indv .LT. 1) THEN        IF (ind_vt .LT. 1) THEN
400          write(msgbuf,'(3a)') 'MNC_CW_RX_R_YY ERROR: vtype ''',          write(msgbuf,'(3a)') 'MNC_CW_RX_R ERROR: vtype ''',
401       &       vtype(nvf:nvl), ''' is not defined'       &       vtype(nvf:nvl), ''' is not defined'
402          CALL print_error(msgbuf, mythid)          CALL print_error(msgbuf, mythid)
403          STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY'          STOP 'ABNORMAL END: S/R MNC_CW_RX_R'
404        ENDIF        ENDIF
405        igrid = mnc_cw_vgind(ind_vt)        igrid = mnc_cw_vgind(ind_vt)
406    
# Line 382  C     Set the bi,bj indicies Line 426  C     Set the bi,bj indicies
426          DO lbi = bis,bie          DO lbi = bis,bie
427    
428  C         Create the file name  C         Create the file name
429            CALL MNC_CW_GET_TILE_NUM(myThid, lbi,lbj, uniq_tnum)            CALL MNC_CW_GET_TILE_NUM( lbi,lbj, uniq_tnum, myThid)
430            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
431            n1 = IFNBLNK(fbname)            n1 = IFNBLNK(fbname)
432            n2 = ILNBLNK(fbname)            n2 = ILNBLNK(fbname)
# Line 392  C         Create the file name Line 436  C         Create the file name
436            fname(ntot:ntot) = '.'            fname(ntot:ntot) = '.'
437            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'
438            nfname = ntot+9            nfname = ntot+9
439        write(*,*) 'The read file is: ', fname(1:nfname)  
440    C         Add the path to the file name
441              IF (mnc_use_indir) THEN
442                path_fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
443                npath = ILNBLNK(mnc_indir_str)
444                path_fname(1:npath) = mnc_indir_str(1:npath)
445                path_fname((npath+1):(npath+nfname)) = fname(1:nfname)
446                fname(1:MNC_MAX_CHAR) = path_fname(1:MNC_MAX_CHAR)
447                nfname = npath + nfname
448              ENDIF
449    
450  C         Open the existing file  C         Open the existing file
451            CALL MNC_FILE_TRY_READ(myThid, fname, ierr, indf)            CALL MNC_FILE_TRY_READ( fname, ierr, indf, myThid)
452    
453  C         Check that the variable (VType) is defined within the file  C         Check that the variable (VType) is defined within the file
454            CALL MNC_GET_FVINDS(myThid, fname, vtype, indf, ind_fv_ids)            CALL MNC_GET_FVINDS( fname, vtype, indf, ind_fv_ids, myThid)
455            IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN            IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN
456              write(msgbuf,'(4a)') 'MNC_CW_RX_R_YY ERROR: vtype ''',              write(msgbuf,'(4a)') 'MNC_CW_RX_R ERROR: vtype ''',
457       &           vtype(nvf:nvl), ''' is not defined within file ''',       &           vtype(nvf:nvl), ''' is not defined within file ''',
458       &           fname(1:nfname)       &           fname(1:nfname)
459              CALL print_error(msgbuf, mythid)              CALL print_error(msgbuf, mythid)
460              STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY'              STOP 'ABNORMAL END: S/R MNC_CW_RX_R'
461            ENDIF            ENDIF
462            fid = mnc_f_info(indf,2)            fid = mnc_f_info(indf,2)
463            idv = mnc_fv_ids(indf,ind_fv_ids+1)            idv = mnc_fv_ids(indf,ind_fv_ids+1)
464    
       write(*,*) 'indf,ind_fv_ids = ', indf,ind_fv_ids  
   
465  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
466  C         are compatible and WARN (only warn) if not  C         are compatible and WARN (only warn) if not
467            f_sNx = -1            f_sNx = -1
# Line 418  C         are compatible and WARN (only Line 469  C         are compatible and WARN (only
469            err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNx',atype,alen)            err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNx',atype,alen)
470            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN
471              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx)              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx)
472              CALL MNC_HANDLE_ERR(myThid, err,              CALL MNC_HANDLE_ERR(err,
473       &           'reading attribute ''sNx'' in S/R MNC_CW_RX_R_YY')       &           'reading attribute ''sNx'' in S/R MNC_CW_RX_R',
474         &           myThid)
475            ENDIF            ENDIF
476            err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen)            err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen)
477            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN
478              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy)              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy)
479              CALL MNC_HANDLE_ERR(myThid, err,              CALL MNC_HANDLE_ERR(err,
480       &           'reading attribute ''sNy'' in S/R MNC_CW_RX_R_YY')       &           'reading attribute ''sNy'' in S/R MNC_CW_RX_R',
481         &           myThid)
482            ENDIF            ENDIF
483            IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN            IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN
484              write(msgbuf,'(5a)') 'MNC_CW_RX_R_YY WARNING: the ',              write(msgbuf,'(5a)') 'MNC_CW_RX_R WARNING: the ',
485       &           'attributes ''sNx'' and ''sNy'' within the file ''',       &           'attributes ''sNx'' and ''sNy'' within the file ''',
486       &           fname(1:nfname), ''' do not exist or do not match ',       &           fname(1:nfname), ''' do not exist or do not match ',
487       &           'the current sizes within the model'       &           'the current sizes within the model'
# Line 437  C         are compatible and WARN (only Line 490  C         are compatible and WARN (only
490    
491  C         Check that the in-memory variable and the in-file variables  C         Check that the in-memory variable and the in-file variables
492  C         are of compatible sizes  C         are of compatible sizes
493            ires = 1  C           ires = 1
494            CALL MNC_CHK_VTYP_R_NCVAR(myThid, ind_vt,  C           CALL MNC_CHK_VTYP_R_NCVAR( ind_vt,
495       &         indf, ind_fv_ids, indu, ires)  C      &         indf, ind_fv_ids, indu, ires)
496            IF (ires .LT. 0) THEN  C           IF (ires .LT. 0) THEN
497              write(msgbuf,'(7a)') 'MNC_CW_RX_R_YY WARNING: the sizes ',  C             write(msgbuf,'(7a)') 'MNC_CW_RX_R WARNING: the sizes ',
498       &           'of the in-program variable ''', vtype(nvf:nvl),  C      &           'of the in-program variable ''', vtype(nvf:nvl),
499       &           ''' and the corresponding variable within file ''',  C      &           ''' and the corresponding variable within file ''',
500       &           fname(1:nfname), ''' are not compatible -- please ',  C      &           fname(1:nfname), ''' are not compatible -- please ',
501       &           'check the sizes'  C      &           'check the sizes'
502              CALL print_error(msgbuf, mythid)  C             CALL print_error(msgbuf, mythid)
503              STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY'  C             STOP 'ABNORMAL END: S/R MNC_CW_RX_R'
504            ENDIF  C           ENDIF
505    
506  C         Check for bi,bj indicies  C         Check for bi,bj indicies
507            bidim = mnc_cw_vbij(1,ind_vt)            bidim = mnc_cw_vbij(1,ind_vt)
508            bjdim = mnc_cw_vbij(2,ind_vt)            bjdim = mnc_cw_vbij(2,ind_vt)
           write(*,*) 'bidim,bjdim = ', bidim,bjdim  
509    
510  C         Set the dimensions for the in-memory array  C         Set the dimensions for the in-memory array
511            ndim = mnc_cw_ndim(igrid)            ndim = mnc_cw_ndim(igrid)
# Line 495  C               Use the indu value Line 547  C               Use the indu value
547                  udo(i) = indu - 1                  udo(i) = indu - 1
548                ELSEIF (indu .EQ. -1) THEN                ELSEIF (indu .EQ. -1) THEN
549  C               Append one to the current unlimited dim size  C               Append one to the current unlimited dim size
550                  CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz)                  CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid)
551                  udo(i) = unlim_sz                  udo(i) = unlim_sz
552                ELSE                ELSE
553  C               Use the current unlimited dim size  C               Use the current unlimited dim size
554                  CALL MNC_DIM_UNLIM_SIZE(myThid, fname, unlim_sz)                  CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid)
555                  udo(i) = unlim_sz - 1                  udo(i) = unlim_sz - 1
556                ENDIF                ENDIF
557              ENDIF              ENDIF
# Line 513  C               Use the current unlimite Line 565  C               Use the current unlimite
565              e(bjdim) = lbj              e(bjdim) = lbj
566            ENDIF            ENDIF
567    
568        DO i = 9,1,-1  C     DO i = 9,1,-1
569          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)
570        ENDDO  C     ENDDO
571                        
572            CALL MNC_FILE_ENDDEF(myThid,fname)            CALL MNC_FILE_ENDDEF(fname, myThid)
573    
574            write(msgbuf,'(5a)') 'reading variable type ''',            write(msgbuf,'(5a)') 'reading variable type ''',
575       &         vtype(nvf:nvl), ''' within file ''',       &         vtype(nvf:nvl), ''' within file ''',
# Line 549  C         Read the variable one vector a Line 601  C         Read the variable one vector a
601                        vstart(2) = udo(2) + j2 - s(2) + 1                        vstart(2) = udo(2) + j2 - s(2) + 1
602                        vcount(2) = 1                        vcount(2) = 1
603    
604          kr = 0
605        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
606        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
607                
608  #ifdef  mnc_rtype_D        IF (stype(1:1) .EQ. 'D') THEN
609        err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh)          err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)
610  #endif          CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
611  #ifdef  mnc_rtype_R          DO j1 = s(1),e(1)
612        err = NF_GET_VARA_REAL(fid, idv, vstart, vcount, resh)            k1 = k2 + j1
613  #endif            kr = kr + 1
614  #ifdef  mnc_rtype_I            var(k1) = resh_d(kr)
615        err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh)          ENDDO
616  #endif        ENDIF
617          IF (stype(1:1) .EQ. 'R') THEN
618        CALL MNC_HANDLE_ERR(myThid, err, msgbuf)          err = NF_GET_VARA_REAL(fid, idv, vstart, vcount, resh_r)
619            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
620            DO j1 = s(1),e(1)
621              k1 = k2 + j1
622              kr = kr + 1
623              var(k1) = resh_r(kr)
624            ENDDO
625          ENDIF
626          IF (stype(1:1) .EQ. 'I') THEN
627            err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh_i)
628            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
629            DO j1 = s(1),e(1)
630              k1 = k2 + j1
631              kr = kr + 1
632              var(k1) = resh_i(kr)
633            ENDDO
634          ENDIF
635    
       kr = 0  
       DO j1 = s(1),e(1)  
         k1 = k2 + j1  
         kr = kr + 1  
         var(k1) = resh(kr)  
       ENDDO  
636                
637    
638                      ENDDO                      ENDDO
# Line 579  C         Read the variable one vector a Line 642  C         Read the variable one vector a
642              ENDDO              ENDDO
643            ENDDO            ENDDO
644    
645    C         Close the file
646              CALL MNC_FILE_CLOSE(fname, myThid)
647    
648  C         End the lbj,lbi loops  C         End the lbj,lbi loops
649          ENDDO          ENDDO
650        ENDDO        ENDDO

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.22