Some time after this (https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/532202) , IVF started to do NaN initial-value setting for allocatable arrays.
The snippet below shows that allocatable arrays from type are not getting initialized. Is there anyway to do that?
The compile-line is: ifort /Od /debug:full /Qinit:snan /Qinit:arrays Test.f90
I am using Compiler 17.0 Update 4 with Visual Studio 2015.
Integer :: j
Real(8), Allocatable :: B(:)
End Type newOBJ
Type(newOBJ), Intent(OUT) :: This
Allocate(This%B(2)) ! This won't initialize to NaN
End Module OM
Real(8), Allocatable :: A(:)
Type(newOBJ) :: OBJ
Allocate(A(3)) ! gets initialized to NaN
!Allocate(OBJ%B(2)) ! OBJ%B will get initialized to NaN
End Program Test
You've discovered a bug that still exists in the current release.
Please submit a bug report, which you can do by using the big orange button on the top of the main page of this forum.
To answer your question, you could create a variant of SetObject that accepts the component, and does the allocation. For example:
Subroutine SetObject2(This) real(8), allocatable :: This(:) Allocate(This(2)) ! This did initialize to NaN End Subroutine
I did not try that with the 17.0 compiler, but it did work with our latest sources.