- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know there are lots of topics about this issue, but I still can't figure out how to do it. Sorry...
I am working on a mixed fortran/C++ code (VS2010/IVF 2013.1.119). The fortan part is quite old (most is fortran IV). Up to now, all variables are in COMMON blocks, and accessed by C++ using extern "C" struct.
However, I am now implementing some new features using modules and allocatable variables, that must also be accessed by C++. I've searched and read about it, but could not make it work. BTW: my knowledge of C++ is very, very basic.
The original code for the module is:
module AreaData
implicit none
integer(4) :: CaseNumArea
real(8), dimension(:), allocatable :: areaINTER
integer(4), dimension(:), allocatable :: area2ext
character(len=36), dimension(:), allocatable :: areaNOME
integer(4) :: ext2area(998)
logical(1), dimension(:), allocatable :: areaLFRSelect
end module AreaData
As long as I could figure out, I should include use iso_c_bindind, change interger(4) to integer(C_INT), real(8) to real(C_DOUBLE), logical(1) to logical(C_BOOL). The basic questions: (i) what about the character variable? (ii) how would the C++ code look like? (iii) is it necessary to use BIND(C)?
Thanks for the help.
Andrea
PS: How do I insert a code block into the post?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is nothing that directly corresponds to a Fortran array of character strings that I can think of. You could make it an array of structs with the struct containing a char[36]. The allocatable attribute isn't something you can play with on the C++ side at this time, but there's no problem passing allocatable arrays as ordinary data.
![](/skins/images/1FC86CD46823E418D1E2B7B4DC10231C/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page