23 character*1,
intent(in) :: in(*)
24 integer,
intent(inout) :: iout(*)
25 integer,
intent(in) :: iskip, nbits
28 subroutine g2_gbytesc(in, iout, iskip, nbits, nskip, n)
29 character*1,
intent(in) :: in(*)
30 integer,
intent(out) :: iout(*)
31 integer,
intent(in) :: iskip, nbits, nskip, n
54 character*1,
intent(in) :: in(*)
55 integer,
intent(inout) :: siout
56 integer,
intent(in) :: iskip, nbits
58 integer (kind = 4) :: iout(1)
61 subroutine g2_gbytesc(in, iout, iskip, nbits, nskip, n)
62 character*1,
intent(in) :: in(*)
63 integer,
intent(out) :: iout(*)
64 integer,
intent(in) :: iskip, nbits, nskip, n
87 character*1,
intent(in) :: in(*)
88 real (kind = 4), intent(out) :: rout(*)
89 integer,
intent(in) :: iskip, nbits, nskip, n
90 integer (kind = 4) :: iout(n)
93 subroutine g2_gbytesc(in, iout, iskip, nbits, nskip, n)
94 character*1,
intent(in) :: in(*)
95 integer,
intent(out) :: iout(*)
96 integer,
intent(in) :: iskip, nbits, nskip, n
101 call g2_gbytesc(in, iout, iskip, nbits, nskip, n)
104 rout(1:n) = transfer(iout, rout(1:n), n)
122 character*1,
intent(in) :: in(*)
123 integer,
intent(out) :: iout(*)
124 integer,
intent(in) :: iskip, nbits, nskip, n
125 integer :: tbit, bitcnt
126 integer,
parameter :: ones(8) = (/ 1, 3, 7, 15, 31, 63, 127, 255 /)
128 integer :: nbit, i, index, ibit, itmp
129 integer,
external :: g2_mova2i
137 nbit = nbit + nbits + nskip
140 tbit = min(bitcnt, 8 - ibit)
141 itmp = iand(g2_mova2i(in(index)), ones(8 - ibit))
142 if (tbit .ne. 8 - ibit) itmp = ishft(itmp, tbit - 8 + ibit)
144 bitcnt = bitcnt - tbit
147 do while (bitcnt .ge. 8)
148 itmp = ior(ishft(itmp,8), g2_mova2i(in(index)))
154 if (bitcnt .gt. 0)
then
155 itmp = ior(ishft(itmp, bitcnt), iand(ishft(g2_mova2i(in(index)), &
156 - (8 - bitcnt)), ones(bitcnt)))
180 character*1,
intent(in) :: in(*)
181 integer (kind = 8),
intent(inout) :: iout(*)
182 integer,
intent(in) :: iskip, nbits
185 subroutine g2_gbytesc8(in, iout, iskip, nbits, nskip, n)
186 character*1,
intent(in) :: in(*)
187 integer (kind = 8),
intent(out) :: iout(*)
188 integer,
intent(in) :: iskip, nbits, nskip, n
211 character*1,
intent(in) :: in(*)
212 integer (kind = 8),
intent(inout) :: siout
213 integer,
intent(in) :: iskip, nbits
214 integer (kind = 8) :: iout(1)
217 subroutine g2_gbytesc8(in, iout, iskip, nbits, nskip, n)
218 character*1,
intent(in) :: in(*)
219 integer (kind = 8),
intent(out) :: iout(*)
220 integer,
intent(in) :: iskip, nbits, nskip, n
243 character*1,
intent(in) :: in(*)
244 integer (kind = 8),
intent(out) :: iout(*)
245 integer,
intent(in) :: iskip, nbits, nskip, n
247 integer :: tbit, bitcnt
248 integer,
parameter :: ones(8) = (/ 1, 3, 7, 15, 31, 63, 127, 255 /)
250 integer :: nbit, i, index, ibit, itmp
251 integer (kind = 8) :: itmp8, itmp8_2, itmp8_3
252 integer,
external :: g2_mova2i
253 integer (kind = 8),
external :: g2_mova2i8
261 nbit = nbit + nbits + nskip
264 tbit = min(bitcnt, 8 - ibit)
265 itmp8 = iand(g2_mova2i8(in(index)), int(ones(8 - ibit), kind = 8))
266 itmp = iand(g2_mova2i(in(index)), ones(8 - ibit))
267 if (tbit .ne. 8 - ibit) itmp = ishft(itmp, tbit - 8 + ibit)
268 if (tbit .ne. 8 - ibit) itmp8 = ishft(itmp8, tbit - 8 + ibit)
270 bitcnt = bitcnt - tbit
273 do while (bitcnt .ge. 8)
274 itmp = ior(ishft(itmp,8), g2_mova2i(in(index)))
275 itmp8 = ior(ishft(itmp8,8), g2_mova2i8(in(index)))
281 if (bitcnt .gt. 0)
then
282 itmp = ior(ishft(itmp, bitcnt), iand(ishft(g2_mova2i(in(index)), - (8 - bitcnt)), ones(bitcnt)))
283 itmp8_2 = ishft(g2_mova2i8(in(index)), int(-(8 - bitcnt), kind(8)))
284 itmp8_3 = int(ones(bitcnt), kind(8))
285 itmp8 = ior(ishft(itmp8, bitcnt), iand(itmp8_2, itmp8_3))
308 character*1,
intent(inout) :: out(*)
309 integer,
intent(in) :: in(*)
310 integer,
intent(in) :: iskip, nbits
313 subroutine g2_sbytesc(out, in, iskip, nbits, nskip, n)
314 character*1,
intent(out) :: out(*)
315 integer,
intent(in) :: in(n)
316 integer,
intent(in) :: iskip, nbits, nskip, n
339 character*1,
intent(inout) :: out(*)
340 integer,
intent(in) :: in
341 integer,
intent(in) :: iskip, nbits
345 subroutine g2_sbytesc(out, in, iskip, nbits, nskip, n)
346 character*1,
intent(out) :: out(*)
347 integer,
intent(in) :: in(n)
348 integer,
intent(in) :: iskip, nbits, nskip, n
369 character*1,
intent(out) :: out(*)
370 real,
intent(in) :: rin(n)
371 integer,
intent(in) :: iskip, nbits, nskip, n
375 subroutine g2_sbytesc(out, in, iskip, nbits, nskip, n)
376 character*1,
intent(out) :: out(*)
377 integer,
intent(in) :: in(n)
378 integer,
intent(in) :: iskip, nbits, nskip, n
383 in(1:n) = transfer(rin, in(1:n), n)
386 call g2_sbytesc(out, in, iskip, nbits, nskip, n)
404 character*1,
intent(out) :: out(*)
405 integer,
intent(in) :: in(n)
406 integer,
intent(in) :: iskip, nbits, nskip, n
408 integer :: bitcnt, tbit
409 integer,
parameter :: ones(8)=(/ 1, 3, 7, 15, 31, 63, 127, 255/)
410 integer :: nbit, i, itmp, index, ibit, imask, itmp2, itmp3
411 integer,
external :: g2_mova2i
415 nbit = iskip + nbits - 1
422 nbit = nbit + nbits + nskip
426 if (ibit .ne. 7)
then
427 tbit = min(bitcnt, ibit + 1)
428 imask = ishft(ones(tbit), 7 - ibit)
429 itmp2 = iand(ishft(itmp, 7 - ibit),imask)
430 itmp3 = iand(g2_mova2i(out(index)), 255 - imask)
431 out(index) = char(ior(itmp2, itmp3))
432 bitcnt = bitcnt - tbit
433 itmp = ishft(itmp, -tbit)
440 do while (bitcnt .ge. 8)
441 out(index) = char(iand(itmp, 255))
443 itmp = ishft(itmp, -8)
449 if (bitcnt .gt. 0)
then
450 itmp2 = iand(itmp, ones(bitcnt))
452 itmp3 = iand(g2_mova2i(out(index)), 255 - ones(bitcnt))
453 out(index) = char(ior(itmp2, itmp3))
475 character*1,
intent(inout) :: out(*)
476 integer (kind = 8),
intent(in) :: in(*)
477 integer,
intent(in) :: iskip, nbits
480 subroutine g2_sbytesc8(out, in, iskip, nbits, nskip, n)
481 character*1,
intent(out) :: out(*)
482 integer (kind = 8),
intent(in) :: in(n)
483 integer,
intent(in) :: iskip, nbits, nskip, n
507 character*1,
intent(inout) :: out(*)
508 integer (kind = 8),
intent(in) :: sin
509 integer,
intent(in) :: iskip, nbits
511 integer (kind = 8) :: in(1)
514 subroutine g2_sbytesc8(out, in, iskip, nbits, nskip, n)
515 character*1,
intent(out) :: out(*)
516 integer (kind = 8),
intent(in) :: in(n)
517 integer,
intent(in) :: iskip, nbits, nskip, n
541 character*1,
intent(out) :: out(*)
542 integer (kind = 8),
intent(in) :: in(n)
543 integer,
intent(in) :: iskip, nbits, nskip, n
545 integer :: bitcnt, tbit
546 integer,
parameter :: ones(8)=(/ 1, 3, 7, 15, 31, 63, 127, 255/)
547 integer :: nbit, i, index, ibit, imask, itmp1, itmp2, itmp3
548 integer (kind = 8) :: itmp8, itmp8_2
549 integer,
external :: g2_mova2i
553 nbit = iskip + nbits - 1
560 nbit = nbit + nbits + nskip
564 if (ibit .ne. 7)
then
565 tbit = min(bitcnt, ibit + 1)
566 imask = ishft(ones(tbit), 7 - ibit)
567 itmp1 = int(ishft(itmp8, int(7 - ibit, kind(8))), kind(4))
568 itmp2 = iand(itmp1, imask)
569 itmp3 = iand(g2_mova2i(out(index)), 255 - imask)
570 out(index) = char(ior(itmp2, itmp3))
571 bitcnt = bitcnt - tbit
572 itmp8 = ishft(itmp8, -tbit)
579 do while (bitcnt .ge. 8)
581 out(index) = char(iand(itmp8, 255_8))
582 itmp8 = ishft(itmp8, -8)
588 if (bitcnt .gt. 0)
then
589 itmp8_2 = int(ones(bitcnt), kind(8))
590 itmp2 = int(iand(itmp8, itmp8_2), kind(4))
591 itmp3 = iand(g2_mova2i(out(index)), 255 - ones(bitcnt))
592 out(index) = char(ior(itmp2, itmp3))
609 character(len = 1),
intent(in) :: cieee(*)
610 real,
intent(out) :: a(num)
611 integer,
intent(in) :: num
612 real (kind = 4) :: rieee(num)
615 subroutine rdieee(rieee, a, num)
616 real(4),
intent(in) :: rieee(num)
617 real,
intent(out) :: a(num)
618 integer,
intent(in) :: num
622 rieee(1:num) = transfer(cieee(1:num * 4), rieee, num)
623 call rdieee(rieee, a, num)
639 real(4),
intent(in) :: rieee(num)
640 real,
intent(out) :: a(num)
641 integer,
intent(in) :: num
644 real,
parameter :: two23 = scale(1.0, -23)
645 real,
parameter :: two126 = scale(1.0, -126)
646 integer :: iexp, imant, isign, j
651 ieee = transfer(rieee(j), ieee)
654 isign = ibits(ieee, 31, 1)
655 iexp = ibits(ieee, 23, 8)
656 imant = ibits(ieee, 0, 23)
658 if (isign .eq. 1) sign = -1.0
660 if (iexp .gt. 0 .and. iexp .lt. 255)
then
661 temp = 2.0**(iexp - 127)
662 a(j) = sign * temp * (1.0 + (two23 * real(imant)))
663 elseif (iexp .eq. 0)
then
664 if (imant .ne. 0)
then
665 a(j) = sign * two126 * two23 * real(imant)
669 elseif (iexp .eq. 255)
then
670 a(j) = sign * huge(a(j))
687 real(4),
intent(in) :: a(num)
688 real(4),
intent(out) :: rieee(num)
689 integer,
intent(in) :: num
692 real,
parameter :: two23 = scale(1.0,23)
693 real,
parameter :: two126 = scale(1.0,126)
695 integer :: iexp, imant, j, n
701 if (a(j) .eq. 0.)
then
703 rieee(j) = transfer(ieee, rieee(j))
708 if (a(j) .lt. 0.0)
then
709 ieee = ibset(ieee, 31)
712 ieee = ibclr(ieee, 31)
717 if (atemp .ge. 1.0)
then
719 do while (2.0**(n+1) .le. atemp)
724 do while (2.0**n .gt. atemp )
729 if (n .gt. 127) iexp = 255
730 if (n .lt. -127) iexp = 0
731 call mvbits(iexp, 0, 8, ieee, 23)
734 if (iexp .ne. 255)
then
735 if (iexp .ne. 0)
then
736 atemp = (atemp / (2.0**n)) - 1.0
738 atemp = atemp * two126
740 imant = nint(atemp * two23)
745 call mvbits(imant, 0, 23, ieee, 0)
748 rieee(j) = transfer(ieee, rieee(j))
subroutine g2_gbytesc(in, iout, iskip, nbits, nskip, n)
Extract arbitrary size big-endian integer values (up to 32 bits each) from a packed bit string.
subroutine rdieee(rieee, a, num)
Copy array of 32-bit IEEE floating point values to local floating point representation.
subroutine g2_sbytesc8(out, in, iskip, nbits, nskip, n)
Put arbitrary sized (up to 64 bits each) values into a packed bit string, taking the low order bits f...
subroutine g2_gbytec(in, iout, iskip, nbits)
Extract one arbitrary size big-endian value (up to 32 bits) from a packed bit string into one element...
subroutine mkieee(a, rieee, num)
Copy an array of real to an array of 32-bit IEEE floating points.
subroutine g2_sbytescr(out, rin, iskip, nbits, nskip, n)
Put real values into a packed bit string in big-endian order.
subroutine g2_gbytec8(in, iout, iskip, nbits)
Extract one arbitrary sized (up to 64-bits) values from a packed bit string, right justifying each va...
subroutine g2_sbytec81(out, sin, iskip, nbits)
Put one arbitrary sized (up to 64 bits) scalar into a packed bit string, taking the low order bits fr...
subroutine g2_sbytec(out, in, iskip, nbits)
Put one arbitrary sized (up to 32 bits) value from an integer array, into a packed bit string,...
subroutine g2_sbytec1(out, in, iskip, nbits)
Put one arbitrary sized (up to 32 bits) values from an integer scalar into a packed bit string,...
subroutine rdieeec(cieee, a, num)
Copy array of 32-bit IEEE floating point values stored in char array to local floating point represen...
subroutine g2_gbytec81(in, siout, iskip, nbits)
Extract one arbitrary size big-endian integer value (up to 64 bits) from a packed bit string into a s...
subroutine g2_gbytesc8(in, iout, iskip, nbits, nskip, n)
Extract arbitrary sized (up to 64-bits) values from a packed bit string, right justifying each value ...
subroutine g2_gbytescr(in, rout, iskip, nbits, nskip, n)
Extract big-endian floating-point values (32 bits each) from a packed bit string.
subroutine g2_sbytec8(out, in, iskip, nbits)
Put one arbitrary sized (up to 64 bits) values into a packed bit string, taking the low order bits fr...
subroutine g2_gbytec1(in, siout, iskip, nbits)
Extract one arbitrary size big-endian integer value (up to 32 bits) from a packed bit string into a s...
subroutine g2_sbytesc(out, in, iskip, nbits, nskip, n)
Put arbitrary size (up to 32 bits each) integer values into a packed bit string in big-endian order.