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

Troubles linking R to Fortran with RFortran library

Joann
Beginner
477 Views

Hi all,

I want to use the RFortran library to call R functions from my FORTRAN program. I use the Microsoft Visual Studio 2010 with Inter Visual Fortran compiler.When I try to insert RFortran commands in my Fortran code, I yield the following error:

"LNK2019: unresolved external symbol _RFORTRAN_RINIT_RCLOSE_mp_RINIT refercended in function _MAIN_". Trying to solve this problem, I followed the online recommendation and attempted to insert the source code directly into my project, but I then yield 2 kinds of warnings:

1) "D:\Program Files\RFortran\src\core\inc_1-3D_Rget.f90(97): warning #7025: This directive is not standard F2003." associated with  !DEC$ IF loops

2) "D:\Program Files\RFortran\src\core\inc_1-3D_Rput.f90(50): warning #7416: Fortran 2003 does not allow this intrinsic procedure.   [LOC]" associated with the loc procedure

and finaly 2 errors of this kind

"1>fortcom: Fatal: There has been an internal compiler error (C0000005).
1>compilation aborted for D:\Program Files\RFortran\src\core\RFortran_Rput_Rget_Reval_Rcall.F90 (code 1)" aborted the compilation.

I cannot figure out how to solve my problem. Hope someone will be able to give me a hint.

Thank you very much!

Regards,

Joannès

0 Kudos
2 Replies
mecej4
Honored Contributor III
477 Views
I think that the simpler solution is to simply check that you add the RFortran library to your project or list that library in the linker command line. By default, a Fortran program does not expect to be linked with the R library. Therefore, if your code calls subroutines/functions from the library, you have to specify explicitly that the linker should use the library. Recompiling the R library from its sources seems rather extreme and uncalled for.
0 Kudos
TimP
Honored Contributor III
477 Views
While the !DEC$ IF method for conditional compilation isn't standard Fortran, as long as you use ifort as your Fortran compiler, it would be supported consistently. There is a Fortran standard equivalent intrinsic C_LOC (declared under USE ISO_C_BINDING) which has stricter rules (in principle) than the legacy LOC. The warning would need to be corrected if you wished to use other Fortran compilers, but, as you saw, this is not the only place where this application requires Intel Fortran specifically. Neither of those warnings appears likely to kill your build. The _mp_ in the unresolved external symbol refers to module procedure. Such a procedure would appear in a MODULE and be provided at the point of reference by a preceding USE referencing that module. The appearance of _MAIN_ could indicate a problem with formatting of your source files. It indicates presence of an unnamed Fortran 66 style main program, which could appear as a result of missing source lines in the file, or the compiler seeing an END causing it to break a source file. If an error occurred when making the .mod file for that module, it's likely to be necessary to delete the .mod in order to rebuild, even though the remainder of your setup is correct. As Rinit is declared private, it's possible that it is being called where the private qualifier prevents it, and possible that the current ifort is enforcing a restriction which wasn't enforced at the time this software was tested.
0 Kudos
Reply