HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
CHARACTER
Chapter 10 297
where
name
is the name of a variable or function,
array-spec
is a
comma-separated list of dimension bounds,
len-spec
is either an asterisk
(*) or a specification expression, and
initialization-expr
is a character
constant expression. If
initialization-expr
is present,
entity-list
must be preceded by the double colon.
Description
The CHARACTER statement is used to declare the length and properties of character data. It is
constrained by the rules for all type declaration statements, including the requirement that it
precede all executable statements.
To indicate that the length of a character can vary, you may use an assumed character length
parameter by specifying an asterisk (*) for
len-param
. The asterisk may be used only when
doing the following:
Declaring the type of a function. The function must not be an internal or module function,
nor must it be array-valued, pointer-valued, or recursive.
Declaring a dummy argument of a procedure.
Declaring a named constant (see the PARAMETER statement).
Examples
The following are valid declarations:
CHARACTER c1, c2
CHARACTER(LEN=80) :: text(0:25)
CHARACTER(2, 1), PARAMETER :: limit='ZZ'
! initialize an array, using an array constructor
CHARACTER(4) :: response(3) = (/"Yes.", "No!!", "Huh?"/)
! use slashes as initialization delimiters, an HP extension
CHARACTER*10 c1/'Tom'/,c2/'Jones'/ ! note, no double colon
The following are valid uses of the assumed length parameter:
CHARACTER(*) dummy_arg_name
CHARACTER(*), PARAMETER :: hello=”Hi Sam”
CHARACTER(LEN=*), PARAMETER :: hello=”Hi Sam”
Assuming that c is an ordinary variable and not the dummy argument to a procedure, the
following declaration is an illegal use of the assumed length parameter:
CHARACTER*(*) c ! illegal
Related concepts
For related information, see the following: