1 |
C $Header: /u/gcmpack/MITgcm/pkg/mdsio/mdsio_rd_rec_rl.F,v 1.4 2011/08/31 21:28:18 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "MDSIO_OPTIONS.h" |
5 |
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
CBOP 0 |
8 |
C !ROUTINE: MDS_RD_REC_RL |
9 |
|
10 |
C !INTERFACE: |
11 |
SUBROUTINE MDS_RD_REC_RL( |
12 |
O arr, |
13 |
O r4Buf, r8Buf, |
14 |
I fPrec, dUnit, iRec, nArr, myThid ) |
15 |
|
16 |
C !DESCRIPTION: |
17 |
C Read one reccord from already opened io-unit "dUnit", into RL array "arr" |
18 |
|
19 |
C !USES: |
20 |
IMPLICIT NONE |
21 |
#include "EEPARAMS.h" |
22 |
#include "SIZE.h" |
23 |
#include "PARAMS.h" |
24 |
|
25 |
C !INPUT PARAMETERS: |
26 |
C fPrec integer :: file precision |
27 |
C dUnit integer :: 'Opened' I/O channel |
28 |
C iRec integer :: record number to WRITE |
29 |
C nArr integer :: dimension off array "arr" |
30 |
C myThid integer :: my Thread Id number |
31 |
C !OUTPUT PARAMETERS: |
32 |
C arr RL :: vector array to read in |
33 |
C r4Buf real*4 :: buffer array |
34 |
C r8Buf real*8 :: buffer array |
35 |
INTEGER fPrec |
36 |
INTEGER dUnit |
37 |
INTEGER iRec |
38 |
INTEGER nArr |
39 |
INTEGER myThid |
40 |
_RL arr(nArr) |
41 |
Real*4 r4Buf(nArr) |
42 |
Real*8 r8Buf(nArr) |
43 |
CEOP |
44 |
|
45 |
C !LOCAL VARIABLES: |
46 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
47 |
INTEGER k |
48 |
|
49 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
50 |
IF ( debugLevel.GE.debLevC ) THEN |
51 |
WRITE(msgBuf,'(A,I9,2x,I9)') |
52 |
& ' MDS_RD_REC_RL: iRec,Dim = ', iRec, nArr |
53 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
54 |
& SQUEEZE_RIGHT , myThid ) |
55 |
ENDIF |
56 |
|
57 |
IF ( fPrec.EQ.precFloat32 ) THEN |
58 |
READ( dUnit, rec=iRec ) r4Buf |
59 |
#ifdef _BYTESWAPIO |
60 |
CALL MDS_BYTESWAPR4( nArr, r4Buf ) |
61 |
#endif |
62 |
DO k=1,nArr |
63 |
arr(k) = r4Buf(k) |
64 |
ENDDO |
65 |
ELSEIF ( fPrec.EQ.precFloat64 ) THEN |
66 |
READ( dUnit, rec=iRec ) r8Buf |
67 |
#ifdef _BYTESWAPIO |
68 |
CALL MDS_BYTESWAPR8( nArr, r8Buf ) |
69 |
#endif |
70 |
DO k=1,nArr |
71 |
arr(k) = r8Buf(k) |
72 |
ENDDO |
73 |
ELSE |
74 |
WRITE(msgBuf,'(A,I9)') |
75 |
& ' MDS_RD_REC_RL: illegal value for fPrec=',fPrec |
76 |
CALL PRINT_ERROR( msgBuf, myThid ) |
77 |
STOP 'ABNORMAL END: S/R MDS_RD_REC_RL' |
78 |
ENDIF |
79 |
|
80 |
RETURN |
81 |
END |