1 subroutine mkieee(a,rieee,num)
2 !$$$ SUBPROGRAM DOCUMENTATION BLOCK
5 ! PRGMMR: Gilbert ORG: W/NP11 DATE: 2000-05-09
7 ! ABSTRACT: This subroutine stores a list of real values in
8 ! 32-bit IEEE floating point format.
10 ! PROGRAM HISTORY LOG:
13 ! USAGE: CALL mkieee(a,rieee,num)
14 ! INPUT ARGUMENT LIST:
15 ! a - Input array of floating point values.
16 ! num - Number of floating point values to convert.
18 ! OUTPUT ARGUMENT LIST:
19 ! rieee - Output array of floating point values in 32-bit IEEE format.
24 ! LANGUAGE: Fortran 90
29 real,intent(in) :: a(num)
30 real(4),intent(out) :: rieee(num)
31 integer,intent(in) :: num
37 integer,save :: once=0
39 if ( once .EQ. 0 ) then
52 rieee(j)=transfer(ieee,rieee(j))
53 ! write(6,fmt='(f20.10,5x,b32)') a,a
54 ! write(6,fmt='(f20.10,5x,b32)') rieee,rieee
59 ! Set Sign bit (bit 31 - leftmost bit)
69 ! Determine exponent n with base 2
71 n=floor(alog(atemp)/alog2)
73 if (n.gt.127) iexp=255 ! overflow
75 ! set exponent bits ( bits 30-23 )
76 call mvbits(iexp,0,8,ieee,23)
82 atemp=(atemp/(2.0**n))-1.0
86 imant=nint(atemp*two23)
90 ! set mantissa bits ( bits 22-0 )
91 call mvbits(imant,0,23,ieee,0)
93 ! Transfer IEEE bit string to real variable
95 rieee(j)=transfer(ieee,rieee(j))
96 ! write(6,fmt='(f20.10,5x,b32)') a,a
97 ! write(6,fmt='(f20.10,5x,b32)') rieee,rieee