Back to home page

MITgcm

 
 

    


File indexing completed on 2026-10-08 05:08:24 UTC

view on githubraw file Latest commit 27256b2d on 2026-10-07 21:35:21 UTC
6d54cf9ca1 Ed H*0001 #include "AUTODIFF_OPTIONS.h"
bead363026 Jean*0002 #ifdef ALLOW_CTRL
                0003 # include "CTRL_OPTIONS.h"
                0004 #endif
2dcaa8b9a5 Patr*0005 
80818af392 Jean*0006 C     ==================================================================
                0007 C
b7b61e618a Mart*0008 C     adread_adwrite.F: routines to handle the I/O of the TAF
3b6c79e4de Mart*0009 C                       generated code. All files are direct access files.
80818af392 Jean*0010 C     Routines:
3b6c79e4de Mart*0011 C     o  ADREAD    - Read  RL/RS data from file.
                0012 C     o  ADWRITE   - Write RL/RS data to   file.
80818af392 Jean*0013 C
3b6c79e4de Mart*0014 C     Note on short real variables (when _RS expands to real*4):
                0015 C     ADREAD/ADWRITE handles this case properly as in F77 only addresses
                0016 C     are passed to the subroutine. The size-parameter determines
                0017 C     correctly how the passed array var is passed to
                0018 C     MDS_READ/WRITE_TAPE. Some compiler/flag combinations that check
                0019 C     for subroutine argument consistency will complain about a real*4
                0020 C     array being passed to a real*8 array, but this can be avoided by
                0021 C     adding this file to the list of NOOPTFILES with appropriate
                0022 C     NOOPTFLAGS in the build-options file.
80818af392 Jean*0023 C
3b6c79e4de Mart*0024 C     The following input variables are used throughout in the argument
80818af392 Jean*0025 C     lists:
                0026 C
                0027 C     name   -  character
                0028 C                 On entry, name is the extended tape name.
                0029 C     len    -  integer
                0030 C                 On entry, len is the number of characters in name.
                0031 C     tid    -  integer
                0032 C                 On entry, tid identifies the tape.
                0033 C     vid    -  integer
                0034 C                 On entry, vid identifies the variable to be stored on
                0035 C                 the tape.
                0036 C     var    -  real array of dimension length
                0037 C                 On entry, var contains the values to be stored.
                0038 C                           var must not be changed.
                0039 C     size   -  integer
                0040 C                 On entry, size is the size in bytes of the type of
                0041 C                           variable var.
                0042 C     length -  integer
                0043 C                 On entry, length is the dimension of the variable
                0044 C                           stored on the tape.
                0045 C     irec   -  integer
                0046 C                 On entry, irec is the record number to be written.
                0047 C     myThid -  integer
                0048 C                 On entry, myThid is the number of the thread or
                0049 C                           instance of the program.
                0050 C
7855a13227 Mart*0051 C     TAF does not provide the leading argument myThid when compiling
                0052 C     the MITgcmUV code. Instead there is a sed script available that
                0053 C     changes the TAF-generated adjoint code.
80818af392 Jean*0054 C
                0055 C     Only the master thread is allowed to write data and only gobal
                0056 C     model arrays are allowed to be written be the subsequent routines.
                0057 C     Tiled data are to be stored in common blocks. This implies that at
                0058 C     least a two level checkpointing for the adjoint code has to be
                0059 C     available.
                0060 C
                0061 C     ==================================================================
2dcaa8b9a5 Patr*0062 
d151781088 Patr*0063 CBOP
7855a13227 Mart*0064 C     !ROUTINE: ADREAD
d151781088 Patr*0065 C     !INTERFACE:
80818af392 Jean*0066       SUBROUTINE ADREAD(
                0067      I                   myThid,
2dcaa8b9a5 Patr*0068      I                   name,
                0069      I                   len,
                0070      I                   tid,
                0071      I                   vid,
                0072      O                   var,
                0073      I                   size,
                0074      I                   length,
3b6c79e4de Mart*0075      I                   irec )
2dcaa8b9a5 Patr*0076 
d151781088 Patr*0077 C     !DESCRIPTION: \bv
80818af392 Jean*0078 C     ==================================================================
                0079 C     SUBROUTINE adread
                0080 C     ==================================================================
                0081 C     o Read direct access file.
                0082 C     A call to this routine implies an open-read-close sequence
