- 积分
- 385
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-11-4
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
下面是其中一段:
index = 1
do 30 dest=1, numworkers
write(*,*) 'Sending to worker task', dest
C *--------------------------------------------------------------------->
C *--->Send index so each process knows where to start in the data array
C *--------------------------------------------------------------------->
call MPI_SEND(index, 1, MPI_INTEGER, dest, indexmsg,
& MPI_COMM_WORLD, ierr)
C *-------------------------------------------------------------->
C *--->Send chunksize bit of data starting at the index position.
C *-------------------------------------------------------------->
call MPI_SEND(data(index), chunksize, MPI_REAL, dest, arraymsg,
& MPI_COMM_WORLD, ierr )
index = index + chunksize
30 continue
C *------------------------------------------------------------------->
C *---> Wait to get back the results from workers & print a few values
C *------------------------------------------------------------------->
do 40 i=1, numworkers
source = i
C *------------------------------------------------------------------------->
C *---> Receive the index position of the chunk this process was working on.
C *------------------------------------------------------------------------->
call MPI_RECV(index, 1, MPI_INTEGER, source, indexmsg,
& MPI_COMM_WORLD, status, ierr)
C *--------------------------------------------------------->
C *---> Receive chunksize bit of data for the results array.
C *--------------------------------------------------------->
call MPI_RECV(result(index), chunksize, MPI_REAL, source,
& arraymsg, MPI_COMM_WORLD, status, ierr)
print *, '---------------------------------------------------'
print *, 'MASTER: Sample results from worker task ', source
print *, ' result[', index, ']=', result(index)
print *, ' result[', index+100, ']=', result(index+100)
print *, ' result[', index+1000, ']=', result(index+1000)
print *, ' '
40 continue
print *, 'MASTER: All Done!'
endif
请问红色部分中的index还变吗?如果变,为什么啊?小弟今天才接触并行计算,希望碰到大侠能拉我一把 |
|