02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Description<br />

<strong>HP</strong> <strong>Fortran</strong> statements<br />

CHARACTER<br />

where name isthenameofavariableorfunction,array-spec is a<br />

comma-separated list of dimension bounds, len-spec is either an asterisk<br />

(*) or a specification expression, and initialization-expr is a character<br />

constant expression. If initialization-expr is present, entity-list<br />

must be preceded by the double colon.<br />

The CHARACTER statement is used to declare the length and properties of character data. It is<br />

constrained by the rules for all type declaration statements, including the requirement that it<br />

precede all executable statements.<br />

To indicate that the length of a character can vary, you may use an assumed character length<br />

parameter by specifying an asterisk (*) forlen-param. The asterisk may be used only when<br />

doing the following:<br />

Declaring the type of a function. The function must not be an internal or module function,<br />

nor must it be array-valued, pointer-valued, or recursive.<br />

Declaring a dummy argument of a procedure.<br />

Declaring a named constant (see the PARAMETER statement).<br />

Examples<br />

The following are valid declarations:<br />

CHARACTER c1, c2<br />

CHARACTER(LEN=80) :: text(0:25)<br />

CHARACTER(2, 1), PARAMETER :: limit='ZZ'<br />

! initialize an array, using an array constructor<br />

CHARACTER(4) :: response(3) = (/"Yes.", "No!!", "Huh?"/)<br />

! use slashes as initialization delimiters, an <strong>HP</strong> extension<br />

CHARACTER*10 c1/'Tom'/,c2/'Jones'/ ! note, no double colon<br />

The following are valid uses of the assumed length parameter:<br />

CHARACTER(*) dummy_arg_name<br />

CHARACTER(*), PARAMETER :: hello=”Hi Sam”<br />

CHARACTER(LEN=*), PARAMETER :: hello=”Hi Sam”<br />

Assuming that c is an ordinary variable and not the dummy argument to a procedure, the<br />

following declaration is an illegal use of the assumed length parameter:<br />

CHARACTER*(*) c ! illegal<br />

Related concepts<br />

For related information, see the following:<br />

Chapter 10 263

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!