Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28446 Discussions

potentially-redundant warning by ifort

DataScientist
Valued Contributor I
278 Views

When I try to compile the following submodule, I get the following remark from ifort that the result variable has not been used:

..\src\mod_Calculus@Gradient.f90(12): remark #7712: This variable has not been used.   [GRADCOMPLEXSTEP]
  module function GetGradComplexStep(GetCplxFunc,nd,Delta,Point) result(GradComplexStep)
------------------------------------------------------------------------^

clearly, this is a wrong remark as the result variable is indeed used in the body of the code. Why does the compiler issue such a remark?

submodule (Calculus) Gradient

  use Constants, only: IK, RK
  implicit none

contains

  ! Compute the first derivative using the complex-step method.
  module function GetGradComplexStep(GetCplxFunc,nd,Delta,Point) result(GradComplexStep)
    use Constants, only: IK, RK
    implicit none
    procedure(GetCplxFuncProc) :: GetCplxFunc
    integer(IK), intent(in)    :: nd
    real(RK)   , intent(in)    :: Delta(nd)
    real(RK)   , intent(in)    :: Point(nd)
    real(RK)                   :: GradComplexStep(nd)
    complex(RK)                :: PointComplex(nd)
    integer(IK)                :: i
    PointComplex = Point
    do i = 1, nd
      PointComplex(i) = cmplx( Point(i) , Delta(i) , kind=RK )
      GradComplexStep(i) = aimag( GetCplxFunc( nd , PointComplex ) ) / Delta(i)
      PointComplex(i) = cmplx( Point(i) , 0._RK , kind=RK )
    end do
  end function GetGradComplexStep

end submodule Gradient


 

0 Kudos
1 Reply
Arjen_Markus
Honored Contributor I
278 Views

Which version of the compiler are you using? It will be easier for people to help if you can supply a complete compilable source - right now the modules Constants and Calculus are missing. (I tried it with Intel Fortran 2017, adding dummy modules and did not get that warning).

0 Kudos
Reply