B.4.1 Initialize_Logical Procedure

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

  subroutine Initialize_Logical_0 (L, status)

    ! Use association information.

    use Caesar_Flags_Module, only: initialize_logical_flag

    ! Output variables.

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

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

    ! Verify requirements - none.

    ! Initialize.

    L = initialize_logical_flag

    ! No errors for initialization possible for scalars.

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

    ! Verify guarantees - none.

    return
  end subroutine Initialize_Logical_0

  define([REPLICATE_ROUTINE],[
    subroutine Initialize_Logical_$1 (L REP_ARGS([dim[]i]), status)
  
      ! Use association information.
  
      use Caesar_Flags_Module, only: initialize_logical_flag
  
      ! Input variables.
  
      REP_DECLARE([type(integer), intent(in)], [dim[]i])  ! Array dimensions.
  
      ! Input/Output variable.
  
      type(logical,$1) :: L            ! 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(L), 0)   ! L starts out unassociated.
      ])

      ! Allocation (for arrays only).
      
      REP_ALLOCATE([L], [dim[]i], [allocate_status])
  
      ! Initialize.
  
      L = initialize_logical_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(L),3)     ! L is now associated.
        if (allocate_status == 0 .and. ASSOCIATED(L)) then
          status = 'Success'
        else
          status = 'Memory Error'
        end if
      else
        VERIFY(allocate_status == 0, 0)  ! Allocation error check.
        VERIFY(ASSOCIATED(L),0)          ! L is now associated.
      end if
  
      return
    end subroutine Initialize_Logical_$1
  ])

  REPLICATE_ARRAYS



Michael L. Hall