Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, All: I plan to using a fortran 90 program in C++. I have no experience about that, and I have some question about that. 1. I think I have two methods to using the fortran 90 program. First, compile all the .f90 and .cpp to .obj, and link them. Second, make the fortran 90 program to a dll, and call it in C++ project. I want to know, which is better, and how I should do? 2. In the fortran 90 program, there many Types. How can I using them in C++. Thank you very much.
Post Follow-up to this messageFlyVenus wrote: > Hi, All: > I plan to using a fortran 90 program in C++. I have no experience > about that, and I have some question about that. > > 1. I think I have two methods to using the fortran 90 program. > First, compile all the .f90 and .cpp to .obj, and link them. Second, > make the fortran 90 program to a dll, and call it in C++ project. I > want to know, which is better, and how I should do? The second method is likely to involve less pain in terms of figuring out which linker to use, etc. You will still need to use the manual for your Fortran compiler to make sure that your Fortran routine in the dll is designed correctly to be called from C++. > 2. In the fortran 90 program, there many Types. How can I using > them in C++. See the manual for your Fortran compiler on mixed language programming. Possibly, all you will need to do is specify SEQUENCE and make sure that the TYPEs are compatible with C++ (i.e. no pointers or allocatables).
Post Follow-up to this messageOn Apr 1, 2:47 am, Craig Powers <eni...@hal-pc.org> wrote: > FlyVenus wrote: > > > The second method is likely to involve less pain in terms of figuring > out which linker to use, etc. You will still need to use the manual for > your Fortran compiler to make sure that your Fortran routine in the dll > is designed correctly to be called from C++. > > > See the manual for your Fortran compiler on mixed language programming. > Possibly, all you will need to do is specify SEQUENCE and make sure > that the TYPEs are compatible with C++ (i.e. no pointers or allocatables).=[/color ] Thank you. I use the Intel=AE Visual Fortran Compiler. And the bad news is the TYPEs contain lots of pointers...
Post Follow-up to this messageOn Mon, 31 Mar 2008 18:33:05 -0700 (PDT), FlyVenus <duguguiyu@gmail.com> wrote: >I use the Intel® Visual Fortran Compiler. And the bad news is the >TYPEs contain lots of pointers... There is a detailed chapter in the Intel Visual Fortran documentation on mixed-language programming. You should also look at the Fortran 2003 C Interoperability features supported by that compiler. The use of pointers is not necessarily a big problem. If you need more help, feel free to ask in the Intel user forum at [url]http://softwarecommunity.intel.com/isn/Community/en-US/forums/1005/ShowForum.aspx[ /url] -- Steve Lionel Developer Products Division Intel Corporation Nashua, NH For email address, replace "invalid" with "com" User communities for Intel Software Development Products http://softwareforums.intel.com/ Intel Fortran Support http://support.intel.com/support/pe...cetools/fortran My Fortran blog http://www.intel.com/software/drfortran
Post Follow-up to this messageFlyVenus wrote: > On Apr 1, 2:47 am, Craig Powers <eni...@hal-pc.org> wrote: > > Thank you. > I use the Intel® Visual Fortran Compiler. And the bad news is the > TYPEs contain lots of pointers... If they have POINTERs in them, then I would think they'll be pretty much impossible to use directly in C++ without making the C++ code dependent on the IVF "dope vector" implementation (which is possible, but undesirable due to extreme lack of portability). However, it may be possible to come up with a scheme where the objects are managed in Fortran, with an interface to manipulate them that is exposed to C++.
Post Follow-up to this messageOn Tue, 01 Apr 2008 13:32:14 -0400, Craig Powers <enigma@hal-pc.org> wrote: >If they have POINTERs in them, then I would think they'll be pretty much >impossible to use directly in C++ without making the C++ code dependent >on the IVF "dope vector" implementation (which is possible, but >undesirable due to extreme lack of portability). However, it may be >possible to come up with a scheme where the objects are managed in >Fortran, with an interface to manipulate them that is exposed to C++. My advice, if one has the flexibility, is to use the F2003 C Interop feature s. Give the derived type the BIND(C) attribute and have it contain components o f TYPE(C_PTR). One can use functions in ISO_C_BINDING to convert between that and Fortran POINTER. This is supported by IVF and is portable (to other compilers supporting this F2003 feature.) -- Steve Lionel Developer Products Division Intel Corporation Nashua, NH For email address, replace "invalid" with "com" User communities for Intel Software Development Products http://softwareforums.intel.com/ Intel Fortran Support http://support.intel.com/support/pe...cetools/fortran My Fortran blog http://www.intel.com/software/drfortran
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.