/[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.23 by edhill, Thu Oct 21 13:38:45 2004 UTC revision 1.32 by edhill, Sat Sep 10 18:30:07 2005 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_BUFF.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 106  CEOP Line 107  CEOP
107    
108  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
109        integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot, indu        integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot, indu
110        integer bis,bie, bjs,bje, uniq_tnum, nfname, iseq        integer bis,bie, bjs,bje, uniq_tnum, uniq_fnum, 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 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 )        character*(MNC_MAX_CHAR) tmpnm
121        REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )        REAL*8  resh_d( MNC_MAX_BUFF )
122        INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )        REAL*4  resh_r( MNC_MAX_BUFF )
123          INTEGER resh_i( MNC_MAX_BUFF )
124  #ifdef HAVE_STAT  #ifdef HAVE_STAT
125        integer ntotenc, ncenc, nbytes, fs_isdone        integer ntotenc, ncenc, nbytes, fs_isdone
126        character*(200) cenc        character*(200) cenc
# Line 187  C         Create the file name Line 189  C         Create the file name
189            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
190            n1 = IFNBLNK(fbname)            n1 = IFNBLNK(fbname)
191            n2 = ILNBLNK(fbname)            n2 = ILNBLNK(fbname)
192    
193    #ifdef MNC_WRITE_OLDNAMES
194    
195            ntot = n2 - n1 + 1            ntot = n2 - n1 + 1
196            fname(1:ntot) = fbname(n1:n2)            fname(1:ntot) = fbname(n1:n2)
197            ntot = ntot + 1            ntot = ntot + 1
198            fname(ntot:ntot) = '.'            fname(ntot:ntot) = '.'
199            write(fname((ntot+1):(ntot+14)),'(i4.4,a1,i6.6,a3)')            IF ( mnc_use_name_ni0 ) THEN
200       &         iseq,'.',uniq_tnum, '.nc'              write(fname((ntot+1):(ntot+17)),'(i10.10,a1,i6.6)')
201            nfname = ntot + 14       &           nIter0,'.',uniq_tnum
202                write(fname((ntot+18):(ntot+25)),'(a1,i4.4,a3)')
203         &           '.', iseq, '.nc'
204                nfname = ntot + 25
205              ELSE
206                write(fname((ntot+1):(ntot+14)),'(i4.4,a1,i6.6,a3)')
207         &           iseq,'.',uniq_tnum, '.nc'
208                nfname = ntot + 14
209              ENDIF
210    
211    #else
212    
213              CALL MNC_PSNCM(tmpnm, uniq_tnum, MNC_DEF_TMNC)
214              k = ILNBLNK(tmpnm)
215              IF ( mnc_cw_cit(1,mnc_cw_fgci(indfg)) .GT. -1 ) THEN
216                write(fname,'(a,a1,i10.10,a2,a,a3)') fbname(n1:n2),
217         &           '.', mnc_cw_cit(2,mnc_cw_fgci(indfg)),
218         &           '.t',tmpnm(1:k),'.nc'
219              ELSEIF ( mnc_cw_cit(1,mnc_cw_fgci(indfg)) .EQ. -1 ) THEN
220    C           Leave off the myIter value entirely
221                write(fname,'(a,a2,a,a3)') fbname(n1:n2), '.t',
222         &           tmpnm(1:k),'.nc'
223              ELSE
224    C           We have an error--bad flag value
225                write(msgbuf,'(4a)')
226         &           'MNC_CW_RX_W ERROR: bad mnc_cw_cit(1,...) ',
227         &           'flag value for base name ''', fbname(fg1:fg2),
228         &           ''''
229                CALL print_error(msgbuf, mythid)
230                STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
231              ENDIF
232              nfname = ILNBLNK(fname)
233    
234    #endif
235    
236  C         Add the path to the file name  C         Add the path to the file name
237            IF (mnc_use_outdir) THEN            IF (mnc_use_outdir) THEN
# Line 206  C         Add the path to the file name Line 244  C         Add the path to the file name
244            ENDIF            ENDIF
245    
246  C         Append to an existing or create a new file  C         Append to an existing or create a new file
247            CALL MNC_CW_FILE_AORC(fname, indf, myThid)            CALL MNC_CW_FILE_AORC(fname,indf, lbi,lbj,uniq_tnum, myThid)
248            fid = mnc_f_info(indf,2)            fid = mnc_f_info(indf,2)
249    
250  #ifdef HAVE_STAT  #ifdef HAVE_STAT
251            IF ((mnc_cw_fgig(indfg) .EQ. 1)            IF ((mnc_cw_fgig(indfg) .EQ. 1)
252       &         .AND. (fs_isdone .EQ. 0)) THEN       &         .AND. (fs_isdone .EQ. 0)) THEN
253  C           Decide whether to append to the existing or create a new file  C           Decide whether to append to the existing or create a new
254  C           based on the byte count per unlimited dimension  C           file based on the byte count per unlimited dimension
255              ncenc = 70              ncenc = 70
256              cenc(1:26)  = 'abcdefghijklmnopqrstuvwxyz'              cenc(1:26)  = 'abcdefghijklmnopqrstuvwxyz'
257              cenc(27:52) = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'              cenc(27:52) = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
# Line 237  C           based on the byte count per Line 275  C           based on the byte count per
275                fsnu = (1.0 _d 0 + 1.0 _d 0 / DBLE(unlim_sz))                fsnu = (1.0 _d 0 + 1.0 _d 0 / DBLE(unlim_sz))
276       &             * DBLE(nbytes)       &             * DBLE(nbytes)
277                IF (fsnu .GT. mnc_max_fsize) THEN                IF (fsnu .GT. mnc_max_fsize) THEN
278                  iseq = iseq + 1  C               Delete the now-full fname from the lookup tables since
279    C               we are all done writing to it.
280                    CALL MNC_FILE_CLOSE(fname, myThid)
281                  indu = 1                  indu = 1
282                  mnc_cw_fgud(indfg) = 1                  mnc_cw_fgud(indfg) = 1
283    
284    #ifdef MNC_WRITE_OLDNAMES
285                    iseq = iseq + 1
286                  mnc_cw_fgis(indfg) = iseq                  mnc_cw_fgis(indfg) = iseq
287    #else
288                    IF (mnc_cw_cit(1,mnc_cw_fgci(indfg)) .LT. 0) THEN
289                      write(msgbuf,'(5a)')
290         &            'MNC_CW_RX_W ERROR: output file for base name ''',
291         &            fbname(fg1:fg2), ''' is about to exceed the max ',
292         &            'file size and is NOT ALLOWED an iteration value ',
293         &            'within its file name'
294                      CALL print_error(msgbuf, mythid)
295                      STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
296                    ELSEIF (mnc_cw_cit(3,mnc_cw_fgci(indfg)) .LT. 0) THEN
297                      write(msgbuf,'(5a)')
298         &            'MNC_CW_RX_W ERROR: output file for base name ''',
299         &            fbname(fg1:fg2), ''' is about to exceed the max ',
300         &            'file size and no next-iter has been specified--',
301         &            'please see the MNC CITER functions'
302                      CALL print_error(msgbuf, mythid)
303                      STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
304                    ENDIF
305                    mnc_cw_cit(2,mnc_cw_fgci(indfg))
306         &               = mnc_cw_cit(3,mnc_cw_fgci(indfg))
307                    mnc_cw_cit(3,mnc_cw_fgci(indfg)) = -1
308    #endif
309                  fs_isdone = 1                  fs_isdone = 1
310                  GOTO 10                  GOTO 10
311    
312                ENDIF                ENDIF
313              ENDIF              ENDIF
314            ENDIF            ENDIF
# Line 259  C         local copy of them Line 325  C         local copy of them
325              ELSE              ELSE
326                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
327              ENDIF              ENDIF
328              CALL MNC_DIM_INIT(fname,  
329       &           mnc_cw_dn(i,igrid), dimnc(i), myThid)  C           Add the coordinate variables
330                CALL MNC_DIM_INIT_ALL_CV(fname,
331         &           mnc_cw_dn(i,igrid), dimnc(i), 'Y', lbi,lbj, myThid)
332    
333            ENDDO            ENDDO
334    
335  C         Ensure that the "grid" is defined  C         Ensure that the "grid" is defined
# Line 369  C         Check the offsets Line 438  C         Check the offsets
438              ENDIF              ENDIF
439            ENDDO            ENDDO
440    
 C         Add the global attributes  
           CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid)  
   
441  C         Add the per-variable attributes  C         Add the per-variable attributes
442            DO i = 1,mnc_cw_vnat(1,indv)            DO i = 1,mnc_cw_vnat(1,indv)
443              CALL MNC_VAR_ADD_ATTR_STR( fname, vtype,              CALL MNC_VAR_ADD_ATTR_STR( fname, vtype,
# Line 427  C         Write the variable one vector Line 493  C         Write the variable one vector
493        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
494        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
495    
496          IF (vcount(1) .GT. MNC_MAX_BUFF) THEN
497            write(msgbuf,'(2a,I7,a)') 'MNC_MAX_BUFF is too small',
498         &       '--please increase to at least ',
499         &       vcount(1), ' in ''MNC_BUFF.h'''
500            CALL PRINT_ERROR(msgBuf , 1)
501            STOP 'ABNORMAL END: S/R MNC_CW_RX_W_OFFSET'
502          ENDIF
503    
504        IF (stype(1:1) .EQ. 'D') THEN        IF (stype(1:1) .EQ. 'D') THEN
505          DO j1 = s(1),e(1)          DO j1 = s(1),e(1)
506            k1 = k2 + j1            k1 = k2 + j1
# Line 447  C         Write the variable one vector Line 521  C         Write the variable one vector
521          DO j1 = s(1),e(1)          DO j1 = s(1),e(1)
522            k1 = k2 + j1            k1 = k2 + j1
523            kr = kr + 1            kr = kr + 1
524            resh_i(kr) = var(k1)            resh_i(kr) = MNC2I( var(k1) )
525          ENDDO          ENDDO
526          err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh_i)          err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh_i)
527        ENDIF        ENDIF
# Line 530  C     !USES: Line 604  C     !USES:
604  #include "netcdf.inc"  #include "netcdf.inc"
605  #include "mnc_common.h"  #include "mnc_common.h"
606  #include "SIZE.h"  #include "SIZE.h"
607    #include "MNC_BUFF.h"
608  #include "EEPARAMS.h"  #include "EEPARAMS.h"
609  #include "PARAMS.h"  #include "PARAMS.h"
610  #include "MNC_PARAMS.h"  #include "MNC_PARAMS.h"
# Line 542  CEOP Line 617  CEOP
617    
618  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
619        integer i,k, nvf,nvl, n1,n2, igrid, ntot, indu        integer i,k, nvf,nvl, n1,n2, igrid, ntot, indu
620        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv        integer bis,bie, bjs,bje, uniq_tnum,uniq_fnum, nfname, fid, idv
621        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr        integer ndim, err, lbi,lbj, bidim,bjdim, unlim_sz, kr
622        integer ind_fv_ids, ind_vt, ierr, atype, alen        integer ind_vt, npath, unlid, f_or_t, ixoff,iyoff
623        integer f_sNx,f_sNy, npath  C     integer f_sNx,f_sNy, alen, atype, ind_fv_ids, ierr, indf
624        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)
625        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
626        character*(MAX_LEN_MBUF) msgbuf        character*(MAX_LEN_MBUF) msgbuf
627        character*(MNC_MAX_CHAR) fname        character*(MNC_MAX_CHAR) fname
628          character*(MNC_MAX_CHAR) fname_zs
629          character*(MNC_MAX_CHAR) tmpnm
630        character*(MNC_MAX_CHAR) path_fname        character*(MNC_MAX_CHAR) path_fname
631        integer indfg, fg1,fg2        integer indfg, fg1,fg2
632        REAL*8  resh_d( sNx + 2*OLx + sNy + 2*OLy )        REAL*8  resh_d( MNC_MAX_BUFF )
633        REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )        REAL*4  resh_r( MNC_MAX_BUFF )
634        INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )        INTEGER resh_i( MNC_MAX_BUFF )
635    
636  C     Functions  C     Functions
637        integer IFNBLNK, ILNBLNK        integer IFNBLNK, ILNBLNK
# Line 612  C     Set the bi,bj indicies Line 689  C     Set the bi,bj indicies
689  C         Create the file name  C         Create the file name
690            CALL MNC_CW_GET_TILE_NUM( lbi,lbj, uniq_tnum, myThid)            CALL MNC_CW_GET_TILE_NUM( lbi,lbj, uniq_tnum, myThid)
691            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)            fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
692    
693    #ifdef MNC_READ_OLDNAMES
694    
695            n1 = IFNBLNK(fbname)            n1 = IFNBLNK(fbname)
696            n2 = ILNBLNK(fbname)            n2 = ILNBLNK(fbname)
697            ntot = n2 - n1 + 1            ntot = n2 - n1 + 1
# Line 631  C         Add the path to the file name Line 711  C         Add the path to the file name
711              nfname = npath + nfname              nfname = npath + nfname
712            ENDIF            ENDIF
713    
714  C         Open the existing file            WRITE(fname_zs,'(2a,i4.4,a1,i6.6,a3)')
715            CALL MNC_FILE_TRY_READ( fname, ierr, indf, myThid)       &         mnc_indir_str(1:npath), fbname(n1:n2),
716         &         0, '.', uniq_tnum, '.nc'
717    
718    C         The steps are:
719    C         (1) open the file in a READ-ONLY mode,
720    C         (2) get the var id for the current variable,
721    C         (3) read the data, and then
722    C         (4) close the file--theres no need to keep it open!
723    
724              write(msgbuf,'(4a)') 'MNC_CW_RX_R: cannot open',
725         &         ' file ''', fname(1:nfname), ''' in read-only mode'
726              err = NF_OPEN(fname, NF_NOWRITE, fid)
727              IF ( err .NE. NF_NOERR ) THEN
728    C           If the initial open fails, try again using a name with a
729    C           zero sequence number inserted
730                err = NF_OPEN(fname_zs, NF_NOWRITE, fid)
731              ENDIF
732              CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
733    
734              write(msgbuf,'(5a)')
735         &         'MNC_CW_RX_R: cannot get id for variable ''',
736         &         vtype(nvf:nvl), '''in file ''', fname(1:nfname), ''''
737              err = NF_INQ_VARID(fid, vtype, idv)
738              CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
739              f_or_t = 0
740    
741    #else
742    
743    C         The sequence for PER-FACE and PER-TILE is:
744    C         (1) check whether a PER-FACE file exists
745    C         .   (a) if only one face is used for the entire domain,
746    C         .       then omit the face index from the file name
747    C         .   (b) if the PER-FACE file exists and is somehow faulty,
748    C         .       then we die with an error message
749    C         (2) if no PER-FACE file exists, then use a PER-TILE file
750    
751    C         Create the PER-FACE file name
752              n1 = IFNBLNK(fbname)
753              n2 = ILNBLNK(fbname)
754    C         Add an iteraton count to the file name if its requested
755              IF (mnc_cw_cit(1,mnc_cw_fgci(indfg)) .LT. 0) THEN
756                WRITE(fname,'(a,a1)') fbname(n1:n2), '.'
757              ELSE
758                WRITE(fname,'(a,a1,i10.10,a1)') fbname(n1:n2), '.',
759         &            mnc_cw_cit(2,mnc_cw_fgci(indfg)), '.'
760              ENDIF
761              ntot = ILNBLNK(fname)
762              path_fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
763              npath = ILNBLNK(mnc_indir_str)
764    C         Add the face index
765              CALL MNC_CW_GET_FACE_NUM( lbi,lbj, uniq_fnum, myThid)
766              IF ( uniq_fnum .EQ. -1 ) THEN
767    C           There is only one face
768                WRITE(path_fname,'(2a,a2)')
769         &           mnc_indir_str(1:npath), fname(1:ntot), 'nc'
770              ELSE
771                CALL MNC_PSNCM(tmpnm, uniq_fnum, MNC_DEF_FMNC)
772                k = ILNBLNK(tmpnm)
773                WRITE(path_fname,'(2a,a1,a,a3)')
774         &           mnc_indir_str(1:npath), fname(1:ntot), 'f',
775         &           tmpnm(1:k), '.nc'
776              ENDIF
777    
778    C         Try to open the PER-FACE file
779              err = NF_OPEN(path_fname, NF_NOWRITE, fid)
780              IF ( err .EQ. NF_NOERR ) THEN
781                f_or_t = 0
782              ELSE
783    
784    C           Create the PER-TILE file name
785                CALL MNC_PSNCM(tmpnm, uniq_tnum, MNC_DEF_TMNC)
786                k = ILNBLNK(tmpnm)
787                path_fname(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR)
788                WRITE(path_fname,'(2a,a1,a,a3)')
789         &           mnc_indir_str(1:npath), fname(1:ntot), 't',
790         &           tmpnm(1:k), '.nc'
791                err = NF_OPEN(path_fname, NF_NOWRITE, fid)
792                IF ( err .EQ. NF_NOERR ) THEN
793                  f_or_t = 1
794                ELSE
795                  k = ILNBLNK(path_fname)
796                  write(msgbuf,'(4a)')
797         &             'MNC_CW_RX_R: cannot open either a per-face or a ',
798         &             'per-tile file: last try was ''', path_fname(1:k),
799         &             ''''
800                  CALL print_error(msgbuf, mythid)
801                  STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
802                ENDIF
803    
804              ENDIF
805    
806              ntot = ILNBLNK(path_fname)
807              write(msgbuf,'(5a)')
808         &         'MNC_CW_RX_R: cannot get netCDF id for variable ''',
809         &         vtype(nvf:nvl), ''' in file ''', path_fname(1:ntot),
810         &         ''''
811              err = NF_INQ_VARID(fid, vtype, idv)
812              CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
813    
814    #endif
815    
816  C         Check that the variable (VType) is defined within the file            IF ( f_or_t .EQ. 1 ) THEN
817            CALL MNC_GET_FVINDS( fname, vtype, indf, ind_fv_ids, myThid)              write(msgbuf,'(4a)')
818            IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN       &           'MNC_CW_RX_R: per-face reads are not yet ',
819              write(msgbuf,'(4a)') 'MNC_CW_RX_R ERROR: vtype ''',       &           'implemented -- so pester Ed to finish them'
      &           vtype(nvf:nvl), ''' is not defined within file ''',  
      &           fname(1:nfname)  
