Can someone please explain the following error to me (Is passing this intrinsic as an actual argument in violation of the Fortran standard, and if not, why won't ifort let me do it?):
error #6551: This intrinsic procedure cannot be passed as an actual argument. [RANDOM_NUMBER]
The following small program will raise this error:
module mymod implicit none integer ,parameter :: WP = kind(1.0D0) abstract interface subroutine RanVec(harvest) import :: WP real(WP) ,intent(out) :: harvest(:) end subroutine end interface contains subroutine neg1to1(Ran,harvest) procedure(RanVec) :: Ran real(WP) ,intent(out) :: harvest(:) call Ran(harvest) harvest = harvest*2 - 1.0_WP end subroutine neg1to1 end module mymod program bugtest use mymod implicit none intrinsic :: random_number real(WP) :: testvec(100) call neg1to1(random_number,testvec) print*,testvec end program
I am writing code to map random uniformly distributed variates onto normaly distributed variates. It would be nice for the user to be able to pass his or her user defined PRNG to the routine or Fortran's intrinsic PRNG, random_number. Note that, if I don't include the
intrinsic :: random_numberline then the compiler type checking complains about random_number being undefined.