Array-valued character function errors

Hi, I have a double error with pgf90 in a function returning an array of character, the simplest program that reproduces the error is the following:

PROGRAM err
INTEGER, PARAMETER :: sl=10, sd=100
CHARACTER(len=sl) :: v1(sd), v2(sd)
v1=' '
PRINT*,v1 ! OK
PRINT*,arr_str_fun(sl, v1) ! SEGFAULT
v2 = arr_str_fun(sl, v1) ! SEGFAULT

CONTAINS

FUNCTION arr_str_fun(vlen, vect)
INTEGER :: vlen
CHARACTER(len=vlen),INTENT(in) :: vect(:)
CHARACTER(len=vlen) :: arr_str_fun(SIZE(vect))

arr_str_fun(:)=vect(:)
END FUNCTION arr_str_fun

END PROGRAM err

The error (segmentation fault or some other kind of (de)allocating error, or no error but a vector shorter than expected, depending on the code) happens on return from the function arr_str_fun, it seems as if the main program does not receive a correct value for the size of the vector returned. This happens with 7.0-4 on Linux x86-64, but also with version 6 on 32 bit Linux. More or less the same happens if the size of arr_str_fun is explicitly passed as an argument rather than deduced from the length of vect. However everything seems to work if INTEGERs are used instead of CHARACTERs.
Actually my purpose is to write the function with a simpler interface, which, AFAIK, is legal in f90:

FUNCTION arr_str_fun(vect)
CHARACTER(len=*),INTENT(in) :: vect(:)
CHARACTER(len=len(vect)) :: arr_str_fun(plen)

but the len=len(vect) generates:

PGF90-W-0000-Internal compiler error. constant string length expected      53

I guess this is yet another matter.
I hope something can be one for thiese problems, thank you very much, Davide

Hi Davide,

I think you found a couple of bugs.
We will get back to you with more info shortly.

  • Brent