- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I need a simple way to return an array of strings with unknown size to C#. Here there is a sample code of fortran subroutine:
[fortran]
subroutine testStringArray(strArr)
! directive
!DEC$ ATTRIBUTES DLLEXPORT, Alias:'testStringArray' :: testStringArray
! argument
character(len=32),allocatable,intent(out) :: strArr(:)
! local variable
integer :: size
! main
print*, 'Please enter the size of array:'
read(*,*) size
allocate(strArr(size))
strArr='Hello world'C
end subroutine testStringArray
[/fortran]
Can anyone give me a C# code to use this subroutine?
There is no matter in changing the directives, interface, arguments and body of subroutine. my main goal is returing strings to C#.
Best regards, Arash.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would recommend using a SafeArray to set up your string array, then using Marshalas(UnmanagedType.SafeArray) on the C# side.
There is a Fortran SafeArray example that comes with the Intel compiler that you an utilise for guidance.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page