/[MITgcm]/MITgcm/pkg/mdsio/mdsio_gl.F
ViewVC logotype

Diff of /MITgcm/pkg/mdsio/mdsio_gl.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5 by heimbach, Thu Oct 14 18:43:39 2004 UTC revision 1.16 by jahn, Tue Dec 30 00:14:05 2008 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3    
4  #include "MDSIO_OPTIONS.h"  #include "MDSIO_OPTIONS.h"
5    
# Line 67  C Created: 03/16/99 adcroft@mit.edu Line 68  C Created: 03/16/99 adcroft@mit.edu
68  C Global variables / common blocks  C Global variables / common blocks
69  #include "SIZE.h"  #include "SIZE.h"
70  #include "EEPARAMS.h"  #include "EEPARAMS.h"
71    #include "EESUPPORT.h"
72  #include "PARAMS.h"  #include "PARAMS.h"
73    
74  C Routine arguments  C Routine arguments
# Line 77  C Routine arguments Line 79  C Routine arguments
79        _RL arr_gl(sNx,nSx,nPx,sNy,nSy,nPy,Nr)        _RL arr_gl(sNx,nSx,nPx,sNy,nSy,nPy,Nr)
80        integer irecord        integer irecord
81        integer myThid        integer myThid
82    
83    #ifdef ALLOW_CTRL
84    
85  C Functions  C Functions
86        integer ILNBLNK        integer ILNBLNK
87        integer MDS_RECLEN        integer MDS_RECLEN
88  C Local variables  C Local variables
89        character*(80) dataFName        character*(MAX_LEN_FNAM) dataFName
90        integer ip,jp,iG,jG,irec,bi,bj,ii,j,k,dUnit,IL        integer ip,jp,iG,jG,irec,bi,bj,i,j,k,dUnit,IL
91        logical exst        logical exst
92        _RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,Nr,nSx,nSy)        _RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,Nr,nSx,nSy)
93        Real*4 r4seg(sNx)        Real*4 r4seg(sNx)
# Line 90  C Local variables Line 95  C Local variables
95        logical globalFile,fileIsOpen        logical globalFile,fileIsOpen
96        integer length_of_rec        integer length_of_rec
97        character*(max_len_mbuf) msgbuf        character*(max_len_mbuf) msgbuf
98    cph-usesingle(
99          integer ii,jj
100    c     integer iG_IO,jG_IO,npe
101          integer x_size,y_size
102          PARAMETER ( x_size = Nx )
103          PARAMETER ( y_size = Ny )
104          Real*4 xy_buffer_r4(x_size,y_size)
105          Real*8 xy_buffer_r8(x_size,y_size)
106          Real*8 global(Nx,Ny)
107    c     _RL    local(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
108    cph-usesingle)
109    CMM(
110          integer pIL
111    CMM)
112    
113  C     ------------------------------------------------------------------  C     ------------------------------------------------------------------
114    
115  C Only do I/O if I am the master thread  C Only do I/O if I am the master thread
# Line 111  C Assume nothing Line 131  C Assume nothing
131        globalFile = .FALSE.        globalFile = .FALSE.
132        fileIsOpen = .FALSE.        fileIsOpen = .FALSE.
133        IL=ILNBLNK( fName )        IL=ILNBLNK( fName )
134    CMM(
135          pIL = ILNBLNK( mdsioLocalDir )
136    CMM)
137    CMM(
138    C Assign special directory
139          if ( pIL.NE.0 ) then
140           write(fName,'(2a)') mdsioLocalDir(1:pIL), fName(1:IL)
141          endif
142    CMM)
143    
144  C Assign a free unit number as the I/O channel for this routine  C Assign a free unit number as the I/O channel for this routine
145        call MDSFINDUNIT( dUnit, mythid )        call MDSFINDUNIT( dUnit, mythid )
146    
147          if ( useSingleCPUIO ) then
148    
149    #ifdef ALLOW_USE_MPI
150            IF( mpiMyId .EQ. 0 ) THEN
151    #else
152            IF ( .TRUE. ) THEN
153    #endif /* ALLOW_USE_MPI */
154    
155  C Check first for global file with simple name (ie. fName)  C Check first for global file with simple name (ie. fName)
156        dataFName = fName           dataFName = fName
157        inquire( file=dataFname, exist=exst )           inquire( file=dataFname, exist=exst )
158        if (exst) then           if (exst) globalFile = .TRUE.
        write(msgbuf,'(a,a)')  
      &   ' MDSREADFIELD: opening global file: ',dataFName  
        call print_message( msgbuf, standardmessageunit,  
      &                     SQUEEZE_RIGHT , mythid)  
       endif  
159    
160  C If negative check for global file with MDS name (ie. fName.data)  C If negative check for global file with MDS name (ie. fName.data)
161        if (.NOT. globalFile) then           if (.NOT. globalFile) then
162         write(dataFname(1:80),'(2a)') fName(1:IL),'.data'            write(dataFname,'(2a)') fName(1:IL),'.data'
163              inquire( file=dataFname, exist=exst )
164              if (exst) globalFile = .TRUE.
165             endif
166    
167    C If global file is visible to process 0, then open it here.
168    C Otherwise stop program.
169             if ( globalFile) then
170              length_of_rec=MDS_RECLEN( filePrec, x_size*y_size, mythid )
171              open( dUnit, file=dataFName, status='old',
172         &         access='direct', recl=length_of_rec )
173             else
174              write(msgbuf,'(2a)')
175         &      ' MDSREADFIELD: filename: ',dataFName(1:IL)
176              call print_message( msgbuf, standardmessageunit,
177         &                        SQUEEZE_RIGHT , mythid)
178              call print_error( msgbuf, mythid )
179              write(msgbuf,'(a)')
180         &      ' MDSREADFIELD: File does not exist'
181              call print_message( msgbuf, standardmessageunit,
182         &                        SQUEEZE_RIGHT , mythid)
183              call print_error( msgbuf, mythid )
184              stop 'ABNORMAL END: S/R MDSREADFIELD'
185             endif
186    
187            ENDIF
188    
189    c-- useSingleCpuIO
190          else
191    C Only do I/O if I am the master thread
192    
193    C Check first for global file with simple name (ie. fName)
194           dataFName = fName
195         inquire( file=dataFname, exist=exst )         inquire( file=dataFname, exist=exst )
196         if (exst) then         if (exst) then
197          write(msgbuf,'(a,a)')          write(msgbuf,'(a,a)')
198       &    ' MDSREADFIELD_GL: opening global file: ',dataFName       &    ' MDSREADFIELD: opening global file: ',dataFName(1:IL)
199          call print_message( msgbuf, standardmessageunit,          call print_message( msgbuf, standardmessageunit,
200       &                      SQUEEZE_RIGHT , mythid)       &                      SQUEEZE_RIGHT , mythid)
         globalFile = .TRUE.  
201         endif         endif
202    
203    C If negative check for global file with MDS name (ie. fName.data)
204           if (.NOT. globalFile) then
205            write(dataFname,'(2a)') fName(1:IL),'.data'
206            inquire( file=dataFname, exist=exst )
207            if (exst) then
208             write(msgbuf,'(a,a)')
209         &     ' MDSREADFIELD_GL: opening global file: ',dataFName(1:IL+5)
210             call print_message( msgbuf, standardmessageunit,
211         &                       SQUEEZE_RIGHT , mythid)
212             globalFile = .TRUE.
213            endif
214           endif
215    
216    c-- useSingleCpuIO
217        endif        endif
218    
219          if ( .not. useSingleCpuIO ) then
220    cph      if ( .not. ( globalFile .and. useSingleCPUIO ) ) then
221          if ( .not. ( globalFile ) ) then
222    
223    C If we are reading from a global file then we open it here
224          if (globalFile) then
225           length_of_rec=MDS_RECLEN( filePrec, sNx, mythid )
226           open( dUnit, file=dataFName, status='old',
227         &      access='direct', recl=length_of_rec )
228           fileIsOpen=.TRUE.
229          endif
230    
231  C Loop over all processors      C Loop over all processors    
232        do jp=1,nPy        do jp=1,nPy
233        do ip=1,nPx        do ip=1,nPx
# Line 147  C If we are reading from a tiled MDS fil Line 238  C If we are reading from a tiled MDS fil
238          if (.NOT. globalFile) then          if (.NOT. globalFile) then
239           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles
240           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles
241           write(dataFname(1:80),'(2a,i3.3,a,i3.3,a)')           write(dataFname,'(2a,i3.3,a,i3.3,a)')
242       &              fName(1:IL),'.',iG,'.',jG,'.data'       &              fName(1:IL),'.',iG,'.',jG,'.data'
243           inquire( file=dataFname, exist=exst )           inquire( file=dataFname, exist=exst )
244  C Of course, we only open the file if the tile is "active"  C Of course, we only open the file if the tile is "active"
# Line 155  C (This is a place-holder for the active Line 246  C (This is a place-holder for the active
246           if (exst) then           if (exst) then
247            if ( debugLevel .GE. debLevA ) then            if ( debugLevel .GE. debLevA ) then
248             write(msgbuf,'(a,a)')             write(msgbuf,'(a,a)')
249       &      ' MDSREADFIELD_GL: opening file: ',dataFName       &      ' MDSREADFIELD_GL: opening file: ',dataFName(1:IL+13)
250             call print_message( msgbuf, standardmessageunit,             call print_message( msgbuf, standardmessageunit,
251       &                        SQUEEZE_RIGHT , mythid)       &                        SQUEEZE_RIGHT , mythid)
252            endif            endif
# Line 166  C (This is a place-holder for the active Line 257  C (This is a place-holder for the active
257           else           else
258            fileIsOpen=.FALSE.            fileIsOpen=.FALSE.
259            write(msgbuf,'(a,a)')            write(msgbuf,'(a,a)')
260       &      ' MDSREADFIELD_GL: filename: ',dataFName       &      ' MDSREADFIELD_GL: filename: ',dataFName(1:IL+13)
261            call print_message( msgbuf, standardmessageunit,            call print_message( msgbuf, standardmessageunit,
262       &                        SQUEEZE_RIGHT , mythid)       &                        SQUEEZE_RIGHT , mythid)
263              call print_error( msgbuf, mythid )
264            write(msgbuf,'(a)')            write(msgbuf,'(a)')
265       &      ' MDSREADFIELD_GL: File does not exist'       &      ' MDSREADFIELD_GL: File does not exist'
266              call print_message( msgbuf, standardmessageunit,
267         &                        SQUEEZE_RIGHT , mythid)
268            call print_error( msgbuf, mythid )            call print_error( msgbuf, mythid )
269            stop 'ABNORMAL END: S/R MDSREADFIELD_GL'            stop 'ABNORMAL END: S/R MDSREADFIELD_GL'
270           endif           endif
# Line 179  C (This is a place-holder for the active Line 273  C (This is a place-holder for the active
273          if (fileIsOpen) then          if (fileIsOpen) then
274           do k=1,Nr           do k=1,Nr
275            do j=1,sNy            do j=1,sNy
276               if (globalFile) then
277                iG=bi+(ip-1)*nsx
278                jG=bj+(jp-1)*nsy
279                irec=1 + INT(iG/sNx) + nSx*nPx*(jG+j-1) + nSx*nPx*Ny*(k-1)
280         &             + nSx*nPx*Ny*nNz*(irecord-1)
281               else
282              iG = 0              iG = 0
283              jG = 0              jG = 0
284              irec=j + sNy*(k-1) + sNy*Nr*(irecord-1)              irec=j + sNy*(k-1) + sNy*Nr*(irecord-1)
285               endif
286             if (filePrec .eq. precFloat32) then             if (filePrec .eq. precFloat32) then
287              read(dUnit,rec=irec) r4seg              read(dUnit,rec=irec) r4seg
288  #ifdef _BYTESWAPIO  #ifdef _BYTESWAPIO
# Line 244  C If global file was opened then close i Line 345  C If global file was opened then close i
345         fileIsOpen = .FALSE.         fileIsOpen = .FALSE.
346        endif        endif
347    
348    c      end of if ( .not. ( globalFile ) ) then
349          endif
350    
351    c      else of if ( .not. ( globalFile .and. useSingleCPUIO ) ) then
352          else
353    
354           DO k=1,nNz
355    
356    #ifdef ALLOW_USE_MPI
357             IF( mpiMyId .EQ. 0 ) THEN
358    #else
359             IF ( .TRUE. ) THEN
360    #endif /* ALLOW_USE_MPI */
361              irec = k+nNz*(irecord-1)
362              if (filePrec .eq. precFloat32) then
363               read(dUnit,rec=irec) xy_buffer_r4
364    #ifdef _BYTESWAPIO
365               call MDS_BYTESWAPR4( x_size*y_size, xy_buffer_r4 )
366    #endif
367               DO J=1,Ny
368                DO I=1,Nx
369                 global(I,J) = xy_buffer_r4(I,J)
370                ENDDO
371               ENDDO
372              elseif (filePrec .eq. precFloat64) then
373               read(dUnit,rec=irec) xy_buffer_r8
374    #ifdef _BYTESWAPIO
375               call MDS_BYTESWAPR8( x_size*y_size, xy_buffer_r8 )
376    #endif
377               DO J=1,Ny
378                DO I=1,Nx
379                 global(I,J) = xy_buffer_r8(I,J)
380                ENDDO
381               ENDDO
382              else
383               write(msgbuf,'(a)')
384         &            ' MDSREADFIELD: illegal value for filePrec'
385               call print_error( msgbuf, mythid )
386               stop 'ABNORMAL END: S/R MDSREADFIELD'
387              endif
388             ENDIF
389            DO jp=1,nPy
390             DO ip=1,nPx
391              DO bj = myByLo(myThid), myByHi(myThid)
392               DO bi = myBxLo(myThid), myBxHi(myThid)
393                DO J=1,sNy
394                 JJ=((jp-1)*nSy+(bj-1))*sNy+J
395                 DO I=1,sNx
396                  II=((ip-1)*nSx+(bi-1))*sNx+I
397                  arr_gl(i,bi,ip,j,bj,jp,k) = global(II,JJ)
398                 ENDDO
399                ENDDO
400               ENDDO
401              ENDDO
402             ENDDO
403            ENDDO
404    
405           ENDDO
406    c      ENDDO k=1,nNz
407    
408            close( dUnit )
409    
410          endif
411    c      end of if ( .not. ( globalFile .and. useSingleCPUIO ) ) then
412    
413        _END_MASTER( myThid )        _END_MASTER( myThid )
414    
415    #endif /* ALLOW_CTRL */
416  C     ------------------------------------------------------------------  C     ------------------------------------------------------------------
417        return        return
418        end        end
# Line 302  C          open(dUnit, ..., status='old' Line 469  C          open(dUnit, ..., status='old'
469  C Global variables / common blocks  C Global variables / common blocks
470  #include "SIZE.h"  #include "SIZE.h"
471  #include "EEPARAMS.h"  #include "EEPARAMS.h"
472    #include "EESUPPORT.h"
473  #include "PARAMS.h"  #include "PARAMS.h"
474    
475  C Routine arguments  C Routine arguments
# Line 316  cph) Line 484  cph)
484        integer irecord        integer irecord
485        integer myIter        integer myIter
486        integer myThid        integer myThid
487    
488    #ifdef ALLOW_CTRL
489    
490  C Functions  C Functions
491        integer ILNBLNK        integer ILNBLNK
492        integer MDS_RECLEN        integer MDS_RECLEN
493  C Local variables  C Local variables
494        character*(80) dataFName,metaFName        character*(MAX_LEN_FNAM) dataFName,metaFName
495        integer ip,jp,iG,jG,irec,bi,bj,ii,j,k,dUnit,IL        integer ip,jp,iG,jG,irec,bi,bj,i,j,k,dUnit,IL
496        Real*4 r4seg(sNx)        Real*4 r4seg(sNx)
497        Real*8 r8seg(sNx)        Real*8 r8seg(sNx)
498        _RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,Nr,nSx,nSy)        _RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,Nr,nSx,nSy)
# Line 329  C Local variables Line 500  C Local variables
500        integer length_of_rec        integer length_of_rec
501        logical fileIsOpen        logical fileIsOpen
502        character*(max_len_mbuf) msgbuf        character*(max_len_mbuf) msgbuf
503    cph-usesingle(
504    #ifdef ALLOW_USE_MPI
505          integer ii,jj
506    c     integer iG_IO,jG_IO,npe
507          integer x_size,y_size
508          PARAMETER ( x_size = Nx )
509          PARAMETER ( y_size = Ny )
510          Real*4 xy_buffer_r4(x_size,y_size)
511          Real*8 xy_buffer_r8(x_size,y_size)
512          Real*8 global(Nx,Ny)
513    #endif
514    cph-usesingle)
515    CMM(
516          integer pIL
517    CMM)
518    
519  C     ------------------------------------------------------------------  C     ------------------------------------------------------------------
520    
521  C Only do I/O if I am the master thread  C Only do I/O if I am the master thread
# Line 349  C Record number must be >= 1 Line 536  C Record number must be >= 1
536  C Assume nothing  C Assume nothing
537        fileIsOpen=.FALSE.        fileIsOpen=.FALSE.
538        IL=ILNBLNK( fName )        IL=ILNBLNK( fName )
539    CMM(
540          pIL = ILNBLNK( mdsioLocalDir )
541    CMM)
542    CMM(
543    C Assign special directory
544          if ( pIL.NE.0 ) then
545           write(fName,'(2a)') mdsioLocalDir(1:pIL), fName(1:IL)
546          endif
547    CMM)
548    
549  C Assign a free unit number as the I/O channel for this routine  C Assign a free unit number as the I/O channel for this routine
550        call MDSFINDUNIT( dUnit, mythid )        call MDSFINDUNIT( dUnit, mythid )
551    
552    cph-usesingle(
553    #ifdef ALLOW_USE_MPI
554          _END_MASTER( myThid )
555    C If option globalFile is desired but does not work or if
556    C globalFile is too slow, then try using single-CPU I/O.
557          if (useSingleCpuIO) then
558    
559    C Master thread of process 0, only, opens a global file
560           _BEGIN_MASTER( myThid )
561            IF( mpiMyId .EQ. 0 ) THEN
562             write(dataFname,'(2a)') fName(1:IL),'.data'
563             length_of_rec=MDS_RECLEN(filePrec,x_size*y_size,mythid)
564             if (irecord .EQ. 1) then
565              open( dUnit, file=dataFName, status=_NEW_STATUS,
566         &        access='direct', recl=length_of_rec )
567             else
568              open( dUnit, file=dataFName, status=_OLD_STATUS,
569         &        access='direct', recl=length_of_rec )
570             endif
571            ENDIF
572           _END_MASTER( myThid )
573    
574    C Gather array and write it to file, one vertical level at a time
575           DO k=1,nNz
576    C Loop over all processors    
577            do jp=1,nPy
578            do ip=1,nPx
579            DO bj = myByLo(myThid), myByHi(myThid)
580             DO bi = myBxLo(myThid), myBxHi(myThid)
581              DO J=1,sNy
582               JJ=((jp-1)*nSy+(bj-1))*sNy+J
583               DO I=1,sNx
584                II=((ip-1)*nSx+(bi-1))*sNx+I
585                global(II,JJ) = arr_gl(i,bi,ip,j,bj,jp,k)
586               ENDDO
587              ENDDO
588             ENDDO
589            ENDDO
590            enddo
591            enddo
592            _BEGIN_MASTER( myThid )
593             IF( mpiMyId .EQ. 0 ) THEN
594              irec=k+nNz*(irecord-1)
595              if (filePrec .eq. precFloat32) then
596               DO J=1,Ny
597                DO I=1,Nx
598                 xy_buffer_r4(I,J) = global(I,J)
599                ENDDO
600               ENDDO
601    #ifdef _BYTESWAPIO
602               call MDS_BYTESWAPR4( x_size*y_size, xy_buffer_r4 )
603    #endif
604               write(dUnit,rec=irec) xy_buffer_r4
605              elseif (filePrec .eq. precFloat64) then
606               DO J=1,Ny
607                DO I=1,Nx
608                 xy_buffer_r8(I,J) = global(I,J)
609                ENDDO
610               ENDDO
611    #ifdef _BYTESWAPIO
612               call MDS_BYTESWAPR8( x_size*y_size, xy_buffer_r8 )
613    #endif
614               write(dUnit,rec=irec) xy_buffer_r8
615              else
616               write(msgbuf,'(a)')
617         &       ' MDSWRITEFIELD: illegal value for filePrec'
618               call print_error( msgbuf, mythid )
619               stop 'ABNORMAL END: S/R MDSWRITEFIELD'
620              endif
621             ENDIF
622            _END_MASTER( myThid )
623           ENDDO
624    
625    C Close data-file and create meta-file
626           _BEGIN_MASTER( myThid )
627            IF( mpiMyId .EQ. 0 ) THEN
628             close( dUnit )
629             write(metaFName,'(2a)') fName(1:IL),'.meta'
630             dimList(1,1)=Nx
631             dimList(2,1)=1
632             dimList(3,1)=Nx
633             dimList(1,2)=Ny
634             dimList(2,2)=1
635             dimList(3,2)=Ny
636             dimList(1,3)=nNz
637             dimList(2,3)=1
638             dimList(3,3)=nNz
639             ndims=3
640             if (nNz .EQ. 1) ndims=2
641             call MDSWRITEMETA( metaFName, dataFName,
642         &     filePrec, ndims, dimList, irecord, myIter, mythid )
643            ENDIF
644           _END_MASTER( myThid )
645    C To be safe, make other processes wait for I/O completion
646           _BARRIER
647    
648          elseif ( .NOT. useSingleCpuIO ) then
649          _BEGIN_MASTER( myThid )
650    #endif /* ALLOW_USE_MPI */
651    cph-usesingle)
652    
653  C Loop over all processors      C Loop over all processors    
654        do jp=1,nPy        do jp=1,nPy
# Line 363  C Loop over all tiles Line 659  C Loop over all tiles
659  C If we are writing to a tiled MDS file then we open each one here  C If we are writing to a tiled MDS file then we open each one here
660           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles
661           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles
662           write(dataFname(1:80),'(2a,i3.3,a,i3.3,a)')           write(dataFname,'(2a,i3.3,a,i3.3,a)')
663       &              fName(1:IL),'.',iG,'.',jG,'.data'       &              fName(1:IL),'.',iG,'.',jG,'.data'
664           if (irecord .EQ. 1) then           if (irecord .EQ. 1) then
665            length_of_rec=MDS_RECLEN( filePrec, sNx, mythid )            length_of_rec=MDS_RECLEN( filePrec, sNx, mythid )
# Line 379  C If we are writing to a tiled MDS file Line 675  C If we are writing to a tiled MDS file
675          if (fileIsOpen) then          if (fileIsOpen) then
676           do k=1,Nr           do k=1,Nr
677            do j=1,sNy            do j=1,sNy
678               do ii=1,sNx               do i=1,sNx
679                  arr(ii,j,k,bi,bj)=arr_gl(ii,bi,ip,j,bj,jp,k)                  arr(i,j,k,bi,bj)=arr_gl(i,bi,ip,j,bj,jp,k)
680               enddo               enddo
681              iG = 0              iG = 0
682              jG = 0              jG = 0
# Line 439  C If we were writing to a tiled MDS file Line 735  C If we were writing to a tiled MDS file
735  C Create meta-file for each tile if we are tiling  C Create meta-file for each tile if we are tiling
736           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles
737           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles
738           write(metaFname(1:80),'(2a,i3.3,a,i3.3,a)')           write(metaFname,'(2a,i3.3,a,i3.3,a)')
739       &              fName(1:IL),'.',iG,'.',jG,'.meta'       &              fName(1:IL),'.',iG,'.',jG,'.meta'
740           dimList(1,1)=Nx           dimList(1,1)=Nx
741           dimList(2,1)=((ip-1)*nSx+(bi-1))*sNx+1           dimList(2,1)=((ip-1)*nSx+(bi-1))*sNx+1
# Line 461  C End of ip,jp loops Line 757  C End of ip,jp loops
757         enddo         enddo
758        enddo        enddo
759    
   
