Created a tag for the 2012 HWRF baseline tests.
[WPS-merge.git] / hwrf-baseline-20120103-1354 / ungrib / src / ngl / g2 / rdieee.f
blob3ec4eb6ffb9dde8946fedbcff468271a4e557016
1 subroutine rdieee(rieee,a,num)
2 !$$$ SUBPROGRAM DOCUMENTATION BLOCK
3 ! . . . .
4 ! SUBPROGRAM: rdieee
5 ! PRGMMR: Gilbert ORG: W/NP11 DATE: 2000-05-09
7 ! ABSTRACT: This subroutine reads a list of real values in
8 ! 32-bit IEEE floating point format.
10 ! PROGRAM HISTORY LOG:
11 ! 2000-05-09 Gilbert
13 ! USAGE: CALL rdieee(rieee,a,num)
14 ! INPUT ARGUMENT LIST:
15 ! rieee - Input array of floating point values in 32-bit IEEE format.
16 ! num - Number of floating point values to convert.
18 ! OUTPUT ARGUMENT LIST:
19 ! a - Output array of real values.
21 ! REMARKS: None
23 ! ATTRIBUTES:
24 ! LANGUAGE: Fortran 90
25 ! MACHINE: IBM SP
27 !$$$
29 real(4),intent(in) :: rieee(num)
30 real,intent(out) :: a(num)
31 integer,intent(in) :: num
33 integer(4) :: ieee
35 real,save :: two23
36 real,save :: two126
37 integer,save :: once=0
39 if ( once .EQ. 0 ) then
40 once=1
41 two23=scale(1.0,-23)
42 two126=scale(1.0,-126)
43 endif
45 do j=1,num
47 ! Transfer IEEE bit string to integer variable
49 ieee=transfer(rieee(j),ieee)
51 ! Extract sign bit, exponent, and mantissa
53 isign=ibits(ieee,31,1)
54 iexp=ibits(ieee,23,8)
55 imant=ibits(ieee,0,23)
56 sign=1.0
57 if (isign.eq.1) sign=-1.0
59 if ( (iexp.gt.0).and.(iexp.lt.255) ) then
60 temp=2.0**(iexp-127)
61 a(j)=sign*temp*(1.0+(two23*real(imant)))
63 elseif ( iexp.eq.0 ) then
64 if ( imant.ne.0 ) then
65 a(j)=sign*two126*two23*real(imant)
66 else
67 a(j)=sign*0.0
68 endif
70 elseif ( iexp.eq.255 ) then
71 a(j)=sign*huge(a(j))
73 endif
75 enddo
77 return
78 end