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.

Weird to the power error

berrydenhartog
Beginner
727 Views

I'm doing matlab calculation with visual fortran 90. Now ihave a strange error.

When i use the ** symbol my mex dll crashes. without the ** it works great.

also the5 ** 2 works great (propably becouse optimalization makes it a5 * 5) but5 ** 0.25 dosn't work.

My testing code

REAL*8 FUNCTION T4_p(p)

IMPLICIT NONE

REAL*8 beta

REAL*8 p

beta = p ** 0.25 also tryed beta = p ** 0.25D0

T4_p = beta

RETURN

End

Do i need to add a lib to my linker? dos anyone know what i am doing wrong.

0 Kudos
4 Replies
jimdempseyatthecove
Honored Contributor III
727 Views

Berry,

Put a breakpoint on the beta = line and examine what p references.

Also, look one level up the call stack and see where and whatthe function (T4_P) is pointing at.

Check for mis-typed variabes as well as undefined variables and if p references NaN, Inf etc...

Does this function have/use interfaces?

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
727 Views
How does it "crash"? What is the error message? If this is being built into a DLL, you need libmmd.lib
0 Kudos
TimP
Honored Contributor III
727 Views
sqrt(sqrt(p)) ought to be more efficient than p**.25.
0 Kudos
berrydenhartog
Beginner
727 Views

Thanks allot Steve, when i added that lib everything works great. i was also trying stuff like this: (maybe it will help someone else)

REAL*8 FUNCTION GetPower(base,exponent)
IMPLICIT NONE
REAL*8 exponent,base

if(exponent .EQ. 0.D0) then
GetPower = 1.D0
RETURN
end if
If(base .EQ. 0.D0) then
GetPower = 0.D0
RETURN
end if
if(exponent .EQ. 2.D0) then
GetPower = base * base
RETURN
end if

GetPower = DEXP(exponent * DLOG(base))
RETURN
End

But also crashed my mex dll file.

Thx for that tip tim18, I didn't tought about that on.

the error was

??? Invalid MEX-file 'Path': The specified module could not be found.

.

0 Kudos
Reply