760        _END_MASTER( myThid )        _END_MASTER( myThid )
761    
762    cph-usesingle(
763    #ifdef ALLOW_USE_MPI
764    C endif useSingleCpuIO
765          endif
766    #endif /* ALLOW_USE_MPI */
767    cph-usesingle)
768    
769    #endif /* ALLOW_CTRL */
770  C     ------------------------------------------------------------------  C     ------------------------------------------------------------------
771        return        return
772        end        end
# Line 510  C Created: 03/16/99 adcroft@mit.edu Line 813  C Created: 03/16/99 adcroft@mit.edu
813  C Global variables / common blocks  C Global variables / common blocks
814  #include "SIZE.h"  #include "SIZE.h"
815  #include "EEPARAMS.h"  #include "EEPARAMS.h"
816    #include "EESUPPORT.h"
817  #include "PARAMS.h"  #include "PARAMS.h"
818    
819  C Routine arguments  C Routine arguments
# Line 521  C Routine arguments Line 825  C Routine arguments
825        _RL arr_gl(sNx,nSx,nPx,sNy,nSy,nPy,nLocz)        _RL arr_gl(sNx,nSx,nPx,sNy,nSy,nPy,nLocz)
826        integer irecord        integer irecord
827        integer myThid        integer myThid
828    
829    #ifdef ALLOW_CTRL
830    
831  C Functions  C Functions
832        integer ILNBLNK        integer ILNBLNK
833        integer MDS_RECLEN        integer MDS_RECLEN
834  C Local variables  C Local variables
835        character*(80) dataFName        character*(MAX_LEN_FNAM) dataFName
836        integer ip,jp,iG,jG,irec,bi,bj,ii,j,k,dUnit,IL        integer ip,jp,iG,jG,irec,bi,bj,i,j,k,dUnit,IL
837        logical exst        logical exst
838        _RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,nLocz,nSx,nSy)        _RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,nLocz,nSx,nSy)
839        Real*4 r4seg(sNx)        Real*4 r4seg(sNx)
# Line 534  C Local variables Line 841  C Local variables
841        logical globalFile,fileIsOpen        logical globalFile,fileIsOpen
842        integer length_of_rec        integer length_of_rec
843        character*(max_len_mbuf) msgbuf        character*(max_len_mbuf) msgbuf
844    cph-usesingle(
845          integer ii,jj
846    c     integer iG_IO,jG_IO,npe
847          integer x_size,y_size
848          PARAMETER ( x_size = Nx )
849          PARAMETER ( y_size = Ny )
850          Real*4 xy_buffer_r4(x_size,y_size)
851          Real*8 xy_buffer_r8(x_size,y_size)
852          Real*8 global(Nx,Ny)
853    c     _RL    local(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
854    cph-usesingle)
855    CMM(
856          integer pIL
857    CMM)
858    
859  C     ------------------------------------------------------------------  C     ------------------------------------------------------------------
860    
861  C Only do I/O if I am the master thread  C Only do I/O if I am the master thread
# Line 555  C Assume nothing Line 877  C Assume nothing
877        globalFile = .FALSE.        globalFile = .FALSE.
878        fileIsOpen = .FALSE.        fileIsOpen = .FALSE.
879        IL=ILNBLNK( fName )        IL=ILNBLNK( fName )
880    CMM(
881          pIL = ILNBLNK( mdsioLocalDir )
882    CMM)
883    CMM(
884    C Assign special directory
885          if ( pIL.NE.0 ) then
886           write(fName,'(2a)') mdsioLocalDir(1:pIL), fName(1:IL)
887          endif
888    CMM)
889    
890  C Assign a free unit number as the I/O channel for this routine  C Assign a free unit number as the I/O channel for this routine
891        call MDSFINDUNIT( dUnit, mythid )        call MDSFINDUNIT( dUnit, mythid )
892    
893          if ( useSingleCPUIO ) then
894    
895    C master thread of process 0, only, opens a global file
896    #ifdef ALLOW_USE_MPI
897            IF( mpiMyId .EQ. 0 ) THEN
898    #else
899            IF ( .TRUE. ) THEN
900    #endif /* ALLOW_USE_MPI */
901    
902  C Check first for global file with simple name (ie. fName)  C Check first for global file with simple name (ie. fName)
903        dataFName = fName           dataFName = fName
904        inquire( file=dataFname, exist=exst )           inquire( file=dataFname, exist=exst )
905        if (exst) then           if (exst) globalFile = .TRUE.
        write(msgbuf,'(a,a)')  
      &   ' MDSREADFIELD: opening global file: ',dataFName  
        call print_message( msgbuf, standardmessageunit,  
      &                     SQUEEZE_RIGHT , mythid)  
       endif  
906    
907  C If negative check for global file with MDS name (ie. fName.data)  C If negative check for global file with MDS name (ie. fName.data)
908        if (.NOT. globalFile) then           if (.NOT. globalFile) then
909         write(dataFname(1:80),'(2a)') fName(1:IL),'.data'            write(dataFname,'(2a)') fName(1:IL),'.data'
910              inquire( file=dataFname, exist=exst )
911              if (exst) globalFile = .TRUE.
912             endif
913    
914    C If global file is visible to process 0, then open it here.
915    C Otherwise stop program.
916             if ( globalFile) then
917              length_of_rec=MDS_RECLEN( filePrec, x_size*y_size, mythid )
918              open( dUnit, file=dataFName, status='old',
919         &         access='direct', recl=length_of_rec )
920             else
921              write(msgbuf,'(2a)')
922         &      ' MDSREADFIELD: filename: ',dataFName(1:IL)
923              call print_message( msgbuf, standardmessageunit,
924         &                        SQUEEZE_RIGHT , mythid)
925              call print_error( msgbuf, mythid )
926              write(msgbuf,'(a)')
927         &      ' MDSREADFIELD: File does not exist'
928              call print_message( msgbuf, standardmessageunit,
929         &                        SQUEEZE_RIGHT , mythid)
930              call print_error( msgbuf, mythid )
931              stop 'ABNORMAL END: S/R MDSREADFIELD'
932             endif
933    
934            ENDIF
935    
936    c-- useSingleCpuIO
937          else
938    
939    C Check first for global file with simple name (ie. fName)
940           dataFName = fName
941         inquire( file=dataFname, exist=exst )         inquire( file=dataFname, exist=exst )
942         if (exst) then         if (exst) then
943          write(msgbuf,'(a,a)')          write(msgbuf,'(a,a)')
944       &    ' MDSREADFIELD_GL: opening global file: ',dataFName       &    ' MDSREADFIELD: opening global file: ',dataFName(1:IL)
945          call print_message( msgbuf, standardmessageunit,          call print_message( msgbuf, standardmessageunit,
946       &                      SQUEEZE_RIGHT , mythid)       &                      SQUEEZE_RIGHT , mythid)
         globalFile = .TRUE.  
947         endif         endif
948    
949    C If negative check for global file with MDS name (ie. fName.data)
950           if (.NOT. globalFile) then
951            write(dataFname,'(2a)') fName(1:IL),'.data'
952            inquire( file=dataFname, exist=exst )
953            if (exst) then
954             write(msgbuf,'(a,a)')
955         &     ' MDSREADFIELD_GL: opening global file: ',dataFName(1:IL+5)
956             call print_message( msgbuf, standardmessageunit,
957         &                       SQUEEZE_RIGHT , mythid)
958             globalFile = .TRUE.
959            endif
960           endif
961    
962    c-- useSingleCpuIO
963          endif
964    
965          if ( .not. useSingleCpuIO ) then
966    cph      if ( .not. ( globalFile .and. useSingleCPUIO ) ) then
967          if ( .not. ( globalFile ) ) then
968    
969    C If we are reading from a global file then we open it here
970          if (globalFile) then
971           length_of_rec=MDS_RECLEN( filePrec, sNx, mythid )
972           open( dUnit, file=dataFName, status='old',
973         &      access='direct', recl=length_of_rec )
974           fileIsOpen=.TRUE.
975        endif        endif
976    
977  C Loop over all processors      C Loop over all processors    
978        do jp=1,nPy        do jp=1,nPy
979        do ip=1,nPx        do ip=1,nPx
# Line 591  C If we are reading from a tiled MDS fil Line 984  C If we are reading from a tiled MDS fil
984          if (.NOT. globalFile) then          if (.NOT. globalFile) then
985           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles
986           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles
987           write(dataFname(1:80),'(2a,i3.3,a,i3.3,a)')           write(dataFname,'(2a,i3.3,a,i3.3,a)')
988       &              fName(1:IL),'.',iG,'.',jG,'.data'       &              fName(1:IL),'.',iG,'.',jG,'.data'
989           inquire( file=dataFname, exist=exst )           inquire( file=dataFname, exist=exst )
990  C Of course, we only open the file if the tile is "active"  C Of course, we only open the file if the tile is "active"
# Line 599  C (This is a place-holder for the active Line 992  C (This is a place-holder for the active
992           if (exst) then           if (exst) then
993            if ( debugLevel .GE. debLevA ) then            if ( debugLevel .GE. debLevA ) then
994             write(msgbuf,'(a,a)')             write(msgbuf,'(a,a)')
995       &      ' MDSREADFIELD_GL: opening file: ',dataFName       &      ' MDSREADFIELD_GL: opening file: ',dataFName(1:IL+13)
996             call print_message( msgbuf, standardmessageunit,             call print_message( msgbuf, standardmessageunit,
997       &                        SQUEEZE_RIGHT , mythid)       &                        SQUEEZE_RIGHT , mythid)
998            endif            endif
# Line 610  C (This is a place-holder for the active Line 1003  C (This is a place-holder for the active
1003           else           else
1004            fileIsOpen=.FALSE.            fileIsOpen=.FALSE.
1005            write(msgbuf,'(a,a)')            write(msgbuf,'(a,a)')
1006       &      ' MDSREADFIELD_GL: filename: ',dataFName       &      ' MDSREADFIELD_GL: filename: ',dataFName(1:IL+13)
1007            call print_message( msgbuf, standardmessageunit,            call print_message( msgbuf, standardmessageunit,
1008       &                        SQUEEZE_RIGHT , mythid)       &                        SQUEEZE_RIGHT , mythid)
1009              call print_error( msgbuf, mythid )
1010            write(msgbuf,'(a)')            write(msgbuf,'(a)')
1011       &      ' MDSREADFIELD_GL: File does not exist'       &      ' MDSREADFIELD_GL: File does not exist'
1012              call print_message( msgbuf, standardmessageunit,
1013         &                        SQUEEZE_RIGHT , mythid)
1014            call print_error( msgbuf, mythid )            call print_error( msgbuf, mythid )
1015            stop 'ABNORMAL END: S/R MDSREADFIELD_GL'            stop 'ABNORMAL END: S/R MDSREADFIELD_GL'
1016           endif           endif
# Line 623  C (This is a place-holder for the active Line 1019  C (This is a place-holder for the active
1019          if (fileIsOpen) then          if (fileIsOpen) then
1020           do k=1,nLocz           do k=1,nLocz
1021            do j=1,sNy            do j=1,sNy
1022               if (globalFile) then
1023                iG=bi+(ip-1)*nsx
1024                jG=bj+(jp-1)*nsy
1025                irec=1 + INT(iG/sNx) + nSx*nPx*(jG+j-1) + nSx*nPx*Ny*(k-1)
1026         &             + nSx*nPx*Ny*nLocz*(irecord-1)
1027               else
1028              iG = 0              iG = 0
1029              jG = 0              jG = 0
1030              irec=j + sNy*(k-1) + sNy*nLocz*(irecord-1)              irec=j + sNy*(k-1) + sNy*nLocz*(irecord-1)
1031               endif
1032             if (filePrec .eq. precFloat32) then             if (filePrec .eq. precFloat32) then
1033              read(dUnit,rec=irec) r4seg              read(dUnit,rec=irec) r4seg
1034  #ifdef _BYTESWAPIO  #ifdef _BYTESWAPIO
# Line 688  C If global file was opened then close i Line 1091  C If global file was opened then close i
1091         fileIsOpen = .FALSE.         fileIsOpen = .FALSE.
1092        endif        endif
1093    
1094    c      end of if ( .not. ( globalFile ) ) then
1095          endif
1096    
1097    c      else of if ( .not. ( globalFile .and. useSingleCPUIO ) ) then
1098          else
1099    
1100           DO k=1,nLocz
1101    
1102    #ifdef ALLOW_USE_MPI
1103             IF( mpiMyId .EQ. 0 ) THEN
1104    #else
1105             IF ( .TRUE. ) THEN
1106    #endif /* ALLOW_USE_MPI */
1107              irec = k+nNz*(irecord-1)
1108              if (filePrec .eq. precFloat32) then
1109               read(dUnit,rec=irec) xy_buffer_r4
1110    #ifdef _BYTESWAPIO
1111               call MDS_BYTESWAPR4( x_size*y_size, xy_buffer_r4 )
1112    #endif
1113               DO J=1,Ny
1114                DO I=1,Nx
1115                 global(I,J) = xy_buffer_r4(I,J)
1116                ENDDO
1117               ENDDO
1118              elseif (filePrec .eq. precFloat64) then
1119               read(dUnit,rec=irec) xy_buffer_r8
1120    #ifdef _BYTESWAPIO
1121               call MDS_BYTESWAPR8( x_size*y_size, xy_buffer_r8 )
1122    #endif
1123               DO J=1,Ny
1124                DO I=1,Nx
1125                 global(I,J) = xy_buffer_r8(I,J)
1126                ENDDO
1127               ENDDO
1128              else
1129               write(msgbuf,'(a)')
1130         &            ' MDSREADFIELD: illegal value for filePrec'
1131               call print_error( msgbuf, mythid )
1132               stop 'ABNORMAL END: S/R MDSREADFIELD'
1133              endif
1134             ENDIF
1135            DO jp=1,nPy
1136             DO ip=1,nPx
1137              DO bj = myByLo(myThid), myByHi(myThid)
1138               DO bi = myBxLo(myThid), myBxHi(myThid)
1139                DO J=1,sNy
1140                 JJ=((jp-1)*nSy+(bj-1))*sNy+J
1141                 DO I=1,sNx
1142                  II=((ip-1)*nSx+(bi-1))*sNx+I
1143                  arr_gl(i,bi,ip,j,bj,jp,k) = global(II,JJ)
1144                 ENDDO
1145                ENDDO
1146               ENDDO
1147              ENDDO
1148             ENDDO
1149            ENDDO
1150    
1151           ENDDO
1152    c      ENDDO k=1,nNz
1153    
1154            close( dUnit )
1155    
1156          endif
1157    c      end of if ( .not. ( globalFile .and. useSingleCPUIO ) ) then
1158    
1159        _END_MASTER( myThid )        _END_MASTER( myThid )
1160    
1161    #endif /* ALLOW_CTRL */
1162  C     ------------------------------------------------------------------  C     ------------------------------------------------------------------
1163        return        return
1164        end        end
# Line 746  C          open(dUnit, ..., status='old' Line 1215  C          open(dUnit, ..., status='old'
1215  C Global variables / common blocks  C Global variables / common blocks
1216  #include "SIZE.h"  #include "SIZE.h"
1217  #include "EEPARAMS.h"  #include "EEPARAMS.h"
1218    #include "EESUPPORT.h"
1219  #include "PARAMS.h"  #include "PARAMS.h"
1220    
1221  C Routine arguments  C Routine arguments
# Line 761  cph) Line 1231  cph)
1231        integer irecord        integer irecord
1232        integer myIter        integer myIter
1233        integer myThid        integer myThid
1234    
1235    #ifdef ALLOW_CTRL
1236    
1237  C Functions  C Functions
1238        integer ILNBLNK        integer ILNBLNK
1239        integer MDS_RECLEN        integer MDS_RECLEN
1240  C Local variables  C Local variables
1241        character*(80) dataFName,metaFName        character*(MAX_LEN_FNAM) dataFName,metaFName
1242        integer ip,jp,iG,jG,irec,bi,bj,ii,j,k,dUnit,IL        integer ip,jp,iG,jG,irec,bi,bj,i,j,k,dUnit,IL
1243        Real*4 r4seg(sNx)        Real*4 r4seg(sNx)
1244        Real*8 r8seg(sNx)        Real*8 r8seg(sNx)
1245        _RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,nLocz,nSx,nSy)        _RL arr(1-oLx:sNx+oLx,1-oLy:sNy+oLy,nLocz,nSx,nSy)
# Line 774  C Local variables Line 1247  C Local variables
1247        integer length_of_rec        integer length_of_rec
1248        logical fileIsOpen        logical fileIsOpen
1249        character*(max_len_mbuf) msgbuf        character*(max_len_mbuf) msgbuf
1250    cph-usesingle(
1251    #ifdef ALLOW_USE_MPI
1252          integer ii,jj
1253    c     integer iG_IO,jG_IO,npe
1254          integer x_size,y_size
1255          PARAMETER ( x_size = Nx )
1256          PARAMETER ( y_size = Ny )
1257          Real*4 xy_buffer_r4(x_size,y_size)
1258          Real*8 xy_buffer_r8(x_size,y_size)
1259          Real*8 global(Nx,Ny)
1260    #endif
1261    cph-usesingle)
1262    CMM(
1263          integer pIL
1264    CMM)
1265    
1266  C     ------------------------------------------------------------------  C     ------------------------------------------------------------------
1267    
1268  C Only do I/O if I am the master thread  C Only do I/O if I am the master thread
# Line 794  C Record number must be >= 1 Line 1283  C Record number must be >= 1
1283  C Assume nothing  C Assume nothing
1284        fileIsOpen=.FALSE.        fileIsOpen=.FALSE.
1285        IL=ILNBLNK( fName )        IL=ILNBLNK( fName )
1286    CMM(
1287          pIL = ILNBLNK( mdsioLocalDir )
1288    CMM)
1289    CMM(
1290    C Assign special directory
1291          if ( pIL.NE.0 ) then
1292           write(fName,'(2a)') mdsioLocalDir(1:pIL), fName(1:IL)
1293          endif
1294    CMM)
1295    
1296  C Assign a free unit number as the I/O channel for this routine  C Assign a free unit number as the I/O channel for this routine
1297        call MDSFINDUNIT( dUnit, mythid )        call MDSFINDUNIT( dUnit, mythid )
1298    
1299    
1300    cph-usesingle(
1301    #ifdef ALLOW_USE_MPI
1302          _END_MASTER( myThid )
1303    C If option globalFile is desired but does not work or if
1304    C globalFile is too slow, then try using single-CPU I/O.
1305          if (useSingleCpuIO) then
1306    
1307    C Master thread of process 0, only, opens a global file
1308           _BEGIN_MASTER( myThid )
1309            IF( mpiMyId .EQ. 0 ) THEN
1310             write(dataFname,'(2a)') fName(1:IL),'.data'
1311             length_of_rec=MDS_RECLEN(filePrec,x_size*y_size,mythid)
1312             if (irecord .EQ. 1) then
1313              open( dUnit, file=dataFName, status=_NEW_STATUS,
1314         &        access='direct', recl=length_of_rec )
1315             else
1316              open( dUnit, file=dataFName, status=_OLD_STATUS,
1317         &        access='direct', recl=length_of_rec )
1318             endif
1319            ENDIF
1320           _END_MASTER( myThid )
1321    
1322    C Gather array and write it to file, one vertical level at a time
1323           DO k=1,nLocz
1324    C Loop over all processors    
1325            do jp=1,nPy
1326            do ip=1,nPx
1327            DO bj = myByLo(myThid), myByHi(myThid)
1328             DO bi = myBxLo(myThid), myBxHi(myThid)
1329              DO J=1,sNy
1330               JJ=((jp-1)*nSy+(bj-1))*sNy+J
1331               DO I=1,sNx
1332                II=((ip-1)*nSx+(bi-1))*sNx+I
1333                global(II,JJ) = arr_gl(i,bi,ip,j,bj,jp,k)
1334               ENDDO
1335              ENDDO
1336             ENDDO
1337            ENDDO
1338            enddo
1339            enddo
1340            _BEGIN_MASTER( myThid )
1341             IF( mpiMyId .EQ. 0 ) THEN
1342              irec=k+nLocz*(irecord-1)
1343              if (filePrec .eq. precFloat32) then
1344               DO J=1,Ny
1345                DO I=1,Nx
1346                 xy_buffer_r4(I,J) = global(I,J)
1347                ENDDO
1348               ENDDO
1349    #ifdef _BYTESWAPIO
1350               call MDS_BYTESWAPR4( x_size*y_size, xy_buffer_r4 )
1351    #endif
1352               write(dUnit,rec=irec) xy_buffer_r4
1353              elseif (filePrec .eq. precFloat64) then
1354               DO J=1,Ny
1355                DO I=1,Nx
1356                 xy_buffer_r8(I,J) = global(I,J)
1357                ENDDO
1358               ENDDO
1359    #ifdef _BYTESWAPIO
1360               call MDS_BYTESWAPR8( x_size*y_size, xy_buffer_r8 )
1361    #endif
1362               write(dUnit,rec=irec) xy_buffer_r8
1363              else
1364               write(msgbuf,'(a)')
1365         &       ' MDSWRITEFIELD: illegal value for filePrec'
1366               call print_error( msgbuf, mythid )
1367               stop 'ABNORMAL END: S/R MDSWRITEFIELD'
1368              endif
1369             ENDIF
1370            _END_MASTER( myThid )
1371           ENDDO
1372    
1373    C Close data-file and create meta-file
1374           _BEGIN_MASTER( myThid )
1375            IF( mpiMyId .EQ. 0 ) THEN
1376             close( dUnit )
1377             write(metaFName,'(2a)') fName(1:IL),'.meta'
1378             dimList(1,1)=Nx
1379             dimList(2,1)=1
1380             dimList(3,1)=Nx
1381             dimList(1,2)=Ny
1382             dimList(2,2)=1
1383             dimList(3,2)=Ny
1384             dimList(1,3)=nLocz
1385             dimList(2,3)=1
1386             dimList(3,3)=nLocz
1387             ndims=3
1388             if (nLocz .EQ. 1) ndims=2
1389             call MDSWRITEMETA( metaFName, dataFName,
1390         &     filePrec, ndims, dimList, irecord, myIter, mythid )
1391            ENDIF
1392           _END_MASTER( myThid )
1393    C To be safe, make other processes wait for I/O completion
1394           _BARRIER
1395    
1396          elseif ( .NOT. useSingleCpuIO ) then
1397          _BEGIN_MASTER( myThid )
1398    #endif /* ALLOW_USE_MPI */
1399    cph-usesingle)
1400    
1401  C Loop over all processors      C Loop over all processors    
1402        do jp=1,nPy        do jp=1,nPy
1403        do ip=1,nPx        do ip=1,nPx
# Line 808  C Loop over all tiles Line 1407  C Loop over all tiles
1407  C If we are writing to a tiled MDS file then we open each one here  C If we are writing to a tiled MDS file then we open each one here
1408           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles
1409           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles
1410           write(dataFname(1:80),'(2a,i3.3,a,i3.3,a)')           write(dataFname,'(2a,i3.3,a,i3.3,a)')
1411       &              fName(1:IL),'.',iG,'.',jG,'.data'       &              fName(1:IL),'.',iG,'.',jG,'.data'
1412           if (irecord .EQ. 1) then           if (irecord .EQ. 1) then
1413            length_of_rec=MDS_RECLEN( filePrec, sNx, mythid )            length_of_rec=MDS_RECLEN( filePrec, sNx, mythid )
# Line 824  C If we are writing to a tiled MDS file Line 1423  C If we are writing to a tiled MDS file
1423          if (fileIsOpen) then          if (fileIsOpen) then
1424           do k=1,nLocz           do k=1,nLocz
1425            do j=1,sNy            do j=1,sNy
1426               do ii=1,sNx               do i=1,sNx
1427                  arr(ii,j,k,bi,bj)=arr_gl(ii,bi,ip,j,bj,jp,k)                  arr(i,j,k,bi,bj)=arr_gl(i,bi,ip,j,bj,jp,k)
1428               enddo               enddo
1429              iG = 0              iG = 0
1430              jG = 0              jG = 0
# Line 884  C If we were writing to a tiled MDS file Line 1483  C If we were writing to a tiled MDS file
1483  C Create meta-file for each tile if we are tiling  C Create meta-file for each tile if we are tiling
1484           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles           iG=bi+(ip-1)*nsx ! Kludge until unstructered tiles
1485           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles           jG=bj+(jp-1)*nsy ! Kludge until unstructered tiles
1486           write(metaFname(1:80),'(2a,i3.3,a,i3.3,a)')           write(metaFname,'(2a,i3.3,a,i3.3,a)')
1487       &              fName(1:IL),'.',iG,'.',jG,'.meta'       &              fName(1:IL),'.',iG,'.',jG,'.meta'
1488           dimList(1,1)=Nx           dimList(1,1)=Nx
1489           dimList(2,1)=((ip-1)*nSx+(bi-1))*sNx+1           dimList(2,1)=((ip-1)*nSx+(bi-1))*sNx+1
# Line 906  C End of ip,jp loops Line 1505  C End of ip,jp loops
1505         enddo         enddo
1506        enddo        enddo
1507    
   
1508        _END_MASTER( myThid )        _END_MASTER( myThid )
1509    
1510    #ifdef ALLOW_USE_MPI
1511    C endif useSingleCpuIO
1512          endif
1513    #endif /* ALLOW_USE_MPI */
1514    
1515    #endif /* ALLOW_CTRL */
1516  C     ------------------------------------------------------------------  C     ------------------------------------------------------------------
1517        return        return
1518        end        end

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.22