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

how to call imsl subroutines in vc++

swarup_1981
Beginner
511 Views
Hai
I wrote a vc++ program that calls imsl fortran subroutine NNLPF.The vc++ compiler is unable to read the header file link_f90_dll.h because it is written in fortran.Without this header file ,the program compiles without any errors.But there are unresolved external errors during build.

error LNK2019: unresolved external symbol _NNLPF@28 referenced in function _main
fatal error LNK1120: 1 unresolved externals

Is there any way of resolving this problem.Please help me in this regard.

swaroop
0 Kudos
2 Replies
Steven_L_Intel1
Employee
511 Views
First, please note that we don't explicitly support calling the IMSL routines from languages other than Fortran. Many times you can do it, but you have to be aware of the calling conventions and may have to carefully read both the IMSL documentation and the source of the Fortran interface (Provided in the IMSL include folder) to understand what is required.

The .h file you mentioned is there only to specify the names of the libraries to use. You can add the IMSL libraries you need to the project directly. You will also need the Intel Fortran libraries (libifcore.lib, ifconsol.lib, libm.lib, etc.)

It would seem that your C++ code has used __stdcall or similar to specify the calling convention of NNLPF. This is incorrect, as the IMSL as provided with Intel Fortran Professional uses the Intel convention of C.

You have the additional problem here in that NNLPF is provided only in a form designed to be called from Fortran 90/95 code, with some of its arguments being assumed-shape arrays. These require that you pass an Intel Fortran array descriptor, whose structure is documented in the Intel Visual Fortran Building Applications manual. The details of what to do here is beyond the scope of what I can help with.

My advice is to write a Fortran routine to serve as a jacket for NNLPF and call that from your C++ code.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
511 Views
Alternatively, you can use the attached C++ template class, which emulates Visual Fortran allocatable/assumed-shape/pointer arrays. In effect, you can "write Fortran in C++". However, it currently works only for 1-d arrays.

Jugoslav
0 Kudos
Reply