[R] Linking Fortran subroutines

Liaw, Andy andy_liaw at merck.com
Thu Nov 17 18:50:28 CET 2005


Why not put the two subroutines into one file and compile them into one DLL?
Or compile them separately into .o, but make them into one DLL.

Andy

> From: Li, Guang Q
> 
> Hi,
> 
>  
> 
> I just started using R a few weeks ago and have a problem 
> with linking Fortran subroutines to R. For some reasons, I 
> need to compile a Fortran program in R (or Splus) and the 
> whole program consists a couple of subroutines, say, subA and 
> subB. There is no difficulty in linking the subroutines 
> individually, but two subroutines are nested, as shown below, 
> 
>  
> 
> SUBROUTINE subA(arg.)
> 
> EXTERNAL subB
> 
> ¡­.
> 
> CALL subB(arg.)
> 
> ¡­. 
> 
> RETURN
> 
> END
> 
>  
> 
> SUBROUTINE subB (arg.)
> 
> ¡­.
> 
> RETURN
> 
> END
> 
>  
> 
> Obviously, if subA(.dll) and subB(.dll) are individually 
> linked to R, subB will not be called within subA. In fact, R 
> does not recognise the command CALL subB( )! Further, in the 
> real situation, subB is called several times with different 
> inputs within subA, so it will be impossible to merge two 
> subroutines into one. 
> 
>  
> 
> I am here asking whether there is any way to solve this 
> problem, and I hope the question is clearly explained.
> 
>  
> 
> Thanks in advance for any help!
> 
>  
> 
> Philip
> 
> 
> 	[[alternative HTML version deleted]]
> 
>




More information about the R-help mailing list