7855a13227 Mart*0083 C     since it uses the MITgcmUV i/o routine MDS_READ_TAPE. Only
80818af392 Jean*0084 C     the master thread reads the data. Otherwise each thread would
                0085 C     read from file.
                0086 C     started: Christian Eckert eckert@mit.edu 30-Jun-1999
                0087 C     ==================================================================
                0088 C     SUBROUTINE adread
                0089 C     ==================================================================
d151781088 Patr*0090 C     \ev
2dcaa8b9a5 Patr*0091 
d151781088 Patr*0092 C     !USES:
80818af392 Jean*0093       IMPLICIT NONE
2dcaa8b9a5 Patr*0094 
80818af392 Jean*0095 C     == global variables ==
2dcaa8b9a5 Patr*0096 #include "EEPARAMS.h"
                0097 #include "SIZE.h"
b76df2dc75 Patr*0098 #include "PARAMS.h"
7855a13227 Mart*0099 #ifdef ALLOW_CTRL
5cf4364659 Mart*0100 # include "CTRL_SIZE.h"
4d72283393 Mart*0101 # include "CTRL.h"
65754df434 Mart*0102 # include "OPTIMCYCLE.h"
7855a13227 Mart*0103 #endif
2f58e54336 Gael*0104 #include "AUTODIFF.h"
2dcaa8b9a5 Patr*0105 
d151781088 Patr*0106 C     !INPUT/OUTPUT PARAMETERS:
3b6c79e4de Mart*0107 C     myThid :: number of the thread or instance of the program.
c55bfc268c Jean*0108 C     name   :: extended tape name.
                0109 C     len    :: number of characters in name.
                0110 C     tid    :: tape identifier.
                0111 C     vid    :: identifies the variable to be stored on tape.
                0112 C     var    :: values to be stored.
                0113 C     size   :: size in bytes of the type of variable var.
                0114 C     length :: dimension of the variable stored on the tape.
                0115 C     irec   :: record number to be written.
80818af392 Jean*0116       INTEGER myThid
                0117       CHARACTER*(*) name
                0118       INTEGER len
                0119       INTEGER tid
                0120       INTEGER vid
3b6c79e4de Mart*0121       real*8  var(*)
80818af392 Jean*0122       INTEGER size
                0123       INTEGER length
                0124       INTEGER irec
2dcaa8b9a5 Patr*0125 
c55bfc268c Jean*0126 C     !FUNCTIONS:
                0127       INTEGER  ILNBLNK
                0128       EXTERNAL ILNBLNK
                0129 
d151781088 Patr*0130 C     !LOCAL VARIABLES:
80818af392 Jean*0131       CHARACTER*(MAX_LEN_FNAM) fname
                0132       CHARACTER*(MAX_LEN_MBUF) msgBuf
                0133       INTEGER filePrec
                0134       INTEGER il, jl, lenLoc
c55bfc268c Jean*0135       real*8  dummyR8(1)
                0136       real*4  dummyR4(1)
9105dbec95 Jean*0137       LOGICAL useWHTapeIO
d151e07a73 Mart*0138 #ifdef ALLOW_AUTODIFF_WHTAPEIO
80818af392 Jean*0139       INTEGER n2d,length2d, jrec, i2d, j2d
d151e07a73 Mart*0140 #endif
d151781088 Patr*0141 CEOP
2dcaa8b9a5 Patr*0142 
b90aba42f8 Patr*0143 #ifdef ALLOW_DEBUG
862d160a2f Jean*0144       IF ( debugMode ) CALL DEBUG_ENTER('ADREAD',myThid)
b90aba42f8 Patr*0145 #endif
516917913e Patr*0146 
80818af392 Jean*0147 C--   default is to write tape-files of same precision as array:
                0148 C     convert bytes to file-prec
                0149       filePrec = 8*size
