8 /* cnames.c Wesley Ebisuzaki
10 * returns strings with either variable name or comment field
12 * reanalysis can use process 180 and subcenter 0
14 * Add DWD tables 2, 201, 202, 203 Helmut P. Frank, DWD, FE13
15 * Thu Aug 23 09:28:34 GMT 2001
19 extern struct ParmTable parm_table_ncep_opn
[256];
20 extern struct ParmTable parm_table_ncep_reanal
[256];
21 extern struct ParmTable parm_table_nceptab_129
[256];
22 extern struct ParmTable parm_table_omb
[256];
23 extern struct ParmTable parm_table_nceptab_130
[256];
24 extern struct ParmTable parm_table_nceptab_131
[256];
26 extern struct ParmTable parm_table_ecmwf_128
[256];
27 extern struct ParmTable parm_table_ecmwf_129
[256];
28 extern struct ParmTable parm_table_ecmwf_130
[256];
29 extern struct ParmTable parm_table_ecmwf_131
[256];
30 extern struct ParmTable parm_table_ecmwf_140
[256];
31 extern struct ParmTable parm_table_ecmwf_150
[256];
32 extern struct ParmTable parm_table_ecmwf_151
[256];
33 extern struct ParmTable parm_table_ecmwf_160
[256];
34 extern struct ParmTable parm_table_ecmwf_170
[256];
35 extern struct ParmTable parm_table_ecmwf_180
[256];
36 extern struct ParmTable parm_table_user
[256];
37 extern struct ParmTable parm_table_dwd_002
[256];
38 extern struct ParmTable parm_table_dwd_201
[256];
39 extern struct ParmTable parm_table_dwd_202
[256];
40 extern struct ParmTable parm_table_dwd_203
[256];
41 extern struct ParmTable parm_table_cptec_254
[256];
43 extern enum Def_NCEP_Table def_ncep_table
;
46 * returns pointer to the parameter table
51 static struct ParmTable
*Parm_Table(unsigned char *pds
) {
53 int i
, center
, subcenter
, ptable
, process
;
54 static int missing_count
= 0, reanal_opn_count
= 0;
56 center
= PDS_Center(pds
);
57 subcenter
= PDS_Subcenter(pds
);
58 ptable
= PDS_Vsn(pds
);
61 i
= setup_user_table(center
, subcenter
, ptable
);
62 if (i
== 1) return &parm_table_user
[0];
64 /* figure out if NCEP opn or reanalysis */
65 if (center
== NMC
&& ptable
<= 3) {
66 if (subcenter
== 1) return &parm_table_ncep_reanal
[0];
67 process
= PDS_Model(pds
);
68 if (subcenter
!= 0 || (process
!= 80 && process
!= 180) ||
69 (ptable
!= 1 && ptable
!= 2))
70 return &parm_table_ncep_opn
[0];
72 /* at this point could be either the opn or reanalysis table */
73 if (def_ncep_table
== opn_nowarn
) return &parm_table_ncep_opn
[0];
74 if (def_ncep_table
== rean_nowarn
) return &parm_table_ncep_reanal
[0];
75 if (reanal_opn_count
++ == 0) {
76 fprintf(stderr
, "Using NCEP %s table, see -ncep_opn, -ncep_rean options\n",
77 (def_ncep_table
== opn
) ? "opn" : "reanalysis");
79 return (def_ncep_table
== opn
) ? &parm_table_ncep_opn
[0]
80 : &parm_table_ncep_reanal
[0];
84 if (ptable
== 128) return &parm_table_omb
[0];
85 if (ptable
== 129) return &parm_table_nceptab_129
[0];
86 if (ptable
== 130) return &parm_table_nceptab_130
[0];
87 if (ptable
== 131) return &parm_table_nceptab_131
[0];
88 if (ptable
== 132) return &parm_table_ncep_reanal
[0];
90 if (center
== ECMWF
) {
91 if (ptable
== 128) return &parm_table_ecmwf_128
[0];
92 if (ptable
== 129) return &parm_table_ecmwf_129
[0];
93 if (ptable
== 130) return &parm_table_ecmwf_130
[0];
94 if (ptable
== 131) return &parm_table_ecmwf_131
[0];
95 if (ptable
== 140) return &parm_table_ecmwf_140
[0];
96 if (ptable
== 150) return &parm_table_ecmwf_150
[0];
97 if (ptable
== 151) return &parm_table_ecmwf_151
[0];
98 if (ptable
== 160) return &parm_table_ecmwf_160
[0];
99 if (ptable
== 170) return &parm_table_ecmwf_170
[0];
100 if (ptable
== 180) return &parm_table_ecmwf_180
[0];
103 if (ptable
== 2) return &parm_table_dwd_002
[0];
104 if (ptable
== 201) return &parm_table_dwd_201
[0];
105 if (ptable
== 202) return &parm_table_dwd_202
[0];
106 if (ptable
== 203) return &parm_table_dwd_203
[0];
108 if (center
== CPTEC
) {
109 if (ptable
== 254) return &parm_table_cptec_254
[0];
112 #ifndef P_TABLE_FIRST
113 i
= setup_user_table(center
, subcenter
, ptable
);
114 if (i
== 1) return &parm_table_user
[0];
117 if ((ptable
> 3 || (PDS_PARAM(pds
)) > 127) && missing_count
++ == 0) {
119 "\nUndefined parameter table (center %d-%d table %d), using NCEP-opn\n",
120 center
, subcenter
, ptable
);
122 return &parm_table_ncep_opn
[0];
126 * return name field of PDS_PARAM(pds)
129 char *k5toa(unsigned char *pds
) {
131 return (Parm_Table(pds
) + PDS_PARAM(pds
))->name
;
135 * return comment field of the PDS_PARAM(pds)
138 char *k5_comments(unsigned char *pds
) {
140 return (Parm_Table(pds
) + PDS_PARAM(pds
))->comment
;