Is it possible to run Fortran 95 code from R? I don't think so, but hopefully someone can prove me wrong. Here is the test I tried: A little fortran 95 subroutine: subroutine allloc() real, dimension(:, :), allocatable :: a integer :: n n = 10 allocate(a(n,n+1)) end I then compiled:>g95 -c allloc.f >R CMD SHLIB allloc.oHere is what happens when I try to dyn.load it in R 2.1.0> dyn.load("allloc.so")Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/home/jbremson/dev/f_code/allloc.so': /home/jbremson/dev/f_code/allloc.so: undefined symbol: _g95_filename Is there any way to deal with this? Is it somehow possible to reach the fortran 95 through C and avoid this whole problem? Regards, Joel Bremson UC Davis [[alternative HTML version deleted]]
First you need a functional F95 compiler. I believe `g95' is obselete, replaced by gfortran. For how to use that, please do read the R-admin manual in R 2.1.0 -- it can be done if you use a bug-fixed version of gfortran (post gcc-4.0.0) or a workaround. Reliable F95 compilers such as those on Solaris have been usable with R for several years. Please do remember to mention your platform and which compilers you used: see the posting guide. Preferably also use the list it suggests (moved there). On Tue, 17 May 2005, Joel Bremson wrote:> Is it possible to run Fortran 95 code from R? I don't think so, but > hopefully someone can prove me wrong. > > Here is the test I tried: > > A little fortran 95 subroutine: > > subroutine allloc() > real, dimension(:, :), allocatable :: a > integer :: n > > n = 10 > allocate(a(n,n+1)) > end > > I then compiled: > >> g95 -c allloc.f >> R CMD SHLIB allloc.o > > Here is what happens when I try to dyn.load it in R 2.1.0 > >> dyn.load("allloc.so") > Error in dyn.load(x, as.logical(local), as.logical(now)) : > unable to load shared library '/home/jbremson/dev/f_code/allloc.so': > /home/jbremson/dev/f_code/allloc.so: undefined symbol: _g95_filename > > Is there any way to deal with this? > > Is it somehow possible to reach the fortran 95 through C and avoid this > whole problem? > > Regards, > > Joel Bremson > UC Davis-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On 18/05/2005, at 8:10 PM, Joel Bremson wrote:> Is it possible to run Fortran 95 code from R? I don't think so, but > hopefully someone can prove me wrong. >This is not really any issue with R. It is matter of what compilers you have installed. If you have Fortran 95 compiler and you use it to build R, then within R 'F77' will refer to that compiler and you should be able to use f95 code. Currently I think it is correct that all the available binary distributions of R use g77 from the gcc 3.x.x compiler suite. gcc-4.0.0 has recently been released and this includes the new gfortran compiler which supports F90 and F95. gfortran is not as mature a product as g77 and may give you problems. Current cvs code seems to usable for many purposes, and by the time gcc-4.1 is released later this year, gfortran should be quite usable. Bill Northcott