正在加载图片...
printf("cant start hello other \n); vm exito node程序 hello other. c* #include"pvm. h # include“ string. h ptid char buf[100] ptid=pvm parentO; strcpy (buf, "hello, world from) gethostname( buf+strlen(buf), 64) pvm initsend( PvmDataDefault) pvm pkstr(buf) pvm send(ptid, 1) pvm exito 4、计算兀可以通过MP程序。为了加深读者对MP的学习和理解,下面给出用 FORTRAN 90语言的实现版本。试分析其工作过程。 计算丌的MPI(F90)编程代码段*∥ program main ulse mpl double precision P125DT parameter(PI25DI=3.141592653589793238462643d0 double precision mypi, pi, h, sum, x, f, a integer n, myid, numprocs, i, rc function to integrate f(a)=4d0/(1.d0+aa) all MPI INIT(ierr) all MPI COMM RANK(MPI COMM WORLD id. ierr) call MPI COMM SIZE(MPI COMM WORLD, numprocs, ierr) print*, process, myid, of', numprocs, "is alive if(myid. eq O)then wite(6,98) format("Enter the number of intervals: (0 quit)) read(, 99)nprintf(“can’t start hello_other \n”); pvm_exit(); } /*node 程序 hello_other.c*/ #include “pvm3.h” #include “string.h” main() { int ptid; char buf[100]; ptid=pvm_parent(); strcpy(buf, “hello, world from”); gethostname(buf+strlen(buf), 64); pvm_initsend(PvmDataDefault); pvm_pkstr(buf); pvm_send(ptid, 1); pvm_exit(); exit(0); } 4、计算 π 可以通过 MPI 程序。为了加深读者对 MPI 的学习和理解,下面给出用 FORTRAN 90 语言的实现版本。试分析其工作过程。 //*计算 π 的 MPI(F90)编程代码段*// program main use mpi double precision PI25DT parameter (PI25DT=3.141592653589793238462643d0) double precision mypi, pi, h, sum, x, f, a integer n, myid, numprocs, i, rc ! function to integrate f(a) = 4.d0/(1.d0+a*a) call MPI_INIT(ierr) call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierr) call MPI_COMM_SIZE(MPI_COMM_WORLD, numprocs, ierr) print *, ‘process’, myid, ‘of’, numprocs, ‘is alive’ sizetype=1 sumtype=2 do if (myid.eq.0) then write(6, 98) 98 format(‘Enter the number of intervals: (0 quit)’) read(5, 99)n
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有