w**d 发帖数: 2334 | 1 Anybody knows how to write a Fortran 77 code runnable under
compaq fortran and sun-workstation?
Our dept bought two compaq machines. They are oveloaded. So I tried
to run my code under a sun-workstation. It gives me "bus error".
It really puzzles me. Thanks in advance. |
n*c 发帖数: 5 | 2 Oh, man, did you compile your source code on the sun machine?
Fortran does not seem to have many troubles working in different
platforms, if the compilcation has passed.
【在 w**d 的大作中提到】 : Anybody knows how to write a Fortran 77 code runnable under : compaq fortran and sun-workstation? : Our dept bought two compaq machines. They are oveloaded. So I tried : to run my code under a sun-workstation. It gives me "bus error". : It really puzzles me. Thanks in advance.
|
w**d 发帖数: 2334 | 3 I did recompile all my codes. Only a couple of warnings about
nonused local variables. I dont think it is the problem.
Thanks anyway.
【在 n*c 的大作中提到】 : Oh, man, did you compile your source code on the sun machine? : Fortran does not seem to have many troubles working in different : platforms, if the compilcation has passed.
|
f****r 发帖数: 27 | 4 You'd better check your array size. It sounds like an out-of-boundary error.
【在 w**d 的大作中提到】 : I did recompile all my codes. Only a couple of warnings about : nonused local variables. I dont think it is the problem. : Thanks anyway.
|
w**d 发帖数: 2334 | 5 The array is small. The codes only take around 20M memory.
I found out what caused the problem, but don't know why.
Whenever I declare an array like a(0:node) in a subroutine
with node being passed from other subroutines or main, there will
be bus error.
But if I declare a(node) or a(0:node) with node being given in the
current subroutine, it works fine.
【在 f****r 的大作中提到】 : You'd better check your array size. It sounds like an out-of-boundary error.
|
w**d 发帖数: 2334 | 6 I did the test with the code written a few years ago. It gives the same probelm
. But it worked before. So weird.
【在 w**d 的大作中提到】 : The array is small. The codes only take around 20M memory. : I found out what caused the problem, but don't know why. : Whenever I declare an array like a(0:node) in a subroutine : with node being passed from other subroutines or main, there will : be bus error. : But if I declare a(node) or a(0:node) with node being given in the : current subroutine, it works fine.
|
w**d 发帖数: 2334 | 7 Any comments?
【在 w**d 的大作中提到】 : I did the test with the code written a few years ago. It gives the same probelm : . But it worked before. So weird.
|
x*y 发帖数: 364 | 8 It's weird. I also have array declared as a(0:node) and passed around several
subroutines. It works fine on sun machine.
probelm
【在 w**d 的大作中提到】 : Any comments?
|
w**d 发帖数: 2334 | 9 it IS weird. A few years ago, there was no such problem. I don't know if
they change anything on those machines.
【在 x*y 的大作中提到】 : It's weird. I also have array declared as a(0:node) and passed around several : subroutines. It works fine on sun machine. : : probelm
|
l**g 发帖数: 5 | 10 "If a program gets a bus error (SIGBUS), it usually has some problems with
misaligned data."
可能是caller传递的数组的类型和subroutine中的数组a的类型不一致引起的。
比如说前者是byte,a是word.如果a(i)的地址没对齐成奇数就有bus error。
这大概是自动数组a(0:node)和a(1:node)结果不同的原因。
去年为什么可以?也许今年f77升级,default不一样了;
或者有其它影响complier行为的原因。参考:
Bus Error--Finding the Line Number
http://docs.sun.com/db/doc/802-2997/6i6u2n7rt?a=view#07.Debugging-27
several
【在 w**d 的大作中提到】 : it IS weird. A few years ago, there was no such problem. I don't know if : they change anything on those machines.
|
w**d 发帖数: 2334 | 11 I asked the same problem on a Fortran newsgroup. Somebody suspected it might
be caused by a compiler bug. I don't know what that means.
That guy also thinks I used F90 compiler. He said the automatic array is
illegal in F77.
Then another guy suggests me to do as follows:
program main
real*8 a(0:10)
call sub(a)
end
subroutine sub(b)
real*8 b(*)
b(0) = 7
end
It is just like those subroutines in Lapack. But there are lots of
work arrays in my code, I don't know how realistic this way is.
【在 l**g 的大作中提到】 : "If a program gets a bus error (SIGBUS), it usually has some problems with : misaligned data." : 可能是caller传递的数组的类型和subroutine中的数组a的类型不一致引起的。 : 比如说前者是byte,a是word.如果a(i)的地址没对齐成奇数就有bus error。 : 这大概是自动数组a(0:node)和a(1:node)结果不同的原因。 : 去年为什么可以?也许今年f77升级,default不一样了; : 或者有其它影响complier行为的原因。参考: : Bus Error--Finding the Line Number : http://docs.sun.com/db/doc/802-2997/6i6u2n7rt?a=view#07.Debugging-27 :
|
l**g 发帖数: 5 | 12 1。这里应该有错:
real*8 b(*) == real*8 b(1:)
所以这里 b(0) 是 bound violation,a(0)的值并不会改变。
2。我觉得你的程序是不是不自觉地引用指针,引起内存访问出错。比如
subroutine sub(b1,N)
real*8 b1(0:N)
b(0) = 7
end
subroutine sub(N)
real*8 b2(0:N)
b(0) = 7
end
其中b1是双精度数组;但fortran把b2解释为local指针数组,指向double.
前者是对的,后者就会出错。
命令g77/f77执行的可能是f90 或 f95
if
【在 w**d 的大作中提到】 : I asked the same problem on a Fortran newsgroup. Somebody suspected it might : be caused by a compiler bug. I don't know what that means. : That guy also thinks I used F90 compiler. He said the automatic array is : illegal in F77. : Then another guy suggests me to do as follows: : program main : real*8 a(0:10) : call sub(a) : end : subroutine sub(b)
|
w**d 发帖数: 2334 | 13
Some guy suggested this. But I did not try it.
The problem is that the same code worked before. And it also runs well
on Compaq machines. Right now, I am busy doing other stuff. Later, I will
try to figure it out.
This is possible.
【在 l**g 的大作中提到】 : 1。这里应该有错: : real*8 b(*) == real*8 b(1:) : 所以这里 b(0) 是 bound violation,a(0)的值并不会改变。 : 2。我觉得你的程序是不是不自觉地引用指针,引起内存访问出错。比如 : subroutine sub(b1,N) : real*8 b1(0:N) : b(0) = 7 : end : subroutine sub(N) : real*8 b2(0:N)
|