/* This test case is based on the test-read-by-tag-name, and reads back the tags written by N procs in * test-nwrite.c use case. In this code N is tested for 4 ranks. Running test-nwrite.c followed by test-nWriteRead.c * is an example of parallel write (nonn-shared/overlapping handles or data) and sequential read by specifying tag name*/ #include #include #include #include #include #include #include "damsel.h" #include "damsel-internal.h" int main(int argc, char **argv) { short int data[5]; printf("%s\n", argv[0]); if(argc!=2) { printf("specify filename of .h5 dump file to check\n"); return 2; } int myrank; #ifndef DAMSEL_SINGLETHREAD int res; MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &res); assert(res == MPI_THREAD_MULTIPLE); #else MPI_Init(&argc, &argv); #endif MPI_Comm_rank (MPI_COMM_WORLD, &myrank); damsel_library lib; damsel_err_t err = DMSLlib_init(&lib); damsel_model model; err = DMSLmodel_create(DAMSEL_HANDLE_TYPE_HANDLE64, &model); assert(model != NULL); damsel_model_internal *ms = (damsel_model_internal *)model; assert(ms != NULL); damsel_trait_bundle tb; err = DMSLtrait_create(&tb); DMSLtrait_put(tb, "mode", "READ"); DMSLmodel_attach(model, argv[1], MPI_COMM_WORLD, tb); DMSLtrait_release(tb); DMSLmodel_populate(model); damsel_handle data_tag_handle = 1000; /* create a sequence of damsel handle collection with 10 handles in it. */ damsel_container block_collection_id; err = DMSLcontainer_create_sequence(model, 100, 5, 1, &block_collection_id); assert(block_collection_id != NULL); damsel_container tag_collection_id; err = DMSLcontainer_create_sequence(model, data_tag_handle, 1, 1, &tag_collection_id); assert(tag_collection_id != NULL); damsel_handle fileside_data_tag_handle; err = DMSLselect_tag_by_name(model, "SolData", &fileside_data_tag_handle); damsel_container file_tag_collection_id; err = DMSLcontainer_create_sequence((damsel_model)ms->attached_file, fileside_data_tag_handle, 1, 1, &file_tag_collection_id); DMSLmodel_map_handles(tag_collection_id, file_tag_collection_id); /* now set the values of the somedata tag on the handles */ DMSLmodel_map_tag(data, block_collection_id, &data_tag_handle); damsel_container filestore_block_collection_id = DMSLselect_handles_with_values(model, fileside_data_tag_handle); int flength = DMSLcontainer_count(filestore_block_collection_id); printf("expecting length 10, got length %d\n", flength); damsel_handle my_local_handles [5]; int cpos, gh=0; for(cpos = myrank*5; cpos<(myrank*5+5); cpos++) { printf("handle %d = %llx\n", cpos, DMSLcontainer_handle_at_position(filestore_block_collection_id, cpos)); my_local_handles[gh] = DMSLcontainer_handle_at_position(filestore_block_collection_id, cpos); gh++; } damsel_container local_container; err = DMSLcontainer_create_vector((damsel_model)ms->attached_file, my_local_handles, 5, &local_container); DMSLmodel_map_handles(block_collection_id, local_container);//filestore_block_collection_id); DMSLcontainer_release(filestore_block_collection_id); DMSLcontainer_release(local_container); damsel_request_t req; DMSLmodel_transfer_async(model, DAMSEL_TRANSFER_TYPE_READ, &req); damsel_status_t status; DMSLmodel_wait(req, &status); int ix; for(ix=0; ix<5; ix++) { printf("Reading value %d\n", data[ix]); } DMSLmodel_close(model); DMSLcontainer_close(block_collection_id); DMSLcontainer_close(tag_collection_id); DMSLcontainer_close(file_tag_collection_id); DMSLlib_finalize(lib); MPI_Finalize(); return 0; }