Skip to content

Commit

Permalink
#2867 Added get_nc_att_values_
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Soh committed Apr 30, 2024
1 parent 438c2ee commit d9d287c
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/libcode/vx_nc_util/nc_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,33 @@ bool get_nc_att_value_(const netCDF::NcVar *var, const ConcatString &att_name,
if (!status) {
mlog << Error << "\n" << caller_name
<< get_log_msg_for_att(att, GET_SAFE_NC_NAME_P(var), att_name);
if (exit_on_error) {
if (att) delete att;
exit(1);
}
}
if (att) delete att;
if (!status && exit_on_error) exit(1);

return status;
}

////////////////////////////////////////////////////////////////////////

template <typename T>
bool get_nc_att_values_(const netCDF::NcVar *var, const ConcatString &att_name,
T *att_vals, bool exit_on_error,
T bad_data, const char *caller_name) {
// caller should initialize att_vals

//
// Retrieve the NetCDF variable attribute.
//
netCDF::NcVarAtt *att = get_nc_att(var, att_name);
bool status = IS_VALID_NC_P(att);
if (status) att->getValues(att_vals);
else {
mlog << Error << "\n" << caller_name
<< get_log_msg_for_att(att, GET_SAFE_NC_NAME_P(var), att_name);
}
if (att) delete att;
if (!status && exit_on_error) exit(1);

return status;
}
Expand Down

0 comments on commit d9d287c

Please sign in to comment.