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

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

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

revision 1.16 by jmc, Tue Sep 1 19:08:27 2009 UTC revision 1.17 by jmc, Thu Dec 23 02:41:47 2010 UTC
# Line 57  C  routine arguments and file, i.e., if Line 57  C  routine arguments and file, i.e., if
57  C  the meta information will record the number of records to be 2. This,  C  the meta information will record the number of records to be 2. This,
58  C  again, is because we have read the meta information. To be fixed.  C  again, is because we have read the meta information. To be fixed.
59  C  C
60    C- Multi-threaded: Only Master thread does IO (and MPI calls) and get data
61    C   from a shared buffer that any thread can copy to.
62    C- Convention regarding thread synchronisation (BARRIER):
63    C  A per-thread (or per tile) partition of the 2-D shared-buffer (sharedLocBuf_r4/r8)
64    C   is readily available => any access (e.g., by master-thread) to a portion
65    C   owned by an other thread is put between BARRIER (protected).
66    C  No thread partition exist for the 3-D shared buffer (shared3dBuf_r4/r8);
67    C   Therefore, the 3-D buffer is considered to be owned by master-thread and
68    C   any access by other than master thread is put between BARRIER (protected).
69    C
70  C Created: 03/16/99 adcroft@mit.edu  C Created: 03/16/99 adcroft@mit.edu
71  C Changed: 01/06/02 menemenlis@jpl.nasa.gov  C Changed: 01/06/02 menemenlis@jpl.nasa.gov
72  C          added useSingleCpuIO hack  C          added useSingleCpuIO hack
# Line 255  C-      copy from fldRL/RS(level=k) to 2 Line 265  C-      copy from fldRL/RS(level=k) to 2
265          IF ( filePrec.EQ.precFloat32 ) THEN          IF ( filePrec.EQ.precFloat32 ) THEN
266            IF ( arrType.EQ.'RS' ) THEN            IF ( arrType.EQ.'RS' ) THEN
267              CALL MDS_PASS_R4toRS( sharedLocBuf_r4, fldRS,              CALL MDS_PASS_R4toRS( sharedLocBuf_r4, fldRS,
268       I                       1, k, kSize, 0, 0, .FALSE., myThid )       I                 0, 0, 1, k, kSize, 0, 0, .FALSE., myThid )
269            ELSEIF ( arrType.EQ.'RL' ) THEN            ELSEIF ( arrType.EQ.'RL' ) THEN
270              CALL MDS_PASS_R4toRL( sharedLocBuf_r4, fldRL,              CALL MDS_PASS_R4toRL( sharedLocBuf_r4, fldRL,
271       I                       1, k, kSize, 0, 0, .FALSE., myThid )       I                 0, 0, 1, k, kSize, 0, 0, .FALSE., myThid )
272            ELSE            ELSE
273              WRITE(msgBuf,'(2A)')              WRITE(msgBuf,'(2A)')
274       &      ' MDS_WRITE_FIELD: illegal value for arrType=', arrType       &      ' MDS_WRITE_FIELD: illegal value for arrType=', arrType
# Line 276  C Wait for all threads to finish filling Line 286  C Wait for all threads to finish filling
286          ELSEIF ( filePrec.EQ.precFloat64 ) THEN          ELSEIF ( filePrec.EQ.precFloat64 ) THEN
287            IF ( arrType.EQ.'RS' ) THEN            IF ( arrType.EQ.'RS' ) THEN
288              CALL MDS_PASS_R8toRS( sharedLocBuf_r8, fldRS,              CALL MDS_PASS_R8toRS( sharedLocBuf_r8, fldRS,
289       I                       1, k, kSize, 0, 0, .FALSE., myThid )       I                 0, 0, 1, k, kSize, 0, 0, .FALSE., myThid )
   
