Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python/Fortran interoperability

Reply
Thread Tools

Python/Fortran interoperability

 
 
sturlamolden
Guest
Posts: n/a
 
      08-24-2009
On 24 Aug, 21:24, (E-Mail Removed) wrote:

> You might also like to consider the converse problem: how to write
> a Fortran function that takes a C string of arbitrary length and
> uses it.


That's what the code I showed you does.

 
Reply With Quote
 
 
 
 
James Van Buskirk
Guest
Posts: n/a
 
      08-24-2009
"Richard Maine" <(E-Mail Removed)> wrote in message
news:1j4y84p.v5docbtueccmN%(E-Mail Removed)...

> There might be a confusion here (and I'm not even sure on whose part) on
> a picky but important detail of wording. I have seen multiple people
> confused by this one before. In fact, some potential confusion was
> forseen, which is why there are notes specifically about it in the
> Fortran standard (see below). Those notes do tend to get overlooked
> though.


> Only character strings of length 1 are interoperable, as the term
> "interoperable" is defined in the Fortran standard. However, that does
> not mean that only character strings of length 1 will work with C. The
> distinction might be picky, but it is important.


> See Note 15.19 (which in turn cites an example in Note 15.23) of f2003.
> You can pass a Fortran string of length n as an actual argument
> corrseponding to a dummy argument that is an array of n character*1
> elements. This isn't considered a question of "interoperability", as it
> is a feature purely within Fortran, but it does impact on what kinds of
> things work.


> One might plausibly regard this as a kludge, but it is a kludge that is
> part of the Fortran standard and is guaranteed to work with all Fortran
> compilers. I almost said all f2003-compliant compilers (admittedly a
> limited set), but then I recalled that the feature actually dates back
> to f77 when character type was introduced; f2003 just extends it to the
> C character kind for the obscure case where the C character kind might
> be different from the default character kind (I don't know of any
> compilers where this is so, but the standard allows for it).


No, this is a tricky point. It was allowed in f77 to pass an array
actual argument to a scalar character dummy argument, but the ability
to pass a scalar character actual argument to an array dummy argument
is new to the sequence association rules of f2003. So your first
impression was more accurate than the result of thoughtful reflection

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


 
Reply With Quote
 
 
 
 
Richard Maine
Guest
Posts: n/a
 
      08-24-2009
James Van Buskirk <(E-Mail Removed)> wrote:

> "Richard Maine" <(E-Mail Removed)> wrote in message
> news:1j4y84p.v5docbtueccmN%(E-Mail Removed)...
>


> > One might plausibly regard this as a kludge, but it is a kludge that is
> > part of the Fortran standard and is guaranteed to work with all Fortran
> > compilers. I almost said all f2003-compliant compilers (admittedly a
> > limited set), but then I recalled that the feature actually dates back
> > to f77 when character type was introduced; f2003 just extends it to the
> > C character kind for the obscure case where the C character kind might
> > be different from the default character kind (I don't know of any
> > compilers where this is so, but the standard allows for it).

>
> No, this is a tricky point. It was allowed in f77 to pass an array
> actual argument to a scalar character dummy argument, but the ability
> to pass a scalar character actual argument to an array dummy argument
> is new to the sequence association rules of f2003. So your first
> impression was more accurate than the result of thoughtful reflection


Ah. You might be right - probably you are. I know there is some closely
related stuff that goes back a ways and was just extended to the C
character kind in f2003, but it might not have been that exact bit. I'm
probably thinking of the rule for sequence association that allows the
character length parameter to differ between the actual and dummy... as
long as you are doing sequence association. But it might be a new rule
that puts the scalar case under sequence association; that's probably
it. Not worth dragging out the standards to check, but I bet that's it.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Proxim and Cisco Access Point Interoperability? Hal Kuff Cisco 1 10-04-2006 03:38 PM
Wireless interoperability between Cisco Aironet and Orinoco. AM Cisco 2 06-10-2005 12:31 PM
.NET & Windows Messenger interoperability Ioannis Vranos ASP .Net 2 04-13-2004 12:25 PM
PVST interoperability with Cabletron/Enterasys Mortimer Mouse Cisco 2 04-01-2004 04:34 PM
CISCO and Juniper Interoperability Syed J farooqi Cisco 0 01-23-2004 01:29 PM



Advertisments