This is a disconnect between the debug information the fortran compiler produces and dbx.
Internally, the fortran compiler treats an array of character(len) as a 2D array (1:len(var), 1:size(var))
The interaction between fortran and dbx has been corrected in solarisstudio12.3. There dbx correctly identifies trimmed_mask as an allocatable array of character.
(dbx) whatis trimmed_mask
Regarding the behavior you see on the assignment, the behavior of the fortran compiler is correct. You have not declared a length 21 character string, you've declared an array of 21 length 1 character strings. When performing an array assignment: array = scalar, each element of the array is assigned the scalar value. Fortran semantics for character assignment is to truncate the right hand side to fit the left hand side, so each element of the array is assigned '/'.
What you probably wanted to use was a deferred length character string. Unfortunately solaris studio won't support deferred length characters until the next release.
CHARACTER*21 data_mask CHARACTER(:), ALLOCATABLE::trimmed_mask INTEGER howBig data_mask = '/data/products/tests/' allocate(character(21):: trimmed_mask) howBig = len(trimmed_mask) trimmed_mask = data_mask deallocate(trimmed_mask) END
Another possibility is to use a scalar allocatable. Scalar allocatables are supported in solarisstudio12.2, although the interaction with dbx seems not to have been fixed til solarisstudio12.3
CHARACTER*21 data_mask CHARACTER(21), ALLOCATABLE::trimmed_mask INTEGER howBig data_mask = '/data/products/tests/' allocate(trimmed_mask) howBig = len(trimmed_mask) trimmed_mask = data_mask deallocate(trimmed_mask) END