HP Fortran for OpenVMS
Language Reference Manual


Previous Contents Index

9.4.7 AIMAG (Z)

Description: Returns the imaginary part of a complex number. 1
Class: Elemental function; Generic
Arguments: Z must be of type complex.
Results: The result is of type real with the same kind parameter as Z. If Z has the value (x, y), the result has the value y.

1This function can also be specified as IMAG.

Specific Name Argument Type Result Type
AIMAG 1 COMPLEX(4) REAL(4)
DIMAG COMPLEX(8) REAL(8)
QIMAG COMPLEX(16) REAL(16)

1The setting of compiler options specifying real size can affect AIMAG.

Examples

AIMAG ((4.0, 5.0)) has the value 5.0.

9.4.8 AINT (A [,KIND])

Description: Truncates a value to a whole number.
Class: Elemental function; Generic
Arguments: A Must be of type real.
  KIND (opt) Must be a scalar integer initialization expression.
Results: The result is of type real. If KIND is present, the kind parameter of the result is that specified by KIND; otherwise, the kind parameter is that of A.

The result is defined as the largest integer whose magnitude does not exceed the magnitude of A and whose sign is the same as that of A. If |A| is less than 1, AINT (A) has the value zero.

Specific Name Argument Type Result Type
AINT REAL(4) REAL(4)
DINT REAL(8) REAL(8)
QINT REAL(16) REAL(16)

Examples

AINT (3.678) has the value 3.0.

AINT (--1.375) has the value --1.0.

9.4.9 ALL (MASK [,DIM])

Description: Determines if all values are true in an entire array or in a specified dimension of an array.
Class: Transformational function; Generic
Arguments: MASK Must be a logical array.
  DIM (opt) Must be a scalar integer with a value in the range 1 to n, where n is the rank of MASK.
Results: The result is an array or a scalar of type logical.

The result is a scalar if DIM is omitted or MASK has rank one. A scalar result is true only if all elements of MASK are true, or MASK has size zero. The result has the value false if any element of MASK is false.

An array result has the same type and kind parameters as MASK, and a rank that is one less than MASK. Its shape is (d 1, d 2, ..., d DIM-1, d DIM+1, ..., d n), where (d 1, d 2,..., d n) is the shape of MASK.

Each element in an array result is true only if all elements in the one dimensional array defined by MASK (s 1, s 2, ..., s DIM-1, :, s DIM+1, ..., s n) are true.

Examples

ALL ((/.TRUE., .FALSE., .TRUE./)) has the value false because some elements of MASK are not true.

ALL ((/.TRUE., .TRUE., .TRUE./)) has the value true because all elements of MASK are true.

A is the array <left[ symbol><matrix symbol> 1&5&7<cr symbol> 3&6&8<cr symbol> <right] symbol> and B is the array <left[ symbol><matrix symbol> 0&5&7<cr symbol> 2&6&9<cr symbol> <right] symbol> .

ALL (A .EQ. B, DIM=1) tests to see if all elements in each column of A are equal to the elements in the corresponding column of B. The result has the value (false, true, false) because only the second column has elements that are all equal.

ALL (A .EQ. B, DIM=2) tests to see if all elements in each row of A are equal to the elements in the corresponding row of B. The result has the value (false, false) because each row has some elements that are not equal.

9.4.10 ALLOCATED (ARRAY)

Description: Indicates whether an allocatable array is currently allocated.
Class: Inquiry function; Generic
Arguments: ARRAY must be an allocatable array.
Results: The result is a scalar of type default logical.

The result has the value true if ARRAY is currently allocated, false if ARRAY is not currently allocated, or undefined if its allocation status is undefined.

Examples

Consider the following:


REAL, ALLOCATABLE, DIMENSION (:,:,:) :: E 
PRINT *, ALLOCATED (E)       ! Returns the value false 
ALLOCATE (E (12, 15, 20)) 
PRINT *, ALLOCATED (E)       ! Returns the value true 

9.4.11 ANINT (A [,KIND])

Description: Calculates the nearest whole number.
Class: Elemental function; Generic
Arguments: A Must be of type real.
  KIND (opt) Must be a scalar integer initialization expression.
Results: The result is of type real. If KIND is present, the kind parameter is that specified by KIND; otherwise, the kind parameter is that of A. If A is greater than zero, ANINT (A) has the value AINT (A + 0.5); if A is less than or equal to zero, ANINT (A) has the value AINT (A - 0.5).
Specific Name Argument Type Result Type
ANINT REAL(4) REAL(4)
DNINT REAL(8) REAL(8)
QNINT REAL(16) REAL(16)

Examples

ANINT (3.456) has the value 3.0.

ANINT (--2.798) has the value --3.0.

9.4.12 ANY (MASK [,DIM])

Description: Determines if any value is true in an entire array or in a specified dimension of an array.
Class: Transformational function; Generic
Arguments: MASK Must be a logical array.
  DIM (opt) Must be a scalar integer expression with a value in the range 1 to n, where n is the rank of MASK.
Results: The result is an array or a scalar of type logical.

The result is a scalar if DIM is omitted or MASK has rank one. A scalar result is true if any elements of MASK are true. The result has the value false if no element of MASK is true, or MASK has size zero.

An array result has the same type and kind parameters as MASK, and a rank that is one less than MASK. Its shape is (d 1, d 2, ..., d DIM-1, d DIM+1, ..., d n), where (d 1, d 2,..., d n) is the shape of MASK.

Each element in an array result is true if any elements in the one dimensional array defined by MASK (s 1, s 2, ..., s DIM-1, :, s DIM+1, ..., s n) are true.

Examples

ANY ((/.FALSE., .FALSE., .TRUE./)) has the value true because one element is true.

A is the array <left[ symbol><matrix symbol> 1&5&7<cr symbol> 3&6&8<cr symbol> <right] symbol> and B is the array <left[ symbol><matrix symbol> 0&5&7<cr symbol> 2&6&9<cr symbol> <right] symbol> .

ANY (A .EQ. B, DIM=1) tests to see if any elements in each column of A are equal to the elements in the corresponding column of B. The result has the value (false, true, true) because the second and third columns have at least one element that is equal.

ANY (A .EQ. B, DIM=2) tests to see if any elements in each row of A are equal to the elements in the corresponding row of B. The result has the value (true, true) because each row has at least one element that is equal.

9.4.13 ASIN (X)

Description: Produces the arcsine of X.
Class: Elemental function; Generic
Arguments: X must be of type real. The |X| must be less than or equal to 1.
Results: The result type is the same as X and is expressed in radians. The value lies in the range --Pi sign/2 to Pi sign/2.
Specific Name Argument Type Result Type
ASIN REAL(4) REAL(4)
DASIN REAL(8) REAL(8)
QASIN REAL(16) REAL(16)

Examples

ASIN (0.79345021) has the value 0.9164571.

9.4.14 ASIND (X)

Description: Produces the arcsine of X.
Class: Elemental function; Generic
Arguments: X must be of type real and must be greater than or equal to zero. The |X| must be less than or equal to 1.
Results: The result type is the same as X and is expressed in degrees.
Specific Name Argument Type Result Type
ASIND REAL(4) REAL(4)
DASIND REAL(8) REAL(8)
QASIND REAL(16) REAL(16)

Examples

ASIND (0.2467590) has the value 14.28581.

9.4.15 ASM (STRING [,A,...]) (Alpha only)

Description: Lets you use assembler instructions in an executable program.
Class: Nonelemental function; Generic
Arguments: STRING Must be of type character. It is a character constant or a concatenation of character constants containing the assembler instructions.
  A (opt) Can be of any type. This can be a source or destination argument for the instruction, for example.
Results: The result is a scalar of type INTEGER(8), REAL(4), or REAL(8).

Arguments are passed by value. If you want to pass an argument by reference (for example, a whole array, a character string, or a record structure), you can use the %REF built-in function. (See Section 8.8.9.1.)

Labels are allowed, but all references must be from within the same ASM (Alpha only) function. This lets you set up looping constructs, for example. Cross-jumping between ASM functions is not permitted.

In general, an ASM function can appear anywhere that an intrinsic function can be used. Since the supplied assembly code, assembly directives, or assembly data is integrated into the code stream, the compiler may choose to use different registers, better code sequences, and so on, just as if the code were written in Fortran.

You do not have absolute control over instruction sequences and registers, and the compiler may intersperse other code together with the ASM code for better performance. Better code sequences may be substituted by the optimizer if it chooses to do so.

Only register names beginning with a dollar sign ($) or percent sign (%) are permitted. For more information on register name conventions, see your operating system documentation set.

Specific Name Argument Type1 Result Type
ASM 2 CHARACTER INTEGER(8)
FASM 3 CHARACTER REAL(4)
DASM 3 CHARACTER REAL(8)

1For the first argument.
2The value must be stored in register $0 by the user code.
3The value must be stored in register $F0 by the user code.

Examples

Consider the following:


! Concatenation is recommended for clarity. 
! Notice that ";" separates instructions. 
! 
 nine=9 
 
 type *, asm('addq %0, $17, $0;'//     ! Adds the first two arguments 
     1    'ldq $22, %6;'//             !   and puts the answer in 
     1    'ldq $23, %7;'//             !   register $0 
     1    'ldq $24, %8;'//             ! 
     1    'mov $0, %fp;'//             ! Comments are not allowed in the 
     1    'addq $18, %fp, $0;'//       !   constant, but are allowed here 
     1    'addq $19, $0, $0;'// 
     1    'addq $20, $0, $0;'// 
     1    'addq $21, $0, $0;'// 
     1    'addq $22, $0, $0;'// 
     1    'addq $23, $0, $0;'// 
     1    'addq $24, $0, $0;', 
     1 1,2,3,4,5,6,7,8,nine)           ! The actual arguments to the 
                                       !   ASM (usually by value) 
 end 

This example shows an integer ASM function that adds up 9 values and returns the sum as its result. Note that the user stores the function result in register $0.

All arguments are passed by value. The arguments not passed in registers can be named %6, %7, and %8, which correspond to the actual arguments 7, 8, and 9 (since %0 is the first argument). Notice that you can reference reserved registers like %fp.

The compiler creates the appropriate argument list. So, in this example, the first argument value (1) will be available in register $16, and the eighth argument value (8) will be available in %7, which is actually 8($30).

9.4.16 ASSOCIATED (POINTER [,TARGET])

Description: Returns the association status of its pointer argument or indicates whether the pointer is associated with the target.
Class: Inquiry function; Generic
Arguments: POINTER Must be a pointer (of any data type).
  TARGET (opt) Must be a pointer or target.
  The pointer (in POINTER or TARGET) must not have an association status that is undefined.
Results: The result is a scalar of type default logical.

If only POINTER appears, the result is true if it is currently associated with a target; otherwise, the result is false.

If TARGET also appears and is a target, the result is true if POINTER is currently associated with TARGET; otherwise, the result is false.

If TARGET is a pointer, the result is true if both POINTER and TARGET are currently associated with the same target; otherwise, the result is false. (If either POINTER or TARGET is disassociated, the result is false.)

The setting of compiler options specifying integer size can affect this function.

Examples

Consider the following:


   REAL, TARGET, DIMENSION (0:50) :: TAR 
   REAL, POINTER, DIMENSION (:) :: PTR 
   PTR => TAR 
   PRINT *, ASSOCIATED (PTR, TAR)     ! Returns the value true 

The subscript range for PTR is 0:50. Consider the following pointer assignment statements:


   (1) PTR => TAR (:) 
   (2) PTR => TAR (0:50) 
   (3) PTR => TAR (0:49) 

For statements 1 and 2, ASSOCIATED (PTR, TAR) is true because TAR has not changed (the subscript range for PTR in both cases is 1:51, following the rules for deferred-shape arrays). For statement 3, ASSOCIATED (PTR, TAR) is false because the upper bound of PTR has changed.

Consider the following:


   REAL, POINTER, DIMENSION (:) :: PTR2, PTR3 
   ALLOCATE (PTR2 (0:15)) 
   PTR3 => PTR2 
   PRINT *, ASSOCIATED (PTR2, PTR3)   ! Returns the value true 
   ... 
   NULLIFY (PTR2) 
   NULLIFY (PTR3) 
   PRINT *, ASSOCIATED (PTR2, PTR3)   ! Returns the value false 


Previous Next Contents Index