Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

Fortran 2003 ISO_C_BINDING: which version of Intel first supported this?

Darrell
Beginner
480 Views
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)
0 Kudos
1 Reply
Steven_L_Intel1
Employee
480 Views

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.
0 Kudos
Reply