Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Pureness of intrinsic specific functions

IanH
Honored Contributor III
674 Views

Responding to this, I got a little surprise.  With the following

[fortran]MODULE m
  IMPLICIT NONE
CONTAINS
  SUBROUTINE sub(proc)
    INTERFACE
      PURE FUNCTION proc(x)
        IMPLICIT NONE
        REAL, INTENT(IN) :: x
        REAL :: proc
      END FUNCTION proc
    END INTERFACE
    PRINT *, proc(0.0)
  END SUBROUTINE sub
END MODULE m

PROGRAM p
  USE m
  IMPLICIT NONE
  INTRINSIC :: sin
  CALL sub(sin)       ! <-- Why "argument must be pure"?
END PROGRAM p
[/fortran]

the compiler complains about the purity of sin.  Why?

[plain]>ifort /check:all /warn:all /standard-semantics passing-intrinsic.f90 && passing-intrinsic.exe
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.0.103 Build 20130728
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

passing-intrinsic.f90(20): error #7892: Procedure argument must be PURE   [SIN]
  CALL sub(sin)       ! <-- Why "argument must be pure"?
-----------^[/plain]

This is unfamiliar territory for me, and ifort isn't alone in its complaint (gfortran complains too), so that makes me wonder what I've missed.

- "All standard intrinsic functions are pure" - F2008 13.1 p2.

- "If the interface of a dummy proceure is explicit, its characteristics as a procedure shall be the same as those of its effective argument, except... an elemental intrinsic actual procedure may be associated with a dummy procedure (which cannot be elemental)." - F2008 12.5.2.9 p1

- In F2008 13.6 the specific `sin` doesn't have a dot, so it can be an actual arg (F2008 C1235 and 12.5.2.9 p4).

0 Kudos
4 Replies
Steven_L_Intel1
Employee
674 Views

As best as I can tell, your example should work. I will let the developers know. Feel free to report this to the gfortran devs too. Our issue ID is DPD200248826.

0 Kudos
Alfonso_S_
Beginner
674 Views

Thank you Steve.

0 Kudos
Steven_L_Intel1
Employee
674 Views

We've fixed this for a future release.

0 Kudos
Alfonso_S_
Beginner
674 Views

Great!

0 Kudos
Reply