- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a subroutine that has a dummy argument declared:
CHARACTER CHRAY(*)*(*)
I don't know what this means. And how would I declare a variable in the calling program that would be passed to this argument?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is an assumed-size array of passed-length character values. You could pass any array of character values to it. Inside the subroutine, the length of the actual argument strings will be available, but the upper bound is not. It is equivalent to:
CHARACTER(LEN=*), DIMENSION(*) :: CHRAY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the quick response, Steve. So can each string in the array be of different allocated size? And do you know how I would declare this data type so that it can be called from C using C/Fortran interoperability?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, all strings would be the same length. Fortran doesn't have the concept of arrays of different-sized strings. The way you'd have to do such a thing in Fortran would be an array of derived type where the type contains a CHARACTER(:), ALLOCATABLE component.
C interoperability in Fortran does not allow for character entities that have length other than 1. It also does not allow for passed-length character arguments. I don't think there's an obvious corresponding declaration for this in C. It would be a char[n*m] where n is number of elements and m is length of each one. You'd also have to pass the element length as a separate argument, of type size_t, by value, at the end of the argument list. This is implementation-specific and outside the scope of C interoperability.

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