Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

Error #6594: executes w/o errors but Exception Thrown if executed again using Start on VS 2019

Ever
New Contributor I
487 Views

I wrote this MWE to illustrate what happens when I execute the same code multiple times.

After a rebuild, the MWE runs fine once, then it throws an Exception. Run it again 2 more times, exceptions are thrown  both times. Run it again, and it runs fine. It is random. 

I am using VS 2019-16.11.31 v4.8.09037 with Intel Fortran 2019.

I wrote this MWE because a much larger code (called "fabrics"), that runs fine when compiled with Intel Fortran 2011, but produces strange errors such as #6594 when recompiled with Intel 2019. I believe there is nothing wrong with the larger code, but the compiler has changed from 2011 to 2019, so that now I can not run the larger code anymore. I've got to fix the MWE before I can do anything about the larger code. Please help me. 

 

program rankDerivedType
    ! investigate lines of code, from larger code "fabrics," that are throwing error #6594
    ! Ff: This name must be the name of a variable with a derived type (structure type).
    
    use strength_mod_test
    
    ! type (a.k.a. object) definition (I define it)
    type One  
        double precision :: small(6) ! the data in this type 
        ! pointer :: Ff(:,:) ! Pointer is not permitted as a statement within a derived-type-def. Must write the constructor outside the type def.
    end type One
    type TxT
        double precision :: small(3,3) ! Defined so that any var of type "type" has the correct size %small, depending of the "type" 
    end type Txt

    ! For Pointers only, must declare variables of type "type" using a constructor, outside the type definition. 
    type(One), pointer :: Ff(:,:), sigmaf123(:,:) 
    type(TxT), pointer :: Df(:,:)

    ! local variables
    integer i,j
    double precision, dimension(3,3) :: D_in=0.d0 ! used to initialize variables of type TxT 

    ! declare and initialize array X
    double precision, dimension(6) :: X = (/1,2,3,4,5,6/) ! just data, not PARAMETER. Values can be modified in the code.
    integer sv ! to check if allocation/deallocation was successful

    ! Allocate and initialize type variables
    ! of type One
    allocate(Ff(nf, nw),STAT=sv); 	if (sv /= 0) then; pause "sv/=0"; endif
    allocate(sigmaf123(nf, nw),STAT=sv); 	if (sv /= 0) then; pause "sv/=0"; endif
    ! of type TxT
    allocate(Df(nf, nw),STAT=sv); 	if (sv /= 0) then; pause "sv/=0"; endif
    ! Each i,j element in Df must be initialized with a 3x3 matrix. 
    do i=1,3        ! nf
        do j=1,3    ! nw
            Df(i,j)%small = D_in     ! 3x3 matrix of 3x3 matrices.
        enddo
    end do

    do i=1,3        ! nf
        do j=1,3    ! nw
            Ff(i,j)%small = F_function (X, Df(i,j)%small, sigmaf123(i,j)%small) ! same line that throws #6594 on the larger code
        enddo
    enddo
    
    ! A breakpoint could be triggered if allocated variables are not deallocated
    ! warning: compare deallocate(Ff(nf, nw),STAT=sv) with deallocate(Ff,STAT=sv). Note different arguments Ff(nf,nw) vs Ff
    ! of type One
    deallocate(Ff,STAT=sv); 	if (sv /= 0) then; pause "sv/=0"; endif
    deallocate(sigmaf123,STAT=sv); 	if (sv /= 0) then; pause "sv/=0"; endif
    ! of type TxT
    deallocate(Df,STAT=sv); 	if (sv /= 0) then; pause "sv/=0"; endif
    
    end program ! executes w/o errors but Exception thrown if executed again using Start on VS 2019

 

A small module is required to provide a Function, as follows: 

 

    module strength_mod_test
    contains
    function F_function (R, D, sig)
        double precision, dimension(6) :: F_function            ! rank=1
        double precision, dimension(6), intent(in) :: R, sig    ! rank=1       
        double precision, dimension(3,3), intent(in) :: D       ! rank=2
        
        F_function = 0.d0
        
        if (D(1,1) == 0.d0 .AND. sig(1) > 0.d0) then
        	F_function(1) = sig(1)/R(1)
        end if
        
        if (D(2,2) == 0.d0 .AND. sig(2) > 0.d0) then
        	F_function(2) = sig(2)/R(2)
        end if
        
        if (D(3,3) == 0.d0 .AND. sig(3) > 0.d0) then
        	F_function(3) = sig(3)/R(3)
        end if
        
        if (D(2,2) == 0.d0 .OR. D(3,3) == 0.d0) then
        	F_function(4) = abs(sig(4))/R(4)
        end if
        
        if (D(3,3) == 0.d0) then
        	F_function(5) = abs(sig(5))/R(5)
        end if
        
        if (D(2,2) == 0.d0) then
        	F_function(6) = abs(sig(6))/R(6)
        end if
                
    end function F_function
    end module

 

Any suggestions will be very much appreciated. 

 

0 Kudos
1 Reply
andrew_4619
Honored Contributor III
476 Views

I put your code in a project and compiled with IFX 2024.2.0.  The first point of note is:

Source1.f90(65): warning #6717: This name has not been given an explicit type. [NF]
Source1.f90(65): warning #6717: This name has not been given an explicit type. [NW]

 

And they are not initialised.  I am not saying this is the cause of your issue but initialised variables cause erratic program results as they can pick up junk values. I suggest checking your debug codes with at least /warn:declarations and /check:uninit  as an absolute minimum.

 

As an aside, you will not find much interest if there is a 2019 compiler issue it is rather out of data. why not use the latest? 

0 Kudos
Reply