516917913e Patr*0150       IF ( doSinglePrecTapelev ) THEN
c55bfc268c Jean*0151        filePrec = precFloat32
516917913e Patr*0152       ENDIF
b90aba42f8 Patr*0153 
9105dbec95 Jean*0154       useWHTapeIO = .FALSE.
d151e07a73 Mart*0155 #ifdef ALLOW_AUTODIFF_WHTAPEIO
9105dbec95 Jean*0156 C    determine number of 2d fields
                0157       length2d = (sNx+2*OLx)*(sNy+2*OLy)*nSx*nSy
                0158       n2d = INT(length/length2d)
                0159       IF ( size.EQ.8 .AND. n2d*length2d.EQ.length ) THEN
                0160 C-    only use "WHTAPEIO" when type and length match
                0161         useWHTapeIO = .TRUE.
80818af392 Jean*0162       ENDIF
d151e07a73 Mart*0163 #endif /* ALLOW_AUTODIFF_WHTAPEIO */
9105dbec95 Jean*0164 
                0165       il = ILNBLNK( name )
                0166       jl = ILNBLNK( adTapeDir )
                0167       IF ( useWHTapeIO ) THEN
                0168         lenLoc = il+jl
                0169         WRITE(fname,'(2A)') adTapeDir(1:jl),name(1:il)
                0170       ELSE
                0171         lenLoc = il+jl+7
                0172         WRITE(fname,'(3A,I4.4)')
                0173      &     adTapeDir(1:jl),name(1:il),'.it',optimcycle
                0174       ENDIF
c55bfc268c Jean*0175 #ifdef ALLOW_DEBUG
                0176       IF ( debugLevel.GE.debLevC ) THEN
                0177         WRITE(msgBuf,'(2A,3I6,I9,2I3,2A)') 'ADREAD: ',
                0178      &    ' tid,vid, irec, length, prec(x2)=', tid, vid, irec,
                0179      &      length, size, filePrec, ' fname=', fname(1:lenLoc)
                0180         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0181      &                      SQUEEZE_RIGHT, myThid )
                0182       ENDIF
                0183 #endif
d151e07a73 Mart*0184 
e33827a95a Gael*0185 #ifdef ALLOW_AUTODIFF_WHTAPEIO
9105dbec95 Jean*0186       IF ( useWHTapeIO ) THEN
80818af392 Jean*0187 
7855a13227 Mart*0188 cc      IF (n2d*length2d.EQ.length) THEN
80818af392 Jean*0189         DO i2d=1,n2d
7855a13227 Mart*0190           IF (tapeFileUnit.EQ.0) THEN
2f58e54336 Gael*0191             jrec=irec
7855a13227 Mart*0192           ELSE
2f58e54336 Gael*0193             tapeFileCounter=tapeFileCounter+1
                0194             jrec=tapeFileCounter+tapeMaxCounter*(irec-1)
7855a13227 Mart*0195             IF (tapeFileCounter.GT.tapeMaxCounter) THEN
                0196               WRITE(msgBuf,'(A,2I5)')
                0197      &              'ADREAD: tapeFileCounter > tapeMaxCounter ',
                0198      &              tapeFileCounter, tapeMaxCounter
                0199               CALL PRINT_ERROR( msgBuf, myThid )
                0200               WRITE(msgBuf,'(2A)') 'for file ', fname(1:lenLoc)
                0201               CALL PRINT_ERROR( msgBuf, myThid )
                0202               STOP 'ABNORMAL END: S/R ADREAD'
                0203             ENDIF
                0204           ENDIF
