[R-SIG-Mac]compiling fortran code of contributed packages using absoft f77 and lnk

Papritz, Andreas andreas.papritz@ito.umnw.ethz.ch
Mon, 28 May 2001 14:19:30 +0200

DeaR mac users

I tried to compile the fortran code of the "splancs" package using 
Absoft's Fortran compiler f77 and combine the object files into a 
shared library using Absoft's lnk. I could create the library without 
any problem but
when I tried to access the library from R strange things happen.

I can load the modules contained in the library by the R's dyn.load().

But when I check whether a particular Fortran routine, say "areapl", 
is accessible to R by using
>  is.loaded(symbol.For("areapl"))

Strange enough if I test
>  is.loaded(symbol.C("areapl"))
[1] TRUE

I get the answer that areapl is accessible as a C module.
From this I conclude that lnk gives the shared library some attribute 
which makes R think that the library contains C code.

For contributed packages containing C code I did not experience any 
problems, ie. acc and lnk created a shared library accessible to R 
(e.g. I could install geoR, available from 
http://www.maths.lancs.ac.uk/~ribeiro/geoR.html, on my G4).

Now my question is: how can I control that lnk creates a shared 
library consisting of FORTRAN routines. Does anybody have a hint?


For MPW/Absoft users I include the contents of the make file


TargetName   =  splancsLib
Makefile     = # "{TargetName}".make
ObjDir_ppc   = :

# Power Macintosh tools and default settings

f77_ppc          = "{AbsoftTools}f77" -c
f77_ppc_opts     =

# Object and resource files used for this build:



# Linkage rule

"{TargetName}"  {PPC_OBJECTS} {makefile}
  lnk -O -xm library -o "{TargetName}" -export "{TargetName}.x" 
  lnk -O -xm sharedLibrary -o "{TargetName}" -export "{TargetName}.x" 
     {PPC_OBJECTS} {PPC_LIBS}  -aliases {AbsoftLibraries}absoft_aliases 

# Compilation rules

"{ObjDir_ppc}areapl.o"  "areapl.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}areapl.o" areapl.f

"{ObjDir_ppc}cncvwt.o"  "cncvwt.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}cncvwt.o" cncvwt.f

"{ObjDir_ppc}dokhat.o"  "dokhat.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}dokhat.o" dokhat.f

"{ObjDir_ppc}inpip.o"  "inpip.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}inpip.o" inpip.f

"{ObjDir_ppc}ipippa.o"  "ipippa.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}ipippa.o" ipippa.f

"{ObjDir_ppc}iplace.o"  "iplace.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}iplace.o" iplace.f

"{ObjDir_ppc}k12hat.o"  "k12hat.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}k12hat.o" k12hat.f

"{ObjDir_ppc}kernel3d.o"  "kernel3d.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}kernel3d.o" kernel3d.f

"{ObjDir_ppc}khvc.o"  "khvc.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}khvc.o" khvc.f

"{ObjDir_ppc}khvmat.o"  "khvmat.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}khvmat.o" khvmat.f

"{ObjDir_ppc}krnnrm.o"  "krnnrm.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}krnnrm.o" krnnrm.f

"{ObjDir_ppc}krnqne.o"  "krnqne.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}krnqne.o" krnqne.f

"{ObjDir_ppc}krnqrt.o"  "krnqrt.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}krnqrt.o" krnqrt.f

"{ObjDir_ppc}nndist.o"  "nndist.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}nndist.o" nndist.f

"{ObjDir_ppc}plarea.o"  "plarea.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}plarea.o" plarea.f

"{ObjDir_ppc}sekhat.o"  "sekhat.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}sekhat.o" sekhat.f

"{ObjDir_ppc}sort.o"  "sort.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}sort.o" sort.f

"{ObjDir_ppc}sort2.o"  "sort2.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}sort2.o" sort2.f

"{ObjDir_ppc}stkhat.o"  "stkhat.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}stkhat.o" stkhat.f

"{ObjDir_ppc}stsecal.o"  "stsecal.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}stsecal.o" stsecal.f

"{ObjDir_ppc}tribble.o"  "tribble.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}tribble.o" tribble.f

"{ObjDir_ppc}twodimmse.o"  "twodimmse.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}twodimmse.o" twodimmse.f

"{ObjDir_ppc}weight.o"  "weight.f" {makefile}
  {f77_ppc} {f77_ppc_opts} -o "{ObjDir_ppc}weight.o" weight.f

  Delete -i "{TargetName}" {PPC_OBJECTS}

Andreas Papritz, Institute of Terrestrial Ecology ETH Zurich,
Grabenstr. 3, CH-8952 Schlieren, Switzerland
phone +41 1 633 6072, fax +41 1 633 1123