Skip to content
Snippets Groups Projects
Commit 5255e1a7 authored by Nils-Arne Dreier's avatar Nils-Arne Dreier
Browse files

refactor(cmake): project structure

parent fc7fefee
No related branches found
No related tags found
No related merge requests found
......@@ -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/)
add_subdirectory(live/)
add_subdirectory(gridwriter/)
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)
......@@ -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
......
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)
......@@ -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
......
add_library(catalyst_adapter MODULE catalyst_adapter.cpp)
target_link_libraries(catalyst_adapter PRIVATE ComIn::ComIn catalyst::catalyst)
......@@ -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
......
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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment