Skip to content

Commit

Permalink
If no start_index is given, assume zero
Browse files Browse the repository at this point in the history
  • Loading branch information
mooiman committed Jun 21, 2023
1 parent ea01d89 commit 8113aff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/include/version_number.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[versionnumbers]
major = 0
minor = 20
revision = 00
revision = 01
48 changes: 18 additions & 30 deletions packages/src/ugrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1947,15 +1947,12 @@ int UGRID::read_variables_with_cf_role(int i_var, std::string var_name, std::str

int start_index;
status = get_attribute(this->m_ncid, var_id, const_cast<char*>("start_index"), &start_index);
if (status == NC_NOERR)
if (status == NC_NOERR && start_index != 0)
{
if (start_index != 0)
for (int i = 0; i < m_mesh_contact->edge[m_nr_mesh_contacts - 1]->count; i++)
{
for (int i = 0; i < m_mesh_contact->edge[m_nr_mesh_contacts - 1]->count; i++)
{
m_mesh_contact->edge[m_nr_mesh_contacts - 1]->edge_nodes[i][0] -= start_index;
m_mesh_contact->edge[m_nr_mesh_contacts - 1]->edge_nodes[i][1] -= start_index;
}
m_mesh_contact->edge[m_nr_mesh_contacts - 1]->edge_nodes[i][0] -= start_index;
m_mesh_contact->edge[m_nr_mesh_contacts - 1]->edge_nodes[i][1] -= start_index;
}
}

Expand Down Expand Up @@ -2089,15 +2086,12 @@ int UGRID::read_variables_with_cf_role(int i_var, std::string var_name, std::str

int start_index;
status = get_attribute(this->m_ncid, var_id, const_cast<char*>("start_index"), &start_index);
if (status == NC_NOERR)
if (status == NC_NOERR && start_index != 0)
{
if (start_index != 0)
for (int i = 0; i < m_ntw_edges->edge[nr_ntw - 1]->count; i++)
{
for (int i = 0; i < m_ntw_edges->edge[nr_ntw - 1]->count; i++)
{
m_ntw_edges->edge[nr_ntw - 1]->edge_nodes[i][0] -= start_index;
m_ntw_edges->edge[nr_ntw - 1]->edge_nodes[i][1] -= start_index;
}
m_ntw_edges->edge[nr_ntw - 1]->edge_nodes[i][0] -= start_index;
m_ntw_edges->edge[nr_ntw - 1]->edge_nodes[i][1] -= start_index;
}
}

Expand Down Expand Up @@ -2295,15 +2289,12 @@ int UGRID::read_variables_with_cf_role(int i_var, std::string var_name, std::str
status = nc_get_vara_int(this->m_ncid, var_id, start2, count2, mesh1d_edge_nodes);

status = get_attribute(this->m_ncid, var_id, const_cast<char*>("start_index"), &start_index);
if (status == NC_NOERR)
if (status == NC_NOERR && start_index != 0)
{
if (start_index != 0)
for (int i = 0; i < m_mesh1d->edge[nr_mesh1d - 1]->count; i++)
{
for (int i = 0; i < m_mesh1d->edge[nr_mesh1d - 1]->count; i++)
{
m_mesh1d->edge[nr_mesh1d - 1]->edge_nodes[i][0] -= start_index;
m_mesh1d->edge[nr_mesh1d - 1]->edge_nodes[i][1] -= start_index;
}
m_mesh1d->edge[nr_mesh1d - 1]->edge_nodes[i][0] -= start_index;
m_mesh1d->edge[nr_mesh1d - 1]->edge_nodes[i][1] -= start_index;
}
}
}
Expand Down Expand Up @@ -2334,7 +2325,7 @@ int UGRID::read_variables_with_cf_role(int i_var, std::string var_name, std::str
status = nc_get_var_long(this->m_ncid, var_id, m_mesh1d->node[nr_mesh1d - 1]->branch.data());

status = nc_get_att_int(this->m_ncid, var_id, "start_index", &start_index);
if (start_index != 0)
if (status == NC_NOERR && start_index != 0)
{
for (int i = 0; i < m_mesh1d->node[nr_mesh1d - 1]->count; i++)
{
Expand Down Expand Up @@ -2367,7 +2358,7 @@ int UGRID::read_variables_with_cf_role(int i_var, std::string var_name, std::str
status = nc_get_var_long(this->m_ncid, var_id, m_mesh1d->edge[nr_mesh1d - 1]->edge_branch.data());

status = nc_get_att_int(this->m_ncid, var_id, "start_index", &start_index);
if (start_index != 0)
if (status == NC_NOERR && start_index != 0)
{
for (int i = 0; i < m_mesh1d->edge[nr_mesh1d - 1]->count; i++)
{
Expand Down Expand Up @@ -2473,15 +2464,12 @@ int UGRID::read_variables_with_cf_role(int i_var, std::string var_name, std::str
}

status = get_attribute(this->m_ncid, var_id, const_cast<char*>("start_index"), &start_index);
if (status == NC_NOERR)
if (status == NC_NOERR && start_index != 0)
{
if (start_index != 0)
for (int i = 0; i < m_mesh2d->edge[nr_mesh2d - 1]->count; i++)
{
for (int i = 0; i < m_mesh2d->edge[nr_mesh2d - 1]->count; i++)
{
m_mesh2d->edge[nr_mesh2d - 1]->edge_nodes[i][0] -= start_index;
m_mesh2d->edge[nr_mesh2d - 1]->edge_nodes[i][1] -= start_index;
}
m_mesh2d->edge[nr_mesh2d - 1]->edge_nodes[i][0] -= start_index;
m_mesh2d->edge[nr_mesh2d - 1]->edge_nodes[i][1] -= start_index;
}
}
free(dimids);
Expand Down

0 comments on commit 8113aff

Please sign in to comment.