2f58e54336 Gael*0205           j2d=(i2d-1)*length2d+1
7855a13227 Mart*0206           CALL MDS_READ_WHALOS(fname,lenLoc,filePrec,tapeFileUnit,
80818af392 Jean*0207      &      1,var(j2d),jrec,tapeSingleCpuIO,tapeBufferIO,myThid)
                0208         ENDDO
7855a13227 Mart*0209 cc      ELSE
                0210 C     The other case actually does not (and should not) occur within the
                0211 C     main loop, where we only store global arrays (i.e. with i,j,bi,bj
3b6c79e4de Mart*0212 C     indices) to disk. At init and final time it is always possible to
                0213 C     recompute or store in memory without much trouble or computational
                0214 C     cost.
6322f3ee50 Patr*0215 cc         WRITE(msgBuf,'(3A)')
3c775cbf98 Mart*0216 cc     &        'ADREAD: ', name, ' was not saved to tape.'
6322f3ee50 Patr*0217 cc         CALL PRINT_ERROR( msgBuf, myThid )
3c775cbf98 Mart*0218 cc         STOP 'ABNORMAL END: S/R ADREAD'
7855a13227 Mart*0219 cc      ENDIF
862d160a2f Jean*0220 
9105dbec95 Jean*0221       ELSE
e33827a95a Gael*0222 #else
9105dbec95 Jean*0223       IF ( .TRUE. ) THEN
e33827a95a Gael*0224 #endif /* ALLOW_AUTODIFF_WHTAPEIO */
                0225 
9105dbec95 Jean*0226         _BEGIN_MASTER( myThid )
                0227          IF ( size.EQ.4 ) THEN
                0228 c          CALL MDSREADVECTOR( fname, filePrec, 'RS',
                0229 c    &                         length, var, 1, 1, irec, myThid )
                0230            CALL MDS_READ_TAPE( fname, filePrec, 'R4',
                0231      &                         length, dummyR8, var,
                0232      &                         useSingleCpuIO, irec, myThid )
                0233          ELSE
                0234 c          CALL MDSREADVECTOR( fname, filePrec, 'RL',
                0235 c    &                         length, var, 1, 1, irec, myThid )
                0236            CALL MDS_READ_TAPE( fname, filePrec, 'R8',
                0237      &                         length,  var, dummyR4,
                0238      &                         useSingleCpuIO, irec, myThid )
                0239          ENDIF
                0240         _END_MASTER( myThid )
                0241 
                0242 C     end if useWHTapeIO / else
                0243       ENDIF
                0244 
80818af392 Jean*0245 C     Everyone must wait for the read operation to be completed.
c55bfc268c Jean*0246 c     _BARRIER
2dcaa8b9a5 Patr*0247 
b90aba42f8 Patr*0248 #ifdef ALLOW_DEBUG
862d160a2f Jean*0249       IF ( debugMode ) CALL DEBUG_LEAVE('ADREAD',myThid)
b90aba42f8 Patr*0250 #endif
                0251 
80818af392 Jean*0252       RETURN
                0253       END
2dcaa8b9a5 Patr*0254 
80818af392 Jean*0255 C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
d151781088 Patr*0256 CBOP
7855a13227 Mart*0257 C     !ROUTINE: ADWRITE
d151781088 Patr*0258 C     !INTERFACE:
80818af392 Jean*0259       SUBROUTINE ADWRITE(
                0260      I                    myThid,
2dcaa8b9a5 Patr*0261      I                    name,
                0262      I                    len,
                0263      I                    tid,
                0264      I                    vid,
                0265      I                    var,
                0266      I                    size,
                0267      I                    length,
3b6c79e4de Mart*0268      I                    irec )
2dcaa8b9a5 Patr*0269 
d151781088 Patr*0270 C     !DESCRIPTION: \bv
80818af392 Jean*0271 C     ==================================================================
                0272 C     SUBROUTINE adwrite
                0273 C     ==================================================================
                0274 C     o Write to direct access file.
                0275 C     A call to this routine implies an open-read-close sequence
