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?
i don’t know much about fortran 90 (back in my day etc etc) but if you place that in a module it works. i get the impression that modules are needed for various “modern” fortran features.
anyway, someone smarter (or younger?) than me can explain, but that should help you continue.
ah, here’s an explanation (see the answers) – Writing and calling pure subroutines in Fortran 90 using gfortran
ps i also get a type warning as you’re passing in integers to float arguments.