- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've defined a code module (a Fortran F90 file) and supplied it with these two subroutines:
pure Subroutine XRotation (x, y, z, Xrot, xp, yp, zp)
! Rotate about X-axis through the angle Xrot
real*4, INTENT(IN) :: x, y, z, xrot
real*4, INTENT(OUT) :: xp, yp, zp
real*4 xrad
Xrad = Xrot * 3.141592627 / 180 ! Convert to radians
yp = y * COS(Xrad) + z * SIN(Xrad)
xp = x
zp = z * COS(Xrad) - y * SIN(Xrad)
END
Pure Subroutine DummyDummy()
Call XRotation(1,2,3,4,5,6,7)
End Subroutine
The compiler (Intel Fortran 12, targeting 32-bit Windows, for whatever that's worth) returns a single error message:
error #7137: Any procedure referenced in a PURE procedure, including one referenced via a defined operation or assignment, must be explicitly declared PURE. [XROTATION]
I'm a little bit stumped. How can I change this code so that the PURE Subroutine "DummyDummy" compiles?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have a couple of problems. First, you don't have a module - you just have two external procedures. When DummyDummy is compiled, it has no idea what the interface to Xrotation is - in particular, it doesn't know it's PURE. If you actually put these in a module and made the two procedures contained, then it would see that. So you'd have...
module mymod
contains
pure subroutine Xrotation...
...
end subroutine Xrotation
pure subroutine DummyDummy ...
...
end subroutine DummyDummy
end module mymod
The second problem is that you have passed all constants as arguments to Xrotation, but three of them are INTENT(OUT) - the compiler won't like that either if you make the interface visible.
module mymod
contains
pure subroutine Xrotation...
...
end subroutine Xrotation
pure subroutine DummyDummy ...
...
end subroutine DummyDummy
end module mymod
The second problem is that you have passed all constants as arguments to Xrotation, but three of them are INTENT(OUT) - the compiler won't like that either if you make the interface visible.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have a couple of problems. First, you don't have a module - you just have two external procedures. When DummyDummy is compiled, it has no idea what the interface to Xrotation is - in particular, it doesn't know it's PURE. If you actually put these in a module and made the two procedures contained, then it would see that. So you'd have...
module mymod
contains
pure subroutine Xrotation...
...
end subroutine Xrotation
pure subroutine DummyDummy ...
...
end subroutine DummyDummy
end module mymod
The second problem is that you have passed all constants as arguments to Xrotation, but three of them are INTENT(OUT) - the compiler won't like that either if you make the interface visible.
module mymod
contains
pure subroutine Xrotation...
...
end subroutine Xrotation
pure subroutine DummyDummy ...
...
end subroutine DummyDummy
end module mymod
The second problem is that you have passed all constants as arguments to Xrotation, but three of them are INTENT(OUT) - the compiler won't like that either if you make the interface visible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With respect to that second problem, it's a poorly written question. DummyDummy was written only to expose the compiler error.
Thanks for the reminder about modules.
Thanks for the reminder about modules.

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