7855a13227 Mart*0276 C     since it uses the MITgcmUV i/o routine MDS_WRITE_TAPE. Only
80818af392 Jean*0277 C     the master thread writes the data. Otherwise each thread would
                0278 C     write to file. This would result in an excessive waste of
                0279 C     disk space.
                0280 C     started: Christian Eckert eckert@mit.edu 30-Jun-1999
                0281 C     ==================================================================
                0282 C     SUBROUTINE adwrite
                0283 C     ==================================================================
d151781088 Patr*0284 C     \ev
2dcaa8b9a5 Patr*0285 
d151781088 Patr*0286 C     !USES:
80818af392 Jean*0287       IMPLICIT NONE
2dcaa8b9a5 Patr*0288 
80818af392 Jean*0289 C     == global variables ==
2dcaa8b9a5 Patr*0290 #include "EEPARAMS.h"
                0291 #include "SIZE.h"
b76df2dc75 Patr*0292 #include "PARAMS.h"
7855a13227 Mart*0293 #ifdef ALLOW_CTRL
5cf4364659 Mart*0294 # include "CTRL_SIZE.h"
4d72283393 Mart*0295 # include "CTRL.h"
65754df434 Mart*0296 # include "OPTIMCYCLE.h"
7855a13227 Mart*0297 #endif
2f58e54336 Gael*0298 #include "AUTODIFF.h"
2dcaa8b9a5 Patr*0299 
d151781088 Patr*0300 C     !INPUT/OUTPUT PARAMETERS:
3b6c79e4de Mart*0301 C     myThid :: number of the thread or instance of the program.
c55bfc268c Jean*0302 C     name   :: extended tape name.
                0303 C     len    :: number of characters in name.
                0304 C     tid    :: tape identifier.
                0305 C     vid    :: identifies the variable to be stored on tape.
                0306 C     var    :: values to be stored.
                0307 C     size   :: size in bytes of the type of variable var.
                0308 C     length :: dimension of the variable stored on the tape.
                0309 C     irec   :: record number to be written.
80818af392 Jean*0310       INTEGER myThid
                0311       CHARACTER*(*) name
                0312       INTEGER len
                0313       INTEGER tid
                0314       INTEGER vid
3b6c79e4de Mart*0315       real*8  var(*)
80818af392 Jean*0316       INTEGER size
                0317       INTEGER length
                0318       INTEGER irec
2dcaa8b9a5 Patr*0319 
c55bfc268c Jean*0320 C     !FUNCTIONS:
                0321       INTEGER ILNBLNK
                0322       EXTERNAL ILNBLNK
                0323 
d151781088 Patr*0324 C     !LOCAL VARIABLES:
80818af392 Jean*0325       CHARACTER*(MAX_LEN_FNAM) fname
                0326       CHARACTER*(MAX_LEN_MBUF) msgBuf
                0327       INTEGER filePrec
                0328       INTEGER il,jl,lenLoc
c55bfc268c Jean*0329       real*8  dummyR8(1)
                0330       real*4  dummyR4(1)
9105dbec95 Jean*0331       LOGICAL useWHTapeIO
c55bfc268c Jean*0332       LOGICAL globalfile
d151e07a73 Mart*0333 #ifdef ALLOW_AUTODIFF_WHTAPEIO
80818af392 Jean*0334       INTEGER n2d,length2d, jrec, i2d, j2d
d151e07a73 Mart*0335 #endif
d151781088 Patr*0336 CEOP
2dcaa8b9a5 Patr*0337 
b90aba42f8 Patr*0338 #ifdef ALLOW_DEBUG
862d160a2f Jean*0339       IF ( debugMode ) CALL DEBUG_ENTER('ADWRITE',myThid)
b90aba42f8 Patr*0340 #endif
                0341 
80818af392 Jean*0342 C--   default is to write tape-files of same precision as array:
                0343 C     convert bytes to file-prec
                0344       filePrec = 8*size
516917913e Patr*0345       IF ( doSinglePrecTapelev ) THEN
c55bfc268c Jean*0346        filePrec = precFloat32
516917913e Patr*0347       ENDIF
                0348 
