- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We're happily retiring our old warhorse Compaq Visual Fortran version 6 and porting all our code to the latest Intel Visual Fortran 11. However, our customer currently insists on using Intel Visual Fortran 9 (and Microsoft Visual Studio 2005). When (which version) did Intel start supporting Fortran 2003's ISO_C_BINDING?
Currently I'm trying to call Fortran from C++ with the Fortran routine returning a pointer to a dynamically allocated string array. Are there any examples of using ISO_C_BINDING? Please tell me if I'm a crazy LART. :-) Thanks!
some of the code is below--buffer is the output argument to the subroutine while buffer2 is used internally and passed into "normal" subroutines...
character(256), dimension(:), pointer :: buffer
character(256), allocatable, dimension(:) :: buffer2
allocate(buffer(nmax), buffer2(nmax))
buffer= ''
buffer2= ''
do i= 1,nmax
buffer2(i) = 'Will this work?'
end do
buffer= buffer2
deallocate(buffer2)
Currently I'm trying to call Fortran from C++ with the Fortran routine returning a pointer to a dynamically allocated string array. Are there any examples of using ISO_C_BINDING? Please tell me if I'm a crazy LART. :-) Thanks!
some of the code is below--buffer is the output argument to the subroutine while buffer2 is used internally and passed into "normal" subroutines...
character(256), dimension(:), pointer :: buffer
character(256), allocatable, dimension(:) :: buffer2
allocate(buffer(nmax), buffer2(nmax))
buffer= ''
buffer2= ''
do i= 1,nmax
buffer2(i) = 'Will this work?'
end do
buffer= buffer2
deallocate(buffer2)
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10.0 was the first version to support the C interoperability features, but I would recommend no earlier than version 10.1 as there were some serious bugs at first. A Fortran pointer is not the same as a C pointer. With the C interop stuff you can use C_LOC on an item to create a value of type C_PTR that C will understand as a pointer. Note that your strinsg will be blank padded and have no trailing NUL - you may want to add that.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page