Skip to content

Commit 5a74ea2

Browse files
committed
APREPRO: Default to using full precision output
1 parent 7d5223e commit 5a74ea2

File tree

7 files changed

+61
-38
lines changed

7 files changed

+61
-38
lines changed

packages/seacas/applications/aprepro/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright(C) 1999-2022 National Technology & Engineering Solutions
1+
# Copyright(C) 1999-2022, 2025 National Technology & Engineering Solutions
22
# of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
33
# NTESS, the U.S. Government retains certain rights in this software.
44
#
@@ -27,7 +27,7 @@ TRIBITS_ADD_EXECUTABLE(
2727
TRIBITS_ADD_ADVANCED_TEST(
2828
aprepro_unit_test
2929
TEST_0 EXEC aprepro
30-
ARGS -q ${CMAKE_CURRENT_SOURCE_DIR}/test.inp_app test_unit.output
30+
ARGS -q --legacy_output_format ${CMAKE_CURRENT_SOURCE_DIR}/test.inp_app test_unit.output
3131
NOEXEPREFIX NOEXESUFFIX
3232
PASS_ANY
3333
TEST_1 CMND diff ARGS -w
@@ -42,7 +42,7 @@ TRIBITS_ADD_ADVANCED_TEST(
4242
TRIBITS_ADD_ADVANCED_TEST(
4343
aprepro_array_test
4444
TEST_0 EXEC aprepro
45-
ARGS -q --info=aprepro-array.dump --include=${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/test-array.i
45+
ARGS -q --legacy_output_format --info=aprepro-array.dump --include=${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/test-array.i
4646
test-array.out
4747
NOEXEPREFIX NOEXESUFFIX
4848
PASS_ANY
@@ -111,7 +111,7 @@ IF (${CMAKE_PROJECT_NAME}_ENABLE_SEACASExodus)
111111
TRIBITS_ADD_ADVANCED_TEST(
112112
aprepro_test_exodus
113113
TEST_0 EXEC aprepro
114-
ARGS --include=${CMAKE_CURRENT_SOURCE_DIR} -q ${CMAKE_CURRENT_SOURCE_DIR}/exodus-test.apr test_exo.output
114+
ARGS --legacy_output_format --include=${CMAKE_CURRENT_SOURCE_DIR} -q ${CMAKE_CURRENT_SOURCE_DIR}/exodus-test.apr test_exo.output
115115
NOEXEPREFIX NOEXESUFFIX
116116
PASS_ANY
117117
TEST_1 CMND diff ARGS -w

packages/seacas/libraries/aprepro_lib/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ if (${PACKAGE_NAME}_ENABLE_TESTS)
113113
TRIBITS_ADD_ADVANCED_TEST(
114114
aprepro_lib_unit_test
115115
TEST_0 EXEC aprepro_lib_test
116-
ARGS -o test.output ${CMAKE_CURRENT_SOURCE_DIR}/test.inp_app
116+
ARGS --legacy_output_format -o test.output ${CMAKE_CURRENT_SOURCE_DIR}/test.inp_app
117117
NOEXEPREFIX NOEXESUFFIX
118118
PASS_ANY
119119
TEST_1 CMND diff ARGS -w
@@ -128,7 +128,7 @@ TRIBITS_ADD_ADVANCED_TEST(
128128
TRIBITS_ADD_ADVANCED_TEST(
129129
aprepro_lib_array_test
130130
TEST_0 EXEC aprepro_lib_test
131-
ARGS --info=test-array.dump --include=${CMAKE_CURRENT_SOURCE_DIR} -o test-array.out test-array.i
131+
ARGS --legacy_output_format --info=test-array.dump --include=${CMAKE_CURRENT_SOURCE_DIR} -o test-array.out test-array.i
132132
NOEXEPREFIX NOEXESUFFIX
133133
PASS_ANY
134134
TEST_1 CMND diff ARGS -w
@@ -146,7 +146,7 @@ TRIBITS_ADD_ADVANCED_TEST(
146146
TRIBITS_ADD_ADVANCED_TEST(
147147
aprepro_lib_array_test_short_opt
148148
TEST_0 EXEC aprepro_lib_test
149-
ARGS --info=test-short-array.dump -I=${CMAKE_CURRENT_SOURCE_DIR} -o test-short-array.out
149+
ARGS --legacy_output_format --info=test-short-array.dump -I=${CMAKE_CURRENT_SOURCE_DIR} -o test-short-array.out
150150
test-array.i
151151
NOEXEPREFIX NOEXESUFFIX
152152
PASS_ANY

packages/seacas/libraries/aprepro_lib/apr_aprepro.cc

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
#endif
3434

3535
namespace {
36-
const std::string version_short{"6.36"};
37-
const std::string version_date{"(2025/02/05)"};
36+
const std::string version_short{"6.37"};
37+
const std::string version_date{"(2025/03/06)"};
3838
const std::string version_string = version_short + " " + version_date;
3939

4040
void output_copyright();
@@ -580,42 +580,49 @@ namespace SEAMS {
580580
ptr->value.svar = "";
581581
}
582582
}
583+
else if (match_option(option, "legacy_output_format", "L", 6)) {
584+
symrec *ptr = getsym("_FORMAT");
585+
if (ptr != nullptr) {
586+
ptr->value.svar = "%.10g";
587+
}
588+
}
583589

584590
else if (match_option(option, "help", "h", 3)) {
585591
std::cerr
586592
<< "\nAprepro version " << version() << "\n"
587593
<< "\nUsage: aprepro [options] [-I path] [-c char] [var=val] [filein] [fileout]\n"
588-
<< " --debug or -d: Dump all variables, debug loops/if/endif and keep temporary "
594+
<< " --debug or -d: Dump all variables, debug loops/if/endif and keep temporary "
589595
"files\n"
590-
<< " --dumpvars or -D: Dump all variables at end of run \n"
591-
<< " --dumpvars_json or -J: Dump all variables at end of run in json format\n"
592-
<< " --version or -v: Print version number to stderr \n"
593-
<< " --immutable or -X: All variables are immutable--cannot be modified\n"
594-
<< " --errors_fatal or -f: Exit program with nonzero status if errors are "
596+
<< " --dumpvars or -D: Dump all variables at end of run \n"
597+
<< " --dumpvars_json or -J: Dump all variables at end of run in json format\n"
598+
<< " --version or -v: Print version number to stderr \n"
599+
<< " --immutable or -X: All variables are immutable--cannot be modified\n"
600+
<< " --errors_fatal or -f: Exit program with nonzero status if errors are "
595601
"encountered\n"
596-
<< " --errors_and_warnings_fatal or -F: Exit program with nonzero status if "
602+
<< " --errors_and_warnings_fatal or -F: Exit program with nonzero status if "
597603
"warnings are encountered\n"
598-
<< "--require_defined or -R: Treat undefined variable warnings as fatal\n"
599-
<< "--one_based_index or -1: Array indexing is one-based (default = zero-based)\n"
600-
<< " --interactive or -i: Interactive use, no buffering \n"
601-
<< " --include=P or -I=P: Include file or include path \n"
602-
<< " : If P is path, then optionally prepended to all include "
604+
<< " --require_defined or -R: Treat undefined variable warnings as fatal\n"
605+
<< " --one_based_index or -1: Array indexing is one-based (default = zero-based)\n"
606+
<< " --interactive or -i: Interactive use, no buffering \n"
607+
<< " --include=P or -I=P: Include file or include path \n"
608+
<< " : If P is path, then optionally prepended to all include "
603609
"filenames\n"
604-
<< " : If P is file, then processed before processing input file\n"
605-
<< " : variables defined in P will be immutable.\n"
606-
<< " --exit_on or -e: End when 'Exit|EXIT|exit' entered \n"
607-
<< " --help or -h: Print this list \n"
608-
<< " --message or -M: Print INFO messages \n"
609-
<< " --info=file: Output INFO messages (e.g. DUMP() output) to file.\n"
610-
<< " --nowarning or -W: Do not print WARN messages \n"
611-
<< " --comment=char or -c=char: Change comment character to 'char' \n"
612-
<< " --full_precision -p: Floating point output uses as many digits as needed.\n"
613-
<< " --copyright or -C: Print copyright message \n"
614-
<< " --keep_history or -k: Keep a history of aprepro substitutions.\n"
615-
<< " (not for general interactive use) \n"
616-
<< " --quiet or -q: Do not print the header output line \n"
617-
<< " var=val: Assign value 'val' to variable 'var' \n"
618-
<< " Use var=\\\"sval\\\" for a string variable. 'var' will be "
610+
<< " : If P is file, then processed before processing input file\n"
611+
<< " : variables defined in P will be immutable.\n"
612+
<< " --exit_on or -e: End when 'Exit|EXIT|exit' entered \n"
613+
<< " --help or -h: Print this list \n"
614+
<< " --message or -M: Print INFO messages \n"
615+
<< " --info=file: Output INFO messages (e.g. DUMP() output) to file.\n"
616+
<< " --nowarning or -W: Do not print WARN messages \n"
617+
<< "--comment=char or -c=char: Change comment character to 'char' \n"
618+
<< " --full_precision -p: Floating point output uses as many digits as needed. [default]\n"
619+
<< "--legacy_output_format -L: Floating point output uses the legacy `%.10g` format.\n"
620+
<< " --copyright or -C: Print copyright message \n"
621+
<< " --keep_history or -k: Keep a history of aprepro substitutions.\n"
622+
<< " (not for general interactive use) \n"
623+
<< " --quiet or -q: Do not print the header output line \n"
624+
<< " var=val: Assign value 'val' to variable 'var' \n"
625+
<< " Use var=\\\"sval\\\" for a string variable. 'var' will be "
619626
"immutable.\n\n"
620627
<< "\tUnits Systems: si, cgs, cgs-ev, shock, swap, ft-lbf-s, ft-lbm-s, in-lbf-s\n"
621628
<< "\tEnter {DUMP()} for list of user-defined variables\n"

packages/seacas/libraries/aprepro_lib/apr_builtin.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ namespace SEAMS {
9292
#define min(x, y) (x) < (y) ? (x) : (y)
9393
#endif
9494

95+
const char* do_use_legacy_output_format()
96+
{
97+
SEAMS::symrec *ptr = aprepro->getsym("_FORMAT");
98+
if (ptr != nullptr) {
99+
ptr->value.svar = "%.10g";
100+
}
101+
return (nullptr);
102+
}
103+
95104
double do_time()
96105
{
97106
time_t timer = time(nullptr);

packages/seacas/libraries/aprepro_lib/apr_builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ namespace SEAMS {
7979
double do_cols(const array *arr);
8080
double do_time();
8181

82+
const char *do_use_legacy_output_format();
8283
const char *do_dumpsym();
8384
const char *do_dumpsym_json();
8485
const char *do_dumpfunc();

packages/seacas/libraries/aprepro_lib/apr_init.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ namespace SEAMS {
134134
{nullptr, nullptr, nullptr, nullptr}};
135135

136136
const str_init string_fncts[] = {
137+
{"use_legacy_output_format", do_use_legacy_output_format, "use_legacy_output_format()",
138+
"Use the output format of `%.10g` which was the default before the full-precision output became the default."},
137139
{"DUMP", do_dumpsym, "DUMP()",
138140
"Output a list of all user-defined variables and their value."},
139141
{"DUMP_JSON", do_dumpsym_json, "DUMP_JSON()",
@@ -381,7 +383,7 @@ namespace SEAMS {
381383
};
382384
// clang-format on
383385

384-
const svar_init svariables[] = {{"_FORMAT", "%.10g"}, /* Default output format */
386+
const svar_init svariables[] = {{"_FORMAT", ""}, /* Default output format if full-precision */
385387
{"_UNITS_SYSTEM", "none"},
386388
{nullptr, nullptr}};
387389
/* NOTE: The current comment is stored in "_C_"

packages/seacas/libraries/aprepro_lib/strings.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright(C) 1999-2020, 2023, 2024 National Technology & Engineering Solutions
1+
// Copyright(C) 1999-2020, 2023, 2024, 2025 National Technology & Engineering Solutions
22
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
33
// NTESS, the U.S. Government retains certain rights in this software.
44
//
@@ -16,6 +16,10 @@ int main(int, char **)
1616
SEAMS::Aprepro aprepro;
1717

1818
aprepro.ap_options.warning_msg = false;
19+
SEAMS::symrec *ptr = aprepro.getsym("_FORMAT");
20+
if (ptr != nullptr) {
21+
ptr->value.svar = "%.10g";
22+
}
1923

2024
std::vector<std::string> strings = build_strings();
2125
bool result = aprepro.parse_strings(strings, "My list of strings");

0 commit comments

Comments
 (0)