9105dbec95 Jean*0349       useWHTapeIO = .FALSE.
d151e07a73 Mart*0350 #ifdef ALLOW_AUTODIFF_WHTAPEIO
9105dbec95 Jean*0351 C    determine number of 2d fields
                0352       length2d = (sNx+2*OLx)*(sNy+2*OLy)*nSx*nSy
                0353       n2d = INT(length/length2d)
                0354       IF ( size.EQ.8 .AND. n2d*length2d.EQ.length ) THEN
                0355 C-    only use "WHTAPEIO" when type and length match
                0356         useWHTapeIO = .TRUE.
80818af392 Jean*0357       ENDIF
d151e07a73 Mart*0358 #endif /* ALLOW_AUTODIFF_WHTAPEIO */
9105dbec95 Jean*0359 
                0360       il = ILNBLNK( name )
                0361       jl = ILNBLNK( adTapeDir )
                0362       IF ( useWHTapeIO ) THEN
                0363         lenLoc = il+jl
                0364         WRITE(fname,'(2A)') adTapeDir(1:jl),name(1:il)
                0365       ELSE
                0366         lenLoc = il+jl+7
                0367         WRITE(fname,'(3A,I4.4)')
                0368      &     adTapeDir(1:jl),name(1:il),'.it',optimcycle
                0369       ENDIF
d151e07a73 Mart*0370 #ifdef ALLOW_DEBUG
c55bfc268c Jean*0371       IF ( debugLevel .GE. debLevC ) THEN
                0372         WRITE(msgBuf,'(2A,3I6,I9,2I3,2A)') 'ADWRITE:',
                0373      &    ' tid,vid, irec, length, prec(x2)=', tid, vid, irec,
                0374      &      length, size, filePrec, ' fname=', fname(1:lenLoc)
                0375         CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0376      &                      SQUEEZE_RIGHT, myThid )
                0377       ENDIF
d151e07a73 Mart*0378 #endif
                0379 
e33827a95a Gael*0380 #ifdef ALLOW_AUTODIFF_WHTAPEIO
9105dbec95 Jean*0381       IF ( useWHTapeIO ) THEN
80818af392 Jean*0382 
7855a13227 Mart*0383 cc      IF (n2d*length2d.EQ.length) THEN
80818af392 Jean*0384         DO i2d=1,n2d
7855a13227 Mart*0385           IF (tapeFileUnit.EQ.0) THEN
2f58e54336 Gael*0386             jrec=irec
7855a13227 Mart*0387           ELSE
3c775cbf98 Mart*0388             tapeFileCounter = tapeFileCounter+1
                0389             jrec = tapeFileCounter+tapeMaxCounter*(irec-1)
                0390             IF ( tapeFileCounter.GT.tapeMaxCounter ) THEN
                0391               WRITE(msgBuf,'(2A,I6,A,I6,A)') 'ADWRITE: ',
                0392      &            'tapeFileCounter (=',tapeFileCounter,
                0393      &            ') > tapeMaxCounter (= nWh =', tapeMaxCounter, ')'
7855a13227 Mart*0394               CALL PRINT_ERROR( msgBuf, myThid )
3c775cbf98 Mart*0395               WRITE(msgBuf,'(3A)') 'ADWRITE: ',
                0396      &            ' for file: ', fname(1:lenLoc)
7855a13227 Mart*0397               CALL PRINT_ERROR( msgBuf, myThid )
3c775cbf98 Mart*0398 C     Here, we cannot determine how many tapeFiles we need, so we print
                0399 C     this rather unspecific instruction.
                0400               WRITE(msgBuf,'(2A)') 'ADWRITE: ',
                0401      &             '==> Need to increase "nWh" in: MDSIO_BUFF_WH.h'
                0402               CALL PRINT_ERROR( msgBuf, myThid )
                0403               WRITE(msgBuf,'(2A)') 'ADWRITE: Tip to find lowest',
                0404      &             ' allowed "nWh": setting debugLevel >= 3'
                0405               CALL PRINT_ERROR( msgBuf , myThid )
                0406               WRITE(msgBuf,'(2A)') 'ADWRITE:  will report ',
                0407      &             '"tapeFileCounter" to STDOUT (can grep for)'
                0408               CALL PRINT_ERROR( msgBuf , myThid )
