9 * PDStimes.c v1.2 wesley ebisuzaki
11 * prints something readable for time code in grib file
13 * not all cases decoded
14 * for NCEP/NCAR Reanalysis
16 * v1.2.1 1/99 fixed forecast time unit table
17 * v1.2.2 10/01 add time_range = 11 (at DWD) Helmut P. Frank
20 static char *units
[] = {
21 "min", "hr", "d", "mon", "yr",
22 "decade", "normal", "century", "??", "??", " x3 hours", " x6 hours",
24 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
25 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
26 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
27 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
28 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
29 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
30 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
31 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
32 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
33 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
34 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
35 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
36 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
37 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
38 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
39 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
40 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
41 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
42 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
43 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
44 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
45 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
46 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
47 "??", "??", "??", "??", "??", "??", "??", "??", "??", "??",
50 void PDStimes(int time_range
, int p1
, int p2
, int time_unit
) {
53 enum {anal
, fcst
, unknown
} type
;
56 if (time_unit
>= 0 && time_unit
<= sizeof(units
)/sizeof(char *))
57 unit
= units
[time_unit
];
61 /* change x3/x6/x12 to hours */
63 if (time_unit
== HOURS3
) {
67 else if (time_unit
== HOURS6
) {
71 else if (time_unit
== HOURS12
) {
76 if (time_unit
>= 0 && time_unit
<= sizeof(units
)/sizeof(char *))
77 unit
= units
[time_unit
];
80 /* figure out if analysis or forecast */
81 /* in GRIB, there is a difference between init and uninit analyses */
82 /* not case at NMC .. no longer run initialization */
83 /* ignore diff between init an uninit analyses */
92 if (p1
== 0) type
= anal
;
98 case 10: /* way NMC uses it, should be unknown? */
100 fcst_len
= p1
*256 + p2
;
101 if (fcst_len
== 0) type
= anal
;
116 default: type
= unknown
;
120 /* ----------------------------------------------- */
122 if (type
== anal
) printf("anl:");
123 else if (type
== fcst
) printf("%d%s fcst:",fcst_len
,unit
);
126 if (time_range
== 123 || time_range
== 124) {
127 if (p1
!= 0) printf("start@%d%s:",p1
,unit
);
131 /* print time range */
134 switch (time_range
) {
140 case 2: printf("valid %d-%d%s:",p1
,p2
,unit
);
142 case 3: printf("%d-%d%s ave:",p1
,p2
,unit
);
144 case 4: printf("%d-%d%s acc:",p1
,p2
,unit
);
146 case 5: printf("%d-%d%s diff:",p1
,p2
,unit
);
148 case 11: if (p1
> 0) {
149 printf("init fcst %d%s:",p1
,unit
);
155 case 51: if (p1
== 0) {
156 /* printf("clim %d%s:",p2,unit); */
157 printf("0-%d%s product:ave@1yr:",p2
,unit
);
160 /* printf("clim (diurnal) %d%s:",p2,unit); */
161 printf("0-%d%s product:same-hour,ave@1yr:",p2
,unit
);
164 printf("clim? p1=%d? %d%s?:",p1
,p2
,unit
);
169 printf("ave@%d%s:",p2
,unit
);
173 printf("acc@%d%s:",p2
,unit
);
176 printf("ave of fcst:%d to %d%s:",p1
,p2
,unit
);
179 printf("acc of fcst:%d to %d%s:",p1
,p2
,unit
);
182 printf("var@%d%s:",p2
,unit
);
185 printf("%d-%d%s fcst acc:ave@24hr:", p1
, p2
, unit
);
188 printf("%d-%d%s fcst acc:ave@%d%s:", p1
, p2
, unit
, p2
-p1
,unit
);
191 printf("%d-%d%s fcst ave:ave@24hr:", p1
, p2
, unit
);
194 printf("%d-%d%s fcst ave:ave@%d%s:", p1
, p2
, unit
,p2
-p1
,unit
);
198 printf("%d-%d%s anl:ave@1yr:", p1
, p2
, unit
);
201 printf("%d-%d%s fcst:ave@1yr:", p1
, p2
, unit
);
204 printf("%d-%d%s fcst-anl:rms@1yr:", p1
, p2
, unit
);
207 printf("%d-%d%s fcst-fcst_mean:rms@1yr:", p1
, p2
, unit
);
210 printf("%d-%d%s anl-anl_mean:rms@1yr:", p1
, p2
, unit
);
214 default: printf("time?:");