t*****o 发帖数: 74 | 1 情况如下:
only two nodes
0 node: a = 0.3
1 node: a = 0.1
use MPI_Allreduce(a, a_temp, 1, MPI_REAL ... )
Fortran中如果我用缺省的mpif77编译, 结果没有问题, 能得到a_temp = 0.4
但是real精度不高, 我那个程序精度大概10负4次方左右, 为了提高精度, 我用
mpif77 -r8 编译, 问题是得到的a_temp = 56.8....
我用
call MPI_Allreduce(a, a_temp, 2, MPI_REAL ... ) 结果同上
用
call MPI_Allreduce(a, a_temp, 1, MPI_DOUBLE_PRECISION ... ) 运行报错,
说什么NULL communicator
搞不清楚数据是怎么传输和存储的了!!!
哪位大侠有这方面的经验? 万分感谢! | a******s 发帖数: 232 | 2 这个和我有关,回头看看
【在 t*****o 的大作中提到】 : 情况如下: : only two nodes : 0 node: a = 0.3 : 1 node: a = 0.1 : use MPI_Allreduce(a, a_temp, 1, MPI_REAL ... ) : Fortran中如果我用缺省的mpif77编译, 结果没有问题, 能得到a_temp = 0.4 : 但是real精度不高, 我那个程序精度大概10负4次方左右, 为了提高精度, 我用 : mpif77 -r8 编译, 问题是得到的a_temp = 56.8.... : 我用 : call MPI_Allreduce(a, a_temp, 2, MPI_REAL ... ) 结果同上
| a******s 发帖数: 232 | 3 用-r8编译的话,需要用MPI_DOUBLE_PRECISION,不用-r8的话,用MPI_REAL,
哎,都是废话,想想都知道:(
【在 t*****o 的大作中提到】 : 情况如下: : only two nodes : 0 node: a = 0.3 : 1 node: a = 0.1 : use MPI_Allreduce(a, a_temp, 1, MPI_REAL ... ) : Fortran中如果我用缺省的mpif77编译, 结果没有问题, 能得到a_temp = 0.4 : 但是real精度不高, 我那个程序精度大概10负4次方左右, 为了提高精度, 我用 : mpif77 -r8 编译, 问题是得到的a_temp = 56.8.... : 我用 : call MPI_Allreduce(a, a_temp, 2, MPI_REAL ... ) 结果同上
| t*****o 发帖数: 74 | 4 thanks a lot!
but I already tried MPI_DOUBLE_PRECISION, and got an error message: NULL
communicator ...... Thanks anyway.
【在 a******s 的大作中提到】 : 用-r8编译的话,需要用MPI_DOUBLE_PRECISION,不用-r8的话,用MPI_REAL, : 哎,都是废话,想想都知道:(
| a******s 发帖数: 232 | 5 try a simple code and you will know. Unless you post your code,nobody will
know where the error is.
【在 t*****o 的大作中提到】 : thanks a lot! : but I already tried MPI_DOUBLE_PRECISION, and got an error message: NULL : communicator ...... Thanks anyway.
| t*****o 发帖数: 74 | 6 ok, here is the code
include "mpif.h"
c
parameter ( MAX = 100 )
integer myid, numprocs, ierr
integer mstatus(MPI_STATUS_SIZE)
real a(MAX), b(MAX)
c ======= MPI initialization
call MPI_INIT( ierr )
call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
call MPI_COMM_RANK( MPI_COMM_WORLD, myid, ierr )
n = 5
c --- initialize array
do i = 1, n
a(i) = myid*1. + (i-1)*0.01
end do
c --- print out for checkin
【在 a******s 的大作中提到】 : try a simple code and you will know. Unless you post your code,nobody will : know where the error is.
| a******s 发帖数: 232 | 7 下次编程序的时候小心点,hoho,你这错误简直太弱了。你仔细看你的code
10遍,就看出来了。
我已经调出来了,你自己先看看,看不出来,我再告诉你。:)
【在 t*****o 的大作中提到】 : ok, here is the code : include "mpif.h" : c : parameter ( MAX = 100 ) : integer myid, numprocs, ierr : integer mstatus(MPI_STATUS_SIZE) : real a(MAX), b(MAX) : c ======= MPI initialization : call MPI_INIT( ierr ) : call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
| a******s 发帖数: 232 | 8 是语法错,和MPI没有关系,我开始编译你的code,执行也错,但是看看
出错信息就知道大概了,仔细看语法,谁都能看出来。
【在 t*****o 的大作中提到】 : ok, here is the code : include "mpif.h" : c : parameter ( MAX = 100 ) : integer myid, numprocs, ierr : integer mstatus(MPI_STATUS_SIZE) : real a(MAX), b(MAX) : c ======= MPI initialization : call MPI_INIT( ierr ) : call MPI_COMM_SIZE( MPI_COMM_WORLD, numprocs, ierr )
| h***o 发帖数: 539 | 9 dd....调戏人家twoxiao dd....hoho
【在 a******s 的大作中提到】 : 是语法错,和MPI没有关系,我开始编译你的code,执行也错,但是看看 : 出错信息就知道大概了,仔细看语法,谁都能看出来。
| h***o 发帖数: 539 | 10 btw....现在fortran77都支持do... end do了?啥编译器都认吗?
我还在
do 10 i = 1, n
......
10 continue
oh....还有,twoxiao 是不是落了一逗号呀
【在 h***o 的大作中提到】 : dd....调戏人家twoxiao dd....hoho
| a******s 发帖数: 232 | 11 就是阿,这个语法错我总觉得是最低级的错,又不是啥大程序,有时候不好定位,
这个程序,多看几眼就出来了,我就不说了。
fortran77只是个规范,不会变的,但是现在我相信所有的编译器都支持
do..enddo,但是也不说明fortran77支持。如果你用ifc7.1的话,如果
用do 10 ...10 continue的话,编译时候不带-w的话,还提示语法过时呢,
现在ifort都给省了,编译缺省级别不同了。
有时候还是do 10这样好,看着清晰,要不enddo太多了,分不清end是哪儿个do了。:)
【在 h***o 的大作中提到】 : btw....现在fortran77都支持do... end do了?啥编译器都认吗? : 我还在 : do 10 i = 1, n : ...... : 10 continue : oh....还有,twoxiao 是不是落了一逗号呀
| t*****o 发帖数: 74 | 12 thanks achillis and hanzo
语法错误, 编译居然能通过。。。 一直没想到这方面出
will
【在 a******s 的大作中提到】 : 是语法错,和MPI没有关系,我开始编译你的code,执行也错,但是看看 : 出错信息就知道大概了,仔细看语法,谁都能看出来。
| t*****o 发帖数: 74 | 13 FT, 居然还DD了, 一般, 大家都叫我 ‘德高望重’的老\同学....
在只有几行的情况下, 我一般用do ... end do
比较大的do loop还是用数字的. HOHO
好象不是所有的F77都支持do...end do, 不过比较新的编译器好象支持
【在 h***o 的大作中提到】 : btw....现在fortran77都支持do... end do了?啥编译器都认吗? : 我还在 : do 10 i = 1, n : ...... : 10 continue : oh....还有,twoxiao 是不是落了一逗号呀
|
|