Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
50 Views

snan initialization for allocatable arrays

Hi

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.

Abhi

 

=====

      Module OM
         
         Implicit None
         
         Type newOBJ
            Integer :: j
            Real(8), Allocatable :: B(:)
         End Type newOBJ
         
      Contains
      
         Subroutine SetObject(This)
            
            Type(newOBJ), Intent(OUT) :: This
            
            Allocate(This%B(2)) ! This won't initialize to NaN
            
         End Subroutine
      
      End Module OM
   
      Program Test
         
         Use OM
         Implicit None
         
         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
         
         Call SetObject(OBJ)
         
      End Program Test

0 Kudos
1 Reply
Highlighted
50 Views

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.

                          --Lorri

0 Kudos