Casey is right. In Release build, the compiler optimization capability is quite remarkable. In your code it will:
a) recognize a_index is local variable
b) recognize t is local variable
c) recognize x_index use in statement to generate t
d) (when you replace =t with =1.d0) recognize t not used
e) due to d) t not used, will eliminate statement generating t
f) due to e) x_index not used, will eliminate statment generating x_index
g) due to f) now observes loop is setting constant into array
In Debug build, the compiler will generate the code you ask for even though the results are not needed.
Jim Dempsey
Casey is right. In Release build, the compiler optimization capability is quite remarkable. In your code it will:
a) recognize a_index is local variable
b) recognize t is local variable
c) recognize x_index use in statement to generate t
d) (when you replace =t with =1.d0) recognize t not used
e) due to d) t not used, will eliminate statement generating t
f) due to e) x_index not used, will eliminate statment generating x_index
g) due to f) now observes loop is setting constant into array
In Debug build, the compiler will generate the code you ask for even though the results are not needed.
Jim Dempsey