Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contidtionally output the json files #562

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/generate_decl_schema.wb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": "0.6",
"features": []
}
4 changes: 2 additions & 2 deletions doc/sphinx/GWB_parameter_listings/world_builder_file/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Explain how to use this page. Here is an example how to link to a specific item
::::{tab-item} All open
:name: all_open

:::{include} ../../../../tests/gwb-dat/world_builder_declarations_open.md
:::{include} ../../../world_builder_declarations_open.md
::::

::::{tab-item} Only root open
:name: root_open

:::{include} ../../../../tests/gwb-dat/world_builder_declarations_closed.md
:::{include} ../../../world_builder_declarations_closed.md
::::

:::::
Original file line number Diff line number Diff line change
Expand Up @@ -6248,7 +6248,7 @@
"documentation": "The reference density of the subducting plate in $kg/m^3$"
},
"plate velocity": {
"default value": NaN,
"default value": "NaN",
"type": "number",
"documentation": "The velocity in meters per year with which the plate subducts in meters per year."
},
Expand Down Expand Up @@ -6939,7 +6939,7 @@
"documentation": "The reference density of the subducting plate in $kg/m^3$"
},
"plate velocity": {
"default value": NaN,
"default value": "NaN",
"type": "number",
"documentation": "The velocity in meters per year with which the plate subducts in meters per year."
},
Expand Down Expand Up @@ -7700,7 +7700,7 @@
"documentation": "The reference density of the subducting plate in $kg/m^3$"
},
"plate velocity": {
"default value": NaN,
"default value": "NaN",
"type": "number",
"documentation": "The velocity in meters per year with which the plate subducts in meters per year."
},
Expand Down Expand Up @@ -8391,7 +8391,7 @@
"documentation": "The reference density of the subducting plate in $kg/m^3$"
},
"plate velocity": {
"default value": NaN,
"default value": "NaN",
"type": "number",
"documentation": "The velocity in meters per year with which the plate subducts in meters per year."
},
Expand Down
2 changes: 1 addition & 1 deletion include/world_builder/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace WorldBuilder
* documented algorithm), we can test the results and they should be the same even for different
* compilers and machines.
*/
World(std::string filename, bool has_output_dir = false, const std::string &output_dir = "", unsigned long random_number_seed = 1, const bool limit_debug_consistency_checks = false);
World(std::string filename, bool has_output_dir = false, const std::string &output_dir = "", unsigned long random_number_seed = 1, const bool limit_debug_consistency_checks = true);

