[Fortran] 纯文本查看 复制代码
module
type con_s
real :: divz(0:maxnz1)#####这里maxnz1=257
type(con_s), target :: c_s
real, pointer :: divz(:)
##############################
divz => c_s%divz
##############################
主程序中use module
call mpi_sum_z(divz(1),i_root,myid,nnz,1)####这里nnz=256
##############################
子程序
subroutine mpi_sum_z(f,i_root,myid,nsend,iall)
#--------- get sums on root or all processors
# for all z for vector f(i)
#
include 'mpif.h'
integer istatus(mpi_status_size)
real recv_b(nsend)
real f(nsend)
call mpi_reduce(f,recv_b,nsend,mpi_real8,mpi_sum,i_root,
& mpi_comm_world,ierr)
do i=1,nsend
f(i) = recv_b(i)
enddo
end
#######################################