- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I would like to check that my understanding of how Fortran handles string arguments is correct.
When using the default calling convention, IVF passes the length of the string arguments at the end of all arguments. For instance the subroutine
SUBROUTINE TEST(A,B,C,D)
IMPLICIT NONE
CHARACTER(LEN=10),INTENT(IN) :: A
REAL(8),INTENT(IN) :: B
CHARACTER(LEN=50),INTENT(IN) :: C(10)
LOGICAL,INTENT(OUT) :: D
...
END SUBROUTINE TEST
would actually have an *interface* that looks like: TEST(A,B,C,D,len_a,len_c) where len_a = 10 and len_c = 50 (ie, that is how it should be called from a JAVA code for instance).
Is this correct? Does the presence of the character array C complicate things?
Thanks,
Olivier
I would like to check that my understanding of how Fortran handles string arguments is correct.
When using the default calling convention, IVF passes the length of the string arguments at the end of all arguments. For instance the subroutine
SUBROUTINE TEST(A,B,C,D)
IMPLICIT NONE
CHARACTER(LEN=10),INTENT(IN) :: A
REAL(8),INTENT(IN) :: B
CHARACTER(LEN=50),INTENT(IN) :: C(10)
LOGICAL,INTENT(OUT) :: D
...
END SUBROUTINE TEST
would actually have an *interface* that looks like: TEST(A,B,C,D,len_a,len_c) where len_a = 10 and len_c = 50 (ie, that is how it should be called from a JAVA code for instance).
Is this correct? Does the presence of the character array C complicate things?
Thanks,
Olivier
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are correct, but in a restricted sense. Knowledge about the protocol for passing string length arguments is needed only if only if you do not use the C-interoperability module. In that case, the compiler vendor is free to implement the passing of hidden length arguments. Indeed, Intel Fortran and Compaq Visual Fortran used a different order for passing the arguments.
A second issue connected to mixed-language programming involves name decoration. This is also something that you will need to work with, and compilers usually provide options for controlling how the decoration is done.
A second issue connected to mixed-language programming involves name decoration. This is also something that you will need to work with, and compilers usually provide options for controlling how the decoration is done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
Yes - I just want to double check for the character array that I just need to pass one extra integer representingthe string length of its elements (as opposed toan extra array containing thestring lengths for all of the character array elements).
Olivier
Yes - I just want to double check for the character array that I just need to pass one extra integer representingthe string length of its elements (as opposed toan extra array containing thestring lengths for all of the character array elements).
Olivier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Make sure that the length you pass is an address-sized integer. INTEGER(4) on IA-32, INTEGER(8) on x64.

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