File indexing completed on 2024-03-02 06:10:09 UTC
view on githubraw file Latest commit 5cf43646 on 2024-03-01 18:50:49 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
0007
3b6c79e4de Mart*0008
0009
80818af392 Jean*0010
3b6c79e4de Mart*0011
0012
80818af392 Jean*0013
3b6c79e4de Mart*0014
0015
0016
0017
0018
0019
0020
0021
0022
80818af392 Jean*0023
3b6c79e4de Mart*0024
80818af392 Jean*0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
7855a13227 Mart*0054
0055
0056
80818af392 Jean*0057
0058
0059
0060
0061
0062
0063
0064
2dcaa8b9a5 Patr*0065
d151781088 Patr*0066
7855a13227 Mart*0067
d151781088 Patr*0068
80818af392 Jean*0069 SUBROUTINE ADREAD(
0070 I myThid,
2dcaa8b9a5 Patr*0071 I name,
0072 I len,
0073 I tid,
0074 I vid,
0075 O var,
0076 I size,
0077 I length,
3b6c79e4de Mart*0078 I irec )
2dcaa8b9a5 Patr*0079
d151781088 Patr*0080
80818af392 Jean*0081
0082
0083
0084
0085
7855a13227 Mart*0086
80818af392 Jean*0087
0088
0089
0090
0091
0092
d151781088 Patr*0093
2dcaa8b9a5 Patr*0094
d151781088 Patr*0095
80818af392 Jean*0096 IMPLICIT NONE
2dcaa8b9a5 Patr*0097
80818af392 Jean*0098
2dcaa8b9a5 Patr*0099 #include "EEPARAMS.h"
0100 #include "SIZE.h"
b76df2dc75 Patr*0101 #include "PARAMS.h"
7855a13227 Mart*0102 #ifdef ALLOW_CTRL
5cf4364659 Mart*0103 # include "CTRL_SIZE.h"
4d72283393 Mart*0104 # include "CTRL.h"
65754df434 Mart*0105 # include "OPTIMCYCLE.h"
7855a13227 Mart*0106 #endif
0107
2f58e54336 Gael*0108 #include "AUTODIFF.h"
2dcaa8b9a5 Patr*0109
d151781088 Patr*0110
3b6c79e4de Mart*0111
c55bfc268c Jean*0112
0113
0114
0115
0116
0117
0118
0119
80818af392 Jean*0120 INTEGER myThid
0121 CHARACTER*(*) name
0122 INTEGER len
0123 INTEGER tid
0124 INTEGER vid
3b6c79e4de Mart*0125 real*8 var(*)
80818af392 Jean*0126 INTEGER size
0127 INTEGER length
0128 INTEGER irec
2dcaa8b9a5 Patr*0129
c55bfc268c Jean*0130
0131 INTEGER ILNBLNK
0132 EXTERNAL ILNBLNK
0133
d151781088 Patr*0134
80818af392 Jean*0135 CHARACTER*(MAX_LEN_FNAM) fname
0136 CHARACTER*(MAX_LEN_MBUF) msgBuf
0137 INTEGER filePrec
0138 INTEGER il, jl, lenLoc
c55bfc268c Jean*0139 real*8 dummyR8(1)
0140 real*4 dummyR4(1)
9105dbec95 Jean*0141 LOGICAL useWHTapeIO
d151e07a73 Mart*0142 #ifdef ALLOW_AUTODIFF_WHTAPEIO
80818af392 Jean*0143 INTEGER n2d,length2d, jrec, i2d, j2d
d151e07a73 Mart*0144 #endif
d151781088 Patr*0145
2dcaa8b9a5 Patr*0146
b90aba42f8 Patr*0147 #ifdef ALLOW_DEBUG
862d160a2f Jean*0148 IF ( debugMode ) CALL DEBUG_ENTER('ADREAD',myThid)
b90aba42f8 Patr*0149 #endif
516917913e Patr*0150
80818af392 Jean*0151
0152
0153 filePrec = 8*size
516917913e Patr*0154 IF ( doSinglePrecTapelev ) THEN
c55bfc268c Jean*0155 filePrec = precFloat32
516917913e Patr*0156 ENDIF
b90aba42f8 Patr*0157
9105dbec95 Jean*0158 useWHTapeIO = .FALSE.
d151e07a73 Mart*0159 #ifdef ALLOW_AUTODIFF_WHTAPEIO
9105dbec95 Jean*0160
0161 length2d = (sNx+2*OLx)*(sNy+2*OLy)*nSx*nSy
0162 n2d = INT(length/length2d)
0163 IF ( size.EQ.8 .AND. n2d*length2d.EQ.length ) THEN
0164
0165 useWHTapeIO = .TRUE.
80818af392 Jean*0166 ENDIF
d151e07a73 Mart*0167 #endif /* ALLOW_AUTODIFF_WHTAPEIO */
9105dbec95 Jean*0168
0169 il = ILNBLNK( name )
0170 jl = ILNBLNK( adTapeDir )
0171 IF ( useWHTapeIO ) THEN
0172 lenLoc = il+jl
0173 WRITE(fname,'(2A)') adTapeDir(1:jl),name(1:il)
0174 ELSE
0175 lenLoc = il+jl+7
0176 WRITE(fname,'(3A,I4.4)')
0177 & adTapeDir(1:jl),name(1:il),'.it',optimcycle
0178 ENDIF
c55bfc268c Jean*0179 #ifdef ALLOW_DEBUG
0180 IF ( debugLevel.GE.debLevC ) THEN
0181 WRITE(msgBuf,'(2A,3I6,I9,2I3,2A)') 'ADREAD: ',
0182 & ' tid,vid, irec, length, prec(x2)=', tid, vid, irec,
0183 & length, size, filePrec, ' fname=', fname(1:lenLoc)
0184 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0185 & SQUEEZE_RIGHT, myThid )
0186 ENDIF
0187 #endif
d151e07a73 Mart*0188
e33827a95a Gael*0189 #ifdef ALLOW_AUTODIFF_WHTAPEIO
9105dbec95 Jean*0190 IF ( useWHTapeIO ) THEN
80818af392 Jean*0191
7855a13227 Mart*0192
80818af392 Jean*0193 DO i2d=1,n2d
7855a13227 Mart*0194 IF (tapeFileUnit.EQ.0) THEN
2f58e54336 Gael*0195 jrec=irec
7855a13227 Mart*0196 ELSE
2f58e54336 Gael*0197 tapeFileCounter=tapeFileCounter+1
0198 jrec=tapeFileCounter+tapeMaxCounter*(irec-1)
7855a13227 Mart*0199 IF (tapeFileCounter.GT.tapeMaxCounter) THEN
0200 WRITE(msgBuf,'(A,2I5)')
0201 & 'ADREAD: tapeFileCounter > tapeMaxCounter ',
0202 & tapeFileCounter, tapeMaxCounter
0203 CALL PRINT_ERROR( msgBuf, myThid )
0204 WRITE(msgBuf,'(2A)') 'for file ', fname(1:lenLoc)
0205 CALL PRINT_ERROR( msgBuf, myThid )
0206 STOP 'ABNORMAL END: S/R ADREAD'
0207 ENDIF
0208 ENDIF
2f58e54336 Gael*0209 j2d=(i2d-1)*length2d+1
7855a13227 Mart*0210 CALL MDS_READ_WHALOS(fname,lenLoc,filePrec,tapeFileUnit,
80818af392 Jean*0211 & 1,var(j2d),jrec,tapeSingleCpuIO,tapeBufferIO,myThid)
0212 ENDDO
7855a13227 Mart*0213
0214
0215
3b6c79e4de Mart*0216
0217
0218
6322f3ee50 Patr*0219
3c775cbf98 Mart*0220
6322f3ee50 Patr*0221
3c775cbf98 Mart*0222
7855a13227 Mart*0223
862d160a2f Jean*0224
9105dbec95 Jean*0225 ELSE
e33827a95a Gael*0226 #else
9105dbec95 Jean*0227 IF ( .TRUE. ) THEN
e33827a95a Gael*0228 #endif /* ALLOW_AUTODIFF_WHTAPEIO */
0229
9105dbec95 Jean*0230 _BEGIN_MASTER( myThid )
0231 IF ( size.EQ.4 ) THEN
0232
0233
0234 CALL MDS_READ_TAPE( fname, filePrec, 'R4',
0235 & length, dummyR8, var,
0236 & useSingleCpuIO, irec, myThid )
0237 ELSE
0238
0239
0240 CALL MDS_READ_TAPE( fname, filePrec, 'R8',
0241 & length, var, dummyR4,
0242 & useSingleCpuIO, irec, myThid )
0243 ENDIF
0244 _END_MASTER( myThid )
0245
0246
0247 ENDIF
0248
80818af392 Jean*0249
c55bfc268c Jean*0250
2dcaa8b9a5 Patr*0251
b90aba42f8 Patr*0252 #ifdef ALLOW_DEBUG
862d160a2f Jean*0253 IF ( debugMode ) CALL DEBUG_LEAVE('ADREAD',myThid)
b90aba42f8 Patr*0254 #endif
0255
80818af392 Jean*0256 RETURN
0257 END
2dcaa8b9a5 Patr*0258
80818af392 Jean*0259
d151781088 Patr*0260
7855a13227 Mart*0261
d151781088 Patr*0262
80818af392 Jean*0263 SUBROUTINE ADWRITE(
0264 I myThid,
2dcaa8b9a5 Patr*0265 I name,
0266 I len,
0267 I tid,
0268 I vid,
0269 I var,
0270 I size,
0271 I length,
3b6c79e4de Mart*0272 I irec )
2dcaa8b9a5 Patr*0273
d151781088 Patr*0274
80818af392 Jean*0275
0276
0277
0278
0279
7855a13227 Mart*0280
80818af392 Jean*0281
0282
0283
0284
0285
0286
0287
d151781088 Patr*0288
2dcaa8b9a5 Patr*0289
d151781088 Patr*0290
80818af392 Jean*0291 IMPLICIT NONE
2dcaa8b9a5 Patr*0292
80818af392 Jean*0293
2dcaa8b9a5 Patr*0294 #include "EEPARAMS.h"
0295 #include "SIZE.h"
b76df2dc75 Patr*0296 #include "PARAMS.h"
7855a13227 Mart*0297 #ifdef ALLOW_CTRL
5cf4364659 Mart*0298 # include "CTRL_SIZE.h"
4d72283393 Mart*0299 # include "CTRL.h"
65754df434 Mart*0300 # include "OPTIMCYCLE.h"
7855a13227 Mart*0301 #endif
0302
2f58e54336 Gael*0303 #include "AUTODIFF.h"
2dcaa8b9a5 Patr*0304
d151781088 Patr*0305
3b6c79e4de Mart*0306
c55bfc268c Jean*0307
0308
0309
0310
0311
0312
0313
0314
80818af392 Jean*0315 INTEGER myThid
0316 CHARACTER*(*) name
0317 INTEGER len
0318 INTEGER tid
0319 INTEGER vid
3b6c79e4de Mart*0320 real*8 var(*)
80818af392 Jean*0321 INTEGER size
0322 INTEGER length
0323 INTEGER irec
2dcaa8b9a5 Patr*0324
c55bfc268c Jean*0325
0326 INTEGER ILNBLNK
0327 EXTERNAL ILNBLNK
0328
d151781088 Patr*0329
80818af392 Jean*0330 CHARACTER*(MAX_LEN_FNAM) fname
0331 CHARACTER*(MAX_LEN_MBUF) msgBuf
0332 INTEGER filePrec
0333 INTEGER il,jl,lenLoc
c55bfc268c Jean*0334 real*8 dummyR8(1)
0335 real*4 dummyR4(1)
9105dbec95 Jean*0336 LOGICAL useWHTapeIO
c55bfc268c Jean*0337 LOGICAL globalfile
d151e07a73 Mart*0338 #ifdef ALLOW_AUTODIFF_WHTAPEIO
80818af392 Jean*0339 INTEGER n2d,length2d, jrec, i2d, j2d
d151e07a73 Mart*0340 #endif
d151781088 Patr*0341
2dcaa8b9a5 Patr*0342
b90aba42f8 Patr*0343 #ifdef ALLOW_DEBUG
862d160a2f Jean*0344 IF ( debugMode ) CALL DEBUG_ENTER('ADWRITE',myThid)
b90aba42f8 Patr*0345 #endif
0346
80818af392 Jean*0347
0348
0349 filePrec = 8*size
516917913e Patr*0350 IF ( doSinglePrecTapelev ) THEN
c55bfc268c Jean*0351 filePrec = precFloat32
516917913e Patr*0352 ENDIF
0353
9105dbec95 Jean*0354 useWHTapeIO = .FALSE.
d151e07a73 Mart*0355 #ifdef ALLOW_AUTODIFF_WHTAPEIO
9105dbec95 Jean*0356
0357 length2d = (sNx+2*OLx)*(sNy+2*OLy)*nSx*nSy
0358 n2d = INT(length/length2d)
0359 IF ( size.EQ.8 .AND. n2d*length2d.EQ.length ) THEN
0360
0361 useWHTapeIO = .TRUE.
80818af392 Jean*0362 ENDIF
d151e07a73 Mart*0363 #endif /* ALLOW_AUTODIFF_WHTAPEIO */
9105dbec95 Jean*0364
0365 il = ILNBLNK( name )
0366 jl = ILNBLNK( adTapeDir )
0367 IF ( useWHTapeIO ) THEN
0368 lenLoc = il+jl
0369 WRITE(fname,'(2A)') adTapeDir(1:jl),name(1:il)
0370 ELSE
0371 lenLoc = il+jl+7
0372 WRITE(fname,'(3A,I4.4)')
0373 & adTapeDir(1:jl),name(1:il),'.it',optimcycle
0374 ENDIF
d151e07a73 Mart*0375 #ifdef ALLOW_DEBUG
c55bfc268c Jean*0376 IF ( debugLevel .GE. debLevC ) THEN
0377 WRITE(msgBuf,'(2A,3I6,I9,2I3,2A)') 'ADWRITE:',
0378 & ' tid,vid, irec, length, prec(x2)=', tid, vid, irec,
0379 & length, size, filePrec, ' fname=', fname(1:lenLoc)
0380 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0381 & SQUEEZE_RIGHT, myThid )
0382 ENDIF
d151e07a73 Mart*0383 #endif
0384
e33827a95a Gael*0385 #ifdef ALLOW_AUTODIFF_WHTAPEIO
9105dbec95 Jean*0386 IF ( useWHTapeIO ) THEN
80818af392 Jean*0387
7855a13227 Mart*0388
80818af392 Jean*0389 DO i2d=1,n2d
7855a13227 Mart*0390 IF (tapeFileUnit.EQ.0) THEN
2f58e54336 Gael*0391 jrec=irec
7855a13227 Mart*0392 ELSE
3c775cbf98 Mart*0393 tapeFileCounter = tapeFileCounter+1
0394 jrec = tapeFileCounter+tapeMaxCounter*(irec-1)
0395 IF ( tapeFileCounter.GT.tapeMaxCounter ) THEN
0396 WRITE(msgBuf,'(2A,I6,A,I6,A)') 'ADWRITE: ',
0397 & 'tapeFileCounter (=',tapeFileCounter,
0398 & ') > tapeMaxCounter (= nWh =', tapeMaxCounter, ')'
7855a13227 Mart*0399 CALL PRINT_ERROR( msgBuf, myThid )
3c775cbf98 Mart*0400 WRITE(msgBuf,'(3A)') 'ADWRITE: ',
0401 & ' for file: ', fname(1:lenLoc)
7855a13227 Mart*0402 CALL PRINT_ERROR( msgBuf, myThid )
3c775cbf98 Mart*0403
0404
0405 WRITE(msgBuf,'(2A)') 'ADWRITE: ',
0406 & '==> Need to increase "nWh" in: MDSIO_BUFF_WH.h'
0407 CALL PRINT_ERROR( msgBuf, myThid )
0408 WRITE(msgBuf,'(2A)') 'ADWRITE: Tip to find lowest',
0409 & ' allowed "nWh": setting debugLevel >= 3'
0410 CALL PRINT_ERROR( msgBuf , myThid )
0411 WRITE(msgBuf,'(2A)') 'ADWRITE: will report ',
0412 & '"tapeFileCounter" to STDOUT (can grep for)'
0413 CALL PRINT_ERROR( msgBuf , myThid )
7855a13227 Mart*0414 STOP 'ABNORMAL END: S/R ADWRITE'
0415 ENDIF
3c775cbf98 Mart*0416 #ifdef ALLOW_DEBUG
0417 IF ( debugLevel.GE.debLevC ) THEN
0418
0419 WRITE(msgBuf,'(A,I6)') 'ADWRITE: tapeFileCounter =',
0420 & tapeFileCounter
0421 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
0422 & SQUEEZE_RIGHT, myThid )
0423 ENDIF
0424 #endif
7855a13227 Mart*0425 ENDIF
2f58e54336 Gael*0426 j2d=(i2d-1)*length2d+1
7855a13227 Mart*0427 CALL MDS_WRITE_WHALOS(fname,lenLoc,filePrec,tapeFileUnit,
80818af392 Jean*0428 & 1,var(j2d),jrec,tapeSingleCpuIO,tapeBufferIO,myThid)
0429 ENDDO
7855a13227 Mart*0430
0431
6322f3ee50 Patr*0432
7855a13227 Mart*0433
6322f3ee50 Patr*0434
7855a13227 Mart*0435
e33827a95a Gael*0436
9105dbec95 Jean*0437 ELSE
e33827a95a Gael*0438 #else
9105dbec95 Jean*0439 IF ( .TRUE. ) THEN
e33827a95a Gael*0440 #endif /* ALLOW_AUTODIFF_WHTAPEIO */
0441
9105dbec95 Jean*0442 globalfile = globalFiles
0443
0444
0445 _BEGIN_MASTER( myThid )
0446 IF ( size.EQ.4 ) THEN
0447
0448
0449 CALL MDS_WRITE_TAPE( fname, filePrec, globalfile, 'R4',
0450 & length, dummyR8, var,
0451 & useSingleCpuIO, irec, 0, myThid )
0452 ELSE
0453
0454
0455 CALL MDS_WRITE_TAPE( fname, filePrec, globalfile, 'R8',
0456 & length, var, dummyR4,
0457 & useSingleCpuIO, irec, 0, myThid )
0458 ENDIF
0459 _END_MASTER( myThid )
0460
0461
0462 ENDIF
0463
80818af392 Jean*0464
c55bfc268c Jean*0465
2dcaa8b9a5 Patr*0466
b90aba42f8 Patr*0467 #ifdef ALLOW_DEBUG
862d160a2f Jean*0468 IF ( debugMode ) CALL DEBUG_LEAVE('ADWRITE',myThid)
b90aba42f8 Patr*0469 #endif
0470
80818af392 Jean*0471 RETURN
0472 END