40 double clp_tlon[
NDS], clp_tlat[
NDS], wmo_1st_tlon[
NDS], wmo_1st_tlat[
NDS],
41 wmo_2nd_tlon[
NDS], wmo_2nd_tlat[
NDS];
43 float clp_th[
NDS], clp_tp[
NDS], clp_tq[
NDS], clp_tt[
NDS], wmo_1st_th[
NDS],
44 wmo_1st_tp[
NDS], wmo_1st_tq[
NDS], wmo_1st_tt[
NDS], wmo_2nd_th[
NDS],
45 wmo_2nd_tp[
NDS], wmo_2nd_tq[
NDS], wmo_2nd_tt[
NDS];
52 ERRMSG(
"Give parameters: <ctl> <out.nc> <gps1.nc> [<gps2.nc> ...]");
55 for (
int iarg = 3; iarg < argc; iarg++)
56 if (!(in = fopen(argv[iarg],
"r")))
65 ERRMSG(
"No profiles found!");
73 for (
int ids = 0; ids < gps->
nds; ids++) {
74 clp_tlon[ids] = gps->
tlon[ids];
75 clp_tlat[ids] = gps->
tlat[ids];
76 clp_tp[ids] = (float) gps->
tp[ids];
77 clp_th[ids] = (
float) gps->
th[ids];
78 clp_tt[ids] = (float) gps->
tt[ids];
79 clp_tq[ids] = (
float) gps->
tq[ids];
84 for (
int ids = 0; ids < gps->
nds; ids++) {
85 wmo_1st_tlon[ids] = gps->
tlon[ids];
86 wmo_1st_tlat[ids] = gps->
tlat[ids];
87 wmo_1st_tp[ids] = (float) gps->
tp[ids];
88 wmo_1st_th[ids] = (
float) gps->
th[ids];
89 wmo_1st_tt[ids] = (float) gps->
tt[ids];
90 wmo_1st_tq[ids] = (
float) gps->
tq[ids];
95 for (
int ids = 0; ids < gps->
nds; ids++) {
96 wmo_2nd_tlon[ids] = gps->
tlon[ids];
97 wmo_2nd_tlat[ids] = gps->
tlat[ids];
98 wmo_2nd_tp[ids] = (float) gps->
tp[ids];
99 wmo_2nd_th[ids] = (
float) gps->
th[ids];
100 wmo_2nd_tt[ids] = (float) gps->
tt[ids];
101 wmo_2nd_tq[ids] = (
float) gps->
tq[ids];
109 int ncid, varid, dimid[10];
110 printf(
"Write tropopause file: %s\n", argv[2]);
111 NC(nc_create(argv[2], NC_CLOBBER, &ncid));
114 NC(nc_def_dim(ncid,
"NDS", (
size_t) gps->
nds, &dimid[0]));
117 add_var(ncid,
"time",
"s",
"time (seconds since 2000-01-01T00:00Z)",
118 NC_DOUBLE, dimid, &varid, 1);
120 add_var(ncid,
"clp_lat",
"degrees_north",
"cold point latitude", NC_DOUBLE,
122 add_var(ncid,
"clp_lon",
"degrees_east",
"cold point longitude", NC_DOUBLE,
124 add_var(ncid,
"clp_z",
"km",
"cold point height", NC_FLOAT, dimid, &varid,
126 add_var(ncid,
"clp_p",
"hPa",
"cold point pressure", NC_FLOAT, dimid,
128 add_var(ncid,
"clp_t",
"K",
"cold point temperature", NC_FLOAT, dimid,
130 add_var(ncid,
"clp_q",
"ppv",
"cold point water vapor", NC_FLOAT, dimid,
133 add_var(ncid,
"wmo_1st_lat",
"degrees_north",
"WMO 1st tropopause latitude",
134 NC_DOUBLE, dimid, &varid, 1);
135 add_var(ncid,
"wmo_1st_lon",
"degrees_east",
"WMO 1st tropopause longitude",
136 NC_DOUBLE, dimid, &varid, 1);
137 add_var(ncid,
"wmo_1st_z",
"km",
"WMO 1st tropopause height", NC_FLOAT,
139 add_var(ncid,
"wmo_1st_p",
"hPa",
"WMO 1st tropopause pressure", NC_FLOAT,
141 add_var(ncid,
"wmo_1st_t",
"K",
"WMO 1st tropopause temperature", NC_FLOAT,
143 add_var(ncid,
"wmo_1st_q",
"ppv",
"WMO 1st tropopause water vapor",
144 NC_FLOAT, dimid, &varid, 1);
146 add_var(ncid,
"wmo_2nd_lat",
"degrees_north",
"WMO 2nd tropopause latitude",
147 NC_DOUBLE, dimid, &varid, 1);
148 add_var(ncid,
"wmo_2nd_lon",
"degrees_east",
"WMO 2nd tropopause longitude",
149 NC_DOUBLE, dimid, &varid, 1);
150 add_var(ncid,
"wmo_2nd_z",
"km",
"WMO 2nd tropopause height", NC_FLOAT,
152 add_var(ncid,
"wmo_2nd_p",
"hPa",
"WMO 2nd tropopause pressure", NC_FLOAT,
154 add_var(ncid,
"wmo_2nd_t",
"K",
"WMO 2nd tropopause temperature", NC_FLOAT,
156 add_var(ncid,
"wmo_2nd_q",
"ppv",
"WMO 2nd tropopause water vapor",
157 NC_FLOAT, dimid, &varid, 1);
163 NC(nc_inq_varid(ncid,
"time", &varid));
164 NC(nc_put_var_double(ncid, varid, gps->
time));
166 NC(nc_inq_varid(ncid,
"clp_lat", &varid));
167 NC(nc_put_var_double(ncid, varid, clp_tlat));
168 NC(nc_inq_varid(ncid,
"clp_lon", &varid));
169 NC(nc_put_var_double(ncid, varid, clp_tlon));
170 NC(nc_inq_varid(ncid,
"clp_z", &varid));
171 NC(nc_put_var_float(ncid, varid, clp_th));
172 NC(nc_inq_varid(ncid,
"clp_p", &varid));
173 NC(nc_put_var_float(ncid, varid, clp_tp));
174 NC(nc_inq_varid(ncid,
"clp_t", &varid));
175 NC(nc_put_var_float(ncid, varid, clp_tt));
176 NC(nc_inq_varid(ncid,
"clp_q", &varid));
177 NC(nc_put_var_float(ncid, varid, clp_tq));
179 NC(nc_inq_varid(ncid,
"wmo_1st_lat", &varid));
180 NC(nc_put_var_double(ncid, varid, wmo_1st_tlat));
181 NC(nc_inq_varid(ncid,
"wmo_1st_lon", &varid));
182 NC(nc_put_var_double(ncid, varid, wmo_1st_tlon));
183 NC(nc_inq_varid(ncid,
"wmo_1st_z", &varid));
184 NC(nc_put_var_float(ncid, varid, wmo_1st_th));
185 NC(nc_inq_varid(ncid,
"wmo_1st_p", &varid));
186 NC(nc_put_var_float(ncid, varid, wmo_1st_tp));
187 NC(nc_inq_varid(ncid,
"wmo_1st_t", &varid));
188 NC(nc_put_var_float(ncid, varid, wmo_1st_tt));
189 NC(nc_inq_varid(ncid,
"wmo_1st_q", &varid));
190 NC(nc_put_var_float(ncid, varid, wmo_1st_tq));
192 NC(nc_inq_varid(ncid,
"wmo_2nd_lat", &varid));
193 NC(nc_put_var_double(ncid, varid, wmo_2nd_tlat));
194 NC(nc_inq_varid(ncid,
"wmo_2nd_lon", &varid));
195 NC(nc_put_var_double(ncid, varid, wmo_2nd_tlon));
196 NC(nc_inq_varid(ncid,
"wmo_2nd_z", &varid));
197 NC(nc_put_var_float(ncid, varid, wmo_2nd_th));
198 NC(nc_inq_varid(ncid,
"wmo_2nd_p", &varid));
199 NC(nc_put_var_float(ncid, varid, wmo_2nd_tp));
200 NC(nc_inq_varid(ncid,
"wmo_2nd_t", &varid));
201 NC(nc_put_var_float(ncid, varid, wmo_2nd_tt));
202 NC(nc_inq_varid(ncid,
"wmo_2nd_q", &varid));
203 NC(nc_put_var_float(ncid, varid, wmo_2nd_tq));
void add_var(int ncid, const char *varname, const char *unit, const char *longname, int type, int dimid[], int *varid, int ndims)
Add variable to netCDF file.
void read_gps_prof(char *filename, gps_t *gps)
Read GPS-RO profile.
void tropopause_spline(gps_t *gps, int met_tropo)
Find tropopause height using cubic spline interpolation.
GPS Code Collection library declarations.
#define NC(cmd)
Execute netCDF library command and check result.
#define NDS
Maximum number of GPS-RO profiles.
double time[NDS]
Time (seconds since 2000-01-01T00:00Z).
double tlon[NDS]
Tropopause longitude [deg].
double tt[NDS]
Tropopause temperature [K].
double tp[NDS]
Tropopause pressure [hPa].
int nds
Number of profiles.
double th[NDS]
Tropopause height [km].
double tlat[NDS]
Tropopause latitude [deg].
double tq[NDS]
Tropopause water vapor [ppmv].
int main(int argc, char *argv[])