Skip to content

Commit

Permalink
Merge pull request #435 from sandialabs/IOSS-use-Data-instead-of-data…
Browse files Browse the repository at this point in the history
…-method

IOSS: Partial conversion from vector.data() to Data(vector)
  • Loading branch information
gsjaardema authored Feb 16, 2024
2 parents 29a9ebe + ae9b6f0 commit 43ab3b3
Show file tree
Hide file tree
Showing 85 changed files with 1,503 additions and 1,409 deletions.
51 changes: 26 additions & 25 deletions packages/seacas/applications/conjoin/CJ_Internals.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2023 National Technology & Engineering Solutions
* Copyright(C) 1999-, 20242024 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand All @@ -13,6 +13,7 @@
#include <exodusII_int.h>
#include <fmt/format.h>
#include <netcdf.h>
#include <vector_data.h>

#include <CJ_ExodusEntity.h>

Expand Down Expand Up @@ -311,7 +312,7 @@ int Excn::Internals::put_metadata(const Mesh<INT> &mesh, const CommunicationMeta
{
std::array dim{timedim};
if ((status = nc_def_var(exodusFilePtr, VAR_WHOLE_TIME, nc_flt_code(exodusFilePtr), 1,
dim.data(), &varid)) != NC_NOERR) {
Data(dim), &varid)) != NC_NOERR) {
std::string errmsg = fmt::format(
"Error: failed to define whole time step variable in file id {}", exodusFilePtr);
ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status);
Expand Down Expand Up @@ -340,7 +341,7 @@ int Excn::Internals::put_metadata(const Mesh<INT> &mesh, const CommunicationMeta

// Define the node map here to avoid a later redefine call
std::array dims{numnoddim};
status = nc_def_var(exodusFilePtr, VAR_NODE_NUM_MAP, map_type, 1, dims.data(), &varid);
status = nc_def_var(exodusFilePtr, VAR_NODE_NUM_MAP, map_type, 1, Data(dims), &varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
if (status == NC_ENAMEINUSE) {
Expand Down Expand Up @@ -372,7 +373,7 @@ int Excn::Internals::put_metadata(const Mesh<INT> &mesh, const CommunicationMeta
// Define the element map here to avoid a later redefine call
std::array dims{numelemdim};
varid = 0;
status = nc_def_var(exodusFilePtr, VAR_ELEM_NUM_MAP, map_type, 1, dims.data(), &varid);
status = nc_def_var(exodusFilePtr, VAR_ELEM_NUM_MAP, map_type, 1, Data(dims), &varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
if (status == NC_ENAMEINUSE) {
Expand Down Expand Up @@ -524,7 +525,7 @@ int Excn::Internals::put_metadata(const std::vector<Block> &blocks)
std::array dims{numelbdim, numattrdim};
int varid = 0;
status = nc_def_var(exodusFilePtr, VAR_ATTRIB(iblk + 1), nc_flt_code(exodusFilePtr), 2,
dims.data(), &varid);
Data(dims), &varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
errmsg =
Expand All @@ -539,7 +540,7 @@ int Excn::Internals::put_metadata(const std::vector<Block> &blocks)
std::array adims{numattrdim, namestrdim};

status =
nc_def_var(exodusFilePtr, VAR_NAME_ATTRIB(iblk + 1), NC_CHAR, 2, adims.data(), &varid);
nc_def_var(exodusFilePtr, VAR_NAME_ATTRIB(iblk + 1), NC_CHAR, 2, Data(adims), &varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
errmsg = fmt::format("Error: failed to define attribute name array for element block {}"
Expand All @@ -555,7 +556,7 @@ int Excn::Internals::put_metadata(const std::vector<Block> &blocks)

int bulk_type = get_type(exodusFilePtr, EX_BULK_INT64_DB);
int connid;
status = nc_def_var(exodusFilePtr, VAR_CONN(iblk + 1), bulk_type, 2, dims.data(), &connid);
status = nc_def_var(exodusFilePtr, VAR_CONN(iblk + 1), bulk_type, 2, Data(dims), &connid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
errmsg = fmt::format("Error: failed to create connectivity array for block {} in file id {}",
Expand Down Expand Up @@ -677,8 +678,8 @@ template <typename INT> int Excn::Internals::put_metadata(const std::vector<Node
int bulk_type = get_type(exodusFilePtr, EX_BULK_INT64_DB);
std::array dims{dimid};
int varid;
status = nc_def_var(exodusFilePtr, VAR_NODE_NS(cur_num_node_sets + 1), bulk_type, 1,
dims.data(), &varid);
status = nc_def_var(exodusFilePtr, VAR_NODE_NS(cur_num_node_sets + 1), bulk_type, 1, Data(dims),
&varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
if (status == NC_ENAMEINUSE) {
Expand Down Expand Up @@ -711,7 +712,7 @@ template <typename INT> int Excn::Internals::put_metadata(const std::vector<Node

// create variable for distribution factors
status = nc_def_var(exodusFilePtr, VAR_FACT_NS(cur_num_node_sets + 1),
nc_flt_code(exodusFilePtr), 1, dims.data(), &varid);
nc_flt_code(exodusFilePtr), 1, Data(dims), &varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
if (status == NC_ENAMEINUSE) {
Expand Down Expand Up @@ -824,8 +825,8 @@ template <typename INT> int Excn::Internals::put_metadata(const std::vector<Side
int bulk_type = get_type(exodusFilePtr, EX_BULK_INT64_DB);
std::array dims{dimid};
int varid = 0;
status = nc_def_var(exodusFilePtr, VAR_ELEM_SS(cur_num_side_sets + 1), bulk_type, 1,
dims.data(), &varid);
status = nc_def_var(exodusFilePtr, VAR_ELEM_SS(cur_num_side_sets + 1), bulk_type, 1, Data(dims),
&varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
if (status == NC_ENAMEINUSE) {
Expand All @@ -843,8 +844,8 @@ template <typename INT> int Excn::Internals::put_metadata(const std::vector<Side
exi_compress_variable(exodusFilePtr, varid, 1);

// create side list variable for side set
status = nc_def_var(exodusFilePtr, VAR_SIDE_SS(cur_num_side_sets + 1), bulk_type, 1,
dims.data(), &varid);
status = nc_def_var(exodusFilePtr, VAR_SIDE_SS(cur_num_side_sets + 1), bulk_type, 1, Data(dims),
&varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
if (status == NC_ENAMEINUSE) {
Expand Down Expand Up @@ -883,7 +884,7 @@ template <typename INT> int Excn::Internals::put_metadata(const std::vector<Side
// create distribution factor list variable for side set
dims[0] = dimid;
status = nc_def_var(exodusFilePtr, VAR_FACT_SS(cur_num_side_sets + 1),
nc_flt_code(exodusFilePtr), 1, dims.data(), &varid);
nc_flt_code(exodusFilePtr), 1, Data(dims), &varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
if (status == NC_ENAMEINUSE) {
Expand Down Expand Up @@ -949,7 +950,7 @@ namespace {
return EX_FATAL;
}

status = nc_put_var_int(exoid, var_id, array.data());
status = nc_put_var_int(exoid, var_id, Data(array));
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
std::string errmsg =
Expand All @@ -976,7 +977,7 @@ namespace {
int id_type = get_type(exoid, EX_IDS_INT64_API);

if (id_type == NC_INT64) {
status = nc_put_var_longlong(exoid, var_id, (long long int *)ids.data());
status = nc_put_var_longlong(exoid, var_id, (long long int *)Data(ids));
}
else {
// Have entity_id (long long), need ints...
Expand All @@ -989,7 +990,7 @@ namespace {
#ifdef _MSC_VER
#pragma warning(pop)
#endif
status = nc_put_var_int(exoid, var_id, int_ids.data());
status = nc_put_var_int(exoid, var_id, Data(int_ids));
}

if (status != NC_NOERR) {
Expand All @@ -1012,7 +1013,7 @@ namespace {
// node coordinate arrays -- separate storage...
std::array dim{node_dim};
if (dimension > 0) {
status = nc_def_var(exodusFilePtr, VAR_COORD_X, nc_flt_code(exodusFilePtr), 1, dim.data(),
status = nc_def_var(exodusFilePtr, VAR_COORD_X, nc_flt_code(exodusFilePtr), 1, Data(dim),
&varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
Expand All @@ -1025,7 +1026,7 @@ namespace {
}

if (dimension > 1) {
status = nc_def_var(exodusFilePtr, VAR_COORD_Y, nc_flt_code(exodusFilePtr), 1, dim.data(),
status = nc_def_var(exodusFilePtr, VAR_COORD_Y, nc_flt_code(exodusFilePtr), 1, Data(dim),
&varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
Expand All @@ -1038,7 +1039,7 @@ namespace {
}

if (dimension > 2) {
status = nc_def_var(exodusFilePtr, VAR_COORD_Z, nc_flt_code(exodusFilePtr), 1, dim.data(),
status = nc_def_var(exodusFilePtr, VAR_COORD_Z, nc_flt_code(exodusFilePtr), 1, Data(dim),
&varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
Expand All @@ -1053,7 +1054,7 @@ namespace {

// coordinate names array
std::array dim{dim_dim, str_dim};
status = nc_def_var(exodusFilePtr, VAR_NAME_COOR, NC_CHAR, 2, dim.data(), &varid);
status = nc_def_var(exodusFilePtr, VAR_NAME_COOR, NC_CHAR, 2, Data(dim), &varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
errmsg =
Expand Down Expand Up @@ -1090,7 +1091,7 @@ namespace {
// id status array:
std::array dim{dimid};
int varid = 0;
status = nc_def_var(exoid, stat_var, NC_INT, 1, dim.data(), &varid);
status = nc_def_var(exoid, stat_var, NC_INT, 1, Data(dim), &varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
errmsg = fmt::format("Error: failed to define side {} status in file id {}", type, exoid);
Expand All @@ -1100,7 +1101,7 @@ namespace {

// id array:
int ids_type = get_type(exoid, EX_IDS_INT64_DB);
status = nc_def_var(exoid, id_var, ids_type, 1, dim.data(), &varid);
status = nc_def_var(exoid, id_var, ids_type, 1, Data(dim), &varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
errmsg = fmt::format("Error: failed to define {} property in file id {}", type, exoid);
Expand All @@ -1119,7 +1120,7 @@ namespace {
}

std::array dims{dimid, namestrdim};
status = nc_def_var(exoid, name_var, NC_CHAR, 2, dims.data(), &varid);
status = nc_def_var(exoid, name_var, NC_CHAR, 2, Data(dims), &varid);
if (status != NC_NOERR) {
ex_opts(EX_VERBOSE);
errmsg = fmt::format("Error: failed to define {} name array in file id {}", type, exoid);
Expand Down
Loading

0 comments on commit 43ab3b3

Please sign in to comment.