Dear all,
A simple question, How to let a(:)=b(:)
without copying b to a? You know I just want b equivalent with a, but I do not want copy b to a, so that I should have better performance.
I am asking this because I have my MPI module for MPI program. I also have my Non-MPI module which is for non-MPI program. My MPI program and non-MPI program are the same, the only difference is this MPI and non-MPI module. So the non-MPI module have exactly the same subroutines and the interfaces as the MPI module, it just mimic mpirun -n 1 case, without installing any version of MPI.
Eg, one of my mpi_gather subroutine,
subroutine gatherr1d(r,rgather)
real(kind=r8) :: r(:),rgather(:)
integer :: ierror
call mpi_gather(r,size(r),mpir8,rgather,size(r),mpir8,0, &
mpi_comm_world,ierror)
return
end subroutine gatherr1d
Its non-MPI version is,
subroutine gatherr1d(r,rgather)
real(kind=r8) :: r(:),rgather(:)
integer :: ierror
rgather=r
return
However, it seems still need to copy r
to rgather
. From performance point of view, this may be not the most efficient. So I wonder, is there a way to let r
and rgather
are the same, you know so no need to copy r to rgather?
I know Fortran has something like equivalence
, does that prevent array copying? But the latest standard seems make it obsolete?
Thank you very much in advance!