experchange > fortran

db (01-11-19, 05:32 PM)
I have a subroutine in C++ that I want to refer to
in a Fortran program. How do I do that?
Arjen Markus (01-11-19, 05:38 PM)
On Friday, January 11, 2019 at 4:32:24 PM UTC+1, db wrote:
> I have a subroutine in C++ that I want to refer to
> in a Fortran program. How do I do that?
> --
> Dieter Britz


You can use the ISO_C_BINDING module and BIND(C) to create the interface needed from the Fortran side, but as C++ mangles the name, you need to do something on the C++ side as well:

extern "C" {
your C++ routine
}

as this will insure the C++ routine is callable from C and transitively from Fortran.

That at the least is the start :). Depending on the character of the C++ routine, you may need to do other things as well - you may need to deal with objects and references for instance.

Regards,

Arjen
Wolfgang Kilian (01-11-19, 05:40 PM)
On 11.01.2019 16:32, db wrote:
> I have a subroutine in C++ that I want to refer to
> in a Fortran program. How do I do that?


IFAIK, there is no standard to interface C++ entities from Fortran
directly (name mangling, etc.).

Our approach is to write an interface to the C++ entity using the

extern "C"

idiom that C++ provides. This goes into a C++ source code file. The
same entity can then be accessed by Fortran using the BIND(C) idiom.
This works reliably as long as there are no exotic contructs involved in
the argument lists. C pointers are no problem.

The Fortran compiler may have to be told to link with the stdc++
library, and maybe others as well.

-- Wolfgang
Sjouke Burry (01-11-19, 08:58 PM)
On 11-1-2019 16:32, db wrote:
Lynn McGuire (01-12-19, 03:25 AM)
On 1/11/2019 9:32 AM, db wrote:
> I have a subroutine in C++ that I want to refer to
> in a Fortran program. How do I do that?


Which platform and which Fortran compiler ?

Lynn
db (01-12-19, 05:18 PM)
On Fri, 11 Jan 2019 19:25:37 -0600, Lynn McGuire wrote:

> On 1/11/2019 9:32 AM, db wrote:
>> I have a subroutine in C++ that I want to refer to in a Fortran
>> program. How do I do that?

> Which platform and which Fortran compiler ?
> Lynn


Ubuntu 16.04 and gfortran.
Lynn McGuire (01-15-19, 12:59 AM)
On 1/12/2019 9:18 AM, db wrote:
> On Fri, 11 Jan 2019 19:25:37 -0600, Lynn McGuire wrote:
> Ubuntu 16.04 and gfortran.


The previous advice is good for you then. You will need to compile the
C++ code with extern "C". You then use the ISO_BINDING feature in the
Fortran code (I have never used this as I use the old F77 to C syntax).

Lynn
brooksj631 (01-15-19, 09:14 AM)
CONTACT US FOR Pain Pills,Nembutal,Seconal ,Oxycotin, Dilaudid,Valium,Hydrocodone & Ritalin Online.
call or text +1(405)500-0724
website :
email me at cliffbudman237
Hello, we are suppliers of assorted pain killers and anxietay pain relief meds, and other research chemicals. Discount are also applicable for bulk buyers.The shipping is meticulously planned; packaging is done with professionalis.
We have the following meds below available in stock now for auction;
Pain/ Anxiety Pills
Seconal
Nembutal (Powder,Pills and Liquid form)
Oxycotin / Oxycodone 10,20 a,40 and 80 mg
Actavis Promethazine Codeine Purple Cough Syrup (16oz and 320z)
Hydrocodone 10500, 10325 ,7.5750 mg
Valium 10,15 and 20 mg
Xanax 1 and 2 mg
Dilaudid 2,4 and 8 mg
Ritalin 5,10, 20 mg
Percocet 7.5mg,5mg and 10mg
Opana 20mg and 40mg
Lorcet - (Hydrocodone Bitartrate/Acetaminophen) 10 mg/650 mg
Midazolam 3mg
Motrin 400mg and 600mg
Norco - ( Hydrocodone Bitartrate/Acetaminophen ) 5 mg/325 mg
Soma 350mg
Tramadol (Ultram) 50mg
Valium 2mg,5mg and 10mg
Valium Roche Brand 10mg
Voltaren 50mg and 100mg
Adderall,Anaprox,Ansaid,Acephen
Bupren , ex,Butrans
Percocet,Phrenilin,Percodan
Soma, , Subutex
Cataflam,Celebrex
Flexeril, Fentora ..,
Demerol,Daypro,Dilaudid
Endocet
Lorcet, L, ortab
Ibudone
Methadone,Morphine
Naprosyn , ,Norco
Oxycontin, Opana
Ritalin, Roxicodone®
Similar Threads