diff --git a/doc/generate_decl_schema.wb b/doc/generate_decl_schema.wb new file mode 100644 index 000000000..e5d14986a --- /dev/null +++ b/doc/generate_decl_schema.wb @@ -0,0 +1,4 @@ +{ + "version": "0.6", + "features": [] +} \ No newline at end of file diff --git a/doc/sphinx/GWB_parameter_listings/world_builder_file/index.md b/doc/sphinx/GWB_parameter_listings/world_builder_file/index.md index 668f3f633..ce0d0d098 100644 --- a/doc/sphinx/GWB_parameter_listings/world_builder_file/index.md +++ b/doc/sphinx/GWB_parameter_listings/world_builder_file/index.md @@ -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 :::: ::::: diff --git a/tests/gwb-dat/world_builder_declarations.schema.json b/doc/world_builder_declarations.schema.json similarity index 99% rename from tests/gwb-dat/world_builder_declarations.schema.json rename to doc/world_builder_declarations.schema.json index 0100a9c3f..2f5b5d5d6 100644 --- a/tests/gwb-dat/world_builder_declarations.schema.json +++ b/doc/world_builder_declarations.schema.json @@ -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." }, @@ -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." }, @@ -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." }, @@ -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." }, diff --git a/tests/gwb-dat/world_builder_declarations_closed.md b/doc/world_builder_declarations_closed.md similarity index 100% rename from tests/gwb-dat/world_builder_declarations_closed.md rename to doc/world_builder_declarations_closed.md diff --git a/tests/gwb-dat/world_builder_declarations_open.md b/doc/world_builder_declarations_open.md similarity index 100% rename from tests/gwb-dat/world_builder_declarations_open.md rename to doc/world_builder_declarations_open.md diff --git a/include/world_builder/world.h b/include/world_builder/world.h index 246ef2f91..fa0c41bfd 100644 --- a/include/world_builder/world.h +++ b/include/world_builder/world.h @@ -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 diff --git a/source/gwb-dat/main.cc b/source/gwb-dat/main.cc index e8ed6cb5d..c1a25ba85 100644 --- a/source/gwb-dat/main.cc +++ b/source/gwb-dat/main.cc @@ -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")) { @@ -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) { @@ -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; } @@ -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(wb_file, true, output_dir,1,limit_debug_consistency_checks); + world = std::make_unique(wb_file, output_json_files, output_dir,1,limit_debug_consistency_checks); } /*catch (std::exception &e) { diff --git a/source/world_builder/world.cc b/source/world_builder/world.cc index 5794411e2..54a61af17 100644 --- a/source/world_builder/world.cc +++ b/source/world_builder/world.cc @@ -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. " diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 068b347ec..afdf0fd91 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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") diff --git a/tests/gwb-dat/generate_declarations_and_schema/screen-output.log b/tests/gwb-dat/generate_declarations_and_schema/screen-output.log new file mode 100644 index 000000000..4b82221cf --- /dev/null +++ b/tests/gwb-dat/generate_declarations_and_schema/screen-output.log @@ -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 diff --git a/tests/gwb-dat/testing_too_many_arguments/screen-output.log b/tests/gwb-dat/testing_too_many_arguments/screen-output.log index 732f9115e..a7d3c9dd9 100644 --- a/tests/gwb-dat/testing_too_many_arguments/screen-output.log +++ b/tests/gwb-dat/testing_too_many_arguments/screen-output.log @@ -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