- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why would the following not work:
-------------------------------------------------------
PROGRAM Test
IMPLICIT NONE
INTEGER, ALLOCATABLE :: Alt(:)
INTEGER, DIMENSION(8) :: Fxd
Fxd = [1, 2, 3, 0, 5, 0, 7, 8]
Alt = pack(Fxd, Fxd .NE. 0)
WRITE(*,*) Alt
!DEALLOCATE(Alt)
END PROGRAM Test
-------------------------------------------------------
According to Metcalf et al. Fortran 95/2003 PP. 298, the direct assignment to an allocatable array (Alt) is possible due to an extension in Fortran 95 standards (Ch. 12).
I am using Intel Fortran Compiler Ver. 10.1.021 on MSXP SP3.
- Kulachi
-------------------------------------------------------
PROGRAM Test
IMPLICIT NONE
INTEGER, ALLOCATABLE :: Alt(:)
INTEGER, DIMENSION(8) :: Fxd
Fxd = [1, 2, 3, 0, 5, 0, 7, 8]
Alt = pack(Fxd, Fxd .NE. 0)
WRITE(*,*) Alt
!DEALLOCATE(Alt)
END PROGRAM Test
-------------------------------------------------------
According to Metcalf et al. Fortran 95/2003 PP. 298, the direct assignment to an allocatable array (Alt) is possible due to an extension in Fortran 95 standards (Ch. 12).
I am using Intel Fortran Compiler Ver. 10.1.021 on MSXP SP3.
- Kulachi
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Because we didn't want to slow down applications written to the F90/95 standard, which required that Alt already be allocated to the correct shape, the F2003 feature of automatic reallocation is disabled by default. You can enable it with the option /assume:realloc_lhs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Steve Lionel (Intel)
Because we didn't want to slow down applications written to the F90/95 standard, which required that Alt already be allocated to the correct shape, the F2003 feature of automatic reallocation is disabled by default. You can enable it with the option /assume:realloc_lhs.
-Kulachi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want the F2003 semantics, then you need the "overhead", which is the added code to do the automatic deallocation/reallocation. If you know that the arrays are always allocated to the correct shape, then you don't need that option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Many Thanks Steve!
-Kulachi
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page