Re: [S] Fortran compilers

Prof Brian Ripley (ripley@stats.ox.ac.uk)
Thu, 19 Feb 1998 07:58:54 +0000 (GMT)


David Scott wrote:
>
>
> A colleague wishes to have some routines he has developed programmed in
> Fortran. The idea is that the work be done on a Windows machine. The
> question is then what compiler to use.
>
> Some considerations are:
>
> It would be desirable to be able to call the routines from Splus. I
> understand that this means that the Watcom compiler is the one to use, but
> maybe Splus 4 allows other compilers. Any comments?
>
You have three choices:

(a) Use dyn.load with Watcom. This works well with version 10.6, and
the current version 11.0 also works, I am told. Erin Hodgess posted
about the non-use of write statements, but that applies to ALL uses of
Fortran on all systems with S-PLUS.

(b) Make a DLL and use dll.load. There you can use any Fortran compiler
you like that can make a fully-relocatable DLL following cdecl or stdcall
conventions. However, making DLLs is not a natural actvity in Fortran!
You may have to take care that the DLL is linked against the required
libraries. One caveat: the Cygnus port of g77 cannot produce suitable
DLLs.

(c) Use f2c and a C compiler, then dyn.load with Watcom, dll.load
with others. There is a full port of f2c to Win32 at
http://www-personal.umich.edu/~gsar, and for most Fortran code
this is a very viable option. (After all, the GNU Fortran
compiler is basically f2c + gcc.)

> Is Fortran 90 usable or is it necessary to stick with Fortran 77?

I have not tried 95 (or even 90) with S-PLUS. I suspect it is
usable via DLLs.

> The routines would be recompiled on a Sun. Do some compilers deviate from
> the standard so that there would be problems doing this?

First, I don't think you will it easy to use Fortran 95/90 on a Sun, as
the libraries will needed to be linked suitably. Depends a bit which Sun
operating system and which version of S-PLUS and which dynamic-loading
method.

Given that, in my experience the PC compilers are the picky ones with
foibles, and I have never had problems moving code to a Sun compiler.
The sort of problems I have had are with code from statlib written in
some approximation to ratfor, with character strings enclosed in " ",
variable dimensions of arrays defined after they are used, code
after column 72, .... _compilers_ tend to accept standards, but
_programmers_ do not!

>
> I would welcome any advice.
>
There are two sources of information, both on-line.

(1) The Programming Complements to V&R2, available via
http://www.stats.ox.ac.uk/pub/MASS2/Sites.html

(2) The recently-released chapter for the S-PLUS 4.0 Programmer's Guide,
via http://www.mathsoft.com/splus/splsprod/update2.htm last time I looked.

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news