Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 10 HP Fortran statements

LOGICAL

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Declares entities of type logical.

Syntax

LOGICAL [kind-spec] [[, attrib-list] ::] entity-list
kind-spec

specifies the size of the logical entity in bytes. kind-spec takes the form:

([KIND=] kind-param)

where kind-param can be a named constant or a constant expression that has the integer value of 1, 2, 4, or 8. The size of the default type is 4.

As an extension, kind-spec can take the form:

*len-param

where len-param is the integer 1, 2, 4, or 8 (default = 4).

attrib-list

is a list of one or more of the following attributes, separated by commas:

Table 10-31 Title not available (LOGICAL)

ALLOCATABLE

INTRINSIC

PRIVATE

DIMENSION

OPTIONAL

PUBLIC

EXTERNAL

PARAMETER

SAVE

INTENT

POINTER

TARGET

 

If attrib-list is present, it must be followed by the double colon. For information about individual attributes, see the corresponding statement in this chapter.

entity-list

is a list of entities, separated by commas. Each entity takes the form:

name [(array-spec)] [= initialization-expr]

where:

name

is the name of a variable or function

array-spec

is a comma-separated list of dimension bounds

initialization-expr

is a logical constant expression. If initialization-expr is present, entity-list must be preceded by the double colon.

Description

The LOGICAL statement is constrained by the rules for type declaration statements, including the requirement that it precede all executable statements.

As a portability extension, HP Fortran allows the following syntax for specifying the length of an entity:

name [*len] [( array-spec )] [= initialization-expr]

If (array-spec) is specified, *len may appear on either side of (array-spec). If name appears with *len, it overrides the length specified by LOGICAL*size.

Examples

The following are valid declarations:

LOGICAL log1, log2
LOGICAL(KIND=2) :: log3
LOGICAL(2), PARAMETER :: test=.TRUE.
! initialize an array, using an array constructor
LOGICAL, DIMENSION(2) :: lvec=(/.TRUE.,.FALSE./)
! use the slash notation (an HP extension) to initialize
LOGICAL log1/.TRUE./, log2/.FALSE./ ! note, no double colon
! the following declarations are equivalent; the second uses the
! HP length specification extension
LOGICAL (KIND = 8) log8
LOGICAL*4 log8*8

Related statements

INTEGER

Related concepts

For related information, see the following:

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.