Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
29313 Discussions

PURE + ASSOCIATE + DO + ALLOCATE/DEALLOCATE

John4
Valued Contributor I
745 Views

Hi,

There seems to be a compiler bug caused by the ASSOCIATE statement when used in a PURE procedure, as shown in the following code.

module mod1

    implicit none

    type :: mytype
        real, allocatable :: G(:,:,:)
        real, allocatable :: K(:,:,:)
        real, allocatable :: B(:,:,:)
    contains
        procedure :: myproc
    end type

contains
    !----------------------------------------------------------------------------------------------
    pure subroutine myproc(this, n)
        class(mytype), intent(INOUT) :: this
        integer, intent(IN) :: n

        real, allocatable :: XDATA(:), FDATA1(:), FDATA2(:)
        integer :: i, nz

    continue
        associate (G => this%G, K => this%K, B => this%B)

        do i = 1, n
            allocate (XDATA(nz), FDATA1(nz), FDATA2(nz))

            deallocate (XDATA, FDATA1, FDATA2)
        enddo

        end associate

    end subroutine

end module mod1

The errors shown are:

~$ ll `which ifort`
-rwxr-xr-x 1 root root 3955056 Jan 24 07:03 /opt/intel/composer_xe_2013_sp1.2.144/bin/intel64/ifort*
~$ ifort -c test_pure.f90 
test_pure.f90(26): error #7146: This object must not be used as an allocate-object in an allocate-stmt or deallocate-stmt in a PURE procedure or an internal procedure contained in a PURE procedure.   [XDATA]
            allocate (XDATA(nz), FDATA1(nz), FDATA2(nz))
----------------------^
test_pure.f90(26): error #7146: This object must not be used as an allocate-object in an allocate-stmt or deallocate-stmt in a PURE procedure or an internal procedure contained in a PURE procedure.   [FDATA1]
            allocate (XDATA(nz), FDATA1(nz), FDATA2(nz))
---------------------------------^
test_pure.f90(26): error #7146: This object must not be used as an allocate-object in an allocate-stmt or deallocate-stmt in a PURE procedure or an internal procedure contained in a PURE procedure.   [FDATA2]
            allocate (XDATA(nz), FDATA1(nz), FDATA2(nz))
---------------------------------------------^
test_pure.f90(28): error #7146: This object must not be used as an allocate-object in an allocate-stmt or deallocate-stmt in a PURE procedure or an internal procedure contained in a PURE procedure.   [XDATA]
            deallocate (XDATA, FDATA1, FDATA2)
------------------------^
test_pure.f90(28): error #7146: This object must not be used as an allocate-object in an allocate-stmt or deallocate-stmt in a PURE procedure or an internal procedure contained in a PURE procedure.   [FDATA1]
            deallocate (XDATA, FDATA1, FDATA2)
-------------------------------^
test_pure.f90(28): error #7146: This object must not be used as an allocate-object in an allocate-stmt or deallocate-stmt in a PURE procedure or an internal procedure contained in a PURE procedure.   [FDATA2]
            deallocate (XDATA, FDATA1, FDATA2)
---------------------------------------^
compilation aborted for test_pure.f90 (code 1)

Removing the PURE attribute, commenting the ASSOCIATE/END ASSOCIATE lines, or even moving the ALLOCATE/DEALLOCATE lines outside the loop, all make the error go away.



 

0 Kudos
1 Solution
Kevin_D_Intel
Employee
745 Views

Pardon the late follow-up. I confirmed this defect is fixed in both the Intel® Fortran Composer XE 2013 SP1 Update 3 release (Version 14.0.3.174 Build 20140422 - Linux) -AND- the Intel® Parallel Studio XE 2015 Initial Release (2015.0.090 - Linux)

View solution in original post

0 Kudos
5 Replies
FortranFan
Honored Contributor III
745 Views

Yep, it does look like a compiler bug.  FWIW, the above code compiles ok in gfortran 4.9; the only message is [plain] warning: 'nz' may be used uninitialized in this function [/plain]

0 Kudos
John4
Valued Contributor I
745 Views

In the actual code, the value of nz is defined properly ---you may have noticed that the code posted does not do anything useful.

(OT: When using gfortran, along with deferred-length character variables, I tend to disable -Wmaybe-uninitialized, because it gives way too many useless warnings).

--

John


 

0 Kudos
Kevin_D_Intel
Employee
745 Views

I reported this to Development (internal tracking id below) and will keep you updated on the status as I learn it. Thank you.

(Internal tracking id: DPD200255246)

(Resolution Update on 10/08/2014): This defect is fixed in the Intel® Fortran Composer XE 2013 SP1 Update 3 release (Version 14.0.3.174 Build 20140422 - Linux) -AND- the Intel® Parallel Studio XE 2015 Initial Release (2015.0.090 - Linux)

0 Kudos
Kevin_D_Intel
Employee
745 Views

Development received an earlier report of this and already had a fix targeted to the major release later this year but with this report they are now also targeting the fix to an upcoming update for the current Composer XE 2013 SP1 (14.0 compiler) release. Hopefully this will be in the Update 3 tentative scheduled for later this month.

I will update the post as I learn more.

0 Kudos
Kevin_D_Intel
Employee
746 Views

Pardon the late follow-up. I confirmed this defect is fixed in both the Intel® Fortran Composer XE 2013 SP1 Update 3 release (Version 14.0.3.174 Build 20140422 - Linux) -AND- the Intel® Parallel Studio XE 2015 Initial Release (2015.0.090 - Linux)

0 Kudos
Reply