26 subroutine simpack(fld,ndpts,idrstmpl,cpack,lcpack)
30 integer,
intent(in) :: ndpts
31 real,
intent(in) :: fld(ndpts)
32 character(len=1),
intent(out) :: cpack(*)
33 integer,
intent(inout) :: idrstmpl(*)
34 integer,
intent(out) :: lcpack
39 integer :: ifld(ndpts)
40 integer,
parameter :: zero=0
41 integer :: nbittot, nbits, maxnum, maxdif, left
42 integer :: imax, imin, j
43 real :: rmax, rmin, temp, dscale, bscale
45 bscale=2.0**real(-idrstmpl(2))
46 dscale=10.0**real(idrstmpl(3))
47 if (idrstmpl(4).le.0.OR.idrstmpl(4).gt.31)
then
61 if (fld(j).gt.rmax) rmax=fld(j)
62 if (fld(j).lt.rmin) rmin=fld(j)
70 if (rmin.ne.rmax)
then
74 if (nbits.eq.0.AND.idrstmpl(2).eq.0)
then
78 imin=nint(rmin*dscale)
79 imax=nint(rmax*dscale)
86 ifld(j)=nint(fld(j)*dscale)-imin
88 elseif (nbits.ne.0.AND.idrstmpl(2).eq.0)
then
95 temp=
ilog2(nint(real(maxnum)/(rmax-rmin)))
96 idrstmpl(2)=ceiling(-1.0*temp)
97 bscale=2.0**real(-idrstmpl(2))
100 ifld(j)=max(0,nint(((fld(j)*dscale)-rmin)*bscale))
102 elseif (nbits.eq.0.AND.idrstmpl(2).ne.0)
then
108 maxdif=nint((rmax-rmin)*bscale)
113 ifld(j)=max(0,nint(((fld(j)*dscale)-rmin)*bscale))
115 elseif (nbits.ne.0.AND.idrstmpl(2).ne.0)
then
124 ifld(j)=max(0,nint(((fld(j)*dscale)-rmin)*bscale))
132 left=8-mod(nbittot,8)
147 rmin4 = real(rmin, 4)
149 iref=transfer(ref,iref)
171 character(len=1),
intent(in) :: cpack(len)
172 integer,
intent(in) :: ndpts, len
173 integer,
intent(in) :: idrstmpl(*)
174 real,
intent(out) :: fld(ndpts)
176 integer :: ifld(ndpts)
178 real :: ref, bscale, dscale
179 integer :: itype, j, nbits
183 bscale = 2.0**real(idrstmpl(2))
184 dscale = 10.0**real(-idrstmpl(3))
190 if (nbits .ne. 0)
then
191 call g2_gbytesc(cpack, ifld, 0, nbits, 0, ndpts)
193 fld(j) = ((real(ifld(j)) * bscale) + ref) * dscale
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 mkieee(a, rieee, num)
Copy an array of real to an array of 32-bit IEEE floating points.
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_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.
subroutine simunpack(cpack, len, idrstmpl, ndpts, fld)
Unpack a data field that was packed using a simple packing, [Data Representation Template 5....
subroutine simpack(fld, ndpts, idrstmpl, cpack, lcpack)
Pack a data field using a simple packing algorithm.
Define math functions used by compack(), simpack(), and misspack().