You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some variables on a UGRID file contain the indices of an array, these indices are zero- or one-based. The value of the start_index (0/1) determines if the array on file is zero- or one-based. Depending on the language which uses the UGrid-library the indices should be corrected by the start_index. Therefor the start_index should be read from file. Example: C++ uses zero-based indices and Fortran uses one-based indices.
For a 1D mesh I use the code:
`
{
// reading start_index, needed for edge_nodes array
int i_var;
int start_index = -2;
std::string var_edge_node;
std::string var_start_index;
std::string tmp_name(stripSpaces(m_mesh1d.name));
status = get_attribute_by_var_name(m_ncid, tmp_name, "edge_node_connectivity", &var_edge_node);
status = nc_inq_varid(m_ncid, var_edge_node.c_str(), &i_var);
status = nc_get_att_int(m_ncid, i_var, "start_index", &start_index);
m_mesh1d.start_index = start_index;
if (m_mesh1d.start_index != 0)
{
for (int i = 0; i < m_mesh1d.num_edges * 2; ++i)
{
m_mesh1d.edge_node[i] -= m_mesh1d.start_index;
}
}
}
The text was updated successfully, but these errors were encountered:
Some variables on a UGRID file contain the indices of an array, these indices are zero- or one-based. The value of the start_index (0/1) determines if the array on file is zero- or one-based. Depending on the language which uses the UGrid-library the indices should be corrected by the start_index. Therefor the start_index should be read from file. Example: C++ uses zero-based indices and Fortran uses one-based indices.
For a 1D mesh I use the code:
`
{
// reading start_index, needed for edge_nodes array
int i_var;
int start_index = -2;
std::string var_edge_node;
std::string var_start_index;
std::string tmp_name(stripSpaces(m_mesh1d.name));
status = get_attribute_by_var_name(m_ncid, tmp_name, "edge_node_connectivity", &var_edge_node);
status = nc_inq_varid(m_ncid, var_edge_node.c_str(), &i_var);
status = nc_get_att_int(m_ncid, i_var, "start_index", &start_index);
m_mesh1d.start_index = start_index;
The text was updated successfully, but these errors were encountered: