- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page