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