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

IFX Fortran compiler not passing values correctly.

Grant_Smith
New User
554 Views

I am using a C++ API function called from a Fortran routine. 

The call code is

SIDOK = SIDPUTVOL(%VAL(J2),%VAL(D2),%VAL(VCLASS),%VAL(TVOL))

the C++ code is

VARIANT_BOOL __stdcall SIDPUTVOL(long origin, long dest, long vclass, float volume)

when I use IFORT 'TVOL' is passed to 'volume' correctly

When i use IFX 'volume' takes either zero or e-37

Tvol and volume are both 4 byte real. the integer values are passing correctly.

Can anyone help?

 

0 Kudos
1 Solution
jimdempseyatthecove
Honored Contributor III
478 Views

Check the reference manual for C Interoperability.

You should declare an interface to SIDPUTVOL something like:

 

interface
  function SIDPUTVOL(J2, D2, VCLASS, TVOL) bind(C,name='SIDPUTVOL') result(ret)
    use, intrinsic :: ISO_C_BINDING
    implicit none
    integer(kind=c_long), value :: J2, D2, VCLASS
    real(kind=c_float), value :: TVOL
    logical(kind=c_bool) :: ret ! ** guessing at this
  end function SIDPUTVOL
end interface

 

Place the interface in a module and use that module where you make calls to SIDPUTVOL

Also, in your C++ code add a prototype

 

extern "C"
VARIANT_BOOL SIDPUTVOL(long origin, long dest, long vclass, float volume);

 

And make the actual declaration match.

Jim Dempsey

View solution in original post

1 Reply
jimdempseyatthecove
Honored Contributor III
479 Views

Check the reference manual for C Interoperability.

You should declare an interface to SIDPUTVOL something like:

 

interface
  function SIDPUTVOL(J2, D2, VCLASS, TVOL) bind(C,name='SIDPUTVOL') result(ret)
    use, intrinsic :: ISO_C_BINDING
    implicit none
    integer(kind=c_long), value :: J2, D2, VCLASS
    real(kind=c_float), value :: TVOL
    logical(kind=c_bool) :: ret ! ** guessing at this
  end function SIDPUTVOL
end interface

 

Place the interface in a module and use that module where you make calls to SIDPUTVOL

Also, in your C++ code add a prototype

 

extern "C"
VARIANT_BOOL SIDPUTVOL(long origin, long dest, long vclass, float volume);

 

And make the actual declaration match.

Jim Dempsey

Reply