ALIGNX(K,M) (IBM extension)

Purpose

The ALIGNX built-in subroutine enables you to assert the alignment of a variable at a certain point in the program flow. Specifically, at the call point to ALIGNX, you can assert that the remainder from dividing the address of the second argument by the value of the first argument is zero. In case the second argument is a Fortran 90 pointer, the assertion refers to the address of the target. In case the second argument is an integer pointer, the assertion refers to the address of the pointee. Should you give the compiler incorrect alignment, the resulting program may not run correctly if alignment-sensitive instructions are either executed (such as VMX operations) or inserted by the optimizer.

Class

Subroutine

Argument type and attributes

K
An INTENT(IN) INTEGER(4). The actual argument corresponding to K must be a positive constant expression with a value that is a power of two.
M
A variable of any type. When the actual argument corresponding to M is a Fortran 90 pointer, the pointer must be associated.

Examples

INTEGER*4 B(200)
  DO N=1, 200
    CALL ALIGNX(4, B(N))   !ASSERTS THAT AT THIS POINT,
    B(N) = N               !B(N) IS 4-BYTE ALIGNED
  END DO
END


SUBROUTINE VEC(A, B, C)
  INTEGER A(200), B(200), C(200)
  CALL ALIGNX(16, A(1))
  CALL ALIGNX(16, B(1))
  CALL ALIGNX(16, C(1))
  DO N = 1, 200
    C(N) = A(N) + B(N)
  END DO
END SUBROUTINE