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

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

  ViewVC Help
Powered by ViewVC 1.1.22