- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have no problem calling C from Fortran Program. But I cant seem to set up an interface from within a Fortran "Module" DLL.I belive the interface should be inside the subroutine, but no, so place outside, sevaral places. No Joy.
This is a compile time issue.Many compile errors. Is this not "Doable" ? IVF11.1.046/Vista/x64
Here is with interface declared inside subroutine calling on CPP (C++)routine.
Here is the module:
module K3_FortranDLL
contains
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine CreateConnection()
!DEC$ ATTRIBUTES DLLEXPORT :: CreateConnection
interface
subroutine CreateConnectionCPP (string) bind(C,"CreateConnectionCPP")
implicit none
character, dimension(*) :: string
end subroutine CreateConnectionCPP
end interface
character(100) string
integer i
! As an example, write the integers 1 to 10 in a loop
do i=1,10
! Convert the number to a string and add a trailing newline (\\n) plus a NUL termination
write (string,'(I0,A)') i,C_NEW_LINE//C_NULL_CHAR
! Call C++ to write the text
! Note that Fortran allows a character string to be passed to an
! array of single characters. The NUL is needed because no length is passed.
call cout_sub (string)
end do
end subroutine
end module K3_FortranDLL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[fortran]use iso_c_binding[/fortran]after the SUBROUTINE declaration statement. In the Interface, the accepted syntax is
[bash]subroutine CreateConnectionCPP (string) bind(C,name='CreateConnectionCPP')[/bash]With these changes, the module can be compiled with no error messages.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[fortran]use iso_c_binding[/fortran]after the SUBROUTINE declaration statement. In the Interface, the accepted syntax is
[bash]subroutine CreateConnectionCPP (string) bind(C,name='CreateConnectionCPP')[/bash]With these changes, the module can be compiled with no error messages.

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