B.3.1 Initialize_Integer Procedure

The main documentation of the Initialize_Integer Procedure contains additional explanation of this code listing.

  subroutine Initialize_Integer_0 (I, status)

    ! Use association information.

    use Caesar_Flags_Module, only: initialize_integer_flag

    ! Output variables.

    type(integer), intent(out) :: I     ! Variable to be initialized.
    type(Status_type), intent(out), optional :: status ! Exit status.

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ! Verify requirements - none.

    ! Initialize to flag value.

    I = initialize_integer_flag

    ! No errors for initialization possible for scalars.

    if (PRESENT(status)) status = 'Success'

    ! Verify guarantees - none.

    return
  end subroutine Initialize_Integer_0

  define([REPLICATE_ROUTINE],[
    subroutine Initialize_Integer_$1 (I REP_ARGS([dim[]i]), status)
  
      ! Use association information.
  
      use Caesar_Flags_Module, only: initialize_integer_flag
  
      ! Input variables.
  
      REP_DECLARE([type(integer), intent(in)], [dim[]i]) ! Array dimensions.
  
      ! Input/Output variable.
  
      type(integer,$1) :: I            ! Variable to be initialized.
  
      ! Output variable.
  
      type(Status_type), intent(out), optional :: status  ! Exit status.
  
      ! Internal variable.
  
      type(integer) :: allocate_status ! Allocation Status.
  
      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
      ! Verify requirements.

      ! The association status of a unallocated pointer is officially 
      ! undefined according to the Fortran standard. With most compilers,
      ! the status is unassociated.
      ifelse(COMPILER, NAGWare,
        [], [
        VERIFY(.not.ASSOCIATED(I), 0)   ! I starts out unassociated.
      ])
  
      ! Allocation (for arrays only).
      
      REP_ALLOCATE([I], [dim[]i], [allocate_status])
  
      ! Initialize to flag value.
  
      I = initialize_integer_flag
  
      ! Verify guarantees and/or set status flag.
  
      if (PRESENT(status)) then
        WARN_IF(allocate_status /= 0, 3)  ! Allocation error check.
        WARN_IF(.not.ASSOCIATED(I),3)     ! I is now associated.
        if (allocate_status == 0 .and. ASSOCIATED(I)) then
          status = 'Success'
        else
          status = 'Memory Error'
        end if
      else
        VERIFY(allocate_status == 0, 0)  ! Allocation error check.
        VERIFY(ASSOCIATED(I),0)          ! I is now associated.
      end if
  
      return
    end subroutine Initialize_Integer_$1
  ])

  REPLICATE_ARRAYS



Michael L. Hall