7855a13227 Mart*0409               STOP 'ABNORMAL END: S/R ADWRITE'
                0410             ENDIF
3c775cbf98 Mart*0411 #ifdef ALLOW_DEBUG
                0412             IF ( debugLevel.GE.debLevC ) THEN
                0413 C     Print tapeFileCounter to help find minimum tapeMaxCounter=nWh value
                0414               WRITE(msgBuf,'(A,I6)') 'ADWRITE:  tapeFileCounter =',
                0415      &            tapeFileCounter
                0416               CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
                0417      &                      SQUEEZE_RIGHT, myThid )
                0418             ENDIF
                0419 #endif
7855a13227 Mart*0420           ENDIF
2f58e54336 Gael*0421           j2d=(i2d-1)*length2d+1
7855a13227 Mart*0422           CALL MDS_WRITE_WHALOS(fname,lenLoc,filePrec,tapeFileUnit,
80818af392 Jean*0423      &      1,var(j2d),jrec,tapeSingleCpuIO,tapeBufferIO,myThid)
                0424         ENDDO
7855a13227 Mart*0425 cc      ELSE
                0426 cc       WRITE(msgBuf,'(3A)')
6322f3ee50 Patr*0427 cc     &      'ADWRITE: ',fname(1:lenLoc),'was not read from tape.'
7855a13227 Mart*0428 cc       CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
6322f3ee50 Patr*0429 cc     &                     SQUEEZE_RIGHT , myThid)
7855a13227 Mart*0430 cc      ENDIF
e33827a95a Gael*0431 
9105dbec95 Jean*0432       ELSE
e33827a95a Gael*0433 #else
9105dbec95 Jean*0434       IF ( .TRUE. ) THEN
e33827a95a Gael*0435 #endif /* ALLOW_AUTODIFF_WHTAPEIO */
                0436 
9105dbec95 Jean*0437         globalfile = globalFiles
                0438 c       globalfile = .FALSE.
                0439 
                0440         _BEGIN_MASTER( myThid )
                0441         IF ( size.EQ.4 ) THEN
                0442 c         CALL MDSWRITEVECTOR( fname, filePrec, globalfile, 'RS',
                0443 c    &                         length, var, 1, 1, irec, 0, myThid )
                0444           CALL MDS_WRITE_TAPE( fname, filePrec, globalfile, 'R4',
                0445      &                         length, dummyR8, var,
                0446      &                         useSingleCpuIO, irec, 0, myThid )
                0447         ELSE
                0448 c         CALL MDSWRITEVECTOR( fname, filePrec, globalfile, 'RL',
                0449 c    &                         length, var, 1, 1, irec, 0, myThid )
                0450           CALL MDS_WRITE_TAPE( fname, filePrec, globalfile, 'R8',
                0451      &                         length, var, dummyR4,
                0452      &                         useSingleCpuIO, irec, 0, myThid )
                0453         ENDIF
                0454         _END_MASTER( myThid )
                0455 
                0456 C     end if useWHTapeIO / else
                0457       ENDIF
                0458 
80818af392 Jean*0459 C     Everyone must wait for the write operation to be completed.
c55bfc268c Jean*0460 c     _BARRIER
2dcaa8b9a5 Patr*0461 
b90aba42f8 Patr*0462 #ifdef ALLOW_DEBUG
862d160a2f Jean*0463       IF ( debugMode ) CALL DEBUG_LEAVE('ADWRITE',myThid)
b90aba42f8 Patr*0464 #endif
                0465 
80818af392 Jean*0466       RETURN
                0467       END