From Kurt.Hornik@ci.tuwien.ac.at  Mon Apr 12 07:20:18 1999
From: Kurt.Hornik@ci.tuwien.ac.at (Kurt Hornik)
Date: Mon, 12 Apr 1999 08:20:18 +0200 (CEST)
Subject: Fortran vs C, easing using Fortran
In-Reply-To: <Pine.GSO.4.05.9904110750450.3678-100000@auk.stats>
References: <6r7lrk16hk.fsf@verdi.stat.wisc.edu>
 <Pine.GSO.4.05.9904110750450.3678-100000@auk.stats>
Message-ID: <14097.37026.863229.382113@pc87.maho.magnaeu.com>

>>>>> Prof Brian D Ripley writes:

> On 10 Apr 1999, Douglas Bates wrote:
>> >>>>> "Ross" == Ross Ihaka <ihaka@stat.auckland.ac.nz> writes:
>> 
Ross> To follow up the "eigen" issue.  What should our position on
Ross> translating Fortran into C be?  Should we leave as much code
Ross> as possible in Fortran or should we move it to C as much as
Ross> possible?
>> 
>> I can think of three different sets of circumstances:
>> a) creating new code: This one is obvious, just say "no" to Fortran.
>> b) enhancing existing code: For something small do the automatic
>> translation to C with f2c then modify the C sources and regard
>> those as the definitive version.  For a big Fortran routine, try
>> to write a C wrapper around it and make modifications in the
>> wrapper. 
>> c) using established code without modification (e.g. Eispack, Linpack):
>> Regard the Fortran sources as the definitive version and don't
>> translate.
>> 
>> Now that g77 is available and reasonably stable, a lot of the
>> motivation for using f2c is gone.  There are still the messy linkage
>> issues when calling Fortran from C but most of those are now resolved
>> by the configure script.  Passing character strings, etc. will
>> continue to be problematic but most of the legacy Fortran code we
>> would use will be strictly numerical routines with, we hope,
>> comparatively simple calling sequences.  (Lapack is an exception in
>> that it uses strings to declare options but we aren't using Lapack.)

> [A long reply: I am much-bitten here!]

> ...

> I think in R we can do better than at present, if only I knew exactly
> how. One idea is to have (effectively) a `hints' file that configure
> uses to add a base set of libraries to FLIBS, but on Solaris at least,
> using the Fortran command (f77 or g77) to link a dynamic library does
> the job.  For linking with ld the base FLIBS would need to be

> -lF77 -lM77 -lV77 -lsunmath -lm

> _if_ f77 is used.  How viable is `use FC to link' on other platforms?

Are you suggesting using the Fortran compiler as SHLIBLD?

Please help me understanding this a bit more.  The above `-lF77 ...'
would be the default FLIBS to use when compiling/linking Fortran?

Short term fix should be to use platform-specific overrides in basic
configure.  Another idea is to have configure scripts supported for add
ons.

(If I fully understood the problem, I think I could fix it ...)

=k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


Fortran vs C, easing using Fortran
Kurt Hornik