- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In the code below, the use of the PURE attribute in the subroutine getDummyLines seems to trigger a variable definition context error (error #7138: This dummy-arg appears in a 'defining' context in a PURE procedure or in an internal procedure contained in a PURE procedure). Without the PURE attribute in the subroutine getDummyLines, the error goes away. The error also goes away by calling getDummyIndex instead of the type-bound procedure (this%getDummyIndex)... So, is there any kind of new restriction to PURE procedures in the Fortran 2003 standard, is it just the same issue with CLASS and INTENT, reported before (DPD200150651)? Or is it something new?
[fortran]module pure_intent implicit none private save type, abstract, public :: SomeClass integer, allocatable, private :: dummy(:) contains procedure :: getDummyIndex procedure :: getDummyLines end type contains !---------------------------------------------------------------------------------------------- pure subroutine getDummyIndex(this, header, idx) logical :: status class(SomeClass), intent(IN) :: this character(:), allocatable, intent(INOUT) :: header integer, intent(OUT) :: idx continue idx = 0 if (.NOT. ALLOCATED(this%dummy)) return end subroutine !---------------------------------------------------------------------------------------------- pure subroutine getDummyLines(this, header, lines) !The PURE attribute triggers an error here class(SomeClass), intent(IN) :: this character(*), intent(IN) :: header character(:), allocatable, intent(OUT) :: lines(:) integer :: idx character(:), allocatable :: header_ continue if (.NOT. ALLOCATED(this%dummy)) return header_ = TRIM(ADJUSTL(header)) call this%getDummyIndex(header_, idx) !call getDummyIndex(this, header_, idx) end subroutine end module pure_intent [/fortran]
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
John,
I don't delve much in this area, so I may be wrong on my read.
On line 5 of your sample you have "save". This is in the module data/declaration area prior to the "contains" section. What I do not know is if this "save" attribute carries on into the contained subroutines. If it does, then the local variables are "save" variables. (e.g. status in getDummyIndex and idx in getDummyLines)
If these are "save" variables, then calling these subroutines have a side effect. i.e. not pure.
You should (? assumption on my part) be able to have "save" in pure provided that it is entirely enclosed (hidden) in the pure function. Since these two pure functions are nested, and the save is associated with the module (as opposed to individual subroutines) I do know if the compiler may have issue with this.
Try commenting on the save on line 5
If that works (but you need save), then try adding save inside each subroutine.
(or wait for Steve to reply with full analysis)
Jim Dempsey
I don't delve much in this area, so I may be wrong on my read.
On line 5 of your sample you have "save". This is in the module data/declaration area prior to the "contains" section. What I do not know is if this "save" attribute carries on into the contained subroutines. If it does, then the local variables are "save" variables. (e.g. status in getDummyIndex and idx in getDummyLines)
If these are "save" variables, then calling these subroutines have a side effect. i.e. not pure.
You should (? assumption on my part) be able to have "save" in pure provided that it is entirely enclosed (hidden) in the pure function. Since these two pure functions are nested, and the save is associated with the module (as opposed to individual subroutines) I do know if the compiler may have issue with this.
Try commenting on the save on line 5
If that works (but you need save), then try adding save inside each subroutine.
(or wait for Steve to reply with full analysis)
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The module-level SAVE does not affect the contained routines, and it is not relevant to this issue.
I think this is simply a compiler bug. It is one that was also reported to us about a week ago - issue ID is DPD200156891.
I think this is simply a compiler bug. It is one that was also reported to us about a week ago - issue ID is DPD200156891.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I expect this issue to be fixed in our November release.

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