/[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.10 by edhill, Sun Mar 21 03:44:23 2004 UTC revision 1.20 by edhill, Fri Oct 8 17:03:21 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 0
8    C !ROUTINE: MNC_CW_RX_W_S
9    
10        SUBROUTINE MNC_CW_RX_W_YY(  C !INTERFACE:
11          SUBROUTINE MNC_CW_RX_W_S(
12         I     stype,
13       I     fbname, bi,bj,       I     fbname, bi,bj,
14       I     vtype,       I     vtype,
 C     I     indu,  
15       I     var,       I     var,
16       I     myThid )       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        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
41    
42    C !INTERFACE:
43          SUBROUTINE MNC_CW_RX_W(
44         I     stype,
45         I     fbname, bi,bj,
46         I     vtype,
47         I     var,
48         I     myThid )
49    
50    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          __V var_arr(1)
62          INTEGER offsets(9)
63    CEOP
64          INTEGER i
65    
66          DO i = 1,9
67            offsets(i) = 0
68          ENDDO
69          var_arr(1) = var
70          CALL MNC_CW_RX_W_OFFSET(stype,fbname,bi,bj,vtype, var_arr,
71         &     offsets, myThid)
72    
73          RETURN
74          END
75    
76    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
77    CBOP 0
78    C !ROUTINE: MNC_CW_RX_W_OFFSET
79    
80    C !INTERFACE:
81          SUBROUTINE MNC_CW_RX_W_OFFSET(
82         I     stype,
83         I     fbname, bi,bj,
84         I     vtype,
85         I     var,
86         I     offsets,
87         I     myThid )
88    
89    C     !DESCRIPTION:
90    C     This subroutine writes one variable to a file or a file group,
91    C     depending upon the tile indicies.
92          
93    C     !USES:
94          implicit none
95  #include "netcdf.inc"  #include "netcdf.inc"
96  #include "mnc_common.h"  #include "mnc_common.h"
 #include "EEPARAMS.h"  
97  #include "SIZE.h"  #include "SIZE.h"
98    #include "EEPARAMS.h"
99    #include "PARAMS.h"
100    #include "MNC_PARAMS.h"
101    
102  #define mnc_rtype_YY  C     !INPUT PARAMETERS:
103          integer myThid, bi,bj
104  C     Arguments        character*(*) stype, fbname, vtype
       integer myThid, bi,bj, indu  
       character*(*) fbname, vtype  
105        __V var(*)        __V var(*)
106          INTEGER offsets(*)
107    CEOP
108    
109  C     Functions  C     !LOCAL VARIABLES:
110        integer IFNBLNK, ILNBLNK        integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot, indu
111          integer bis,bie, bjs,bje, uniq_tnum, nfname
112  C     Local Variables        integer fid, idv, indvids, ndim, indf, err
113        integer i,j,k, indv,nvf,nvl, n1,n2, igrid, ntot        integer lbi,lbj, bidim,bjdim, unlim_sz, kr
114        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv, indvids        integer p(9),s(9),e(9), dimnc(9)
115        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr        integer vstart(9),vcount(9), udo(9)
       integer p(9),s(9),e(9), dimnc(9), vstart(9),vcount(9), udo(9)  
116        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
117        integer indfg, fg1,fg2        integer indfg, fg1,fg2, npath
118        character*(MAX_LEN_MBUF) msgbuf        character*(MAX_LEN_MBUF) msgbuf
119        character*(MNC_MAX_CHAR) fname        character*(MNC_MAX_CHAR) fname
120          character*(MNC_MAX_CHAR) path_fname
121          REAL*8  resh_d( sNx + 2*OLx + sNy + 2*OLy )
122          REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )
123          INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )
124    
125  C     Temporary storage for the simultaneous type conversion and  C     Functions
126  C     re-shaping before passing to NetCDF        integer IFNBLNK, ILNBLNK
 #ifdef  mnc_rtype_D  
       REAL*8  resh( sNx + 2*OLx + sNy + 2*OLy )  
 #endif  
 #ifdef  mnc_rtype_R  
       REAL*4  resh( sNx + 2*OLx + sNy + 2*OLy )  
 #endif  
 #ifdef  mnc_rtype_I  
       INTEGER resh( sNx + 2*OLx + sNy + 2*OLy )  
 #endif  
