38 for (ai = 0; ai < wrfout->
natts; ++ai) {
40 att = wrfout->
atts[ai];
49 ncid, NC_GLOBAL, att->
name, &att_type, &att_length);
53 "Could not get '%s' attribute from input NetCDF file\n",
61 if (status == 0 || att_length == 0) {
70 "Could not allocate memory for '%s' attribute value\n",
79 status = nc_get_att_schar(ncid, NC_GLOBAL, att->
name, att->
value.
bp);
82 status = nc_get_att_text(ncid, NC_GLOBAL, att->
name, att->
value.
cp);
85 status = nc_get_att_short(ncid, NC_GLOBAL, att->
name, att->
value.
sp);
88 status = nc_get_att_int(ncid, NC_GLOBAL, att->
name, att->
value.
ip);
91 status = nc_get_att_float(ncid, NC_GLOBAL, att->
name, att->
value.
fp);
94 status = nc_get_att_double(ncid, NC_GLOBAL, att->
name, att->
value.
dp);
98 "Could not get netcdf attribute value for: %s\n"
99 " -> invalid CDSDataType in output dataset\n",
100 att->
name, nc_strerror(status));
104 if (status != NC_NOERR) {
106 "Could not get netcdf attribute value for: %s\n"
108 att->
name, nc_strerror(status));
133 time_t *times = (time_t *)NULL;
135 char full_path[PATH_MAX];
144 char in_var_name[NC_MAX_NAME];
160 if (!
ncds_open(full_path, NC_NOWRITE, &ncid)) {
162 "Could not open input NetCDF file: %s\n", full_path);
171 "Could not create input dataset for: %s\n", full_path);
186 time_var =
ncds_get_var(ncid,
"XTIME", 0, &nsamples, wrfin,
187 NULL, 0, NULL, 0, 0, NULL, NULL, NULL, NULL);
191 "Could not get 'XTIME' variable from: %s\n", full_path);
206 "Could not get base time from 'XTIME' units string in file: %s\n",
220 times = (time_t *)malloc(nsamples *
sizeof(time_t));
223 "Could not allocated memory for time data\n");
229 for (ti = 0; ti < nsamples; ++ti) {
230 times[ti] = base_time + (time_t)(minutes[ti] * 60);
255 "Could not read dimensions from: %s\n", full_path);
267 "Could not copy dimensions to output dataset\n");
295 for (vi = 3; vi < wrfout->
nvars; ++vi) {
297 out_var = wrfout->
vars[vi];
299 if (strcmp(out_var->
name,
"lon") == 0) {
300 strcpy(in_var_name,
"XLONG");
302 else if (strcmp(out_var->
name,
"lat") == 0) {
303 strcpy(in_var_name,
"XLAT");
309 strcpy(in_var_name, out_var->
name);
310 for (chrp = in_var_name; *chrp; ++chrp) *chrp = toupper(*chrp);
316 in_var =
ncds_get_var(ncid, in_var_name, 0, &count, wrfin,
317 NULL, 0, NULL, 0, 0, NULL, NULL, NULL, NULL);
321 "Could not get the '%s' variable from: %s\n",
322 in_var_name, full_path);
334 in_var, wrfout, out_var->
name,
335 NULL, NULL, NULL, NULL,
340 "Could not copy input variable '%s' to output variable '%s'\n",
341 in_var_name, out_var->
name);
366 if (times) free(times);