290            ELSEIF ( arrType.EQ.'RL' ) THEN            ELSEIF ( arrType.EQ.'RL' ) THEN
291              CALL MDS_PASS_R8toRL( sharedLocBuf_r8, fldRL,              CALL MDS_PASS_R8toRL( sharedLocBuf_r8, fldRL,
292       I                       1, k, kSize, 0, 0, .FALSE., myThid )       I                 0, 0, 1, k, kSize, 0, 0, .FALSE., myThid )
293            ELSE            ELSE
294              WRITE(msgBuf,'(2A)')              WRITE(msgBuf,'(2A)')
295       &      ' MDS_WRITE_FIELD: illegal value for arrType=', arrType       &      ' MDS_WRITE_FIELD: illegal value for arrType=', arrType
# Line 333  C---+----1----+----2----+----3----+----4 Line 342  C---+----1----+----2----+----3----+----4
342  C---  else .NOT.useSingleCpuIO  C---  else .NOT.useSingleCpuIO
343        ELSE        ELSE
344    
345    C Wait for all thread to finish. This prevents other threads (e.g., master)
346    C  to continue to acces 3-D buffer while this thread is filling it.
347            CALL BAR2( myThid )
348    
349  C---    Copy from fldRL/RS to 3-D buffer (multi-threads):  C---    Copy from fldRL/RS to 3-D buffer (multi-threads):
350          IF ( filePrec.EQ.precFloat32 ) THEN          IF ( filePrec.EQ.precFloat32 ) THEN
351            IF ( arrType.EQ.'RS' ) THEN            IF ( arrType.EQ.'RS' ) THEN
352              CALL MDS_PASS_R4toRS( shared3dBuf_r4, fldRS,              CALL MDS_PASS_R4toRS( shared3dBuf_r4, fldRS,
353       I                    nNz, kLo, kSize, 0,0, .FALSE., myThid )       I              0, 0, nNz, kLo, kSize, 0,0, .FALSE., myThid )
354            ELSEIF ( arrType.EQ.'RL' ) THEN            ELSEIF ( arrType.EQ.'RL' ) THEN
355              CALL MDS_PASS_R4toRL( shared3dBuf_r4, fldRL,              CALL MDS_PASS_R4toRL( shared3dBuf_r4, fldRL,
356       I                    nNz, kLo, kSize, 0,0, .FALSE., myThid )       I              0, 0, nNz, kLo, kSize, 0,0, .FALSE., myThid )
357            ELSE            ELSE
358              WRITE(msgBuf,'(2A)')              WRITE(msgBuf,'(2A)')
359       &      ' MDS_WRITE_FIELD: illegal value for arrType=', arrType       &      ' MDS_WRITE_FIELD: illegal value for arrType=', arrType
# Line 351  C---    Copy from fldRL/RS to 3-D buffer Line 364  C---    Copy from fldRL/RS to 3-D buffer
364          ELSEIF ( filePrec.EQ.precFloat64 ) THEN          ELSEIF ( filePrec.EQ.precFloat64 ) THEN
365            IF ( arrType.EQ.'RS' ) THEN            IF ( arrType.EQ.'RS' ) THEN
366              CALL MDS_PASS_R8toRS( shared3dBuf_r8, fldRS,              CALL MDS_PASS_R8toRS( shared3dBuf_r8, fldRS,
367       I                    nNz, kLo, kSize, 0,0, .FALSE., myThid )       I              0, 0, nNz, kLo, kSize, 0,0, .FALSE., myThid )
368            ELSEIF ( arrType.EQ.'RL' ) THEN            ELSEIF ( arrType.EQ.'RL' ) THEN
369              CALL MDS_PASS_R8toRL( shared3dBuf_r8, fldRL,              CALL MDS_PASS_R8toRL( shared3dBuf_r8, fldRL,
370       I                    nNz, kLo, kSize, 0,0, .FALSE., myThid )       I              0, 0, nNz, kLo, kSize, 0,0, .FALSE., myThid )
371            ELSE            ELSE
372              WRITE(msgBuf,'(2A)')              WRITE(msgBuf,'(2A)')
373       &      ' MDS_WRITE_FIELD: illegal value for arrType=', arrType       &      ' MDS_WRITE_FIELD: illegal value for arrType=', arrType
# Line 530  C- endif iAmDoingIO Line 543  C- endif iAmDoingIO
543    
544  C Make other threads wait for I/O completion so that after this,  C Make other threads wait for I/O completion so that after this,
545  C  3-D buffer can again be modified by any thread  C  3-D buffer can again be modified by any thread
546         CALL BAR2( myThid )  c      CALL BAR2( myThid )
547    
548  C     if useSingleCpuIO / else / end  C     if useSingleCpuIO / else / end
549        ENDIF        ENDIF

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

  ViewVC Help
Powered by ViewVC 1.1.22