/**
* Destructor
Expand Down
17 changes: 11 additions & 6 deletions source/gwb-dat/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ int main(int argc, char **argv)
unsigned int grain_compositions = 0;
size_t n_grains = 0;
bool convert_spherical = false;
bool limit_debug_consistency_checks = true;
bool limit_debug_consistency_checks = false;
bool output_json_files = false;

if (find_command_line_option(argv, argv+argc, "-h") || find_command_line_option(argv, argv+argc, "--help"))
{
Expand All @@ -85,7 +86,10 @@ int main(int argc, char **argv)
}

if (find_command_line_option(argv, argv+argc, "-ldcc") || find_command_line_option(argv, argv+argc, "--limit-debug-consistency-checks"))
limit_debug_consistency_checks = false;
limit_debug_consistency_checks = true;

if (find_command_line_option(argv, argv+argc, "--output-json-files"))
output_json_files = true;

if (argc == 1)
{
Expand All @@ -102,11 +106,12 @@ int main(int argc, char **argv)
return 0;
}

if ((argc == 3 && !limit_debug_consistency_checks) || argc > 4)
if ((argc == 3 && !(limit_debug_consistency_checks && output_json_files)) || (argc == 4 && !(!limit_debug_consistency_checks != !output_json_files)) || (argc == 5 && (!limit_debug_consistency_checks && !output_json_files)) || argc > 5)
{
std::cout << "Only exactly two command line arguments may be given, which should be the world builder file location and the data file location (in that order) "
<< "or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks (in that order). "
<< ", argc = " << argc << ", limit_debug_consistency_checks = " << (limit_debug_consistency_checks ? "true" : "false") << std::endl;
<< "or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks or --output-json-files (in that order),"
"or exactly four comman line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks and --output-json-files (in that order),"
<< ", argc = " << argc << ", limit_debug_consistency_checks = " << (limit_debug_consistency_checks ? "true" : "false") << ", output_json_files = " << (output_json_files ? "true" : "false") << std::endl;
return 0;
}

Expand All @@ -130,7 +135,7 @@ int main(int argc, char **argv)
//try
{
const std::string output_dir = wb_file.substr(0,wb_file.find_last_of("/\\") + 1);
world = std::make_unique<WorldBuilder::World>(wb_file, true, output_dir,1,limit_debug_consistency_checks);
world = std::make_unique<WorldBuilder::World>(wb_file, output_json_files, output_dir,1,limit_debug_consistency_checks);
}
/*catch (std::exception &e)
{
Expand Down
2 changes: 1 addition & 1 deletion source/world_builder/world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ namespace WorldBuilder
// We receive the cartesian points from the user.
const Point<3> point(point_,cartesian);
(void) this->limit_debug_consistency_checks;
WBAssert(!this->limit_debug_consistency_checks || this->parameters.coordinate_system->natural_coordinate_system() == cartesian
WBAssert(this->limit_debug_consistency_checks || this->parameters.coordinate_system->natural_coordinate_system() == cartesian
|| approx(depth, this->parameters.coordinate_system->max_model_depth()-sqrt(point_[0]*point_[0]+point_[1]*point_[1]+point_[2]*point_[2])),
"Inconsistent input. Please check whether the radius in the sperhical coordinates is consistent with the radius of the planet as defined "
<< "in the program that uses the Geodynamic World Builder. "
Expand Down
14 changes: 14 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,20 @@ IF(WB_RUN_APP_TESTS)
-D TEST_DIFF=${TEST_DIFF}
-P ${CMAKE_SOURCE_DIR}/tests/gwb-dat/run_gwb-dat_tests.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gwb-dat/)

# Add tests which generates the declarations and schema files in the docs folder. Do not care about the output.
set(TEST_ARGUMENTS "${CMAKE_SOURCE_DIR}/doc/generate_decl_schema.wb\;${CMAKE_SOURCE_DIR}/tests/gwb-dat/app_wb2.dat\;--output-json-files")
add_test(generate_declarations_and_schema
${CMAKE_COMMAND}
-D TEST_NAME=generate_declarations_and_schema
-D TEST_PROGRAM=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gwb-dat${CMAKE_EXECUTABLE_SUFFIX}
-D TEST_ARGS=${TEST_ARGUMENTS}
-D TEST_OUTPUT=${CMAKE_BINARY_DIR}/tests/gwb-dat/generate_declarations_and_schema/screen-output.log
-D TEST_REFERENCE=${CMAKE_CURRENT_SOURCE_DIR}/gwb-dat/generate_declarations_and_schema/screen-output.log
-D TEST_DIFF=${TEST_DIFF}
-P ${CMAKE_SOURCE_DIR}/tests/gwb-dat/run_gwb-dat_tests.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gwb-dat/)


#find all the integration test files
file(GLOB_RECURSE APP_TEST_SOURCES "gwb-dat/*.wb")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# x y z d g T c0 c1 c2 c3 c4
100e3 200e3 0 0 1600 0 0 0 0 0
120e3 550e3 0 0 1600 0 0 0 0 0
1500e3 1500e3 3 0 1600 0 0 0 0 0
2 changes: 1 addition & 1 deletion tests/gwb-dat/testing_too_many_arguments/screen-output.log
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Only exactly two command line arguments may be given, which should be the world builder file location and the data file location (in that order) or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks (in that order). , argc = 5, limit_debug_consistency_checks = true
Only exactly two command line arguments may be given, which should be the world builder file location and the data file location (in that order) or exactly three command line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks or --output-json-files (in that order),or exactly four comman line arguments, which should be the world builder file location, the data file location and --limit-debug-consistency-checks and --output-json-files (in that order),, argc = 5, limit_debug_consistency_checks = false, output_json_files = false
Loading