爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 4086|回复: 3

[求助] 帮忙看一下并行计算程序,跪谢!

[复制链接]

新浪微博达人勋

发表于 2012-6-7 21:06:55 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

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还变吗?如果变,为什么啊?小弟今天才接触并行计算,希望碰到大侠能拉我一把
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2012-6-7 21:47:46 | 显示全部楼层
要看你的subroutine是什么样的了
fortran是双向传递参数的
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2012-6-8 10:18:48 | 显示全部楼层
并行计算?貌似很深奥啊!!!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2012-6-18 19:15:25 | 显示全部楼层
111.jpg
假设chunksize=2,进程数为4,如上图,index应该是变了。
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表