diff --git a/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.C b/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.C index dc9a295fb4..6a4ec0ae30 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.C +++ b/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.C @@ -181,10 +181,8 @@ namespace Ioss { void ChangeSet::verify_change_set_index(unsigned index) const { if (index >= m_changeSetNames.size()) { - std::ostringstream errmsg; - fmt::print(errmsg, "Invalid change set index {} with a max value of {}\n", index, - m_changeSetNames.size() - 1); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("Invalid change set index {} with a max value of {}\n", index, + m_changeSetNames.size() - 1)); } } diff --git a/packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.C b/packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.C index 1fb9559f26..a40b3dd02e 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/Ioss_DatabaseIO.C @@ -202,12 +202,10 @@ namespace { int64_t zero_copy_not_enabled(const ENTITY *entity, const Ioss::Field &field, const Ioss::DatabaseIO *db) { - std::ostringstream errmsg; - fmt::print(errmsg, + IOSS_ERROR(fmt::format( "On {} {}, the field {} is specified as zero-copy enabled, but the database {} does " "not support zero-copy for this field and/or entity type.\n", - entity->type_string(), entity->name(), field.get_name(), db->get_filename()); - IOSS_ERROR(errmsg); + entity->type_string(), entity->name(), field.get_name(), db->get_filename())); } } // namespace @@ -268,12 +266,10 @@ namespace Ioss { duplicateFieldBehavior = DuplicateFieldBehavior::ERROR_; } else { - std::ostringstream errmsg; - fmt::print(errmsg, + IOSS_ERROR(fmt::format( "Invalid value ({}) for property `DUPLICATE_FIELD_NAME_BEHAVIOR`.\n" "\tValid values are `IGNORE`, `WARNING`, or `ERROR`\n", - prop); - IOSS_ERROR(errmsg); + prop)); } } else { @@ -494,10 +490,8 @@ namespace Ioss { #endif int dwret = dw_wait_file_stage(bb_file.filename().c_str()); if (dwret < 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: failed waiting for file stage `{}`: {}\n", bb_file.filename(), - std::strerror(-dwret)); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: failed waiting for file stage `{}`: {}\n", bb_file.filename(), + std::strerror(-dwret))); } #else // Used to debug DataWarp logic on systems without DataWarp... @@ -529,10 +523,8 @@ namespace Ioss { if (pending > 0) { int dwret = dw_wait_file_stage(get_dw_name().c_str()); if (dwret < 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: failed waiting for file stage `{}`: {}\n", get_dw_name(), - std::strerror(-dwret)); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: failed waiting for file stage `{}`: {}\n", get_dw_name(), + std::strerror(-dwret))); } #if IOSS_DEBUG_OUTPUT dw_query_file_stage(get_dw_name().c_str(), &complete, &pending, &deferred, &failed); @@ -554,10 +546,8 @@ namespace Ioss { fmt::print(Ioss::DebugOut(), "\nDW: END dw_stage_file_out({})\n", diff.count()); #endif if (ret < 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: file staging of `{}` to `{}` failed at close: {}\n", - get_dw_name(), get_pfs_name(), std::strerror(-ret)); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: file staging of `{}` to `{}` failed at close: {}\n", + get_dw_name(), get_pfs_name(), std::strerror(-ret))); } #else fmt::print(Ioss::DebugOut(), @@ -728,13 +718,11 @@ namespace Ioss { // the first location and the members of the group as subsequent // locations. OK to have a single member if (group_spec.size() < 2) { - std::ostringstream errmsg; - fmt::print(errmsg, + IOSS_ERROR(fmt::format( "ERROR: Invalid {} group specification '{}'\n" " Correct syntax is 'new_group,member1,...,memberN' and there must " " be at least 1 member of the group", - type_name, group); - IOSS_ERROR(errmsg); + type_name, group)); } create_group(type, type_name, group_spec, set_type); @@ -880,30 +868,24 @@ namespace Ioss { { if (!omissions.empty() && !inclusions.empty()) { // Only one can be non-empty - std::ostringstream errmsg; - fmt::print(errmsg, + IOSS_ERROR(fmt::format( "ERROR: Only one of element block omission or inclusion can be non-empty" " [{}]\n", - get_filename()); - IOSS_ERROR(errmsg); + get_filename())); } if (!assemblyOmissions.empty() && !inclusions.empty()) { - std::ostringstream errmsg; - fmt::print(errmsg, + IOSS_ERROR(fmt::format( "ERROR: Only one of element block inclusion or assembly omission can be non-empty" " [{}]\n", - get_filename()); - IOSS_ERROR(errmsg); + get_filename())); } if (!assemblyInclusions.empty() && !omissions.empty()) { - std::ostringstream errmsg; - fmt::print(errmsg, + IOSS_ERROR(fmt::format( "ERROR: Only one of element block omission or assembly inclusion can be non-empty" " [{}]\n", - get_filename()); - IOSS_ERROR(errmsg); + get_filename())); } if (!omissions.empty()) { @@ -921,30 +903,24 @@ namespace Ioss { { if (!omissions.empty() && !inclusions.empty()) { // Only one can be non-empty - std::ostringstream errmsg; - fmt::print(errmsg, + IOSS_ERROR(fmt::format( "ERROR: Only one of assembly omission or inclusion can be non-empty" " [{}]\n", - get_filename()); - IOSS_ERROR(errmsg); + get_filename())); } if (!blockOmissions.empty() && !inclusions.empty()) { - std::ostringstream errmsg; - fmt::print(errmsg, + IOSS_ERROR(fmt::format( "ERROR: Only one of element block omission or assembly inclusion can be non-empty" " [{}]\n", - get_filename()); - IOSS_ERROR(errmsg); + get_filename())); } if (!blockInclusions.empty() && !omissions.empty()) { - std::ostringstream errmsg; - fmt::print(errmsg, + IOSS_ERROR(fmt::format( "ERROR: Only one of element block inclusion or assembly omission can be non-empty" " [{}]\n", - get_filename()); - IOSS_ERROR(errmsg); + get_filename())); } if (!omissions.empty()) { @@ -1192,19 +1168,15 @@ namespace Ioss { assert(result != MPI_SUCCESS || non_zero == req_cnt); if (result != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: MPI_Irecv error on processor {} in {}", util().parallel_rank(), - __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: MPI_Irecv error on processor {} in {}", util().parallel_rank(), + __func__)); } int local_error = (MPI_SUCCESS == result) ? 0 : 1; int global_error = util().global_minmax(local_error, Ioss::ParallelUtils::DO_MAX); if (global_error != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: MPI_Irecv error on some processor in {}", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: MPI_Irecv error on some processor in {}", __func__)); } result = MPI_SUCCESS; @@ -1222,28 +1194,22 @@ namespace Ioss { assert(result != MPI_SUCCESS || non_zero == req_cnt); if (result != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: MPI_Rsend error on processor {} in {}", util().parallel_rank(), - __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: MPI_Rsend error on processor {} in {}", util().parallel_rank(), + __func__)); } local_error = (MPI_SUCCESS == result) ? 0 : 1; global_error = util().global_minmax(local_error, Ioss::ParallelUtils::DO_MAX); if (global_error != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: MPI_Rsend error on some processor in {}", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: MPI_Rsend error on some processor in {}", __func__)); } result = MPI_Waitall(req_cnt, Data(request), Data(status)); if (result != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: MPI_Waitall error on processor {} in {}", util().parallel_rank(), - __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: MPI_Waitall error on processor {} in {}", util().parallel_rank(), + __func__)); } // Unpack the data and update the inv_con arrays for boundary @@ -1455,23 +1421,15 @@ namespace Ioss { size_t block_data_size = num_to_get_for_block * field_byte_size; if (block_data_size != field.get_size()) { - std::ostringstream errmsg; - fmt::print( - errmsg, - "ERROR: Field '{}' data size {} on entity {} does not match computed size {}\n\n", - field_name, field.get_size(), entity->name(), block_data_size); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Field '{}' data size {} on entity {} does not match computed size {}\n\n", + field_name, field.get_size(), entity->name(), block_data_size)); } size_t expected_data_size = offset[i + 1] * field_byte_size; if (data_size < expected_data_size) { - std::ostringstream errmsg; - fmt::print( - errmsg, - "ERROR: Field '{}' data size {} on entity {} is less than expected size {}\n\n", - field_name, data_size, entity->name(), expected_data_size); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Field '{}' data size {} on entity {} is less than expected size {}\n\n", + field_name, data_size, entity->name(), expected_data_size)); } size_t block_data_offset = offset[i] * field_byte_size; @@ -1481,12 +1439,9 @@ namespace Ioss { size_t block_component_count = field.raw_storage()->component_count(); if (num_to_get_for_block != retval * block_component_count) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Data length {} for field {} on block {} is not expected length {}\n\n", - retval * block_component_count, field_name, entity->name(), - num_to_get_for_block); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Data length {} for field {} on block {} is not expected length {}\n\n", + retval * block_component_count, field_name, entity->name(), + num_to_get_for_block)); } if (retval >= 0) { diff --git a/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C b/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C index 5d41b9069e..970b333163 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C +++ b/packages/seacas/libraries/ioss/src/Ioss_Decomposition.C @@ -81,12 +81,9 @@ namespace { } if (!check_valid_decomp_method(method)) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Invalid decomposition method specified: '{}'\n" + IOSS_ERROR(fmt::format( "ERROR: Invalid decomposition method specified: '{}'\n" " Valid methods: {}\n", - method, fmt::join(Ioss::valid_decomp_methods(), ", ")); - IOSS_ERROR(errmsg); + method, fmt::join(Ioss::valid_decomp_methods(), ", "))); } return method; } @@ -726,12 +723,9 @@ namespace Ioss { } if (scale < 1.0) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Processor {} scaling factor is {} which is not allowed.\n" + IOSS_ERROR(fmt::format( "ERROR: Processor {} scaling factor is {} which is not allowed.\n" "\tIt must be >= 1.0. Scaling values is not possible.", - label, scale); - IOSS_ERROR(errmsg); + label, scale)); } // Do the scaling (integer division...) @@ -750,12 +744,9 @@ namespace Ioss { } } else if (max_proc >= m_processorCount) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: The element processor {} '{}' specifies a processor of {} which\n" + IOSS_ERROR(fmt::format( "ERROR: The element processor {} '{}' specifies a processor of {} which\n" "\tis not valid for a decomposition on {} processors.", - label, m_decompExtra, max_proc, m_processorCount); - IOSS_ERROR(errmsg); + label, m_decompExtra, max_proc, m_processorCount)); } // Finally... Do the decomposition... @@ -908,15 +899,11 @@ namespace Ioss { if (m_globalElementCount >= INT_MAX || m_globalNodeCount >= INT_MAX || m_pointer[m_elementCount] >= INT_MAX) { // Can't narrow... - std::ostringstream errmsg; - fmt::print( - errmsg, - "ERROR: The metis/parmetis libraries being used with this application only support\n" + IOSS_ERROR(fmt::format( "ERROR: The metis/parmetis libraries being used with this application only support\n" " 32-bit integers, but the mesh being decomposed requires 64-bit integers.\n" " You must either choose a different, non-metis decomposition method, or\n" " rebuild your metis/parmetis libraries with 64-bit integer support.\n" - " Contact gdsjaar@sandia.gov for more details.\n"); - IOSS_ERROR(errmsg); + " Contact gdsjaar@sandia.gov for more details.\n")); } else { // Should be able to narrow... @@ -1023,10 +1010,8 @@ namespace Ioss { fmt::print(Ioss::DebugOut(), "Edge Cuts = {}\n", edge_cuts); #endif if (rc != METIS_OK) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Problem during call to ParMETIS_V3_PartMeshKWay " - "decomposition\n"); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Problem during call to ParMETIS_V3_PartMeshKWay " + "decomposition\n")); } } else if (m_method == "GEOM_KWAY" || m_method == "KWAY_GEOM") { @@ -1037,10 +1022,7 @@ namespace Ioss { &dual_xadj, &dual_adjacency, &m_comm); if (rc != METIS_OK) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Problem during call to ParMETIS_V3_Mesh2Dual graph conversion\n"); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: Problem during call to ParMETIS_V3_Mesh2Dual graph conversion\n")); } if (sizeof(double) == sizeof(real_t)) { @@ -1064,10 +1046,7 @@ namespace Ioss { METIS_Free(dual_adjacency); if (rc != METIS_OK) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Problem during call to ParMETIS_V3_PartGeomKWay decomposition\n"); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: Problem during call to ParMETIS_V3_PartGeomKWay decomposition\n")); } } else if (m_method == "METIS_SFC") { @@ -1082,9 +1061,7 @@ namespace Ioss { } if (rc != METIS_OK) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Problem during call to ParMETIS_V3_PartGeom decomposition\n"); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Problem during call to ParMETIS_V3_PartGeom decomposition\n")); } } m_centroids.clear(); @@ -1106,13 +1083,10 @@ namespace Ioss { int lib_global_id_type_size = Zoltan_get_global_id_type(nullptr); if (lib_global_id_type_size != sizeof(ZOLTAN_ID_TYPE)) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: The compile-time ZOLTAN_ID_TYPE size ({}) does not match the run-time " + IOSS_ERROR(fmt::format( "ERROR: The compile-time ZOLTAN_ID_TYPE size ({}) does not match the run-time " "ZOLTAN_ID_TYPE size ({}). There is an error in the build/link procedure for this " "application.\n", - sizeof(ZOLTAN_ID_TYPE), lib_global_id_type_size); - IOSS_ERROR(errmsg); + sizeof(ZOLTAN_ID_TYPE), lib_global_id_type_size)); } zz.Set_Param("NUM_GID_ENTRIES", std::to_string(num_global)); @@ -1141,9 +1115,7 @@ namespace Ioss { export_global_ids, export_local_ids, export_procs, export_to_part); if (rc != ZOLTAN_OK) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Problem during call to Zoltan LB_Partition.\n"); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Problem during call to Zoltan LB_Partition.\n")); } show_progress("\tZoltan lb_partition finished"); @@ -1166,9 +1138,7 @@ namespace Ioss { if (num_global == 1) { if (num_export > 0 && export_procs == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Internal error in zoltan_decompose. export_procs is null.\n"); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Internal error in zoltan_decompose. export_procs is null.\n")); } std::vector> export_map; @@ -1193,9 +1163,7 @@ namespace Ioss { } else { if (num_export > 0 && export_procs == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Internal error in zoltan_decompose. export_procs is null.\n"); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Internal error in zoltan_decompose. export_procs is null.\n")); } std::vector> export_map; export_map.reserve(num_export); diff --git a/packages/seacas/libraries/ioss/src/Ioss_GroupingEntity.C b/packages/seacas/libraries/ioss/src/Ioss_GroupingEntity.C index 0050e99304..e942cc0a77 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_GroupingEntity.C +++ b/packages/seacas/libraries/ioss/src/Ioss_GroupingEntity.C @@ -163,10 +163,8 @@ Ioss::Property Ioss::GroupingEntity::get_implicit_property(const std::string &my } // End of the line. No property of this name exists. - std::ostringstream errmsg; - fmt::print(errmsg, "\nERROR: Property '{}' does not exist on {} {}\n\n", my_name, type_string(), - name()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("\nERROR: Property '{}' does not exist on {} {}\n\n", my_name, type_string(), + name())); } bool Ioss::GroupingEntity::check_for_duplicate(const Ioss::Field &new_field) const @@ -230,13 +228,10 @@ void Ioss::GroupingEntity::field_add(Ioss::Field new_field) } else if (entity_size != field_size && type() != REGION) { std::string filename = get_database()->get_filename(); - std::ostringstream errmsg; - fmt::print(errmsg, - "IO System error: The {} '{}' has a size of {},\nbut the field '{}' which is being " + IOSS_ERROR(fmt::format( "IO System error: The {} '{}' has a size of {},\nbut the field '{}' which is being " "output on that entity has a size of {}\non database '{}'.\nThe sizes must match. " "This is an application error that should be reported.", - type_string(), name(), entity_size, new_field.get_name(), field_size, filename); - IOSS_ERROR(errmsg); + type_string(), name(), entity_size, new_field.get_name(), field_size, filename)); } if (!check_for_duplicate(new_field)) { fields.add(new_field); @@ -349,10 +344,8 @@ void Ioss::GroupingEntity::verify_field_exists(const std::string &field_name, { if (!field_exists(field_name)) { std::string filename = get_database()->get_filename(); - std::ostringstream errmsg; - fmt::print(errmsg, "\nERROR: On database '{}', Field '{}' does not exist for {} on {} {}\n\n", - filename, field_name, inout, type_string(), name()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("\nERROR: On database '{}', Field '{}' does not exist for {} on {} {}\n\n", + filename, field_name, inout, type_string(), name())); } } diff --git a/packages/seacas/libraries/ioss/src/Ioss_ParallelUtils.C b/packages/seacas/libraries/ioss/src/Ioss_ParallelUtils.C index 02fe4dd06a..d06577d714 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_ParallelUtils.C +++ b/packages/seacas/libraries/ioss/src/Ioss_ParallelUtils.C @@ -61,13 +61,10 @@ void Ioss::ParallelUtils::add_environment_properties(Ioss::PropertyManager &prop for (auto &elem : prop_val) { Ioss::NameList property = tokenize(elem, "="); if (property.size() != 2) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "ERROR: Invalid property specification found in IOSS_PROPERTIES environment variable\n" " Found '{}' which is not of the correct PROPERTY=VALUE form", - elem); - IOSS_ERROR(errmsg); + elem)); } std::string prop = Utils::uppercase(property[0]); std::string value = property[1]; @@ -290,9 +287,7 @@ void Ioss::ParallelUtils::attribute_reduction(IOSS_MAYBE_UNUSED const int length const int success = MPI_Allreduce(buffer, Data(recv_buf), length, MPI_BYTE, MPI_BOR, communicator_); if (MPI_SUCCESS != success) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Allreduce failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Allreduce failed", __func__)); } std::memcpy(buffer, Data(recv_buf), length); @@ -318,18 +313,14 @@ void Ioss::ParallelUtils::global_count(const IntVector &local_counts, #ifdef SEACAS_HAVE_MPI if (!local_counts.empty() && parallel_size() > 1) { if (Ioss::SerializeIO::isEnabled() && Ioss::SerializeIO::inBarrier()) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - Attempting mpi while in barrier owned by {}", __func__, - Ioss::SerializeIO::getOwner()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - Attempting mpi while in barrier owned by {}", __func__, + Ioss::SerializeIO::getOwner())); } const int success = MPI_Allreduce((void *)Data(local_counts), Data(global_counts), static_cast(local_counts.size()), MPI_INT, MPI_SUM, communicator_); if (success != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Allreduce failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Allreduce failed", __func__)); } } else { @@ -352,18 +343,14 @@ void Ioss::ParallelUtils::global_count(const Int64Vector &local_counts, #ifdef SEACAS_HAVE_MPI if (!local_counts.empty() && parallel_size() > 1) { if (Ioss::SerializeIO::isEnabled() && Ioss::SerializeIO::inBarrier()) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - Attempting mpi while in barrier owned by {}", __func__, - Ioss::SerializeIO::getOwner()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - Attempting mpi while in barrier owned by {}", __func__, + Ioss::SerializeIO::getOwner())); } const int success = MPI_Allreduce((void *)Data(local_counts), Data(global_counts), static_cast(local_counts.size()), MPI_LONG_LONG_INT, MPI_SUM, communicator_); if (success != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Allreduce failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Allreduce failed", __func__)); } } else { @@ -394,10 +381,8 @@ T Ioss::ParallelUtils::global_minmax(T local_minmax, #ifdef SEACAS_HAVE_MPI if (parallel_size() > 1) { if (Ioss::SerializeIO::isEnabled() && Ioss::SerializeIO::inBarrier()) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - Attempting mpi while in barrier owned by {}", __func__, - Ioss::SerializeIO::getOwner()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - Attempting mpi while in barrier owned by {}", __func__, + Ioss::SerializeIO::getOwner())); } static T inbuf[1], outbuf[1]; inbuf[0] = local_minmax; @@ -407,9 +392,7 @@ T Ioss::ParallelUtils::global_minmax(T local_minmax, const int success = MPI_Allreduce((void *)&inbuf[0], &outbuf[0], 1, mpi_type(T()), oper, communicator_); if (success != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Allreduce failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Allreduce failed", __func__)); } minmax = outbuf[0]; } @@ -436,9 +419,7 @@ namespace Ioss { const int success = MPI_Bcast(const_cast(my_str.data()), (int)my_str.size() + 1, MPI_CHAR, root, communicator_); if (success != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Broadcast failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Broadcast failed", __func__)); } } #endif @@ -454,9 +435,7 @@ void Ioss::ParallelUtils::broadcast(IOSS_MAYBE_UNUSED T &my_value, IOSS_MAYBE_UN if (parallel_size() > 1) { const int success = MPI_Bcast((void *)&my_value, 1, mpi_type(T()), root, communicator_); if (success != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Broadcast failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Broadcast failed", __func__)); } } #endif @@ -486,9 +465,7 @@ namespace Ioss { const int success = MPI_Bcast(Data(my_value), (int)my_value.size() * 2, mpi_type(int(0)), root, communicator_); if (success != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Broadcast failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Broadcast failed", __func__)); } } #endif @@ -506,9 +483,7 @@ void Ioss::ParallelUtils::broadcast(IOSS_MAYBE_UNUSED std::vector &my_value, const int success = MPI_Bcast(Data(my_value), (int)my_value.size(), mpi_type(T()), root, communicator_); if (success != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Broadcast failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Broadcast failed", __func__)); } } #endif @@ -541,9 +516,7 @@ template void Ioss::ParallelUtils::gather(T my_value, std::vector void Ioss::ParallelUtils::all_gather(T my_value, std::vect const int success = MPI_Allgather((void *)&my_value, 1, mpi_type(T()), (void *)Data(result), 1, mpi_type(T()), communicator_); if (success != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Allgather failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Allgather failed", __func__)); } } else { @@ -585,9 +556,7 @@ void Ioss::ParallelUtils::all_gather(std::vector &my_values, std::vector & MPI_Allgather(Data(my_values), my_values.size(), mpi_type(T()), (void *)Data(result), my_values.size(), mpi_type(T()), communicator_); if (success != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Allgather failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Allgather failed", __func__)); } } else { @@ -631,9 +600,7 @@ void Ioss::ParallelUtils::gather(std::vector &my_values, std::vector &resu const int success = MPI_Gather((void *)Data(my_values), count, mpi_type(T()), (void *)Data(result), count, mpi_type(T()), 0, communicator_); if (success != MPI_SUCCESS) { - std::ostringstream errmsg; - fmt::print(errmsg, "{} - MPI_Gather failed", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{} - MPI_Gather failed", __func__)); } } else { diff --git a/packages/seacas/libraries/ioss/src/Ioss_Region.C b/packages/seacas/libraries/ioss/src/Ioss_Region.C index c6327ecf98..84897db84b 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Region.C +++ b/packages/seacas/libraries/ioss/src/Ioss_Region.C @@ -748,17 +748,13 @@ namespace Ioss { // For the invalid transitions; provide a more meaningful // message in certain cases... case STATE_READONLY: { - std::ostringstream errmsg; - fmt::print(errmsg, "Cannot change state of an input (readonly) database in {}", - get_database()->get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("Cannot change state of an input (readonly) database in {}", + get_database()->get_filename())); } default: { - std::ostringstream errmsg; - fmt::print(errmsg, "Invalid nesting of begin/end pairs in {}", - get_database()->get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("Invalid nesting of begin/end pairs in {}", + get_database()->get_filename())); } } } @@ -791,12 +787,9 @@ namespace Ioss { // Check that 'current_state' matches the current state of the // Region (that is, we are leaving the state we are in). if (get_state() != current_state) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Specified end state does not match currently open state\n" - " [{}]\n", - get_database()->get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Specified end state does not match currently open state\n" + " [{}]\n", + get_database()->get_filename())); } if (current_state == STATE_DEFINE_MODEL) { @@ -859,11 +852,9 @@ namespace Ioss { if (check_consistency) { bool ok = check_parallel_consistency(*this); if (!ok) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Parallel Consistency Failure for {} database '{}'.", + IOSS_ERROR(fmt::format("ERROR: Parallel Consistency Failure for {} database '{}'.", (get_database()->is_input() ? "input" : "output"), - get_database()->get_filename()); - IOSS_ERROR(errmsg); + get_database()->get_filename())); } } @@ -946,10 +937,8 @@ namespace Ioss { if (get_database()->is_input() || get_database()->usage() == WRITE_RESULTS || get_database()->usage() == WRITE_RESTART) { if (currentState == -1) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: No currently active state.\n [{}]\n", - get_database()->get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: No currently active state.\n [{}]\n", + get_database()->get_filename())); } else { SMART_ASSERT((int)stateTimes.size() >= currentState)(stateTimes.size())(currentState); @@ -962,12 +951,9 @@ namespace Ioss { } } else if (state <= 0 || state > stateCount) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Requested state ({}) is invalid. State must be between 1 and {}.\n" + IOSS_ERROR(fmt::format("ERROR: Requested state ({}) is invalid. State must be between 1 and {}.\n" " [{}]\n", - state, stateCount, get_database()->get_filename()); - IOSS_ERROR(errmsg); + state, stateCount, get_database()->get_filename())); } else { if (get_database()->is_input() || get_database()->usage() == WRITE_RESULTS || @@ -1058,26 +1044,18 @@ namespace Ioss { { double time = 0.0; if (get_database()->is_input() && stateCount == 0) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: There are no states (time steps) on the input database.\n" + IOSS_ERROR(fmt::format( "ERROR: There are no states (time steps) on the input database.\n" " [{}]\n", - get_database()->get_filename()); - IOSS_ERROR(errmsg); + get_database()->get_filename())); } if (state <= 0 || state > stateCount) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Requested state ({}) is invalid. State must be between 1 and {}.\n" + IOSS_ERROR(fmt::format( "ERROR: Requested state ({}) is invalid. State must be between 1 and {}.\n" " [{}]\n", - state, stateCount, get_database()->get_filename()); - IOSS_ERROR(errmsg); + state, stateCount, get_database()->get_filename())); } else if (currentState != -1 && !get_database()->is_input()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: State {} was not ended. Can not begin new state.\n [{}]\n", - currentState, get_database()->get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: State {} was not ended. Can not begin new state.\n [{}]\n", + currentState, get_database()->get_filename())); } else { { @@ -1112,12 +1090,9 @@ namespace Ioss { double Region::end_state(int state) { if (state != currentState) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: The current database state ({}) does not match the ending state ({}).\n" + IOSS_ERROR(fmt::format( "ERROR: The current database state ({}) does not match the ending state ({}).\n" " [{}]\n", - currentState, state, get_database()->get_filename()); - IOSS_ERROR(errmsg); + currentState, state, get_database()->get_filename())); } DatabaseIO *db = get_database(); double time = 0.0; @@ -1699,13 +1674,10 @@ namespace Ioss { (ge->type() == SIDEBLOCK && old_ge->type() == SIDESET))) { auto old_id = old_ge->get_optional_property(id_str(), -1); auto new_id = ge->get_optional_property(id_str(), -1); - std::ostringstream errmsg; - fmt::print(errmsg, - "\n\nERROR: Duplicate names detected.\n" + IOSS_ERROR(fmt::format("\n\nERROR: Duplicate names detected.\n" " The name '{}' was found for both {} {} and {} {}.\n" " Names must be unique over all types in a finite element model.\n\n", - db_name, old_ge->type_string(), old_id, ge->type_string(), new_id); - IOSS_ERROR(errmsg); + db_name, old_ge->type_string(), old_id, ge->type_string(), new_id)); } } } @@ -1757,13 +1729,10 @@ namespace Ioss { std::tie(std::ignore, result) = aliases_[type].insert(std::make_pair(alias, canon)); return result; } - std::ostringstream errmsg; - fmt::print(errmsg, - "\n\nERROR: The entity named '{}' of type {} which is being aliased to '{}' does " + IOSS_ERROR(fmt::format( "\n\nERROR: The entity named '{}' of type {} which is being aliased to '{}' does " "not exist in " "region '{}'.\n", - db_name, static_cast(type), alias, name()); - IOSS_ERROR(errmsg); + db_name, static_cast(type), alias, name())); } bool Region::add_alias(const std::string &db_name, const std::string &alias) @@ -1974,16 +1943,12 @@ namespace Ioss { } if (nfound > 1) { std::string filename = get_database()->get_filename(); - std::ostringstream errmsg; - fmt::print( - errmsg, - "ERROR: There are multiple ({}) blocks, sets, assemblies and/or blobs with the name '{}' " + IOSS_ERROR(fmt::format("ERROR: There are multiple ({}) blocks, sets, assemblies and/or blobs with the name '{}' " "defined in the " "database file '{}'.\n" "\tThis is allowed in general, but this application uses an API function (get_entity) " "that does not support duplicate names.", - nfound, my_name, filename); - IOSS_ERROR(errmsg); + nfound, my_name, filename)); } return entity; } @@ -2330,9 +2295,7 @@ namespace Ioss { return coor_frame; } } - std::ostringstream errmsg; - fmt::print(errmsg, "Error: Invalid id {} specified for coordinate frame.", id); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("Error: Invalid id {} specified for coordinate frame.", id)); } /** \brief Determine whether the entity with the given name and type exists. @@ -2449,12 +2412,9 @@ namespace Ioss { } } // Should not reach this point... - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: In Ioss::Region::get_element_block, an invalid local_id of {} is specified. " + IOSS_ERROR(fmt::format( "ERROR: In Ioss::Region::get_element_block, an invalid local_id of {} is specified. " " The valid range is 1 to {}", - local_id, get_implicit_property("element_count").get_int()); - IOSS_ERROR(errmsg); + local_id, get_implicit_property("element_count").get_int())); } /** \brief Get the structured block containing a specified global-offset-node. @@ -2472,12 +2432,9 @@ namespace Ioss { } } // Should not reach this point... - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: In Ioss::Region::get_structured_block, an invalid global_offset of {} is " + IOSS_ERROR(fmt::format( "ERROR: In Ioss::Region::get_structured_block, an invalid global_offset of {} is " "specified.", - global_offset); - IOSS_ERROR(errmsg); + global_offset)); } /** \brief Get an implicit property -- These are calculated from data stored @@ -2704,12 +2661,9 @@ namespace Ioss { // Get the entity from this region... Must be non-nullptr GroupingEntity *this_ge = get_entity(base); if (this_ge == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, - "INTERNAL ERROR: Could not find entity '{}' in synchronize_id_and_name() " + IOSS_ERROR(fmt::format( "INTERNAL ERROR: Could not find entity '{}' in synchronize_id_and_name() " " [{}]\n", - base, get_database()->get_filename()); - IOSS_ERROR(errmsg); + base, get_database()->get_filename())); } // See if there is an 'id' property... @@ -2812,14 +2766,11 @@ namespace Ioss { std::string filename = get_database()->get_filename(); int64_t id1 = entity->get_optional_property(id_str(), 0); int64_t id2 = old_ge->get_optional_property(id_str(), 0); - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: There are multiple blocks, sets, assemblies, and/or blobs with the same " + IOSS_ERROR(fmt::format( "ERROR: There are multiple blocks, sets, assemblies, and/or blobs with the same " "name defined in the " "database file '{}'.\n" "\tBoth {} {} and {} {} are named '{}'. All names must be unique.", - filename, entity->type_string(), id1, old_ge->type_string(), id2, name); - IOSS_ERROR(errmsg); + filename, entity->type_string(), id1, old_ge->type_string(), id2, name)); } } } @@ -2831,10 +2782,8 @@ namespace Ioss { if (observer->get_control_option() == FileControlOption::CONTROL_AUTO_GROUP_FILE) { const Ioss::PropertyManager &db_properties = get_database()->get_property_manager(); if (!db_properties.exists("ENABLE_FILE_GROUPS")) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: File groups are not enabled in the database file '{}'.\n", - get_database()->get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: File groups are not enabled in the database file '{}'.\n", + get_database()->get_filename())); } } @@ -2868,19 +2817,14 @@ namespace Ioss { const Ioss::PropertyManager &db_properties = get_database()->get_property_manager(); if (!db_properties.exists("ENABLE_FILE_GROUPS")) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: File groups are not enabled in the database file '{}'.\n", - get_database()->get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: File groups are not enabled in the database file '{}'.\n", + get_database()->get_filename())); } if (topologyObserver && (topologyObserver->get_control_option() == FileControlOption::CONTROL_AUTO_MULTI_FILE)) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: TopologyObserver for database file '{}' does not support file groups.\n", - get_database()->get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: TopologyObserver for database file '{}' does not support file groups.\n", + get_database()->get_filename())); } int state = steps; diff --git a/packages/seacas/libraries/ioss/src/Ioss_Utils.h b/packages/seacas/libraries/ioss/src/Ioss_Utils.h index e13b43dc25..2a017feedc 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_Utils.h +++ b/packages/seacas/libraries/ioss/src/Ioss_Utils.h @@ -40,6 +40,11 @@ namespace Ioss { throw std::runtime_error((errmsg).str()); } +[[noreturn]] inline void IOSS_ERROR(const std::string &errmsg) +{ + throw std::runtime_error(errmsg); +} + #ifdef NDEBUG #define IOSS_ASSERT_USED(x) (void)x #else diff --git a/packages/seacas/libraries/ioss/src/cgns/Iocgns_DatabaseIO.C b/packages/seacas/libraries/ioss/src/cgns/Iocgns_DatabaseIO.C index edbf32ad24..2654ef6ba5 100644 --- a/packages/seacas/libraries/ioss/src/cgns/Iocgns_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/cgns/Iocgns_DatabaseIO.C @@ -334,17 +334,14 @@ namespace { br = adjacent_block(blocks[br], ijk + 3, proc_block_map); if (++iter > end - begin) { auto bp = adjacent_block(blocks[br], ijk + 3, proc_block_map); - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Block '{}' is in infinite loop calculating processor " + IOSS_ERROR(fmt::format( "ERROR: CGNS: Block '{}' is in infinite loop calculating processor " "adjacencies for direction " "'{}' on processors {} and {}. Check decomposition.", blocks[bb].name, (ijk == 0 ? 'i' : ijk == 1 ? 'j' : 'k'), - blocks[bp].proc, blocks[br].proc); - IOSS_ERROR(errmsg); + blocks[bp].proc, blocks[br].proc)); } } while (br >= 0); break; @@ -1175,12 +1172,9 @@ namespace Iocgns { std::string zname = name_proc.first; int proc = name_proc.second; if (proc != myProcessor) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Zone {} has a name that specifies it should be on processor {}, but " + IOSS_ERROR(fmt::format( "ERROR: CGNS: Zone {} has a name that specifies it should be on processor {}, but " "it is actually on processor {}", - zone, proc, myProcessor); - IOSS_ERROR(errmsg); + zone, proc, myProcessor)); } m_zoneNameMap[zname] = zone; @@ -1360,23 +1354,17 @@ namespace Iocgns { if (connect_type != CGNS_ENUMV(Abutting1to1) || ptset_type != CGNS_ENUMV(PointList) || donor_ptset_type != CGNS_ENUMV(PointListDonor)) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Zone {} adjacency data is not correct type. Require " + IOSS_ERROR(fmt::format( "ERROR: CGNS: Zone {} adjacency data is not correct type. Require " "Abutting1to1 and PointList." " {}\t{}\t{}", zone, static_cast(connect_type), static_cast(ptset_type), - static_cast(donor_ptset_type)); - IOSS_ERROR(errmsg); + static_cast(donor_ptset_type))); } // Verify data consistency... if (npnts != ndata_donor) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Zone {} point count ({}) does not match donor point count ({}).", - zone, npnts, ndata_donor); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: CGNS: Zone {} point count ({}) does not match donor point count ({}).", + zone, npnts, ndata_donor)); } // Get number of nodes shared with other "previous" zones... @@ -1536,11 +1524,7 @@ namespace Iocgns { int n_bases = 0; CGCHECKM(cg_nbases(get_file_pointer(), &n_bases)); if (n_bases != 1) { - std::ostringstream errmsg; - fmt::print( - errmsg, - "ERROR: CGNS: Too many bases; only support files with a single bases at this time"); - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: CGNS: Too many bases; only support files with a single bases at this time"); } get_step_times_nl(); @@ -1589,12 +1573,9 @@ namespace Iocgns { } #endif else { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Zone {} is not of type Unstructured or Structured " + IOSS_ERROR(fmt::format( "ERROR: CGNS: Zone {} is not of type Unstructured or Structured " "which are the only types currently supported", - zone); - IOSS_ERROR(errmsg); + zone)); } } } @@ -1608,10 +1589,8 @@ namespace Iocgns { int phys_dimension = 0; CGCHECKM(cg_base_read(get_file_pointer(), base, basename, &cell_dimension, &phys_dimension)); if (phys_dimension != 3 && mesh_type == Ioss::MeshType::STRUCTURED) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: The model is {}D. Only 3D structured models are supported.", - phys_dimension); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: The model is {}D. Only 3D structured models are supported.", + phys_dimension)); } auto *nblock = new Ioss::NodeBlock(this, "nodeblock_1", num_node, phys_dimension); @@ -2421,9 +2400,7 @@ namespace Iocgns { if (num_to_get > 0) { int64_t entity_count = sb->entity_count(); if (num_to_get != entity_count) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Partial field input not yet implemented for side blocks"); - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: Partial field input not yet implemented for side blocks"); } } @@ -2498,12 +2475,9 @@ namespace Iocgns { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Could not find face with connectivity {} {} {} {} on " + IOSS_ERROR(fmt::format( "ERROR: CGNS: Could not find face with connectivity {} {} {} {} on " "sideblock {} with parent {}.", - conn[0], conn[1], conn[2], conn[3], sb->name(), name); - IOSS_ERROR(errmsg); + conn[0], conn[1], conn[2], conn[3], sb->name(), name)); } } } @@ -2862,11 +2836,8 @@ namespace Iocgns { // prior to outputting nodal coordinates. for (const auto &z : m_globalToBlockLocalNodeMap) { if (z.second == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: The globalToBlockLocalNodeMap is not defined, so nodal fields " + IOSS_ERROR( "ERROR: CGNS: The globalToBlockLocalNodeMap is not defined, so nodal fields " "cannot be output."); - IOSS_ERROR(errmsg); } } @@ -3094,12 +3065,9 @@ namespace Iocgns { { const Ioss::EntityBlock *parent_block = sb->parent_block(); if (parent_block == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: SideBlock '{}' does not have a parent-block specified. This is " + IOSS_ERROR(fmt::format( "ERROR: CGNS: SideBlock '{}' does not have a parent-block specified. This is " "required for CGNS output.", - sb->name()); - IOSS_ERROR(errmsg); + sb->name())); } int base = parent_block->get_property("base").get_int(); diff --git a/packages/seacas/libraries/ioss/src/cgns/Iocgns_DecompositionData.C b/packages/seacas/libraries/ioss/src/cgns/Iocgns_DecompositionData.C index 6f76fa7849..69a64d1428 100644 --- a/packages/seacas/libraries/ioss/src/cgns/Iocgns_DecompositionData.C +++ b/packages/seacas/libraries/ioss/src/cgns/Iocgns_DecompositionData.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2023 National Technology & Engineering Solutions +// Copyright(C) 1999-2024 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. // @@ -220,17 +220,13 @@ namespace Iocgns { } #if IOSS_ENABLE_HYBRID else if (mesh_type == Ioss::MeshType::HYBRID) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: CGNS: The mesh type is HYBRID which is not supported for parallel " + IOSS_ERROR("ERROR: CGNS: The mesh type is HYBRID which is not supported for parallel " "decomposition yet."); - IOSS_ERROR(errmsg); } #endif else { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: CGNS: The mesh type is not Unstructured or Structured " + IOSS_ERROR("ERROR: CGNS: The mesh type is not Unstructured or Structured " "which are the only types currently supported"); - IOSS_ERROR(errmsg); } } @@ -396,12 +392,9 @@ namespace Iocgns { } if (global_element_count < (size_t)m_decomposition.m_processorCount) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Element Count ({}) is less than Processor Count ({}). No " + IOSS_ERROR(fmt::format( "ERROR: CGNS: Element Count ({}) is less than Processor Count ({}). No " "decomposition possible.", - global_element_count, m_decomposition.m_processorCount); - IOSS_ERROR(errmsg); + global_element_count, m_decomposition.m_processorCount)); } // Generate element_dist/node_dist -- size m_decomposition.m_processorCount + 1 @@ -527,21 +520,15 @@ namespace Iocgns { if (connect_type != CGNS_ENUMV(Abutting1to1) || ptset_type != CGNS_ENUMV(PointList) || donor_ptset_type != CGNS_ENUMV(PointListDonor)) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Zone {} adjacency data is not correct type. Require " + IOSS_ERROR(fmt::format( "ERROR: CGNS: Zone {} adjacency data is not correct type. Require " "Abutting1to1 and PointList. {}\t{}\t{}", - zone, connect_type, ptset_type, donor_ptset_type); - IOSS_ERROR(errmsg); + zone, connect_type, ptset_type, donor_ptset_type)); } // Verify data consistency... if (npnts != ndata_donor) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Zone {} point count ({}) does not match donor point count ({}).", - zone, npnts, ndata_donor); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: CGNS: Zone {} point count ({}) does not match donor point count ({}).", + zone, npnts, ndata_donor)); } // Get number of nodes shared with other "previous" zones... @@ -732,14 +719,11 @@ namespace Iocgns { // Make sure 'sum' can fit in INT... INT tmp_sum = (INT)sum; if ((size_t)tmp_sum != sum) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR( "ERROR: The decomposition of this mesh requires 64-bit integers, but is being\n" " run with 32-bit integer code. Please rerun with the property INTEGER_SIZE_API\n" " set to 8. The details of how to do this vary with the code that is being run.\n" " Contact gdsjaar@sandia.gov for more details.\n"); - IOSS_ERROR(errmsg); } // Now, populate the vectors... @@ -1137,12 +1121,9 @@ namespace Iocgns { ioss_data[j++] = fid % 10 + 1; } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Could not find face with connectivity {} {} {} {} on " + IOSS_ERROR(fmt::format( "ERROR: CGNS: Could not find face with connectivity {} {} {} {} on " "sideblock {}.", - conn[0], conn[1], conn[2], conn[3], sset.name()); - IOSS_ERROR(errmsg); + conn[0], conn[1], conn[2], conn[3], sset.name())); } } } diff --git a/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C b/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C index 2af15c79ba..6f45e95fc3 100644 --- a/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C +++ b/packages/seacas/libraries/ioss/src/cgns/Iocgns_Utils.C @@ -530,12 +530,9 @@ Ioss::MeshType Iocgns::Utils::check_mesh_type(int cgns_file_ptr) common_zone_type = CGNS_ENUMV(ZoneTypeUserDefined); // This is how we represent hybrid... break; #else - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Zone {} is not the same zone type as previous zones." + IOSS_ERROR(fmt::format( "ERROR: CGNS: Zone {} is not the same zone type as previous zones." " This is currently not allowed or supported (hybrid mesh).", - zone); - IOSS_ERROR(errmsg); + zone)); #endif } } @@ -581,12 +578,9 @@ void Iocgns::Utils::update_db_zone_property(int cgns_file_ptr, const Ioss::Regio block->property_update("db_zone", db_zone); } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Structured Block '{}' was not found on the CGNS database on " + IOSS_ERROR(fmt::format( "ERROR: CGNS: Structured Block '{}' was not found on the CGNS database on " "processor {}.", - name, myProcessor); - IOSS_ERROR(errmsg); + name, myProcessor)); } } } @@ -600,12 +594,9 @@ void Iocgns::Utils::update_db_zone_property(int cgns_file_ptr, const Ioss::Regio block->property_update("db_zone", db_zone); } else { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "ERROR: CGNS: Element Block '{}' was not found on the CGNS database on processor {}.", - name, myProcessor); - IOSS_ERROR(errmsg); + name, myProcessor)); } } } @@ -621,11 +612,8 @@ int Iocgns::Utils::get_db_zone(const Ioss::GroupingEntity *entity) if (entity->property_exists("zone")) { return entity->get_property("zone").get_int(); } - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Entity '{}' of type '{}' does not have the 'zone' property assigned.", - entity->name(), entity->type_string()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: CGNS: Entity '{}' of type '{}' does not have the 'zone' property assigned.", + entity->name(), entity->type_string())); } namespace { @@ -843,12 +831,9 @@ namespace { } else { // We have a bad zgc -- name and owner_zone match, but not donor_zone. - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Found zgc named '{}' on zone {} which has two different " + IOSS_ERROR(fmt::format( "ERROR: CGNS: Found zgc named '{}' on zone {} which has two different " "donor zones: {} and {}\n", - zgc[i].m_connectionName, owner_zone, donor_zone, zgc[j].m_donorZone); - IOSS_ERROR(errmsg); + zgc[i].m_connectionName, owner_zone, donor_zone, zgc[j].m_donorZone)); } } } @@ -1014,12 +999,9 @@ void Iocgns::Utils::write_state_meta_data(int file_ptr, const Ioss::Region ®i CGERR(cg_zone_write(file_ptr, base, name.c_str(), size, CGNS_ENUMV(Unstructured), &db_zone)); int prev_db_zone = get_db_zone(eb); if (db_zone != prev_db_zone) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "ERROR: CGNS: The 'db_zone' does not match in the state file {} and the base file {}.", - db_zone, prev_db_zone); - IOSS_ERROR(errmsg); + db_zone, prev_db_zone)); } } @@ -1054,12 +1036,9 @@ void Iocgns::Utils::write_state_meta_data(int file_ptr, const Ioss::Region ®i int db_zone = 0; CGERR(cg_zone_write(file_ptr, base, name.c_str(), size, CGNS_ENUMV(Structured), &db_zone)); if (db_zone != sb->get_property("db_zone").get_int()) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "ERROR: CGNS: The 'db_zone' does not match in the state file {} and the base file {}.", - db_zone, sb->get_property("db_zone").get_int()); - IOSS_ERROR(errmsg); + db_zone, sb->get_property("db_zone").get_int())); } } } @@ -1071,12 +1050,9 @@ size_t Iocgns::Utils::common_write_metadata(int file_ptr, const Ioss::Region &re #if !IOSS_ENABLE_HYBRID // Make sure mesh is not hybrid... if (region.mesh_type() == Ioss::MeshType::HYBRID) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: The mesh on region '{}' is of type 'hybrid'." + IOSS_ERROR(fmt::format( "ERROR: CGNS: The mesh on region '{}' is of type 'hybrid'." " This is currently not allowed or supported.", - region.name()); - IOSS_ERROR(errmsg); + region.name())); } #endif @@ -1379,11 +1355,8 @@ size_t Iocgns::Utils::common_write_metadata(int file_ptr, const Ioss::Region &re } } if (connect_name == zgc.m_connectionName) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Duplicate ZGC Name '{}' on zone '{}', processor {}\n", - zgc.m_connectionName, sb->name(), zgc.m_ownerProcessor); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: CGNS: Duplicate ZGC Name '{}' on zone '{}', processor {}\n", + zgc.m_connectionName, sb->name(), zgc.m_ownerProcessor)); } } } @@ -2327,11 +2300,8 @@ void Iocgns::Utils::add_transient_variables(int cgns_file_ptr, const std::vector : region->get_node_blocks()[0]; auto *nb = const_cast(cnb); if (nb == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: CGNS: Null entity accessing nodeblock for structured block {}.", - block->name()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: CGNS: Null entity accessing nodeblock for structured block {}.", + block->name())); } size_t entity_count = nb->entity_count(); Ioss::Utils::get_fields(entity_count, field_names, Ioss::Field::TRANSIENT, @@ -2543,10 +2513,8 @@ void Iocgns::Utils::decompose_model(std::vector &z } if (avg_work < 1.0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Model size too small to distribute over {} processors.\n", - proc_count); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Model size too small to distribute over {} processors.\n", + proc_count)); } if (verbose) { @@ -2672,11 +2640,8 @@ void Iocgns::Utils::assign_zones_to_procs(std::vector= work_vector.size()); size_t i = 0; @@ -2717,15 +2682,11 @@ void Iocgns::Utils::assign_zones_to_procs(std::vectorwork(); } else { - std::ostringstream errmsg; - fmt::print(errmsg, "IOCGNS error: Could not assign zones to processors in {}", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("IOCGNS error: Could not assign zones to processors in {}", __func__)); } } else { - std::ostringstream errmsg; - fmt::print(errmsg, "IOCGNS error: Could not assign zones to processors in {}", __func__); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("IOCGNS error: Could not assign zones to processors in {}", __func__)); } } } @@ -2981,13 +2942,10 @@ std::vector Iocgns::Utils::parse_zonebc_sideblocks(int cgns_file &num_pnts, nullptr, &normal_list_size, &normal_data_type, &num_dataset)); if (num_pnts != 2 || ptset_type != CGNS_ENUMV(PointRange)) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "CGNS: In Zone {}, boundary condition '{}' has a PointSetType of '{}' and {} points.\n" " The type must be 'PointRange' and there must be 2 points.", - zone, boco_name, cg_PointSetTypeName(ptset_type), num_pnts); - IOSS_ERROR(errmsg); + zone, boco_name, cg_PointSetTypeName(ptset_type), num_pnts)); } std::array point_range; diff --git a/packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.C b/packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.C index f206f73b25..30b53b04f2 100644 --- a/packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/exodus/Ioex_BaseDatabaseIO.C @@ -135,10 +135,8 @@ namespace { } if (!found) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find sub-assembly with id: {} and name: {}", - assembly.id, assembly.name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find sub-assembly with id: {} and name: {}", + assembly.id, assembly.name)); } } } @@ -534,9 +532,7 @@ namespace Ioex { int64_t format = ex_inquire_int(exoid, EX_INQ_FILE_FORMAT); if (format < 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not query file format for file '{}'.\n", get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not query file format for file '{}'.\n", get_filename())); } return (NC_FORMAT_NETCDF4 == format); @@ -558,20 +554,16 @@ namespace Ioex { float rdum; int ierr = ex_inquire(exoid, EX_INQ_GROUP_NAME, &idum, &rdum, group_name.data()); if (ierr < 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not open root group of group named '{}' in file '{}'.\n", - m_groupName, get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not open root group of group named '{}' in file '{}'.\n", + m_groupName, get_filename())); } m_groupName = std::string(group_name.data()); m_exodusFilePtr = ex_inquire_int(exoid, EX_INQ_GROUP_ROOT); if (m_exodusFilePtr < 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not open group named '{}' in file '{}'.\n", m_groupName, - get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not open group named '{}' in file '{}'.\n", m_groupName, + get_filename())); } success = true; return success; @@ -586,10 +578,8 @@ namespace Ioex { // Check name for '/' which is not allowed since it is the // separator character in a full group path if (set_name.find('/') != std::string::npos) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Invalid group name '{}' contains a '/' which is not allowed.\n", - set_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Invalid group name '{}' contains a '/' which is not allowed.\n", + set_name)); } if (!open_root_group_nl()) @@ -610,10 +600,8 @@ namespace Ioex { ex_get_group_id(exoid, m_groupName.c_str(), &m_exodusFilePtr); if (m_exodusFilePtr < 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not open group named '{}' in file '{}'.\n", m_groupName, - get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not open group named '{}' in file '{}'.\n", m_groupName, + get_filename())); } success = true; return success; @@ -638,19 +626,15 @@ namespace Ioex { // Check name for '/' which is not allowed since it is the // separator character in a full group path if (group_name.find('/') != std::string::npos) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Invalid group name '{}' contains a '/' which is not allowed.\n", - m_groupName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Invalid group name '{}' contains a '/' which is not allowed.\n", + m_groupName)); } m_groupName = group_name; exoid = ex_create_group(exoid, m_groupName.c_str()); if (exoid < 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not create group named '{}' in file '{}'.\n", m_groupName, - get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not create group named '{}' in file '{}'.\n", m_groupName, + get_filename())); } m_exodusFilePtr = exoid; success = true; @@ -801,14 +785,11 @@ namespace Ioex { int step = get_region()->get_current_state(); if (step <= 0) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: No currently active state. The calling code must call " + IOSS_ERROR(fmt::format( "ERROR: No currently active state. The calling code must call " "Ioss::Region::begin_state(int step)\n" " to set the database timestep from which to read the transient data.\n" " [{}]\n", - get_filename()); - IOSS_ERROR(errmsg); + get_filename())); } return step; } @@ -1204,10 +1185,7 @@ namespace Ioex { get_reduction_field(field, get_region(), data); } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Can not handle non-TRANSIENT or non-REDUCTION fields on regions"); - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: Can not handle non-TRANSIENT or non-REDUCTION fields on regions"); } return num_to_get; } @@ -1238,14 +1216,11 @@ namespace Ioex { ; } else { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "ERROR: The variable named '{}' is of the wrong type. A region variable must be of type" " TRANSIENT or REDUCTION.\n" "This is probably an internal error; please notify gdsjaar@sandia.gov", - field.get_name()); - IOSS_ERROR(errmsg); + field.get_name())); } return num_to_get; } @@ -2766,12 +2741,9 @@ namespace Ioex { int offset = 1; for (const auto &field : attributes) { if (block->field_exists(field.get_name())) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: In block '{}', attribute '{}' is defined multiple times which is " + IOSS_ERROR(fmt::format( "ERROR: In block '{}', attribute '{}' is defined multiple times which is " "not allowed.\n", - block->name(), field.get_name()); - IOSS_ERROR(errmsg); + block->name(), field.get_name())); } block->field_add(field); const Ioss::Field &tmp_field = block->get_fieldref(field.get_name()); @@ -2916,12 +2888,9 @@ namespace Ioex { // Verify that exodus supports the mesh_type... if (region->mesh_type() != Ioss::MeshType::UNSTRUCTURED) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: The mesh type is '{}' which Exodus does not support.\n" + IOSS_ERROR(fmt::format( "ERROR: The mesh type is '{}' which Exodus does not support.\n" " Only 'Unstructured' is supported at this time.\n", - region->mesh_type_string()); - IOSS_ERROR(errmsg); + region->mesh_type_string())); } const Ioss::NodeBlockContainer &node_blocks = region->get_node_blocks(); @@ -3351,9 +3320,7 @@ namespace Ioex { std::string currentGroupName = m_groupName; if (!open_root_group_nl()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not open root group.\n", m_groupName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not open root group.\n", m_groupName)); } int numChildGroup = num_child_group(); @@ -3376,9 +3343,7 @@ namespace Ioex { bool BaseDatabaseIO::open_internal_change_set_nl(int index) { if (!open_root_group_nl()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not open root group.\n", m_groupName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not open root group.\n", m_groupName)); } return open_child_group_nl(index); @@ -3517,39 +3482,30 @@ namespace { } if (field_offset + comp_count - 1 > attribute_count) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "INTERNAL ERROR: For block '{}', attribute '{}', the indexing is incorrect.\n" "Something is wrong in the Ioex::BaseDatabaseIO class, function {}. Please report.\n", - block->name(), field_name, __func__); - IOSS_ERROR(errmsg); + block->name(), field_name, __func__)); } for (int i = field_offset; i < field_offset + comp_count; i++) { if (attributes[i] != 0) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "INTERNAL ERROR: For block '{}', attribute '{}', indexes into the same location as a " "previous attribute.\n" "Something is wrong in the Ioex::BaseDatabaseIO class, function {}. Please report.\n", - block->name(), field_name, __func__); - IOSS_ERROR(errmsg); + block->name(), field_name, __func__)); } attributes[i] = 1; } } if (component_sum > attribute_count) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "INTERNAL ERROR: Block '{}' is supposed to have {} attributes, but {} attributes " "were counted.\n" "Something is wrong in the Ioex::BaseDatabaseIO class, function {}. Please report.\n", - block->name(), attribute_count, component_sum, __func__); - IOSS_ERROR(errmsg); + block->name(), attribute_count, component_sum, __func__)); } // Take care of the easy cases first... @@ -3558,13 +3514,10 @@ namespace { // caught above in the duplicate index check. for (int i = 1; i <= attribute_count; i++) { if (attributes[i] == 0) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "INTERNAL ERROR: Block '{}' has an incomplete set of attributes.\n" "Something is wrong in the Ioex::BaseDatabaseIO class, function {}. Please report.\n", - block->name(), __func__); - IOSS_ERROR(errmsg); + block->name(), __func__)); } } return; diff --git a/packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C b/packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C index 0d49fa7663..63e280b883 100644 --- a/packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/exodus/Ioex_DatabaseIO.C @@ -160,15 +160,11 @@ namespace Ioex { isSerialParallel = true; } else { - std::ostringstream errmsg; - fmt::print( - errmsg, - "ERROR: Processor id and processor count are specified via the " + IOSS_ERROR( "ERROR: Processor id and processor count are specified via the " "'processor_count' and 'processor_id' properties which indicates that this " "database is " "being run in 'serial-parallel' mode, but the database constructor was passed an " "mpi communicator which has more than 1 processor. This is not allowed.\n"); - IOSS_ERROR(errmsg); } } } @@ -241,9 +237,7 @@ namespace Ioex { *bad_count = std::count_if(status.begin(), status.end(), [](int i) { return i < 0; }); } if (abort_if_error) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Cannot {} file '{}'\n", open_create, get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Cannot {} file '{}'\n", open_create, get_filename())); } } return false; @@ -457,17 +451,13 @@ namespace Ioex { // Checks that the file is open and if not, opens it first. if (Ioss::SerializeIO::isEnabled()) { if (!Ioss::SerializeIO::inBarrier()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Process {} is attempting to do I/O without serialized I/O", - Ioss::SerializeIO::getRank()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Process {} is attempting to do I/O without serialized I/O", + Ioss::SerializeIO::getRank())); } if (!Ioss::SerializeIO::inMyGroup()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Process {} is attempting to do I/O while {} owns the token", - Ioss::SerializeIO::getRank(), Ioss::SerializeIO::getOwner()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Process {} is attempting to do I/O while {} owns the token", + Ioss::SerializeIO::getRank(), Ioss::SerializeIO::getOwner())); } } @@ -594,12 +584,9 @@ namespace Ioex { } else if (nodeCount < 0) { // NOTE: Code will not continue past this call... - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Negative node count was found in the model\n" + IOSS_ERROR(fmt::format( "ERROR: Negative node count was found in the model\n" " File: '{}'.\n", - decoded_filename()); - IOSS_ERROR(errmsg); + decoded_filename())); } if (elementCount == 0 && info.num_blob == 0) { @@ -609,22 +596,16 @@ namespace Ioex { if (elementCount < 0) { // NOTE: Code will not continue past this call... - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Negative element count was found in the model\n" + IOSS_ERROR(fmt::format( "ERROR: Negative element count was found in the model\n" " File: '{}'.\n", - decoded_filename()); - IOSS_ERROR(errmsg); + decoded_filename())); } if (elementCount > 0 && m_groupCount[EX_ELEM_BLOCK] <= 0) { // NOTE: Code will not continue past this call... - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: No element blocks were found in the model\n" + IOSS_ERROR(fmt::format( "ERROR: No element blocks were found in the model\n" " File: '{}'.\n", - decoded_filename()); - IOSS_ERROR(errmsg); + decoded_filename())); } Ioss::Region *this_region = get_region(); @@ -883,10 +864,8 @@ namespace Ioex { // Not a nemesis file nemesis_file = false; if (isParallel && util().parallel_size() > 1) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Exodus file '{}' does not contain nemesis information.\n", - get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Exodus file '{}' does not contain nemesis information.\n", + get_filename())); } file_type[0] = 'p'; } @@ -901,30 +880,21 @@ namespace Ioex { } if (isParallel && num_proc != util().parallel_size() && util().parallel_size() > 1) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "ERROR: Exodus file '{}' was decomposed for {} processors; application is currently " "being run on {} processors", - get_filename(), num_proc, util().parallel_size()); - IOSS_ERROR(errmsg); + get_filename(), num_proc, util().parallel_size())); } if (num_proc_in_file != 1) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Exodus file '{}' contains data for {} processors; application requires 1 " + IOSS_ERROR(fmt::format( "ERROR: Exodus file '{}' contains data for {} processors; application requires 1 " "processor per file.", - get_filename(), num_proc_in_file); - IOSS_ERROR(errmsg); + get_filename(), num_proc_in_file)); } if (file_type[0] != 'p') { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "ERROR: Exodus file '{}' contains scalar nemesis data; application requires parallel " "nemesis data.", - get_filename()); - IOSS_ERROR(errmsg); + get_filename())); } bool minimal_nemesis = false; @@ -1038,11 +1008,9 @@ namespace Ioex { case EX_EDGE_SET: return get_map(edgeMap, edgeCount, EX_EDGE_MAP, EX_INQ_EDGE_MAP); default: - std::ostringstream errmsg; - fmt::print(errmsg, "INTERNAL ERROR: Invalid map type. " + IOSS_ERROR("INTERNAL ERROR: Invalid map type. " "Something is wrong in the Ioex::DatabaseIO::get_map() function. " "Please report.\n"); - IOSS_ERROR(errmsg); } } @@ -1059,11 +1027,9 @@ namespace Ioex { case EX_FACE_MAP: read_exodus_map = !properties.exists("IGNORE_FACE_MAP"); break; case EX_EDGE_MAP: read_exodus_map = !properties.exists("IGNORE_EDGE_MAP"); break; default: - std::ostringstream errmsg; - fmt::print(errmsg, "INTERNAL ERROR: Invalid map type. " + IOSS_ERROR("INTERNAL ERROR: Invalid map type. " "Something is wrong in the Ioex::DatabaseIO::get_map() function. " "Please report.\n"); - IOSS_ERROR(errmsg); } if (is_input() || open_create_behavior() == Ioss::DB_APPEND) { @@ -1351,9 +1317,7 @@ namespace Ioex { get_region()->add(eblock); } else { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Invalid type in get_blocks()"); - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: Invalid type in get_blocks()"); } // See which connectivity options were defined for this block. @@ -1860,12 +1824,9 @@ namespace Ioex { else if (split_type == Ioss::SPLIT_BY_ELEMENT_BLOCK) { block = get_region()->get_element_block(topo_or_block_name); if (block == nullptr || Ioss::Utils::block_is_omitted(block)) { - std::ostringstream errmsg; - fmt::print(errmsg, - "INTERNAL ERROR: Could not find element block '{}' Something is wrong " + IOSS_ERROR(fmt::format( "INTERNAL ERROR: Could not find element block '{}' Something is wrong " "in the Ioex::DatabaseIO class. Please report.\n", - topo_or_block_name); - IOSS_ERROR(errmsg); + topo_or_block_name)); } elem_topo = block->topology(); } @@ -1876,13 +1837,10 @@ namespace Ioex { elem_topo = Ioss::ElementTopology::factory(topo_or_block_name); } else { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "INTERNAL ERROR: Invalid setting for `split_type` {}. Something is wrong " "in the Ioex::DatabaseIO class. Please report.\n", - static_cast(split_type)); - IOSS_ERROR(errmsg); + static_cast(split_type))); } assert(elem_topo != nullptr); @@ -3177,9 +3135,7 @@ namespace Ioex { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Invalid commset type {}", type); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Invalid commset type {}", type)); } } else if (field.get_name() == "ids") { @@ -3203,9 +3159,7 @@ namespace Ioex { int64_t id = Ioex::get_id(fb, &ids_); int64_t entity_count = fb->entity_count(); if (num_to_get != entity_count) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Partial field input not yet implemented for side blocks"); - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: Partial field input not yet implemented for side blocks"); } ex_set set_param[1]; @@ -3296,14 +3250,11 @@ namespace Ioex { for (int64_t iel = 0; iel < 2 * entity_count; iel += 2) { int64_t new_id = static_cast(10) * els[iel] + els[iel + 1]; if (new_id > int_max) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Process {} accessing the sideset field 'ids'\n" + IOSS_ERROR(fmt::format( "ERROR: Process {} accessing the sideset field 'ids'\n" "\t\thas exceeded the integer bounds for entity {}, local side id {}" ".\n\t\tTry using 64-bit mode to read the file '{}'.\n", Ioss::SerializeIO::getRank(), els[iel], els[iel + 1], - decoded_filename()); - IOSS_ERROR(errmsg); + decoded_filename())); } ids[idx++] = static_cast(new_id); @@ -3609,10 +3560,8 @@ namespace Ioex { Ioss::Field::BasicType ioss_type = field.get_type(); if (ioss_type == Ioss::Field::INTEGER || ioss_type == Ioss::Field::INT64) { - std::ostringstream errmsg; - fmt::print(errmsg, "INTERNAL ERROR: Integer attribute fields are not yet handled for read. " + IOSS_ERROR("INTERNAL ERROR: Integer attribute fields are not yet handled for read. " "Please report.\n"); - IOSS_ERROR(errmsg); } int attribute_count = ge->get_property("attribute_count").get_int(); @@ -3692,9 +3641,7 @@ namespace Ioex { auto var_iter = variables.find(var_name); if (var_iter == variables.end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find field '{}'\n", var_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find field '{}'\n", var_name)); } size_t var_index = var_iter->second; assert(var_index > 0); @@ -3715,9 +3662,7 @@ namespace Ioex { int ierr = 0; auto var_iter = variables.find(var_name); if (var_iter == variables.end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find field '{}'\n", var_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find field '{}'\n", var_name)); } size_t var_index = var_iter->second; assert(var_index > 0); @@ -3747,12 +3692,9 @@ namespace Ioex { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "IOSS_ERROR: Field storage type must be either integer or double.\n" + IOSS_ERROR(fmt::format( "IOSS_ERROR: Field storage type must be either integer or double.\n" " Field '{}' is invalid.\n", - field.get_name()); - IOSS_ERROR(errmsg); + field.get_name())); } assert(k == num_entity); } @@ -3784,9 +3726,7 @@ namespace Ioex { int ierr = 0; auto var_iter = m_variables[EX_SIDE_SET].find(var_name); if (var_iter == m_variables[EX_SIDE_SET].end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find Sideset field '{}'\n", var_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find Sideset field '{}'\n", var_name)); } size_t var_index = var_iter->second; assert(var_index > 0); @@ -3826,12 +3766,9 @@ namespace Ioex { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "IOSS_ERROR: Field storage type must be either integer or double.\n" + IOSS_ERROR(fmt::format( "IOSS_ERROR: Field storage type must be either integer or double.\n" " Field '{}' is invalid.\n", - field.get_name()); - IOSS_ERROR(errmsg); + field.get_name())); } if (i + 1 == comp_count) { num_valid_sides = j / comp_count; @@ -3993,17 +3930,14 @@ namespace Ioex { // Verify that number_distribution_factors is sane... if (number_sides * nfnodes != number_distribution_factors && number_sides != number_distribution_factors) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "ERROR: SideBlock '{}' in file '{}'\n" "\thas incorrect distribution factor count.\n" "\tThere are {} '{}' sides with " "{} nodes per side, but there are {} distribution factors which is not correct.\n" "\tThere should be either {} or {} distribution factors.\n", fb->name(), get_filename(), number_sides, ftopo->name(), nfnodes, - number_distribution_factors, number_sides, number_sides * nfnodes); - IOSS_ERROR(errmsg); + number_distribution_factors, number_sides, number_sides * nfnodes)); } return ex_get_set_dist_fact(get_file_pointer(), EX_SIDE_SET, id, dist_fact); } @@ -4096,21 +4030,16 @@ namespace Ioex { } if (block == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, - "INTERNAL ERROR: Could not find element block containing element with id {}. " + IOSS_ERROR(fmt::format( "INTERNAL ERROR: Could not find element block containing element with id {}. " "Something is wrong in the Ioex::DatabaseIO class. Please report.\n", - elem_id); - IOSS_ERROR(errmsg); + elem_id)); } const Ioss::ElementTopology *topo = block->topology()->boundary_type(side_id); if (topo == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, "INTERNAL ERROR: Could not find topology of element block boundary. " + IOSS_ERROR("INTERNAL ERROR: Could not find topology of element block boundary. " "Something is wrong in the Ioex::DatabaseIO class. Please report.\n"); - IOSS_ERROR(errmsg); } int nside_nodes = topo->number_nodes(); @@ -4758,9 +4687,7 @@ namespace Ioex { auto var_iter = m_variables[EX_NODE_BLOCK].find(var_name); if (var_iter == m_variables[EX_NODE_BLOCK].end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find nodal variable '{}'\n", var_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find nodal variable '{}'\n", var_name)); } var_index = var_iter->second; @@ -4782,12 +4709,9 @@ namespace Ioex { } if (num_out != nodeCount) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Problem outputting nodal variable '{}' with index = {} to file '{}'\n" + IOSS_ERROR(fmt::format( "ERROR: Problem outputting nodal variable '{}' with index = {} to file '{}'\n" "Should have output {} values, but instead only output {} values.\n", - var_name, var_index, decoded_filename(), nodeCount, num_out); - IOSS_ERROR(errmsg); + var_name, var_index, decoded_filename(), nodeCount, num_out)); } // Write the variable... @@ -4858,9 +4782,7 @@ namespace Ioex { std::string var_name = get_component_name(field, Ioss::Field::InOut::OUTPUT, 1); auto var_iter = m_variables[type].find(var_name); if (var_iter == m_variables[type].end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find field '{}'\n", var_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find field '{}'\n", var_name)); } int var_index = var_iter->second; assert(var_index > 0); @@ -4889,9 +4811,7 @@ namespace Ioex { auto var_iter = m_variables[type].find(var_name); if (var_iter == m_variables[type].end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find field '{}'\n", var_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find field '{}'\n", var_name)); } int var_index = var_iter->second; assert(var_index > 0); @@ -5178,9 +5098,7 @@ namespace Ioex { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Invalid commset type {}", type); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Invalid commset type {}", type)); } } else if (field.get_name() == "ids") { @@ -5309,10 +5227,8 @@ namespace Ioex { } } catch (const std::runtime_error &x) { - std::ostringstream errmsg; - fmt::print(errmsg, "{}On SideBlock `{}` while outputting field `elem_side`\n", - x.what(), fb->name()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{}On SideBlock `{}` while outputting field `elem_side`\n", + x.what(), fb->name())); } int ierr = ex_put_partial_set(get_file_pointer(), EX_SIDE_SET, id, offset + 1, @@ -5333,10 +5249,8 @@ namespace Ioex { } } catch (const std::runtime_error &x) { - std::ostringstream errmsg; - fmt::print(errmsg, "{}On SideBlock `{}` while outputting field `elem_side`\n", - x.what(), fb->name()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("{}On SideBlock `{}` while outputting field `elem_side`\n", + x.what(), fb->name())); } int ierr = ex_put_partial_set(get_file_pointer(), EX_SIDE_SET, id, offset + 1, @@ -5560,9 +5474,7 @@ namespace Ioex { meta->elementMap.emplace_back(id, count, 'e'); } else { - std::ostringstream errmsg; - fmt::print(errmsg, "Internal Program Error..."); - IOSS_ERROR(errmsg); + IOSS_ERROR("Internal Program Error..."); } } } diff --git a/packages/seacas/libraries/ioss/src/exodus/Ioex_ParallelDatabaseIO.C b/packages/seacas/libraries/ioss/src/exodus/Ioex_ParallelDatabaseIO.C index 80be41bd21..fca4b9477c 100644 --- a/packages/seacas/libraries/ioss/src/exodus/Ioex_ParallelDatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/exodus/Ioex_ParallelDatabaseIO.C @@ -95,22 +95,17 @@ namespace { return; } if (nop.empty()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: The use of the 'compose' output option requires the definition of " + IOSS_ERROR("ERROR: The use of the 'compose' output option requires the definition of " "the 'owning_processor'" " field prior to the output of nodal data. This field has not yet been " "defined so output is not possible." " For more information, contact gdsjaar@sandia.gov.\n"); - IOSS_ERROR(errmsg); } else if (nop.size() < file_node_count) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: The 'owning_processor' data was defined, but it is not the correct size." + IOSS_ERROR(fmt::format( "ERROR: The 'owning_processor' data was defined, but it is not the correct size." " Its size is {}, but it must be at least this size {}." " For more information, contact gdsjaar@sandia.gov.\n", - nop.size(), file_node_count); - IOSS_ERROR(errmsg); + nop.size(), file_node_count)); } } void get_connectivity_data(int exoid, void *data, ex_entity_type type, ex_entity_id id, @@ -374,13 +369,10 @@ namespace Ioex { { usingParallelIO = true; if (!is_parallel_consistent()) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Parallel IO cannot be used in an application that is not guaranteeing " + IOSS_ERROR("ERROR: Parallel IO cannot be used in an application that is not guaranteeing " "parallel consistent calls of the get and put field data functions.\n" "The application created this database with a 'false' setting for the " "isParallelConsistent property."); - IOSS_ERROR(errmsg); } if (!is_input()) { @@ -461,9 +453,7 @@ namespace Ioex { *bad_count = std::count_if(status.begin(), status.end(), [](int i) { return i < 0; }); } if (abort_if_error) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Cannot {} file '{}'", open_create, get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Cannot {} file '{}'", open_create, get_filename())); } } return false; @@ -781,18 +771,14 @@ namespace Ioex { int flag; MPI_Initialized(&flag); if (flag == 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: MPI is not initialized."); - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: MPI is not initialized."); } // Make sure all file pointers are valid... int fp_min = util().global_minmax(m_exodusFilePtr, Ioss::ParallelUtils::DO_MIN); int fp_max = util().global_minmax(m_exodusFilePtr, Ioss::ParallelUtils::DO_MAX); if (fp_min != fp_max && fp_min < 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Inconsistent file pointer values."); - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: Inconsistent file pointer values."); } return Ioex::BaseDatabaseIO::free_file_pointer(); } @@ -1057,11 +1043,9 @@ namespace Ioex { case EX_EDGE_SET: return get_map(edgeMap, edgeCount, 0, 0, EX_EDGE_MAP, EX_INQ_EDGE_MAP); default: - std::ostringstream errmsg; - fmt::print(errmsg, "INTERNAL ERROR: Invalid map type. " + IOSS_ERROR("INTERNAL ERROR: Invalid map type. " "Something is wrong in the Ioex::ParallelDatabaseIO::get_map() function. " "Please report.\n"); - IOSS_ERROR(errmsg); } } @@ -1311,9 +1295,7 @@ namespace Ioex { #endif } else { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Invalid type in get_blocks()"); - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: Invalid type in get_blocks()"); } #if 0 @@ -1796,13 +1778,10 @@ namespace Ioex { else if (split_type == Ioss::SPLIT_BY_ELEMENT_BLOCK) { block = get_region()->get_element_block(topo_or_block_name); if (block == nullptr || Ioss::Utils::block_is_omitted(block)) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "INTERNAL ERROR: Could not find element block '{}'. Something is wrong " "in the Ioex::ParallelDatabaseIO class. Please report.\n", - topo_or_block_name); - IOSS_ERROR(errmsg); + topo_or_block_name)); } elem_topo = block->topology(); } @@ -2660,9 +2639,7 @@ namespace Ioex { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Invalid commset type {}", type); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Invalid commset type {}", type)); } } else if (field.get_name() == "ids") { @@ -2684,9 +2661,7 @@ namespace Ioex { int64_t id = Ioex::get_id(sb, &ids_); int64_t entity_count = sb->entity_count(); if (num_to_get != entity_count) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Partial field input not yet implemented for side blocks"); - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: Partial field input not yet implemented for side blocks"); } auto &set = decomp->get_decomp_set(EX_SIDE_SET, id); @@ -2766,13 +2741,10 @@ namespace Ioex { for (int64_t iel = 0; iel < 2 * entity_count; iel += 2) { int64_t new_id = static_cast(10) * els[iel] + els[iel + 1]; if (new_id > int_max) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: accessing the sideset field 'ids'\n" + IOSS_ERROR(fmt::format( "ERROR: accessing the sideset field 'ids'\n" "\t\thas exceeded the integer bounds for entity {}, local side id {}.\n" "\t\tTry using 64-bit mode to read the file '{}'.\n", - els[iel], els[iel + 1], get_filename()); - IOSS_ERROR(errmsg); + els[iel], els[iel + 1], get_filename())); } ids[idx++] = static_cast(new_id); @@ -3085,10 +3057,8 @@ namespace Ioex { Ioss::Field::BasicType ioss_type = field.get_type(); if (ioss_type == Ioss::Field::INTEGER || ioss_type == Ioss::Field::INT64) { - std::ostringstream errmsg; - fmt::print(errmsg, "INTERNAL ERROR: Integer attribute fields are not yet handled for read. " + IOSS_ERROR("INTERNAL ERROR: Integer attribute fields are not yet handled for read. " "Please report.\n"); - IOSS_ERROR(errmsg); } std::string att_name = ge->name() + SEP() + field.get_name(); @@ -3166,9 +3136,7 @@ namespace Ioex { int ierr = 0; auto var_iter = variables.find(var_name); if (var_iter == variables.end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find field '{}'\n", var_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find field '{}'\n", var_name)); } size_t var_index = var_iter->second; assert(var_index > 0); @@ -3205,12 +3173,9 @@ namespace Ioex { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "IOSS_ERROR: Field storage type must be either integer or double.\n" + IOSS_ERROR(fmt::format( "IOSS_ERROR: Field storage type must be either integer or double.\n" " Field '{}' is invalid.\n", - field.get_name()); - IOSS_ERROR(errmsg); + field.get_name())); } assert(k == num_entity); } @@ -3242,9 +3207,7 @@ namespace Ioex { int ierr = 0; auto var_iter = m_variables[EX_SIDE_SET].find(var_name); if (var_iter == m_variables[EX_SIDE_SET].end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find Sideset field '{}'\n", var_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find Sideset field '{}'\n", var_name)); } size_t var_index = var_iter->second; assert(var_index > 0); @@ -3284,12 +3247,9 @@ namespace Ioex { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "IOSS_ERROR: Field storage type must be either integer or double.\n" + IOSS_ERROR(fmt::format( "IOSS_ERROR: Field storage type must be either integer or double.\n" " Field '{}' is invalid.\n", - field.get_name()); - IOSS_ERROR(errmsg); + field.get_name())); } if (i + 1 == comp_count) { num_valid_sides = j / comp_count; @@ -3486,15 +3446,12 @@ namespace Ioex { assert(number_sides == 0 || number_distribution_factors / number_sides == nfnodes); if (number_sides * nfnodes != number_distribution_factors && number_sides != number_distribution_factors) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: SideBlock '{}' has incorrect distribution factor count.\n" + IOSS_ERROR(fmt::format( "ERROR: SideBlock '{}' has incorrect distribution factor count.\n" "\tThere are {} '{}' sides with {} nodes per side, but there are {}" " distribution factors which is not correct.\n" "\tThere should be either {} or {} distribution factors.\n", sb->name(), number_sides, ftopo->name(), nfnodes, number_distribution_factors, - number_sides, number_sides * nfnodes); - IOSS_ERROR(errmsg); + number_sides, number_sides * nfnodes)); } std::string storage = "Real[" + std::to_string(nfnodes) + "]"; Ioss::Field dist("distribution_factors", Ioss::Field::REAL, storage, Ioss::Field::MESH, @@ -3607,22 +3564,16 @@ namespace Ioex { } if (block == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, - "INTERNAL ERROR: Could not find element block containing element with id {}." + IOSS_ERROR(fmt::format( "INTERNAL ERROR: Could not find element block containing element with id {}." " Something is wrong in the Ioex::ParallelDatabaseIO class. Please report.\n", - elem_id); - IOSS_ERROR(errmsg); + elem_id)); } const Ioss::ElementTopology *topo = block->topology()->boundary_type(side_id); if (topo == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, - "INTERNAL ERROR: Could not find topology of element block boundary. " + IOSS_ERROR( "INTERNAL ERROR: Could not find topology of element block boundary. " "Something is wrong in the Ioex::ParallelDatabaseIO class. Please report.\n"); - IOSS_ERROR(errmsg); } int nside_nodes = topo->number_nodes(); @@ -4321,9 +4272,7 @@ namespace Ioex { auto var_iter = m_variables[EX_NODE_BLOCK].find(var_name); if (var_iter == m_variables[EX_NODE_BLOCK].end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find nodal variable '{}'\n", var_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find nodal variable '{}'\n", var_name)); } int var_index = var_iter->second; @@ -4346,15 +4295,12 @@ namespace Ioex { } if (num_out != static_cast(nodeCount)) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "ERROR: Problem outputting nodal variable '{}' with index = {} to file '{}' on " "processor {}\n" "\tShould have output {} values, but instead only output {} values.\n", var_name, var_index, get_filename(), myProcessor, fmt::group_digits(nodeCount), - fmt::group_digits(num_out)); - IOSS_ERROR(errmsg); + fmt::group_digits(num_out))); } // Write the variable... @@ -4438,9 +4384,7 @@ namespace Ioex { auto var_iter = m_variables[type].find(var_name); if (var_iter == m_variables[type].end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find field '{}'\n", var_name); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find field '{}'\n", var_name)); } int var_index = var_iter->second; assert(var_index > 0); @@ -5025,11 +4969,9 @@ namespace Ioex { } if (!bad_proc.empty()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Negative {} count on {} processor{}:\n\t{}\n\n", label[j], + IOSS_ERROR(fmt::format("ERROR: Negative {} count on {} processor{}:\n\t{}\n\n", label[j], bad_proc.size(), bad_proc.size() > 1 ? "s" : "", - Ioss::Utils::format_id_list(bad_proc, ":")); - IOSS_ERROR(errmsg); + Ioss::Utils::format_id_list(bad_proc, ":"))); } } } @@ -5060,8 +5002,7 @@ namespace Ioex { } else { // All other processors; need to abort if negative count if (min_val < 0) { - std::ostringstream errmsg; - IOSS_ERROR(errmsg); + IOSS_ERROR(""); } } } @@ -5078,11 +5019,8 @@ namespace Ioex { size_t expected_data_size = num_to_get * decomp->int_size(); if (data_size < expected_data_size) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Connectivity data size {} on region {} is less than expected size {}\n\n", - data_size, get_region()->name(), expected_data_size); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: Connectivity data size {} on region {} is less than expected size {}\n\n", + data_size, get_region()->name(), expected_data_size)); } std::vector offsets = @@ -5125,10 +5063,8 @@ namespace Ioex { auto var_iter = variables.find(var_name); if (var_iter == variables.end()) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not find field '{}' on block '{}'\n", var_name, - entity->name()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not find field '{}' on block '{}'\n", var_name, + entity->name())); } size_t var_index = var_iter->second; assert(var_index > 0); @@ -5199,12 +5135,9 @@ namespace Ioex { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "IOSS_ERROR: Field storage type must be either integer or double.\n" + IOSS_ERROR(fmt::format( "IOSS_ERROR: Field storage type must be either integer or double.\n" " Field '{}' is invalid.\n", - field.get_name()); - IOSS_ERROR(errmsg); + field.get_name())); } } @@ -5232,11 +5165,8 @@ namespace Ioex { size_t expected_data_size = get_entity_field_data_size(field_name, elem_blocks); if (data_size < expected_data_size) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Field {} with data size {} on region {} is less than expected size {}\n\n", - field_name, data_size, get_region()->name(), expected_data_size); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: Field {} with data size {} on region {} is less than expected size {}\n\n", + field_name, data_size, get_region()->name(), expected_data_size)); } return get_entity_transient_field_data(m_variables[EX_ELEM_BLOCK], field_name, elem_blocks, diff --git a/packages/seacas/libraries/ioss/src/exodus/Ioex_SuperElement.C b/packages/seacas/libraries/ioss/src/exodus/Ioex_SuperElement.C index 15d71c99e7..9539b5a785 100644 --- a/packages/seacas/libraries/ioss/src/exodus/Ioex_SuperElement.C +++ b/packages/seacas/libraries/ioss/src/exodus/Ioex_SuperElement.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions +// Copyright(C) 1999-2020, 2023, 2024 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. // @@ -38,8 +38,6 @@ namespace { int nc_get_dimension(int ncid, const char *DIMENSION, const char *label, size_t *count) { - std::ostringstream errmsg; - *count = 0; int dimid = -1; @@ -50,14 +48,12 @@ namespace { *count = 0; return 0; } - fmt::print(errmsg, "ERROR: Failed to locate number of {} in superelement file.", label); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Failed to locate number of {} in superelement file.", label)); } status = nc_inq_dimlen(ncid, dimid, count); if (status != NC_NOERR) { - fmt::print(errmsg, "ERROR: Failed to get number of {} in superelement file.", label); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Failed to get number of {} in superelement file.", label)); } return status; } @@ -77,9 +73,7 @@ Ioex::SuperElement::SuperElement(std::string filename, const std::string &my_nam int status = nc_open(local_filename.c_str(), NC_NOWRITE, &filePtr); if (status != NC_NOERR) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Failed to open superelement file '{}'.", local_filename); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Failed to open superelement file '{}'.", local_filename)); } // At this point have a valid netcdf file handle. @@ -152,10 +146,8 @@ int64_t Ioex::SuperElement::internal_get_field_data(const Ioss::Field &field, vo assert(num_to_get == 2 * num_nodes * num_dim); int status = nc_get_array(filePtr, "cbmap", reinterpret_cast(data)); if (status != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not load coordinate data field 'cbmap' from file '{}'.", - fileName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not load coordinate data field 'cbmap' from file '{}'.", + fileName)); } } else if (field.get_name() == "node_num_map") { @@ -163,81 +155,63 @@ int64_t Ioex::SuperElement::internal_get_field_data(const Ioss::Field &field, vo int status = nc_get_array(filePtr, "node_num_map", reinterpret_cast(data)); if (status != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Could not load coordinate data field 'node_num_map' from file '{}'.", - fileName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: Could not load coordinate data field 'node_num_map' from file '{}'.", + fileName)); } } else if (field.get_name() == "coordx") { assert(num_to_get == num_nodes); int status = nc_get_array(filePtr, "coordx", reinterpret_cast(data)); if (status != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not load coordinate data field 'coordx' from file '{}'.", - fileName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not load coordinate data field 'coordx' from file '{}'.", + fileName)); } } else if (field.get_name() == "coordy") { assert(num_to_get == num_nodes); int status = nc_get_array(filePtr, "coordy", reinterpret_cast(data)); if (status != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not load coordinate data field 'coordy' from file '{}'.", - fileName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not load coordinate data field 'coordy' from file '{}'.", + fileName)); } } else if (field.get_name() == "coordz") { assert(num_to_get == num_nodes); int status = nc_get_array(filePtr, "coordz", reinterpret_cast(data)); if (status != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not load coordinate data field 'coordz' from file '{}'.", - fileName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not load coordinate data field 'coordz' from file '{}'.", + fileName)); } } else if (field.get_name() == "Kr") { assert(num_to_get == numDOF * numDOF); int status = nc_get_array(filePtr, "Kr", reinterpret_cast(data)); if (status != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not load stiffness matrix field 'Kr' from file '{}'.", - fileName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not load stiffness matrix field 'Kr' from file '{}'.", + fileName)); } } else if (field.get_name() == "Mr") { assert(num_to_get == numDOF * numDOF); int status = nc_get_array(filePtr, "Mr", reinterpret_cast(data)); if (status != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not load mass matrix field 'Mr' from file '{}'.", fileName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not load mass matrix field 'Mr' from file '{}'.", fileName)); } } else if (field.get_name() == "InertiaTensor") { assert(num_to_get == numDOF * numRBM); int status = nc_get_array(filePtr, "InertiaTensor", reinterpret_cast(data)); if (status != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Could not load inertia matrix field 'InertialTensor' from file '{}'.", - fileName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format( "ERROR: Could not load inertia matrix field 'InertialTensor' from file '{}'.", + fileName)); } } else if (field.get_name() == "MassInertia") { assert(num_to_get == numDOF * numRBM); int status = nc_get_array(filePtr, "MassInertia", reinterpret_cast(data)); if (status != 0) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not mass inertia matrix field 'MassInertia' from file '{}'.", - fileName); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not mass inertia matrix field 'MassInertia' from file '{}'.", + fileName)); } } else { diff --git a/packages/seacas/libraries/ioss/src/exodus/Ioex_Utils.C b/packages/seacas/libraries/ioss/src/exodus/Ioex_Utils.C index 8cf3cf2b3f..a938dc2160 100644 --- a/packages/seacas/libraries/ioss/src/exodus/Ioex_Utils.C +++ b/packages/seacas/libraries/ioss/src/exodus/Ioex_Utils.C @@ -921,12 +921,9 @@ namespace Ioex { for (size_t iel = 0; iel < element.size(); iel++) { int64_t elem_id = element[iel]; if (elem_id <= 0) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: In sideset/surface '{}' an element with id {} is specified. Element " + IOSS_ERROR(fmt::format( "ERROR: In sideset/surface '{}' an element with id {} is specified. Element " "ids must be greater than zero. ({})", - surface_name, elem_id, __func__); - IOSS_ERROR(errmsg); + surface_name, elem_id, __func__)); } if (block == nullptr || !block->contains(elem_id)) { block = region->get_element_block(elem_id); @@ -944,15 +941,12 @@ namespace Ioex { if (common_ftopo == nullptr && sides[iel] != current_side) { current_side = sides[iel]; if (current_side <= 0 || current_side > block->topology()->number_boundaries()) { - std::ostringstream errmsg; - fmt::print( - errmsg, + IOSS_ERROR(fmt::format( "ERROR: In sideset/surface '{}' for the element with id {} of topology '{}';\n\t" "an invalid face index '{}' is specified.\n\tFace indices " "must be between 1 and {}. ({})", surface_name, fmt::group_digits(elem_id), block->topology()->name(), current_side, - block->topology()->number_boundaries(), __func__); - IOSS_ERROR(errmsg); + block->topology()->number_boundaries(), __func__)); } topo = block->topology()->boundary_type(sides[iel]); SMART_ASSERT(topo != nullptr); diff --git a/packages/seacas/libraries/ioss/src/gen_struc/Iogs_DatabaseIO.C b/packages/seacas/libraries/ioss/src/gen_struc/Iogs_DatabaseIO.C index 34e57cb336..8d9e763b90 100644 --- a/packages/seacas/libraries/ioss/src/gen_struc/Iogs_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/gen_struc/Iogs_DatabaseIO.C @@ -1,4 +1,4 @@ -// Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions +// Copyright(C) 1999-2020, 2022, 2023, 2024 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. // @@ -14,6 +14,7 @@ #include // for ostringstream, operator<<, etc #include #include // for string, operator==, etc +#include #include "Ioss_CommSet.h" // for CommSet #include "Ioss_DBUsage.h" // for DatabaseUsage @@ -112,17 +113,13 @@ namespace Iogs { dbState = Ioss::STATE_UNKNOWN; } else { - std::ostringstream errmsg; - errmsg << "ERROR: Structured Generated mesh option is only valid for input mesh."; - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: Structured Generated mesh option is only valid for input mesh."); } if (props.exists("USE_CONSTANT_DF")) { m_useVariableDf = false; } if (util().parallel_size() > 1) { - std::ostringstream errmsg; - errmsg << "ERROR: Structured Generated mesh option is not valid for parallel yet."; - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: Structured Generated mesh option is not valid for parallel yet."); } } @@ -132,10 +129,8 @@ namespace Iogs { { if (m_generatedMesh == nullptr) { if (get_filename() == "external") { - std::ostringstream errmsg; - errmsg << "ERROR: (gen_struc mesh) 'external' specified for mesh, but " - << "getGeneratedMesh was not called to set the external mesh.\n"; - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: (gen_struc mesh) 'external' specified for mesh, but " + "getGeneratedMesh was not called to set the external mesh.\n"); } else { m_generatedMesh = @@ -298,9 +293,7 @@ namespace Iogs { int64_t id = sd_blk->get_property("id").get_int(); size_t entity_count = sd_blk->entity_count(); if (num_to_get != entity_count) { - std::ostringstream errmsg; - errmsg << "ERROR: Partial field input not implemented for side blocks"; - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: Partial field input not implemented for side blocks"); } Ioss::Field::RoleType role = field.get_role(); @@ -431,9 +424,7 @@ namespace Iogs { } } else { - std::ostringstream errmsg; - errmsg << "Invalid commset type " << type; - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("Invalid commset type {}", type)); } } else if (field.get_name() == "ids") { diff --git a/packages/seacas/libraries/ioss/src/gen_struc/Iogs_GeneratedMesh.C b/packages/seacas/libraries/ioss/src/gen_struc/Iogs_GeneratedMesh.C index d558e39241..4ccbd13294 100644 --- a/packages/seacas/libraries/ioss/src/gen_struc/Iogs_GeneratedMesh.C +++ b/packages/seacas/libraries/ioss/src/gen_struc/Iogs_GeneratedMesh.C @@ -55,15 +55,12 @@ namespace Iogs { void GeneratedMesh::initialize() { if (processorCount > numZ) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: ({})\n" + IOSS_ERROR(fmt::format( "ERROR: ({})\n" " The number of mesh intervals in the Z direction ({})\n" " must be at least as large as the number of processors ({}).\n" " The current parameters do not meet that requirement. Execution will " "terminate.\n", - __func__, numZ, processorCount); - IOSS_ERROR(errmsg); + __func__, numZ, processorCount)); } if (processorCount > 1) { @@ -120,13 +117,10 @@ namespace Iogs { // specified later in the option list, you may not get the // desired bounding box. if (numX == 0 || numY == 0 || numZ == 0) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: ({})\n" + IOSS_ERROR(fmt::format( "ERROR: ({})\n" " All interval counts must be greater than 0.\n" " numX = {}, numY = {}, numZ = {}\n", - __func__, numX, numY, numZ); - IOSS_ERROR(errmsg); + __func__, numX, numY, numZ)); } double x_range = xmax - xmin; @@ -175,9 +169,7 @@ namespace Iogs { case 'z': add_sideset(MZ); break; case 'Z': add_sideset(PZ); break; default: - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Unrecognized sideset location option '{}'.", opt); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Unrecognized sideset location option '{}'.", opt)); } } } diff --git a/packages/seacas/libraries/ioss/src/generated/Iogn_DatabaseIO.C b/packages/seacas/libraries/ioss/src/generated/Iogn_DatabaseIO.C index df82f3793a..265126597a 100644 --- a/packages/seacas/libraries/ioss/src/generated/Iogn_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/generated/Iogn_DatabaseIO.C @@ -13,7 +13,6 @@ #include // for sqrt #include #include -#include // for ostringstream #include #include // for string, operator==, etc @@ -115,9 +114,7 @@ namespace Iogn { dbState = Ioss::STATE_UNKNOWN; } else { - std::ostringstream errmsg; - fmt::print(errmsg, "Generated mesh option is only valid for input mesh."); - IOSS_ERROR(errmsg); + IOSS_ERROR("Generated mesh option is only valid for input mesh."); } if (props.exists("USE_CONSTANT_DF")) { m_useVariableDf = false; @@ -130,10 +127,8 @@ namespace Iogn { { if (m_generatedMesh == nullptr) { if (get_filename() == "external") { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: (generated mesh) 'external' specified for mesh, but " - "getGeneratedMesh was not called to set the external mesh.\n"); - IOSS_ERROR(errmsg); + IOSS_ERROR("ERROR: (generated mesh) 'external' specified for mesh, but " + "getGeneratedMesh was not called to set the external mesh.\n"); } else { m_generatedMesh = @@ -153,16 +148,13 @@ namespace Iogn { const int64_t two_billion = 2ll << 30; if ((glob_node_count > two_billion || glob_elem_count > two_billion) && int_byte_size_api() == 4) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: The node count is {} and the element count is {}.\n" + IOSS_ERROR(fmt::format( "ERROR: The node count is {} and the element count is {}.\n" " This exceeds the capacity of the 32-bit integers ({})\n" " which are being requested by the client.\n" " The mesh requires 64-bit integers which can be requested by setting the " "`INTEGER_SIZE_API=8` property.", fmt::group_digits(glob_node_count), fmt::group_digits(glob_elem_count), - fmt::group_digits(two_billion)); - IOSS_ERROR(errmsg); + fmt::group_digits(two_billion))); } spatialDimension = 3; @@ -343,9 +335,7 @@ namespace Iogn { int64_t id = sd_blk->get_property("id").get_int(); size_t entity_count = sd_blk->entity_count(); if (num_to_get != entity_count) { - std::ostringstream errmsg; - fmt::print(errmsg, "Partial field input not implemented for side blocks"); - IOSS_ERROR(errmsg); + IOSS_ERROR("Partial field input not implemented for side blocks"); } Ioss::Field::RoleType role = field.get_role(); @@ -532,9 +522,7 @@ namespace Iogn { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, "Invalid commset type {}", type); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("Invalid commset type {}", type)); } } else if (field.get_name() == "ids") { diff --git a/packages/seacas/libraries/ioss/src/generated/Iogn_GeneratedMesh.C b/packages/seacas/libraries/ioss/src/generated/Iogn_GeneratedMesh.C index 9fa3400924..c5f16c7b00 100644 --- a/packages/seacas/libraries/ioss/src/generated/Iogn_GeneratedMesh.C +++ b/packages/seacas/libraries/ioss/src/generated/Iogn_GeneratedMesh.C @@ -79,13 +79,10 @@ namespace Iogn { numZ = std::stoull(tokens[2]); if (numX <= 0 || numY <= 0 || numZ <= 0) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: (Iogn::GeneratedMesh::GeneratedMesh)\n" + IOSS_ERROR(fmt::format( "ERROR: (Iogn::GeneratedMesh::GeneratedMesh)\n" " All interval counts must be greater than 0.\n" " numX = {}, numY = {}, numZ = {}\n", - numX, numY, numZ); - IOSS_ERROR(errmsg); + numX, numY, numZ)); } initialize(); parse_options(groups); @@ -96,15 +93,12 @@ namespace Iogn { void GeneratedMesh::initialize() { if (processorCount > numZ) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: (Iogn::GeneratedMesh::initialize)\n" + IOSS_ERROR(fmt::format( "ERROR: (Iogn::GeneratedMesh::initialize)\n" " The number of mesh intervals in the Z direction ({})\n" " must be at least as large as the number of processors ({}).\n" " The current parameters do not meet that requirement. Execution will " "terminate.\n", - numZ, processorCount); - IOSS_ERROR(errmsg); + numZ, processorCount)); } if (processorCount > 1) { @@ -177,13 +171,10 @@ namespace Iogn { // specified later in the option list, you may not get the // desired bounding box. if (numX == 0 || numY == 0 || numZ == 0) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: (Iogn::GeneratedMesh::set_bbox)\n" + IOSS_ERROR(fmt::format( "ERROR: (Iogn::GeneratedMesh::set_bbox)\n" " All interval counts must be greater than 0.\n" " numX = {}, numY = {}, numZ = {}\n", - numX, numY, numZ); - IOSS_ERROR(errmsg); + numX, numY, numZ)); } double x_range = xmax - xmin; @@ -232,9 +223,7 @@ namespace Iogn { case 'z': add_shell_block(MZ); break; case 'Z': add_shell_block(PZ); break; default: - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Unrecognized shell location option '{}'.", opt); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Unrecognized shell location option '{}'.", opt)); } } } @@ -251,9 +240,7 @@ namespace Iogn { case 'z': add_nodeset(MZ); break; case 'Z': add_nodeset(PZ); break; default: - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Unrecognized nodeset location option '{}'.", opt); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Unrecognized nodeset location option '{}'.", opt)); } } } @@ -270,9 +257,7 @@ namespace Iogn { case 'z': add_sideset(MZ); break; case 'Z': add_sideset(PZ); break; default: - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Unrecognized sideset location option '{}'.", opt); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Unrecognized sideset location option '{}'.", opt)); } } } @@ -351,10 +336,8 @@ namespace Iogn { else if (option[0] == "pyramids") { createPyramids = true; if (processorCount > 1) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Pyramid option can currently only be used in a serial run. " + IOSS_ERROR("ERROR: Pyramid option can currently only be used in a serial run. " "Parallel not supported yet.\n"); - IOSS_ERROR(errmsg); } } @@ -381,9 +364,7 @@ namespace Iogn { } else { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Unrecognized option '{}'. It will be ignored.\n", option[0]); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Unrecognized option '{}'. It will be ignored.\n", option[0])); } } } @@ -1685,13 +1666,10 @@ namespace Iogn { variableCount[Ioss::SIDEBLOCK] = count; } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: (Iogn::GeneratedMesh::set_variable_count)\n" + IOSS_ERROR(fmt::format( "ERROR: (Iogn::GeneratedMesh::set_variable_count)\n" " Unrecognized variable type '{}'. Valid types are:\n" " global, element, node, nodal, nodeset, nset, surface, sideset, sset.\n", - type); - IOSS_ERROR(errmsg); + type)); } } diff --git a/packages/seacas/libraries/ioss/src/heartbeat/Iohb_DatabaseIO.C b/packages/seacas/libraries/ioss/src/heartbeat/Iohb_DatabaseIO.C index 32b02b82d2..d9609242e2 100644 --- a/packages/seacas/libraries/ioss/src/heartbeat/Iohb_DatabaseIO.C +++ b/packages/seacas/libraries/ioss/src/heartbeat/Iohb_DatabaseIO.C @@ -166,9 +166,7 @@ namespace Iohb { new_this->logStream = open_stream(get_filename(), &(new_this->streamNeedsDelete), append); if (new_this->logStream == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, "ERROR: Could not create heartbeat file '{}'\n", get_filename()); - IOSS_ERROR(errmsg); + IOSS_ERROR(fmt::format("ERROR: Could not create heartbeat file '{}'\n", get_filename())); } } @@ -392,9 +390,7 @@ namespace Iohb { } else { if (layout_ == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, "INTERNAL ERROR: Unexpected nullptr layout.\n"); - IOSS_ERROR(errmsg); + IOSS_ERROR("INTERNAL ERROR: Unexpected nullptr layout.\n"); } if (field.get_type() == Ioss::Field::INTEGER) { assert(field.transformed_count() == 1); @@ -417,10 +413,7 @@ namespace Iohb { } } else { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Can not handle non-TRANSIENT or non-REDUCTION fields on regions.\n"); - IOSS_ERROR(errmsg); + IOSS_ERROR( "ERROR: Can not handle non-TRANSIENT or non-REDUCTION fields on regions.\n"); } return num_to_get; } diff --git a/packages/seacas/libraries/ioss/src/main/skinner.C b/packages/seacas/libraries/ioss/src/main/skinner.C index f63ad50d9a..5c2823bc89 100644 --- a/packages/seacas/libraries/ioss/src/main/skinner.C +++ b/packages/seacas/libraries/ioss/src/main/skinner.C @@ -323,12 +323,9 @@ namespace { auto face_topo = eb->topology()->face_type(0); std::string topo = "shell"; if (face_topo == nullptr) { - std::ostringstream errmsg; - fmt::print(errmsg, - "ERROR: Block '{}' with topology '{}' does not have" + IOSS_ERROR(fmt::format( "ERROR: Block '{}' with topology '{}' does not have" " a unique face topology.\nThis is not supported at this time.\n", - name, eb->topology()->name()); - IOSS_ERROR(errmsg); + name, eb->topology()->name())); } if (face_topo->name() == "tri3") { topo = "trishell";