I have a program where I am trying to gather up a set of data into an std::array however I cannot get this to work when the size of my array is set to the value of the world size. I get the following error:
MPITests.cpp:16:21: error: the value of ‘size’ is not usable in a constant expression 16 | std::array<int, size> gatheredRanks2; | ^~~~
here is a section of the relevant code:
int rank, size; MPI_Init(NULL, NULL); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); std::array<int, size> gatheredRanks2;
If I simply set the value of this size to a number the program works.
Is there a workaround for this?