From: smryan@netcom.com (@#$%!?!)
Subject: Re: C calling Fortran 77 shared library on OSF/1 (or DUnix ?)
Date: 1996/05/02 [thread overview]
Message-ID: <smryanDqs5uu.Gvu@netcom.com> (raw)
In-Reply-To: 4m9s2v$f6u@newton.cc.rl.ac.uk
: 2) Also any one tried to mix character*(*) array(length) and char *array[]
: (or char **array) when making calls from C into Fortran 77 functions ?
My fortran is growing hazy, but I think that for character parameters,
you pass in both the address of the characters and the string length. For
an assumed size string, it uses that as the actual string length. Otherwise
it uses whatever the subprogram says the string length should be. The
string length could be packed with the characters or a separate parameter.
If you need assumed length strings, you're going to have to discover the
calling conventions.
I don't remember fortran strings as being variable length, that is with a
terminating mark or current string length. You're given a character vector
and ways to move it around, but not much more.
: 3) What do I do with the common blocks when I create the shared library
: from its object and 'normal' library parts? Does ld know how to find
: the commons and deal with them automatically ? What about block data
: units ones ?
Fortran common is the same as a c global variable.
REAL X,Y,Z
COMMON /XYZ/ X,Y,Z
is the same as
struct {float x,y,z;} xyz; /*or _xyz or xyz_ or _xyz_ or XYZ or ...*/
Fortran is case insensitive. Many compilers downcase the external names. Also
many compilers prefix or suffix a '_' to externals to prevent a collision with
library entry point. Many c and fortran compilers. So you may have to play
games to get the underscores right.
The C version of block data is that you only define a global in one file.
In other source files, it must be declared extern. I don't know how ld
decides which block data to load. Perhaps it only permits one among all
the *.o files?
--
The Queen who loves, the Queen of life, | smryan@netcom.com PO Box 1563
the Queen who straits, the Queen of strife;| Cupertino, California
with gasp of death or gift of breath | (xxx)xxx-xxxx 95015
she brings the choice of birth or knife. | I don't use no smileys
next prev parent reply other threads:[~1996-05-02 4:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-05-02 4:00 C calling Fortran 77 shared library on OSF/1 (or DUnix ?) Rachel Kay Street
1996-05-02 4:00 ` @#$%!?! [this message]
1996-05-04 4:00 ` Sergio Gelato
1996-05-07 4:00 ` William Deich
1996-05-08 4:00 ` Sergio Gelato
1996-05-06 4:00 ` Steve Lionel
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox