有关gfortran初始值的设定的问题
遇到一个问题,请教各位大佬module m_haha
implicit none
real :: nan_4
end
program main
use m_haha
implicit none
real :: a
print*,nan_4,a
end program
编译方式:
gfortran -finit-real=nan -c m_haha.f90
gfortran -finit-real=nan -c main.f90
gfortran -finit-real=nan *.o
结果:
0.0000 nan
很迷。。。
-finit-local-zero
-finit-integer=n
-finit-real=<zero|inf|-inf|nan>
-finit-logical=<true|false>
-finit-character=n
The -finit-local-zero option instructs the compiler to initialize local "INTEGER",
"REAL", and "COMPLEX" variables to zero, "LOGICAL" variables to false, and "CHARACTER"
variables to a string of null bytes.Finer-grained initialization options are
provided by the -finit-integer=n, -finit-real=<zero|inf|-inf|nan> (which also
initializes the real and imaginary parts of local "COMPLEX" variables), fcode 发表于 2019-8-18 08:52
-finit-local-zero
-finit-integer=n
-finit-real=
{:4_90:}也就是说,module中定义的变量不是local的? 不是,只有子程序(函数)的局部变量,主程序的变量,才叫“local variables” fcode 发表于 2019-8-19 15:10
不是,只有子程序(函数)的局部变量,主程序的变量,才叫“local variables” ...
多谢绝地答疑 1. (nan_4, a) = (0.0, 0.0), (nan, nan), (0.0, nan), (nan, 0.0) or (莫名其妙的數字)
是 compiler, compile-time-switches dependent的
據此評論編譯器沒有意義, 就科學計算而言, 是程式員的錯(未定義就使用)
2. 我認為MODULE的变量也是"local variables", 請參考:
页:
[1]