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

Dummy argument declared character(*)*(*) - what does this mean?

Daniel_Owen
Beginner
689 Views

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?

0 Kudos
3 Replies
Steven_L_Intel1
Employee
689 Views

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

0 Kudos
Daniel_Owen
Beginner
689 Views

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?

0 Kudos
Steven_L_Intel1
Employee
689 Views

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.

0 Kudos
Reply