Skip to content

Commit

Permalink
#1966 Do not write into NetcDF if empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Soh committed Jan 25, 2022
1 parent c4f5a1b commit 4226cbe
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions met/src/libcode/vx_nc_obs/nc_obs_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1132,26 +1132,28 @@ void NetcdfObsVars::write_header_to_nc(NcDataBuffer &data_buf,
else if (data_buf.hdr_data_offset == data_buf.pb_hdr_data_offset) {
int save_len = lengths[0];
int pb_hdr_len = raw_hdr_cnt - offsets[0];
if (pb_hdr_len > buf_size) pb_hdr_len = buf_size;

lengths[0] = pb_hdr_len;
if(IS_VALID_NC(hdr_prpt_typ_var) && !put_nc_data((NcVar *)&hdr_prpt_typ_var,
data_buf.hdr_prpt_typ_buf, lengths, offsets)) {
mlog << Error << "error writing the pb message type to the netCDF file\n\n";
exit(1);
}
if(IS_VALID_NC(hdr_irpt_typ_var) && !put_nc_data((NcVar *)&hdr_irpt_typ_var,
data_buf.hdr_irpt_typ_buf, lengths, offsets)) {
mlog << Error << "error writing the in message type to the netCDF file\n\n";
exit(1);
}
if(IS_VALID_NC(hdr_inst_typ_var) && !put_nc_data((NcVar *)&hdr_inst_typ_var,
data_buf.hdr_inst_typ_buf, lengths, offsets)) {
mlog << Error << "error writing the instrument type to the netCDF file\n\n";
exit(1);
if (pb_hdr_len > 0) {
if (pb_hdr_len > buf_size) pb_hdr_len = buf_size;

lengths[0] = pb_hdr_len;
if(IS_VALID_NC(hdr_prpt_typ_var) && !put_nc_data((NcVar *)&hdr_prpt_typ_var,
data_buf.hdr_prpt_typ_buf, lengths, offsets)) {
mlog << Error << "error writing the pb message type to the netCDF file\n\n";
exit(1);
}
if(IS_VALID_NC(hdr_irpt_typ_var) && !put_nc_data((NcVar *)&hdr_irpt_typ_var,
data_buf.hdr_irpt_typ_buf, lengths, offsets)) {
mlog << Error << "error writing the in message type to the netCDF file\n\n";
exit(1);
}
if(IS_VALID_NC(hdr_inst_typ_var) && !put_nc_data((NcVar *)&hdr_inst_typ_var,
data_buf.hdr_inst_typ_buf, lengths, offsets)) {
mlog << Error << "error writing the instrument type to the netCDF file\n\n";
exit(1);
}
lengths[0] = save_len;
data_buf.pb_hdr_data_offset += pb_hdr_len;
}
lengths[0] = save_len;
data_buf.pb_hdr_data_offset += pb_hdr_len;
}
else {
mlog << Debug(6) << method_name
Expand Down

0 comments on commit 4226cbe

Please sign in to comment.