IBM Extension

ALIGNX(K,M)

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.

Class

Subroutine

Argument type and attributes

K
is an INTEGER(4) positive constant expression whose value is a power of two.
M
is a variable of any type. When 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
End of IBM Extension