diff --git a/CMakeLists.txt b/CMakeLists.txt index ed252ac9de47b913582dff7294f4e57ca3cb443b..902248c614476183b27928fad47da71435966add 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,25 +14,6 @@ endif() find_package(catalyst 2.0 REQUIRED) find_package(ComIn REQUIRED) -add_library(catalyst_adapter MODULE catalyst_adapter.cpp) -target_link_libraries(catalyst_adapter PRIVATE ComIn::ComIn catalyst::catalyst) - - -if(BUILD_TESTING) - comin_add_replay_data( - NAME test_nwp_R02B04_R02B05_nest - URL "https://gitlab.dkrz.de/api/v4/projects/139706/packages/generic/test_nwp_R02B04_R02B05_nest/1/test_nwp_R02B04_R02B05_nest.tar.gz" - MD5HASH 103c0b673fbef0bc07c567b7f3acf975) - - comin_add_replay_test(NAME catalyst_test - REPLAY_DATA "test_nwp_R02B04_R02B05_nest" - NUM_PROCS 3 - ) - - comin_test_add_plugin(TEST catalyst_test - NAME "catalyst_adapter" - PLUGIN_LIBRARY "$<TARGET_FILE:catalyst_adapter>" - OPTIONS "/home/nils/projects/comin/catalyst_adaptor/pvExample.py" - # OPTIONS "/home/nils/projects/comin/catalyst_adaptor/gridwriter.py" - ) -endif() +add_subdirectory(src/) +add_subdirectory(test/) +add_subdirectory(pipelines/) diff --git a/pipelines/CMakeLists.txt b/pipelines/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..34c110fb8bd55aaf0f5f199e9b224e5c1317ffb8 --- /dev/null +++ b/pipelines/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(live/) +add_subdirectory(gridwriter/) diff --git a/pipelines/gridwriter/CMakeLists.txt b/pipelines/gridwriter/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..922bacc0ed22cd013b32d1f45d146ce459b2cdfd --- /dev/null +++ b/pipelines/gridwriter/CMakeLists.txt @@ -0,0 +1,20 @@ +set(REPLAY_DATA_NAME "test_nwp_R02B04_R02B05_nest") +get_target_property(REPLAY_DATA_PATH "download_replay_data_${REPLAY_DATA_NAME}" DATA_DIRECTORY) +file(GENERATE OUTPUT master.nml + CONTENT "&comin_nml + plugin_list(1)%name = \"comin_var_replay_plugin\" + plugin_list(1)%plugin_library = \"$<TARGET_FILE:ComIn::comin_var_replay_plugin>\" + plugin_list(1)%options = \"${REPLAY_DATA_PATH}/vars_\" + plugin_list(2)%name = \"catalyst_adapter\" + plugin_list(2)%plugin_library = \"${PROJECT_BINARY_DIR}/src/libcatalyst_adapter.so\" + plugin_list(2)%options = \"${CMAKE_CURRENT_SOURCE_DIR}/gridwriter.py\" +/ +") +file(GENERATE OUTPUT run.sh + CONTENT "#!/bin/sh +cmake --build . --target \"download_replay_data_${REPLAY_DATA_NAME}\" +cd ${CMAKE_CURRENT_BINARY_DIR} +set -e +${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 3 \"$<TARGET_FILE:ComIn::comin_replay>\" \"${REPLAY_DATA_PATH}/\" +" +FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) diff --git a/gridwriter.py b/pipelines/gridwriter/gridwriter.py similarity index 88% rename from gridwriter.py rename to pipelines/gridwriter/gridwriter.py index 1a339fb758d1dfb4a644e5a27d5b37a35343041a..a3e8c77e7e8c75ca68cc72cb6f56463b0f5c5768 100644 --- a/gridwriter.py +++ b/pipelines/gridwriter/gridwriter.py @@ -7,7 +7,7 @@ # Input parameters #--------------------------------------------------------- # Specify the Catalyst channel name -catalystChannel = "domain1" +catalystChannel = "2d_domain1" # Specify the write frequency frequency = 1 @@ -54,10 +54,15 @@ def create_extractor(data): # Pipeline -data = TrivialProducer(registrationName=catalystChannel) +domain1 = TrivialProducer(registrationName=catalystChannel) + +lonlat2sphere = '-1*sin(coordsX)*cos(coordsY)*iHat+cos(coordsX)*cos(coordsY)*jHat+sin(coordsY)*kHat' +calculator1 = Calculator(registrationName='Calculator1', Input=domain1) +calculator1.CoordinateResults = 1 +calculator1.Function = lonlat2sphere # Returns extractor type based on data (or you can manually specify -extractor = create_extractor(data) +extractor = create_extractor(calculator1) # ------------------------------------------------------------------------------ # Catalyst options diff --git a/pipelines/live/CMakeLists.txt b/pipelines/live/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1a4c5eedf8c347db990c5a71a451910c9d5fb5ed --- /dev/null +++ b/pipelines/live/CMakeLists.txt @@ -0,0 +1,20 @@ +set(REPLAY_DATA_NAME "test_nwp_R02B04_R02B05_nest") +get_target_property(REPLAY_DATA_PATH "download_replay_data_${REPLAY_DATA_NAME}" DATA_DIRECTORY) +file(GENERATE OUTPUT master.nml + CONTENT "&comin_nml + plugin_list(1)%name = \"comin_var_replay_plugin\" + plugin_list(1)%plugin_library = \"$<TARGET_FILE:ComIn::comin_var_replay_plugin>\" + plugin_list(1)%options = \"${REPLAY_DATA_PATH}/vars_\" + plugin_list(2)%name = \"catalyst_adapter\" + plugin_list(2)%plugin_library = \"${PROJECT_BINARY_DIR}/src/libcatalyst_adapter.so\" + plugin_list(2)%options = \"${CMAKE_CURRENT_SOURCE_DIR}/live.py\" +/ +") +file(GENERATE OUTPUT run.sh + CONTENT "#!/bin/sh +cmake --build . --target \"download_replay_data_${REPLAY_DATA_NAME}\" +cd ${CMAKE_CURRENT_BINARY_DIR} +set -e +${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 3 \"$<TARGET_FILE:ComIn::comin_replay>\" \"${REPLAY_DATA_PATH}/\" +" +FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) diff --git a/pvExample.py b/pipelines/live/live.py similarity index 91% rename from pvExample.py rename to pipelines/live/live.py index 255ed2f525c8745aa7bf7934c454bcc1b9f2ce35..a1eccee62a603d1954598e69eb0e0171ea13d41e 100644 --- a/pvExample.py +++ b/pipelines/live/live.py @@ -12,13 +12,13 @@ options.CatalystLiveTrigger = 'TimeStep' lonlat2sphere = '-1*sin(coordsX)*cos(coordsY)*iHat+cos(coordsX)*cos(coordsY)*jHat+sin(coordsY)*kHat' -domain1 = TrivialProducer(registrationName='domain1') +domain1 = TrivialProducer(registrationName='2d_domain1') calculator1 = Calculator(registrationName='Calculator1', Input=domain1) calculator1.CoordinateResults = 1 calculator1.Function = lonlat2sphere calculator1Display = Show(calculator1) -domain2 = TrivialProducer(registrationName='domain2') +domain2 = TrivialProducer(registrationName='2d_domain2') calculator2 = Calculator(registrationName='Calculator2', Input=domain2) calculator2.CoordinateResults = 1 calculator2.Function = lonlat2sphere diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c1ce8c3f69d0323addec122a44b11167c35643b0 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(catalyst_adapter MODULE catalyst_adapter.cpp) +target_link_libraries(catalyst_adapter PRIVATE ComIn::ComIn catalyst::catalyst) diff --git a/catalyst_adapter.cpp b/src/catalyst_adapter.cpp similarity index 96% rename from catalyst_adapter.cpp rename to src/catalyst_adapter.cpp index ace9e7ddc115381a70f19d628458f884cca541ad..0dd235d009b57d38de0fcf02f4001630c979cd63 100644 --- a/catalyst_adapter.cpp +++ b/src/catalyst_adapter.cpp @@ -5,7 +5,6 @@ #include <comin.h> #include <catalyst.hpp> -int ierr = COMIN_SUCCESS; void catalyst_adapter_secondary_constructor(); void catalyst_adapter_execute(); void catalyst_adapter_destruct(); @@ -19,7 +18,7 @@ extern "C"{ // avoid name-mangling const char* script_file = NULL; int script_file_len; - comin_current_get_plugin_options(&script_file, &script_file_len, &ierr); + comin_current_get_plugin_options(&script_file, &script_file_len); catalyst_init_params["catalyst/scripts/script/filename"] = std::string(script_file, script_file_len); catalyst_status err = catalyst_initialize(conduit_cpp::c_node(&catalyst_init_params)); @@ -34,9 +33,9 @@ extern "C"{ // avoid name-mangling } about_node.print(); - comin_callback_register(EP_SECONDARY_CONSTRUCTOR, catalyst_adapter_secondary_constructor, &ierr); - comin_callback_register(EP_ATM_WRITE_OUTPUT_BEFORE, catalyst_adapter_execute, &ierr); - comin_callback_register(EP_DESTRUCTOR, catalyst_adapter_destruct, &ierr); + comin_callback_register(EP_SECONDARY_CONSTRUCTOR, catalyst_adapter_secondary_constructor); + comin_callback_register(EP_ATM_WRITE_OUTPUT_BEFORE, catalyst_adapter_execute); + comin_callback_register(EP_DESTRUCTOR, catalyst_adapter_destruct); } } @@ -45,7 +44,7 @@ void catalyst_adapter_secondary_constructor(){ // prepare the execute node for(int jg = 1; jg<=comin_descrdata_get_global_n_dom(); ++jg){ std::cout << "dom: " << jg << std::endl; - auto channel = catalyst_exec_params[std::string("catalyst/channels/domain")+std::to_string(jg)]; + auto channel = catalyst_exec_params[std::string("catalyst/channels/2d_domain")+std::to_string(jg)]; // now, create the mesh. channel["type"] = "mesh"; @@ -84,9 +83,9 @@ void catalyst_adapter_secondary_constructor(){ it != nullptr; it = comin_var_get_descr_list_next(it)){ t_comin_var_descriptor var_desc; - comin_var_get_descr_list_var_desc(it, &var_desc, &ierr); + comin_var_get_descr_list_var_desc(it, &var_desc); int zaxis_id = -1; - comin_metadata_get_integer(var_desc, "zaxis_id", &zaxis_id, &ierr); + comin_metadata_get_integer(var_desc, "zaxis_id", &zaxis_id); if(var_desc.id == jg && zaxis_id == COMIN_ZAXIS_2D){ // TODO split tracers in separate arrays diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a6b73c24320abb5bc01a1de187f37a93d102634d --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,12 @@ +if(BUILD_TESTING) + comin_add_replay_test(NAME catalyst_test + REPLAY_DATA "test_nwp_R02B04_R02B05_nest" + NUM_PROCS 3 + ) + + comin_test_add_plugin(TEST catalyst_test + NAME "catalyst_adapter" + PLUGIN_LIBRARY "$<TARGET_FILE:catalyst_adapter>" + OPTIONS "/home/nils/projects/comin/catalyst_adaptor/pvExample.py" + ) +endif()