1 !-----------------------------------------------------------------------
3 !-----------------------------------------------------------------------
5 ! CRAY XMP,YMP/UNICOS (#define CRAY)
6 ! VAX/VMS (#define VAX)
7 ! Stardent 1500/3000/UNIX (#define STARDENT)
8 ! IBM RS/6000-AIX (#define IBM)
9 ! SUN Sparcstation (#define SUN)
10 ! SGI Silicon Graphics (#define SGI)
12 ! DEC ALPHA (#define ALPHA)
13 ! +------------------------------------------------------------------+
14 ! _ SYSTEM DEPENDENT ROUTINES _
16 ! _ This module contains short utility routines that are not _
17 ! _ of the FORTRAN 77 standard and may differ from system to system. _
18 ! _ These include bit manipulation, I/O, JCL calls, and vector _
20 ! +------------------------------------------------------------------+
21 ! +------------------------------------------------------------------+
23 ! DATA SET UTILITY AT LEVEL 003 AS OF 02/25/92
24 SUBROUTINE GBYTE_G1(IN,IOUT,ISKIP,NBYTE)
26 ! THIS PROGRAM WRITTEN BY.....
27 ! DR. ROBERT C. GAMMILL, CONSULTANT
28 ! NATIONAL CENTER FOR ATMOSPHERIC RESEARCH
31 ! CHANGES FOR CRAY Y-MP8/832
33 ! JULY 1992, RUSSELL E. JONES
34 ! NATIONAL WEATHER SERVICE
36 ! THIS IS THE FORTRAN VERSION OF GBYTE
40 #if defined (CRAY) || defined (BIT64)
46 ! MASKS TABLE PUT IN DECIMAL SO IT WILL COMPILE ON ANY 64 BIT
49 DATA MASKS / 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, &
50 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, &
51 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, &
52 67108863, 134217727, 268435455, 536870911, 1073741823, &
53 2147483647, 4294967295, 8589934591, 17179869183, &
54 34359738367, 68719476735, 137438953471, 274877906943, &
55 549755813887, 1099511627775, 2199023255551, 4398046511103, &
56 8796093022207, 17592186044415, 35184372088831, &
57 70368744177663, 140737488355327, 281474976710655, &
58 562949953421311, 1125899906842623, 2251799813685247, &
59 4503599627370495, 9007199254740991, 18014398509481983, &
60 36028797018963967, 72057594037927935, 144115188075855871, &
61 288230376151711743, 576460752303423487, 1152921504606846975, &
62 2305843009213693951, 4611686018427387903, 9223372036854775807, &
69 ! MASKS TABLE PUT IN DECIMAL SO IT WILL COMPILE ON ANY 32 BIT
72 DATA MASKS / 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, &
73 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, &
74 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, &
75 67108863, 134217727, 268435455, 536870911, 1073741823, &
79 ! NBYTE MUST BE LESS THAN OR EQUAL TO NBITSW
85 ! INDEX TELLS HOW MANY WORDS INTO THE ARRAY 'IN' THE NEXT BYTE APPEARS.
87 INDEX = ISKIP / NBITSW
89 ! II TELLS HOW MANY BITS THE BYTE IS FROM THE LEFT SIDE OF THE WORD.
91 II = MOD(ISKIP,NBITSW)
93 ! MOVER SPECIFIES HOW FAR TO THE RIGHT NBYTE MUST BE MOVED IN ORDER
94 ! TO BE RIGHT ADJUSTED.
99 IOUT = IAND(ISHFT(IN(INDEX+1),-MOVER),MASK)
101 ! THE BYTE IS SPLIT ACROSS A WORD BREAK.
103 ELSE IF (MOVER.LT.0) THEN
105 MOVER = NBITSW - MOVEL
106 IOUT = IAND(IOR(ISHFT(IN(INDEX+1),MOVEL), &
107 & ISHFT(IN(INDEX+2),-MOVER)),MASK)
109 ! THE BYTE IS ALREADY RIGHT ADJUSTED.
112 IOUT = IAND(IN(INDEX+1),MASK)
118 ! +------------------------------------------------------------------+
119 SUBROUTINE GBYTES_G1(IN,IOUT,ISKIP,NBYTE,NSKIP,N)
121 ! THIS PROGRAM WRITTEN BY.....
122 ! DR. ROBERT C. GAMMILL, CONSULTANT
123 ! NATIONAL CENTER FOR ATMOSPHERIC RESEARCH
126 ! CHANGES FOR CRAY Y-MP8/832
128 ! JULY 1992, RUSSELL E. JONES
129 ! NATIONAL WEATHER SERVICE
131 ! THIS IS THE FORTRAN VERSION OF GBYTES.
135 #if defined (CRAY) || defined (BIT64)
141 ! MASKS TABLE PUT IN DECIMAL SO IT WILL COMPILE ON ANY 64 BIT
144 DATA MASKS / 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, &
145 & 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, &
146 & 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, &
147 & 67108863, 134217727, 268435455, 536870911, 1073741823, &
148 & 2147483647, 4294967295, 8589934591, 17179869183, &
149 & 34359738367, 68719476735, 137438953471, 274877906943, &
150 & 549755813887, 1099511627775, 2199023255551, 4398046511103, &
151 & 8796093022207, 17592186044415, 35184372088831, &
152 & 70368744177663, 140737488355327, 281474976710655, &
153 & 562949953421311, 1125899906842623, 2251799813685247, &
154 & 4503599627370495, 9007199254740991, 18014398509481983, &
155 & 36028797018963967, 72057594037927935, 144115188075855871, &
156 & 288230376151711743, 576460752303423487, 1152921504606846975, &
157 & 2305843009213693951, 4611686018427387903, 9223372036854775807, &
164 ! MASKS TABLE PUT IN DECIMAL SO IT WILL COMPILE ON ANY 32 BIT
167 DATA MASKS / 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, &
168 & 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, &
169 & 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, &
170 & 67108863, 134217727, 268435455, 536870911, 1073741823, &
174 ! NBYTE MUST BE LESS THAN OR EQUAL TO NBITSW
176 ICON = NBITSW - NBYTE
177 IF (ICON.LT.0) RETURN
180 ! INDEX TELLS HOW MANY WORDS INTO THE ARRAY 'IN' THE NEXT BYTE APPEARS.
182 INDEX = ISKIP / NBITSW
184 ! II TELLS HOW MANY BITS THE BYTE IS FROM THE LEFT SIDE OF THE WORD.
186 II = MOD(ISKIP,NBITSW)
188 ! ISTEP IS THE DISTANCE IN BITS FROM THE START OF ONE BYTE TO THE NEXT.
190 ISTEP = NBYTE + NSKIP
192 ! IWORDS TELLS HOW MANY WORDS TO SKIP FROM ONE BYTE TO THE NEXT.
194 IWORDS = ISTEP / NBITSW
196 ! IBITS TELLS HOW MANY BITS TO SKIP AFTER SKIPPING IWORDS.
198 IBITS = MOD(ISTEP,NBITSW)
202 ! MOVER SPECIFIES HOW FAR TO THE RIGHT A BYTE MUST BE MOVED IN ORDER
204 ! TO BE RIGHT ADJUSTED.
205 ! TO BE RIGHT ADJUSTED.
209 ! THE BYTE IS SPLIT ACROSS A WORD BREAK.
213 MOVER = NBITSW - MOVEL
214 IOUT(I) = IAND(IOR(ISHFT(IN(INDEX+1),MOVEL), &
215 & ISHFT(IN(INDEX+2),-MOVER)),MASK)
217 ! RIGHT ADJUST THE BYTE.
219 ELSE IF (MOVER.GT.0) THEN
220 IOUT(I) = IAND(ISHFT(IN(INDEX+1),-MOVER),MASK)
222 ! THE BYTE IS ALREADY RIGHT ADJUSTED.
225 IOUT(I) = IAND(IN(INDEX+1),MASK)
228 ! INCREMENT II AND INDEX.
231 INDEX = INDEX + IWORDS
232 IF (II.GE.NBITSW) THEN
241 ! +------------------------------------------------------------------+
242 SUBROUTINE SBYTE_G1(IOUT,IN,ISKIP,NBYTE)
243 ! THIS PROGRAM WRITTEN BY.....
244 ! DR. ROBERT C. GAMMILL, CONSULTANT
245 ! NATIONAL CENTER FOR ATMOSPHERIC RESEARCH
247 ! THIS IS THE FORTRAN VERSIONS OF SBYTE.
249 ! AUGUST 1990 RUSSELL E. JONES
250 ! NATIONAL WEATHER SERVICE
252 ! USAGE: CALL SBYTE (PCKD,UNPK,INOFST,NBIT)
254 ! INPUT ARGUMENT LIST:
255 ! UNPK - NBITS OF THE RIGHT SIDE OF UNPK IS MOVED TO
256 ! ARRAY PCKD. INOFST BITS ARE SKIPPED OVER BEFORE
257 ! THE DATA IS MOVED, NBITS ARE STORED.
258 ! INOFST - A FULLWORD INTEGER SPECIFYING THE INITAL OFFSET
259 ! IN BITS OF THE FIRST BYTE, COUNTED FROM THE
260 ! LEFTMOST BIT IN PCKD.
261 ! NBITS - A FULLWORD INTEGER SPECIFYING THE NUMBER OF BITS
262 ! IN EACH BYTE TO BE PACKED. LEGAL BYTE WIDTHS
263 ! ARE IN THE RANGE 1 - 32.
264 ! OUTPUT ARGUMENT LIST:
265 ! PCKD - THE FULLWORD IN MEMORY TO WHICH PACKING IS TO
266 ! BEGIN STARTING AT BIT INOFST. THE INOSTAT BITS
271 #if defined (CRAY) || defined (BIT64)
276 ! MASKS TABLE PUT IN DECIMAL SO IT WILL COMPILE ON ANY 64 BIT
279 DATA MASKS / 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, &
280 & 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, &
281 & 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, &
282 & 67108863, 134217727, 268435455, 536870911, 1073741823, &
283 & 2147483647, 4294967295, 8589934591, 17179869183, &
284 & 34359738367, 68719476735, 137438953471, 274877906943, &
285 & 549755813887, 1099511627775, 2199023255551, 4398046511103, &
286 & 8796093022207, 17592186044415, 35184372088831, &
287 & 70368744177663, 140737488355327, 281474976710655, &
288 & 562949953421311, 1125899906842623, 2251799813685247, &
289 & 4503599627370495, 9007199254740991, 18014398509481983, &
290 & 36028797018963967, 72057594037927935, 144115188075855871, &
291 & 288230376151711743, 576460752303423487, 1152921504606846975, &
292 & 2305843009213693951, 4611686018427387903, 9223372036854775807, &
299 ! MASKS TABLE PUT IN DECIMAL SO IT WILL COMPILE ON ANY 32 BIT
302 DATA MASKS / 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, &
303 & 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, &
304 & 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, &
305 & 67108863, 134217727, 268435455, 536870911, 1073741823, &
309 ! NBYTE MUST BE LESS THAN OR EQUAL TO NBITSW
311 ICON = NBITSW - NBYTE
312 IF (ICON.LT.0) RETURN
315 ! INDEX TELLS HOW MANY WORDS INTO IOUT THE NEXT BYTE IS TO BE STORED.
317 INDEX = ISKIP / NBITSW
319 ! II TELLS HOW MANY BITS IN FROM THE LEFT SIDE OF THE WORD TO STORE IT.
321 II = MOD(ISKIP,NBITSW)
326 ! BYTE IS TO BE STORED IN MIDDLE OF WORD. SHIFT LEFT.
329 MSK = ISHFT(MASK,MOVEL)
330 IOUT(INDEX+1) = IOR(IAND(NOT(MSK),IOUT(INDEX+1)), &
333 ! THE BYTE IS TO BE SPLIT ACROSS A WORD BREAK.
335 ELSE IF (MOVEL.LT.0) THEN
336 MSK = MASKS(NBYTE+MOVEL)
337 IOUT(INDEX+1) = IOR(IAND(NOT(MSK),IOUT(INDEX+1)), &
339 ITEMP = IAND(MASKS(NBITSW+MOVEL),IOUT(INDEX+2))
340 IOUT(INDEX+2) = IOR(ITEMP,ISHFT(J,NBITSW+MOVEL))
342 ! BYTE IS TO BE STORED RIGHT-ADJUSTED.
345 IOUT(INDEX+1) = IOR(IAND(NOT(MASK),IOUT(INDEX+1)),J)
351 ! +------------------------------------------------------------------+
352 SUBROUTINE SBYTES_G1(IOUT,IN,ISKIP,NBYTE,NSKIP,N)
353 ! THIS PROGRAM WRITTEN BY.....
354 ! DR. ROBERT C. GAMMILL, CONSULTANT
355 ! NATIONAL CENTER FOR ATMOSPHERIC RESEARCH
357 ! THIS IS THE FORTRAN VERSIONS OF SBYTES.
360 ! AUGUST 1990 RUSSELL E. JONES
361 ! NATIONAL WEATHER SERVICE
363 ! USAGE: CALL SBYTES (PCKD,UNPK,INOFST,NBIT, NSKIP,ITER)
365 ! INPUT ARGUMENT LIST:
366 ! UNPK - NBITS OF THE RIGHT SIDE OF EACH WORD OF ARRAY
367 ! UNPK IS MOVED TO ARRAY PCKD. INOFST BITS ARE
368 ! SKIPPED OVER BEFORE THE 1ST DATA IS MOVED, NBITS
369 ! ARE STORED, NSKIP BITS ARE SKIPPED OVER, THE NEXT
370 ! NBITS ARE MOVED, BIT ARE SKIPPED OVER, ETC. UNTIL
371 ! ITER GROUPS OF BITS ARE PACKED.
372 ! INOFST - A FULLWORD INTEGER SPECIFYING THE INITAL OFFSET
373 ! IN BITS OF THE FIRST BYTE, COUNTED FROM THE
374 ! LEFTMOST BIT IN PCKD.
375 ! NBITS - A FULLWORD INTEGER SPECIFYING THE NUMBER OF BITS
376 ! IN EACH BYTE TO BE PACKED. LEGAL BYTE WIDTHS
377 ! ARE IN THE RANGE 1 - 32.
378 ! NSKIP - A FULLWORD INTEGER SPECIFYING THE NUMBER OF BITS
379 ! TO SKIP BETWEEN SUCCESSIVE BYTES. ALL NON-NEGATIVE
380 ! SKIP COUNTS ARE LEGAL.
381 ! ITER - A FULLWORD INTEGER SPECIFYING THE TOTAL NUMBER OF
382 ! BYTES TO BE PACKED, AS CONTROLLED BY INOFST,
383 ! NBIT AND NSKIP ABOVE. ALL NON-NEGATIVE ITERATION
386 ! OUTPUT ARGUMENT LIST:
387 ! PCKD - THE FULLWORD IN MEMORY TO WHICH PACKING IS TO
388 ! BEGIN STARTING AT BIT INOFST. THE INOSTAT BITS
389 ! ARE NOT ALTERED. NSKIP BITS ARE NOT ALTERED.
393 #if defined (CRAY) || defined (BIT64)
398 ! MASKS TABLE PUT IN DECIMAL SO IT WILL COMPILE ON ANY 64 BIT
401 DATA MASKS / 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, &
402 & 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, &
403 & 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, &
404 & 67108863, 134217727, 268435455, 536870911, 1073741823, &
405 & 2147483647, 4294967295, 8589934591, 17179869183, &
406 & 34359738367, 68719476735, 137438953471, 274877906943, &
407 & 549755813887, 1099511627775, 2199023255551, 4398046511103, &
408 & 8796093022207, 17592186044415, 35184372088831, &
409 & 70368744177663, 140737488355327, 281474976710655, &
410 & 562949953421311, 1125899906842623, 2251799813685247, &
411 & 4503599627370495, 9007199254740991, 18014398509481983, &
412 & 36028797018963967, 72057594037927935, 144115188075855871, &
413 & 288230376151711743, 576460752303423487, 1152921504606846975, &
414 & 2305843009213693951, 4611686018427387903, 9223372036854775807, &
421 ! MASKS TABLE PUT IN DECIMAL SO IT WILL COMPILE ON ANY 32 BIT
424 DATA MASKS / 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, &
425 & 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, &
426 & 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, &
427 & 67108863, 134217727, 268435455, 536870911, 1073741823, &
431 ! NBYTE MUST BE LESS THAN OR EQUAL TO NBITSW
433 ICON = NBITSW - NBYTE
434 IF (ICON.LT.0) RETURN
437 ! INDEX TELLS HOW MANY WORDS INTO IOUT THE NEXT BYTE IS TO BE STORED.
439 INDEX = ISKIP / NBITSW
441 ! II TELLS HOW MANY BITS IN FROM THE LEFT SIDE OF THE WORD TO STORE IT.
443 II = MOD(ISKIP,NBITSW)
445 ! ISTEP IS THE DISTANCE IN BITS FROM ONE BYTE POSITION TO THE NEXT.
447 ISTEP = NBYTE + NSKIP
449 ! IWORDS TELLS HOW MANY WORDS TO SKIP FROM ONE BYTE TO THE NEXT.
451 IWORDS = ISTEP / NBITSW
453 ! IBITS TELLS HOW MANY BITS TO SKIP AFTER SKIPPING IWORDS.
455 IBITS = MOD(ISTEP,NBITSW)
461 ! BYTE IS TO BE STORED IN MIDDLE OF WORD. SHIFT LEFT.
464 MSK = ISHFT(MASK,MOVEL)
465 IOUT(INDEX+1) = IOR(IAND(NOT(MSK),IOUT(INDEX+1)), &
468 ! THE BYTE IS TO BE SPLIT ACROSS A WORD BREAK.
470 ELSE IF (MOVEL.LT.0) THEN
471 MSK = MASKS(NBYTE+MOVEL)
472 IOUT(INDEX+1) = IOR(IAND(NOT(MSK),IOUT(INDEX+1)), &
474 ITEMP = IAND(MASKS(NBITSW+MOVEL),IOUT(INDEX+2))
475 IOUT(INDEX+2) = IOR(ITEMP,ISHFT(J,NBITSW+MOVEL))
477 ! BYTE IS TO BE STORED RIGHT-ADJUSTED.
480 IOUT(INDEX+1) = IOR(IAND(NOT(MASK),IOUT(INDEX+1)),J)
484 INDEX = INDEX + IWORDS
485 IF (II.GE.NBITSW) THEN