- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good day,
I have coded a subroutine which called another PURE procedure. I would like the first one to be a PURE procedure, too.
There is a simple snippet model of my code:
[fortran]PURE subroutine theAnotherOne(a,n,np,d,e) implicit none integer, intent(IN) :: n, np double precision, intent(INOUT) :: e(np), a(np,np) double precision, intent(OUT) :: d(np) ! ... end subroutine theAnotherOne !... PURE subroutine theFirstOne(foo) ! I got the error about this procedure implicit none class(someClass), intent(INOUT) :: foo !... call theAnotherOne(a,n,np, foo%one,e) ! on this line... !... end subroutine theFirstOne [/fortran]
I have read that
A PURE subroutine has no side effects other than changing the values of the INTENT(OUT) and INTENT(INOUT) arguments and/or pointer associations.
and I get the error#7137:Any procedure referenced in a PURE procedure, including one referenced via a defined operation or assignment, must be explicitly declared PURE
best regards,
Oleg.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are those procedures both module procedures or internal procedures - are they both after the contains statement of the same module or other program unit (and still inside that program unit)?
If they are not internal procedures or module procedures, then while compiling theFirstOne the compiler knows nothing about theAnotherOne - program units in Fortran are separately compiled even when they are in the same file. To fix this you ether need to provide an interface block for theAnotherOne inside theFirstOne; or make theAnotherOne an internal procedure of theFirstOne (put it after a contains statement in theFirstOne); or (best) make both procedures module procedures by putting both of them inside a module.
Note also, that if theFirstOne is not an internal procedure or module procedure then anything that calls it also needs to have access to its corresponding interface block due to the polymorphic argument (hence it is best if it is a module procedure).
If those procedures are already both internal procedures or module procedures inside the same program unit, then... ummm.... errr.... (I haven't got a clue...)... provide more information!
If they are not internal procedures or module procedures, then while compiling theFirstOne the compiler knows nothing about theAnotherOne - program units in Fortran are separately compiled even when they are in the same file. To fix this you ether need to provide an interface block for theAnotherOne inside theFirstOne; or make theAnotherOne an internal procedure of theFirstOne (put it after a contains statement in theFirstOne); or (best) make both procedures module procedures by putting both of them inside a module.
Note also, that if theFirstOne is not an internal procedure or module procedure then anything that calls it also needs to have access to its corresponding interface block due to the polymorphic argument (hence it is best if it is a module procedure).
If those procedures are already both internal procedures or module procedures inside the same program unit, then... ummm.... errr.... (I haven't got a clue...)... provide more information!
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are those procedures both module procedures or internal procedures - are they both after the contains statement of the same module or other program unit (and still inside that program unit)?
If they are not internal procedures or module procedures, then while compiling theFirstOne the compiler knows nothing about theAnotherOne - program units in Fortran are separately compiled even when they are in the same file. To fix this you ether need to provide an interface block for theAnotherOne inside theFirstOne; or make theAnotherOne an internal procedure of theFirstOne (put it after a contains statement in theFirstOne); or (best) make both procedures module procedures by putting both of them inside a module.
Note also, that if theFirstOne is not an internal procedure or module procedure then anything that calls it also needs to have access to its corresponding interface block due to the polymorphic argument (hence it is best if it is a module procedure).
If those procedures are already both internal procedures or module procedures inside the same program unit, then... ummm.... errr.... (I haven't got a clue...)... provide more information!
If they are not internal procedures or module procedures, then while compiling theFirstOne the compiler knows nothing about theAnotherOne - program units in Fortran are separately compiled even when they are in the same file. To fix this you ether need to provide an interface block for theAnotherOne inside theFirstOne; or make theAnotherOne an internal procedure of theFirstOne (put it after a contains statement in theFirstOne); or (best) make both procedures module procedures by putting both of them inside a module.
Note also, that if theFirstOne is not an internal procedure or module procedure then anything that calls it also needs to have access to its corresponding interface block due to the polymorphic argument (hence it is best if it is a module procedure).
If those procedures are already both internal procedures or module procedures inside the same program unit, then... ummm.... errr.... (I haven't got a clue...)... provide more information!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!
Your solution works.
I`ve been thinking about a module for theAnotherOne... But I have been trying a whole day to fix a couple of bug and I was a little bit tired.
Oleg.

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