From mboxrd@z Thu Jan 1 00:00:00 1970
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fee84,155cd148fb637302
X-Google-Attributes: gidfee84,public
From: lionel@quark.zko.dec.com (Steve Lionel)
Subject: Re: Calling FORTRAN from cxx
Date: 1996/06/17
Message-ID: <4q4elq$174@zk2nws.zko.dec.com>#1/1
X-Deja-AN: 160689346
distribution: world
sender: lionel@quark.enet.dec.com (Steve Lionel)
references: <31C01EAC.41C6@bham.ac.uk>
organization: Digital Equipment Corporation, Nashua NH
reply-to: lionel@quark.zko.dec.com (Steve Lionel)
newsgroups: comp.unix.osf.osf1
In article <31C01EAC.41C6@bham.ac.uk>, PS Hatton
writes:
|>Is it possible to call a FORTRAN (77 or 90) routine from cxx? Section
|>2.3.13 of 'Using DEC C++ for DEC OSF/1 Systems' says that
|>
|>'Specifying linkage other than "C++" or "C" generates a compile-
|>time error' (which it does)
|>
|>which would imply not, and not specifying anything on the extern
|>statement in the calling C++ code generates a linker error. Calling
|>FORTRAN from C, as per the Fortran manuals, works fine.
Use the "C" linkage and make sure you declare the arguments so that they are
passed by reference and not value. The routine name should be downcased
and have an underscore appended to it, so if the Fortran routine is named
FOO, in C++ declare it as foo_.
--
Steve Lionel mailto:lionel@quark.zko.dec.com
Fortran Development http://www.digital.com/info/slionel.html
Digital Equipment Corporation
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698 "Free advice is worth every cent"
For information on Digital Fortran, see http://www.digital.com/info/hpc/fortran/