/*Simple test to let root write metadata to the file, while rest of the processes only write data to the assigned handles*/ //#include "test-flash-parallel.h" #include #include "damsel-hdf5.h" #include "damsel.h" #include "damsel-internal.h" #include "damsel-ndc.h" #include "damsel-debug.h" #include "damsel-connectivity.h" #include "damsel-types.h" #include "damsel-sugar.h" #include #include #define FILENAME "output/newflash.h5" #define MAX_BLOCKS 10 #define LOCAL_BLOCKS 5 double block_coords[][2] = { {0.0, 0.1}, {0.0, 0.2}, {0.0, 0.3}, {0.0, 0.4}, {0.0, 0.5}, {0.0, 0.6}, {0.0, 0.7}, {0.0, 0.8}, {0.0, 0.9}, {0.0, 0.10}, {0.0, 0.11}, {0.0, 0.12}, {0.0, 0.13}, {0.0, 0.14}, {0.0, 0.15}, {0.0, 0.16}, {0.0, 0.17} }; int unk[5][24]; damsel_handle define_coords(damsel_model model, damsel_container container, damsel_data_type array_type); damsel_handle define_data(damsel_model model, damsel_container container, damsel_data_type array_type); damsel_handle define_coords(damsel_model model, damsel_container container, damsel_data_type array_type) { damsel_handle coord_tag_handle = 10004; DMSLtag_define(model, &coord_tag_handle, array_type, "coordinates"); DMSLmodel_map_tag(block_coords, container, &coord_tag_handle); return coord_tag_handle; } damsel_handle define_data(damsel_model model, damsel_container container, damsel_data_type array_type){ damsel_handle unk_tag_handle = 10000; DMSLtag_define(model, &unk_tag_handle, array_type, "UNK"); int i, j; for(i=0;i<5;i++){ for(j=0;j<24;j++) printf("%d\t", unk[i][j]); //solution data array, considering one variable and 2D data here printf("\n"); } DMSLmodel_map_tag(unk, container, &unk_tag_handle); return unk_tag_handle; } /*Main Function*/ int main(int argc, char **argv) { int res, myrank, num_procs; #ifndef DAMSEL_SINGLETHREAD 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); MPI_Comm_size (MPI_COMM_WORLD, &num_procs); 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); size_t coords_array_dim[1] = {2}; damsel_data_type coords_array_type = DMSLtype_array_create(DAMSEL_DATA_TYPE_DOUBLE, 1, coords_array_dim); size_t unk_array_dim[] = {24}; damsel_data_type unk_array_type = DMSLtype_array_create(DAMSEL_DATA_TYPE_DOUBLE, 1, unk_array_dim); int i, j; for(i=0;i<5;i++){ for(j=0;j<24;j++) unk[i][j]=i+j; //solution data array, considering one variable and 2D data here } damsel_handle block_id [10]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; damsel_container block_collection_id; err = DMSLcontainer_create_vector(model, block_id, 10, &block_collection_id); //assuming these are application handles? damsel_container block_handle_collection_id; err = DMSLcontainer_create_sequence(model, 200, 10, 1, &block_handle_collection_id); //these are the handles for entities? Whats the difference between application handes and e.g. vertex handles in entity_define function. DMSLentity_define(block_collection_id, DAMSEL_ENTITY_TYPE_VERTEX, 1, block_handle_collection_id); damsel_handle coord_tag_handle; /*Setting coordinates tag data on the handle container of vertices*/ if (myrank == 0) coord_tag_handle = define_coords(model, block_collection_id, coords_array_type); damsel_handle local_block_id[5]; if(myrank == 0) { for (i=0;i<5;i++) local_block_id[i] = block_id[5+i]; } else { for (i=0;i<5;i++) local_block_id[i] = block_id[i]; } damsel_handle unk_tag_handle; damsel_container local_block_collection_id; err = DMSLcontainer_create_vector(model, local_block_id, 5, &local_block_collection_id); if(myrank == 1) unk_tag_handle = define_data(model, local_block_collection_id, unk_array_type); unlink(FILENAME); damsel_trait_bundle tb; err = DMSLtrait_create(&tb); DMSLtrait_put(tb, "mode", "WRITE"); #ifdef DAMSEL_SUBFILE DMSLtrait_put(tb, "dmsl_num_subfiles", "2"); #endif DMSLmodel_attach(model, FILENAME, MPI_COMM_WORLD, tb); DMSLtrait_release(tb); //if(myrank == 0) { DMSLmodel_map_handles_inventing_file_handles(block_collection_id); DMSLmodel_map_handles_inventing_file_handles(block_handle_collection_id); if(myrank == 0) { DMSLmodel_map_single_handle_inventing_file_handle(model, coord_tag_handle); } if(myrank==1) DMSLmodel_map_single_handle_inventing_file_handle(model, unk_tag_handle); damsel_request_t req; DMSLmodel_transfer_async(model, DAMSEL_TRANSFER_TYPE_WRITE, &req); damsel_status_t status; DMSLmodel_wait(req, &status); DMSLmodel_close(model); DMSLcontainer_close(block_collection_id); DMSLcontainer_close(block_handle_collection_id); DMSLcontainer_close(local_block_collection_id); DMSLlib_finalize(lib); MPI_Finalize(); return 0; }