24 subroutine specpack(fld,ndpts,JJ,KK,MM,idrstmpl,cpack,lcpack)
26 real,
intent(in) :: fld(ndpts)
27 integer,
intent(in) :: ndpts,JJ,KK,MM
28 integer,
intent(inout) :: idrstmpl(*)
29 character(len=1),
intent(out) :: cpack(*)
30 integer,
intent(out) :: lcpack
32 integer :: Ts,tmplsim(5)
33 real :: bscale,dscale,unpk(ndpts),tfld(ndpts)
34 real,
allocatable :: pscale(:)
36 bscale = 2.0**real(-idrstmpl(2))
37 dscale = 10.0**real(idrstmpl(3))
45 allocate(pscale(jj+mm))
46 tscale=real(idrstmpl(5))*1e-6
48 pscale(n)=real(n*(n+1))**(tscale)
59 if (kk .eq. jj+mm) nm=jj+m
61 if (ks .eq. js+ms) ns=js+m
63 if (n.le.ns .AND. m.le.ms)
then
65 unpk(incu+1)=fld(inc+1)
70 tfld(incp)=fld(inc)*pscale(n)
71 tfld(incp+1)=fld(inc+1)*pscale(n)
81 if (incu .ne. ts)
then
82 print *,
'specpack: Incorrect number of unpacked values ',
'given:',ts
83 print *,
'specpack: Resetting idrstmpl(9) to ',incu
92 tmplsim(2)=idrstmpl(2)
93 tmplsim(3)=idrstmpl(3)
94 tmplsim(4)=idrstmpl(4)
95 call simpack(tfld,ndpts-ts,tmplsim,cpack(ipos+1),lcpack)
99 idrstmpl(1)=tmplsim(1)
100 idrstmpl(2)=tmplsim(2)
101 idrstmpl(3)=tmplsim(3)
102 idrstmpl(4)=tmplsim(4)
123 subroutine specunpack(cpack, len, idrstmpl, ndpts, JJ, KK, MM, fld)
125 character(len = 1),
intent(in) :: cpack(len)
126 integer,
intent(in) :: ndpts, len, JJ, KK, MM
127 integer,
intent(in) :: idrstmpl(*)
128 real,
intent(out) :: fld(ndpts)
130 integer :: ifld(ndpts), Ts
132 real :: ref, bscale, dscale, unpk(ndpts)
133 real,
allocatable :: pscale(:)
137 bscale = 2.0**real(idrstmpl(2))
138 dscale = 10.0**real(-idrstmpl(3))
145 if (idrstmpl(10) .eq. 1)
then
148 call g2_gbytesc(cpack, ifld, iofst, nbits, 0, ndpts - ts)
151 allocate(pscale(jj + mm))
152 tscale = real(idrstmpl(5)) * 1e-6
154 pscale(n) = real(n * (n + 1))**(-tscale)
163 if (kk .eq. jj + mm) nm = jj + m
165 if (ks .eq. js + ms) ns = js + m
167 if (n .le. ns .AND. m .le. ms)
then
168 fld(inc) = unpk(incu)
169 fld(inc + 1) = unpk(incu + 1)
173 fld(inc) = ((real(ifld(incp))*bscale) + ref)*dscale*pscale(n)
174 fld(inc + 1) = ((real(ifld(incp + 1)) * bscale) + ref) * dscale * pscale(n)
182 print *,
'specunpack: Cannot handle 64 or 128-bit floats.'
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 rdieeec(cieee, a, num)
Copy array of 32-bit IEEE floating point values stored in char array to local floating point represen...
subroutine simpack(fld, ndpts, idrstmpl, cpack, lcpack)
Pack a data field using a simple packing algorithm.
subroutine specpack(fld, ndpts, JJ, KK, MM, idrstmpl, cpack, lcpack)
Pack a spectral data field using the complex packing algorithm for spherical harmonic data as defined...
subroutine specunpack(cpack, len, idrstmpl, ndpts, JJ, KK, MM, fld)
Unpack a spectral data field using the complex packing algorithm for spherical harmonic data,...