/[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.24 by edhill, Fri Oct 22 21:30:31 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 24  C     !USES: Line 93  C     !USES:
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_SIZE.h"
97  #include "EEPARAMS.h"  #include "EEPARAMS.h"
98  #include "PARAMS.h"  #include "PARAMS.h"
99    #include "MNC_PARAMS.h"
100    
101  C     !INPUT PARAMETERS:  C     !INPUT PARAMETERS:
102        integer myThid, bi,bj, indu        integer myThid, bi,bj
103        character*(*) stype, fbname, vtype        character*(*) stype, fbname, vtype
104        __V var(*)        __V var(*)
105          INTEGER offsets(*)
106  CEOP  CEOP
107    
108  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
109        integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot        integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot, indu
110        integer bis,bie, bjs,bje, uniq_tnum, nfname        integer bis,bie, bjs,bje, uniq_tnum, nfname, iseq
111        integer fid, idv, indvids, ndim, indf, err        integer fid, idv, indvids, ndim, indf, err
112        integer lbi,lbj, bidim,bjdim, unlim_sz, kr        integer lbi,lbj, bidim,bjdim, unlim_sz, kr
113        integer p(9),s(9),e(9), dimnc(9)        integer p(9),s(9),e(9), dimnc(9)
# Line 45  C     !LOCAL VARIABLES: Line 117  C     !LOCAL VARIABLES:
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        REAL*8  resh_d( sNx + 2*OLx + sNy + 2*OLy )        REAL*8  resh_d( MNC_MAX_BUFF )
121        REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )        REAL*4  resh_r( MNC_MAX_BUFF )
122        INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )        INTEGER resh_i( MNC_MAX_BUFF )
123    #ifdef HAVE_STAT
124          integer ntotenc, ncenc, nbytes, fs_isdone
125          character*(200) cenc
126          integer ienc(200)
127          REAL*8  fsnu
128    #endif
129    
130  C     Functions  C     Functions
131        integer IFNBLNK, ILNBLNK        integer IFNBLNK, ILNBLNK
# Line 68  C     group (or base) name Line 146  C     group (or base) name
146          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
147        ENDIF        ENDIF
148        indu = mnc_cw_fgud(indfg)        indu = mnc_cw_fgud(indfg)
149          iseq = mnc_cw_fgis(indfg)
150    C     write(*,*) 'indu,iseq = ', indu, iseq
151    
152  C     Check that the Variable Type exists  C     Check that the Variable Type exists
153        nvf = IFNBLNK(vtype)        nvf = IFNBLNK(vtype)
# Line 98  C     Set the bi,bj indicies Line 178  C     Set the bi,bj indicies
178        DO lbj = bjs,bje        DO lbj = bjs,bje
179          DO lbi = bis,bie          DO lbi = bis,bie
180    
181    #ifdef HAVE_STAT
182              fs_isdone = 0
183    #endif
184     10       CONTINUE
185    
186  C         Create the file name  C         Create the file name
187            CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid)            CALL MNC_CW_GET_TILE_NUM(lbi,lbj, uniq_tnum, myThid)
188            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
# Line 107  C         Create the file name Line 192  C         Create the file name
192            fname(1:ntot) = fbname(n1:n2)            fname(1:ntot) = fbname(n1:n2)
193            ntot = ntot + 1            ntot = ntot + 1
194            fname(ntot:ntot) = '.'            fname(ntot:ntot) = '.'
195            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'            write(fname((ntot+1):(ntot+14)),'(i4.4,a1,i6.6,a3)')
196            nfname = ntot+9       &         iseq,'.',uniq_tnum, '.nc'
197              nfname = ntot + 14
198    
199  C         Add the path to the file name  C         Add the path to the file name
200            IF (mnc_use_outdir) THEN            IF (mnc_use_outdir) THEN
# Line 124  C         Append to an existing or creat Line 210  C         Append to an existing or creat
210            CALL MNC_CW_FILE_AORC(fname, indf, myThid)            CALL MNC_CW_FILE_AORC(fname, indf, myThid)
211            fid = mnc_f_info(indf,2)            fid = mnc_f_info(indf,2)
212    
213    #ifdef HAVE_STAT
214              IF ((mnc_cw_fgig(indfg) .EQ. 1)
215         &         .AND. (fs_isdone .EQ. 0)) THEN
216    C           Decide whether to append to the existing or create a new file
217    C           based on the byte count per unlimited dimension
218                ncenc = 70
219                cenc(1:26)  = 'abcdefghijklmnopqrstuvwxyz'
220                cenc(27:52) = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
221                cenc(53:70) = '0123456789_.,+-=/~'
222                k = nfname
223                IF (k .GT. 200)  k = 200
224                ntotenc = 0
225                DO i = 1,k
226                  DO j = 1,ncenc
227                    IF (fname(i:i) .EQ. cenc(j:j)) THEN
228                      ntotenc = ntotenc + 1
229                      ienc(ntotenc) = j
230                      GOTO 20
231                    ENDIF
232                  ENDDO
233     20           CONTINUE
234                ENDDO
235                CALL mncfsize(ntotenc, ienc, nbytes)
236                IF (nbytes .GT. 0) THEN
237                  CALL MNC_DIM_UNLIM_SIZE(fname, unlim_sz, myThid)
238                  fsnu = (1.0 _d 0 + 1.0 _d 0 / DBLE(unlim_sz))
239         &             * DBLE(nbytes)
240                  IF (fsnu .GT. mnc_max_fsize) THEN
241                    iseq = iseq + 1
242                    indu = 1
243                    mnc_cw_fgud(indfg) = 1
244                    mnc_cw_fgis(indfg) = iseq
245                    fs_isdone = 1
246                    GOTO 10
247                  ENDIF
248                ENDIF
249              ENDIF
250    #endif  /*  HAVE_STAT  */
251    
252  C         Ensure that all the NetCDF dimensions are defined and create a  C         Ensure that all the NetCDF dimensions are defined and create a
253  C         local copy of them  C         local copy of them
254            DO i = 1,9            DO i = 1,9
# Line 160  C         Ensure that the variable is de Line 285  C         Ensure that the variable is de
285                idv = mnc_fv_ids(indf,j+1)                idv = mnc_fv_ids(indf,j+1)
286                indvids = mnc_fd_ind(indf, mnc_f_info(indf,                indvids = mnc_fd_ind(indf, mnc_f_info(indf,
287       &             (mnc_fv_ids(indf,j+2) + 1)) )       &             (mnc_fv_ids(indf,j+2) + 1)) )
288                GOTO 10                GOTO 30
289              ENDIF              ENDIF
290            ENDDO            ENDDO
291            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ',            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ',
292       &         'cannot reference variable ''', vtype, ''''       &         'cannot reference variable ''', vtype, ''''
293            CALL print_error(msgbuf, mythid)            CALL print_error(msgbuf, mythid)
294            STOP 'ABNORMAL END: package MNC'            STOP 'ABNORMAL END: package MNC'
295   10       CONTINUE   30       CONTINUE
296    
297  C         Check for bi,bj indicies  C         Check for bi,bj indicies
298            bidim = mnc_cw_vbij(1,indv)            bidim = mnc_cw_vbij(1,indv)
# Line 194  C         Set the dimensions for the in- Line 319  C         Set the dimensions for the in-
319              ELSE              ELSE
320                p(i) = k * p(i-1)                p(i) = k * p(i-1)
321              ENDIF              ENDIF
322                IF (offsets(i) .GT. 0) THEN
323                  k = 1
324                  p(i) = k * p(i-1)
325                ENDIF
326            ENDDO            ENDDO
327    
328  C         Set starting and ending indicies for the in-memory array and  C         Set starting and ending indicies for the in-memory array and
# Line 231  C               Use the current unlimite Line 360  C               Use the current unlimite
360              s(bjdim) = lbj              s(bjdim) = lbj
361              e(bjdim) = lbj              e(bjdim) = lbj
362            ENDIF            ENDIF
363  CEH3      DO i = 1,9            
364  CEH3        write(*,*) 'i,p(i),s(i),e(i) = ', i,p(i),s(i),e(i)  C         Check the offsets
365  CEH3      ENDDO            DO i = 1,9
366                IF (offsets(i) .GT. 0) THEN
367                  udo(i) = udo(i) + offsets(i) - 1
368                  s(i) = 1
369                  e(i) = 1
370                ENDIF
371              ENDDO
372    
373  C         Add the global attributes  C         Add the global attributes
374            CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid)            CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid)
# Line 258  C         Add the per-variable attribute Line 393  C         Add the per-variable attribute
393       &         vtype(nvf:nvl), ''' within file ''',       &         vtype(nvf:nvl), ''' within file ''',
394       &         fname(1:nfname), ''''       &         fname(1:nfname), ''''
395    
396    C         DO i = 1,9
397    C         write(*,*) 'i,p(i),s(i),e(i),udo(i),offsets(i) = ',
398    C         &        i,p(i),s(i),e(i),udo(i),offsets(i)
399    C         ENDDO
400    
401  C         Write the variable one vector at a time  C         Write the variable one vector at a time
402            DO j7 = s(7),e(7)            DO j7 = s(7),e(7)
403              k7 = (j7 - 1)*p(6)              k7 = (j7 - 1)*p(6)
# Line 288  C         Write the variable one vector Line 428  C         Write the variable one vector
428        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
429        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
430    
431          IF (vcount(1) .GT. MNC_MAX_BUFF) THEN
432            write(msgbuf,'(2a,I7,a)') 'MNC_MAX_BUFF is too small',
433         &       '--please increase to at least ',
434         &       vcount(1), ' in ''MNC_SIZE.h'''
435            CALL PRINT_ERROR(msgBuf , 1)
436            STOP 'ABNORMAL END: S/R MNC_CW_RX_W_OFFSET'
437          ENDIF
438    
439        IF (stype(1:1) .EQ. 'D') THEN        IF (stype(1:1) .EQ. 'D') THEN
440          DO j1 = s(1),e(1)          DO j1 = s(1),e(1)
441            k1 = k2 + j1            k1 = k2 + j1
# Line 339  C         Sync the file Line 487  C         Sync the file
487    
488  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
489  CBOP 0  CBOP 0
490    C !ROUTINE: MNC_CW_RX_R_S
491    
492    C !INTERFACE:
493          SUBROUTINE MNC_CW_RX_R_S(
494         I     stype,
495         I     fbname, bi,bj,
496         I     vtype,
497         I     var,
498         I     myThid )
499    
500    C     !DESCRIPTION:
501    C     A scalar version of MNC_CW_RX_R() for compilers that cannot
502    C     gracefully handle the conversion on their own.
503          
504    C     !USES:
505          implicit none
506    
507    C     !INPUT PARAMETERS:
508          integer myThid, bi,bj
509          character*(*) stype, fbname, vtype
510          __V var
511          __V var_arr(1)
512    CEOP
513          var_arr(1) = var
514    
515          CALL MNC_CW_RX_R(stype,fbname,bi,bj,vtype, var_arr, myThid)
516    
517          RETURN
518          END
519    
520    
521    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
522    CBOP 0
523  C !ROUTINE: MNC_CW_RX_R  C !ROUTINE: MNC_CW_RX_R
524    
525  C !INTERFACE:  C !INTERFACE:
# Line 358  C     !USES: Line 539  C     !USES:
539  #include "netcdf.inc"  #include "netcdf.inc"
540  #include "mnc_common.h"  #include "mnc_common.h"
541  #include "SIZE.h"  #include "SIZE.h"
542    #include "MNC_SIZE.h"
543  #include "EEPARAMS.h"  #include "EEPARAMS.h"
544  #include "PARAMS.h"  #include "PARAMS.h"
545    #include "MNC_PARAMS.h"
546    
547  C     !INPUT PARAMETERS:  C     !INPUT PARAMETERS:
548        integer myThid, bi,bj, indu        integer myThid, bi,bj
549        character*(*) stype, fbname, vtype        character*(*) stype, fbname, vtype
550        __V var(*)        __V var(*)
551  CEOP  CEOP
552    
553  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
554        integer i,k, nvf,nvl, n1,n2, igrid, ntot        integer i,k, nvf,nvl, n1,n2, igrid, ntot, indu
555        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv
556        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr
557        integer ind_fv_ids, ind_vt, ierr, atype, alen        integer ind_fv_ids, ind_vt, ierr, atype, alen
# Line 379  C     !LOCAL VARIABLES: Line 562  C     !LOCAL VARIABLES:
562        character*(MNC_MAX_CHAR) fname        character*(MNC_MAX_CHAR) fname
563        character*(MNC_MAX_CHAR) path_fname        character*(MNC_MAX_CHAR) path_fname
564        integer indfg, fg1,fg2        integer indfg, fg1,fg2
565        REAL*8  resh_d( sNx + 2*OLx + sNy + 2*OLy )        REAL*8  resh_d( MNC_MAX_BUFF )
566        REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )        REAL*4  resh_r( MNC_MAX_BUFF )
567        INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )        INTEGER resh_i( MNC_MAX_BUFF )
568    
569  C     Functions  C     Functions
570        integer IFNBLNK, ILNBLNK        integer IFNBLNK, ILNBLNK
# Line 615  C         Read the variable one vector a Line 798  C         Read the variable one vector a
798        kr = 0        kr = 0
799        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
800        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
801          
802          IF (vcount(1) .GT. MNC_MAX_BUFF) THEN
803            write(msgbuf,'(2a,I7,a)') 'MNC_MAX_BUFF is too small',
804         &       '--please increase to at least ',
805         &       vcount(1), ' in ''MNC_SIZE.h'''
806            CALL PRINT_ERROR(msgBuf , 1)
807            STOP 'ABNORMAL END: S/R MNC_CW_RX_R_OFFSET'
808          ENDIF
809    
810        IF (stype(1:1) .EQ. 'D') THEN        IF (stype(1:1) .EQ. 'D') THEN
811          err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)          err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)
812          CALL MNC_HANDLE_ERR(err, msgbuf, myThid)          CALL MNC_HANDLE_ERR(err, msgbuf, myThid)

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

  ViewVC Help
Powered by ViewVC 1.1.22