/[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.17 by edhill, Fri Apr 2 16:12:48 2004 UTC revision 1.23 by edhill, Thu Oct 21 13:38:45 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  CBOP 0  CBOP 0
8    C !ROUTINE: MNC_CW_RX_W_S
9    
10    C !INTERFACE:
11          SUBROUTINE MNC_CW_RX_W_S(
12         I     stype,
13         I     fbname, bi,bj,
14         I     vtype,
15         I     var,
16         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  C !ROUTINE: MNC_CW_RX_W
41    
42  C !INTERFACE:  C !INTERFACE:
# Line 16  C !INTERFACE: Line 48  C !INTERFACE:
48       I     myThid )       I     myThid )
49    
50  C     !DESCRIPTION:  C     !DESCRIPTION:
51    C     A scalar version of MNC_CW_RX_W() for compilers that cannot
52    C     gracefully handle the conversion on their own.
53          
54    C     !USES:
55          implicit none
56    
57    C     !INPUT PARAMETERS:
58          integer myThid, bi,bj
59          character*(*) stype, fbname, vtype
60          __V var(*)
61          INTEGER offsets(9)
62    CEOP
63          INTEGER i
64    
65          DO i = 1,9
66            offsets(i) = 0
67          ENDDO
68          CALL MNC_CW_RX_W_OFFSET(stype,fbname,bi,bj,vtype, var,
69         &     offsets, myThid)
70    
71          RETURN
72          END
73    
74    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
75    CBOP 0
76    C !ROUTINE: MNC_CW_RX_W_OFFSET
77    
78    C !INTERFACE:
79          SUBROUTINE MNC_CW_RX_W_OFFSET(
80         I     stype,
81         I     fbname, bi,bj,
82         I     vtype,
83         I     var,
84         I     offsets,
85         I     myThid )
86    
87    C     !DESCRIPTION:
88  C     This subroutine writes one variable to a file or a file group,  C     This subroutine writes one variable to a file or a file group,
89  C     depending upon the tile indicies.  C     depending upon the tile indicies.
90                
# Line 26  C     !USES: Line 95  C     !USES:
95  #include "SIZE.h"  #include "SIZE.h"
96  #include "EEPARAMS.h"  #include "EEPARAMS.h"
97  #include "PARAMS.h"  #include "PARAMS.h"
98    #include "MNC_PARAMS.h"
99    
100  C     !INPUT PARAMETERS:  C     !INPUT PARAMETERS:
101        integer myThid, bi,bj, indu        integer myThid, bi,bj
102        character*(*) stype, fbname, vtype        character*(*) stype, fbname, vtype
103        __V var(*)        __V var(*)
104          INTEGER offsets(*)
105  CEOP  CEOP
106    
107  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
108        integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot        integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot, indu
109        integer bis,bie, bjs,bje, uniq_tnum, nfname        integer bis,bie, bjs,bje, uniq_tnum, nfname, iseq
110        integer fid, idv, indvids, ndim, indf, err        integer fid, idv, indvids, ndim, indf, err
111        integer lbi,lbj, bidim,bjdim, unlim_sz, kr        integer lbi,lbj, bidim,bjdim, unlim_sz, kr
112        integer p(9),s(9),e(9), dimnc(9)        integer p(9),s(9),e(9), dimnc(9)
# Line 48  C     !LOCAL VARIABLES: Line 119  C     !LOCAL VARIABLES:
119        REAL*8  resh_d( sNx + 2*OLx + sNy + 2*OLy )        REAL*8  resh_d( sNx + 2*OLx + sNy + 2*OLy )
120        REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )        REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )
121        INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )        INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )
122    #ifdef HAVE_STAT
123          integer ntotenc, ncenc, nbytes, fs_isdone
124          character*(200) cenc
125          integer ienc(200)
126          REAL*8  fsnu
127    #endif
128    
129  C     Functions  C     Functions
130        integer IFNBLNK, ILNBLNK        integer IFNBLNK, ILNBLNK
# Line 68  C     group (or base) name Line 145  C     group (or base) name
145          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
146        ENDIF        ENDIF
147        indu = mnc_cw_fgud(indfg)        indu = mnc_cw_fgud(indfg)
148          iseq = mnc_cw_fgis(indfg)
149    C     write(*,*) 'indu,iseq = ', indu, iseq
150    
151  C     Check that the Variable Type exists  C     Check that the Variable Type exists
152        nvf = IFNBLNK(vtype)        nvf = IFNBLNK(vtype)
# Line 98  C     Set the bi,bj indicies Line 177  C     Set the bi,bj indicies
177        DO lbj = bjs,bje        DO lbj = bjs,bje
178          DO lbi = bis,bie          DO lbi = bis,bie
179    
180    #ifdef HAVE_STAT
181              fs_isdone = 0
182    #endif
183     10       CONTINUE
184    
185  C         Create the file name  C         Create the file name
186            CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid)            CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid)
187            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
# Line 107  C         Create the file name Line 191  C         Create the file name
191            fname(1:ntot) = fbname(n1:n2)            fname(1:ntot) = fbname(n1:n2)
192            ntot = ntot + 1            ntot = ntot + 1
193            fname(ntot:ntot) = '.'            fname(ntot:ntot) = '.'
194            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'            write(fname((ntot+1):(ntot+14)),'(i4.4,a1,i6.6,a3)')
195            nfname = ntot+9       &         iseq,'.',uniq_tnum, '.nc'
196              nfname = ntot + 14
197    
198  C         Add the path to the file name  C         Add the path to the file name
199            IF (mnc_use_outdir) THEN            IF (mnc_use_outdir) THEN
# Line 124  C         Append to an existing or creat Line 209  C         Append to an existing or creat
209            CALL MNC_CW_FILE_AORC(fname, indf, myThid)            CALL MNC_CW_FILE_AORC(fname, indf, myThid)
210            fid = mnc_f_info(indf,2)            fid = mnc_f_info(indf,2)
211    
212    #ifdef HAVE_STAT
213              IF ((mnc_cw_fgig(indfg) .EQ. 1)
214         &         .AND. (fs_isdone .EQ. 0)) THEN
215    C           Decide whether to append to the existing or create a new file
216    C           based on the byte count per unlimited dimension
217                ncenc = 70
218                cenc(1:26)  = 'abcdefghijklmnopqrstuvwxyz'
219                cenc(27:52) = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
220                cenc(53:70) = '0123456789_.,+-=/~'
221                k = nfname
222                IF (k .GT. 200)  k = 200
223                ntotenc = 0
224                DO i = 1,k
225                  DO j = 1,ncenc
226                    IF (fname(i:i) .EQ. cenc(j:j)) THEN
227                      ntotenc = ntotenc + 1
228                      ienc(ntotenc) = j
229                      GOTO 20
230                    ENDIF
231                  ENDDO
232     20           CONTINUE
233                ENDDO
234                CALL mncfsize(ntotenc, ienc, nbytes)
235                IF (nbytes .GT. 0) THEN
236                  CALL MNC_DIM_UNLIM_SIZE(fname, unlim_sz, myThid)
237                  fsnu = (1.0 _d 0 + 1.0 _d 0 / DBLE(unlim_sz))
238         &             * DBLE(nbytes)
239                  IF (fsnu .GT. mnc_max_fsize) THEN
240                    iseq = iseq + 1
241                    indu = 1
242                    mnc_cw_fgud(indfg) = 1
243                    mnc_cw_fgis(indfg) = iseq
244                    fs_isdone = 1
245                    GOTO 10
246                  ENDIF
247                ENDIF
248              ENDIF
249    #endif  /*  HAVE_STAT  */
250    
251  C         Ensure that all the NetCDF dimensions are defined and create a  C         Ensure that all the NetCDF dimensions are defined and create a
252  C         local copy of them  C         local copy of them
253            DO i = 1,9            DO i = 1,9
# Line 160  C         Ensure that the variable is de Line 284  C         Ensure that the variable is de
284                idv = mnc_fv_ids(indf,j+1)                idv = mnc_fv_ids(indf,j+1)
285                indvids = mnc_fd_ind(indf, mnc_f_info(indf,                indvids = mnc_fd_ind(indf, mnc_f_info(indf,
286       &             (mnc_fv_ids(indf,j+2) + 1)) )       &             (mnc_fv_ids(indf,j+2) + 1)) )
287                GOTO 10                GOTO 30
288              ENDIF              ENDIF
289            ENDDO            ENDDO
290            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ',            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ',
291       &         'cannot reference variable ''', vtype, ''''       &         'cannot reference variable ''', vtype, ''''
292            CALL print_error(msgbuf, mythid)            CALL print_error(msgbuf, mythid)
293            STOP 'ABNORMAL END: package MNC'            STOP 'ABNORMAL END: package MNC'
294   10       CONTINUE   30       CONTINUE
295    
296  C         Check for bi,bj indicies  C         Check for bi,bj indicies
297            bidim = mnc_cw_vbij(1,indv)            bidim = mnc_cw_vbij(1,indv)
# Line 194  C         Set the dimensions for the in- Line 318  C         Set the dimensions for the in-
318              ELSE              ELSE
319                p(i) = k * p(i-1)                p(i) = k * p(i-1)
320              ENDIF              ENDIF
321                IF (offsets(i) .GT. 0) THEN
322                  k = 1
323                  p(i) = k * p(i-1)
324                ENDIF
325            ENDDO            ENDDO
326    
327  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 231  C               Use the current unlimite Line 359  C               Use the current unlimite
359              s(bjdim) = lbj              s(bjdim) = lbj
360              e(bjdim) = lbj              e(bjdim) = lbj
361            ENDIF            ENDIF
362  CEH3      DO i = 1,9            
363  CEH3        write(*,*) 'i,p(i),s(i),e(i) = ', i,p(i),s(i),e(i)  C         Check the offsets
364  CEH3      ENDDO            DO i = 1,9
365                IF (offsets(i) .GT. 0) THEN
366                  udo(i) = udo(i) + offsets(i) - 1
367                  s(i) = 1
368                  e(i) = 1
369                ENDIF
370              ENDDO
371    
372  C         Add the global attributes  C         Add the global attributes
373            CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid)            CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid)
# Line 258  C         Add the per-variable attribute Line 392  C         Add the per-variable attribute
392       &         vtype(nvf:nvl), ''' within file ''',       &         vtype(nvf:nvl), ''' within file ''',
393       &         fname(1:nfname), ''''       &         fname(1:nfname), ''''
394    
395    C         DO i = 1,9
396    C         write(*,*) 'i,p(i),s(i),e(i),udo(i),offsets(i) = ',
397    C         &        i,p(i),s(i),e(i),udo(i),offsets(i)
398    C         ENDDO
399    
400  C         Write the variable one vector at a time  C         Write the variable one vector at a time
401            DO j7 = s(7),e(7)            DO j7 = s(7),e(7)
402              k7 = (j7 - 1)*p(6)              k7 = (j7 - 1)*p(6)
# Line 339  C         Sync the file Line 478  C         Sync the file
478    
479  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
480  CBOP 0  CBOP 0
481    C !ROUTINE: MNC_CW_RX_R_S
482    
483    C !INTERFACE:
484          SUBROUTINE MNC_CW_RX_R_S(
485         I     stype,
486         I     fbname, bi,bj,
487         I     vtype,
488         I     var,
489         I     myThid )
490    
491    C     !DESCRIPTION:
492    C     A scalar version of MNC_CW_RX_R() for compilers that cannot
493    C     gracefully handle the conversion on their own.
494          
495    C     !USES:
496          implicit none
497    
498    C     !INPUT PARAMETERS:
499          integer myThid, bi,bj
500          character*(*) stype, fbname, vtype
501          __V var
502          __V var_arr(1)
503    CEOP
504          var_arr(1) = var
505    
506          CALL MNC_CW_RX_R(stype,fbname,bi,bj,vtype, var_arr, myThid)
507    
508          RETURN
509          END
510    
511    
512    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
513    CBOP 0
514  C !ROUTINE: MNC_CW_RX_R  C !ROUTINE: MNC_CW_RX_R
515    
516  C !INTERFACE:  C !INTERFACE:
# Line 360  C     !USES: Line 532  C     !USES:
532  #include "SIZE.h"  #include "SIZE.h"
533  #include "EEPARAMS.h"  #include "EEPARAMS.h"
534  #include "PARAMS.h"  #include "PARAMS.h"
535    #include "MNC_PARAMS.h"
536    
537  C     !INPUT PARAMETERS:  C     !INPUT PARAMETERS:
538        integer myThid, bi,bj, indu        integer myThid, bi,bj
539        character*(*) stype, fbname, vtype        character*(*) stype, fbname, vtype
540        __V var(*)        __V var(*)
541  CEOP  CEOP
542    
543  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
544        integer i,k, nvf,nvl, n1,n2, igrid, ntot        integer i,k, nvf,nvl, n1,n2, igrid, ntot, indu
545        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv
546        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr
547        integer ind_fv_ids, ind_vt, ierr, atype, alen        integer ind_fv_ids, ind_vt, ierr, atype, alen

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.23

  ViewVC Help
Powered by ViewVC 1.1.22