- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a few occurrences of a scalar character variable being passed into a subroutine expecting a character array:
character*20 title
CALL wrap_kzpwwa(title, 1)
.......
SUBROUTINE wrap_kzpwwa(carr, nel)
integer :: nel
character*(*) :: carr(nel)
This compiles just fine on my machine, but the build machine gives:
"Error: If the actual argument is scalar, the corresponding dummy argument shall be scalar unless the actual argument is an element of an array that is not an assumed-shape or pointer array, or a substring of such an element. [CARR] "
Even if I use the same compiler arguments, I still cannot get it to fail in this way on my machine. Obviously I can fix this by creating another routine which expects a scalar and call that one instead, however I am intrigued as to why this works just fine on my machine but not on another machine. Is there a difference in behavior between different compiler versions? How can I get this to fail on my machine so I can be sure my fixes don't break the overnight build?
Why is this just a problem with character variables?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
CHARACTER(LEN=nel) :: carr
This works if nel is a PARAMETER constant, not sure how it works with an argument variable.
You may need to add
INTEGER, INTENT(IN) :: nel
Regards,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No NEL is the length of the character string, not the array dimension. Actually I think this is a compiler bug since I have 5 calls to wrap_kzpwwa in the calling routine, and it only fails on the last 2 calls. The only difference is that the first 3 calls are character scalars in external modules while the last 2 (which fail) are local character scalars.
I'll wait for the Intel folk to comment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Fortran language prohibits passing a scalar to an an array, with one exception. You may pass a character scalar to an array of length-1 characters. Your declaration is not that - you would need to say CHARACTER*1 not CHARACTER*(*).
The difference you are seeing is likely due to generated interface checking being on in the case where you get the error and off or unavailable where you don't.

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