updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / var / external / bufr / gets1loc.f
blob3f71b27284e0c0e6bd049cdefde80212af76250f
1 SUBROUTINE GETS1LOC(S1MNEM,IBEN,ISBYT,IWID,IRET)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
5 C SUBPROGRAM: GETS1LOC
6 C PRGMMR: ATOR ORG: NP12 DATE: 2005-11-29
8 C ABSTRACT: THIS SUBROUTINE RETURNS THE LOCATION (I.E. STARTING BYTE
9 C AND BIT WIDTH) OF A SPECIFIED VALUE WITHIN SECTION 1 OF A BUFR
10 C MESSAGE ENCODED ACCORDING TO A SPECIFIED BUFR EDITION. IT WILL
11 C WORK ON ANY MESSAGE ENCODED USING BUFR EDITION 2, 3 OR 4. THE
12 C VALUE FOR WHICH THE LOCATION IS TO BE DETERMINED IS SPECIFIED VIA
13 C THE MNEMONIC S1MNEM, AS EXPLAINED IN FURTHER DETAIL BELOW.
15 C PROGRAM HISTORY LOG:
16 C 2005-11-29 J. ATOR -- ORIGINAL AUTHOR
17 C 2006-04-14 D. KEYSER -- ADDED OPTIONS FOR 'YCEN' AND 'CENT'
19 C USAGE: GETS1LOC ( S1MNEM, IBEN, ISBYT, IWID, IRET )
20 C INPUT ARGUMENT LIST:
21 C S1MNEM - CHARACTER*(*): MNEMONIC SPECIFYING VALUE WHOSE
22 C LOCATION WITHIN SECTION 1 IS TO BE DETERMINED:
23 C 'LEN1' = LENGTH (IN BYTES) OF SECTION 1
24 C 'BMT' = BUFR MASTER TABLE
25 C 'OGCE' = ORIGINATING CENTER
26 C 'GSES' = ORIGINATING SUBCENTER
27 C (NOTE: THIS VALUE IS PRESENT ONLY IN
28 C BUFR EDITION 3 OR 4 MESSAGES!)
29 C 'USN' = UPDATE SEQUENCE NUMBER
30 C 'ISC2' = FLAG INDICATING ABSENCE/PRESENCE OF
31 C (OPTIONAL) SECTION 2 IN BUFR MESSAGE:
32 C 0 = SECTION 2 ABSENT
33 C 1 = SECTION 2 PRESENT
34 C 'MTYP' = DATA CATEGORY
35 C 'MSBTI' = DATA SUBCATEGORY (INTERNATIONAL)
36 C (NOTE: THIS VALUE IS PRESENT ONLY IN
37 C BUFR EDITION 4 MESSAGES!)
38 C 'MSBT' = DATA SUBCATEGORY (LOCAL)
39 C 'MTV' = VERSION NUMBER OF MASTER TABLE
40 C 'MTVL' = VERSION NUMBER OF LOCAL TABLES
41 C 'YCEN' = YEAR OF CENTURY (1-100)
42 C (NOTE: THIS VALUE IS PRESENT ONLY IN
43 C BUFR EDITION 2 AND 3 MESSAGES!)
44 C 'CENT' = CENTURY (I.E., 20 FOR YEARS 1901-2000,
45 C 21 FOR YEARS 2001-2100)
46 C (NOTE: THIS VALUE *MAY* BE PRESENT IN
47 C BUFR EDITION 2 AND 3 MESSAGES,
48 C BUT IT IS NEVER PRESENT IN ANY
49 C BUFR EDITION 4 MESSAGES!)
50 C 'YEAR' = YEAR (4-DIGIT)
51 C (NOTE: THIS VALUE IS PRESENT ONLY IN
52 C BUFR EDITION 4 MESSAGES!)
53 C 'MNTH' = MONTH
54 C 'DAYS' = DAY
55 C 'HOUR' = HOUR
56 C 'MINU' = MINUTE
57 C 'SECO' = SECOND
58 C (NOTE: THIS VALUE IS PRESENT ONLY IN
59 C BUFR EDITION 4 MESSAGES!)
60 C IBEN - INTEGER: BUFR EDITION NUMBER
63 C OUTPUT ARGUMENT LIST:
64 C ISBYT - INTEGER: NUMBER OF STARTING BYTE WITHIN SECTION 1
65 C WHICH CONTAINS VALUE CORRESPONDING TO S1MNEM
66 C (NOTE: ISBYT IS ALWAYS RETURNED AS 18 WHENEVER
67 C S1MNEM = 'CENT' AND IBEN = 2 OR 3; IN SUCH
68 C CASES IT IS THEN UP TO THE CALLING ROUTINE
69 C TO DETERMINE WHETHER THIS LOCATION ACTUALLY
70 C CONTAINS A VALID CENTURY VALUE!)
71 C IWID - INTEGER: WIDTH (IN BITS) OF VALUE CORRESPONDING
72 C TO S1MNEM
73 C IRET - INTEGER: RETURN CODE
74 C 0 = NORMAL RETURN
75 C -1 = THE INPUT S1MNEM MNEMONIC IS INVALID FOR
76 C BUFR EDITION IBEN
78 C REMARKS:
79 C THIS ROUTINE CALLS: None
80 C THIS ROUTINE IS CALLED BY: CRBMG IUPBS01 PKBS1
81 C Normally not called by any application
82 C programs.
84 C ATTRIBUTES:
85 C LANGUAGE: FORTRAN 77
86 C MACHINE: PORTABLE TO ALL PLATFORMS
88 C$$$
90 CHARACTER*(*) S1MNEM
92 C-----------------------------------------------------------------------
93 C-----------------------------------------------------------------------
95 IRET = 0
96 IWID = 8
98 IF(S1MNEM.EQ.'LEN1') THEN
99 ISBYT = 1
100 IWID = 24
101 ELSE IF(S1MNEM.EQ.'BMT') THEN
102 ISBYT = 4
103 ELSE IF(S1MNEM.EQ.'OGCE') THEN
104 IF(IBEN.EQ.3) THEN
105 ISBYT = 6
106 ELSE
108 C Note that this location is actually the same for both
109 C Edition 2 *and* Edition 4 of BUFR!
111 ISBYT = 5
112 IWID = 16
113 ENDIF
114 ELSE IF(S1MNEM.EQ.'GSES') THEN
115 IF(IBEN.EQ.3) THEN
116 ISBYT = 5
117 ELSE IF(IBEN.EQ.4) THEN
118 ISBYT = 7
119 IWID = 16
120 ELSE
121 IRET = -1
122 ENDIF
123 ELSE IF(S1MNEM.EQ.'USN') THEN
124 IF(IBEN.EQ.4) THEN
125 ISBYT = 9
126 ELSE
127 ISBYT = 7
128 ENDIF
129 ELSE IF(S1MNEM.EQ.'ISC2') THEN
130 IWID = 1
131 IF(IBEN.EQ.4) THEN
132 ISBYT = 10
133 ELSE
134 ISBYT = 8
135 ENDIF
136 ELSE IF(S1MNEM.EQ.'MTYP') THEN
137 IF(IBEN.EQ.4) THEN
138 ISBYT = 11
139 ELSE
140 ISBYT = 9
141 ENDIF
142 ELSE IF(S1MNEM.EQ.'MSBTI') THEN
143 IF(IBEN.EQ.4) THEN
144 ISBYT = 12
145 ELSE
146 IRET = -1
147 ENDIF
148 ELSE IF(S1MNEM.EQ.'MSBT') THEN
149 IF(IBEN.EQ.4) THEN
150 ISBYT = 13
151 ELSE
152 ISBYT = 10
153 ENDIF
154 ELSE IF(S1MNEM.EQ.'MTV') THEN
155 IF(IBEN.EQ.4) THEN
156 ISBYT = 14
157 ELSE
158 ISBYT = 11
159 ENDIF
160 ELSE IF(S1MNEM.EQ.'MTVL') THEN
161 IF(IBEN.EQ.4) THEN
162 ISBYT = 15
163 ELSE
164 ISBYT = 12
165 ENDIF
166 ELSE IF(S1MNEM.EQ.'YEAR') THEN
167 IF(IBEN.EQ.4) THEN
168 ISBYT = 16
169 IWID = 16
170 ELSE
171 IRET = -1
172 ENDIF
173 ELSE IF(S1MNEM.EQ.'YCEN') THEN
174 IF(IBEN.LT.4) THEN
175 ISBYT = 13
176 ELSE
177 IRET = -1
178 ENDIF
179 ELSE IF(S1MNEM.EQ.'CENT') THEN
180 IF(IBEN.LT.4) THEN
181 ISBYT = 18
182 ELSE
183 IRET = -1
184 ENDIF
185 ELSE IF(S1MNEM.EQ.'MNTH') THEN
186 IF(IBEN.EQ.4) THEN
187 ISBYT = 18
188 ELSE
189 ISBYT = 14
190 ENDIF
191 ELSE IF(S1MNEM.EQ.'DAYS') THEN
192 IF(IBEN.EQ.4) THEN
193 ISBYT = 19
194 ELSE
195 ISBYT = 15
196 ENDIF
197 ELSE IF(S1MNEM.EQ.'HOUR') THEN
198 IF(IBEN.EQ.4) THEN
199 ISBYT = 20
200 ELSE
201 ISBYT = 16
202 ENDIF
203 ELSE IF(S1MNEM.EQ.'MINU') THEN
204 IF(IBEN.EQ.4) THEN
205 ISBYT = 21
206 ELSE
207 ISBYT = 17
208 ENDIF
209 ELSE IF(S1MNEM.EQ.'SECO') THEN
210 IF(IBEN.EQ.4) THEN
211 ISBYT = 22
212 ELSE
213 IRET = -1
214 ENDIF
215 ELSE
216 IRET = -1
217 ENDIF
219 RETURN