NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
w3ymdh4.f
Go to the documentation of this file.
1C> @file
2C> @brief 4-byte date word unpacker and packer.
3C> @author K. F. Brill @date 1998-07-29
4
5C> Obtains the components of the nmc date word (ncep y2k
6C> compliant form), or given its components, forms an nmc type date
7C> word. The packing is done using base 32.
8C>
9C> If the first byte of IDATE is less than 101, then the old
10C> Office Note 84 packing is assumed. A four-digit year is
11C> always returned. To pack the "old" way, pass in a 2-digit
12C> year.
13C>
14C> This program will work for the years ranging from A.D. 101
15C> through 79359.
16C>
17C> On unpacking, years less than or equal to 100 are returned
18C> as follows:
19C>
20C> - 0-50 2000--2050
21C> - 51-100 1951--2000
22C>
23C>
24C> ### Program History Log:
25C> Date | Programmer | Comment
26C> -----|------------|--------
27C> 1998-07-29 | K. F. Brill | Initial.
28C> 1999-03-15 | Gilbert | Removed Call to W3FS11() and put its processing inline.
29C> W3FS11 was deleted from the W3LIB.
30C>
31C> @param[inout] IDATE Left 4 bytes of integer 64 bit word, or can be
32C> IDATE(4) or CHARACTER*4 IDATE.
33C> @param[inout] IYEAR Year (4 digits or 2 digits for on84)
34C> @param[inout] MONTH Month
35C> @param[inout] IDAY Day
36C> @param[inout] IHOUR Hour
37C> @param[in] NN Code:
38C> - .eq. 0 pack iyear, month, iday, ihour into idate
39C> - .ne. 0 unpack idate into iyear, month, iday, ihour
40C>
41C> @author K. F. Brill @date 1998-07-29
42 SUBROUTINE w3ymdh4 (IDATE,IYEAR,MONTH,IDAY,IHOUR,NN)
43C
44 CHARACTER IDATE(4)
45C
46 IF (nn.NE.0) THEN
47C
48 itemp = mova2i(idate(1))
49 IF ( itemp .lt. 101 ) THEN
50 iyear = mova2i(idate(1))
51 month = mova2i(idate(2))
52 iday = mova2i(idate(3))
53 ihour = mova2i(idate(4))
54 IF(iyear.LE.100) iyear=2050-mod(2050-iyear,100)
55 RETURN
56 END IF
57 itemp = itemp - 101
58 itemp = itemp * 256 + mova2i(idate(2))
59 itemp = itemp * 256 + mova2i(idate(3))
60 itemp = itemp * 256 + mova2i(idate(4))
61 ihour = mod( itemp, 32 )
62 itemp = itemp / 32
63 iday = mod( itemp, 32 )
64 itemp = itemp / 32
65 month = mod( itemp, 32 )
66 iyear = itemp / 32
67C
68 ELSE
69C
70 itemp = iyear
71 IF ( itemp .lt. 101 ) THEN
72 idate(1) = char(iyear)
73 idate(2) = char(month)
74 idate(3) = char(iday)
75 idate(4) = char(ihour)
76 RETURN
77 END IF
78 itemp = itemp * 32 + month
79 itemp = itemp * 32 + iday
80 itemp = itemp * 32 + ihour
81C*
82 idate(4)=char(mod(itemp,256))
83 itemp = itemp / 256
84 idate(3)=char(mod(itemp,256))
85 itemp = itemp / 256
86 idate(2)=char(mod(itemp,256))
87 itemp = itemp / 256
88 itemp = itemp + 101
89 idate(1)=char(itemp)
90C
91 ENDIF
92C
93 RETURN
94 END
integer function mova2i(a)
This Function copies a bit string from a Character*1 variable to an integer variable.
Definition mova2i.f:25
subroutine w3ymdh4(idate, iyear, month, iday, ihour, nn)
Obtains the components of the nmc date word (ncep y2k compliant form), or given its components,...
Definition w3ymdh4.f:43