parallel processing - Reshape an outer layer of a 3D array to 1D array -


i have 3d array, msh(0:m+1,0:n+1,0:l+1) representative of cartesian mesh grid. reshape outer layer 1d array. best way (efficient memory point of view)?

currently reshape plane plane starting -z,+z,:

array(1:m*n)=reshape(msh(1:m,1:n,0),m*n)    array(m*n+1:2*m*n)=reshape(msh(1:m,1:n,l+1),m*n)  

my first question weather reshaping being done in memory efficient way! or there other way using loop faster , more memory efficient (the size of arrays huge).

secondly, if have several of these arrays in different processors best way gather these outer layers in master node (e.g. rank=0) using mpi.

it's o(2*m*n+2*l*m+2*l*n) problem way it, one option series of loops:

allocate(array(2*m*n+2*l*m+2*l*n)) h = 1 j=1,n    i=1,m       array(h) = msh(i,j,0)       array(h+m*n+1) = msh(i,j,l+1)       h = h+1    enddo enddo k=1,l    i=1,m       array(h) = msh(i,0,k)       array(h+m*l+1) = msh(i,n+1,k)       h = h + 1    enddo enddo k=1,l    j=1,n       array(h) = msh(0,j,k)       array(h+l*n+1) = msh(m+1,j,k)       h = h + 1    enddo enddo 

then use normal mpi subroutines pass array master.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -