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

malfunction of function present() ?

aid-usman
Beginner
744 Views
In the following example the parameter Bound is called by value and is optional. If Bound get a value of 2.0 then the function present(Bound) returns .false. and if Bound get a value of 2.1 then the function present(Bound) returns .true.
It seems that if Bound gets a value that is (near to) an integer value the internal function present() doesn't work correct
function func(X, Bound) result (l)
!DEC$ attributes dllexport, stdcall, alias : "func" :: func
!DEC$ attributes reference :: X
real(8) :: X
real(8), optional, intent(in) :: Bound
logical :: l

if (present(Bound)) then
l = .true
else
l = .false.
end if
end function func
Is this a knownproblem or does someone know what I am doing wrong?
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
744 Views
The problem is that OPTIONAL is incompatible with VALUE attribute, and STDCALL implies VALUE attribute. To solve it, you should also declare REFERENCE for Bound.

IVF previously did not raise an error for code like that (it would if you spell out !DEC$ATTRIBUTES VALUE:: Bound); I submitted a bug report to Premier and it is either fixed in the latest release or is about to be (I'm lazy to check right now). Which version do you have?
0 Kudos
aid-usman
Beginner
744 Views
Thank you for your remarks.
I am using CVF 6.6.C
0 Kudos
Reply