/[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.22 by edhill, Wed Oct 20 21:26:14 2004 UTC revision 1.26 by edhill, Fri Dec 17 04:50:05 2004 UTC
# Line 93  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"  #include "MNC_PARAMS.h"
# Line 116  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 140  C     group (or base) name Line 147  C     group (or base) name
147        ENDIF        ENDIF
148        indu = mnc_cw_fgud(indfg)        indu = mnc_cw_fgud(indfg)
149        iseq = mnc_cw_fgis(indfg)        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 170  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 194  C         Add the path to the file name Line 207  C         Add the path to the file name
207            ENDIF            ENDIF
208    
209  C         Append to an existing or create a new file  C         Append to an existing or create a new file
210            CALL MNC_CW_FILE_AORC(fname, indf, myThid)            CALL MNC_CW_FILE_AORC(fname,indf, lbi,lbj,uniq_tnum, 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
217    C           file 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    C               Delete the now-full fname from the lookup tables since
242    C               we are all done writing to it.
243                    CALL MNC_FILE_CLOSE(fname, myThid)
244                    iseq = iseq + 1
245                    indu = 1
246                    mnc_cw_fgud(indfg) = 1
247                    mnc_cw_fgis(indfg) = iseq
248                    fs_isdone = 1
249                    GOTO 10
250                  ENDIF
251                ENDIF
252              ENDIF
253    #endif  /*  HAVE_STAT  */
254    
255  C         Ensure that all the NetCDF dimensions are defined and create a  C         Ensure that all the NetCDF dimensions are defined and create a
256  C         local copy of them  C         local copy of them
257            DO i = 1,9            DO i = 1,9
# Line 210  C         local copy of them Line 265  C         local copy of them
265              ENDIF              ENDIF
266              CALL MNC_DIM_INIT(fname,              CALL MNC_DIM_INIT(fname,
267       &           mnc_cw_dn(i,igrid), dimnc(i), myThid)       &           mnc_cw_dn(i,igrid), dimnc(i), myThid)
268    
269    C           Add the coordinate variables
270    C           CALL MNC_CW_ADD_CVAR(fname, mnc_cw_dn(i,igrid),
271    C                                dimnc(i), myThid)
272    
273            ENDDO            ENDDO
274    
275  C         Ensure that the "grid" is defined  C         Ensure that the "grid" is defined
# Line 233  C         Ensure that the variable is de Line 293  C         Ensure that the variable is de
293                idv = mnc_fv_ids(indf,j+1)                idv = mnc_fv_ids(indf,j+1)
294                indvids = mnc_fd_ind(indf, mnc_f_info(indf,                indvids = mnc_fd_ind(indf, mnc_f_info(indf,
295       &             (mnc_fv_ids(indf,j+2) + 1)) )       &             (mnc_fv_ids(indf,j+2) + 1)) )
296                GOTO 10                GOTO 30
297              ENDIF              ENDIF
298            ENDDO            ENDDO
299            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ',            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ',
300       &         'cannot reference variable ''', vtype, ''''       &         'cannot reference variable ''', vtype, ''''
301            CALL print_error(msgbuf, mythid)            CALL print_error(msgbuf, mythid)
302            STOP 'ABNORMAL END: package MNC'            STOP 'ABNORMAL END: package MNC'
303   10       CONTINUE   30       CONTINUE
304    
305  C         Check for bi,bj indicies  C         Check for bi,bj indicies
306            bidim = mnc_cw_vbij(1,indv)            bidim = mnc_cw_vbij(1,indv)
# Line 318  C         Check the offsets Line 378  C         Check the offsets
378              ENDIF              ENDIF
379            ENDDO            ENDDO
380    
 C         Add the global attributes  
           CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid)  
   
381  C         Add the per-variable attributes  C         Add the per-variable attributes
382            DO i = 1,mnc_cw_vnat(1,indv)            DO i = 1,mnc_cw_vnat(1,indv)
383              CALL MNC_VAR_ADD_ATTR_STR( fname, vtype,              CALL MNC_VAR_ADD_ATTR_STR( fname, vtype,
# Line 376  C         Write the variable one vector Line 433  C         Write the variable one vector
433        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
434        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
435    
436          IF (vcount(1) .GT. MNC_MAX_BUFF) THEN
437            write(msgbuf,'(2a,I7,a)') 'MNC_MAX_BUFF is too small',
438         &       '--please increase to at least ',
439         &       vcount(1), ' in ''MNC_SIZE.h'''
440            CALL PRINT_ERROR(msgBuf , 1)
441            STOP 'ABNORMAL END: S/R MNC_CW_RX_W_OFFSET'
442          ENDIF
443    
444        IF (stype(1:1) .EQ. 'D') THEN        IF (stype(1:1) .EQ. 'D') THEN
445          DO j1 = s(1),e(1)          DO j1 = s(1),e(1)
446            k1 = k2 + j1            k1 = k2 + j1
# Line 479  C     !USES: Line 544  C     !USES:
544  #include "netcdf.inc"  #include "netcdf.inc"
545  #include "mnc_common.h"  #include "mnc_common.h"
546  #include "SIZE.h"  #include "SIZE.h"
547    #include "MNC_SIZE.h"
548  #include "EEPARAMS.h"  #include "EEPARAMS.h"
549  #include "PARAMS.h"  #include "PARAMS.h"
550  #include "MNC_PARAMS.h"  #include "MNC_PARAMS.h"
# Line 501  C     !LOCAL VARIABLES: Line 567  C     !LOCAL VARIABLES:
567        character*(MNC_MAX_CHAR) fname        character*(MNC_MAX_CHAR) fname
568        character*(MNC_MAX_CHAR) path_fname        character*(MNC_MAX_CHAR) path_fname
569        integer indfg, fg1,fg2        integer indfg, fg1,fg2
570        REAL*8  resh_d( sNx + 2*OLx + sNy + 2*OLy )        REAL*8  resh_d( MNC_MAX_BUFF )
571        REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )        REAL*4  resh_r( MNC_MAX_BUFF )
572        INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )        INTEGER resh_i( MNC_MAX_BUFF )
573    
574  C     Functions  C     Functions
575        integer IFNBLNK, ILNBLNK        integer IFNBLNK, ILNBLNK
# Line 737  C         Read the variable one vector a Line 803  C         Read the variable one vector a
803        kr = 0        kr = 0
804        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
805        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
806          
807          IF (vcount(1) .GT. MNC_MAX_BUFF) THEN
808            write(msgbuf,'(2a,I7,a)') 'MNC_MAX_BUFF is too small',
809         &       '--please increase to at least ',
810         &       vcount(1), ' in ''MNC_SIZE.h'''
811            CALL PRINT_ERROR(msgBuf , 1)
812            STOP 'ABNORMAL END: S/R MNC_CW_RX_R_OFFSET'
813          ENDIF
814    
815        IF (stype(1:1) .EQ. 'D') THEN        IF (stype(1:1) .EQ. 'D') THEN
816          err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)          err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)
817          CALL MNC_HANDLE_ERR(err, msgbuf, myThid)          CALL MNC_HANDLE_ERR(err, msgbuf, myThid)

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.22