NCEPLIBS-w3emc  2.11.0
w3fi32.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Pack id's into office note 84 format.
3 C> @author Alan Nierow @date 1986-02-07
4 
5 C> Converts an array of the 27 data field identifiers into
6 C> an array of the first 8 identification words of the format de-
7 C> scribed in NMC office note 84 (89-06-15, page-35). On a cray
8 C> they will fit into four 64 bit integer words.
9 C>
10 C> Program history log:
11 C> - Alan Nierow 1986-02-07
12 C> - Ralph Jones 1989-10-24 Convert to cray cft77 fortran.
13 C> - Ralph Jones 1991-03-19 Changes for big records.
14 C> - Boi Vuong 1998-03-10 Remove the cdir$ integer=64 directive.
15 C> - Stephen Gilbert 1999-03-15 Specified 8-byte integer array explicitly.
16 C>
17 C> @param[in] LARRAY Integer array containing 27 data field
18 C> identifiers (see o.n. 84)
19 C> @param[out] KIDNT Integer array of 6 words, 12 office note 84 32 bit
20 C> words, first 4 words are made by w3fi32(), if you are
21 C> using packer w3ai00(), it will compute word 5 and 6.
22 C> (office note 84 words 9,10, 11 and 12). If J the
23 C> word count in word 27 of LARRAY is greater than
24 C> 32743 then bits 15-0 of the 4th ID word are set to
25 C> zero, J is stored in bits 31-0 of the 6th ID word.
26 C> ID word 5 is set zero, bit 63-32 of the 6th ID
27 C> word are set zero.
28 C> @note bis are number left to right on the cray as 63-0.
29 C>
30 C> @note Exit states printed messages:
31 C> If any number n in (LARRAY(i),i=1,27) is erroneously large:
32 C> 'value in LARRAY(i)=n is too large to pack'
33 C> if any number n in (LARRAY(i),i=1,27) is erroneously negative:
34 C> 'value in LARRAY(i)=n should not be negative'
35 C> in either of the above situations, that portion of the packed
36 C> word corresponding to LARRAY(i) will be set to binary ones.
37 C>
38 C> @author Alan Nierow @date 1986-02-07
39  SUBROUTINE w3fi32(LARRAY,KIDNT)
40 C
41  INTEGER(8) LARRAY(27)
42  INTEGER(8) ITABLE(27)
43  INTEGER(8) KIDNT(*)
44  INTEGER(8) KX,MASK,MASK16,ISC,ITEMP8
45 C
46  SAVE
47 C
48  DATA itable/z'0000000000340C01',z'0000000000280C01',
49  & z'0000000000200801',z'00000000001C0401',
50  & z'0000000001081401',z'0000000001000801',
51  & z'00000000003C0402',z'0000000000340802',
52  & z'0000000000280C02',z'0000000000200802',
53  & z'00000000001C0402',z'0000000001081402',
54  & z'0000000001000802',z'0000000000380803',
55  & z'0000000000300803',z'0000000000280803',
56  & z'0000000000200803',z'00000000001C0403',
57  & z'0000000000100C03',z'0000000000001003',
58  & z'0000000000380804',z'0000000000300804',
59  & z'0000000000280804',z'0000000000200804',
60  & z'0000000000180804',z'0000000000100804',
61  & z'0000000000001004'/
62  DATA kx /z'00000000FFFFFFFF'/
63  DATA mask /z'00000000000000FF'/
64  DATA mask16/z'FFFFFFFFFFFF0000'/
65 C
66 C MAKE KIDNT = 0
67 C
68  DO 10 i = 1,4
69  kidnt(i) = 0
70  10 CONTINUE
71 C
72  isign = 0
73 C
74  DO 90 i = 1,27
75  isc = itable(i)
76  i1 = iand(isc,mask)
77  i2 = iand(ishft(isc,-8_8), mask)
78  i3 = iand(ishft(isc,-16_8),mask)
79  i4 = iand(ishft(isc,-24_8),mask)
80 C
81 C SIGN TEST
82 C
83  iv = larray(i)
84  IF (iv.GE.0) GO TO 50
85  IF (i4.NE.0) GO TO 30
86  WRITE (6,20) i, iv
87  20 FORMAT(/,1x,' W3FI32 - VALUE IN LARRAY(',i2,') =',i11,
88  & ' SHOULD NOT BE NEGATIVE',/)
89  GO TO 70
90 C
91  30 CONTINUE
92  iv = iabs(iv)
93  msign = 1
94  isign = msign
95  k = i2 / 4
96 C
97  DO 40 m = 1,k
98  isign = ishft(isign,4)
99  40 CONTINUE
100 C
101  isign = ishft(isign,-1)
102  iv = ior(iv,isign)
103 C
104  50 CONTINUE
105 C
106 C MAG TEST
107 C
108  IF (ishft(iv,-i2).EQ.0) GO TO 80
109  IF (larray(27).GT.32743) GO TO 70
110  print 60, i , iv
111  60 FORMAT(/,1x,' W3FI32 - VALUE IN LARRAY(',i2,') =',i11,
112  & ' IS TOO LARGE TO PACK',/)
113 C
114  70 CONTINUE
115  iv = kx
116  ia = 32 - i2
117  iv = ishft(iv,-ia)
118 C
119 C SHIFT
120 C
121  80 CONTINUE
122  itemp=ishft(iv,i3)
123  itemp8=itemp
124  kidnt(i1) = ior(kidnt(i1),itemp8)
125 C
126  90 CONTINUE
127 C
128 C TEST FOR BIG RECORDS, STORE J THE WORD COUNT IN THE 6TH
129 C ID WORD IF GREATER THAN 32743.
130 C
131  IF (larray(27).EQ.0) THEN
132  print *,' W3FI32 - ERROR, WORD COUNT J = 0'
133  ELSE IF (larray(27).GT.32743) THEN
134  kidnt(4) = iand(kidnt(4),mask16)
135  kidnt(5) = 0
136  kidnt(6) = larray(27)
137  END IF
138 C
139  RETURN
140  END
subroutine w3fi32(LARRAY, KIDNT)
Converts an array of the 27 data field identifiers into an array of the first 8 identification words ...
Definition: w3fi32.f:40