NCEPLIBS-w3emc  2.11.0
w3ai01.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Unpack record into IEEE F.P.
3 C> @author Ralph Jones @date 1989-10-17
4 
5 C> Unpacks a record in office note 84 format and convert the
6 C> packed data to ieee real floating point numbers. The
7 C> office note 84 data is bit for bit the same on the nas-9050 and
8 C> the cray.
9 C>
10 C> Program history log:
11 C> - Ralph Jones 1989-10-20
12 C> - Ralph Jones 1990-02-02 Change to cray function for integer*2, f.p.
13 C> - Ralph Jones 1990-10-11 Special version of w3ai01 to unpack records
14 c> packed by big version of w3ai00. Will do old and new version.
15 C> - Ralph Jones 1991-03-19 Make special version of w3ai01 to unpack
16 c> big records the operational version.
17 C> - Ralph Jones 1993-06-10 Increace array size to 262144 words.
18 C> - Boi Vuong 1998-03-10 Remove the cdir$ integer=64 directive.
19 C> - Stephen Gilbert 1998-11-17 Changed to unpack into IEEE reals for the IBM SP.
20 C>
21 C> @param[in] PACK Integer array with data in office note 84 format to be unpacked.
22 C> @param[out] REAL8 Real array of n words. where n is given in word 6 of pack.
23 c> Word 6 of pack must contain center and scaling values.
24 C> @param[out] LABEL Six word integer label copied from pack,
25 c> 12 office note 84 32 bit id's that are stored into six 64-bit words.
26 C>
27 C> @note Label and pack may be equivalenced.
28 C>
29 C> @author Ralph Jones @date 1989-10-17
30 
31  SUBROUTINE w3ai01(PACK,REAL8,LABEL)
32 C
33  REAL REAL8(*)
34 C
35  INTEGER(2) ITEMP(262144)
36  INTEGER(8) LABEL(6)
37  INTEGER(8) PACK(*)
38  INTEGER(8) MASK16
39  INTEGER(8) MASK32
40  integer(2) i2(4)
41  real(4) rtemp(2)
42  integer(8) ktemp,jtemp(65536)
43  equivalence(ktemp,rtemp(1),i2(1))
44  equivalence(itemp(1),jtemp(1))
45 C
46  SAVE
47 C
48  DATA mask16/z'000000000000FFFF'/
49  DATA mask32/z'00000000FFFFFFFF'/
50 C
51 C MOVE OFFICE NOTE 84 12 32 BIT ID'S INTO LABEL
52 C
53  DO 10 i = 1,6
54  label(i) = pack(i)
55  10 CONTINUE
56 C
57 C GET WORD COUNT, AVERAGE VALUE, SCALING FACTOR, J, A , N.
58 C
59  j = iand(label(4),mask16)
60  IF (j.EQ.0) THEN
61  j = iand(label(6),mask32)
62  IF (j.EQ.0) THEN
63  print *,' W3AI01 ERROR, NUMBER OF WORDS IN GRID IS 0'
64  RETURN
65  ENDIF
66  IF (j.GT.262144) THEN
67  print *,' W3AI01 ERROR, NUMBER OF WORDS IN GRID IS ',j
68  print *,' THERE IS A LIMIT OF 262144'
69  RETURN
70  ENDIF
71  ENDIF
72 C
73 C CONVERT IBM 32 BIT MEAN VALUE TO IEEE F.P. NUMBER
74 C
75 C CALL USSCTC(LABEL(5),5,A,1)
76  ktemp=label(5)
77  call q9ie32(rtemp(2),rtemp(1),1,istat)
78  a=rtemp(1)
79 C
80 C GET SCALING VALUE N, CAN BE NEGATIVE (INTEGER*2 TWO'S COMPL.)
81 C
82 C CALL USICTC(LABEL(6),3,N,1,2)
83  ktemp=label(6)
84  n=i2(2)
85 C
86  twon = 2.0 ** (n - 15)
87 C
88 C UNPACK, CONVERT TO REAL 64 BIT FLOATING POINT DATA
89 C
90 C CALL USICTC(PACK(7),1,ITEMP,J,2)
91  jtemp(1:65536)=pack(7:65542)
92 C
93  DO 20 i = 1,j
94  real8(i) = float(itemp(i)) * twon + a
95  20 CONTINUE
96 C
97  RETURN
98  END
subroutine q9ie32(A, B, N, ISTAT)
Convert ibm370 32 bit floating point numbers to ieee 32 bit task 754 floating point numbers.
Definition: q9ie32.f:28
subroutine w3ai01(PACK, REAL8, LABEL)
Unpacks a record in office note 84 format and convert the packed data to ieee real floating point num...
Definition: w3ai01.f:32