820              CALL print_error(msgbuf, mythid)              CALL print_error(msgbuf, mythid)
821              STOP 'ABNORMAL END: S/R MNC_CW_RX_R'              STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
822    
823    C           Get the X,Y PER-FACE offsets
824                CALL MNC_CW_GET_XYFO(lbi,lbj, ixoff,iyoff, myThid)
825    
826            ENDIF            ENDIF
           fid = mnc_f_info(indf,2)  
           idv = mnc_fv_ids(indf,ind_fv_ids+1)  
827    
828  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
829  C         are compatible and WARN (only warn) if not  C         are compatible and WARN (only warn) if not
830            f_sNx = -1  C           f_sNx = -1
831            f_sNy = -1  C           f_sNy = -1
832            err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNx',atype,alen)  C           err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNx',atype,alen)
833            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN  C           IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN
834              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx)  C             err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx)
835              CALL MNC_HANDLE_ERR(err,  C             CALL MNC_HANDLE_ERR(err,
836       &           'reading attribute ''sNx'' in S/R MNC_CW_RX_R',  C      &           'reading attribute ''sNx'' in S/R MNC_CW_RX_R',
837       &           myThid)  C      &           myThid)
838            ENDIF  C           ENDIF
839            err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen)  C           err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen)
840            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN  C           IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN
841              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy)  C             err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy)
842              CALL MNC_HANDLE_ERR(err,  C             CALL MNC_HANDLE_ERR(err,
843       &           'reading attribute ''sNy'' in S/R MNC_CW_RX_R',  C      &           'reading attribute ''sNy'' in S/R MNC_CW_RX_R',
844       &           myThid)  C      &           myThid)
845            ENDIF  C           ENDIF
846            IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN  C           IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN
847              write(msgbuf,'(5a)') 'MNC_CW_RX_R WARNING: the ',  C             write(msgbuf,'(5a)') 'MNC_CW_RX_R WARNING: the ',
848       &           'attributes ''sNx'' and ''sNy'' within the file ''',  C      &           'attributes ''sNx'' and ''sNy'' within the file ''',
849       &           fname(1:nfname), ''' do not exist or do not match ',  C      &           fname(1:nfname), ''' do not exist or do not match ',
850       &           'the current sizes within the model'  C      &           'the current sizes within the model'
851              CALL print_error(msgbuf, mythid)  C             CALL print_error(msgbuf, mythid)
852            ENDIF  C           ENDIF
853    
854  C         Check that the in-memory variable and the in-file variables  C         Check that the in-memory variable and the in-file variables
855  C         are of compatible sizes  C         are of compatible sizes
# Line 722  C         the unlimited dimension offset Line 901  C         the unlimited dimension offset
901              IF (i .LE. ndim) THEN              IF (i .LE. ndim) THEN
902                s(i) = mnc_cw_is(i,igrid)                s(i) = mnc_cw_is(i,igrid)
903                e(i) = mnc_cw_ie(i,igrid)                e(i) = mnc_cw_ie(i,igrid)
904    
905                  IF ( f_or_t .EQ. 1 ) THEN
906    C               Add the per-face X,Y offsets to the udo offset vector
907    C               since they accomplish the same thing
908                    IF ( mnc_cw_dn(i,igrid)(1:1) .EQ. 'X' ) THEN
909                      udo(i) = ixoff - 1
910                    ELSEIF ( mnc_cw_dn(i,igrid)(1:1) .EQ. 'Y' ) THEN
911                      udo(i) = iyoff - 1
912                    ENDIF
913                  ENDIF
914    
915              ENDIF              ENDIF
916  C           Check for the unlimited dimension  C           Check for the unlimited dimension
917              IF ((i .EQ. ndim)              IF ((i .EQ. ndim)
# Line 729  C           Check for the unlimited dime Line 919  C           Check for the unlimited dime
919                IF (indu .GT. 0) THEN                IF (indu .GT. 0) THEN
920  C               Use the indu value  C               Use the indu value
921                  udo(i) = indu - 1                  udo(i) = indu - 1
               ELSEIF (indu .EQ. -1) THEN  
 C               Append one to the current unlimited dim size  
                 CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid)  
                 udo(i) = unlim_sz  
922                ELSE                ELSE
923  C               Use the current unlimited dim size  C               We need the current unlim dim size
924                  CALL MNC_DIM_UNLIM_SIZE( fname, unlim_sz, myThid)                  write(msgbuf,'(5a)') 'MNC_CW_RX_R: getting the ',
925                  udo(i) = unlim_sz - 1       &               'unlim dim id within file ''',
926         &               fname(1:nfname), ''''
927                    err = NF_INQ_UNLIMDIM(fid, unlid)
928                    CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
929                    write(msgbuf,'(5a)') 'MNC_CW_RX_R: getting the ',
930         &               'unlim dim size within file ''',
931         &               fname(1:nfname), ''''
932                    err = NF_INQ_DIMLEN(fid, unlid, unlim_sz)
933                    CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
934                    udo(i) = unlim_sz
935                ENDIF                ENDIF
936              ENDIF              ENDIF
937            ENDDO            ENDDO
# Line 753  C     DO i = 9,1,-1 Line 948  C     DO i = 9,1,-1
948  C     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)
949  C     ENDDO  C     ENDDO
950                        
           CALL MNC_FILE_ENDDEF(fname, myThid)  
   
951            write(msgbuf,'(5a)') 'reading variable type ''',            write(msgbuf,'(5a)') 'reading variable type ''',
952       &         vtype(nvf:nvl), ''' within file ''',       &         vtype(nvf:nvl), ''' within file ''',
953       &         fname(1:nfname), ''''       &         fname(1:nfname), ''''
# Line 788  C         Read the variable one vector a Line 981  C         Read the variable one vector a
981        kr = 0        kr = 0
982        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
983        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
984          
985          IF (vcount(1) .GT. MNC_MAX_BUFF) THEN
986            write(msgbuf,'(2a,I7,a)') 'MNC_MAX_BUFF is too small',
987         &       '--please increase to at least ',
988         &       vcount(1), ' in ''MNC_BUFF.h'''
989            CALL PRINT_ERROR(msgBuf , 1)
990            STOP 'ABNORMAL END: S/R MNC_CW_RX_R_OFFSET'
991          ENDIF
992    
993        IF (stype(1:1) .EQ. 'D') THEN        IF (stype(1:1) .EQ. 'D') THEN
994          err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)          err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)
995          CALL MNC_HANDLE_ERR(err, msgbuf, myThid)          CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
996          DO j1 = s(1),e(1)          DO j1 = s(1),e(1)
997            k1 = k2 + j1            k1 = k2 + j1
998            kr = kr + 1            kr = kr + 1
999            var(k1) = resh_d(kr)            var(k1) = MNCI2( resh_d(kr) )
1000          ENDDO          ENDDO
1001        ENDIF        ENDIF
1002        IF (stype(1:1) .EQ. 'R') THEN        IF (stype(1:1) .EQ. 'R') THEN
# Line 804  C         Read the variable one vector a Line 1005  C         Read the variable one vector a
1005          DO j1 = s(1),e(1)          DO j1 = s(1),e(1)
1006            k1 = k2 + j1            k1 = k2 + j1
1007            kr = kr + 1            kr = kr + 1
1008            var(k1) = resh_r(kr)            var(k1) = MNCI2( resh_r(kr) )
1009          ENDDO          ENDDO
1010        ENDIF        ENDIF
1011        IF (stype(1:1) .EQ. 'I') THEN        IF (stype(1:1) .EQ. 'I') THEN
# Line 817  C         Read the variable one vector a Line 1018  C         Read the variable one vector a
1018          ENDDO          ENDDO
1019        ENDIF        ENDIF
1020    
         
1021    
1022                      ENDDO                      ENDDO
1023                    ENDDO                    ENDDO
# Line 827  C         Read the variable one vector a Line 1027  C         Read the variable one vector a
1027            ENDDO            ENDDO
1028    
1029  C         Close the file  C         Close the file
1030            CALL MNC_FILE_CLOSE(fname, myThid)  C         CALL MNC_FILE_CLOSE(fname, myThid)
1031              err = NF_CLOSE(fid)
1032              write(msgbuf,'(3a)') 'MNC_CW_RX_R:  cannot close file ''',
1033         &         fname(1:nfname), ''''
1034              CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
1035    
1036    
1037  C         End the lbj,lbi loops  C         End the lbj,lbi loops
1038          ENDDO          ENDDO

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

  ViewVC Help
Powered by ViewVC 1.1.22