127    
128  C     Only do I/O if I am the master thread  C     Only do I/O if I am the master thread
129        _BEGIN_MASTER( myThid )        _BEGIN_MASTER( myThid )
# Line 61  C     group (or base) name Line 135  C     group (or base) name
135        CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid)        CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid)
136        IF (indfg .LT. 1) THEN        IF (indfg .LT. 1) THEN
137          write(msgbuf,'(3a)')          write(msgbuf,'(3a)')
138       &       'MNC_CW_RX_W_YY ERROR: file group name ''',       &       'MNC_CW_RX_W ERROR: file group name ''',
139       &       fbname(fg1:fg2), ''' is not defined'       &       fbname(fg1:fg2), ''' is not defined'
140          CALL print_error(msgbuf, mythid)          CALL print_error(msgbuf, mythid)
141          STOP 'ABNORMAL END: S/R MNC_CW_RX_W_YY'          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
142        ENDIF        ENDIF
143        indu = mnc_cw_fgud(indfg)        indu = mnc_cw_fgud(indfg)
144    
# Line 73  C     Check that the Variable Type exist Line 147  C     Check that the Variable Type exist
147        nvl = ILNBLNK(vtype)        nvl = ILNBLNK(vtype)
148        CALL MNC_GET_IND(MNC_MAX_ID, vtype, mnc_cw_vname, indv, myThid)        CALL MNC_GET_IND(MNC_MAX_ID, vtype, mnc_cw_vname, indv, myThid)
149        IF (indv .LT. 1) THEN        IF (indv .LT. 1) THEN
150          write(msgbuf,'(3a)') 'MNC_CW_RX_W_YY ERROR: vtype ''',          write(msgbuf,'(3a)') 'MNC_CW_RX_W ERROR: vtype ''',
151       &       vtype(nvf:nvl), ''' is not defined'       &       vtype(nvf:nvl), ''' is not defined'
152          CALL print_error(msgbuf, mythid)          CALL print_error(msgbuf, mythid)
153          STOP 'ABNORMAL END: S/R MNC_CW_RX_W_YY'          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
154        ENDIF        ENDIF
155        igrid = mnc_cw_vgind(indv)        igrid = mnc_cw_vgind(indv)
156    
# Line 109  C         Create the file name Line 183  C         Create the file name
183            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'
184            nfname = ntot+9            nfname = ntot+9
185    
186    C         Add the path to the file name
187              IF (mnc_use_outdir) THEN
188                path_fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
189                npath = ILNBLNK(mnc_out_path)
190                path_fname(1:npath) = mnc_out_path(1:npath)
191                path_fname((npath+1):(npath+nfname)) = fname(1:nfname)
192                fname(1:MNC_MAX_CHAR) = path_fname(1:MNC_MAX_CHAR)
193                nfname = npath + nfname
194              ENDIF
195    
196  C         Append to an existing or create a new file  C         Append to an existing or create a new file
197            CALL MNC_CW_FILE_AORC(fname, indf, myThid)            CALL MNC_CW_FILE_AORC(fname, indf, myThid)
198            fid = mnc_f_info(indf,2)            fid = mnc_f_info(indf,2)
# Line 133  C         Ensure that the "grid" is defi Line 217  C         Ensure that the "grid" is defi
217       &        mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid), myThid)       &        mnc_cw_ndim(igrid), mnc_cw_dn(1,igrid), myThid)
218    
219  C         Ensure that the variable is defined  C         Ensure that the variable is defined
220  #ifdef  mnc_rtype_D            IF (stype(1:1) .EQ. 'D')
221        CALL MNC_VAR_INIT_DBL(fname,mnc_cw_gname(igrid),vtype, myThid)       &         CALL MNC_VAR_INIT_DBL(
222  #endif       &         fname, mnc_cw_gname(igrid), vtype, myThid)
223  #ifdef  mnc_rtype_R            IF (stype(1:1) .EQ. 'R')
224        CALL MNC_VAR_INIT_REAL(fname,mnc_cw_gname(igrid),vtype, myThid)       &         CALL MNC_VAR_INIT_REAL(
225  #endif       &         fname, mnc_cw_gname(igrid), vtype, myThid)
226  #ifdef  mnc_rtype_I            IF (stype(1:1) .EQ. 'I')
227        CALL MNC_VAR_INIT_INT(fname,mnc_cw_gname(igrid),vtype, myThid)       &         CALL MNC_VAR_INIT_INT(
228  #endif       &         fname, mnc_cw_gname(igrid), vtype, myThid)
229    
230            DO i = 1,mnc_fv_ids(indf,1)            DO i = 1,mnc_fv_ids(indf,1)
231              j = 2 + 3*(i - 1)              j = 2 + 3*(i - 1)
232              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 151  C         Ensure that the variable is de Line 236  C         Ensure that the variable is de
236                GOTO 10                GOTO 10
237              ENDIF              ENDIF
238            ENDDO            ENDDO
239            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W_YY ERROR: ',            write(msgbuf,'(4a)') 'MNC_MNC_CW_RX_W ERROR: ',
240       &         'cannot reference variable ''', vtype, ''''       &         'cannot reference variable ''', vtype, ''''
241            CALL print_error(msgbuf, mythid)            CALL print_error(msgbuf, mythid)
242            STOP 'ABNORMAL END: package MNC'            STOP 'ABNORMAL END: package MNC'
# Line 182  C         Set the dimensions for the in- Line 267  C         Set the dimensions for the in-
267              ELSE              ELSE
268                p(i) = k * p(i-1)                p(i) = k * p(i-1)
269              ENDIF              ENDIF
270                IF (offsets(i) .GT. 0) THEN
271                  k = 1
272                  p(i) = k * p(i-1)
273                ENDIF
274            ENDDO            ENDDO
275    
276  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 219  C               Use the current unlimite Line 308  C               Use the current unlimite
308              s(bjdim) = lbj              s(bjdim) = lbj
309              e(bjdim) = lbj              e(bjdim) = lbj
310            ENDIF            ENDIF
311  CEH3      DO i = 1,9            
312  CEH3        write(*,*) 'i,p(i),s(i),e(i) = ', i,p(i),s(i),e(i)  C         Check the offsets
313  CEH3      ENDDO            DO i = 1,9
314                IF (offsets(i) .GT. 0) THEN
315                  udo(i) = udo(i) + offsets(i) - 1
316                  s(i) = 1
317                  e(i) = 1
318                ENDIF
319              ENDDO
320    
321  C         Add the global attributes  C         Add the global attributes
322            CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid)            CALL MNC_CW_SET_GATTR( fname, lbi,lbj, uniq_tnum, myThid)
# Line 246  C         Add the per-variable attribute Line 341  C         Add the per-variable attribute
341       &         vtype(nvf:nvl), ''' within file ''',       &         vtype(nvf:nvl), ''' within file ''',
342       &         fname(1:nfname), ''''       &         fname(1:nfname), ''''
343    
344    C         DO i = 1,9
345    C         write(*,*) 'i,p(i),s(i),e(i),udo(i),offsets(i) = ',
346    C         &        i,p(i),s(i),e(i),udo(i),offsets(i)
347    C         ENDDO
348    
349  C         Write the variable one vector at a time  C         Write the variable one vector at a time
350            DO j7 = s(7),e(7)            DO j7 = s(7),e(7)
351              k7 = (j7 - 1)*p(6)              k7 = (j7 - 1)*p(6)
# Line 273  C         Write the variable one vector Line 373  C         Write the variable one vector
373                        vcount(2) = 1                        vcount(2) = 1
374    
375        kr = 0        kr = 0
       DO j1 = s(1),e(1)  
         k1 = k2 + j1  
         kr = kr + 1  
         resh(kr) = var(k1)  
       ENDDO  
         
376        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
377        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
378    
379  #ifdef  mnc_rtype_D        IF (stype(1:1) .EQ. 'D') THEN
380        err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh)          DO j1 = s(1),e(1)
381  #endif            k1 = k2 + j1
382  #ifdef  mnc_rtype_R            kr = kr + 1
383        err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh)            resh_d(kr) = var(k1)
384  #endif          ENDDO
385  #ifdef  mnc_rtype_I          err = NF_PUT_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)
386        err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh)        ENDIF
387  #endif        IF (stype(1:1) .EQ. 'R') THEN
388            DO j1 = s(1),e(1)
389              k1 = k2 + j1
390              kr = kr + 1
391              resh_r(kr) = var(k1)
392            ENDDO
393            err = NF_PUT_VARA_REAL(fid, idv, vstart, vcount, resh_r)
394          ENDIF
395          IF (stype(1:1) .EQ. 'I') THEN
396            DO j1 = s(1),e(1)
397              k1 = k2 + j1
398              kr = kr + 1
399              resh_i(kr) = var(k1)
400            ENDDO
401            err = NF_PUT_VARA_INT(fid, idv, vstart, vcount, resh_i)
402          ENDIF
403    
404        CALL MNC_HANDLE_ERR(err, msgbuf, myThid)        CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
405    
# Line 304  C         Write the variable one vector Line 413  C         Write the variable one vector
413  C         Sync the file  C         Sync the file
414            err = NF_SYNC(fid)            err = NF_SYNC(fid)
415            write(msgbuf,'(3a)') 'sync for file ''', fname,            write(msgbuf,'(3a)') 'sync for file ''', fname,
416       &         ''' in S/R MNC_CW_RX_W_YY'       &         ''' in S/R MNC_CW_RX_W'
417            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
418    
419          ENDDO          ENDDO
# Line 317  C         Sync the file Line 426  C         Sync the file
426                
427    
428  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
429    CBOP 0
430    C !ROUTINE: MNC_CW_RX_R_S
431    
432    C !INTERFACE:
433        SUBROUTINE MNC_CW_RX_R_YY(        SUBROUTINE MNC_CW_RX_R_S(
434         I     stype,
435       I     fbname, bi,bj,       I     fbname, bi,bj,
436       I     vtype,       I     vtype,
 C     I     indu,  
437       I     var,       I     var,
438       I     myThid )       I     myThid )
439    
440    C     !DESCRIPTION:
441    C     A scalar version of MNC_CW_RX_R() for compilers that cannot
442    C     gracefully handle the conversion on their own.
443          
444    C     !USES:
445        implicit none        implicit none
446    
447    C     !INPUT PARAMETERS:
448          integer myThid, bi,bj
449          character*(*) stype, fbname, vtype
450          __V var
451          __V var_arr(1)
452    CEOP
453          var_arr(1) = var
454    
455          CALL MNC_CW_RX_R(stype,fbname,bi,bj,vtype, var_arr, myThid)
456    
457          RETURN
458          END
459    
460    
461    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
462    CBOP 0
463    C !ROUTINE: MNC_CW_RX_R
464    
465    C !INTERFACE:
466          SUBROUTINE MNC_CW_RX_R(
467         I     stype,
468         I     fbname, bi,bj,
469         I     vtype,
470         I     var,
471         I     myThid )
472    
473    C     !DESCRIPTION:
474    C     This subroutine reads one variable from a file or a file group,
475    C     depending upon the tile indicies.
476          
477    C     !USES:
478          implicit none
479  #include "netcdf.inc"  #include "netcdf.inc"
480  #include "mnc_common.h"  #include "mnc_common.h"
 #include "EEPARAMS.h"  
481  #include "SIZE.h"  #include "SIZE.h"
482    #include "EEPARAMS.h"
483    #include "PARAMS.h"
484    #include "MNC_PARAMS.h"
485    
486  #define mnc_rtype_YY  C     !INPUT PARAMETERS:
487          integer myThid, bi,bj
488  C     Arguments        character*(*) stype, fbname, vtype
       integer myThid, bi,bj, indu  
       character*(*) fbname, vtype  
489        __V var(*)        __V var(*)
490    CEOP
491    
492  C     Functions  C     !LOCAL VARIABLES:
493        integer IFNBLNK, ILNBLNK        integer i,k, nvf,nvl, n1,n2, igrid, ntot, indu
   
 C     Local Variables  
       integer i,k, nvf,nvl, n1,n2, igrid, ntot  
494        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv        integer bis,bie, bjs,bje, uniq_tnum, nfname, fid, idv
495        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr        integer ndim, indf, err, lbi,lbj, bidim,bjdim, unlim_sz, kr
496        integer ind_fv_ids, ind_vt, ierr, atype, alen        integer ind_fv_ids, ind_vt, ierr, atype, alen
497        integer f_sNx,f_sNy        integer f_sNx,f_sNy, npath
498        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)
499        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
500        character*(MAX_LEN_MBUF) msgbuf        character*(MAX_LEN_MBUF) msgbuf
501        character*(MNC_MAX_CHAR) fname        character*(MNC_MAX_CHAR) fname
502          character*(MNC_MAX_CHAR) path_fname
503        integer indfg, fg1,fg2        integer indfg, fg1,fg2
504          REAL*8  resh_d( sNx + 2*OLx + sNy + 2*OLy )
505          REAL*4  resh_r( sNx + 2*OLx + sNy + 2*OLy )
506          INTEGER resh_i( sNx + 2*OLx + sNy + 2*OLy )
507    
508  C     Temporary storage for the simultaneous type conversion and  C     Functions
509  C     re-shaping before passing to NetCDF        integer IFNBLNK, ILNBLNK
 #ifdef  mnc_rtype_D  
       REAL*8  resh( sNx + 2*OLx + sNy + 2*OLy )  
 #endif  
 #ifdef  mnc_rtype_R  
       REAL*4  resh( sNx + 2*OLx + sNy + 2*OLy )  
 #endif  
 #ifdef  mnc_rtype_I  
       INTEGER resh( sNx + 2*OLx + sNy + 2*OLy )  
 #endif  
510    
511  C     Only do I/O if I am the master thread  C     Only do I/O if I am the master thread
512        _BEGIN_MASTER( myThid )        _BEGIN_MASTER( myThid )
# Line 377  C     group (or base) name Line 518  C     group (or base) name
518        CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid)        CALL MNC_GET_IND(MNC_MAX_ID, fbname, mnc_cw_fgnm, indfg, myThid)
519        IF (indfg .LT. 1) THEN        IF (indfg .LT. 1) THEN
520          write(msgbuf,'(3a)')          write(msgbuf,'(3a)')
521       &       'MNC_CW_RX_W_YY ERROR: file group name ''',       &       'MNC_CW_RX_W ERROR: file group name ''',
522       &       fbname(fg1:fg2), ''' is not defined'       &       fbname(fg1:fg2), ''' is not defined'
523          CALL print_error(msgbuf, mythid)          CALL print_error(msgbuf, mythid)
524          STOP 'ABNORMAL END: S/R MNC_CW_RX_W_YY'          STOP 'ABNORMAL END: S/R MNC_CW_RX_W'
525        ENDIF        ENDIF
526        indu = mnc_cw_fgud(indfg)        indu = mnc_cw_fgud(indfg)
527    
# Line 389  C     Check that the Variable Type exist Line 530  C     Check that the Variable Type exist
530        nvl = ILNBLNK(vtype)        nvl = ILNBLNK(vtype)
531        CALL MNC_GET_IND( MNC_MAX_ID, vtype, mnc_cw_vname, ind_vt, myThid)        CALL MNC_GET_IND( MNC_MAX_ID, vtype, mnc_cw_vname, ind_vt, myThid)
532        IF (ind_vt .LT. 1) THEN        IF (ind_vt .LT. 1) THEN
533          write(msgbuf,'(3a)') 'MNC_CW_RX_R_YY ERROR: vtype ''',          write(msgbuf,'(3a)') 'MNC_CW_RX_R ERROR: vtype ''',
534       &       vtype(nvf:nvl), ''' is not defined'       &       vtype(nvf:nvl), ''' is not defined'
535          CALL print_error(msgbuf, mythid)          CALL print_error(msgbuf, mythid)
536          STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY'          STOP 'ABNORMAL END: S/R MNC_CW_RX_R'
537        ENDIF        ENDIF
538        igrid = mnc_cw_vgind(ind_vt)        igrid = mnc_cw_vgind(ind_vt)
539    
# Line 429  C         Create the file name Line 570  C         Create the file name
570            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'            write(fname((ntot+1):(ntot+9)),'(i6.6,a3)') uniq_tnum, '.nc'
571            nfname = ntot+9            nfname = ntot+9
572    
573    C         Add the path to the file name
574              IF (mnc_use_indir) THEN
575                path_fname(1:MNC_MAX_CHAR) = mnc_blank_name(1:MNC_MAX_CHAR)
576                npath = ILNBLNK(mnc_indir_str)
577                path_fname(1:npath) = mnc_indir_str(1:npath)
578                path_fname((npath+1):(npath+nfname)) = fname(1:nfname)
579                fname(1:MNC_MAX_CHAR) = path_fname(1:MNC_MAX_CHAR)
580                nfname = npath + nfname
581              ENDIF
582    
583  C         Open the existing file  C         Open the existing file
584            CALL MNC_FILE_TRY_READ( fname, ierr, indf, myThid)            CALL MNC_FILE_TRY_READ( fname, ierr, indf, myThid)
585    
586  C         Check that the variable (VType) is defined within the file  C         Check that the variable (VType) is defined within the file
587            CALL MNC_GET_FVINDS( fname, vtype, indf, ind_fv_ids, myThid)            CALL MNC_GET_FVINDS( fname, vtype, indf, ind_fv_ids, myThid)
588            IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN            IF ((indf .LT. 1) .OR. (ind_fv_ids .LT. 1)) THEN
589              write(msgbuf,'(4a)') 'MNC_CW_RX_R_YY ERROR: vtype ''',              write(msgbuf,'(4a)') 'MNC_CW_RX_R ERROR: vtype ''',
590       &           vtype(nvf:nvl), ''' is not defined within file ''',       &           vtype(nvf:nvl), ''' is not defined within file ''',
591       &           fname(1:nfname)       &           fname(1:nfname)
592              CALL print_error(msgbuf, mythid)              CALL print_error(msgbuf, mythid)
593              STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY'              STOP 'ABNORMAL END: S/R MNC_CW_RX_R'
594            ENDIF            ENDIF
595            fid = mnc_f_info(indf,2)            fid = mnc_f_info(indf,2)
596            idv = mnc_fv_ids(indf,ind_fv_ids+1)            idv = mnc_fv_ids(indf,ind_fv_ids+1)
# Line 452  C         are compatible and WARN (only Line 603  C         are compatible and WARN (only
603            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN
604              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx)              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNx', f_sNx)
605              CALL MNC_HANDLE_ERR(err,              CALL MNC_HANDLE_ERR(err,
606       &           'reading attribute ''sNx'' in S/R MNC_CW_RX_R_YY',       &           'reading attribute ''sNx'' in S/R MNC_CW_RX_R',
607       &           myThid)       &           myThid)
608            ENDIF            ENDIF
609            err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen)            err = NF_INQ_ATT(fid,NF_GLOBAL, 'sNy',atype,alen)
610            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN            IF ((err .EQ. NF_NOERR) .AND. (alen .EQ. 1)) THEN
611              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy)              err = NF_GET_ATT_INT(fid, NF_GLOBAL, 'sNy', f_sNy)
612              CALL MNC_HANDLE_ERR(err,              CALL MNC_HANDLE_ERR(err,
613       &           'reading attribute ''sNy'' in S/R MNC_CW_RX_R_YY',       &           'reading attribute ''sNy'' in S/R MNC_CW_RX_R',
614       &           myThid)       &           myThid)
615            ENDIF            ENDIF
616            IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN            IF ((f_sNx .NE. sNx) .OR. (f_sNy .NE. sNy)) THEN
617              write(msgbuf,'(5a)') 'MNC_CW_RX_R_YY WARNING: the ',              write(msgbuf,'(5a)') 'MNC_CW_RX_R WARNING: the ',
618       &           'attributes ''sNx'' and ''sNy'' within the file ''',       &           'attributes ''sNx'' and ''sNy'' within the file ''',
619       &           fname(1:nfname), ''' do not exist or do not match ',       &           fname(1:nfname), ''' do not exist or do not match ',
620       &           'the current sizes within the model'       &           'the current sizes within the model'
# Line 476  C           ires = 1 Line 627  C           ires = 1
627  C           CALL MNC_CHK_VTYP_R_NCVAR( ind_vt,  C           CALL MNC_CHK_VTYP_R_NCVAR( ind_vt,
628  C      &         indf, ind_fv_ids, indu, ires)  C      &         indf, ind_fv_ids, indu, ires)
629  C           IF (ires .LT. 0) THEN  C           IF (ires .LT. 0) THEN
630  C             write(msgbuf,'(7a)') 'MNC_CW_RX_R_YY WARNING: the sizes ',  C             write(msgbuf,'(7a)') 'MNC_CW_RX_R WARNING: the sizes ',
631  C      &           'of the in-program variable ''', vtype(nvf:nvl),  C      &           'of the in-program variable ''', vtype(nvf:nvl),
632  C      &           ''' and the corresponding variable within file ''',  C      &           ''' and the corresponding variable within file ''',
633  C      &           fname(1:nfname), ''' are not compatible -- please ',  C      &           fname(1:nfname), ''' are not compatible -- please ',
634  C      &           'check the sizes'  C      &           'check the sizes'
635  C             CALL print_error(msgbuf, mythid)  C             CALL print_error(msgbuf, mythid)
636  C             STOP 'ABNORMAL END: S/R MNC_CW_RX_R_YY'  C             STOP 'ABNORMAL END: S/R MNC_CW_RX_R'
637  C           ENDIF  C           ENDIF
638    
639  C         Check for bi,bj indicies  C         Check for bi,bj indicies
# Line 583  C         Read the variable one vector a Line 734  C         Read the variable one vector a
734                        vstart(2) = udo(2) + j2 - s(2) + 1                        vstart(2) = udo(2) + j2 - s(2) + 1
735                        vcount(2) = 1                        vcount(2) = 1
736    
737          kr = 0
738        vstart(1) = udo(1) + 1        vstart(1) = udo(1) + 1
739        vcount(1) = e(1) - s(1) + 1        vcount(1) = e(1) - s(1) + 1
740                
741  #ifdef  mnc_rtype_D        IF (stype(1:1) .EQ. 'D') THEN
742        err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh)          err = NF_GET_VARA_DOUBLE(fid, idv, vstart, vcount, resh_d)
743  #endif          CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
744  #ifdef  mnc_rtype_R          DO j1 = s(1),e(1)
745        err = NF_GET_VARA_REAL(fid, idv, vstart, vcount, resh)            k1 = k2 + j1
746  #endif            kr = kr + 1
747  #ifdef  mnc_rtype_I            var(k1) = resh_d(kr)
748        err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh)          ENDDO
749  #endif        ENDIF
750          IF (stype(1:1) .EQ. 'R') THEN
751        CALL MNC_HANDLE_ERR(err, msgbuf, myThid)          err = NF_GET_VARA_REAL(fid, idv, vstart, vcount, resh_r)
752            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
753            DO j1 = s(1),e(1)
754              k1 = k2 + j1
755              kr = kr + 1
756              var(k1) = resh_r(kr)
757            ENDDO
758          ENDIF
759          IF (stype(1:1) .EQ. 'I') THEN
760            err = NF_GET_VARA_INT(fid, idv, vstart, vcount, resh_i)
761            CALL MNC_HANDLE_ERR(err, msgbuf, myThid)
762            DO j1 = s(1),e(1)
763              k1 = k2 + j1
764              kr = kr + 1
765              var(k1) = resh_i(kr)
766            ENDDO
767          ENDIF
768    
       kr = 0  
       DO j1 = s(1),e(1)  
         k1 = k2 + j1  
         kr = kr + 1  
         var(k1) = resh(kr)  
       ENDDO  
769                
770    
771                      ENDDO                      ENDDO

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.22